From 057e88ecfc1f86e9153915cfb49d0838ef8f4d5a Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 16 Oct 2025 13:57:34 -0700 Subject: [PATCH 001/112] Move feature patches --- .../0001-Moonrise-optimisation-patches.patch | 0 .../0002-Rewrite-dataconverter-system.patch | 0 ...003-Optimize-Network-Manager-and-add-advanced-packet-sup.patch | 0 .../0004-Allow-Saving-of-Oversized-Chunks.patch | 0 .../0005-Entity-Activation-Range-2.0.patch | 0 .../0006-Use-Velocity-compression-and-cipher-natives.patch | 0 .../0007-Optimize-GoalSelector-Goal.Flag-Set-operations.patch | 0 .../0008-Optimize-Voxel-Shape-Merging.patch | 0 .../0009-Handle-Oversized-block-entities-in-chunks.patch | 0 .../0010-optimize-dirt-and-snow-spreading.patch | 0 .../0011-Optimize-Bit-Operations-by-inlining.patch | 0 .../0012-Remove-streams-from-hot-code.patch | 0 ...013-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch | 0 ...014-Fix-entity-tracker-desync-when-new-players-are-added.patch | 0 .../0015-Eigencraft-redstone-implementation.patch | 0 .../0016-Add-Alternate-Current-redstone-implementation.patch | 0 .../0017-Improve-exact-choice-recipe-ingredients.patch | 0 ...018-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch | 0 .../0019-Entity-load-save-limit-per-chunk.patch | 0 ...020-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch | 0 .../0021-Incremental-chunk-and-player-saving.patch | 0 .../0022-Optimise-general-POI-access.patch | 0 .../0023-Flush-regionfiles-on-save-configuration-option.patch | 0 ...024-Optimise-collision-checking-in-player-move-packet-ha.patch | 0 .../0025-Improve-keepalive-ping-system.patch | 0 .../0026-Optimise-EntityScheduler-ticking.patch | 0 .../0027-Optional-per-player-mob-spawns.patch | 0 ...028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch | 0 .../{features => features-unapplied}/0029-Optimize-Hoppers.patch | 0 .../patches/{features => features-unapplied}/0030-Anti-Xray.patch | 0 .../0031-DataConverter-Fixes.patch | 0 31 files changed, 0 insertions(+), 0 deletions(-) rename paper-server/patches/{features => features-unapplied}/0001-Moonrise-optimisation-patches.patch (100%) rename paper-server/patches/{features => features-unapplied}/0002-Rewrite-dataconverter-system.patch (100%) rename paper-server/patches/{features => features-unapplied}/0003-Optimize-Network-Manager-and-add-advanced-packet-sup.patch (100%) rename paper-server/patches/{features => features-unapplied}/0004-Allow-Saving-of-Oversized-Chunks.patch (100%) rename paper-server/patches/{features => features-unapplied}/0005-Entity-Activation-Range-2.0.patch (100%) rename paper-server/patches/{features => features-unapplied}/0006-Use-Velocity-compression-and-cipher-natives.patch (100%) rename paper-server/patches/{features => features-unapplied}/0007-Optimize-GoalSelector-Goal.Flag-Set-operations.patch (100%) rename paper-server/patches/{features => features-unapplied}/0008-Optimize-Voxel-Shape-Merging.patch (100%) rename paper-server/patches/{features => features-unapplied}/0009-Handle-Oversized-block-entities-in-chunks.patch (100%) rename paper-server/patches/{features => features-unapplied}/0010-optimize-dirt-and-snow-spreading.patch (100%) rename paper-server/patches/{features => features-unapplied}/0011-Optimize-Bit-Operations-by-inlining.patch (100%) rename paper-server/patches/{features => features-unapplied}/0012-Remove-streams-from-hot-code.patch (100%) rename paper-server/patches/{features => features-unapplied}/0013-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch (100%) rename paper-server/patches/{features => features-unapplied}/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch (100%) rename paper-server/patches/{features => features-unapplied}/0015-Eigencraft-redstone-implementation.patch (100%) rename paper-server/patches/{features => features-unapplied}/0016-Add-Alternate-Current-redstone-implementation.patch (100%) rename paper-server/patches/{features => features-unapplied}/0017-Improve-exact-choice-recipe-ingredients.patch (100%) rename paper-server/patches/{features => features-unapplied}/0018-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch (100%) rename paper-server/patches/{features => features-unapplied}/0019-Entity-load-save-limit-per-chunk.patch (100%) rename paper-server/patches/{features => features-unapplied}/0020-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch (100%) rename paper-server/patches/{features => features-unapplied}/0021-Incremental-chunk-and-player-saving.patch (100%) rename paper-server/patches/{features => features-unapplied}/0022-Optimise-general-POI-access.patch (100%) rename paper-server/patches/{features => features-unapplied}/0023-Flush-regionfiles-on-save-configuration-option.patch (100%) rename paper-server/patches/{features => features-unapplied}/0024-Optimise-collision-checking-in-player-move-packet-ha.patch (100%) rename paper-server/patches/{features => features-unapplied}/0025-Improve-keepalive-ping-system.patch (100%) rename paper-server/patches/{features => features-unapplied}/0026-Optimise-EntityScheduler-ticking.patch (100%) rename paper-server/patches/{features => features-unapplied}/0027-Optional-per-player-mob-spawns.patch (100%) rename paper-server/patches/{features => features-unapplied}/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch (100%) rename paper-server/patches/{features => features-unapplied}/0029-Optimize-Hoppers.patch (100%) rename paper-server/patches/{features => features-unapplied}/0030-Anti-Xray.patch (100%) rename paper-server/patches/{features => features-unapplied}/0031-DataConverter-Fixes.patch (100%) diff --git a/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch b/paper-server/patches/features-unapplied/0001-Moonrise-optimisation-patches.patch similarity index 100% rename from paper-server/patches/features/0001-Moonrise-optimisation-patches.patch rename to paper-server/patches/features-unapplied/0001-Moonrise-optimisation-patches.patch diff --git a/paper-server/patches/features/0002-Rewrite-dataconverter-system.patch b/paper-server/patches/features-unapplied/0002-Rewrite-dataconverter-system.patch similarity index 100% rename from paper-server/patches/features/0002-Rewrite-dataconverter-system.patch rename to paper-server/patches/features-unapplied/0002-Rewrite-dataconverter-system.patch diff --git a/paper-server/patches/features/0003-Optimize-Network-Manager-and-add-advanced-packet-sup.patch b/paper-server/patches/features-unapplied/0003-Optimize-Network-Manager-and-add-advanced-packet-sup.patch similarity index 100% rename from paper-server/patches/features/0003-Optimize-Network-Manager-and-add-advanced-packet-sup.patch rename to paper-server/patches/features-unapplied/0003-Optimize-Network-Manager-and-add-advanced-packet-sup.patch diff --git a/paper-server/patches/features/0004-Allow-Saving-of-Oversized-Chunks.patch b/paper-server/patches/features-unapplied/0004-Allow-Saving-of-Oversized-Chunks.patch similarity index 100% rename from paper-server/patches/features/0004-Allow-Saving-of-Oversized-Chunks.patch rename to paper-server/patches/features-unapplied/0004-Allow-Saving-of-Oversized-Chunks.patch diff --git a/paper-server/patches/features/0005-Entity-Activation-Range-2.0.patch b/paper-server/patches/features-unapplied/0005-Entity-Activation-Range-2.0.patch similarity index 100% rename from paper-server/patches/features/0005-Entity-Activation-Range-2.0.patch rename to paper-server/patches/features-unapplied/0005-Entity-Activation-Range-2.0.patch diff --git a/paper-server/patches/features/0006-Use-Velocity-compression-and-cipher-natives.patch b/paper-server/patches/features-unapplied/0006-Use-Velocity-compression-and-cipher-natives.patch similarity index 100% rename from paper-server/patches/features/0006-Use-Velocity-compression-and-cipher-natives.patch rename to paper-server/patches/features-unapplied/0006-Use-Velocity-compression-and-cipher-natives.patch diff --git a/paper-server/patches/features/0007-Optimize-GoalSelector-Goal.Flag-Set-operations.patch b/paper-server/patches/features-unapplied/0007-Optimize-GoalSelector-Goal.Flag-Set-operations.patch similarity index 100% rename from paper-server/patches/features/0007-Optimize-GoalSelector-Goal.Flag-Set-operations.patch rename to paper-server/patches/features-unapplied/0007-Optimize-GoalSelector-Goal.Flag-Set-operations.patch diff --git a/paper-server/patches/features/0008-Optimize-Voxel-Shape-Merging.patch b/paper-server/patches/features-unapplied/0008-Optimize-Voxel-Shape-Merging.patch similarity index 100% rename from paper-server/patches/features/0008-Optimize-Voxel-Shape-Merging.patch rename to paper-server/patches/features-unapplied/0008-Optimize-Voxel-Shape-Merging.patch diff --git a/paper-server/patches/features/0009-Handle-Oversized-block-entities-in-chunks.patch b/paper-server/patches/features-unapplied/0009-Handle-Oversized-block-entities-in-chunks.patch similarity index 100% rename from paper-server/patches/features/0009-Handle-Oversized-block-entities-in-chunks.patch rename to paper-server/patches/features-unapplied/0009-Handle-Oversized-block-entities-in-chunks.patch diff --git a/paper-server/patches/features/0010-optimize-dirt-and-snow-spreading.patch b/paper-server/patches/features-unapplied/0010-optimize-dirt-and-snow-spreading.patch similarity index 100% rename from paper-server/patches/features/0010-optimize-dirt-and-snow-spreading.patch rename to paper-server/patches/features-unapplied/0010-optimize-dirt-and-snow-spreading.patch diff --git a/paper-server/patches/features/0011-Optimize-Bit-Operations-by-inlining.patch b/paper-server/patches/features-unapplied/0011-Optimize-Bit-Operations-by-inlining.patch similarity index 100% rename from paper-server/patches/features/0011-Optimize-Bit-Operations-by-inlining.patch rename to paper-server/patches/features-unapplied/0011-Optimize-Bit-Operations-by-inlining.patch diff --git a/paper-server/patches/features/0012-Remove-streams-from-hot-code.patch b/paper-server/patches/features-unapplied/0012-Remove-streams-from-hot-code.patch similarity index 100% rename from paper-server/patches/features/0012-Remove-streams-from-hot-code.patch rename to paper-server/patches/features-unapplied/0012-Remove-streams-from-hot-code.patch diff --git a/paper-server/patches/features/0013-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch b/paper-server/patches/features-unapplied/0013-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch similarity index 100% rename from paper-server/patches/features/0013-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch rename to paper-server/patches/features-unapplied/0013-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch diff --git a/paper-server/patches/features/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch b/paper-server/patches/features-unapplied/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch similarity index 100% rename from paper-server/patches/features/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch rename to paper-server/patches/features-unapplied/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch diff --git a/paper-server/patches/features/0015-Eigencraft-redstone-implementation.patch b/paper-server/patches/features-unapplied/0015-Eigencraft-redstone-implementation.patch similarity index 100% rename from paper-server/patches/features/0015-Eigencraft-redstone-implementation.patch rename to paper-server/patches/features-unapplied/0015-Eigencraft-redstone-implementation.patch diff --git a/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch b/paper-server/patches/features-unapplied/0016-Add-Alternate-Current-redstone-implementation.patch similarity index 100% rename from paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch rename to paper-server/patches/features-unapplied/0016-Add-Alternate-Current-redstone-implementation.patch diff --git a/paper-server/patches/features/0017-Improve-exact-choice-recipe-ingredients.patch b/paper-server/patches/features-unapplied/0017-Improve-exact-choice-recipe-ingredients.patch similarity index 100% rename from paper-server/patches/features/0017-Improve-exact-choice-recipe-ingredients.patch rename to paper-server/patches/features-unapplied/0017-Improve-exact-choice-recipe-ingredients.patch diff --git a/paper-server/patches/features/0018-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch b/paper-server/patches/features-unapplied/0018-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch similarity index 100% rename from paper-server/patches/features/0018-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch rename to paper-server/patches/features-unapplied/0018-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch diff --git a/paper-server/patches/features/0019-Entity-load-save-limit-per-chunk.patch b/paper-server/patches/features-unapplied/0019-Entity-load-save-limit-per-chunk.patch similarity index 100% rename from paper-server/patches/features/0019-Entity-load-save-limit-per-chunk.patch rename to paper-server/patches/features-unapplied/0019-Entity-load-save-limit-per-chunk.patch diff --git a/paper-server/patches/features/0020-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/paper-server/patches/features-unapplied/0020-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch similarity index 100% rename from paper-server/patches/features/0020-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch rename to paper-server/patches/features-unapplied/0020-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch diff --git a/paper-server/patches/features/0021-Incremental-chunk-and-player-saving.patch b/paper-server/patches/features-unapplied/0021-Incremental-chunk-and-player-saving.patch similarity index 100% rename from paper-server/patches/features/0021-Incremental-chunk-and-player-saving.patch rename to paper-server/patches/features-unapplied/0021-Incremental-chunk-and-player-saving.patch diff --git a/paper-server/patches/features/0022-Optimise-general-POI-access.patch b/paper-server/patches/features-unapplied/0022-Optimise-general-POI-access.patch similarity index 100% rename from paper-server/patches/features/0022-Optimise-general-POI-access.patch rename to paper-server/patches/features-unapplied/0022-Optimise-general-POI-access.patch diff --git a/paper-server/patches/features/0023-Flush-regionfiles-on-save-configuration-option.patch b/paper-server/patches/features-unapplied/0023-Flush-regionfiles-on-save-configuration-option.patch similarity index 100% rename from paper-server/patches/features/0023-Flush-regionfiles-on-save-configuration-option.patch rename to paper-server/patches/features-unapplied/0023-Flush-regionfiles-on-save-configuration-option.patch diff --git a/paper-server/patches/features/0024-Optimise-collision-checking-in-player-move-packet-ha.patch b/paper-server/patches/features-unapplied/0024-Optimise-collision-checking-in-player-move-packet-ha.patch similarity index 100% rename from paper-server/patches/features/0024-Optimise-collision-checking-in-player-move-packet-ha.patch rename to paper-server/patches/features-unapplied/0024-Optimise-collision-checking-in-player-move-packet-ha.patch diff --git a/paper-server/patches/features/0025-Improve-keepalive-ping-system.patch b/paper-server/patches/features-unapplied/0025-Improve-keepalive-ping-system.patch similarity index 100% rename from paper-server/patches/features/0025-Improve-keepalive-ping-system.patch rename to paper-server/patches/features-unapplied/0025-Improve-keepalive-ping-system.patch diff --git a/paper-server/patches/features/0026-Optimise-EntityScheduler-ticking.patch b/paper-server/patches/features-unapplied/0026-Optimise-EntityScheduler-ticking.patch similarity index 100% rename from paper-server/patches/features/0026-Optimise-EntityScheduler-ticking.patch rename to paper-server/patches/features-unapplied/0026-Optimise-EntityScheduler-ticking.patch diff --git a/paper-server/patches/features/0027-Optional-per-player-mob-spawns.patch b/paper-server/patches/features-unapplied/0027-Optional-per-player-mob-spawns.patch similarity index 100% rename from paper-server/patches/features/0027-Optional-per-player-mob-spawns.patch rename to paper-server/patches/features-unapplied/0027-Optional-per-player-mob-spawns.patch diff --git a/paper-server/patches/features/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch b/paper-server/patches/features-unapplied/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch similarity index 100% rename from paper-server/patches/features/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch rename to paper-server/patches/features-unapplied/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch diff --git a/paper-server/patches/features/0029-Optimize-Hoppers.patch b/paper-server/patches/features-unapplied/0029-Optimize-Hoppers.patch similarity index 100% rename from paper-server/patches/features/0029-Optimize-Hoppers.patch rename to paper-server/patches/features-unapplied/0029-Optimize-Hoppers.patch diff --git a/paper-server/patches/features/0030-Anti-Xray.patch b/paper-server/patches/features-unapplied/0030-Anti-Xray.patch similarity index 100% rename from paper-server/patches/features/0030-Anti-Xray.patch rename to paper-server/patches/features-unapplied/0030-Anti-Xray.patch diff --git a/paper-server/patches/features/0031-DataConverter-Fixes.patch b/paper-server/patches/features-unapplied/0031-DataConverter-Fixes.patch similarity index 100% rename from paper-server/patches/features/0031-DataConverter-Fixes.patch rename to paper-server/patches/features-unapplied/0031-DataConverter-Fixes.patch From c25a855a6ace0bb7a4585fb349f327efb217e4f7 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 16 Oct 2025 13:57:41 -0700 Subject: [PATCH 002/112] Update CONTRIBUTING.md --- CONTRIBUTING.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 89c56883035b..a2811d2b0068 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -192,6 +192,26 @@ and your server. While we will fix minor formatting issues, you should stick to the guide below when making and submitting changes. +### Branches and Minecraft Versions + +Generally, PRs should be targeted at the `main` branch, where active development for +the latest Minecraft release happens. + +If a new Minecraft release is imminent, it may be wise to wait until it's released +and merged to `main` to avoid having to rebase your PR, as the `main` branch will be +frozen during this time (you can ask in the Paper Discord if you're unsure). + +For old Minecraft versions - we are unlikely to accept PRs targeting any versions not +marked as supported at https://fill-ui.papermc.io/projects/paper. + +For snapshots and other pre-release versions - you should only target these branches +for changes specific to features or changes in those versions. For example, if Copper +Golem is going to be added in 1.21.9, you can PR to the relevant dev branch as it would +not make sense to merge that into `main`. Or, if you are fixing a bug that only exists in +a dev branch, you should target that branch. When submitting PRs to dev branches, please +coordinate with the dev team in Discord or open an issue before starting work to ensure +it's an area we want to accept changes for. + ## Formatting All modifications to Vanilla files should be marked. For historical reasons, From fbbefbd2ec9557762a16e8079077cc4f45e03107 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 16 Oct 2025 13:57:51 -0700 Subject: [PATCH 003/112] Initial 25w42a update --- gradle.properties | 6 +- .../paper/entity/ai/VanillaGoal.java | 2 + .../paper/registry/keys/DamageTypeKeys.java | 7 + .../registry/keys/DataComponentTypeKeys.java | 42 ++ .../paper/registry/keys/EnchantmentKeys.java | 7 + .../paper/registry/keys/ItemTypeKeys.java | 98 +++++ .../paper/registry/keys/MobEffectKeys.java | 7 + .../paper/registry/keys/SoundEventKeys.java | 224 +++++++++++ .../registry/keys/tags/BiomeTagKeys.java | 28 -- .../registry/keys/tags/BlockTypeTagKeys.java | 7 + .../registry/keys/tags/EntityTypeTagKeys.java | 21 + .../registry/keys/tags/ItemTypeTagKeys.java | 53 ++- .../com/destroystokyo/paper/MaterialTags.java | 3 +- .../item/consumable/ItemUseAnimation.java | 5 +- .../event/player/PlayerBedFailEnterEvent.java | 6 + .../src/main/java/org/bukkit/Material.java | 14 + paper-api/src/main/java/org/bukkit/Sound.java | 64 ++++ paper-api/src/main/java/org/bukkit/Tag.java | 24 +- .../java/org/bukkit/damage/DamageType.java | 2 + .../enchantments/EnchantmentTarget.java | 4 +- .../org/bukkit/entity/AbstractNautilus.java | 4 + .../java/org/bukkit/entity/EntityType.java | 2 + .../main/java/org/bukkit/entity/Nautilus.java | 4 + .../org/bukkit/entity/ZombieNautilus.java | 4 + .../org/bukkit/entity/memory/MemoryKey.java | 4 + .../event/player/PlayerBedEnterEvent.java | 6 + .../main/java/io/papermc/generator/Main.java | 3 +- .../generator/types/goal/MobGoalNames.java | 3 + paper-server/build.gradle.kts | 8 +- .../mojang/math/OctahedralGroup.java.patch | 6 +- .../commands/CommandSourceStack.java.patch | 34 +- .../minecraft/commands/Commands.java.patch | 33 +- .../commands/PermissionSource.java.patch | 26 -- .../arguments/EntityArgument.java.patch | 14 +- .../arguments/MessageArgument.java.patch | 4 +- .../selector/EntitySelector.java.patch | 6 +- .../selector/EntitySelectorParser.java.patch | 14 +- .../net/minecraft/core/Vec3i.java.patch | 8 +- .../core/component/DataComponents.java.patch | 4 +- .../registries/BuiltInRegistries.java.patch | 10 +- .../loot/packs/VanillaChestLoot.java.patch | 2 +- .../framework/GameTestServer.java.patch | 8 +- .../TestEnvironmentDefinition.java.patch | 4 +- .../network/FriendlyByteBuf.java.patch | 6 +- .../network/chat/ComponentUtils.java.patch | 2 +- .../network/chat/MutableComponent.java.patch | 2 +- .../net/minecraft/server/Main.java.patch | 4 +- .../server/MinecraftServer.java.patch | 142 ++++--- .../ReloadableServerResources.java.patch | 8 +- .../server/ServerFunctionLibrary.java.patch | 2 +- .../server/ServerScoreboard.java.patch | 26 +- .../minecraft/server/WorldLoader.java.patch | 2 +- .../server/commands/DebugCommand.java.patch | 2 +- .../commands/GameRuleCommand.java.patch | 13 +- .../server/commands/ReloadCommand.java.patch | 2 +- .../dedicated/DedicatedServer.java.patch | 48 +-- .../DedicatedServerProperties.java.patch | 8 +- .../JsonRpcNotificationService.java.patch | 2 +- .../MinecraftGameRuleServiceImpl.java.patch | 2 +- .../server/level/ChunkMap.java.patch | 26 +- .../server/level/ServerChunkCache.java.patch | 26 +- .../server/level/ServerEntity.java.patch | 16 +- .../server/level/ServerLevel.java.patch | 98 ++--- .../server/level/ServerPlayer.java.patch | 206 +++++----- .../server/level/TicketType.java.patch | 9 +- .../server/level/WorldGenRegion.java.patch | 16 +- .../ServerGamePacketListenerImpl.java.patch | 185 ++++----- .../ServerLoginPacketListenerImpl.java.patch | 32 +- .../EmptyNotificationService.java.patch | 2 +- .../NotificationManager.java.patch | 2 +- .../NotificationService.java.patch | 2 +- .../PermissionProviderCheck.java.patch | 25 ++ .../server/players/PlayerList.java.patch | 65 ++-- .../server/rcon/RconConsoleSource.java.patch | 6 +- .../ServerWaypointManager.java.patch | 11 - .../util/datafix/DataFixers.java.patch | 2 +- .../util/worldupdate/WorldUpgrader.java.patch | 4 +- .../world/effect/MobEffectUtil.java.patch | 2 +- .../minecraft/world/entity/Entity.java.patch | 193 +++++----- .../world/entity/EntityType.java.patch | 12 +- .../world/entity/LightningBolt.java.patch | 37 +- .../world/entity/LivingEntity.java.patch | 175 +++++---- .../net/minecraft/world/entity/Mob.java.patch | 47 +-- .../world/entity/NeutralMob.java.patch | 26 +- .../ai/attributes/Attributes.java.patch | 6 +- .../world/entity/animal/Cat.java.patch | 4 +- .../world/entity/animal/Fox.java.patch | 14 +- .../world/entity/animal/SnowGolem.java.patch | 2 +- .../entity/animal/frog/Tadpole.java.patch | 2 +- .../animal/horse/AbstractHorse.java.patch | 14 +- .../monster/AbstractSkeleton.java.patch | 24 +- .../world/entity/monster/Drowned.java.patch | 2 +- .../world/entity/monster/Husk.java.patch | 2 +- .../world/entity/monster/Phantom.java.patch | 25 +- .../world/entity/monster/Slime.java.patch | 33 +- .../world/entity/monster/Zombie.java.patch | 32 +- .../entity/monster/ZombifiedPiglin.java.patch | 16 +- .../monster/creaking/Creaking.java.patch | 2 +- .../entity/monster/hoglin/Hoglin.java.patch | 2 +- .../monster/piglin/AbstractPiglin.java.patch | 2 +- .../entity/monster/piglin/Piglin.java.patch | 4 +- .../entity/npc/AbstractVillager.java.patch | 14 +- .../world/entity/npc/Villager.java.patch | 38 +- .../entity/npc/VillagerTrades.java.patch | 18 +- .../world/entity/player/Player.java.patch | 360 +++++++++--------- .../projectile/AbstractArrow.java.patch | 45 ++- .../world/entity/raid/Raid.java.patch | 28 +- .../world/entity/raid/Raids.java.patch | 50 +-- .../vehicle/MinecartCommandBlock.java.patch | 26 +- .../vehicle/NewMinecartBehavior.java.patch | 10 +- .../minecraft/world/item/BlockItem.java.patch | 10 +- .../world/item/BucketItem.java.patch | 14 +- .../minecraft/world/item/ItemStack.java.patch | 18 +- .../world/item/SpawnEggItem.java.patch | 6 +- .../world/level/BaseCommandBlock.java.patch | 36 +- .../world/level/BaseSpawner.java.patch | 2 +- .../minecraft/world/level/Level.java.patch | 18 +- .../world/level/LevelAccessor.java.patch | 2 +- .../world/level/LevelReader.java.patch | 2 +- .../world/level/LevelWriter.java.patch | 2 +- .../level/ServerLevelAccessor.java.patch | 4 +- .../world/level/block/BedBlock.java.patch | 30 +- .../world/level/block/Block.java.patch | 12 +- .../level/block/ComposterBlock.java.patch | 2 +- .../block/CopperGolemStatueBlock.java.patch | 2 +- .../world/level/block/FireBlock.java.patch | 4 +- .../world/level/block/IceBlock.java.patch | 17 +- .../level/block/NetherPortalBlock.java.patch | 18 +- .../block/PointedDripstoneBlock.java.patch | 10 +- .../level/block/RespawnAnchorBlock.java.patch | 36 +- .../level/block/TurtleEggBlock.java.patch | 2 +- .../entity/CommandBlockEntity.java.patch | 17 +- .../entity/JukeboxBlockEntity.java.patch | 4 +- .../entity/LecternBlockEntity.java.patch | 20 +- .../block/entity/SignBlockEntity.java.patch | 19 +- .../level/chunk/EmptyLevelChunk.java.patch | 4 +- .../level/levelgen/PatrolSpawner.java.patch | 12 +- .../StructureTemplate.java.patch | 18 +- .../world/level/material/LavaFluid.java.patch | 10 +- .../storage/DimensionDataStorage.java.patch | 4 +- .../world/scores/Scoreboard.java.patch | 11 + .../scores/ScoreboardSaveData.java.patch | 11 - .../paper/entity/ai/MobGoalHelper.java | 3 + .../paper/PaperServerInternalAPIBridge.java | 4 +- .../command/brigadier/PaperBrigadier.java | 3 +- .../commands/FeedbackForwardingSender.java | 4 +- .../paper/util/PaperScoreboardFormat.java | 4 +- .../craftbukkit/CraftRegionAccessor.java | 3 +- .../org/bukkit/craftbukkit/CraftWorld.java | 20 +- .../command/VanillaCommandWrapper.java | 3 +- .../entity/CraftAbstractNautilus.java | 15 + .../bukkit/craftbukkit/entity/CraftBee.java | 4 +- .../craftbukkit/entity/CraftDisplay.java | 4 +- .../craftbukkit/entity/CraftEntityTypes.java | 4 + .../entity/CraftMinecartCommand.java | 3 +- .../craftbukkit/entity/CraftNautilus.java | 15 + .../craftbukkit/entity/CraftPigZombie.java | 4 +- .../craftbukkit/entity/CraftPlayer.java | 6 +- .../craftbukkit/entity/CraftVillager.java | 3 +- .../entity/CraftZombieNautilus.java | 15 + .../craftbukkit/event/CraftEventFactory.java | 46 ++- .../util/DelegatedGeneratorAccess.java | 9 +- .../util/DummyGeneratorAccess.java | 6 + .../util/permissions/CommandPermissions.java | 1 + .../datacomponent/DataComponentTypesTest.java | 1 + .../craftbukkit/entity/EntityTypesTest.java | 4 +- .../bukkit/craftbukkit/legacy/LegacyTest.java | 3 + .../org/bukkit/support/RegistryHelper.java | 3 +- todo-snapshot.txt | 3 + 169 files changed, 2205 insertions(+), 1471 deletions(-) create mode 100644 paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java create mode 100644 paper-api/src/main/java/org/bukkit/entity/Nautilus.java create mode 100644 paper-api/src/main/java/org/bukkit/entity/ZombieNautilus.java delete mode 100644 paper-server/patches/sources/net/minecraft/commands/PermissionSource.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/server/permissions/PermissionProviderCheck.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/server/waypoints/ServerWaypointManager.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/world/scores/ScoreboardSaveData.java.patch create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftNautilus.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java create mode 100644 todo-snapshot.txt diff --git a/gradle.properties b/gradle.properties index 4dbf5fe9db7e..5911e180da2a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ group=io.papermc.paper -version=1.21.10-R0.1-SNAPSHOT -mcVersion=1.21.10 +version=25w42a-R0.1-SNAPSHOT +mcVersion=25w42a # Set to true while updating Minecraft version -updatingMinecraft=false +updatingMinecraft=true org.gradle.configuration-cache=true org.gradle.caching=true diff --git a/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java index a2a80b85d281..1cde924756ae 100644 --- a/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java +++ b/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java @@ -298,6 +298,8 @@ public interface VanillaGoal extends Goal { GoalKey RANGED_CROSSBOW_ATTACK = create("ranged_crossbow_attack", Monster.class); + GoalKey SPEAR_USE = create("spear_use", Monster.class); + GoalKey OCELOT_AVOID_ENTITY = create("ocelot_avoid_entity", Ocelot.class); GoalKey OCELOT_TEMPT = create("ocelot_tempt", Ocelot.class); diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DamageTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DamageTypeKeys.java index e2969894b0bf..5e878a9384df 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DamageTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DamageTypeKeys.java @@ -284,6 +284,13 @@ public final class DamageTypeKeys { */ public static final TypedKey SONIC_BOOM = create(key("sonic_boom")); + /** + * {@code minecraft:spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SPEAR = create(key("spear")); + /** * {@code minecraft:spit} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java index bec9a32fcc91..e082492f24ed 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java @@ -214,6 +214,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey DAMAGE_RESISTANT = create(key("damage_resistant")); + /** + * {@code minecraft:damage_type} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DAMAGE_TYPE = create(key("damage_type")); + /** * {@code minecraft:death_protection} * @@ -354,6 +361,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey JUKEBOX_PLAYABLE = create(key("jukebox_playable")); + /** + * {@code minecraft:kinetic_weapon} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey KINETIC_WEAPON = create(key("kinetic_weapon")); + /** * {@code minecraft:llama/variant} * @@ -424,6 +438,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey MAX_STACK_SIZE = create(key("max_stack_size")); + /** + * {@code minecraft:minimum_attack_charge} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MINIMUM_ATTACK_CHARGE = create(key("minimum_attack_charge")); + /** * {@code minecraft:mooshroom/variant} * @@ -459,6 +480,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey PARROT_VARIANT = create(key("parrot/variant")); + /** + * {@code minecraft:piercing_weapon} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PIERCING_WEAPON = create(key("piercing_weapon")); + /** * {@code minecraft:pig/variant} * @@ -578,6 +606,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey SUSPICIOUS_STEW_EFFECTS = create(key("suspicious_stew_effects")); + /** + * {@code minecraft:swing_animation} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SWING_ANIMATION = create(key("swing_animation")); + /** * {@code minecraft:tool} * @@ -641,6 +676,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey USE_COOLDOWN = create(key("use_cooldown")); + /** + * {@code minecraft:use_effects} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey USE_EFFECTS = create(key("use_effects")); + /** * {@code minecraft:use_remainder} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/EnchantmentKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/EnchantmentKeys.java index 69841708a839..f58723783bb3 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/EnchantmentKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/EnchantmentKeys.java @@ -172,6 +172,13 @@ public final class EnchantmentKeys { */ public static final TypedKey LUCK_OF_THE_SEA = create(key("luck_of_the_sea")); + /** + * {@code minecraft:lunge} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LUNGE = create(key("lunge")); + /** * {@code minecraft:lure} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java index f5fd056c76c6..096a5a83730e 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java @@ -2139,6 +2139,13 @@ public final class ItemTypeKeys { */ public static final TypedKey COPPER_LEGGINGS = create(key("copper_leggings")); + /** + * {@code minecraft:copper_nautilus_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey COPPER_NAUTILUS_ARMOR = create(key("copper_nautilus_armor")); + /** * {@code minecraft:copper_nugget} * @@ -2167,6 +2174,13 @@ public final class ItemTypeKeys { */ public static final TypedKey COPPER_SHOVEL = create(key("copper_shovel")); + /** + * {@code minecraft:copper_spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey COPPER_SPEAR = create(key("copper_spear")); + /** * {@code minecraft:copper_sword} * @@ -3063,6 +3077,13 @@ public final class ItemTypeKeys { */ public static final TypedKey DIAMOND_LEGGINGS = create(key("diamond_leggings")); + /** + * {@code minecraft:diamond_nautilus_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DIAMOND_NAUTILUS_ARMOR = create(key("diamond_nautilus_armor")); + /** * {@code minecraft:diamond_ore} * @@ -3084,6 +3105,13 @@ public final class ItemTypeKeys { */ public static final TypedKey DIAMOND_SHOVEL = create(key("diamond_shovel")); + /** + * {@code minecraft:diamond_spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DIAMOND_SPEAR = create(key("diamond_spear")); + /** * {@code minecraft:diamond_sword} * @@ -3952,6 +3980,13 @@ public final class ItemTypeKeys { */ public static final TypedKey GOLDEN_LEGGINGS = create(key("golden_leggings")); + /** + * {@code minecraft:golden_nautilus_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GOLDEN_NAUTILUS_ARMOR = create(key("golden_nautilus_armor")); + /** * {@code minecraft:golden_pickaxe} * @@ -3966,6 +4001,13 @@ public final class ItemTypeKeys { */ public static final TypedKey GOLDEN_SHOVEL = create(key("golden_shovel")); + /** + * {@code minecraft:golden_spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GOLDEN_SPEAR = create(key("golden_spear")); + /** * {@code minecraft:golden_sword} * @@ -4568,6 +4610,13 @@ public final class ItemTypeKeys { */ public static final TypedKey IRON_LEGGINGS = create(key("iron_leggings")); + /** + * {@code minecraft:iron_nautilus_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey IRON_NAUTILUS_ARMOR = create(key("iron_nautilus_armor")); + /** * {@code minecraft:iron_nugget} * @@ -4596,6 +4645,13 @@ public final class ItemTypeKeys { */ public static final TypedKey IRON_SHOVEL = create(key("iron_shovel")); + /** + * {@code minecraft:iron_spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey IRON_SPEAR = create(key("iron_spear")); + /** * {@code minecraft:iron_sword} * @@ -5940,6 +5996,13 @@ public final class ItemTypeKeys { */ public static final TypedKey NAUTILUS_SHELL = create(key("nautilus_shell")); + /** + * {@code minecraft:nautilus_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey NAUTILUS_SPAWN_EGG = create(key("nautilus_spawn_egg")); + /** * {@code minecraft:nether_brick} * @@ -6080,6 +6143,13 @@ public final class ItemTypeKeys { */ public static final TypedKey NETHERITE_LEGGINGS = create(key("netherite_leggings")); + /** + * {@code minecraft:netherite_nautilus_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey NETHERITE_NAUTILUS_ARMOR = create(key("netherite_nautilus_armor")); + /** * {@code minecraft:netherite_pickaxe} * @@ -6101,6 +6171,13 @@ public final class ItemTypeKeys { */ public static final TypedKey NETHERITE_SHOVEL = create(key("netherite_shovel")); + /** + * {@code minecraft:netherite_spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey NETHERITE_SPEAR = create(key("netherite_spear")); + /** * {@code minecraft:netherite_sword} * @@ -8733,6 +8810,13 @@ public final class ItemTypeKeys { */ public static final TypedKey STONE_SLAB = create(key("stone_slab")); + /** + * {@code minecraft:stone_spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey STONE_SPEAR = create(key("stone_spear")); + /** * {@code minecraft:stone_stairs} * @@ -10273,6 +10357,13 @@ public final class ItemTypeKeys { */ public static final TypedKey WOODEN_SHOVEL = create(key("wooden_shovel")); + /** + * {@code minecraft:wooden_spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WOODEN_SPEAR = create(key("wooden_spear")); + /** * {@code minecraft:wooden_sword} * @@ -10420,6 +10511,13 @@ public final class ItemTypeKeys { */ public static final TypedKey ZOMBIE_HORSE_SPAWN_EGG = create(key("zombie_horse_spawn_egg")); + /** + * {@code minecraft:zombie_nautilus_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ZOMBIE_NAUTILUS_SPAWN_EGG = create(key("zombie_nautilus_spawn_egg")); + /** * {@code minecraft:zombie_spawn_egg} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/MobEffectKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/MobEffectKeys.java index 7a4c53968010..7059e3566a5e 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/MobEffectKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/MobEffectKeys.java @@ -46,6 +46,13 @@ public final class MobEffectKeys { */ public static final TypedKey BLINDNESS = create(key("blindness")); + /** + * {@code minecraft:breath_of_the_nautilus} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BREATH_OF_THE_NAUTILUS = create(key("breath_of_the_nautilus")); + /** * {@code minecraft:conduit_power} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java index 5608b4fe02ac..d036d41bcaed 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java @@ -6031,6 +6031,41 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_AXOLOTL_SWIM = create(key("entity.axolotl.swim")); + /** + * {@code minecraft:entity.baby_nautilus.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_AMBIENT = create(key("entity.baby_nautilus.ambient")); + + /** + * {@code minecraft:entity.baby_nautilus.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_DEATH = create(key("entity.baby_nautilus.death")); + + /** + * {@code minecraft:entity.baby_nautilus.eat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_EAT = create(key("entity.baby_nautilus.eat")); + + /** + * {@code minecraft:entity.baby_nautilus.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_HURT = create(key("entity.baby_nautilus.hurt")); + + /** + * {@code minecraft:entity.baby_nautilus.swim} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_SWIM = create(key("entity.baby_nautilus.swim")); + /** * {@code minecraft:entity.bat.ambient} * @@ -8481,6 +8516,62 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_MULE_JUMP = create(key("entity.mule.jump")); + /** + * {@code minecraft:entity.nautilus.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_AMBIENT = create(key("entity.nautilus.ambient")); + + /** + * {@code minecraft:entity.nautilus.dash} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_DASH = create(key("entity.nautilus.dash")); + + /** + * {@code minecraft:entity.nautilus.dash_ready} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_DASH_READY = create(key("entity.nautilus.dash_ready")); + + /** + * {@code minecraft:entity.nautilus.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_DEATH = create(key("entity.nautilus.death")); + + /** + * {@code minecraft:entity.nautilus.eat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_EAT = create(key("entity.nautilus.eat")); + + /** + * {@code minecraft:entity.nautilus.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_HURT = create(key("entity.nautilus.hurt")); + + /** + * {@code minecraft:entity.nautilus.riding} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_RIDING = create(key("entity.nautilus.riding")); + + /** + * {@code minecraft:entity.nautilus.swim} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_SWIM = create(key("entity.nautilus.swim")); + /** * {@code minecraft:entity.ocelot.ambient} * @@ -11141,6 +11232,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_ZOMBIE_HORSE_AMBIENT = create(key("entity.zombie_horse.ambient")); + /** + * {@code minecraft:entity.zombie_horse.angry} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_HORSE_ANGRY = create(key("entity.zombie_horse.angry")); + /** * {@code minecraft:entity.zombie_horse.death} * @@ -11155,6 +11253,55 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_ZOMBIE_HORSE_HURT = create(key("entity.zombie_horse.hurt")); + /** + * {@code minecraft:entity.zombie_nautilus.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_AMBIENT = create(key("entity.zombie_nautilus.ambient")); + + /** + * {@code minecraft:entity.zombie_nautilus.dash} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DASH = create(key("entity.zombie_nautilus.dash")); + + /** + * {@code minecraft:entity.zombie_nautilus.dash_ready} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DASH_READY = create(key("entity.zombie_nautilus.dash_ready")); + + /** + * {@code minecraft:entity.zombie_nautilus.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DEATH = create(key("entity.zombie_nautilus.death")); + + /** + * {@code minecraft:entity.zombie_nautilus.eat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_EAT = create(key("entity.zombie_nautilus.eat")); + + /** + * {@code minecraft:entity.zombie_nautilus.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_HURT = create(key("entity.zombie_nautilus.hurt")); + + /** + * {@code minecraft:entity.zombie_nautilus.swim} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_SWIM = create(key("entity.zombie_nautilus.swim")); + /** * {@code minecraft:entity.zombie_villager.ambient} * @@ -11316,6 +11463,13 @@ public final class SoundEventKeys { */ public static final TypedKey ITEM_ARMOR_EQUIP_LEATHER = create(key("item.armor.equip_leather")); + /** + * {@code minecraft:item.armor.equip_nautilus} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_ARMOR_EQUIP_NAUTILUS = create(key("item.armor.equip_nautilus")); + /** * {@code minecraft:item.armor.equip_netherite} * @@ -11337,6 +11491,13 @@ public final class SoundEventKeys { */ public static final TypedKey ITEM_ARMOR_EQUIP_WOLF = create(key("item.armor.equip_wolf")); + /** + * {@code minecraft:item.armor.unequip_nautilus} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_ARMOR_UNEQUIP_NAUTILUS = create(key("item.armor.unequip_nautilus")); + /** * {@code minecraft:item.armor.unequip_wolf} * @@ -11855,6 +12016,69 @@ public final class SoundEventKeys { */ public static final TypedKey ITEM_SHOVEL_FLATTEN = create(key("item.shovel.flatten")); + /** + * {@code minecraft:item.spear.attack} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_ATTACK = create(key("item.spear.attack")); + + /** + * {@code minecraft:item.spear.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_HIT = create(key("item.spear.hit")); + + /** + * {@code minecraft:item.spear.lunge_1} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_LUNGE_1 = create(key("item.spear.lunge_1")); + + /** + * {@code minecraft:item.spear.lunge_2} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_LUNGE_2 = create(key("item.spear.lunge_2")); + + /** + * {@code minecraft:item.spear.lunge_3} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_LUNGE_3 = create(key("item.spear.lunge_3")); + + /** + * {@code minecraft:item.spear.use} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_USE = create(key("item.spear.use")); + + /** + * {@code minecraft:item.spear_wood.attack} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_WOOD_ATTACK = create(key("item.spear_wood.attack")); + + /** + * {@code minecraft:item.spear_wood.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_WOOD_HIT = create(key("item.spear_wood.hit")); + + /** + * {@code minecraft:item.spear_wood.use} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_WOOD_USE = create(key("item.spear_wood.use")); + /** * {@code minecraft:item.spyglass.stop_using} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java index a9034950da84..07cb23cc2bc1 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java @@ -39,13 +39,6 @@ public final class BiomeTagKeys { */ public static final TagKey ALLOWS_TROPICAL_FISH_SPAWNS_AT_ANY_HEIGHT = create(key("allows_tropical_fish_spawns_at_any_height")); - /** - * {@code #minecraft:has_closer_water_fog} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TagKey HAS_CLOSER_WATER_FOG = create(key("has_closer_water_fog")); - /** * {@code #minecraft:has_structure/ancient_city} * @@ -284,13 +277,6 @@ public final class BiomeTagKeys { */ public static final TagKey HAS_STRUCTURE_WOODLAND_MANSION = create(key("has_structure/woodland_mansion")); - /** - * {@code #minecraft:increased_fire_burnout} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TagKey INCREASED_FIRE_BURNOUT = create(key("increased_fire_burnout")); - /** * {@code #minecraft:is_badlands} * @@ -403,13 +389,6 @@ public final class BiomeTagKeys { */ public static final TagKey MORE_FREQUENT_DROWNED_SPAWNS = create(key("more_frequent_drowned_spawns")); - /** - * {@code #minecraft:plays_underwater_music} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TagKey PLAYS_UNDERWATER_MUSIC = create(key("plays_underwater_music")); - /** * {@code #minecraft:polar_bears_spawn_on_alternate_blocks} * @@ -438,13 +417,6 @@ public final class BiomeTagKeys { */ public static final TagKey REQUIRED_OCEAN_MONUMENT_SURROUNDING = create(key("required_ocean_monument_surrounding")); - /** - * {@code #minecraft:snow_golem_melts} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TagKey SNOW_GOLEM_MELTS = create(key("snow_golem_melts")); - /** * {@code #minecraft:spawns_cold_variant_farm_animals} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BlockTypeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BlockTypeTagKeys.java index 82d3b953fa1a..4f1e44542145 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BlockTypeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BlockTypeTagKeys.java @@ -242,6 +242,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey CAMPFIRES = create(key("campfires")); + /** + * {@code #minecraft:can_glide_through} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CAN_GLIDE_THROUGH = create(key("can_glide_through")); + /** * {@code #minecraft:candle_cakes} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java index 95073a65d876..97d4b0af8e66 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java @@ -81,6 +81,13 @@ public final class EntityTypeTagKeys { */ public static final TagKey BOAT = create(key("boat")); + /** + * {@code #minecraft:burn_in_daylight} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey BURN_IN_DAYLIGHT = create(key("burn_in_daylight")); + /** * {@code #minecraft:can_breathe_under_water} * @@ -116,6 +123,13 @@ public final class EntityTypeTagKeys { */ public static final TagKey CAN_WEAR_HORSE_ARMOR = create(key("can_wear_horse_armor")); + /** + * {@code #minecraft:can_wear_nautilus_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CAN_WEAR_NAUTILUS_ARMOR = create(key("can_wear_nautilus_armor")); + /** * {@code #minecraft:candidate_for_iron_golem_gift} * @@ -228,6 +242,13 @@ public final class EntityTypeTagKeys { */ public static final TagKey INVERTED_HEALING_AND_HARM = create(key("inverted_healing_and_harm")); + /** + * {@code #minecraft:nautilus_hostiles} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey NAUTILUS_HOSTILES = create(key("nautilus_hostiles")); + /** * {@code #minecraft:no_anger_from_wind_charge} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java index 8145f5dda0c2..3e6ff0c0c383 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java @@ -487,6 +487,13 @@ public final class ItemTypeTagKeys { */ public static final TagKey ENCHANTABLE_LEG_ARMOR = create(key("enchantable/leg_armor")); + /** + * {@code #minecraft:enchantable/lunge} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey ENCHANTABLE_LUNGE = create(key("enchantable/lunge")); + /** * {@code #minecraft:enchantable/mace} * @@ -494,6 +501,13 @@ public final class ItemTypeTagKeys { */ public static final TagKey ENCHANTABLE_MACE = create(key("enchantable/mace")); + /** + * {@code #minecraft:enchantable/melee_weapon} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey ENCHANTABLE_MELEE_WEAPON = create(key("enchantable/melee_weapon")); + /** * {@code #minecraft:enchantable/mining} * @@ -516,11 +530,11 @@ public final class ItemTypeTagKeys { public static final TagKey ENCHANTABLE_SHARP_WEAPON = create(key("enchantable/sharp_weapon")); /** - * {@code #minecraft:enchantable/sword} + * {@code #minecraft:enchantable/sweeping} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TagKey ENCHANTABLE_SWORD = create(key("enchantable/sword")); + public static final TagKey ENCHANTABLE_SWEEPING = create(key("enchantable/sweeping")); /** * {@code #minecraft:enchantable/trident} @@ -816,6 +830,27 @@ public final class ItemTypeTagKeys { */ public static final TagKey MEAT = create(key("meat")); + /** + * {@code #minecraft:nautilus_bucket_food} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey NAUTILUS_BUCKET_FOOD = create(key("nautilus_bucket_food")); + + /** + * {@code #minecraft:nautilus_food} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey NAUTILUS_FOOD = create(key("nautilus_food")); + + /** + * {@code #minecraft:nautilus_taming_items} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey NAUTILUS_TAMING_ITEMS = create(key("nautilus_taming_items")); + /** * {@code #minecraft:netherite_tool_materials} * @@ -1131,6 +1166,13 @@ public final class ItemTypeTagKeys { */ public static final TagKey SOUL_FIRE_BASE_BLOCKS = create(key("soul_fire_base_blocks")); + /** + * {@code #minecraft:spears} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SPEARS = create(key("spears")); + /** * {@code #minecraft:spruce_logs} * @@ -1355,6 +1397,13 @@ public final class ItemTypeTagKeys { */ public static final TagKey WOOL_CARPETS = create(key("wool_carpets")); + /** + * {@code #minecraft:zombie_horse_food} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey ZOMBIE_HORSE_FOOD = create(key("zombie_horse_food")); + private ItemTypeTagKeys() { } diff --git a/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java b/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java index a748e78bbdd1..41f83b2e2522 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java @@ -340,7 +340,7 @@ private static MaterialSetTag replacedBy(Tag vanillaTag, String legacy */ public static final MaterialSetTag SPAWN_EGGS = new MaterialSetTag(keyFor("spawn_eggs")) .endsWith("_SPAWN_EGG") - .ensureSize("SPAWN_EGGS", 83).lock(); + .ensureSize("SPAWN_EGGS", 85).lock(); /** * Covers all colors of stained glass. @@ -677,6 +677,7 @@ private static MaterialSetTag replacedBy(Tag vanillaTag, String legacy .not(Material.COPPER_HORSE_ARMOR, Material.COPPER_GOLEM_SPAWN_EGG) .not(Material.COPPER_HELMET, Material.COPPER_CHESTPLATE, Material.COPPER_LEGGINGS, Material.COPPER_BOOTS) .not(Material.COPPER_AXE, Material.COPPER_HOE, Material.COPPER_PICKAXE, Material.COPPER_SHOVEL, Material.COPPER_SWORD) + .not(Material.COPPER_NAUTILUS_ARMOR, Material.COPPER_SPEAR) .ensureSize("UNAFFECTED_COPPER_BLOCKS", 30).lock(); /** diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/consumable/ItemUseAnimation.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/consumable/ItemUseAnimation.java index 8851e0e5770d..6de384922758 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/consumable/ItemUseAnimation.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/consumable/ItemUseAnimation.java @@ -13,11 +13,12 @@ public enum ItemUseAnimation { DRINK, BLOCK, BOW, - SPEAR, + TRIDENT, CROSSBOW, SPYGLASS, TOOT_HORN, BRUSH, - BUNDLE; + BUNDLE, + SPEAR; // End generate - ItemUseAnimation } diff --git a/paper-api/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java b/paper-api/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java index 393d127463a6..c30873dfbf98 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java @@ -84,7 +84,10 @@ public enum FailReason { /** * The world doesn't allow sleeping (ex. Nether or The End). Entering * the bed is prevented and the bed explodes. + * + * @deprecated TODO - snapshot - no longer exists in vanilla */ + @Deprecated(since = "1.21.11") NOT_POSSIBLE_HERE, /** * Entering the bed is prevented due to it not being night nor @@ -93,7 +96,10 @@ public enum FailReason { * If the event is forcefully allowed during daytime, the player will * enter the bed (and set its bed location), but might get immediately * thrown out again. + * + * @deprecated TODO - snapshot - no longer exists in vanilla */ + @Deprecated(since = "1.21.11") NOT_POSSIBLE_NOW, /** * Entering the bed is prevented due to the player being too far away. diff --git a/paper-api/src/main/java/org/bukkit/Material.java b/paper-api/src/main/java/org/bukkit/Material.java index 73cf04c20ff5..4e1dec4828c8 100644 --- a/paper-api/src/main/java/org/bukkit/Material.java +++ b/paper-api/src/main/java/org/bukkit/Material.java @@ -248,9 +248,11 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla COPPER_HORSE_ARMOR(-1, 1), COPPER_INGOT(-1), COPPER_LEGGINGS(-1, 1), + COPPER_NAUTILUS_ARMOR(-1, 1), COPPER_NUGGET(-1), COPPER_PICKAXE(-1, 1), COPPER_SHOVEL(-1, 1), + COPPER_SPEAR(-1, 1), COPPER_SWORD(-1, 1), COW_SPAWN_EGG(-1), CREAKING_SPAWN_EGG(-1), @@ -272,8 +274,10 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla DIAMOND_HOE(-1, 1), DIAMOND_HORSE_ARMOR(-1, 1), DIAMOND_LEGGINGS(-1, 1), + DIAMOND_NAUTILUS_ARMOR(-1, 1), DIAMOND_PICKAXE(-1, 1), DIAMOND_SHOVEL(-1, 1), + DIAMOND_SPEAR(-1, 1), DIAMOND_SWORD(-1, 1), DISC_FRAGMENT_5(-1), DOLPHIN_SPAWN_EGG(-1), @@ -340,8 +344,10 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla GOLDEN_HOE(-1, 1), GOLDEN_HORSE_ARMOR(-1, 1), GOLDEN_LEGGINGS(-1, 1), + GOLDEN_NAUTILUS_ARMOR(-1, 1), GOLDEN_PICKAXE(-1, 1), GOLDEN_SHOVEL(-1, 1), + GOLDEN_SPEAR(-1, 1), GOLDEN_SWORD(-1, 1), GRAY_BUNDLE(-1, 1), GRAY_DYE(-1), @@ -375,9 +381,11 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla IRON_HORSE_ARMOR(-1, 1), IRON_INGOT(-1), IRON_LEGGINGS(-1, 1), + IRON_NAUTILUS_ARMOR(-1, 1), IRON_NUGGET(-1), IRON_PICKAXE(-1, 1), IRON_SHOVEL(-1, 1), + IRON_SPEAR(-1, 1), IRON_SWORD(-1, 1), ITEM_FRAME(-1), JUNGLE_BOAT(-1, 1), @@ -446,6 +454,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla MUTTON(-1), NAME_TAG(-1), NAUTILUS_SHELL(-1), + NAUTILUS_SPAWN_EGG(-1), NETHER_BRICK(-1), NETHER_STAR(-1), NETHERITE_AXE(-1, 1), @@ -455,9 +464,11 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla NETHERITE_HOE(-1, 1), NETHERITE_INGOT(-1), NETHERITE_LEGGINGS(-1, 1), + NETHERITE_NAUTILUS_ARMOR(-1, 1), NETHERITE_PICKAXE(-1, 1), NETHERITE_SCRAP(-1), NETHERITE_SHOVEL(-1, 1), + NETHERITE_SPEAR(-1, 1), NETHERITE_SWORD(-1, 1), NETHERITE_UPGRADE_SMITHING_TEMPLATE(-1), OAK_BOAT(-1, 1), @@ -564,6 +575,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla STONE_HOE(-1, 1), STONE_PICKAXE(-1, 1), STONE_SHOVEL(-1, 1), + STONE_SPEAR(-1, 1), STONE_SWORD(-1, 1), STRAY_SPAWN_EGG(-1), STRIDER_SPAWN_EGG(-1), @@ -612,6 +624,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla WOODEN_HOE(-1, 1), WOODEN_PICKAXE(-1, 1), WOODEN_SHOVEL(-1, 1), + WOODEN_SPEAR(-1, 1), WOODEN_SWORD(-1, 1), WRITABLE_BOOK(-1, 1), WRITTEN_BOOK(-1, 16), @@ -620,6 +633,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla YELLOW_HARNESS(-1, 1), ZOGLIN_SPAWN_EGG(-1), ZOMBIE_HORSE_SPAWN_EGG(-1), + ZOMBIE_NAUTILUS_SPAWN_EGG(-1), ZOMBIE_SPAWN_EGG(-1), ZOMBIE_VILLAGER_SPAWN_EGG(-1), ZOMBIFIED_PIGLIN_SPAWN_EGG(-1), diff --git a/paper-api/src/main/java/org/bukkit/Sound.java b/paper-api/src/main/java/org/bukkit/Sound.java index 0ceba9ca35ce..7ebb488f47a2 100644 --- a/paper-api/src/main/java/org/bukkit/Sound.java +++ b/paper-api/src/main/java/org/bukkit/Sound.java @@ -1739,6 +1739,16 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_AXOLOTL_SWIM = getSound("entity.axolotl.swim"); + Sound ENTITY_BABY_NAUTILUS_AMBIENT = getSound("entity.baby_nautilus.ambient"); + + Sound ENTITY_BABY_NAUTILUS_DEATH = getSound("entity.baby_nautilus.death"); + + Sound ENTITY_BABY_NAUTILUS_EAT = getSound("entity.baby_nautilus.eat"); + + Sound ENTITY_BABY_NAUTILUS_HURT = getSound("entity.baby_nautilus.hurt"); + + Sound ENTITY_BABY_NAUTILUS_SWIM = getSound("entity.baby_nautilus.swim"); + Sound ENTITY_BAT_AMBIENT = getSound("entity.bat.ambient"); Sound ENTITY_BAT_DEATH = getSound("entity.bat.death"); @@ -2439,6 +2449,22 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_MULE_JUMP = getSound("entity.mule.jump"); + Sound ENTITY_NAUTILUS_AMBIENT = getSound("entity.nautilus.ambient"); + + Sound ENTITY_NAUTILUS_DASH = getSound("entity.nautilus.dash"); + + Sound ENTITY_NAUTILUS_DASH_READY = getSound("entity.nautilus.dash_ready"); + + Sound ENTITY_NAUTILUS_DEATH = getSound("entity.nautilus.death"); + + Sound ENTITY_NAUTILUS_EAT = getSound("entity.nautilus.eat"); + + Sound ENTITY_NAUTILUS_HURT = getSound("entity.nautilus.hurt"); + + Sound ENTITY_NAUTILUS_RIDING = getSound("entity.nautilus.riding"); + + Sound ENTITY_NAUTILUS_SWIM = getSound("entity.nautilus.swim"); + Sound ENTITY_OCELOT_AMBIENT = getSound("entity.ocelot.ambient"); Sound ENTITY_OCELOT_DEATH = getSound("entity.ocelot.death"); @@ -3199,10 +3225,26 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_ZOMBIE_HORSE_AMBIENT = getSound("entity.zombie_horse.ambient"); + Sound ENTITY_ZOMBIE_HORSE_ANGRY = getSound("entity.zombie_horse.angry"); + Sound ENTITY_ZOMBIE_HORSE_DEATH = getSound("entity.zombie_horse.death"); Sound ENTITY_ZOMBIE_HORSE_HURT = getSound("entity.zombie_horse.hurt"); + Sound ENTITY_ZOMBIE_NAUTILUS_AMBIENT = getSound("entity.zombie_nautilus.ambient"); + + Sound ENTITY_ZOMBIE_NAUTILUS_DASH = getSound("entity.zombie_nautilus.dash"); + + Sound ENTITY_ZOMBIE_NAUTILUS_DASH_READY = getSound("entity.zombie_nautilus.dash_ready"); + + Sound ENTITY_ZOMBIE_NAUTILUS_DEATH = getSound("entity.zombie_nautilus.death"); + + Sound ENTITY_ZOMBIE_NAUTILUS_EAT = getSound("entity.zombie_nautilus.eat"); + + Sound ENTITY_ZOMBIE_NAUTILUS_HURT = getSound("entity.zombie_nautilus.hurt"); + + Sound ENTITY_ZOMBIE_NAUTILUS_SWIM = getSound("entity.zombie_nautilus.swim"); + Sound ENTITY_ZOMBIE_VILLAGER_AMBIENT = getSound("entity.zombie_villager.ambient"); Sound ENTITY_ZOMBIE_VILLAGER_CONVERTED = getSound("entity.zombie_villager.converted"); @@ -3249,12 +3291,16 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ITEM_ARMOR_EQUIP_LEATHER = getSound("item.armor.equip_leather"); + Sound ITEM_ARMOR_EQUIP_NAUTILUS = getSound("item.armor.equip_nautilus"); + Sound ITEM_ARMOR_EQUIP_NETHERITE = getSound("item.armor.equip_netherite"); Sound ITEM_ARMOR_EQUIP_TURTLE = getSound("item.armor.equip_turtle"); Sound ITEM_ARMOR_EQUIP_WOLF = getSound("item.armor.equip_wolf"); + Sound ITEM_ARMOR_UNEQUIP_NAUTILUS = getSound("item.armor.unequip_nautilus"); + Sound ITEM_ARMOR_UNEQUIP_WOLF = getSound("item.armor.unequip_wolf"); Sound ITEM_AXE_SCRAPE = getSound("item.axe.scrape"); @@ -3403,6 +3449,24 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ITEM_SHOVEL_FLATTEN = getSound("item.shovel.flatten"); + Sound ITEM_SPEAR_ATTACK = getSound("item.spear.attack"); + + Sound ITEM_SPEAR_HIT = getSound("item.spear.hit"); + + Sound ITEM_SPEAR_LUNGE_1 = getSound("item.spear.lunge_1"); + + Sound ITEM_SPEAR_LUNGE_2 = getSound("item.spear.lunge_2"); + + Sound ITEM_SPEAR_LUNGE_3 = getSound("item.spear.lunge_3"); + + Sound ITEM_SPEAR_USE = getSound("item.spear.use"); + + Sound ITEM_SPEAR_WOOD_ATTACK = getSound("item.spear_wood.attack"); + + Sound ITEM_SPEAR_WOOD_HIT = getSound("item.spear_wood.hit"); + + Sound ITEM_SPEAR_WOOD_USE = getSound("item.spear_wood.use"); + Sound ITEM_SPYGLASS_STOP_USING = getSound("item.spyglass.stop_using"); Sound ITEM_SPYGLASS_USE = getSound("item.spyglass.use"); diff --git a/paper-api/src/main/java/org/bukkit/Tag.java b/paper-api/src/main/java/org/bukkit/Tag.java index 7088f069facc..542082e33dbf 100644 --- a/paper-api/src/main/java/org/bukkit/Tag.java +++ b/paper-api/src/main/java/org/bukkit/Tag.java @@ -84,6 +84,8 @@ public interface Tag extends Keyed { Tag CAMPFIRES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("campfires"), Material.class); + Tag CAN_GLIDE_THROUGH = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("can_glide_through"), Material.class); + Tag CANDLE_CAKES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("candle_cakes"), Material.class); Tag CANDLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("candles"), Material.class); @@ -562,15 +564,19 @@ public interface Tag extends Keyed { Tag ITEMS_ENCHANTABLE_LEG_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/leg_armor"), Material.class); + Tag ITEMS_ENCHANTABLE_LUNGE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/lunge"), Material.class); + Tag ITEMS_ENCHANTABLE_MACE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mace"), Material.class); + Tag ITEMS_ENCHANTABLE_MELEE_WEAPON = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/melee_weapon"), Material.class); + Tag ITEMS_ENCHANTABLE_MINING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mining"), Material.class); Tag ITEMS_ENCHANTABLE_MINING_LOOT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mining_loot"), Material.class); Tag ITEMS_ENCHANTABLE_SHARP_WEAPON = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/sharp_weapon"), Material.class); - Tag ITEMS_ENCHANTABLE_SWORD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/sword"), Material.class); + Tag ITEMS_ENCHANTABLE_SWEEPING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/sweeping"), Material.class); Tag ITEMS_ENCHANTABLE_TRIDENT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/trident"), Material.class); @@ -656,6 +662,12 @@ public interface Tag extends Keyed { Tag ITEMS_MEAT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("meat"), Material.class); + Tag ITEMS_NAUTILUS_BUCKET_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("nautilus_bucket_food"), Material.class); + + Tag ITEMS_NAUTILUS_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("nautilus_food"), Material.class); + + Tag ITEMS_NAUTILUS_TAMING_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("nautilus_taming_items"), Material.class); + Tag ITEMS_NETHERITE_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("netherite_tool_materials"), Material.class); Tag ITEMS_NON_FLAMMABLE_WOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("non_flammable_wood"), Material.class); @@ -746,6 +758,8 @@ public interface Tag extends Keyed { Tag ITEMS_SOUL_FIRE_BASE_BLOCKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("soul_fire_base_blocks"), Material.class); + Tag ITEMS_SPEARS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("spears"), Material.class); + Tag ITEMS_SPRUCE_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("spruce_logs"), Material.class); Tag ITEMS_STAIRS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("stairs"), Material.class); @@ -810,6 +824,8 @@ public interface Tag extends Keyed { Tag ITEMS_WOOL_CARPETS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wool_carpets"), Material.class); + Tag ITEMS_ZOMBIE_HORSE_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("zombie_horse_food"), Material.class); + String REGISTRY_FLUIDS = "fluids"; Tag FLUIDS_LAVA = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("lava"), Fluid.class); @@ -834,6 +850,8 @@ public interface Tag extends Keyed { Tag ENTITY_TYPES_BOAT = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("boat"), EntityType.class); + Tag ENTITY_TYPES_BURN_IN_DAYLIGHT = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("burn_in_daylight"), EntityType.class); + Tag ENTITY_TYPES_CAN_BREATHE_UNDER_WATER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_breathe_under_water"), EntityType.class); Tag ENTITY_TYPES_CAN_EQUIP_HARNESS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_equip_harness"), EntityType.class); @@ -844,6 +862,8 @@ public interface Tag extends Keyed { Tag ENTITY_TYPES_CAN_WEAR_HORSE_ARMOR = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_wear_horse_armor"), EntityType.class); + Tag ENTITY_TYPES_CAN_WEAR_NAUTILUS_ARMOR = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_wear_nautilus_armor"), EntityType.class); + Tag ENTITY_TYPES_CANDIDATE_FOR_IRON_GOLEM_GIFT = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("candidate_for_iron_golem_gift"), EntityType.class); Tag ENTITY_TYPES_CANNOT_BE_PUSHED_ONTO_BOATS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("cannot_be_pushed_onto_boats"), EntityType.class); @@ -876,6 +896,8 @@ public interface Tag extends Keyed { Tag ENTITY_TYPES_INVERTED_HEALING_AND_HARM = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("inverted_healing_and_harm"), EntityType.class); + Tag ENTITY_TYPES_NAUTILUS_HOSTILES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("nautilus_hostiles"), EntityType.class); + Tag ENTITY_TYPES_NO_ANGER_FROM_WIND_CHARGE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("no_anger_from_wind_charge"), EntityType.class); Tag ENTITY_TYPES_NON_CONTROLLING_RIDER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("non_controlling_rider"), EntityType.class); diff --git a/paper-api/src/main/java/org/bukkit/damage/DamageType.java b/paper-api/src/main/java/org/bukkit/damage/DamageType.java index 8d1e681b820b..6f4a6cc6bbcc 100644 --- a/paper-api/src/main/java/org/bukkit/damage/DamageType.java +++ b/paper-api/src/main/java/org/bukkit/damage/DamageType.java @@ -93,6 +93,8 @@ public interface DamageType extends Keyed, Translatable { DamageType SONIC_BOOM = getDamageType("sonic_boom"); + DamageType SPEAR = getDamageType("spear"); + DamageType SPIT = getDamageType("spit"); DamageType STALAGMITE = getDamageType("stalagmite"); diff --git a/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java b/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java index 16d3a35de7a4..70f6c8428c66 100644 --- a/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java +++ b/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java @@ -82,12 +82,12 @@ public boolean includes(@NotNull Material item) { }, /** - * Allows the Enchantment to be placed on weapons (swords) + * Allows the Enchantment to be placed on weapons (swords, spears) */ WEAPON { @Override public boolean includes(@NotNull Material item) { - return Tag.ITEMS_ENCHANTABLE_SWORD.isTagged(item); + return Tag.ITEMS_ENCHANTABLE_SHARP_WEAPON.isTagged(item); } }, diff --git a/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java b/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java new file mode 100644 index 000000000000..1b4c1d7b6491 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java @@ -0,0 +1,4 @@ +package org.bukkit.entity; + +public interface AbstractNautilus extends Animals { +} diff --git a/paper-api/src/main/java/org/bukkit/entity/EntityType.java b/paper-api/src/main/java/org/bukkit/entity/EntityType.java index ce60b976bc0c..0d7d6af83dc5 100644 --- a/paper-api/src/main/java/org/bukkit/entity/EntityType.java +++ b/paper-api/src/main/java/org/bukkit/entity/EntityType.java @@ -135,6 +135,7 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans MINECART("minecart", RideableMinecart.class, 42), MOOSHROOM("mooshroom", MushroomCow.class, 96), MULE("mule", Mule.class, 32), + NAUTILUS("nautilus", Nautilus.class, -1), OAK_BOAT("oak_boat", OakBoat.class, -1), OAK_CHEST_BOAT("oak_chest_boat", OakChestBoat.class, -1), OCELOT("ocelot", Ocelot.class, 98), @@ -197,6 +198,7 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans ZOGLIN("zoglin", Zoglin.class, -1), ZOMBIE("zombie", Zombie.class, 54), ZOMBIE_HORSE("zombie_horse", ZombieHorse.class, 29), + ZOMBIE_NAUTILUS("zombie_nautilus", ZombieNautilus.class, -1), ZOMBIE_VILLAGER("zombie_villager", ZombieVillager.class, 27), ZOMBIFIED_PIGLIN("zombified_piglin", PigZombie.class, 57), // End generate - EntityType diff --git a/paper-api/src/main/java/org/bukkit/entity/Nautilus.java b/paper-api/src/main/java/org/bukkit/entity/Nautilus.java new file mode 100644 index 000000000000..94232fd4cb92 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/Nautilus.java @@ -0,0 +1,4 @@ +package org.bukkit.entity; + +public interface Nautilus extends AbstractNautilus { +} diff --git a/paper-api/src/main/java/org/bukkit/entity/ZombieNautilus.java b/paper-api/src/main/java/org/bukkit/entity/ZombieNautilus.java new file mode 100644 index 000000000000..03fe9bfe4c1b --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/ZombieNautilus.java @@ -0,0 +1,4 @@ +package org.bukkit.entity; + +public interface ZombieNautilus extends AbstractNautilus { +} diff --git a/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java b/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java index db4e51bfc1de..aa327854fe16 100644 --- a/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java +++ b/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java @@ -57,8 +57,12 @@ public Class getMemoryClass() { public static final MemoryKey ATTACK_COOLING_DOWN = new MemoryKey<>(NamespacedKey.minecraft("attack_cooling_down"), Boolean.class); + public static final MemoryKey ATTACK_TARGET_COOLDOWN = new MemoryKey<>(NamespacedKey.minecraft("attack_target_cooldown"), Integer.class); + public static final MemoryKey CANT_REACH_WALK_TARGET_SINCE = new MemoryKey<>(NamespacedKey.minecraft("cant_reach_walk_target_since"), Long.class); + public static final MemoryKey CHARGE_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("charge_cooldown_ticks"), Integer.class); + public static final MemoryKey DANCING = new MemoryKey<>(NamespacedKey.minecraft("dancing"), Boolean.class); public static final MemoryKey DANGER_DETECTED_RECENTLY = new MemoryKey<>(NamespacedKey.minecraft("danger_detected_recently"), Boolean.class); diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java index 628a1bbfae71..8b68c9fe2709 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java @@ -139,7 +139,10 @@ public enum BedEnterResult { *

* Entering the bed is prevented and if {@link World#isBedWorks()} is * {@code false} then the bed explodes. + * + * @deprecated TODO - snapshot - no longer exists in vanilla */ + @Deprecated(since = "1.21.11") NOT_POSSIBLE_HERE, /** * Entering the bed is prevented due to it not being night nor @@ -148,7 +151,10 @@ public enum BedEnterResult { * If the event is forcefully allowed during daytime, the player will * enter the bed (and set its bed location), but might get immediately * thrown out again. + * + * @deprecated TODO - snapshot - no longer exists in vanilla */ + @Deprecated(since = "1.21.11") NOT_POSSIBLE_NOW, /** * Entering the bed is prevented due to the player being too far away. diff --git a/paper-generator/src/main/java/io/papermc/generator/Main.java b/paper-generator/src/main/java/io/papermc/generator/Main.java index 0b5564a7cc66..fd9cb7216329 100644 --- a/paper-generator/src/main/java/io/papermc/generator/Main.java +++ b/paper-generator/src/main/java/io/papermc/generator/Main.java @@ -34,6 +34,7 @@ import net.minecraft.server.packs.repository.ServerPacksSource; import net.minecraft.server.packs.resources.CloseableResourceManager; import net.minecraft.server.packs.resources.MultiPackResourceManager; +import net.minecraft.server.permissions.LevelBasedPermissionSet; import net.minecraft.tags.TagKey; import net.minecraft.tags.TagLoader; import net.minecraft.world.flag.FeatureFlagSet; @@ -97,7 +98,7 @@ public static CompletableFuture bootStrap(boolean withTags) { pendingTags, flags, Commands.CommandSelection.DEDICATED, - Commands.LEVEL_GAMEMASTERS, + LevelBasedPermissionSet.GAMEMASTER, Util.backgroundExecutor(), Runnable::run ).whenComplete((result, ex) -> { diff --git a/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java b/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java index 474c4fa3963f..a797995c1ddb 100644 --- a/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java @@ -137,6 +137,9 @@ public final class MobGoalNames { // todo sync with MobGoalHelper ideally this s map.put(net.minecraft.world.entity.animal.AbstractCow.class, AbstractCow.class); map.put(net.minecraft.world.entity.animal.HappyGhast.class, HappyGhast.class); map.put(net.minecraft.world.entity.animal.coppergolem.CopperGolem.class, org.bukkit.entity.CopperGolem.class); + map.put(net.minecraft.world.entity.animal.nautilus.AbstractNautilus.class, org.bukkit.entity.AbstractNautilus.class); + map.put(net.minecraft.world.entity.animal.nautilus.Nautilus.class, org.bukkit.entity.Nautilus.class); + map.put(net.minecraft.world.entity.animal.nautilus.ZombieNautilus.class, org.bukkit.entity.ZombieNautilus.class); // }); diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 212e2edca5b2..91c3d8490f70 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:1.21.10+build.4") + mache("io.papermc:mache:25w42a+build.3") paperclip("io.papermc:paperclip:3.0.3") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } @@ -24,7 +24,7 @@ paperweight { gitFilePatches = false spigot { - enabled = true + enabled = false buildDataRef = "42d18d4c4653ffc549778dbe223f6994a031d69e" packageVersion = "v1_21_R6" // also needs to be updated in MappingEnvironment } @@ -40,6 +40,10 @@ paperweight { "org.bukkit.craftbukkit", "org.spigotmc", ) + + updatingMinecraft { + //oldPaperCommit = "b57d6410f648268b62c674a754253fcbcc74cbb9" + } } tasks.generateDevelopmentBundle { diff --git a/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch b/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch index b699e0d32d5a..59bb0cf429e6 100644 --- a/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch +++ b/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/math/OctahedralGroup.java +++ b/com/mojang/math/OctahedralGroup.java -@@ -123,6 +_,12 @@ +@@ -116,6 +_,12 @@ } ); @@ -13,7 +13,7 @@ private OctahedralGroup(final String name, final SymmetricGroup3 permutation, final boolean invertX, final boolean invertY, final boolean invertZ) { this.name = name; this.invertX = invertX; -@@ -160,7 +_,7 @@ +@@ -156,7 +_,7 @@ return this.name; } @@ -22,7 +22,7 @@ if (this.rotatedDirections == null) { this.rotatedDirections = Util.makeEnumMap(Direction.class, direction1 -> { Direction.Axis axis = direction1.getAxis(); -@@ -171,6 +_,11 @@ +@@ -167,6 +_,11 @@ }); } diff --git a/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch b/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch index 8f350ebabe4a..1fbab0cbda5c 100644 --- a/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/commands/CommandSourceStack.java +++ b/net/minecraft/commands/CommandSourceStack.java -@@ -47,7 +_,7 @@ +@@ -48,7 +_,7 @@ import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; --public class CommandSourceStack implements ExecutionCommandSource, PermissionSource, SharedSuggestionProvider { -+public class CommandSourceStack implements ExecutionCommandSource, PermissionSource, SharedSuggestionProvider, io.papermc.paper.command.brigadier.PaperCommandSourceStack { // Paper - Brigadier API +-public class CommandSourceStack implements ExecutionCommandSource, SharedSuggestionProvider { ++public class CommandSourceStack implements ExecutionCommandSource, SharedSuggestionProvider, io.papermc.paper.command.brigadier.PaperCommandSourceStack { // Paper - Brigadier API public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(Component.translatable("permissions.requires.player")); public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(Component.translatable("permissions.requires.entity")); public final CommandSource source; -@@ -65,6 +_,7 @@ +@@ -66,6 +_,7 @@ private final Vec2 rotation; private final CommandSigningContext signingContext; private final TaskChainer chatMessageChainer; @@ -17,7 +17,7 @@ public CommandSourceStack( CommandSource source, -@@ -190,6 +_,30 @@ +@@ -191,6 +_,30 @@ ); } @@ -31,7 +31,7 @@ + new Vec3(location.x(), location.y(), location.z()), + new Vec2(location.getPitch(), location.getYaw()), + ((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle(), -+ this.permissionLevel, ++ this.permissions, + this.textName, + this.displayName, + this.server, @@ -48,8 +48,8 @@ public CommandSourceStack withRotation(Vec2 rotation) { return this.rotation.equals(rotation) ? this -@@ -396,6 +_,32 @@ - return this.permissionLevel >= level; +@@ -380,6 +_,32 @@ + return this.permissions; } + // Paper start - Fix permission levels for command blocks @@ -59,14 +59,14 @@ + // Paper end - Fix permission levels for command blocks + + // CraftBukkit start -+ public boolean hasPermission(int i, String bukkitPermission) { ++ public boolean hasPermission(net.minecraft.server.permissions.Permission permission, String bukkitPermission) { + // Paper start - Fix permission levels for command blocks + final java.util.function.BooleanSupplier hasBukkitPerm = () -> this.source == CommandSource.NULL /*treat NULL as having all bukkit perms*/ || this.getBukkitSender().hasPermission(bukkitPermission); // lazily check bukkit perms to the benefit of custom permission setups + // if the server is null, we must check the vanilla perm level system + // if ignoreVanillaPermissions is true, we can skip vanilla perms and just run the bukkit perm check + //noinspection ConstantValue + if (this.getServer() == null || !this.getServer().server.ignoreVanillaPermissions) { // server & level are null for command function loading -+ final boolean hasPermLevel = this.permissionLevel >= i; ++ final boolean hasPermLevel = this.permissions.hasPermission(permission); + if (this.forceRespectPermissionLevel()) { // NULL CommandSource and command blocks (if setting is enabled) should always pass the vanilla perm check + return hasPermLevel && hasBukkitPerm.getAsBoolean(); + } else { // otherwise check vanilla perm first then bukkit perm, matching upstream behavior @@ -81,9 +81,9 @@ public Vec3 getPosition() { return this.worldPosition; } -@@ -500,20 +_,25 @@ - Component component = Component.translatable("chat.type.admin", this.getDisplayName(), message).withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC); - if (this.server.getGameRules().getBoolean(GameRules.RULE_SENDCOMMANDFEEDBACK)) { +@@ -485,20 +_,25 @@ + GameRules gameRules = this.level.getGameRules(); + if (gameRules.getBoolean(GameRules.RULE_SENDCOMMANDFEEDBACK)) { for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) { - if (serverPlayer.commandSource() != this.source && this.server.getPlayerList().isOp(serverPlayer.nameAndId())) { + if (serverPlayer.commandSource() != this.source && serverPlayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit @@ -92,8 +92,8 @@ } } -- if (this.source != this.server && this.server.getGameRules().getBoolean(GameRules.RULE_LOGADMINCOMMANDS)) { -+ if (this.source != this.server && this.server.getGameRules().getBoolean(GameRules.RULE_LOGADMINCOMMANDS) && !org.spigotmc.SpigotConfig.silentCommandBlocks) { // Spigot +- if (this.source != this.server && gameRules.getBoolean(GameRules.RULE_LOGADMINCOMMANDS)) { ++ if (this.source != this.server && gameRules.getBoolean(GameRules.RULE_LOGADMINCOMMANDS) && !org.spigotmc.SpigotConfig.silentCommandBlocks) { // Spigot this.server.sendSystemMessage(component); } } @@ -110,7 +110,7 @@ } } -@@ -524,7 +_,7 @@ +@@ -509,7 +_,7 @@ @Override public Collection getOnlinePlayerNames() { @@ -119,7 +119,7 @@ } @Override -@@ -604,4 +_,16 @@ +@@ -589,4 +_,16 @@ public boolean isSilent() { return this.silent; } diff --git a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch index bd775ab10d66..dcf528ef8c15 100644 --- a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch @@ -1,13 +1,22 @@ --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -172,12 +_,18 @@ +@@ -155,6 +_,7 @@ + import org.slf4j.Logger; + + public class Commands { ++ public interface RestrictedMarker { } // Paper - restricted api + public static final String COMMAND_PREFIX = "/"; + private static final ThreadLocal> CURRENT_EXECUTION_CONTEXT = new ThreadLocal<>(); + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -180,6 +_,7 @@ @Override public boolean isRestricted(CommandNode node) { -+ if (node.getRequirement() instanceof PermissionSource.RestrictedMarker) return true; // Paper - restricted api - return node.getRequirement() instanceof PermissionCheck permissionCheck && permissionCheck.requiredLevel() > 0; ++ if (node.getRequirement() instanceof RestrictedMarker) return true; // Paper - restricted api + Predicate requirement = node.getRequirement(); + return !requirement.test(this.noPermissionSource); } - }; +@@ -187,6 +_,11 @@ private final CommandDispatcher dispatcher = new CommandDispatcher<>(); public Commands(Commands.CommandSelection selection, CommandBuildContext context) { @@ -19,7 +28,7 @@ AdvancementCommands.register(this.dispatcher); AttributeCommand.register(this.dispatcher, context); ExecuteCommand.register(this.dispatcher, context); -@@ -287,6 +_,42 @@ +@@ -297,6 +_,42 @@ PublishCommand.register(this.dispatcher); } @@ -27,7 +36,7 @@ + for (final CommandNode node : this.dispatcher.getRoot().getChildren()) { + if (node.getRequirement() == com.mojang.brigadier.builder.ArgumentBuilder.defaultRequirement()) { + node.requirement = stack -> stack.source == CommandSource.NULL || stack.getBukkitSender().hasPermission(org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(node)); -+ } else if (node.getRequirement() instanceof net.minecraft.commands.PermissionSource.Check check) { ++ } else if (node.getRequirement() instanceof PermissionProviderCheck check) { + check.vanillaNode().set(node); + } + } @@ -62,7 +71,7 @@ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -306,6 +_,13 @@ +@@ -316,6 +_,13 @@ } public void performCommand(ParseResults parseResults, String command) { @@ -76,7 +85,7 @@ CommandSourceStack commandSourceStack = parseResults.getContext().getSource(); Profiler.get().push(() -> "/" + command); ContextChain contextChain = finishParsing(parseResults, command, commandSourceStack); -@@ -319,10 +_,13 @@ +@@ -329,10 +_,13 @@ ) ); } @@ -93,7 +102,7 @@ StackTraceElement[] stackTrace = var12.getStackTrace(); for (int i = 0; i < Math.min(stackTrace.length, 3); i++) { -@@ -348,13 +_,17 @@ +@@ -358,13 +_,17 @@ } @Nullable @@ -113,7 +122,7 @@ if (var7.getInput() != null && var7.getCursor() >= 0) { int min = Math.min(var7.getInput().length(), var7.getCursor()); MutableComponent mutableComponent = Component.empty() -@@ -371,7 +_,17 @@ +@@ -381,7 +_,17 @@ } mutableComponent.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC)); @@ -132,7 +141,7 @@ } return null; -@@ -399,17 +_,110 @@ +@@ -409,17 +_,110 @@ } public void sendCommands(ServerPlayer player) { @@ -246,7 +255,7 @@ if (argumentBuilder.getRedirect() != null) { argumentBuilder.redirect(output.get(argumentBuilder.getRedirect())); } -@@ -418,7 +_,7 @@ +@@ -428,7 +_,7 @@ output.put(commandNode, commandNode1); current.addChild(commandNode1); if (!commandNode.getChildren().isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/commands/PermissionSource.java.patch b/paper-server/patches/sources/net/minecraft/commands/PermissionSource.java.patch deleted file mode 100644 index 0d8a8570bb81..000000000000 --- a/paper-server/patches/sources/net/minecraft/commands/PermissionSource.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/commands/PermissionSource.java -+++ b/net/minecraft/commands/PermissionSource.java -@@ -9,9 +_,22 @@ - return this.hasPermission(2); - } - -- public record Check(@Override int requiredLevel) implements PermissionCheck { -+ // Paper start - Vanilla Command permission checking & expose restricted API -+ interface RestrictedMarker { } -+ -+ public record Check(@Override int requiredLevel, java.util.concurrent.atomic.AtomicReference> vanillaNode) implements PermissionCheck { -+ public Check(int requiredLevel) { -+ this(requiredLevel, new java.util.concurrent.atomic.AtomicReference<>()); -+ } -+ // Paper end - Vanilla Command permission checking & expose restricted API - @Override - public boolean test(T source) { -+ // Paper start - Vanilla Command permission checking -+ com.mojang.brigadier.tree.CommandNode currentCommand = vanillaNode.get(); -+ if (currentCommand != null && source instanceof CommandSourceStack commandSourceStack) { -+ return commandSourceStack.hasPermission(this.requiredLevel, org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand)); -+ } -+ // Paper end - Vanilla Command permission checking - return source.hasPermission(this.requiredLevel); - } - } diff --git a/paper-server/patches/sources/net/minecraft/commands/arguments/EntityArgument.java.patch b/paper-server/patches/sources/net/minecraft/commands/arguments/EntityArgument.java.patch index 4a154e157e21..a1eea4fbe882 100644 --- a/paper-server/patches/sources/net/minecraft/commands/arguments/EntityArgument.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/arguments/EntityArgument.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/EntityArgument.java +++ b/net/minecraft/commands/arguments/EntityArgument.java -@@ -105,9 +_,14 @@ +@@ -106,9 +_,14 @@ } private EntitySelector parse(StringReader reader, boolean allowSelectors) throws CommandSyntaxException { @@ -16,17 +16,19 @@ if (entitySelector.getMaxResults() > 1 && this.single) { if (this.playersOnly) { reader.setCursor(0); -@@ -129,7 +_,13 @@ +@@ -130,9 +_,15 @@ if (context.getSource() instanceof SharedSuggestionProvider sharedSuggestionProvider) { StringReader stringReader = new StringReader(builder.getInput()); stringReader.setCursor(builder.getStart()); -- EntitySelectorParser entitySelectorParser = new EntitySelectorParser(stringReader, EntitySelectorParser.allowSelectors(sharedSuggestionProvider)); + // Paper start - Fix EntityArgument permissions + final boolean permission = sharedSuggestionProvider instanceof CommandSourceStack stack -+ ? stack.bypassSelectorPermissions || stack.hasPermission(2, "minecraft.command.selector") ++ ? stack.bypassSelectorPermissions || stack.hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS, "minecraft.command.selector") + // Only CommandSourceStack implements SharedSuggestionProvider. If *somehow* anything else ends up here, try to query its permission level, otherwise yield false. -+ : (sharedSuggestionProvider instanceof final net.minecraft.commands.PermissionSource permissionSource && permissionSource.hasPermission(2)); -+ EntitySelectorParser entitySelectorParser = new EntitySelectorParser(stringReader, permission); ++ : sharedSuggestionProvider.permissions().hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS); + EntitySelectorParser entitySelectorParser = new EntitySelectorParser( +- stringReader, sharedSuggestionProvider.permissions().hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS) ++ stringReader, permission + ); + // Paper end - Fix EntityArgument permissions try { diff --git a/paper-server/patches/sources/net/minecraft/commands/arguments/MessageArgument.java.patch b/paper-server/patches/sources/net/minecraft/commands/arguments/MessageArgument.java.patch index c2bfa9606584..9ec0535601f1 100644 --- a/paper-server/patches/sources/net/minecraft/commands/arguments/MessageArgument.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/arguments/MessageArgument.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/MessageArgument.java +++ b/net/minecraft/commands/arguments/MessageArgument.java -@@ -40,6 +_,11 @@ +@@ -41,6 +_,11 @@ public static void resolveChatMessage(CommandContext context, String key, Consumer callback) throws CommandSyntaxException { MessageArgument.Message message = context.getArgument(key, MessageArgument.Message.class); @@ -12,7 +12,7 @@ CommandSourceStack commandSourceStack = context.getSource(); Component component = message.resolveComponent(commandSourceStack); CommandSigningContext signingContext = commandSourceStack.getSigningContext(); -@@ -54,17 +_,21 @@ +@@ -55,17 +_,21 @@ private static void resolveSignedMessage(Consumer callback, CommandSourceStack source, PlayerChatMessage message) { MinecraftServer server = source.getServer(); CompletableFuture completableFuture = filterPlainText(source, message); diff --git a/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelector.java.patch b/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelector.java.patch index b95523bc7703..c85828a3f37a 100644 --- a/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelector.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelector.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java -@@ -106,7 +_,7 @@ +@@ -107,7 +_,7 @@ } private void checkPermissions(CommandSourceStack source) throws CommandSyntaxException { -- if (this.usesSelector && !source.allowsSelectors()) { -+ if (!source.bypassSelectorPermissions && (this.usesSelector && !source.hasPermission(2, "minecraft.command.selector"))) { // CraftBukkit // Paper - add bypass for selector perms +- if (this.usesSelector && !source.permissions().hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS)) { ++ if (!source.bypassSelectorPermissions && this.usesSelector && !source.hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS, "minecraft.command.selector")) { // CraftBukkit // Paper - add bypass for selector perms throw EntityArgument.ERROR_SELECTORS_NOT_ALLOWED.create(); } } diff --git a/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch b/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch index 8507af1706cd..c34391be4ca2 100644 --- a/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelectorParser.java +++ b/net/minecraft/commands/arguments/selector/EntitySelectorParser.java -@@ -125,6 +_,11 @@ +@@ -126,6 +_,11 @@ } public static boolean allowSelectors(S suggestionProvider) { + // Paper start - Fix EntityArgument permissions + if (suggestionProvider instanceof net.minecraft.commands.CommandSourceStack stack) { -+ return stack.bypassSelectorPermissions || stack.hasPermission(2, "minecraft.command.selector"); ++ return stack.bypassSelectorPermissions || stack.hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS, "minecraft.command.selector"); + } + // Paper end - Fix EntityArgument permissions - return suggestionProvider instanceof PermissionSource permissionSource && permissionSource.allowsSelectors(); + return suggestionProvider instanceof PermissionSetSupplier permissionSetSupplier + && permissionSetSupplier.permissions().hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS); } - -@@ -201,8 +_,10 @@ +@@ -208,8 +_,10 @@ }; } @@ -25,7 +25,7 @@ this.suggestions = this::suggestSelector; if (!this.reader.canRead()) { throw ERROR_MISSING_SELECTOR_TYPE.createWithContext(this.reader); -@@ -474,6 +_,12 @@ +@@ -481,6 +_,12 @@ } public EntitySelector parse() throws CommandSyntaxException { @@ -38,7 +38,7 @@ this.startPosition = this.reader.getCursor(); this.suggestions = this::suggestNameOrSelector; if (this.reader.canRead() && this.reader.peek() == '@') { -@@ -482,7 +_,7 @@ +@@ -489,7 +_,7 @@ } this.reader.skip(); diff --git a/paper-server/patches/sources/net/minecraft/core/Vec3i.java.patch b/paper-server/patches/sources/net/minecraft/core/Vec3i.java.patch index 49e43c6489f0..9b131d3e85a4 100644 --- a/paper-server/patches/sources/net/minecraft/core/Vec3i.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/Vec3i.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/Vec3i.java +++ b/net/minecraft/core/Vec3i.java -@@ -22,9 +_,9 @@ +@@ -23,9 +_,9 @@ ByteBufCodecs.VAR_INT, Vec3i::getX, ByteBufCodecs.VAR_INT, Vec3i::getY, ByteBufCodecs.VAR_INT, Vec3i::getZ, Vec3i::new ); public static final Vec3i ZERO = new Vec3i(0, 0, 0); @@ -13,7 +13,7 @@ public static Codec offsetCodec(int maxOffset) { return CODEC.validate( -@@ -41,12 +_,12 @@ +@@ -42,12 +_,12 @@ } @Override @@ -28,7 +28,7 @@ return (this.getY() + this.getZ() * 31) * 31 + this.getX(); } -@@ -59,15 +_,15 @@ +@@ -60,15 +_,15 @@ } } @@ -47,7 +47,7 @@ return this.z; } -@@ -241,4 +_,11 @@ +@@ -250,4 +_,11 @@ public String toShortString() { return this.getX() + ", " + this.getY() + ", " + this.getZ(); } diff --git a/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch b/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch index 751de4f933df..b46c42cbc965 100644 --- a/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/component/DataComponents.java +++ b/net/minecraft/core/component/DataComponents.java -@@ -206,10 +_,10 @@ +@@ -231,10 +_,10 @@ "map_post_processing", builder -> builder.networkSynchronized(MapPostProcessing.STREAM_CODEC) ); public static final DataComponentType CHARGED_PROJECTILES = register( @@ -13,7 +13,7 @@ ); public static final DataComponentType POTION_CONTENTS = register( "potion_contents", builder -> builder.persistent(PotionContents.CODEC).networkSynchronized(PotionContents.STREAM_CODEC).cacheEncoding() -@@ -292,7 +_,7 @@ +@@ -317,7 +_,7 @@ "pot_decorations", builder -> builder.persistent(PotDecorations.CODEC).networkSynchronized(PotDecorations.STREAM_CODEC).cacheEncoding() ); public static final DataComponentType CONTAINER = register( diff --git a/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch b/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch index 1f38f500e383..93178427d8bf 100644 --- a/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/core/registries/BuiltInRegistries.java +++ b/net/minecraft/core/registries/BuiltInRegistries.java -@@ -336,6 +_,11 @@ - public static final Registry> DIALOG_BODY_TYPE = registerSimple(Registries.DIALOG_BODY_TYPE, DialogBodyTypes::bootstrap); +@@ -352,6 +_,11 @@ + public static final Registry> ATTRIBUTE_TYPE = registerSimple(Registries.ATTRIBUTE_TYPE, AttributeTypes::bootstrap); public static final Registry> TEST_FUNCTION = registerSimple(Registries.TEST_FUNCTION, BuiltinTestFunctions::bootstrap); public static final Registry> REGISTRY = WRITABLE_REGISTRY; + // Paper start - add built-in registry conversions @@ -12,7 +12,7 @@ private static Registry registerSimple(ResourceKey> registryKey, BuiltInRegistries.RegistryBootstrap bootstrap) { return internalRegister(registryKey, new MappedRegistry<>(registryKey, Lifecycle.stable(), false), bootstrap); -@@ -363,6 +_,7 @@ +@@ -379,6 +_,7 @@ ResourceKey> registryKey, R registry, BuiltInRegistries.RegistryBootstrap bootstrap ) { Bootstrap.checkBootstrapCalled(() -> "registry " + registryKey.location()); @@ -20,7 +20,7 @@ ResourceLocation resourceLocation = registryKey.location(); LOADERS.put(resourceLocation, () -> bootstrap.run(registry)); WRITABLE_REGISTRY.register((ResourceKey)registryKey, registry, RegistrationInfo.BUILT_IN); -@@ -370,16 +_,34 @@ +@@ -386,16 +_,34 @@ } public static void bootStrap() { @@ -55,7 +55,7 @@ }); } -@@ -388,6 +_,7 @@ +@@ -404,6 +_,7 @@ for (Registry registry : REGISTRY) { bindBootstrappedTagsToEmpty(registry); diff --git a/paper-server/patches/sources/net/minecraft/data/loot/packs/VanillaChestLoot.java.patch b/paper-server/patches/sources/net/minecraft/data/loot/packs/VanillaChestLoot.java.patch index e846768ab6ef..289351cfa27d 100644 --- a/paper-server/patches/sources/net/minecraft/data/loot/packs/VanillaChestLoot.java.patch +++ b/paper-server/patches/sources/net/minecraft/data/loot/packs/VanillaChestLoot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/loot/packs/VanillaChestLoot.java +++ b/net/minecraft/data/loot/packs/VanillaChestLoot.java -@@ -1002,7 +_,6 @@ +@@ -1046,7 +_,6 @@ .add( LootItem.lootTableItem(Items.COMPASS) .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F))) diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch index 40b256941af9..60d0e26ddc85 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java -@@ -143,6 +_,8 @@ +@@ -145,6 +_,8 @@ boolean verify ) { super( @@ -9,7 +9,7 @@ serverThread, storageSource, packRepository, -@@ -158,8 +_,16 @@ +@@ -160,8 +_,16 @@ @Override public boolean initServer() { @@ -28,7 +28,7 @@ ServerLevel serverLevel = this.overworld(); this.testBatches = this.evaluateTestsToRun(serverLevel); LOGGER.info("Started game test server"); -@@ -354,6 +_,13 @@ +@@ -346,6 +_,13 @@ return false; } @@ -42,7 +42,7 @@ @Override public boolean isSingleplayerOwner(NameAndId nameAndId) { return false; -@@ -401,5 +_,16 @@ +@@ -393,5 +_,16 @@ @Override public void save() { } diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch index 142439d7e687..bc812f397e89 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/TestEnvironmentDefinition.java +++ b/net/minecraft/gametest/framework/TestEnvironmentDefinition.java -@@ -132,11 +_,11 @@ +@@ -136,11 +_,11 @@ MinecraftServer server = level.getServer(); for (TestEnvironmentDefinition.SetGameRules.Entry entry : this.boolRules) { @@ -14,7 +14,7 @@ } } -@@ -146,11 +_,11 @@ +@@ -150,11 +_,11 @@ MinecraftServer server = level.getServer(); for (TestEnvironmentDefinition.SetGameRules.Entry entry : this.boolRules) { diff --git a/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch b/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch index 74c11d5f854c..a9b9b399fb70 100644 --- a/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/FriendlyByteBuf.java +++ b/net/minecraft/network/FriendlyByteBuf.java -@@ -70,14 +_,20 @@ +@@ -72,14 +_,20 @@ public class FriendlyByteBuf extends ByteBuf { public static final int DEFAULT_NBT_QUOTA = 2097152; private final ByteBuf source; @@ -21,7 +21,7 @@ this.source = source; } -@@ -106,8 +_,13 @@ +@@ -108,8 +_,13 @@ } public void writeJsonWithCodec(Codec codec, T value) { @@ -36,7 +36,7 @@ } public static IntFunction limitValue(IntFunction function, int limit) { -@@ -554,7 +_,7 @@ +@@ -556,7 +_,7 @@ try { NbtIo.writeAnyTag(tag, new ByteBufOutputStream(buffer)); diff --git a/paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch index 082b3e84e871..525b0643e6f4 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/ComponentUtils.java +++ b/net/minecraft/network/chat/ComponentUtils.java -@@ -33,16 +_,45 @@ +@@ -49,16 +_,45 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch index 99e4fad8ac77..9a37c4f26d6c 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/MutableComponent.java +++ b/net/minecraft/network/chat/MutableComponent.java -@@ -94,6 +_,11 @@ +@@ -98,6 +_,11 @@ @Override public boolean equals(Object other) { diff --git a/paper-server/patches/sources/net/minecraft/server/Main.java.patch b/paper-server/patches/sources/net/minecraft/server/Main.java.patch index 667cc9190f97..c7a44529abe9 100644 --- a/paper-server/patches/sources/net/minecraft/server/Main.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/Main.java.patch @@ -238,8 +238,8 @@ thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); Runtime.getRuntime().addShutdownHook(thread); + */ // CraftBukkit end - } catch (Exception var42) { - LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", (Throwable)var42); + } catch (Throwable var42) { + LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", var42); } } diff --git a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch index 136b2e391a9a..86ea8484bc9f 100644 --- a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -178,11 +_,13 @@ +@@ -183,11 +_,13 @@ import org.slf4j.Logger; public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ServerInfo, CommandSource, ChunkIOErrorReporter { @@ -15,7 +15,7 @@ private static final int OVERLOADED_TICKS_THRESHOLD = 20; private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeUtil.NANOSECONDS_PER_SECOND; private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100; -@@ -209,7 +_,7 @@ +@@ -215,7 +_,7 @@ private MinecraftServer.TimeProfiler debugCommandProfiler; private boolean debugCommandProfilerDelayStart; private ServerConnectionListener connection; @@ -24,7 +24,7 @@ @Nullable private ServerStatus status; @Nullable -@@ -222,14 +_,14 @@ +@@ -228,14 +_,14 @@ private Map, ServerLevel> levels = Maps.newLinkedHashMap(); private PlayerList playerList; private volatile boolean running = true; @@ -41,7 +41,7 @@ private int playerIdleTimeout; private final long[] tickTimesNanos = new long[100]; private long aggregatedTickTimesNanos = 0L; -@@ -278,10 +_,108 @@ +@@ -287,10 +_,108 @@ private final DiscontinuousFrame tickFrame; private final PacketProcessor packetProcessor; @@ -151,7 +151,7 @@ if (Runtime.getRuntime().availableProcessors() > 4) { thread.setPriority(8); } -@@ -293,6 +_,10 @@ +@@ -302,6 +_,10 @@ } public MinecraftServer( @@ -162,7 +162,7 @@ Thread serverThread, LevelStorageSource.LevelStorageAccess storageSource, PackRepository packRepository, -@@ -303,18 +_,19 @@ +@@ -312,18 +_,19 @@ LevelLoadListener levelLoadListener ) { super("Server"); @@ -185,8 +185,8 @@ this.storageSource = storageSource; this.playerDataStorage = storageSource.createPlayerStorage(); this.fixerUpper = fixerUpper; -@@ -333,6 +_,38 @@ - this.notificationManager = new NotificationManager(); +@@ -343,6 +_,38 @@ + this.serverActivityMonitor = new ServerActivityMonitor(this.notificationManager, 30); this.packetProcessor = new PacketProcessor(serverThread); } + // CraftBukkit start @@ -223,8 +223,8 @@ + this.paperConfigurations = services.paper().configurations(); // Paper - add paper configuration files } - private void readScoreboard(DimensionDataStorage dataStorage) { -@@ -371,15 +_,15 @@ + protected abstract boolean initServer() throws IOException; +@@ -377,15 +_,15 @@ }; } @@ -245,7 +245,7 @@ if (profiledDuration != null) { profiledDuration.finish(true); } -@@ -393,30 +_,126 @@ +@@ -399,31 +_,127 @@ } } @@ -337,8 +337,9 @@ + this.worldData = serverLevelData; + this.worldData.setGameType(((net.minecraft.server.dedicated.DedicatedServer) this).getProperties().gameMode.get()); // From DedicatedServer.init DimensionDataStorage dataStorage = serverLevel.getDataStorage(); - this.readScoreboard(dataStorage); + this.scoreboard.load(dataStorage.computeIfAbsent(ScoreboardSaveData.TYPE).getData()); this.commandStorage = new CommandStorage(dataStorage); + this.stopwatches = dataStorage.computeIfAbsent(Stopwatches.TYPE); + this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, serverLevel.getScoreboard()); + } else { + final List spawners; @@ -382,7 +383,7 @@ serverLevelData.setInitialized(true); if (isDebugWorld) { this.setupDebugLevel(this.worldData); -@@ -436,38 +_,16 @@ +@@ -443,38 +_,16 @@ } GlobalPos globalPos = this.selectLevelLoadFocusPos(); @@ -429,7 +430,7 @@ Optional legacyWorldBorderSettings = serverLevelData.getLegacyWorldBorderSettings(); if (legacyWorldBorderSettings.isPresent()) { WorldBorder.Settings settings = legacyWorldBorderSettings.get(); -@@ -488,16 +_,14 @@ +@@ -495,16 +_,14 @@ dataStorage1.set(WorldBorder.TYPE, settings1.toWorldBorder()); } @@ -452,7 +453,7 @@ } private static void setInitialSpawn( -@@ -509,6 +_,30 @@ +@@ -516,6 +_,30 @@ levelData.setSpawn(LevelData.RespawnData.of(level.dimension(), BlockPos.ZERO.above(80), 0.0F, 0.0F)); } else { ServerChunkCache chunkSource = level.getChunkSource(); @@ -483,7 +484,7 @@ ChunkPos chunkPos = new ChunkPos(chunkSource.randomState().sampler().findSpawnPosition()); levelLoadListener.start(LevelLoadListener.Stage.PREPARE_GLOBAL_SPAWN, 0); levelLoadListener.updateFocus(level.dimension(), chunkPos); -@@ -565,10 +_,13 @@ +@@ -572,10 +_,13 @@ serverLevelData.setGameType(GameType.SPECTATOR); } @@ -499,7 +500,7 @@ chunkLoadCounter.track(serverLevel, () -> { TicketStorage ticketStorage = serverLevel.getDataStorage().get(TicketStorage.TYPE); if (ticketStorage != null) { -@@ -577,17 +_,19 @@ +@@ -584,17 +_,19 @@ }); } @@ -525,7 +526,7 @@ } protected GlobalPos selectLevelLoadFocusPos() { -@@ -620,8 +_,10 @@ +@@ -628,8 +_,10 @@ flag = true; } @@ -538,7 +539,7 @@ if (flush) { for (ServerLevel serverLevel : this.getAllLevels()) { LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", serverLevel.getChunkSource().chunkMap.getStorageName()); -@@ -651,19 +_,49 @@ +@@ -659,19 +_,49 @@ this.stopServer(); } @@ -589,7 +590,7 @@ } LOGGER.info("Saving worlds"); -@@ -705,6 +_,25 @@ +@@ -713,6 +_,25 @@ } catch (IOException var4) { LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), var4); } @@ -615,7 +616,7 @@ } public String getLocalIp() { -@@ -720,6 +_,14 @@ +@@ -728,6 +_,14 @@ } public void halt(boolean waitForShutdown) { @@ -630,7 +631,7 @@ this.running = false; if (waitForShutdown) { try { -@@ -730,6 +_,124 @@ +@@ -738,6 +_,124 @@ } } @@ -755,7 +756,7 @@ protected void runServer() { try { if (!this.initServer()) { -@@ -737,26 +_,68 @@ +@@ -745,26 +_,68 @@ } this.nextTickTimeNanos = Util.getNanos(); @@ -834,7 +835,7 @@ boolean flag = l == 0L; if (this.debugCommandProfilerDelayStart) { -@@ -764,7 +_,7 @@ +@@ -772,22 +_,22 @@ this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount); } @@ -843,10 +844,12 @@ try (Profiler.Scope scope = Profiler.use(this.createProfiler())) { ProfilerFiller profilerFiller = Profiler.get(); -@@ -773,13 +_,15 @@ - profilerFiller.push("scheduledPacketProcessing"); - this.packetProcessor.processQueuedPackets(); - profilerFiller.pop(); + profilerFiller.push("tick"); + this.tickFrame.start(); +- profilerFiller.push("scheduledPacketProcessing"); +- this.packetProcessor.processQueuedPackets(); +- profilerFiller.pop(); ++ // Paper - improve tick loop - moved into runAllTasksAtTickStart + this.runAllTasksAtTickStart(); // Paper - improve tick loop this.tickServer(flag ? () -> false : this::haveTime); this.tickFrame.end(); @@ -860,7 +863,7 @@ this.finishMeasuringTaskExecutionTime(); if (flag) { this.tickRateManager.endTickWork(); -@@ -813,7 +_,7 @@ +@@ -821,7 +_,7 @@ } catch (Throwable var64) { LOGGER.error("Exception stopping the server", var64); } finally { @@ -869,7 +872,7 @@ } } } -@@ -865,7 +_,14 @@ +@@ -873,7 +_,14 @@ } private boolean haveTime() { @@ -885,13 +888,10 @@ } public static boolean throwIfFatalException() { -@@ -892,14 +_,11 @@ +@@ -899,11 +_,11 @@ + } protected void waitUntilNextTick() { - ProfilerFiller profilerFiller = Profiler.get(); -- profilerFiller.push("scheduledPacketProcessing"); -- this.packetProcessor.processQueuedPackets(); -- profilerFiller.pop(); - this.runAllTasks(); + // Paper - improve tick loop - moved to start of tick this.waitingForNextTick = true; @@ -902,7 +902,7 @@ } finally { this.waitingForNextTick = false; } -@@ -918,17 +_,23 @@ +@@ -922,17 +_,23 @@ @Override public TickTask wrapRunnable(Runnable runnable) { @@ -928,7 +928,7 @@ this.mayHaveDelayedTasks = flag; return flag; } -@@ -937,15 +_,16 @@ +@@ -941,15 +_,16 @@ if (super.pollTask()) { return true; } else { @@ -947,7 +947,7 @@ } } -@@ -993,26 +_,44 @@ +@@ -1001,26 +_,44 @@ } public void tickServer(BooleanSupplier hasTimeLeft) { @@ -993,7 +993,7 @@ this.tickCount++; this.tickRateManager.tick(); this.tickChildren(hasTimeLeft); -@@ -1022,11 +_,18 @@ +@@ -1030,11 +_,18 @@ } this.ticksUntilAutosave--; @@ -1013,7 +1013,7 @@ profilerFiller.push("tallying"); long l = Util.getNanos() - nanos; int i1 = this.tickCount % 100; -@@ -1039,7 +_,7 @@ +@@ -1047,7 +_,7 @@ } private void autoSave() { @@ -1022,7 +1022,7 @@ LOGGER.debug("Autosave started"); ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("save"); -@@ -1081,7 +_,7 @@ +@@ -1089,7 +_,7 @@ private ServerStatus buildServerStatus() { ServerStatus.Players players = this.buildPlayerStatus(); return new ServerStatus( @@ -1031,7 +1031,7 @@ Optional.of(players), Optional.of(ServerStatus.Version.current()), Optional.ofNullable(this.statusIcon), -@@ -1095,7 +_,7 @@ +@@ -1103,7 +_,7 @@ if (this.hidesOnlinePlayers()) { return new ServerStatus.Players(maxPlayers, players.size(), List.of()); } else { @@ -1040,7 +1040,7 @@ ObjectArrayList list = new ObjectArrayList<>(min); int randomInt = Mth.nextInt(this.random, 0, players.size() - min); -@@ -1112,18 +_,77 @@ +@@ -1120,18 +_,77 @@ protected void tickChildren(BooleanSupplier hasTimeLeft) { ProfilerFiller profilerFiller = Profiler.get(); this.getPlayerList().getPlayers().forEach(serverPlayer1 -> serverPlayer1.connection.suspendFlushing()); @@ -1118,7 +1118,7 @@ profilerFiller.push("tick"); -@@ -1137,7 +_,9 @@ +@@ -1145,7 +_,9 @@ profilerFiller.pop(); profilerFiller.pop(); @@ -1128,8 +1128,8 @@ profilerFiller.popPush("connection"); this.tickConnection(); -@@ -1166,9 +_,12 @@ - profilerFiller.pop(); +@@ -1175,9 +_,12 @@ + this.serverActivityMonitor.tick(); } - private void updateEffectiveRespawnData() { @@ -1143,7 +1143,7 @@ this.effectiveRespawnData = serverLevel.getWorldBorderAdjustedRespawnData(respawnData); } -@@ -1224,6 +_,22 @@ +@@ -1229,6 +_,22 @@ return this.levels.get(dimension); } @@ -1166,7 +1166,7 @@ public Set> levelKeys() { return this.levels.keySet(); } -@@ -1248,7 +_,7 @@ +@@ -1253,7 +_,7 @@ @DontObfuscate public String getServerModName() { @@ -1175,7 +1175,7 @@ } public SystemReport fillSystemReport(SystemReport systemReport) { -@@ -1283,7 +_,7 @@ +@@ -1288,7 +_,7 @@ @Override public void sendSystemMessage(Component message) { @@ -1184,7 +1184,7 @@ } public KeyPair getKeyPair() { -@@ -1321,11 +_,17 @@ +@@ -1326,11 +_,17 @@ } } @@ -1207,15 +1207,7 @@ } } -@@ -1397,6 +_,7 @@ - - public abstract boolean isEpollEnabled(); - -+ @io.papermc.paper.annotation.DoNotUse @Deprecated(forRemoval = true) // Paper - use CraftWorld#getPVP - public boolean isPvpAllowed() { - return this.getGameRules().getBoolean(GameRules.RULE_PVP); - } -@@ -1415,10 +_,20 @@ +@@ -1402,10 +_,20 @@ @Override public String getMotd() { @@ -1237,7 +1229,7 @@ this.motd = motd; } -@@ -1447,9 +_,13 @@ +@@ -1434,9 +_,13 @@ int i = 0; for (ServerPlayer serverPlayer : this.getPlayerList().getPlayers()) { @@ -1253,7 +1245,7 @@ } return i; -@@ -1457,7 +_,7 @@ +@@ -1444,7 +_,7 @@ } public ServerConnectionListener getConnection() { @@ -1262,7 +1254,7 @@ } public boolean isReady() { -@@ -1525,7 +_,7 @@ +@@ -1512,7 +_,7 @@ @Override public void executeIfPossible(Runnable task) { if (this.isStopped()) { @@ -1271,7 +1263,7 @@ } else { super.executeIfPossible(task); } -@@ -1560,7 +_,14 @@ +@@ -1547,7 +_,14 @@ return this.functionManager; } @@ -1286,7 +1278,7 @@ CompletableFuture completableFuture = CompletableFuture.supplyAsync( () -> selectedIds.stream().map(this.packRepository::getPack).filter(Objects::nonNull).map(Pack::open).collect(ImmutableList.toImmutableList()), this -@@ -1568,7 +_,7 @@ +@@ -1555,7 +_,7 @@ .thenCompose( list -> { CloseableResourceManager closeableResourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, list); @@ -1295,7 +1287,7 @@ return ReloadableServerResources.loadResources( closeableResourceManager, this.registries, -@@ -1589,20 +_,39 @@ +@@ -1576,20 +_,39 @@ ) .thenAcceptAsync( reloadableResources -> { @@ -1337,7 +1329,7 @@ }, this ); -@@ -1619,7 +_,7 @@ +@@ -1606,7 +_,7 @@ DataPackConfig dataPackConfig = initialDataConfig.dataPacks(); FeatureFlagSet featureFlagSet = initMode ? FeatureFlagSet.of() : initialDataConfig.enabledFeatures(); FeatureFlagSet featureFlagSet1 = initMode ? FeatureFlags.REGISTRY.allFlags() : initialDataConfig.enabledFeatures(); @@ -1346,7 +1338,7 @@ if (safeMode) { return configureRepositoryWithSelection(packRepository, List.of("vanilla"), featureFlagSet, false); } else { -@@ -1674,7 +_,7 @@ +@@ -1661,7 +_,7 @@ private static WorldDataConfiguration configureRepositoryWithSelection( PackRepository packRepository, Collection selectedPacks, FeatureFlagSet enabledFeatures, boolean safeMode ) { @@ -1355,7 +1347,7 @@ enableForcedFeaturePacks(packRepository, enabledFeatures); DataPackConfig selectedPacks1 = getSelectedPacks(packRepository, safeMode); FeatureFlagSet featureFlagSet = packRepository.getRequestedFeatureFlags().join(enabledFeatures); -@@ -1706,7 +_,7 @@ +@@ -1693,7 +_,7 @@ } } @@ -1364,7 +1356,7 @@ } } -@@ -1723,8 +_,8 @@ +@@ -1710,8 +_,8 @@ UserWhiteList whiteList = playerList.getWhiteList(); for (ServerPlayer serverPlayer : Lists.newArrayList(playerList.getPlayers())) { @@ -1375,7 +1367,7 @@ } } } -@@ -1754,12 +_,12 @@ +@@ -1741,12 +_,12 @@ } public ServerLevel findRespawnDimension() { @@ -1390,7 +1382,7 @@ public void setRespawnData(LevelData.RespawnData respawnData) { ServerLevelData serverLevelData = this.worldData.overworldData(); LevelData.RespawnData respawnData1 = serverLevelData.getRespawnData(); -@@ -1957,6 +_,17 @@ +@@ -1948,6 +_,17 @@ } } @@ -1408,7 +1400,7 @@ private ProfilerFiller createProfiler() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted( -@@ -2078,16 +_,22 @@ +@@ -2069,16 +_,22 @@ } public void logChatMessage(Component content, ChatType.Bound boundChatType, @Nullable String header) { @@ -1435,7 +1427,7 @@ } public boolean logIPs() { -@@ -2098,8 +_,9 @@ +@@ -2089,8 +_,9 @@ LOGGER.debug("Received custom click action {} with payload {}", id, payload.orElse(null)); } @@ -1446,7 +1438,7 @@ } public boolean setAutoSave(boolean autoSave) { -@@ -2125,8 +_,9 @@ +@@ -2116,8 +_,9 @@ return false; } @@ -1457,7 +1449,7 @@ } public boolean acceptsTransfers() { -@@ -2260,4 +_,53 @@ +@@ -2251,4 +_,53 @@ }; } } diff --git a/paper-server/patches/sources/net/minecraft/server/ReloadableServerResources.java.patch b/paper-server/patches/sources/net/minecraft/server/ReloadableServerResources.java.patch index 164b4a459341..37f4eb620c5e 100644 --- a/paper-server/patches/sources/net/minecraft/server/ReloadableServerResources.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ReloadableServerResources.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ReloadableServerResources.java +++ b/net/minecraft/server/ReloadableServerResources.java -@@ -38,7 +_,9 @@ +@@ -39,7 +_,9 @@ this.fullRegistryHolder = new ReloadableServerRegistries.Holder(registryAccess.compositeAccess()); this.postponedTags = postponedTags; this.recipes = new RecipeManager(registries); @@ -9,11 +9,11 @@ + io.papermc.paper.command.brigadier.PaperCommands.INSTANCE.setDispatcher(this.commands, CommandBuildContext.simple(registries, enabledFeatures)); // Paper - Brigadier Command API + io.papermc.paper.command.PaperCommands.registerCommands(); // Paper this.advancements = new ServerAdvancementManager(registries); - this.functionLibrary = new ServerFunctionLibrary(functionCompilationLevel, this.commands.getDispatcher()); + this.functionLibrary = new ServerFunctionLibrary(permissions, this.commands.getDispatcher()); } -@@ -83,6 +_,14 @@ +@@ -84,6 +_,14 @@ ReloadableServerResources reloadableServerResources = new ReloadableServerResources( - loadResult.layers(), loadResult.lookupWithUpdatedTags(), enabledFeatures, commandSelection, postponedTags, functionCompilationLevel + loadResult.layers(), loadResult.lookupWithUpdatedTags(), enabledFeatures, commandSelection, postponedTags, permissions ); + // Paper start - call commands event for bootstraps + //noinspection ConstantValue diff --git a/paper-server/patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch b/paper-server/patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch index 399fc05dbb60..6f49e308d06e 100644 --- a/paper-server/patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ServerFunctionLibrary.java +++ b/net/minecraft/server/ServerFunctionLibrary.java -@@ -114,7 +_,7 @@ +@@ -108,7 +_,7 @@ return null; }).join()); this.functions = builder.build(); diff --git a/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch b/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch index 6653b3913a06..619f2eb4210e 100644 --- a/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ServerScoreboard.java +++ b/net/minecraft/server/ServerScoreboard.java -@@ -45,9 +_,7 @@ +@@ -51,9 +_,7 @@ protected void onScoreChanged(ScoreHolder scoreHolder, Objective objective, Score score) { super.onScoreChanged(scoreHolder, objective, score); if (this.trackedObjectives.contains(objective)) { @@ -11,7 +11,7 @@ new ClientboundSetScorePacket( scoreHolder.getScoreboardName(), objective.getName(), -@@ -70,7 +_,7 @@ +@@ -76,7 +_,7 @@ @Override public void onPlayerRemoved(ScoreHolder scoreHolder) { super.onPlayerRemoved(scoreHolder); @@ -20,7 +20,7 @@ this.setDirty(); } -@@ -78,7 +_,7 @@ +@@ -84,7 +_,7 @@ public void onPlayerScoreRemoved(ScoreHolder scoreHolder, Objective objective) { super.onPlayerScoreRemoved(scoreHolder, objective); if (this.trackedObjectives.contains(objective)) { @@ -29,7 +29,7 @@ } this.setDirty(); -@@ -90,7 +_,7 @@ +@@ -96,7 +_,7 @@ super.setDisplayObjective(slot, objective); if (displayObjective != objective && displayObjective != null) { if (this.getObjectiveDisplaySlotCount(displayObjective) > 0) { @@ -38,7 +38,7 @@ } else { this.stopTrackingObjective(displayObjective); } -@@ -98,7 +_,7 @@ +@@ -104,7 +_,7 @@ if (objective != null) { if (this.trackedObjectives.contains(objective)) { @@ -47,7 +47,7 @@ } else { this.startTrackingObjective(objective); } -@@ -110,9 +_,7 @@ +@@ -116,9 +_,7 @@ @Override public boolean addPlayerToTeam(String playerName, PlayerTeam team) { if (super.addPlayerToTeam(playerName, team)) { @@ -58,7 +58,7 @@ this.updatePlayerWaypoint(playerName); this.setDirty(); return true; -@@ -121,16 +_,44 @@ +@@ -127,16 +_,44 @@ } } @@ -106,7 +106,7 @@ @Override public void onObjectiveAdded(Objective objective) { super.onObjectiveAdded(objective); -@@ -141,7 +_,7 @@ +@@ -147,7 +_,7 @@ public void onObjectiveChanged(Objective objective) { super.onObjectiveChanged(objective); if (this.trackedObjectives.contains(objective)) { @@ -115,7 +115,7 @@ } this.setDirty(); -@@ -160,14 +_,14 @@ +@@ -166,14 +_,14 @@ @Override public void onTeamAdded(PlayerTeam team) { super.onTeamAdded(team); @@ -132,7 +132,7 @@ this.updateTeamWaypoints(team); this.setDirty(); } -@@ -175,7 +_,7 @@ +@@ -181,7 +_,7 @@ @Override public void onTeamRemoved(PlayerTeam team) { super.onTeamRemoved(team); @@ -141,7 +141,7 @@ this.updateTeamWaypoints(team); this.setDirty(); } -@@ -219,6 +_,7 @@ +@@ -226,6 +_,7 @@ List> startTrackingPackets = this.getStartTrackingPackets(objective); for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) { @@ -149,7 +149,7 @@ for (Packet packet : startTrackingPackets) { serverPlayer.connection.send(packet); } -@@ -244,6 +_,7 @@ +@@ -251,6 +_,7 @@ List> stopTrackingPackets = this.getStopTrackingPackets(objective); for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) { @@ -157,7 +157,7 @@ for (Packet packet : stopTrackingPackets) { serverPlayer.connection.send(packet); } -@@ -295,4 +_,13 @@ +@@ -287,4 +_,13 @@ .forEach(serverPlayer -> serverLevel.getWaypointManager().remakeConnections(serverPlayer)); } } diff --git a/paper-server/patches/sources/net/minecraft/server/WorldLoader.java.patch b/paper-server/patches/sources/net/minecraft/server/WorldLoader.java.patch index a2c0814152b9..58978e5e9ff9 100644 --- a/paper-server/patches/sources/net/minecraft/server/WorldLoader.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/WorldLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/WorldLoader.java +++ b/net/minecraft/server/WorldLoader.java -@@ -37,7 +_,7 @@ +@@ -38,7 +_,7 @@ CloseableResourceManager closeableResourceManager = pair.getSecond(); LayeredRegistryAccess layeredRegistryAccess = RegistryLayer.createRegistryAccess(); List> list = TagLoader.loadTagsForExistingRegistries( diff --git a/paper-server/patches/sources/net/minecraft/server/commands/DebugCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/DebugCommand.java.patch index 9d1cc61c466b..8a3de200eb96 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/DebugCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/DebugCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/DebugCommand.java +++ b/net/minecraft/server/commands/DebugCommand.java -@@ -262,6 +_,13 @@ +@@ -263,6 +_,13 @@ return true; } diff --git a/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch index af9b8546b7b6..23c44096b8f3 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch @@ -1,22 +1,13 @@ --- a/net/minecraft/server/commands/GameRuleCommand.java +++ b/net/minecraft/server/commands/GameRuleCommand.java -@@ -30,15 +_,15 @@ - +@@ -32,8 +_,8 @@ static > int setRule(CommandContext context, GameRules.Key gameRule) { CommandSourceStack commandSourceStack = context.getSource(); -- T rule = commandSourceStack.getServer().getGameRules().getRule(gameRule); + T rule = commandSourceStack.getLevel().getGameRules().getRule(gameRule); - rule.setFromArgument(context, "value"); - commandSourceStack.getServer().onGameRuleChanged(gameRule.getId(), rule); -+ T rule = commandSourceStack.getLevel().getGameRules().getRule(gameRule); // CraftBukkit + rule.setFromArgument(context, "value", gameRule); // Paper - Add WorldGameRuleChangeEvent + commandSourceStack.getServer().notificationManager().onGameRuleChanged(commandSourceStack.getLevel(), gameRule.getId(), rule); // Paper - per-world game rules commandSourceStack.sendSuccess(() -> Component.translatable("commands.gamerule.set", gameRule.getId(), rule.toString()), true); return rule.getCommandResult(); } - - static > int queryRule(CommandSourceStack source, GameRules.Key gameRule) { -- T rule = source.getServer().getGameRules().getRule(gameRule); -+ T rule = source.getLevel().getGameRules().getRule(gameRule); // CraftBukkit - source.sendSuccess(() -> Component.translatable("commands.gamerule.query", gameRule.getId(), rule.toString()), false); - return rule.getCommandResult(); - } diff --git a/paper-server/patches/sources/net/minecraft/server/commands/ReloadCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/ReloadCommand.java.patch index da6d6d1877d7..a96e3087c595 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/ReloadCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/ReloadCommand.java.patch @@ -34,4 +34,4 @@ + // CraftBukkit end public static void register(CommandDispatcher dispatcher) { - dispatcher.register(Commands.literal("reload").requires(Commands.hasPermission(2)).executes(commandContext -> { + dispatcher.register(Commands.literal("reload").requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)).executes(commandContext -> { diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch index 57bff330f478..f0fc6ae608cc 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -78,10 +_,10 @@ +@@ -80,10 +_,10 @@ static final Logger LOGGER = LogUtils.getLogger(); private static final int CONVERSION_RETRY_DELAY_MS = 5000; private static final int CONVERSION_RETRIES = 2; @@ -13,7 +13,7 @@ @Nullable private RconThread rconThread; public DedicatedServerSettings settings; -@@ -99,6 +_,7 @@ +@@ -101,6 +_,7 @@ private long lastHeartbeat; public DedicatedServer( @@ -21,7 +21,7 @@ Thread serverThread, LevelStorageSource.LevelStorageAccess storageSource, PackRepository packRepository, -@@ -107,9 +_,10 @@ +@@ -109,9 +_,10 @@ DataFixer fixerUpper, Services services ) { @@ -34,7 +34,7 @@ this.serverTextFilter = ServerTextFilter.createFromConfig(settings.getProperties()); this.serverLinks = createServerLinks(settings); if (settings.getProperties().codeOfConduct) { -@@ -194,6 +_,10 @@ +@@ -197,6 +_,10 @@ Thread thread = new Thread("Server console handler") { @Override public void run() { @@ -44,8 +44,8 @@ + /* BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); - String string3; -@@ -203,17 +_,41 @@ + String string4; +@@ -206,17 +_,41 @@ } } catch (IOException var4) { DedicatedServer.LOGGER.error("Exception handling console input", (Throwable)var4); @@ -89,7 +89,7 @@ LOGGER.info("Loading properties"); DedicatedServerProperties properties = this.settings.getProperties(); if (this.isSingleplayer()) { -@@ -224,8 +_,46 @@ +@@ -227,8 +_,46 @@ this.setLocalIp(properties.serverIp); } @@ -137,7 +137,7 @@ InetAddress inetAddress = null; if (!this.getLocalIp().isEmpty()) { inetAddress = InetAddress.getByName(this.getLocalIp()); -@@ -234,46 +_,72 @@ +@@ -237,46 +_,72 @@ if (this.getPort() < 0) { this.setPort(properties.serverPort); } @@ -208,17 +208,17 @@ - this.loadLevel(); + this.loadLevel(this.storageSource.getLevelId()); // CraftBukkit long l = Util.getNanos() - nanos; - String string2 = String.format(Locale.ROOT, "%.3fs", l / 1.0E9); -- LOGGER.info("Done ({})! For help, type \"help\"", string2); -+ LOGGER.info("Done preparing level \"{}\" ({})", this.getLevelIdName(), string2); // Paper - Improve startup message, add total time + String string3 = String.format(Locale.ROOT, "%.3fs", l / 1.0E9); +- LOGGER.info("Done ({})! For help, type \"help\"", string3); ++ LOGGER.info("Done preparing level \"{}\" ({})", this.getLevelIdName(), string3); // Paper - Improve startup message, add total time + this.initPostWorld(); // Paper - don't include plugins in world preparation time if (properties.announcePlayerAchievements != null) { -- this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS).set(properties.announcePlayerAchievements, this); -+ this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS).set(properties.announcePlayerAchievements, this.overworld()); // CraftBukkit - per-world +- this.worldData.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS).set(properties.announcePlayerAchievements, this); ++ this.worldData.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS).set(properties.announcePlayerAchievements, this.overworld()); // CraftBukkit - per-world } if (properties.enableQuery) { -@@ -286,7 +_,7 @@ +@@ -289,7 +_,7 @@ this.rconThread = RconThread.create(this); } @@ -227,7 +227,7 @@ Thread thread1 = new Thread(new ServerWatchdog(this)); thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(LOGGER)); thread1.setName("Server Watchdog"); -@@ -304,6 +_,12 @@ +@@ -307,6 +_,12 @@ } } @@ -240,7 +240,7 @@ @Override public boolean isEnforceWhitelist() { return this.settings.getProperties().enforceWhitelist.get(); -@@ -321,6 +_,7 @@ +@@ -324,6 +_,7 @@ @Override public void setUsingWhitelist(boolean usingWhitelist) { @@ -248,7 +248,7 @@ this.settings.update(dedicatedServerProperties -> dedicatedServerProperties.whiteList.update(this.registryAccess(), usingWhitelist)); } -@@ -371,7 +_,7 @@ +@@ -374,7 +_,7 @@ @Override public void forceDifficulty() { @@ -257,7 +257,7 @@ } public int viewDistance() { -@@ -427,11 +_,11 @@ +@@ -430,11 +_,11 @@ } if (this.rconThread != null) { @@ -271,7 +271,7 @@ } if (this.jsonRpcServer != null) { -@@ -441,6 +_,9 @@ +@@ -444,6 +_,9 @@ LOGGER.error("Interrupted while stopping the management server", (Throwable)var2); } } @@ -281,7 +281,7 @@ } @Override -@@ -450,12 +_,20 @@ +@@ -453,12 +_,20 @@ } public void handleConsoleInput(String msg, CommandSourceStack source) { @@ -305,7 +305,7 @@ this.getCommands().performPrefixedCommand(consoleInput.source, consoleInput.msg); } } -@@ -601,12 +_,15 @@ +@@ -603,12 +_,15 @@ @Override public String getMotd() { @@ -323,7 +323,7 @@ } @Override -@@ -632,7 +_,11 @@ +@@ -634,7 +_,11 @@ @Override public boolean enforceSecureProfile() { DedicatedServerProperties properties = this.getProperties(); @@ -336,7 +336,7 @@ } @Override -@@ -717,21 +_,60 @@ +@@ -719,21 +_,60 @@ @Override public String getPluginNames() { @@ -402,7 +402,7 @@ } @Override -@@ -863,4 +_,15 @@ +@@ -865,4 +_,15 @@ public Map getCodeOfConducts() { return this.codeOfConductTexts; } diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch index 6a7a8d321b88..a96aa62f6148 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java -@@ -48,6 +_,7 @@ +@@ -50,6 +_,7 @@ static final Logger LOGGER = LogUtils.getLogger(); private static final Pattern SHA1 = Pattern.compile("^[a-fA-F0-9]{40}$"); private static final Splitter COMMA_SPLITTER = Splitter.on(',').trimResults(); @@ -8,7 +8,7 @@ public static final String MANAGEMENT_SERVER_TLS_ENABLED_KEY = "management-server-tls-enabled"; public static final String MANAGEMENT_SERVER_TLS_KEYSTORE_KEY = "management-server-tls-keystore"; public static final String MANAGEMENT_SERVER_TLS_KEYSTORE_PASSWORD_KEY = "management-server-tls-keystore-password"; -@@ -97,7 +_,7 @@ +@@ -107,7 +_,7 @@ public final boolean broadcastRconToOps = this.get("broadcast-rcon-to-ops", true); public final boolean broadcastConsoleToOps = this.get("broadcast-console-to-ops", true); public final int maxWorldSize = this.get("max-world-size", property -> Mth.clamp(property, 1, 29999984), 29999984); @@ -17,7 +17,7 @@ public final String regionFileComression = this.get("region-file-compression", "deflate"); public final boolean enableJmxMonitoring = this.get("enable-jmx-monitoring", false); public final Settings.MutableValue enableStatus = this.getMutable("enable-status", true); -@@ -114,13 +_,16 @@ +@@ -124,13 +_,16 @@ public final Settings.MutableValue whiteList = this.getMutable("white-list", false); public final boolean enforceSecureProfile = this.get("enforce-secure-profile", true); public final boolean logIPs = this.get("log-ips", true); @@ -37,7 +37,7 @@ String string = this.get("level-seed", ""); boolean flag = this.get("generate-structures", true); long l = WorldOptions.parseSeed(string).orElse(WorldOptions.randomSeed()); -@@ -141,15 +_,21 @@ +@@ -151,15 +_,21 @@ this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())), this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled())) ); diff --git a/paper-server/patches/sources/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java.patch b/paper-server/patches/sources/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java.patch index 5acedfe81d4f..263d75bcc248 100644 --- a/paper-server/patches/sources/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java +++ b/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java -@@ -96,7 +_,8 @@ +@@ -101,7 +_,8 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java.patch index 6cda8047e978..94e422dcfaf8 100644 --- a/paper-server/patches/sources/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java +++ b/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java -@@ -24,18 +_,18 @@ +@@ -25,18 +_,18 @@ net.minecraft.world.level.GameRules.Value ruleValue = this.getRuleValue(rule.key()); String string = ruleValue.serialize(); if (ruleValue instanceof net.minecraft.world.level.GameRules.BooleanValue booleanValue) { diff --git a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch index eb5307f183f4..d1bb7820bdc7 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch @@ -141,7 +141,7 @@ } }, this.unloadQueue::add).whenComplete((_void, error) -> { if (error != null) { -@@ -850,7 +_,7 @@ +@@ -847,7 +_,7 @@ } public int size() { @@ -150,7 +150,7 @@ } public net.minecraft.server.level.DistanceManager getDistanceManager() { -@@ -877,10 +_,10 @@ +@@ -874,10 +_,10 @@ .addColumn("fluid_ticks") .build(writer); @@ -164,7 +164,7 @@ Optional optional = Optional.ofNullable(chunkHolder.getLatestChunk()); Optional optional1 = optional.flatMap(chunk -> chunk instanceof LevelChunk ? Optional.of((LevelChunk)chunk) : Optional.empty()); csvOutput.writeRow( -@@ -920,11 +_,13 @@ +@@ -917,11 +_,13 @@ } private CompletableFuture> readChunk(ChunkPos pos) { @@ -181,7 +181,7 @@ } void collectSpawningChunks(List output) { -@@ -934,7 +_,7 @@ +@@ -931,7 +_,7 @@ ChunkHolder chunkHolder = this.visibleChunkMap.get(spawnCandidateChunks.nextLong()); if (chunkHolder != null) { LevelChunk tickingChunk = chunkHolder.getTickingChunk(); @@ -190,7 +190,7 @@ output.add(tickingChunk); } } -@@ -954,13 +_,35 @@ +@@ -951,13 +_,35 @@ } public boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkPos) { @@ -228,7 +228,7 @@ return true; } } -@@ -976,7 +_,7 @@ +@@ -973,7 +_,7 @@ Builder builder = ImmutableList.builder(); for (ServerPlayer serverPlayer : this.playerMap.getAllPlayers()) { @@ -237,7 +237,7 @@ builder.add(serverPlayer); } } -@@ -985,12 +_,12 @@ +@@ -982,12 +_,12 @@ } } @@ -252,7 +252,7 @@ } } -@@ -1112,9 +_,19 @@ +@@ -1109,9 +_,19 @@ } public void addEntity(Entity entity) { @@ -272,7 +272,7 @@ if (i != 0) { int updateInterval = type.updateInterval(); if (this.entityMap.containsKey(entity.getId())) { -@@ -1138,6 +_,7 @@ +@@ -1135,6 +_,7 @@ } protected void removeEntity(Entity entity) { @@ -280,7 +280,7 @@ if (entity instanceof ServerPlayer serverPlayer) { this.updatePlayerStatus(serverPlayer, false); -@@ -1299,10 +_,10 @@ +@@ -1296,10 +_,10 @@ final Entity entity; private final int range; SectionPos lastSectionPos; @@ -293,7 +293,7 @@ this.entity = entity; this.range = range; this.lastSectionPos = SectionPos.of(entity); -@@ -1349,6 +_,7 @@ +@@ -1346,6 +_,7 @@ } public void removePlayer(ServerPlayer player) { @@ -301,7 +301,7 @@ if (this.seenBy.remove(player.connection)) { this.serverEntity.removePairing(player); if (this.seenBy.isEmpty()) { -@@ -1358,23 +_,45 @@ +@@ -1355,23 +_,45 @@ } public void updatePlayer(ServerPlayer player) { @@ -352,7 +352,7 @@ } } else { this.removePlayer(player); -@@ -1391,6 +_,7 @@ +@@ -1388,6 +_,7 @@ for (Entity entity : this.entity.getIndirectPassengers()) { int i1 = entity.getType().clientTrackingRange() * 16; diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch index a1623773c6c5..186c46ecd7cd 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -68,6 +_,7 @@ +@@ -67,6 +_,7 @@ private final TicketStorage ticketStorage; private long lastInhabitedUpdate; public boolean spawnEnemies = true; @@ -8,7 +8,7 @@ private static final int CACHE_SIZE = 4; private final long[] lastChunkPos = new long[4]; private final ChunkStatus[] lastChunkStatus = new ChunkStatus[4]; -@@ -77,6 +_,13 @@ +@@ -76,6 +_,13 @@ @Nullable @VisibleForDebug private NaturalSpawner.SpawnState lastSpawnState; @@ -22,7 +22,7 @@ public ServerChunkCache( ServerLevel level, -@@ -125,6 +_,64 @@ +@@ -124,6 +_,64 @@ this.clearCache(); } @@ -87,7 +87,7 @@ @Override public ThreadedLevelLightEngine getLightEngine() { return this.lightEngine; -@@ -160,7 +_,7 @@ +@@ -159,7 +_,7 @@ for (int i = 0; i < 4; i++) { if (packedChunkPos == this.lastChunkPos[i] && chunkStatus == this.lastChunkStatus[i]) { ChunkAccess chunkAccess = this.lastChunk[i]; @@ -96,7 +96,7 @@ return chunkAccess; } } -@@ -169,6 +_,7 @@ +@@ -168,6 +_,7 @@ profilerFiller.incrementCounter("getChunkCacheMiss"); CompletableFuture> chunkFutureMainThread = this.getChunkFutureMainThread(x, z, chunkStatus, requireChunk); this.mainThreadProcessor.managedBlock(chunkFutureMainThread::isDone); @@ -104,7 +104,7 @@ ChunkResult chunkResult = chunkFutureMainThread.join(); ChunkAccess chunkAccess1 = chunkResult.orElse(null); if (chunkAccess1 == null && requireChunk) { -@@ -240,7 +_,15 @@ +@@ -239,7 +_,15 @@ long packedChunkPos = chunkPos.toLong(); int i = ChunkLevel.byStatus(chunkStatus); ChunkHolder visibleChunkIfPresent = this.getVisibleChunkIfPresent(packedChunkPos); @@ -121,7 +121,7 @@ this.addTicket(new Ticket(TicketType.UNKNOWN, i), chunkPos); if (this.chunkAbsent(visibleChunkIfPresent, i)) { ProfilerFiller profilerFiller = Profiler.get(); -@@ -260,7 +_,7 @@ +@@ -259,7 +_,7 @@ } private boolean chunkAbsent(@Nullable ChunkHolder chunkHolder, int status) { @@ -130,7 +130,7 @@ } @Override -@@ -315,17 +_,39 @@ +@@ -314,17 +_,39 @@ @Override public void close() throws IOException { @@ -172,7 +172,7 @@ this.ticketStorage.purgeStaleTickets(this.chunkMap); } -@@ -381,12 +_,20 @@ +@@ -380,12 +_,20 @@ naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, new LocalMobCapCalculator(this.chunkMap) ); this.lastSpawnState = spawnState; @@ -181,7 +181,7 @@ int _int = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); List filteredSpawningCategories; - if (_boolean) { -- boolean flag = this.level.getLevelData().getGameTime() % 400L == 0L; +- boolean flag = this.level.getGameTime() % 400L == 0L; - filteredSpawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnState, true, this.spawnEnemies, flag); + if (_boolean && (this.spawnEnemies || this.spawnFriendlies)) { // Paper + // Paper start - PlayerNaturallySpawnCreaturesEvent @@ -192,12 +192,12 @@ + entityPlayer.playerNaturallySpawnedEvent.callEvent(); + } + // Paper end - PlayerNaturallySpawnCreaturesEvent -+ boolean flag = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit ++ boolean flag = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit + filteredSpawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnState, this.spawnFriendlies, this.spawnEnemies, flag, this.level); // CraftBukkit } else { filteredSpawningCategories = List.of(); } -@@ -559,7 +_,13 @@ +@@ -558,7 +_,13 @@ @Override public void setSpawnSettings(boolean spawnSettings) { @@ -211,7 +211,7 @@ } public String getChunkDebugData(ChunkPos chunkPos) { -@@ -632,12 +_,18 @@ +@@ -631,12 +_,18 @@ @Override public boolean pollTask() { diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch index 700e812b324d..035b390e4150 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch @@ -18,7 +18,7 @@ this.level = level; this.synchronizer = synchronizer; this.entity = entity; -@@ -94,16 +_,22 @@ +@@ -95,16 +_,22 @@ new ClientboundSetPassengersPacket(this.entity), serverPlayer1 -> passengers.contains(serverPlayer1) == this.lastPassengers.contains(serverPlayer1) ); @@ -45,7 +45,7 @@ savedData.tickCarriedBy(serverPlayer, item); Packet updatePacket = savedData.getUpdatePacket(mapId, serverPlayer); if (updatePacket != null) { -@@ -136,7 +_,13 @@ +@@ -137,7 +_,13 @@ } else { this.teleportDelay++; Vec3 vec3 = this.entity.trackingPosition(); @@ -60,7 +60,7 @@ Packet packet = null; boolean flag2 = flag1 || this.tickCount % 60 == 0; boolean flag3 = false; -@@ -218,6 +_,25 @@ +@@ -219,6 +_,25 @@ this.tickCount++; if (this.entity.hurtMarked) { @@ -86,9 +86,9 @@ this.entity.hurtMarked = false; this.synchronizer.sendToTrackingPlayersAndSelf(new ClientboundSetEntityMotionPacket(this.entity)); } -@@ -268,7 +_,10 @@ - +@@ -270,7 +_,10 @@ public void sendPairingData(ServerPlayer player, Consumer> consumer) { + this.entity.updateDataBeforeSync(); if (this.entity.isRemoved()) { - LOGGER.warn("Fetching packet for removed entity {}", this.entity); + // CraftBukkit start - Remove useless error spam, just return @@ -98,7 +98,7 @@ } Packet addEntityPacket = this.entity.getAddEntityPacket(this); -@@ -279,6 +_,11 @@ +@@ -281,6 +_,11 @@ if (this.entity instanceof LivingEntity livingEntity) { Collection syncableAttributes = livingEntity.getAttributes().getSyncableAttributes(); @@ -110,7 +110,7 @@ if (!syncableAttributes.isEmpty()) { consumer.accept(new ClientboundUpdateAttributesPacket(this.entity.getId(), syncableAttributes)); } -@@ -295,8 +_,9 @@ +@@ -297,8 +_,9 @@ } if (!list.isEmpty()) { @@ -121,7 +121,7 @@ } if (!this.entity.getPassengers().isEmpty()) { -@@ -343,6 +_,11 @@ +@@ -345,6 +_,11 @@ if (this.entity instanceof LivingEntity) { Set attributesToSync = ((LivingEntity)this.entity).getAttributes().getAttributesToSync(); if (!attributesToSync.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch index c1e8249b8bd8..56f78b6b8eaa 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -187,7 +_,7 @@ +@@ -189,7 +_,7 @@ final List players = Lists.newArrayList(); public final ServerChunkCache chunkSource; private final MinecraftServer server; @@ -9,7 +9,7 @@ final EntityTickList entityTickList = new EntityTickList(); private final ServerWaypointManager waypointManager; public final PersistentEntitySectionManager entityManager; -@@ -215,25 +_,170 @@ +@@ -217,25 +_,170 @@ private final RandomSequences randomSequences; final LevelDebugSynchronizers debugSynchronizers = new LevelDebugSynchronizers(this); @@ -183,7 +183,7 @@ boolean flag = server.forceSynchronousWrites(); DataFixer fixerUpper = server.getFixerUpper(); EntityPersistentStorage entityPersistentStorage = new EntityStorage( -@@ -255,8 +_,8 @@ +@@ -257,8 +_,8 @@ server.getStructureManager(), dispatcher, chunkGenerator, @@ -194,7 +194,7 @@ flag, this.entityManager::updateChunkStatus, () -> server.overworld().getDataStorage() -@@ -275,7 +_,7 @@ +@@ -277,7 +_,7 @@ this.chunkSource.chunkScanner(), this.registryAccess(), server.getStructureManager(), @@ -203,7 +203,7 @@ chunkGenerator, this.chunkSource.randomState(), this, -@@ -283,9 +_,9 @@ +@@ -285,9 +_,9 @@ seed, fixerUpper ); @@ -216,7 +216,7 @@ } else { this.dragonFight = null; } -@@ -294,7 +_,15 @@ +@@ -296,7 +_,15 @@ this.gameEventDispatcher = new GameEventDispatcher(this); this.randomSequences = Objects.requireNonNullElseGet(randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE)); this.waypointManager = new ServerWaypointManager(); @@ -233,7 +233,7 @@ @Deprecated @VisibleForTesting -@@ -306,8 +_,8 @@ +@@ -308,8 +_,8 @@ this.serverLevelData.setClearWeatherTime(clearTime); this.serverLevelData.setRainTime(weatherTime); this.serverLevelData.setThunderTime(weatherTime); @@ -244,7 +244,7 @@ } @Override -@@ -334,12 +_,25 @@ +@@ -336,12 +_,25 @@ int _int = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); if (this.sleepStatus.areEnoughSleeping(_int) && this.sleepStatus.areEnoughDeepSleeping(_int, this.players)) { @@ -273,7 +273,7 @@ if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -354,9 +_,9 @@ +@@ -356,9 +_,9 @@ if (!this.isDebug() && runsNormally) { long l = this.getGameTime(); profilerFiller.push("blockTicks"); @@ -285,7 +285,7 @@ profilerFiller.pop(); } -@@ -374,7 +_,7 @@ +@@ -376,7 +_,7 @@ this.handlingTick = false; profilerFiller.pop(); @@ -294,7 +294,7 @@ if (hasActiveTickets) { this.resetEmptyTime(); } -@@ -478,11 +_,13 @@ +@@ -484,11 +_,13 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("iceandsnow"); @@ -308,7 +308,7 @@ profilerFiller.popPush("tickBlocks"); if (randomTickSpeed > 0) { -@@ -525,12 +_,12 @@ +@@ -531,12 +_,12 @@ int minBlockZ = pos.getMinBlockZ(); ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("thunder"); @@ -323,7 +323,7 @@ && !this.getBlockState(blockPos.below()).is(BlockTags.LIGHTNING_RODS); if (flag) { SkeletonHorse skeletonHorse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT); -@@ -538,7 +_,7 @@ +@@ -544,7 +_,7 @@ skeletonHorse.setTrap(true); skeletonHorse.setAge(0); skeletonHorse.setPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()); @@ -332,7 +332,7 @@ } } -@@ -546,7 +_,7 @@ +@@ -552,7 +_,7 @@ if (lightningBolt != null) { lightningBolt.snapTo(Vec3.atBottomCenterOf(blockPos)); lightningBolt.setVisualOnly(flag); @@ -341,7 +341,7 @@ } } } -@@ -560,7 +_,7 @@ +@@ -566,7 +_,7 @@ BlockPos blockPos = heightmapPos.below(); Biome biome = this.getBiome(heightmapPos).value(); if (biome.shouldFreeze(this, blockPos)) { @@ -350,7 +350,7 @@ } if (this.isRaining()) { -@@ -572,10 +_,10 @@ +@@ -578,10 +_,10 @@ if (layersValue < Math.min(_int, 8)) { BlockState blockState1 = blockState.setValue(SnowLayerBlock.LAYERS, layersValue + 1); Block.pushEntitiesUp(blockState, blockState1, this, heightmapPos); @@ -363,7 +363,7 @@ } } -@@ -600,6 +_,12 @@ +@@ -606,6 +_,12 @@ } protected BlockPos findLightningTargetAround(BlockPos pos) { @@ -376,7 +376,7 @@ BlockPos heightmapPos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos); Optional optional = this.findLightningRod(heightmapPos); if (optional.isPresent()) { -@@ -607,11 +_,12 @@ +@@ -613,11 +_,12 @@ } else { AABB aabb = AABB.encapsulatingFullBlocks(heightmapPos, heightmapPos.atY(this.getMaxY() + 1)).inflate(3.0); List entitiesOfClass = this.getEntitiesOfClass( @@ -390,7 +390,7 @@ if (heightmapPos.getY() == this.getMinY() - 1) { heightmapPos = heightmapPos.above(2); } -@@ -702,8 +_,8 @@ +@@ -721,8 +_,8 @@ this.serverLevelData.setThunderTime(thunderTime); this.serverLevelData.setRainTime(rainTime); this.serverLevelData.setClearWeatherTime(clearWeatherTime); @@ -401,7 +401,7 @@ } this.oThunderLevel = this.thunderLevel; -@@ -724,6 +_,7 @@ +@@ -743,6 +_,7 @@ this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -409,7 +409,7 @@ if (this.oRainLevel != this.rainLevel) { this.server .getPlayerList() -@@ -746,14 +_,47 @@ +@@ -765,14 +_,47 @@ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -461,7 +461,7 @@ } public void resetEmptyTime() { -@@ -775,18 +_,46 @@ +@@ -794,18 +_,46 @@ } } @@ -508,7 +508,7 @@ } private void tickPassenger(Entity ridingEntity, Entity passengerEntity) { -@@ -795,10 +_,12 @@ +@@ -814,10 +_,12 @@ } else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) { passengerEntity.setOldPosAndRot(); passengerEntity.tickCount++; @@ -521,7 +521,7 @@ profilerFiller.pop(); for (Entity entity : passengerEntity.getPassengers()) { -@@ -829,6 +_,7 @@ +@@ -848,6 +_,7 @@ public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) { ServerChunkCache chunkSource = this.getChunkSource(); if (!skipSave) { @@ -529,7 +529,7 @@ if (progress != null) { progress.progressStartNoAbort(Component.translatable("menu.savingLevel")); } -@@ -845,11 +_,18 @@ +@@ -864,11 +_,18 @@ this.entityManager.autoSave(); } } @@ -549,7 +549,7 @@ } DimensionDataStorage dataStorage = this.getChunkSource().getDataStorage(); -@@ -914,18 +_,40 @@ +@@ -933,18 +_,40 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -593,7 +593,7 @@ } } -@@ -948,41 +_,120 @@ +@@ -967,41 +_,120 @@ this.entityManager.addNewEntity(player); } @@ -719,7 +719,7 @@ if (d * d + d1 * d1 + d2 * d2 < 1024.0) { serverPlayer.connection.send(new ClientboundBlockDestructionPacket(breakerId, pos, progress)); } -@@ -1057,7 +_,7 @@ +@@ -1076,7 +_,7 @@ pos.getX(), pos.getY(), pos.getZ(), @@ -728,7 +728,7 @@ this.dimension(), new ClientboundLevelEventPacket(type, pos, data, false) ); -@@ -1069,6 +_,11 @@ +@@ -1088,6 +_,11 @@ @Override public void gameEvent(Holder gameEvent, Vec3 pos, GameEvent.Context context) { @@ -740,7 +740,7 @@ this.gameEventDispatcher.post(gameEvent, pos, context); } -@@ -1081,17 +_,28 @@ +@@ -1100,17 +_,28 @@ this.getChunkSource().blockChanged(pos); this.pathTypesByPosCache.invalidate(pos); @@ -769,7 +769,7 @@ try { this.isUpdatingNavigations = true; -@@ -1103,15 +_,23 @@ +@@ -1122,15 +_,23 @@ this.isUpdatingNavigations = false; } } @@ -793,7 +793,7 @@ this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, block, null, orientation); } -@@ -1161,6 +_,44 @@ +@@ -1180,6 +_,44 @@ WeightedList blockParticles, Holder explosionSound ) { @@ -838,7 +838,7 @@ Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) { case NONE -> Explosion.BlockInteraction.KEEP; case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); -@@ -1169,10 +_,17 @@ +@@ -1188,10 +_,17 @@ : Explosion.BlockInteraction.KEEP; case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY); case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; @@ -856,7 +856,7 @@ ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles; for (ServerPlayer serverPlayer : this.players) { -@@ -1181,6 +_,8 @@ +@@ -1200,6 +_,8 @@ serverPlayer.connection.send(new ClientboundExplodePacket(vec3, radius, i, optional, particleOptions, explosionSound, blockParticles)); } } @@ -865,7 +865,7 @@ } private Explosion.BlockInteraction getDestroyType(GameRules.Key decayGameRule) { -@@ -1251,19 +_,55 @@ +@@ -1270,19 +_,55 @@ public int sendParticles( T options, double x, double y, double z, int count, double xDist, double yDist, double zDist, double speed ) { @@ -924,7 +924,7 @@ if (this.sendParticles(serverPlayer, overrideLimiter, x, y, z, clientboundLevelParticlesPacket)) { i++; } -@@ -1352,7 +_,7 @@ +@@ -1371,7 +_,7 @@ @Nullable public BlockPos findNearestMapStructure(TagKey structureTag, BlockPos pos, int radius, boolean skipKnownStructures) { @@ -933,7 +933,7 @@ return null; } else { Optional> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag); -@@ -1404,10 +_,36 @@ +@@ -1423,10 +_,36 @@ @Nullable @Override public MapItemSavedData getMapData(MapId mapId) { @@ -971,7 +971,7 @@ this.getServer().overworld().getDataStorage().set(MapItemSavedData.type(mapId), data); } -@@ -1417,7 +_,19 @@ +@@ -1436,7 +_,19 @@ @Override public void setRespawnData(LevelData.RespawnData respawnData) { @@ -992,7 +992,7 @@ } @Override -@@ -1454,6 +_,11 @@ +@@ -1473,6 +_,11 @@ this.debugSynchronizers.dropPoi(blockPos); })); optional1.ifPresent(holder -> this.getServer().execute(() -> { @@ -1004,7 +1004,7 @@ PoiRecord poiRecord = this.getPoiManager().add(blockPos, (Holder)holder); if (poiRecord != null) { this.debugSynchronizers.registerPoi(poiRecord); -@@ -1608,12 +_,12 @@ +@@ -1627,12 +_,12 @@ } public boolean isFlat() { @@ -1019,7 +1019,7 @@ } @Nullable -@@ -1664,6 +_,7 @@ +@@ -1683,6 +_,7 @@ @Override public LevelEntityGetter getEntities() { @@ -1027,7 +1027,7 @@ return this.entityManager.getEntityGetter(); } -@@ -1772,6 +_,28 @@ +@@ -1793,6 +_,28 @@ return this.serverLevelData.getGameRules(); } @@ -1056,7 +1056,7 @@ @Override public CrashReportCategory fillReportDetails(CrashReport report) { CrashReportCategory crashReportCategory = super.fillReportDetails(report); -@@ -1800,6 +_,7 @@ +@@ -1837,6 +_,7 @@ if (entity instanceof WaypointTransmitter waypointTransmitter && waypointTransmitter.isTransmittingWaypoint()) { ServerLevel.this.getWaypointManager().trackWaypoint(waypointTransmitter); } @@ -1064,7 +1064,7 @@ } @Override -@@ -1813,17 +_,24 @@ +@@ -1850,17 +_,24 @@ @Override public void onTickingStart(Entity entity) { @@ -1090,7 +1090,7 @@ if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.add(serverPlayer); if (serverPlayer.isReceivingWaypoints()) { -@@ -1838,7 +_,7 @@ +@@ -1875,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1099,7 +1099,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1855,10 +_,52 @@ +@@ -1892,10 +_,52 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -1152,7 +1152,7 @@ ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); -@@ -1867,7 +_,7 @@ +@@ -1904,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1161,7 +1161,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1885,6 +_,15 @@ +@@ -1922,6 +_,15 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); ServerLevel.this.debugSynchronizers.dropEntity(entity); @@ -1177,7 +1177,7 @@ } @Override -@@ -1892,4 +_,24 @@ +@@ -1929,4 +_,24 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::move); } } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index cf3803fd1603..8659dc0f90d5 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -253,7 +_,8 @@ +@@ -256,7 +_,8 @@ private int levitationStartTime; private boolean disconnected; private int requestedViewDistance = 2; @@ -10,7 +10,7 @@ @Nullable private Vec3 startingToFallPosition; @Nullable -@@ -302,6 +_,13 @@ +@@ -305,6 +_,13 @@ } } @@ -24,7 +24,7 @@ @Override public void sendSlotChange(AbstractContainerMenu container, int slot, ItemStack stack) { ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(container.containerId, container.incrementStateId(), slot, stack)); -@@ -337,6 +_,32 @@ +@@ -340,6 +_,32 @@ } } @@ -57,7 +57,7 @@ @Override public void dataChanged(AbstractContainerMenu containerMenu, int dataSlotIndex, int value) { } -@@ -365,10 +_,43 @@ +@@ -368,10 +_,43 @@ public void sendSystemMessage(Component message) { ServerPlayer.this.sendSystemMessage(message); } @@ -101,7 +101,7 @@ public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) { super(level, gameProfile); -@@ -379,8 +_,14 @@ +@@ -382,8 +_,14 @@ this.recipeBook = new ServerRecipeBook((recipe, output) -> server.getRecipeManager().listDisplaysForRecipe(recipe, output)); this.stats = server.getPlayerList().getPlayerStats(this); this.advancements = server.getPlayerList().getPlayerAdvancements(this); @@ -117,7 +117,7 @@ } @Override -@@ -398,6 +_,7 @@ +@@ -401,6 +_,7 @@ this.seenCredits = input.getBooleanOr("seenCredits", false); input.read("recipeBook", ServerRecipeBook.Packed.CODEC) .ifPresent(packed -> this.recipeBook.loadUntrusted(packed, key -> this.server.getRecipeManager().byKey(key).isPresent())); @@ -125,7 +125,7 @@ if (this.isSleeping()) { this.stopSleeping(); } -@@ -405,6 +_,19 @@ +@@ -408,6 +_,19 @@ this.respawnConfig = input.read("respawn", ServerPlayer.RespawnConfig.CODEC).orElse(null); this.spawnExtraParticlesOnFall = input.getBooleanOr("spawn_extra_particles_on_fall", false); this.raidOmenPosition = input.read("raid_omen_position", BlockPos.CODEC).orElse(null); @@ -145,7 +145,7 @@ this.gameMode .setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(input, "playerGameType")), readPlayerMode(input, "previousPlayerGameType")); this.setShoulderEntityLeft(input.read("ShoulderEntityLeft", CompoundTag.CODEC).orElseGet(CompoundTag::new)); -@@ -432,12 +_,24 @@ +@@ -435,12 +_,24 @@ if (!this.getShoulderEntityRight().isEmpty()) { output.store("ShoulderEntityRight", CompoundTag.CODEC, this.getShoulderEntityRight()); } @@ -171,7 +171,7 @@ ValueOutput valueOutput = output.child("RootVehicle"); valueOutput.store("Attach", UUIDUtil.CODEC, vehicle.getUUID()); rootVehicle.save(valueOutput.child("Entity")); -@@ -449,7 +_,7 @@ +@@ -452,7 +_,7 @@ if (!optional.isEmpty()) { ServerLevel serverLevel = this.level(); Entity entity = EntityType.loadEntityRecursive( @@ -180,7 +180,7 @@ ); if (entity != null) { UUID uuid = optional.get().read("Attach", UUIDUtil.CODEC).orElse(null); -@@ -466,10 +_,10 @@ +@@ -469,10 +_,10 @@ if (!this.isPassenger()) { LOGGER.warn("Couldn't reattach entity to player"); @@ -193,7 +193,7 @@ } } } -@@ -481,6 +_,7 @@ +@@ -484,6 +_,7 @@ ValueOutput.ValueOutputList valueOutputList = output.childrenList("ender_pearls"); for (ThrownEnderpearl thrownEnderpearl : this.enderPearls) { @@ -201,7 +201,7 @@ if (thrownEnderpearl.isRemoved()) { LOGGER.warn("Trying to save removed ender pearl, skipping"); } else { -@@ -513,6 +_,16 @@ +@@ -516,6 +_,16 @@ } } @@ -218,7 +218,7 @@ public void setExperiencePoints(int experiencePoints) { float f = this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -570,6 +_,11 @@ +@@ -580,6 +_,11 @@ @Override public void tick() { @@ -230,7 +230,7 @@ this.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); -@@ -577,9 +_,18 @@ +@@ -587,9 +_,18 @@ this.invulnerableTime--; } @@ -252,7 +252,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -638,10 +_,10 @@ +@@ -648,10 +_,10 @@ public void doTick() { try { @@ -265,7 +265,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -671,7 +_,7 @@ +@@ -681,7 +_,7 @@ if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -274,7 +274,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -702,6 +_,12 @@ +@@ -712,6 +_,12 @@ this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float)this.lastRecordedExperience)); } @@ -287,7 +287,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float)this.lastRecordedLevel)); -@@ -715,6 +_,21 @@ +@@ -725,6 +_,21 @@ if (this.tickCount % 20 == 0) { CriteriaTriggers.LOCATION.trigger(this); } @@ -309,7 +309,7 @@ } catch (Throwable var4) { CrashReport crashReport = CrashReport.forThrowable(var4, "Ticking player"); CrashReportCategory crashReportCategory = crashReport.addCategory("Player being ticked"); -@@ -739,7 +_,7 @@ +@@ -749,7 +_,7 @@ if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { if (this.tickCount % 20 == 0) { if (this.getHealth() < this.getMaxHealth()) { @@ -318,7 +318,7 @@ } float saturationLevel = this.foodData.getSaturationLevel(); -@@ -759,6 +_,7 @@ +@@ -769,6 +_,7 @@ this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft()); this.playShoulderEntityAmbientSound(this.getShoulderEntityRight()); if (this.fallDistance > 0.5 || this.isInWater() || this.getAbilities().flying || this.isSleeping() || this.isInPowderSnow) { @@ -326,7 +326,7 @@ this.removeEntitiesOnShoulder(); } } -@@ -803,35 +_,64 @@ +@@ -813,35 +_,64 @@ @Override public void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { @@ -398,7 +398,7 @@ } @Override -@@ -868,15 +_,36 @@ +@@ -878,15 +_,36 @@ } private void updateScoreForCriteria(ObjectiveCriteria criteria, int points) { @@ -444,7 +444,7 @@ this.connection .send( new ClientboundPlayerCombatKillPacket(this.getId(), deathMessage), -@@ -893,6 +_,65 @@ +@@ -903,6 +_,65 @@ } ) ); @@ -510,7 +510,7 @@ Team team = this.getTeam(); if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) { this.server.getPlayerList().broadcastSystemMessage(deathMessage, false); -@@ -902,7 +_,7 @@ +@@ -912,7 +_,7 @@ this.server.getPlayerList().broadcastSystemToAllExceptTeam(this, deathMessage); } } else { @@ -519,7 +519,7 @@ } this.removeEntitiesOnShoulder(); -@@ -910,11 +_,35 @@ +@@ -920,11 +_,35 @@ this.tellNeutralMobsThatIDied(); } @@ -558,7 +558,7 @@ LivingEntity killCredit = this.getKillCredit(); if (killCredit != null) { this.awardStat(Stats.ENTITY_KILLED_BY.get(killCredit.getType())); -@@ -948,10 +_,10 @@ +@@ -958,10 +_,10 @@ if (entity != this) { super.awardKillScore(entity, damageSource); Scoreboard scoreboard = this.level().getScoreboard(); @@ -571,7 +571,7 @@ } else { this.awardStat(Stats.MOB_KILLS); } -@@ -963,12 +_,11 @@ +@@ -973,12 +_,11 @@ } private void handleTeamKill(ScoreHolder scoreHolder, ScoreHolder teamMember, ObjectiveCriteria[] criteria) { @@ -586,7 +586,7 @@ } } } -@@ -979,9 +_,20 @@ +@@ -989,9 +_,20 @@ return false; } else { Entity entity = damageSource.getEntity(); @@ -609,12 +609,12 @@ } } -@@ -991,25 +_,86 @@ +@@ -1001,25 +_,86 @@ } private boolean isPvpAllowed() { -- return this.server.isPvpAllowed(); -+ return this.level().getWorld().getPVP(); // CraftBukkit - this.server.isPvpAllowed() -> this.level().getWorld().getPVP() +- return this.level().isPvpAllowed(); ++ return this.level().getWorld().getPVP(); // CraftBukkit - this.level().isPvpAllowed() -> this.level().getWorld().getPVP() } - public TeleportTransition findRespawnPositionAndUseSpawnBlock(boolean useCharge, TeleportTransition.PostTeleportTransition postTeleportTransition) { @@ -702,9 +702,9 @@ } public boolean isReceivingWaypoints() { -@@ -1042,14 +_,16 @@ - Block block = blockState.getBlock(); - if (block instanceof RespawnAnchorBlock && (flag || blockState.getValue(RespawnAnchorBlock.CHARGE) > 0) && RespawnAnchorBlock.canSetSpawn(level)) { +@@ -1054,14 +_,16 @@ + && (flag || blockState.getValue(RespawnAnchorBlock.CHARGE) > 0) + && RespawnAnchorBlock.canSetSpawn(level, blockPos)) { Optional optional = RespawnAnchorBlock.findStandUpPosition(EntityType.PLAYER, level, blockPos); + Runnable consumeAnchorCharge = null; // Paper - Fix SPIGOT-5989 (don't use charge until after respawn event) if (!flag && useCharge && optional.isPresent()) { @@ -715,14 +715,14 @@ - return optional.map(pos -> ServerPlayer.RespawnPosAngle.of(pos, blockPos, 0.0F)); + return optional.map(pos -> ServerPlayer.RespawnPosAngle.of(pos, blockPos, 0.0F, false, true, finalConsumeAnchorCharge)); // Paper - Fix SPIGOT-5989 (don't use charge until after respawn event) - } else if (block instanceof BedBlock && BedBlock.canSetSpawn(level)) { + } else if (block instanceof BedBlock && level.environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, blockPos).canSetSpawn(level)) { return BedBlock.findStandUpPosition(EntityType.PLAYER, level, blockPos, blockState.getValue(BedBlock.FACING), yaw) - .map(pos -> ServerPlayer.RespawnPosAngle.of(pos, blockPos, 0.0F)); + .map(pos -> ServerPlayer.RespawnPosAngle.of(pos, blockPos, 0.0F, true, false, null)); // Paper - Fix SPIGOT-5989 } else if (!flag) { return Optional.empty(); } else { -@@ -1057,7 +_,7 @@ +@@ -1069,7 +_,7 @@ BlockState blockState1 = level.getBlockState(blockPos.above()); boolean isPossibleToRespawnInThis1 = blockState1.getBlock().isPossibleToRespawnInThis(blockState1); return isPossibleToRespawnInThis && isPossibleToRespawnInThis1 @@ -731,7 +731,7 @@ : Optional.empty(); } } -@@ -1075,6 +_,7 @@ +@@ -1087,6 +_,7 @@ @Nullable @Override public ServerPlayer teleport(TeleportTransition teleportTransition) { @@ -739,7 +739,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1084,17 +_,52 @@ +@@ -1096,17 +_,52 @@ ServerLevel level = teleportTransition.newLevel(); ServerLevel serverLevel = this.level(); @@ -795,7 +795,7 @@ this.isChangingDimension = true; LevelData levelData = level.getLevelData(); this.connection.send(new ClientboundRespawnPacket(this.createCommonSpawnInfo(level), (byte)3)); -@@ -1103,16 +_,30 @@ +@@ -1115,16 +_,30 @@ playerList.sendPlayerPermissionLevel(this); serverLevel.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); this.unsetRemoved(); @@ -828,7 +828,7 @@ this.connection.resetPosition(); level.addDuringTeleport(this); profilerFiller.pop(); -@@ -1127,10 +_,37 @@ +@@ -1139,10 +_,37 @@ this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(teleportTransition, serverLevel); @@ -866,7 +866,7 @@ @Override public void forceSetRotation(float yRot, boolean yRelative, float xRot, boolean xRelative) { -@@ -1141,12 +_,26 @@ +@@ -1153,12 +_,26 @@ public void triggerDimensionChangeTriggers(ServerLevel level) { ResourceKey resourceKey = level.dimension(); ResourceKey resourceKey1 = this.level().dimension(); @@ -896,7 +896,7 @@ this.enteredNetherPosition = null; } } -@@ -1162,12 +_,11 @@ +@@ -1174,9 +_,8 @@ this.containerMenu.broadcastChanges(); } @@ -905,30 +905,29 @@ - Direction direction = this.level().getBlockState(bedPos).getValue(HorizontalDirectionalBlock.FACING); + // CraftBukkit start - moved bed result checks from below into separate method + private Either getBedResult(BlockPos bedPos, Direction direction) { - if (this.isSleeping() || !this.isAlive()) { - return Either.left(Player.BedSleepingProblem.OTHER_PROBLEM); -- } else if (!this.level().dimensionType().natural()) { -+ } else if (!this.level().dimensionType().natural() && !this.level().dimensionType().bedWorks()) { // CraftBukkit - moved bed result checks from below into separate method - return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_HERE); - } else if (!this.bedInRange(bedPos, direction)) { - return Either.left(Player.BedSleepingProblem.TOO_FAR_AWAY); -@@ -1175,7 +_,7 @@ - return Either.left(Player.BedSleepingProblem.OBSTRUCTED); - } else { - this.setRespawnPosition( -- new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(this.level().dimension(), bedPos, this.getYRot(), this.getXRot()), false), true -+ new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(this.level().dimension(), bedPos, this.getYRot(), this.getXRot()), false), true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.BED // Paper - Add PlayerSetSpawnEvent - ); - if (this.level().isBrightOutside()) { - return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW); -@@ -1195,7 +_,34 @@ - } + if (!this.isSleeping() && this.isAlive()) { + BedRule bedRule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, bedPos); + boolean canSleep = bedRule.canSleep(this.level()); +@@ -1190,7 +_,7 @@ + } else { + if (canSetSpawn) { + this.setRespawnPosition( +- new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(this.level().dimension(), bedPos, this.getYRot(), this.getXRot()), false), true ++ new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(this.level().dimension(), bedPos, this.getYRot(), this.getXRot()), false), true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.BED // Paper - Add PlayerSetSpawnEvent + ); } -- Either either = super.startSleepInBed(bedPos).ifRight(unit -> { -+ // CraftBukkit start -+ return Either.right(Unit.INSTANCE); +@@ -1212,7 +_,37 @@ + } + } + +- Either either = super.startSleepInBed(bedPos).ifRight(unit -> { ++ // CraftBukkit start ++ return Either.right(Unit.INSTANCE); ++ } + } ++ } else { ++ return Either.left(Player.BedSleepingProblem.OTHER_PROBLEM); + } + } + @@ -952,12 +951,23 @@ + + { + { -+ Either either = super.startSleepInBed(bedPos, force).ifRight(unit -> { -+ // CraftBukkit end - this.awardStat(Stats.SLEEP_IN_BED); - CriteriaTriggers.SLEPT_IN_BED.trigger(this); - }); -@@ -1231,21 +_,29 @@ ++ Either either = super.startSleepInBed(bedPos, force).ifRight(unit -> { ++ // CraftBukkit end + this.awardStat(Stats.SLEEP_IN_BED); + CriteriaTriggers.SLEPT_IN_BED.trigger(this); + }); +@@ -1222,10 +_,7 @@ + + this.level().updateSleepingPlayerList(); + return either; +- } + } +- } else { +- return Either.left(Player.BedSleepingProblem.OTHER_PROBLEM); + } + } + +@@ -1251,21 +_,29 @@ @Override public void stopSleepInBed(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) { @@ -990,7 +1000,7 @@ } @Override -@@ -1293,8 +_,9 @@ +@@ -1313,8 +_,9 @@ this.connection.send(new ClientboundShowDialogPacket(dialog)); } @@ -1001,7 +1011,7 @@ } @Override -@@ -1302,12 +_,39 @@ +@@ -1322,12 +_,39 @@ if (menu == null) { return OptionalInt.empty(); } else { @@ -1042,7 +1052,7 @@ if (abstractContainerMenu == null) { if (this.isSpectator()) { this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true); -@@ -1315,10 +_,14 @@ +@@ -1335,10 +_,14 @@ return OptionalInt.empty(); } else { @@ -1059,7 +1069,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1331,14 +_,25 @@ +@@ -1351,14 +_,25 @@ @Override public void openHorseInventory(AbstractHorse horse, Container inventory) { @@ -1088,7 +1098,7 @@ this.initMenu(this.containerMenu); } -@@ -1360,10 +_,30 @@ +@@ -1380,10 +_,30 @@ @Override public void closeContainer() { @@ -1119,7 +1129,7 @@ @Override public void doCloseContainer() { this.containerMenu.removed(this); -@@ -1386,19 +_,19 @@ +@@ -1406,19 +_,19 @@ int rounded = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); if (rounded > 0) { this.awardStat(Stats.SWIM_ONE_CM, rounded); @@ -1142,7 +1152,7 @@ } } else if (this.onClimbable()) { if (dy > 0.0) { -@@ -1409,13 +_,13 @@ +@@ -1429,13 +_,13 @@ if (rounded > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, rounded); @@ -1159,7 +1169,7 @@ } } } else if (this.isFallFlying()) { -@@ -1457,13 +_,13 @@ +@@ -1477,13 +_,13 @@ @Override public void awardStat(Stat stat, int amount) { this.stats.increment(this, stat, amount); @@ -1175,7 +1185,7 @@ } @Override -@@ -1494,9 +_,9 @@ +@@ -1514,9 +_,9 @@ super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1187,7 +1197,7 @@ } } -@@ -1509,6 +_,13 @@ +@@ -1531,6 +_,13 @@ public void disconnect() { this.disconnected = true; this.ejectPassengers(); @@ -1201,7 +1211,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, false); } -@@ -1520,6 +_,7 @@ +@@ -1542,6 +_,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1209,7 +1219,7 @@ } @Override -@@ -1554,12 +_,12 @@ +@@ -1576,12 +_,12 @@ this.onUpdateAbilities(); if (keepEverything) { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1224,7 +1234,7 @@ } this.getInventory().replaceWith(that.getInventory()); -@@ -1570,7 +_,7 @@ +@@ -1592,7 +_,7 @@ this.portalProcess = that.portalProcess; } else { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1233,7 +1243,7 @@ if (this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || that.isSpectator()) { this.getInventory().replaceWith(that.getInventory()); this.experienceLevel = that.experienceLevel; -@@ -1586,7 +_,7 @@ +@@ -1608,7 +_,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1242,7 +1252,7 @@ this.seenCredits = that.seenCredits; this.enteredNetherPosition = that.enteredNetherPosition; this.chunkTrackingView = that.chunkTrackingView; -@@ -1640,7 +_,7 @@ +@@ -1662,7 +_,7 @@ } @Override @@ -1251,7 +1261,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, true); } -@@ -1649,7 +_,7 @@ +@@ -1671,7 +_,7 @@ this.setCamera(this); } @@ -1259,8 +1269,8 @@ + boolean flag = super.teleportTo(level, x, y, z, relativeMovements, yaw, pitch, setCamera, cause); // CraftBukkit if (flag) { this.setYHeadRot(relativeMovements.contains(Relative.Y_ROT) ? this.getYHeadRot() + yaw : yaw); - } -@@ -1687,9 +_,19 @@ + this.connection.resetFlyingTicks(); +@@ -1710,9 +_,19 @@ } public boolean setGameMode(GameType gameMode) { @@ -1282,7 +1292,7 @@ } else { this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, gameMode.getId())); if (gameMode == GameType.SPECTATOR) { -@@ -1705,7 +_,7 @@ +@@ -1728,7 +_,7 @@ this.onUpdateAbilities(); this.updateEffectVisibility(); @@ -1291,7 +1301,7 @@ } } -@@ -1761,8 +_,13 @@ +@@ -1784,8 +_,13 @@ } public void sendChatMessage(OutgoingChatMessage message, boolean filtered, ChatType.Bound boundChatType) { @@ -1306,7 +1316,7 @@ } } -@@ -1773,7 +_,42 @@ +@@ -1796,7 +_,42 @@ } public void updateOptions(ClientInformation clientInformation) { @@ -1349,7 +1359,7 @@ this.requestedViewDistance = clientInformation.viewDistance(); this.chatVisibility = clientInformation.chatVisibility(); this.canChatColor = clientInformation.chatColors(); -@@ -1859,8 +_,23 @@ +@@ -1882,8 +_,23 @@ Entity camera = this.getCamera(); this.camera = (Entity)(entityToSpectate == null ? this : entityToSpectate); if (camera != this.camera) { @@ -1374,7 +1384,7 @@ } if (entityToSpectate != null) { -@@ -1894,11 +_,11 @@ +@@ -1917,11 +_,11 @@ @Nullable public Component getTabListDisplayName() { @@ -1388,7 +1398,7 @@ } @Override -@@ -1929,11 +_,62 @@ +@@ -1952,11 +_,62 @@ } public void setRespawnPosition(@Nullable ServerPlayer.RespawnConfig respawnConfig, boolean displayInChat) { @@ -1453,7 +1463,7 @@ } public SectionPos getLastSectionPos() { -@@ -1963,16 +_,23 @@ +@@ -1986,16 +_,23 @@ } @Override @@ -1482,7 +1492,7 @@ return itemEntity; } -@@ -2095,9 +_,9 @@ +@@ -2118,9 +_,9 @@ } @Override @@ -1494,7 +1504,7 @@ if (vehicle instanceof LivingEntity livingEntity) { for (MobEffectInstance mobEffectInstance : livingEntity.getActiveEffects()) { this.connection.send(new ClientboundRemoveMobEffectPacket(vehicle.getId(), mobEffectInstance.getEffect())); -@@ -2214,7 +_,7 @@ +@@ -2237,7 +_,7 @@ } public static long placeEnderPearlTicket(ServerLevel level, ChunkPos pos) { @@ -1503,7 +1513,7 @@ return TicketType.ENDER_PEARL.timeout(); } -@@ -2244,9 +_,11 @@ +@@ -2267,9 +_,11 @@ } } @@ -1518,7 +1528,7 @@ } private static float calculateLookAtYaw(Vec3 position, BlockPos towardsPos) { -@@ -2266,4 +_,138 @@ +@@ -2289,4 +_,138 @@ ); public static final ServerPlayer.SavedPosition EMPTY = new ServerPlayer.SavedPosition(Optional.empty(), Optional.empty(), Optional.empty()); } diff --git a/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch b/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch index 45fbeae2000c..19a61c1fd8da 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java -@@ -19,6 +_,11 @@ +@@ -23,6 +_,11 @@ public static final TicketType PORTAL = register("portal", 300L, 15); public static final TicketType ENDER_PEARL = register("ender_pearl", 40L, 14); public static final TicketType UNKNOWN = register("unknown", 1L, 18); @@ -10,9 +10,9 @@ + public static final TicketType FUTURE_AWAIT = register("future_await", NO_TIMEOUT, FLAG_LOADING | FLAG_SIMULATION); // Paper + public static final TicketType CHUNK_LOAD = register("chunk_load", NO_TIMEOUT, FLAG_LOADING); // Paper - moonrise - private static TicketType register(String name, long timeout, int flags) { + private static TicketType register(String name, long timeout, @TicketType.Flags int flags) { return Registry.register(BuiltInRegistries.TICKET_TYPE, name, new TicketType(timeout, flags)); -@@ -44,7 +_,14 @@ +@@ -48,8 +_,15 @@ return (this.flags & 16) != 0; } @@ -27,4 +27,5 @@ + return this.timeout() != 0L; + // Paper end - chunk-gc config } - } + + @Retention(RetentionPolicy.CLASS) diff --git a/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch b/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch index 7f48377c41bc..bb40ae05343f 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/WorldGenRegion.java +++ b/net/minecraft/server/level/WorldGenRegion.java -@@ -151,6 +_,28 @@ +@@ -152,6 +_,28 @@ return chessboardDistance < this.generatingStep.directDependencies().size(); } @@ -29,7 +29,7 @@ @Override public BlockState getBlockState(BlockPos pos) { return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos); -@@ -198,7 +_,8 @@ +@@ -199,7 +_,8 @@ if (blockState.isAir()) { return false; } else { @@ -39,7 +39,7 @@ BlockEntity blockEntity = blockState.hasBlockEntity() ? this.getBlockEntity(pos) : null; Block.dropResources(blockState, this.level, pos, blockEntity, entity, ItemStack.EMPTY); } -@@ -242,6 +_,7 @@ +@@ -243,6 +_,7 @@ } } @@ -47,7 +47,7 @@ @Override public boolean ensureCanWrite(BlockPos pos) { int sectionPosX = SectionPos.blockToSectionCoord(pos.getX()); -@@ -259,6 +_,8 @@ +@@ -260,6 +_,8 @@ return true; } else { @@ -56,7 +56,7 @@ Util.logAndPauseIfInIde( "Detected setBlock in a far chunk [" + sectionPosX -@@ -270,6 +_,12 @@ +@@ -271,6 +_,12 @@ + this.generatingStep.targetStatus() + (this.currentlyGenerating == null ? "" : ", currently generating: " + this.currentlyGenerating.get()) ); @@ -69,7 +69,7 @@ return false; } } -@@ -280,7 +_,7 @@ +@@ -281,7 +_,7 @@ return false; } else { ChunkAccess chunk = this.getChunk(pos); @@ -78,7 +78,7 @@ if (blockState != null) { this.level.updatePOIOnBlockStateChange(pos, blockState, state); } -@@ -294,6 +_,17 @@ +@@ -295,6 +_,17 @@ chunk.removeBlockEntity(pos); } } else { @@ -96,7 +96,7 @@ CompoundTag compoundTag = new CompoundTag(); compoundTag.putInt("x", pos.getX()); compoundTag.putInt("y", pos.getY()); -@@ -319,6 +_,13 @@ +@@ -320,6 +_,13 @@ @Override public boolean addFreshEntity(Entity entity) { diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index cb7f5006c505..9356630f9dd1 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -210,6 +_,38 @@ +@@ -213,6 +_,38 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.slf4j.Logger; @@ -39,7 +39,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements GameProtocols.Context, -@@ -228,7 +_,9 @@ +@@ -232,7 +_,9 @@ private int tickCount; private int ackBlockChangesUpTo = -1; private final TickThrottler chatSpamThrottler = new TickThrottler(20, 200); @@ -49,7 +49,7 @@ private double firstGoodX; private double firstGoodY; private double firstGoodZ; -@@ -254,14 +_,33 @@ +@@ -258,14 +_,33 @@ private int receivedMovePacketCount; private int knownMovePacketCount; private boolean receivedMovementThisTick; @@ -83,7 +83,7 @@ public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player, CommonListenerCookie cookie) { super(server, connection, cookie); -@@ -270,8 +_,22 @@ +@@ -274,8 +_,22 @@ player.connection = this; player.getTextFilter().join(); this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(player.getUUID(), server::enforceSecureProfile); @@ -108,7 +108,7 @@ @Override public void tick() { -@@ -284,11 +_,13 @@ +@@ -288,11 +_,13 @@ this.keepConnectionAlive(); this.chatSpamThrottler.tick(); this.dropSpamThrottler.tick(); @@ -123,7 +123,7 @@ } } } -@@ -304,8 +_,8 @@ +@@ -308,8 +_,8 @@ this.knownMovePacketCount = this.receivedMovePacketCount; if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger() && !this.player.isDeadOrDying()) { if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player)) { @@ -134,7 +134,7 @@ return true; } } else { -@@ -323,8 +_,8 @@ +@@ -327,8 +_,8 @@ this.vehicleLastGoodZ = this.lastVehicle.getZ(); if (this.clientVehicleIsFloating && this.lastVehicle.getControllingPassenger() == this.player) { if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle)) { @@ -145,7 +145,7 @@ return true; } } else { -@@ -337,6 +_,12 @@ +@@ -341,6 +_,12 @@ this.aboveGroundVehicleTickCount = 0; } @@ -158,7 +158,7 @@ return false; } -@@ -397,11 +_,37 @@ +@@ -406,11 +_,37 @@ @Override public void handlePlayerInput(ServerboundPlayerInputPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -198,7 +198,7 @@ } private static boolean containsInvalidValues(double x, double y, double z, float yRot, float xRot) { -@@ -420,17 +_,29 @@ +@@ -429,17 +_,29 @@ public void handleMoveVehicle(ServerboundMoveVehiclePacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (containsInvalidValues(packet.position().x(), packet.position().y(), packet.position().z(), packet.yRot(), packet.xRot())) { @@ -232,7 +232,7 @@ float f = Mth.wrapDegrees(packet.yRot()); float f1 = Mth.wrapDegrees(packet.xRot()); double d3 = d - this.vehicleFirstGoodX; -@@ -438,16 +_,61 @@ +@@ -447,16 +_,61 @@ double d5 = d2 - this.vehicleFirstGoodZ; double d6 = rootVehicle.getDeltaMovement().lengthSqr(); double d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -298,7 +298,7 @@ boolean flag = rootVehicle.verticalCollisionBelow; if (rootVehicle instanceof LivingEntity livingEntity && livingEntity.onClimbable()) { livingEntity.resetFallDistance(); -@@ -464,7 +_,7 @@ +@@ -473,7 +_,7 @@ d5 = d2 - rootVehicle.getZ(); d7 = d3 * d3 + d4 * d4 + d5 * d5; boolean flag1 = false; @@ -307,7 +307,7 @@ flag1 = true; LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", rootVehicle.getPlainTextName(), this.player.getPlainTextName(), Math.sqrt(d7)); } -@@ -478,6 +_,57 @@ +@@ -487,6 +_,57 @@ } rootVehicle.absSnapTo(d, d1, d2, f, f1); @@ -365,7 +365,7 @@ this.player.level().getChunkSource().move(this.player); Vec3 vec3 = new Vec3(rootVehicle.getX() - x, rootVehicle.getY() - y, rootVehicle.getZ() - z); this.handlePlayerKnownMovement(vec3); -@@ -508,12 +_,12 @@ +@@ -517,12 +_,12 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (packet.getId() == this.awaitingTeleport) { if (this.awaitingPositionFromClient == null) { @@ -380,7 +380,7 @@ this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, -@@ -525,12 +_,20 @@ +@@ -534,12 +_,20 @@ this.lastGoodZ = this.awaitingPositionFromClient.z; this.player.hasChangedDimension(); this.awaitingPositionFromClient = null; @@ -401,7 +401,7 @@ this.player.setClientLoaded(true); } -@@ -552,6 +_,7 @@ +@@ -561,6 +_,7 @@ @Override public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -409,7 +409,7 @@ this.player.getRecipeBook().setBookSetting(packet.getBookType(), packet.isOpen(), packet.isFiltering()); } -@@ -567,25 +_,110 @@ +@@ -576,25 +_,110 @@ } } @@ -525,25 +525,25 @@ } ); } -@@ -595,7 +_,7 @@ +@@ -602,7 +_,7 @@ + @Override + public void handleSetCommandBlock(ServerboundSetCommandBlockPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); - if (!this.server.isCommandBlockEnabled()) { - this.player.sendSystemMessage(Component.translatable("advMode.notEnabled")); -- } else if (!this.player.canUseGameMasterBlocks()) { -+ } else if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission +- if (!this.player.canUseGameMasterBlocks()) { ++ if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock baseCommandBlock = null; -@@ -650,7 +_,7 @@ +@@ -663,7 +_,7 @@ + @Override + public void handleSetCommandMinecart(ServerboundSetCommandMinecartPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); - if (!this.server.isCommandBlockEnabled()) { - this.player.sendSystemMessage(Component.translatable("advMode.notEnabled")); -- } else if (!this.player.canUseGameMasterBlocks()) { -+ } else if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission +- if (!this.player.canUseGameMasterBlocks()) { ++ if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock commandBlock = packet.getCommandBlock(this.player.level()); -@@ -678,11 +_,11 @@ +@@ -701,11 +_,11 @@ boolean flag = this.player.hasInfiniteMaterials() && packet.includeData(); ItemStack cloneItemStack = blockState.getCloneItemStack(serverLevel, blockPos, flag); if (!cloneItemStack.isEmpty()) { @@ -557,7 +557,7 @@ } } } -@@ -709,27 +_,40 @@ +@@ -732,27 +_,40 @@ if (entityOrPart != null && this.player.canInteractWithEntity(entityOrPart, 3.0)) { ItemStack pickResult = entityOrPart.getPickResult(); if (pickResult != null && !pickResult.isEmpty()) { @@ -604,7 +604,7 @@ } } -@@ -907,6 +_,13 @@ +@@ -930,6 +_,13 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); int item = packet.getItem(); if (this.player.containerMenu instanceof MerchantMenu merchantMenu) { @@ -618,7 +618,7 @@ if (!merchantMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, merchantMenu); return; -@@ -919,6 +_,51 @@ +@@ -942,6 +_,51 @@ @Override public void handleEditBook(ServerboundEditBookPacket packet) { @@ -670,7 +670,7 @@ int slot = packet.slot(); if (Inventory.isHotbarSlot(slot) || slot == 40) { List list = Lists.newArrayList(); -@@ -933,10 +_,14 @@ +@@ -956,10 +_,14 @@ } private void updateBookContents(List pages, int index) { @@ -686,7 +686,7 @@ } } -@@ -949,7 +_,8 @@ +@@ -972,7 +_,8 @@ itemStack.set( DataComponents.WRITTEN_BOOK_CONTENT, new WrittenBookContent(this.filterableFromOutgoing(title), this.player.getPlainTextName(), 0, list, true) ); @@ -696,7 +696,7 @@ } } -@@ -997,27 +_,35 @@ +@@ -1020,27 +_,35 @@ public void handleMovePlayer(ServerboundMovePlayerPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (containsInvalidValues(packet.getX(0.0), packet.getY(0.0), packet.getZ(0.0), packet.getYRot(0.0F), packet.getXRot(0.0F))) { @@ -739,7 +739,7 @@ double x = this.player.getX(); double y = this.player.getY(); double z = this.player.getZ(); -@@ -1026,6 +_,16 @@ +@@ -1049,6 +_,16 @@ double d5 = d2 - this.firstGoodZ; double d6 = this.player.getDeltaMovement().lengthSqr(); double d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -756,7 +756,7 @@ if (this.player.isSleeping()) { if (d7 > 1.0) { this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); -@@ -1035,36 +_,108 @@ +@@ -1058,36 +_,108 @@ if (serverLevel.tickRateManager().runsNormally()) { this.receivedMovePacketCount++; int i = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -875,7 +875,7 @@ double verticalDelta = d4; d3 = d - this.player.getX(); d4 = d1 - this.player.getY(); -@@ -1074,20 +_,100 @@ +@@ -1097,20 +_,100 @@ d5 = d2 - this.player.getZ(); d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -985,7 +985,7 @@ this.player.absSnapTo(d, d1, d2, f, f1); boolean isAutoSpinAttack = this.player.isAutoSpinAttack(); this.clientIsFloating = verticalDelta >= -0.03125 -@@ -1122,7 +_,7 @@ +@@ -1145,7 +_,7 @@ this.lastGoodY = this.player.getY(); this.lastGoodZ = this.player.getZ(); } else { @@ -994,7 +994,7 @@ this.player.doCheckFallDamage(this.player.getX() - x, this.player.getY() - y, this.player.getZ() - z, packet.isOnGround()); this.player.removeLatestMovementRecording(); } -@@ -1158,6 +_,7 @@ +@@ -1181,6 +_,7 @@ this.player.getXRot() ); } @@ -1002,7 +1002,7 @@ return true; } else { -@@ -1181,10 +_,77 @@ +@@ -1204,10 +_,77 @@ } public void teleport(double x, double y, double z, float yRot, float xRot) { @@ -1081,7 +1081,7 @@ this.awaitingTeleportTime = this.tickCount; if (++this.awaitingTeleport == Integer.MAX_VALUE) { this.awaitingTeleport = 0; -@@ -1192,12 +_,20 @@ +@@ -1215,12 +_,20 @@ this.player.teleportSetPosition(posMoveRotation, relatives); this.awaitingPositionFromClient = this.player.position(); @@ -1102,14 +1102,14 @@ if (this.player.hasClientLoaded()) { BlockPos pos = packet.getPos(); this.player.resetLastActionTime(); -@@ -1206,32 +_,95 @@ +@@ -1245,32 +_,95 @@ case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { - ItemStack itemInHand = this.player.getItemInHand(InteractionHand.OFF_HAND); + ItemStack itemInHand1 = this.player.getItemInHand(InteractionHand.OFF_HAND); - this.player.setItemInHand(InteractionHand.OFF_HAND, this.player.getItemInHand(InteractionHand.MAIN_HAND)); -- this.player.setItemInHand(InteractionHand.MAIN_HAND, itemInHand); +- this.player.setItemInHand(InteractionHand.MAIN_HAND, itemInHand1); + // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394) -+ CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemInHand); ++ CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemInHand1); + CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.getItemInHand(InteractionHand.MAIN_HAND)); + PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(this.getCraftPlayer(), mainHand.clone(), offHand.clone()); + this.cserver.getPluginManager().callEvent(swapItemsEvent); @@ -1122,7 +1122,7 @@ + this.player.setItemInHand(InteractionHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem())); + } + if (swapItemsEvent.getMainHandItem().equals(mainHand)) { -+ this.player.setItemInHand(InteractionHand.MAIN_HAND, itemInHand); ++ this.player.setItemInHand(InteractionHand.MAIN_HAND, itemInHand1); + } else { + this.player.setItemInHand(InteractionHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem())); + } @@ -1200,7 +1200,7 @@ return; default: throw new IllegalArgumentException("Invalid player action"); -@@ -1249,9 +_,31 @@ +@@ -1288,9 +_,31 @@ } } @@ -1232,7 +1232,7 @@ if (this.player.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel serverLevel = this.player.level(); -@@ -1260,6 +_,11 @@ +@@ -1299,6 +_,11 @@ if (itemInHand.isItemEnabled(serverLevel.enabledFeatures())) { BlockHitResult hitResult = packet.getHitResult(); Vec3 location = hitResult.getLocation(); @@ -1244,7 +1244,7 @@ BlockPos blockPos = hitResult.getBlockPos(); if (this.player.canInteractWithBlock(blockPos, 1.0)) { Vec3 vec3 = location.subtract(Vec3.atCenterOf(blockPos)); -@@ -1269,7 +_,8 @@ +@@ -1308,7 +_,8 @@ this.player.resetLastActionTime(); int maxY = this.player.level().getMaxY(); if (blockPos.getY() <= maxY) { @@ -1254,7 +1254,7 @@ InteractionResult interactionResult = this.player.gameMode.useItemOn(this.player, serverLevel, itemInHand, hand, hitResult); if (interactionResult.consumesAction()) { CriteriaTriggers.ANY_BLOCK_USE.trigger(this.player, hitResult.getBlockPos(), itemInHand.copy()); -@@ -1282,10 +_,10 @@ +@@ -1321,10 +_,10 @@ Component component = Component.translatable("build.tooHigh", maxY).withStyle(ChatFormatting.RED); this.player.sendSystemMessage(component, true); } else if (interactionResult instanceof InteractionResult.Success success @@ -1267,7 +1267,7 @@ } else { Component component1 = Component.translatable("build.tooHigh", maxY).withStyle(ChatFormatting.RED); this.player.sendSystemMessage(component1, true); -@@ -1293,13 +_,8 @@ +@@ -1332,13 +_,8 @@ this.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos)); this.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos.relative(direction))); @@ -1283,7 +1283,7 @@ } } } -@@ -1309,6 +_,8 @@ +@@ -1348,6 +_,8 @@ @Override public void handleUseItem(ServerboundUseItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1292,7 +1292,7 @@ if (this.player.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel serverLevel = this.player.level(); -@@ -1322,6 +_,48 @@ +@@ -1361,6 +_,48 @@ this.player.absSnapRotationTo(f, f1); } @@ -1341,7 +1341,7 @@ if (this.player.gameMode.useItem(this.player, serverLevel, itemInHand, hand) instanceof InteractionResult.Success success && success.swingSource() == InteractionResult.SwingSource.SERVER) { this.player.swing(hand, true); -@@ -1337,7 +_,7 @@ +@@ -1376,7 +_,7 @@ for (ServerLevel serverLevel : this.server.getAllLevels()) { Entity entity = packet.getEntity(serverLevel); if (entity != null) { @@ -1350,7 +1350,7 @@ return; } } -@@ -1354,24 +_,50 @@ +@@ -1393,24 +_,50 @@ @Override public void onDisconnect(DisconnectionDetails details) { @@ -1403,7 +1403,7 @@ throw new IllegalArgumentException("Expected packet sequence nr >= 0"); } else { this.ackBlockChangesUpTo = Math.max(sequence, this.ackBlockChangesUpTo); -@@ -1381,20 +_,38 @@ +@@ -1420,20 +_,38 @@ @Override public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1442,7 +1442,7 @@ Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { this.tryHandleChat(packet.message(), false, () -> { -@@ -1406,25 +_,45 @@ +@@ -1445,25 +_,45 @@ return; } @@ -1495,7 +1495,7 @@ ParseResults parseResults = this.parseCommand(command); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseResults)) { LOGGER.error( -@@ -1441,28 +_,57 @@ +@@ -1480,28 +_,57 @@ Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { this.tryHandleChat(packet.command(), true, () -> { @@ -1556,7 +1556,7 @@ } private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) { -@@ -1526,14 +_,20 @@ +@@ -1565,14 +_,20 @@ return dispatcher.parse(command, this.player.createCommandSourceStack()); } @@ -1581,7 +1581,7 @@ } } -@@ -1545,7 +_,7 @@ +@@ -1584,7 +_,7 @@ var10000 = Optional.of(lastSeenMessages); } catch (LastSeenMessagesValidator.ValidationException var5) { LOGGER.error("Failed to validate message acknowledgements from {}: {}", this.player.getPlainTextName(), var5.getMessage()); @@ -1590,7 +1590,7 @@ return Optional.empty(); } -@@ -1563,22 +_,81 @@ +@@ -1602,22 +_,81 @@ return false; } @@ -1678,7 +1678,7 @@ } } -@@ -1589,7 +_,7 @@ +@@ -1628,7 +_,7 @@ this.lastSeenMessages.applyOffset(packet.offset()); } catch (LastSeenMessagesValidator.ValidationException var5) { LOGGER.error("Failed to validate message acknowledgement offset from {}: {}", this.player.getPlainTextName(), var5.getMessage()); @@ -1687,7 +1687,7 @@ } } } -@@ -1597,7 +_,40 @@ +@@ -1636,7 +_,40 @@ @Override public void handleAnimate(ServerboundSwingPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1728,7 +1728,7 @@ this.player.swing(packet.getHand()); } -@@ -1605,6 +_,22 @@ +@@ -1644,6 +_,22 @@ public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (this.player.hasClientLoaded()) { @@ -1751,7 +1751,7 @@ this.player.resetLastActionTime(); switch (packet.getAction()) { case START_SPRINTING: -@@ -1649,6 +_,14 @@ +@@ -1688,6 +_,14 @@ } public void sendPlayerChatMessage(PlayerChatMessage chatMessage, ChatType.Bound boundChatType) { @@ -1766,7 +1766,7 @@ this.send( new ClientboundPlayerChatPacket( this.nextChatIndex++, -@@ -1671,9 +_,11 @@ +@@ -1710,9 +_,11 @@ } if (i > 4096) { @@ -1779,7 +1779,7 @@ } public void sendDisguisedChatMessage(Component message, ChatType.Bound boundChatType) { -@@ -1684,6 +_,17 @@ +@@ -1723,6 +_,17 @@ return this.connection.getRemoteAddress(); } @@ -1797,7 +1797,7 @@ public void switchToConfig() { this.waitingForSwitchToConfig = true; this.removePlayerFromWorld(); -@@ -1699,9 +_,16 @@ +@@ -1738,9 +_,16 @@ @Override public void handleInteract(ServerboundInteractPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1814,7 +1814,7 @@ this.player.resetLastActionTime(); this.player.setShiftKeyDown(packet.isUsingSecondaryAction()); if (target != null) { -@@ -1710,16 +_,54 @@ +@@ -1749,16 +_,54 @@ } AABB boundingBox = target.getBoundingBox(); @@ -1874,7 +1874,7 @@ ItemStack itemStack1 = success.wasItemInteraction() ? itemStack : ItemStack.EMPTY; CriteriaTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(ServerGamePacketListenerImpl.this.player, itemStack1, target); if (success.swingSource() == InteractionResult.SwingSource.SERVER) { -@@ -1731,13 +_,13 @@ +@@ -1770,13 +_,13 @@ @Override public void onInteraction(InteractionHand hand) { @@ -1890,7 +1890,7 @@ ); } -@@ -1745,14 +_,14 @@ +@@ -1784,7 +_,7 @@ public void onAttack() { if (!(target instanceof ItemEntity) && !(target instanceof ExperienceOrb) @@ -1899,7 +1899,8 @@ && !(target instanceof AbstractArrow abstractArrow && !abstractArrow.isAttackable())) { ItemStack itemInHand = ServerGamePacketListenerImpl.this.player.getItemInHand(InteractionHand.MAIN_HAND); if (itemInHand.isItemEnabled(serverLevel.enabledFeatures())) { - ServerGamePacketListenerImpl.this.player.attack(target); +@@ -1793,7 +_,7 @@ + } } } else { - ServerGamePacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.invalid_entity_attacked")); @@ -1907,7 +1908,7 @@ ServerGamePacketListenerImpl.LOGGER .warn("Player {} tried to attack an invalid entity", ServerGamePacketListenerImpl.this.player.getPlainTextName()); } -@@ -1761,6 +_,27 @@ +@@ -1802,6 +_,27 @@ ); } } @@ -1935,7 +1936,7 @@ } } -@@ -1773,7 +_,7 @@ +@@ -1814,7 +_,7 @@ case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; @@ -1944,7 +1945,7 @@ this.resetPosition(); CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); } else { -@@ -1781,11 +_,11 @@ +@@ -1822,11 +_,11 @@ return; } @@ -1959,7 +1960,7 @@ } } break; -@@ -1796,16 +_,27 @@ +@@ -1837,16 +_,27 @@ @Override public void handleContainerClose(ServerboundContainerClosePacket packet) { @@ -1989,7 +1990,7 @@ this.player.containerMenu.sendAllDataToRemote(); } else if (!this.player.containerMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); -@@ -1821,7 +_,298 @@ +@@ -1862,7 +_,298 @@ } else { boolean flag = packet.stateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -2289,7 +2290,7 @@ for (Entry entry : Int2ObjectMaps.fastIterable(packet.changedSlots())) { this.player.containerMenu.setRemoteSlotUnsafe(entry.getIntKey(), entry.getValue()); -@@ -1834,6 +_,8 @@ +@@ -1875,6 +_,8 @@ } else { this.player.containerMenu.broadcastChanges(); } @@ -2298,7 +2299,7 @@ } } } -@@ -1841,6 +_,14 @@ +@@ -1882,6 +_,14 @@ @Override public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) { @@ -2313,7 +2314,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); this.player.resetLastActionTime(); if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) { -@@ -1857,9 +_,44 @@ +@@ -1898,9 +_,44 @@ return; } @@ -2359,7 +2360,7 @@ if (postPlaceAction == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) { this.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, recipeFromDisplay.display().display())); } -@@ -1873,6 +_,7 @@ +@@ -1914,6 +_,7 @@ @Override public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2367,7 +2368,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -1882,6 +_,7 @@ +@@ -1923,6 +_,7 @@ if (flag) { this.player.containerMenu.broadcastChanges(); } @@ -2375,7 +2376,7 @@ } } } -@@ -1898,10 +_,48 @@ +@@ -1939,10 +_,48 @@ boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45; boolean flag2 = itemStack.isEmpty() || itemStack.getCount() <= itemStack.getMaxStackSize(); @@ -2424,7 +2425,7 @@ } else if (flag && flag2) { if (this.dropSpamThrottler.isUnderThreshold()) { this.dropSpamThrottler.increment(); -@@ -1915,15 +_,38 @@ +@@ -1956,15 +_,38 @@ @Override public void handleSignUpdate(ServerboundSignUpdatePacket packet) { @@ -2464,7 +2465,7 @@ if (!(serverLevel.getBlockEntity(pos) instanceof SignBlockEntity signBlockEntity)) { return; } -@@ -1935,14 +_,32 @@ +@@ -1976,14 +_,32 @@ @Override public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2498,7 +2499,7 @@ if (this.player.isModelPartShown(PlayerModelPart.HAT) != isModelPartShown) { this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player)); } -@@ -1958,7 +_,7 @@ +@@ -1999,7 +_,7 @@ packet.difficulty().getDisplayName() ); } else { @@ -2507,7 +2508,7 @@ } } -@@ -1972,7 +_,7 @@ +@@ -2013,7 +_,7 @@ packet.mode().getShortDisplayName().getString() ); } else { @@ -2516,7 +2517,7 @@ } } -@@ -1992,7 +_,7 @@ +@@ -2033,7 +_,7 @@ ProfilePublicKey.Data data2 = data.profilePublicKey(); if (!Objects.equals(data1, data2)) { if (data1 != null && data2.expiresAt().isBefore(data1.expiresAt())) { @@ -2525,7 +2526,7 @@ } else { try { SignatureValidator signatureValidator = this.server.services().profileKeySignatureValidator(); -@@ -2003,8 +_,8 @@ +@@ -2044,8 +_,8 @@ this.resetPlayerChatState(data.validate(this.player.getGameProfile(), signatureValidator)); } catch (ProfilePublicKey.ValidationException var6) { @@ -2536,7 +2537,7 @@ } } } -@@ -2015,11 +_,13 @@ +@@ -2056,11 +_,13 @@ if (!this.waitingForSwitchToConfig) { throw new IllegalStateException("Client acknowledged config, but none was requested"); } else { @@ -2551,7 +2552,7 @@ } } -@@ -2037,27 +_,32 @@ +@@ -2078,27 +_,32 @@ private void resetPlayerChatState(RemoteChatSession chatSession) { this.chatSession = chatSession; @@ -2585,7 +2586,7 @@ if (!this.receivedMovementThisTick) { this.player.setKnownMovement(Vec3.ZERO); } -@@ -2088,4 +_,80 @@ +@@ -2129,4 +_,80 @@ interface EntityInteraction { InteractionResult run(ServerPlayer player, Entity entity, InteractionHand hand); } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch index 9c74541405f7..b97c3ae2a6cc 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -45,9 +_,16 @@ +@@ -46,9 +_,16 @@ import org.apache.commons.lang3.Validate; import org.slf4j.Logger; @@ -17,7 +17,7 @@ private static final int MAX_TICKS_BEFORE_LOGIN = 600; private final byte[] challenge; final MinecraftServer server; -@@ -55,21 +_,36 @@ +@@ -57,11 +_,16 @@ public volatile ServerLoginPacketListenerImpl.State state = ServerLoginPacketListenerImpl.State.HELLO; private int tick; @Nullable @@ -36,7 +36,8 @@ public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection, boolean transferred) { this.server = server; - this.connection = connection; +@@ -69,10 +_,20 @@ + this.serverActivityMonitor = this.server.getServerActivityMonitor(); this.challenge = Ints.toByteArray(RandomSource.create().nextInt()); this.transferred = transferred; + this.paperLoginConnection = new io.papermc.paper.connection.PaperPlayerLoginConnection(this); // Paper @@ -56,7 +57,7 @@ if (this.state == ServerLoginPacketListenerImpl.State.VERIFYING) { this.verifyLoginAndFinishConnectionSetup(Objects.requireNonNull(this.authenticatedProfile)); } -@@ -79,11 +_,23 @@ +@@ -82,11 +_,23 @@ this.finishLoginAndWaitForClient(this.authenticatedProfile); } @@ -80,7 +81,7 @@ @Override public boolean isAcceptingMessages() { return this.connection.isConnected(); -@@ -94,6 +_,7 @@ +@@ -97,6 +_,7 @@ LOGGER.info("Disconnecting {}: {}", this.getUserName(), reason.getString()); this.connection.send(new ClientboundLoginDisconnectPacket(reason)); this.connection.disconnect(reason); @@ -88,7 +89,7 @@ } catch (Exception var3) { LOGGER.error("Error whilst disconnecting player", (Throwable)var3); } -@@ -116,7 +_,14 @@ +@@ -119,7 +_,14 @@ @Override public void handleHello(ServerboundHelloPacket packet) { Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet"); @@ -104,7 +105,7 @@ this.requestedUsername = packet.name(); GameProfile singleplayerProfile = this.server.getSingleplayerProfile(); if (singleplayerProfile != null && this.requestedUsername.equalsIgnoreCase(singleplayerProfile.name())) { -@@ -126,7 +_,32 @@ +@@ -129,7 +_,32 @@ this.state = ServerLoginPacketListenerImpl.State.KEY; this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge, true)); } else { @@ -138,7 +139,7 @@ } } } -@@ -138,7 +_,7 @@ +@@ -141,7 +_,7 @@ private void verifyLoginAndFinishConnectionSetup(GameProfile profile) { PlayerList playerList = this.server.getPlayerList(); @@ -147,7 +148,7 @@ if (component != null) { this.disconnect(component); } else { -@@ -150,7 +_,7 @@ +@@ -153,7 +_,7 @@ ); } @@ -156,7 +157,7 @@ if (flag) { this.state = ServerLoginPacketListenerImpl.State.WAITING_FOR_DUPE_DISCONNECT; } else { -@@ -162,6 +_,7 @@ +@@ -165,6 +_,7 @@ private void finishLoginAndWaitForClient(GameProfile profile) { this.state = ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING; this.connection.send(new ClientboundLoginFinishedPacket(profile)); @@ -164,7 +165,7 @@ } @Override -@@ -185,7 +_,8 @@ +@@ -188,7 +_,8 @@ throw new IllegalStateException("Protocol error", var7); } @@ -174,7 +175,7 @@ @Override public void run() { String string1 = Objects.requireNonNull(ServerLoginPacketListenerImpl.this.requestedUsername, "Player name not initialized"); -@@ -197,11 +_,17 @@ +@@ -200,12 +_,18 @@ .hasJoinedServer(string1, string, this.getAddress()); if (profileResult != null) { GameProfile gameProfile = profileResult.profile(); @@ -185,6 +186,7 @@ + gameProfile = ServerLoginPacketListenerImpl.this.callPlayerPreLoginEvents(gameProfile); // Paper - Add more fields to AsyncPlayerPreLoginEvent + // CraftBukkit end ServerLoginPacketListenerImpl.LOGGER.info("UUID of player {} is {}", gameProfile.name(), gameProfile.id()); + ServerLoginPacketListenerImpl.this.serverActivityMonitor.reportLoginActivity(); ServerLoginPacketListenerImpl.this.startClientVerification(gameProfile); } else if (ServerLoginPacketListenerImpl.this.server.isSingleplayer()) { ServerLoginPacketListenerImpl.LOGGER.warn("Failed to verify username but will let them in anyway!"); @@ -193,7 +195,7 @@ } else { ServerLoginPacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.unverified_username")); ServerLoginPacketListenerImpl.LOGGER.error("Username '{}' tried to join with an invalid session", string1); -@@ -209,11 +_,16 @@ +@@ -213,11 +_,16 @@ } catch (AuthenticationUnavailableException var4) { if (ServerLoginPacketListenerImpl.this.server.isSingleplayer()) { ServerLoginPacketListenerImpl.LOGGER.warn("Authentication servers are down but will let them in anyway!"); @@ -212,7 +214,7 @@ } } -@@ -224,18 +_,113 @@ +@@ -228,18 +_,113 @@ ? ((InetSocketAddress)remoteAddress).getAddress() : null; } @@ -330,7 +332,7 @@ Validate.validState(this.state == ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet"); this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND); CommonListenerCookie commonListenerCookie = CommonListenerCookie.createInitial(Objects.requireNonNull(this.authenticatedProfile), this.transferred); -@@ -254,8 +_,31 @@ +@@ -258,8 +_,31 @@ @Override public void handleCookieResponse(ServerboundCookieResponsePacket packet) { diff --git a/paper-server/patches/sources/net/minecraft/server/notifications/EmptyNotificationService.java.patch b/paper-server/patches/sources/net/minecraft/server/notifications/EmptyNotificationService.java.patch index c58986091655..03e9ee786948 100644 --- a/paper-server/patches/sources/net/minecraft/server/notifications/EmptyNotificationService.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/notifications/EmptyNotificationService.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/notifications/EmptyNotificationService.java +++ b/net/minecraft/server/notifications/EmptyNotificationService.java -@@ -65,7 +_,7 @@ +@@ -69,7 +_,7 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/server/notifications/NotificationManager.java.patch b/paper-server/patches/sources/net/minecraft/server/notifications/NotificationManager.java.patch index 1ee81048e872..2a3768c26a69 100644 --- a/paper-server/patches/sources/net/minecraft/server/notifications/NotificationManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/notifications/NotificationManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/notifications/NotificationManager.java +++ b/net/minecraft/server/notifications/NotificationManager.java -@@ -87,8 +_,8 @@ +@@ -92,8 +_,8 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/server/notifications/NotificationService.java.patch b/paper-server/patches/sources/net/minecraft/server/notifications/NotificationService.java.patch index 366caf0f5fb5..fb34055d0f72 100644 --- a/paper-server/patches/sources/net/minecraft/server/notifications/NotificationService.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/notifications/NotificationService.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/notifications/NotificationService.java +++ b/net/minecraft/server/notifications/NotificationService.java -@@ -36,7 +_,7 @@ +@@ -38,7 +_,7 @@ void playerUnbanned(NameAndId nameAndId); diff --git a/paper-server/patches/sources/net/minecraft/server/permissions/PermissionProviderCheck.java.patch b/paper-server/patches/sources/net/minecraft/server/permissions/PermissionProviderCheck.java.patch new file mode 100644 index 000000000000..205aa6425bd4 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/permissions/PermissionProviderCheck.java.patch @@ -0,0 +1,25 @@ +--- a/net/minecraft/server/permissions/PermissionProviderCheck.java ++++ b/net/minecraft/server/permissions/PermissionProviderCheck.java +@@ -2,9 +_,21 @@ + + import java.util.function.Predicate; + +-public record PermissionProviderCheck(PermissionCheck test) implements Predicate { ++public record PermissionProviderCheck(PermissionCheck test, java.util.concurrent.atomic.AtomicReference> vanillaNode) implements Predicate { // Paper - Vanilla Command permission checking + @Override + public boolean test(T permissionsSupplier) { ++ // Paper start - Vanilla Command permission checking ++ com.mojang.brigadier.tree.CommandNode currentCommand = vanillaNode.get(); ++ if (currentCommand != null && permissionsSupplier instanceof net.minecraft.commands.CommandSourceStack commandSourceStack && this.test instanceof net.minecraft.server.permissions.PermissionCheck.Require req) { ++ return commandSourceStack.hasPermission(req.permission(), org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand)); ++ } ++ // Paper end - Vanilla Command permission checking + return this.test.check(permissionsSupplier.permissions()); + } ++ ++ // Paper start - Vanilla Command permission checking ++ public PermissionProviderCheck(final PermissionCheck test) { ++ this(test, new java.util.concurrent.atomic.AtomicReference<>(null)); ++ } ++ // Paper end - Vanilla Command permission checking + } diff --git a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch index 200b3c317c3b..7d4a6b0d8807 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -109,14 +_,16 @@ +@@ -110,14 +_,16 @@ private static final int SEND_PLAYER_INFO_INTERVAL = 600; private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); private final MinecraftServer server; @@ -20,7 +20,7 @@ public final PlayerDataStorage playerIo; private final LayeredRegistryAccess registries; private int viewDistance; -@@ -124,9 +_,17 @@ +@@ -125,9 +_,17 @@ private boolean allowCommandsForAllPlayers; private int sendAllPlayerInfoIn; @@ -38,7 +38,7 @@ this.server = server; this.registries = registries; this.playerIo = playerIo; -@@ -136,23 +_,19 @@ +@@ -137,23 +_,19 @@ this.ipBans = new IpBanList(IPBANLIST_FILE, notificationService); } @@ -67,7 +67,7 @@ LevelData levelData = serverLevel.getLevelData(); ServerGamePacketListenerImpl serverGamePacketListenerImpl = new ServerGamePacketListenerImpl(this.server, connection, player, cookie); connection.setupInboundProtocol( -@@ -169,8 +_,8 @@ +@@ -171,8 +_,8 @@ levelData.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), @@ -78,7 +78,7 @@ _boolean1, !_boolean, _boolean2, -@@ -178,6 +_,7 @@ +@@ -180,6 +_,7 @@ this.server.enforceSecureProfile() ) ); @@ -86,7 +86,7 @@ serverGamePacketListenerImpl.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); serverGamePacketListenerImpl.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities())); serverGamePacketListenerImpl.send(new ClientboundSetHeldSlotPacket(player.getInventory().getSelectedSlot())); -@@ -197,23 +_,128 @@ +@@ -199,24 +_,129 @@ mutableComponent = Component.translatable("multiplayer.player.joined.renamed", player.getDisplayName(), string); } @@ -187,6 +187,7 @@ + // Paper - move loading pearls / parent vehicle up player.initInventoryMenu(); this.server.notificationManager().playerJoined(player); + serverGamePacketListenerImpl.resumeFlushing(); + // Paper start - Configurable player collision; Add to collideRule team if needed + final net.minecraft.world.scores.Scoreboard scoreboard = this.getServer().getLevel(Level.OVERWORLD).getScoreboard(); + final PlayerTeam collideRuleTeam = scoreboard.getPlayerTeam(this.collideRuleTeamName); @@ -219,7 +220,7 @@ } public void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) { -@@ -235,31 +_,40 @@ +@@ -238,31 +_,40 @@ } } @@ -265,7 +266,7 @@ } @Override -@@ -283,57 +_,137 @@ +@@ -286,57 +_,137 @@ } protected void save(ServerPlayer player) { @@ -417,7 +418,7 @@ MutableComponent mutableComponent = Component.translatable("multiplayer.disconnect.banned.reason", userBanListEntry.getReasonMessage()); if (userBanListEntry.getExpires() != null) { mutableComponent.append( -@@ -341,9 +_,11 @@ +@@ -344,9 +_,11 @@ ); } @@ -432,7 +433,7 @@ } else if (this.ipBans.isBanned(socketAddress)) { IpBanListEntry ipBanListEntry = this.ipBans.get(socketAddress); MutableComponent mutableComponent = Component.translatable("multiplayer.disconnect.banned_ip.reason", ipBanListEntry.getReasonMessage()); -@@ -353,19 +_,18 @@ +@@ -356,19 +_,18 @@ ); } @@ -457,7 +458,7 @@ set.add(serverPlayer); } } -@@ -376,41 +_,87 @@ +@@ -379,41 +_,87 @@ } for (ServerPlayer serverPlayer2 : set) { @@ -556,7 +557,7 @@ serverPlayer.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); serverPlayer.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); serverPlayer.connection -@@ -418,10 +_,13 @@ +@@ -421,10 +_,13 @@ this.sendActivePlayerEffects(serverPlayer); this.sendLevelInfo(serverPlayer, level); this.sendPlayerPermissionLevel(serverPlayer); @@ -574,7 +575,7 @@ serverPlayer.setHealth(serverPlayer.getHealth()); ServerPlayer.RespawnConfig respawnConfig = serverPlayer.getRespawnConfig(); if (!keepInventory && respawnConfig != null) { -@@ -445,8 +_,52 @@ +@@ -448,8 +_,52 @@ ) ); } @@ -627,7 +628,7 @@ return serverPlayer; } -@@ -456,23 +_,58 @@ +@@ -459,23 +_,58 @@ } public void sendActiveEffects(LivingEntity entity, ServerGamePacketListenerImpl connection) { @@ -649,7 +650,7 @@ + + public void sendPlayerPermissionLevel(ServerPlayer player, boolean recalculatePermissions) { + // Paper end - avoid recalculating permissions if possible - int profilePermissions = this.server.getProfilePermissions(player.nameAndId()); + LevelBasedPermissionSet profilePermissions = this.server.getProfilePermissions(player.nameAndId()); - this.sendPlayerPermissionLevel(player, profilePermissions); + this.sendPlayerPermissionLevel(player, profilePermissions, recalculatePermissions); // Paper - avoid recalculating permissions if possible } @@ -689,20 +690,20 @@ public void broadcastAll(Packet packet) { for (ServerPlayer serverPlayer : this.players) { serverPlayer.connection.send(packet); -@@ -558,6 +_,12 @@ +@@ -561,6 +_,12 @@ } - private void sendPlayerPermissionLevel(ServerPlayer player, int permLevel) { + private void sendPlayerPermissionLevel(ServerPlayer player, LevelBasedPermissionSet permissions) { + // Paper start - Add sendOpLevel API -+ this.sendPlayerPermissionLevel(player, permLevel, true); ++ this.sendPlayerPermissionLevel(player, permissions, true); + } + -+ public void sendPlayerPermissionLevel(ServerPlayer player, int permLevel, boolean recalculatePermissions) { ++ public void sendPlayerPermissionLevel(ServerPlayer player, LevelBasedPermissionSet permissions, boolean recalculatePermissions) { + // Paper end - Add sendOpLevel API if (player.connection != null) { - byte b; - if (permLevel <= 0) { -@@ -571,9 +_,48 @@ + byte b = switch (permissions.level()) { + case ALL -> 24; +@@ -572,9 +_,48 @@ player.connection.send(new ClientboundEntityEventPacket(player, b)); } @@ -753,7 +754,7 @@ public boolean isWhiteListed(NameAndId nameAndId) { return !this.isUsingWhitelist() || this.ops.contains(nameAndId) || this.whitelist.contains(nameAndId); } -@@ -586,21 +_,17 @@ +@@ -587,21 +_,17 @@ @Nullable public ServerPlayer getPlayerByName(String username) { @@ -781,7 +782,7 @@ if (serverPlayer != except && serverPlayer.level().dimension() == dimension) { double d = x - serverPlayer.getX(); double d1 = y - serverPlayer.getY(); -@@ -613,9 +_,11 @@ +@@ -614,9 +_,11 @@ } public void saveAll() { @@ -793,7 +794,7 @@ } public UserWhiteList getWhiteList() { -@@ -643,9 +_,13 @@ +@@ -644,9 +_,13 @@ player.connection.send(new ClientboundSetTimePacket(level.getGameTime(), level.getDayTime(), level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); if (level.isRaining()) { @@ -810,7 +811,7 @@ } player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F)); -@@ -654,8 +_,21 @@ +@@ -655,8 +_,21 @@ public void sendAllPlayerInfo(ServerPlayer player) { player.inventoryMenu.sendAllDataToRemote(); @@ -833,7 +834,7 @@ } public int getPlayerCount() { -@@ -704,9 +_,26 @@ +@@ -705,9 +_,26 @@ } public void removeAll() { @@ -863,7 +864,7 @@ } public void broadcastSystemMessage(Component message, boolean overlay) { -@@ -729,20 +_,39 @@ +@@ -730,20 +_,39 @@ } public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound boundChatType) { @@ -906,7 +907,7 @@ flag1 |= flag2 && message.isFullyFiltered(); } -@@ -755,15 +_,21 @@ +@@ -756,15 +_,21 @@ return message.hasSignature() && !message.hasExpiredServer(Instant.now()); } @@ -933,7 +934,7 @@ Path path = file2.toPath(); if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { file2.renameTo(file1); -@@ -771,7 +_,7 @@ +@@ -772,7 +_,7 @@ } serverStatsCounter = new ServerStatsCounter(this.server, file1); @@ -942,7 +943,7 @@ } return serverStatsCounter; -@@ -779,11 +_,11 @@ +@@ -780,11 +_,11 @@ public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) { UUID uuid = player.getUUID(); @@ -956,7 +957,7 @@ } playerAdvancements.setPlayer(player); -@@ -837,11 +_,34 @@ +@@ -838,11 +_,34 @@ } public void reloadResources() { diff --git a/paper-server/patches/sources/net/minecraft/server/rcon/RconConsoleSource.java.patch b/paper-server/patches/sources/net/minecraft/server/rcon/RconConsoleSource.java.patch index d0e4e10eae85..ef6f7fc283cd 100644 --- a/paper-server/patches/sources/net/minecraft/server/rcon/RconConsoleSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/rcon/RconConsoleSource.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/rcon/RconConsoleSource.java +++ b/net/minecraft/server/rcon/RconConsoleSource.java -@@ -13,8 +_,13 @@ +@@ -14,8 +_,13 @@ private static final Component RCON_COMPONENT = Component.literal("Rcon"); private final StringBuffer buffer = new StringBuffer(); private final MinecraftServer server; @@ -15,8 +15,8 @@ this.server = server; } -@@ -32,6 +_,17 @@ - this, Vec3.atLowerCornerOf(serverLevel.getRespawnData().pos()), Vec2.ZERO, serverLevel, 4, "Rcon", RCON_COMPONENT, this.server, null +@@ -41,6 +_,17 @@ + null ); } + diff --git a/paper-server/patches/sources/net/minecraft/server/waypoints/ServerWaypointManager.java.patch b/paper-server/patches/sources/net/minecraft/server/waypoints/ServerWaypointManager.java.patch deleted file mode 100644 index 9b3c295fd0bd..000000000000 --- a/paper-server/patches/sources/net/minecraft/server/waypoints/ServerWaypointManager.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/waypoints/ServerWaypointManager.java -+++ b/net/minecraft/server/waypoints/ServerWaypointManager.java -@@ -102,7 +_,7 @@ - } - - private static boolean isLocatorBarEnabledFor(ServerPlayer player) { -- return player.level().getServer().getGameRules().getBoolean(GameRules.RULE_LOCATOR_BAR); -+ return player.level().getGameRules().getBoolean(GameRules.RULE_LOCATOR_BAR); // Paper - per world gamerules - } - - private void createConnection(ServerPlayer player, WaypointTransmitter waypoint) { diff --git a/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch b/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch index 2b8d14d12c20..3f96af7cf973 100644 --- a/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/datafix/DataFixers.java +++ b/net/minecraft/util/datafix/DataFixers.java -@@ -524,6 +_,24 @@ +@@ -530,6 +_,24 @@ Schema schema44 = builder.addSchema(1456, SAME_NAMESPACED); builder.addFixer(new EntityItemFrameDirectionFix(schema44, false)); Schema schema45 = builder.addSchema(1458, V1458::new); diff --git a/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch b/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch index 31132f35d5e2..77d62fe93850 100644 --- a/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/worldupdate/WorldUpgrader.java +++ b/net/minecraft/util/worldupdate/WorldUpgrader.java -@@ -87,7 +_,7 @@ +@@ -86,7 +_,7 @@ boolean recreateRegionFiles ) { this.dimensions = registryAccess.lookupOrThrow(Registries.LEVEL_STEM); @@ -9,7 +9,7 @@ this.eraseCache = eraseCache; this.dataFixer = dataFixer; this.levelStorage = levelStorage; -@@ -369,7 +_,7 @@ +@@ -365,7 +_,7 @@ int version = ChunkStorage.getVersion(compoundTag); ChunkGenerator chunkGenerator = WorldUpgrader.this.dimensions.getValueOrThrow(Registries.levelToLevelStem(dimension)).generator(); CompoundTag compoundTag1 = chunkStorage.upgradeChunkTag( diff --git a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch index 16be8c581898..a28b1c75be6b 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffectUtil.java +++ b/net/minecraft/world/effect/MobEffectUtil.java -@@ -47,18 +_,38 @@ +@@ -49,18 +_,38 @@ public static List addEffectToPlayersAround( ServerLevel level, @Nullable Entity source, Vec3 pos, double radius, MobEffectInstance effect, int duration ) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch index 484aee473514..e542ba5ef532 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -150,6 +_,106 @@ +@@ -152,6 +_,106 @@ import org.slf4j.Logger; public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, EntityAccess, ScoreHolder, DataComponentGetter { @@ -107,7 +107,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); public static final String TAG_ID = "id"; public static final String TAG_UUID = "UUID"; -@@ -227,7 +_,7 @@ +@@ -229,7 +_,7 @@ public double yOld; public double zOld; public boolean noPhysics; @@ -116,7 +116,7 @@ public int tickCount; private int remainingFireTicks; public boolean wasTouchingWater; -@@ -264,7 +_,7 @@ +@@ -266,7 +_,7 @@ protected UUID uuid = Mth.createInsecureUUID(this.random); protected String stringUUID = this.uuid.toString(); private boolean hasGlowingTag; @@ -125,7 +125,7 @@ private final double[] pistonDeltas = new double[]{0.0, 0.0, 0.0}; private long pistonDeltasGameTime; private EntityDimensions dimensions; -@@ -275,7 +_,7 @@ +@@ -277,7 +_,7 @@ private boolean onGroundNoBlocks = false; private float crystalSoundIntensity; private int lastCrystalSoundPlayTick; @@ -134,7 +134,7 @@ @Nullable private BlockState inBlockState = null; public static final int MAX_MOVEMENTS_HANDELED_PER_TICK = 100; -@@ -284,6 +_,41 @@ +@@ -286,6 +_,41 @@ private final LongSet visitedBlocks = new LongOpenHashSet(); private final InsideBlockEffectApplier.StepBasedCollector insideEffectCollector = new InsideBlockEffectApplier.StepBasedCollector(); private CustomData customData = CustomData.EMPTY; @@ -176,7 +176,7 @@ public Entity(EntityType type, Level level) { this.type = type; -@@ -305,6 +_,7 @@ +@@ -307,6 +_,7 @@ this.entityData = builder.build(); this.setPos(0.0, 0.0, 0.0); this.eyeHeight = this.dimensions.eyeHeight(); @@ -184,7 +184,7 @@ } public boolean isColliding(BlockPos pos, BlockState state) { -@@ -317,6 +_,12 @@ +@@ -319,6 +_,12 @@ return team != null && team.getColor().getColor() != null ? team.getColor().getColor() : 16777215; } @@ -197,7 +197,7 @@ public boolean isSpectator() { return false; } -@@ -369,7 +_,7 @@ +@@ -371,7 +_,7 @@ } public boolean addTag(String tag) { @@ -206,7 +206,7 @@ } public boolean removeTag(String tag) { -@@ -377,12 +_,18 @@ +@@ -379,12 +_,18 @@ } public void kill(ServerLevel level) { @@ -227,7 +227,7 @@ } protected abstract void defineSynchedData(SynchedEntityData.Builder builder); -@@ -391,6 +_,48 @@ +@@ -393,6 +_,48 @@ return this.entityData; } @@ -276,7 +276,7 @@ @Override public boolean equals(Object other) { return other instanceof Entity && ((Entity)other).id == this.id; -@@ -402,7 +_,13 @@ +@@ -404,7 +_,13 @@ } public void remove(Entity.RemovalReason reason) { @@ -291,7 +291,7 @@ } public void onClientRemoval() { -@@ -412,6 +_,15 @@ +@@ -414,6 +_,15 @@ } public void setPose(Pose pose) { @@ -307,7 +307,7 @@ this.entityData.set(DATA_POSE, pose); } -@@ -435,6 +_,32 @@ +@@ -437,6 +_,32 @@ } public void setRot(float yRot, float xRot) { @@ -340,7 +340,7 @@ this.setYRot(yRot % 360.0F); this.setXRot(xRot % 360.0F); } -@@ -444,8 +_,8 @@ +@@ -446,8 +_,8 @@ } public void setPos(double x, double y, double z) { @@ -351,7 +351,7 @@ } protected final AABB makeBoundingBox() { -@@ -475,12 +_,28 @@ +@@ -480,12 +_,28 @@ } public void tick() { @@ -380,7 +380,7 @@ this.inBlockState = null; if (this.isPassenger() && this.getVehicle().isRemoved()) { this.stopRiding(); -@@ -490,7 +_,7 @@ +@@ -495,7 +_,7 @@ this.boardingCooldown--; } @@ -389,7 +389,7 @@ if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -518,6 +_,10 @@ +@@ -523,6 +_,10 @@ if (this.isInLava()) { this.fallDistance *= 0.5; @@ -400,7 +400,7 @@ } this.checkBelowWorld(); -@@ -534,11 +_,16 @@ +@@ -539,11 +_,16 @@ } public void setSharedFlagOnFire(boolean isOnFire) { @@ -419,7 +419,7 @@ this.onBelowWorld(); } } -@@ -566,15 +_,41 @@ +@@ -571,15 +_,41 @@ } public void lavaIgnite() { @@ -463,7 +463,7 @@ && this.shouldPlayLavaHurtSound() && !this.isSilent()) { serverLevel.playSound( -@@ -589,6 +_,20 @@ +@@ -594,6 +_,20 @@ } public final void igniteForSeconds(float seconds) { @@ -484,7 +484,7 @@ this.igniteForTicks(Mth.floor(seconds * 20.0F)); } -@@ -613,7 +_,7 @@ +@@ -618,7 +_,7 @@ } protected void onBelowWorld() { @@ -493,7 +493,7 @@ } public boolean isFree(double x, double y, double z) { -@@ -669,7 +_,28 @@ +@@ -674,7 +_,28 @@ return this.onGround; } @@ -522,7 +522,7 @@ if (this.noPhysics) { this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); this.horizontalCollision = false; -@@ -752,6 +_,27 @@ +@@ -757,6 +_,27 @@ block.updateEntityMovementAfterFallOn(this.level(), this); } } @@ -550,7 +550,7 @@ if (!this.level().isClientSide() || this.isLocalInstanceAuthoritative()) { Entity.MovementEmission movementEmission = this.getMovementEmission(); -@@ -765,6 +_,13 @@ +@@ -770,6 +_,13 @@ profilerFiller.pop(); } } @@ -564,7 +564,7 @@ } private void applyMovementEmissionAndPlaySound(Entity.MovementEmission movementEmission, Vec3 movement, BlockPos pos, BlockState state) { -@@ -946,7 +_,7 @@ +@@ -951,7 +_,7 @@ } protected BlockPos getOnPos(float yOffset) { @@ -573,7 +573,7 @@ BlockPos blockPos = this.mainSupportingBlockPos.get(); if (!(yOffset > 1.0E-5F)) { return blockPos; -@@ -1201,7 +_,7 @@ +@@ -1206,7 +_,7 @@ if (flag2) { try { boolean flag4 = flag || aabb.intersects(pos); @@ -582,7 +582,7 @@ blockState.entityInside(this.level(), pos, this, stepBasedCollector, flag4); this.onInsideBlock(blockState); } catch (Throwable var20) { -@@ -1215,7 +_,7 @@ +@@ -1220,7 +_,7 @@ } if (flag3) { @@ -591,7 +591,7 @@ blockState.getFluidState().entityInside(this.level(), pos, this, stepBasedCollector); } -@@ -1652,6 +_,7 @@ +@@ -1657,6 +_,7 @@ this.setXRot(Mth.clamp(xRot, -90.0F, 90.0F) % 360.0F); this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); @@ -599,7 +599,7 @@ } public void absSnapTo(double x, double y, double z) { -@@ -1661,6 +_,7 @@ +@@ -1666,6 +_,7 @@ this.yo = y; this.zo = d1; this.setPos(d, y, d1); @@ -607,7 +607,7 @@ } public void snapTo(Vec3 pos) { -@@ -1680,11 +_,19 @@ +@@ -1685,11 +_,19 @@ } public void snapTo(double x, double y, double z, float yRot, float xRot) { @@ -627,7 +627,7 @@ } public final void setOldPosAndRot() { -@@ -1751,6 +_,7 @@ +@@ -1756,6 +_,7 @@ public void push(Entity entity) { if (!this.isPassengerOfSameVehicle(entity)) { if (!entity.noPhysics && !this.noPhysics) { @@ -635,7 +635,7 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double max = Mth.absMax(d, d1); -@@ -1784,7 +_,21 @@ +@@ -1789,7 +_,21 @@ } public void push(double x, double y, double z) { @@ -658,7 +658,7 @@ this.hasImpulse = true; } -@@ -1891,8 +_,20 @@ +@@ -1896,8 +_,20 @@ } public boolean isPushable() { @@ -679,7 +679,7 @@ public void awardKillScore(Entity entity, DamageSource damageSource) { if (entity instanceof ServerPlayer) { -@@ -1919,15 +_,23 @@ +@@ -1924,15 +_,23 @@ } public boolean saveAsPassenger(ValueOutput output) { @@ -707,7 +707,7 @@ return true; } } -@@ -1938,14 +_,35 @@ +@@ -1943,14 +_,35 @@ } public void saveWithoutId(ValueOutput output) { @@ -743,7 +743,7 @@ output.store("Rotation", Vec2.CODEC, new Vec2(this.getYRot(), this.getXRot())); output.putDouble("fall_distance", this.fallDistance); output.putShort("Fire", (short)this.remainingFireTicks); -@@ -1953,7 +_,29 @@ +@@ -1958,7 +_,29 @@ output.putBoolean("OnGround", this.onGround()); output.putBoolean("Invulnerable", this.invulnerable); output.putInt("PortalCooldown", this.portalCooldown); @@ -773,7 +773,7 @@ output.storeNullable("CustomName", ComponentSerialization.CODEC, this.getCustomName()); if (this.isCustomNameVisible()) { output.putBoolean("CustomNameVisible", this.isCustomNameVisible()); -@@ -1976,9 +_,12 @@ +@@ -1981,9 +_,12 @@ output.putInt("TicksFrozen", this.getTicksFrozen()); } @@ -788,7 +788,7 @@ if (!this.tags.isEmpty()) { output.store("Tags", TAG_LIST_CODEC, List.copyOf(this.tags)); -@@ -1988,13 +_,13 @@ +@@ -1993,13 +_,13 @@ output.store("data", CustomData.CODEC, this.customData); } @@ -804,7 +804,7 @@ valueOutputList.discardLast(); } } -@@ -2003,6 +_,34 @@ +@@ -2008,6 +_,34 @@ output.discard("Passengers"); } } @@ -839,7 +839,7 @@ } catch (Throwable var7) { CrashReport crashReport = CrashReport.forThrowable(var7, "Saving entity NBT"); CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being saved"); -@@ -2014,7 +_,7 @@ +@@ -2019,7 +_,7 @@ public void load(ValueInput input) { try { Vec3 vec3 = input.read("Pos", Vec3.CODEC).orElse(Vec3.ZERO); @@ -848,7 +848,7 @@ Vec2 vec2 = input.read("Rotation", Vec2.CODEC).orElse(Vec2.ZERO); this.setDeltaMovement(Math.abs(vec31.x) > 10.0 ? 0.0 : vec31.x, Math.abs(vec31.y) > 10.0 ? 0.0 : vec31.y, Math.abs(vec31.z) > 10.0 ? 0.0 : vec31.z); this.hasImpulse = true; -@@ -2046,7 +_,20 @@ +@@ -2051,7 +_,20 @@ this.setNoGravity(input.getBooleanOr("NoGravity", false)); this.setGlowingTag(input.getBooleanOr("Glowing", false)); this.setTicksFrozen(input.getIntOr("TicksFrozen", 0)); @@ -870,7 +870,7 @@ this.customData = input.read("data", CustomData.CODEC).orElse(CustomData.EMPTY); this.tags.clear(); input.read("Tags", TAG_LIST_CODEC).ifPresent(this.tags::addAll); -@@ -2057,6 +_,59 @@ +@@ -2062,6 +_,59 @@ } else { throw new IllegalStateException("Entity has invalid rotation"); } @@ -930,7 +930,7 @@ } catch (Throwable var7) { CrashReport crashReport = CrashReport.forThrowable(var7, "Loading entity NBT"); CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being loaded"); -@@ -2071,13 +_,24 @@ +@@ -2076,13 +_,24 @@ @Nullable public final String getEncodeId() { @@ -956,7 +956,7 @@ protected abstract void addAdditionalSaveData(ValueOutput output); @Nullable -@@ -2092,11 +_,62 @@ +@@ -2097,11 +_,62 @@ @Nullable public ItemEntity spawnAtLocation(ServerLevel level, ItemStack stack, Vec3 offset) { @@ -1021,7 +1021,7 @@ level.addFreshEntity(itemEntity); return itemEntity; } -@@ -2142,6 +_,15 @@ +@@ -2147,6 +_,15 @@ for (Leashable leashable1 : list) { if (leashable1.canHaveALeashAttachedTo(this)) { @@ -1037,7 +1037,7 @@ leashable1.setLeashedTo(this, true); flag = true; } -@@ -2156,7 +_,7 @@ +@@ -2161,7 +_,7 @@ } ItemStack itemInHand = player.getItemInHand(hand); @@ -1046,7 +1046,7 @@ itemInHand.hurtAndBreak(1, player, hand); return InteractionResult.SUCCESS; } else if (this instanceof Mob mob -@@ -2169,11 +_,13 @@ +@@ -2174,11 +_,13 @@ if (this.isAlive() && this instanceof Leashable leashable2) { if (leashable2.getLeashHolder() == player) { if (!this.level().isClientSide()) { @@ -1064,7 +1064,7 @@ this.gameEvent(GameEvent.ENTITY_INTERACT, player); this.playSound(SoundEvents.LEAD_UNTIED); -@@ -2186,9 +_,22 @@ +@@ -2191,9 +_,22 @@ if (itemInHand1.is(Items.LEAD) && !(leashable2.getLeashHolder() instanceof Player)) { if (!this.level().isClientSide() && leashable2.canHaveALeashAttachedTo(player)) { if (leashable2.isLeashed()) { @@ -1088,7 +1088,7 @@ leashable2.setLeashedTo(player, true); this.playSound(SoundEvents.LEAD_TIED); itemInHand1.shrink(1); -@@ -2203,7 +_,12 @@ +@@ -2208,7 +_,12 @@ } public boolean shearOffAllLeashConnections(@Nullable Player player) { @@ -1102,7 +1102,7 @@ if (flag && this.level() instanceof ServerLevel serverLevel) { serverLevel.playSound(null, this.blockPosition(), SoundEvents.SHEARS_SNIP, player != null ? player.getSoundSource() : this.getSoundSource()); } -@@ -2212,15 +_,38 @@ +@@ -2217,15 +_,38 @@ } public boolean dropAllLeashConnections(@Nullable Player player) { @@ -1145,7 +1145,7 @@ } if (flag) { -@@ -2244,7 +_,9 @@ +@@ -2249,7 +_,9 @@ this.gameEvent(GameEvent.SHEAR, player); this.playSound(equippable.shearingSound().value()); if (this.level() instanceof ServerLevel serverLevel) { @@ -1155,7 +1155,7 @@ CriteriaTriggers.PLAYER_SHEARED_EQUIPMENT.trigger((ServerPlayer)player, itemBySlot, mob); } -@@ -2317,11 +_,11 @@ +@@ -2322,11 +_,11 @@ } public boolean startRiding(Entity entity, boolean force, boolean triggerEvents) { @@ -1169,7 +1169,7 @@ return false; } else { for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) { -@@ -2331,6 +_,27 @@ +@@ -2336,6 +_,27 @@ } if (force || this.canRide(entity) && entity.canAddPassenger(this)) { @@ -1197,7 +1197,7 @@ if (this.isPassenger()) { this.stopRiding(); } -@@ -2363,10 +_,16 @@ +@@ -2368,10 +_,16 @@ } public void removeVehicle() { @@ -1215,7 +1215,7 @@ Entity.RemovalReason removalReason = this.getRemovalReason(); if (removalReason == null || removalReason.shouldDestroy()) { this.level().gameEvent(this, GameEvent.ENTITY_DISMOUNT, entity.position); -@@ -2375,7 +_,13 @@ +@@ -2380,7 +_,13 @@ } public void stopRiding() { @@ -1230,7 +1230,7 @@ } protected void addPassenger(Entity passenger) { -@@ -2397,10 +_,43 @@ +@@ -2402,10 +_,43 @@ } } @@ -1275,7 +1275,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == passenger) { this.passengers = ImmutableList.of(); } else { -@@ -2409,6 +_,7 @@ +@@ -2414,6 +_,7 @@ passenger.boardingCooldown = 60; } @@ -1283,18 +1283,17 @@ } protected boolean canAddPassenger(Entity passenger) { -@@ -2505,8 +_,8 @@ +@@ -2514,7 +_,8 @@ TeleportTransition portalDestination = this.portalProcess.getPortalDestination(serverLevel, this); if (portalDestination != null) { ServerLevel level = portalDestination.newLevel(); -- if (serverLevel.getServer().isAllowedToEnterPortal(level) -- && (level.dimension() == serverLevel.dimension() || this.canTeleport(serverLevel, level))) { +- if (serverLevel.isAllowedToEnterPortal(level) && (level.dimension() == serverLevel.dimension() || this.canTeleport(serverLevel, level)) + if (this instanceof ServerPlayer // CraftBukkit - always call event for players -+ || (level != null && (level.dimension() == serverLevel.dimension() || this.canTeleport(serverLevel, level)))) { // CraftBukkit ++ || (level != null && (level.dimension() == serverLevel.dimension() || this.canTeleport(serverLevel, level))) // CraftBukkit + ) + { this.teleport(portalDestination); - } - } -@@ -2587,7 +_,7 @@ +@@ -2597,7 +_,7 @@ } public boolean isCrouching() { @@ -1303,7 +1302,7 @@ } public boolean isSprinting() { -@@ -2603,7 +_,7 @@ +@@ -2613,7 +_,7 @@ } public boolean isVisuallySwimming() { @@ -1312,7 +1311,7 @@ } public boolean isVisuallyCrawling() { -@@ -2611,6 +_,13 @@ +@@ -2621,6 +_,13 @@ } public void setSwimming(boolean swimming) { @@ -1326,7 +1325,7 @@ this.setSharedFlag(4, swimming); } -@@ -2649,6 +_,7 @@ +@@ -2659,6 +_,7 @@ @Nullable public PlayerTeam getTeam() { @@ -1334,7 +1333,7 @@ return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -2665,7 +_,11 @@ +@@ -2675,7 +_,11 @@ } public void setInvisible(boolean invisible) { @@ -1347,7 +1346,7 @@ } public boolean getSharedFlag(int flag) { -@@ -2682,7 +_,7 @@ +@@ -2692,7 +_,7 @@ } public int getMaxAirSupply() { @@ -1356,7 +1355,7 @@ } public int getAirSupply() { -@@ -2690,10 +_,22 @@ +@@ -2700,10 +_,22 @@ } public void setAirSupply(int airSupply) { @@ -1380,7 +1379,7 @@ this.setTicksFrozen(0); } -@@ -2720,11 +_,43 @@ +@@ -2730,11 +_,43 @@ public void thunderHit(ServerLevel level, LightningBolt lightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -1428,7 +1427,7 @@ } public void onAboveBubbleColumn(boolean downwards, BlockPos pos) { -@@ -2880,26 +_,30 @@ +@@ -2890,26 +_,30 @@ return this.removalReason != null ? String.format( Locale.ROOT, @@ -1462,7 +1461,7 @@ ); } -@@ -2923,6 +_,13 @@ +@@ -2933,6 +_,13 @@ } public void restoreFrom(Entity entity) { @@ -1476,7 +1475,7 @@ try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) { TagValueOutput tagValueOutput = TagValueOutput.createWithContext(scopedCollector, entity.registryAccess()); entity.saveWithoutId(tagValueOutput); -@@ -2935,7 +_,65 @@ +@@ -2945,7 +_,65 @@ @Nullable public Entity teleport(TeleportTransition teleportTransition) { @@ -1542,7 +1541,7 @@ ServerLevel level = teleportTransition.newLevel(); boolean flag = level.dimension() != serverLevel.dimension(); if (!teleportTransition.asPassenger()) { -@@ -2985,10 +_,15 @@ +@@ -2995,10 +_,15 @@ profilerFiller.pop(); return null; } else { @@ -1559,7 +1558,7 @@ for (Entity entity2 : list) { entity2.startRiding(entityx, true, false); -@@ -3078,9 +_,17 @@ +@@ -3088,9 +_,17 @@ } protected void removeAfterChangingDimensions() { @@ -1580,7 +1579,7 @@ } if (this instanceof WaypointTransmitter waypointTransmitter && this.level instanceof ServerLevel serverLevel) { -@@ -3092,11 +_,37 @@ +@@ -3102,11 +_,37 @@ return PortalShape.getRelativePosition(portal, axis, this.position(), this.getDimensions(this.getPose())); } @@ -1618,7 +1617,7 @@ if (fromLevel.dimension() == Level.END && toLevel.dimension() == Level.OVERWORLD) { for (Entity entity : this.getPassengers()) { if (entity instanceof ServerPlayer serverPlayer && !serverPlayer.seenCredits) { -@@ -3204,8 +_,14 @@ +@@ -3214,8 +_,14 @@ return this.entityData.get(DATA_CUSTOM_NAME_VISIBLE); } @@ -1635,7 +1634,7 @@ return entity != null; } -@@ -3319,7 +_,26 @@ +@@ -3329,7 +_,26 @@ } public final void setBoundingBox(AABB bb) { @@ -1663,7 +1662,7 @@ } public final float getEyeHeight(Pose pose) { -@@ -3346,6 +_,12 @@ +@@ -3356,6 +_,12 @@ } public void stopSeenByPlayer(ServerPlayer player) { @@ -1676,7 +1675,7 @@ } public float rotate(Rotation transformRotation) { -@@ -3374,7 +_,7 @@ +@@ -3384,7 +_,7 @@ } @Nullable @@ -1685,7 +1684,7 @@ return null; } -@@ -3406,21 +_,32 @@ +@@ -3416,21 +_,32 @@ } private Stream getIndirectPassengersStream() { @@ -1719,7 +1718,7 @@ } public int countPlayerPassengers() { -@@ -3428,6 +_,7 @@ +@@ -3438,6 +_,7 @@ } public boolean hasExactlyOnePlayerPassenger() { @@ -1727,7 +1726,7 @@ return this.countPlayerPassengers() == 1; } -@@ -3510,9 +_,38 @@ +@@ -3520,9 +_,38 @@ return 0; } @@ -1762,12 +1761,12 @@ + public CommandSourceStack createCommandSourceStackForNameResolution(ServerLevel level) { return new CommandSourceStack( -- CommandSource.NULL, this.position(), this.getRotationVector(), level, 0, this.getPlainTextName(), this.getDisplayName(), level.getServer(), this -+ this.commandSource, this.position(), this.getRotationVector(), level, 0, this.getPlainTextName(), this.getDisplayName(), level.getServer(), this // CraftBukkit - ); - } - -@@ -3570,6 +_,11 @@ +- CommandSource.NULL, ++ this.commandSource, // CraftBukkit + this.position(), + this.getRotationVector(), + level, +@@ -3588,6 +_,11 @@ vec3 = vec3.add(flow); i++; } @@ -1779,7 +1778,7 @@ } } } -@@ -3668,7 +_,9 @@ +@@ -3686,7 +_,9 @@ } public void setDeltaMovement(Vec3 deltaMovement) { @@ -1789,7 +1788,7 @@ } public void addDeltaMovement(Vec3 addend) { -@@ -3731,9 +_,35 @@ +@@ -3749,9 +_,35 @@ return this.getZ((2.0 * this.random.nextDouble() - 1.0) * scale); } @@ -1825,7 +1824,7 @@ int floor = Mth.floor(x); int floor1 = Mth.floor(y); int floor2 = Mth.floor(z); -@@ -3755,7 +_,18 @@ +@@ -3773,7 +_,18 @@ serverLevel.getWaypointManager().updatePlayer(serverPlayer); } } @@ -1845,7 +1844,7 @@ } public void checkDespawn() { -@@ -3808,6 +_,12 @@ +@@ -3826,6 +_,12 @@ return this.getTicksFrozen() > 0; } @@ -1858,7 +1857,7 @@ public float getYRot() { return this.yRot; } -@@ -3859,7 +_,9 @@ +@@ -3877,7 +_,9 @@ } @Override @@ -1869,7 +1868,7 @@ if (this.removalReason == null) { this.removalReason = removalReason; } -@@ -3871,12 +_,28 @@ +@@ -3889,12 +_,28 @@ this.getPassengers().forEach(Entity::stopRiding); this.levelCallback.onRemove(removalReason); this.onRemoval(removalReason); @@ -1898,7 +1897,7 @@ @Override public void setLevelCallback(EntityInLevelCallback levelCallback) { this.levelCallback = levelCallback; -@@ -4073,4 +_,14 @@ +@@ -4091,4 +_,14 @@ return this.save; } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch index 5c732b5bef81..9717149ae655 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -1265,6 +_,22 @@ +@@ -1283,6 +_,22 @@ boolean shouldOffsetY, boolean shouldOffsetYMore ) { @@ -23,7 +23,7 @@ Consumer consumer; if (spawnedFrom != null) { consumer = createDefaultStackConfig(level, spawnedFrom, owner); -@@ -1272,7 +_,7 @@ +@@ -1290,7 +_,7 @@ consumer = entity -> {}; } @@ -32,7 +32,7 @@ } public static Consumer createDefaultStackConfig(Level level, ItemStack stack, @Nullable LivingEntity owner) { -@@ -1289,21 +_,58 @@ +@@ -1307,21 +_,58 @@ public static Consumer appendCustomEntityStackConfig(Consumer consumer, Level level, ItemStack stack, @Nullable LivingEntity owner) { TypedEntityData> typedEntityData = stack.get(DataComponents.ENTITY_DATA); @@ -94,7 +94,7 @@ if (entity instanceof Mob mob) { mob.playAmbientSound(); } -@@ -1358,6 +_,13 @@ +@@ -1376,6 +_,13 @@ if (level.isClientSide() || !entity.getType().onlyOpCanSetNbt() || owner instanceof Player player && server.getPlayerList().isOp(player.nameAndId())) { @@ -108,7 +108,7 @@ entityData.loadInto(entity); } } -@@ -1429,9 +_,20 @@ +@@ -1447,9 +_,20 @@ } public static Optional create(ValueInput input, Level level, EntitySpawnReason spawnReason) { @@ -130,7 +130,7 @@ () -> LOGGER.warn("Skipping Entity with id {}", input.getStringOr("id", "[invalid]")) ); } -@@ -1588,8 +_,23 @@ +@@ -1606,8 +_,23 @@ return this.builtInRegistryHolder; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch index a497034e5f8b..6ba4467572df 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LightningBolt.java +++ b/net/minecraft/world/entity/LightningBolt.java -@@ -39,6 +_,7 @@ +@@ -40,6 +_,7 @@ private ServerPlayer cause; private final Set hitEntities = Sets.newHashSet(); private int blocksSetOnFire; @@ -8,7 +8,7 @@ public LightningBolt(EntityType type, Level level) { super(type, level); -@@ -76,7 +_,7 @@ +@@ -77,7 +_,7 @@ @Override public void tick() { super.tick(); @@ -17,7 +17,7 @@ if (this.level().isClientSide()) { this.level() .playLocalSound( -@@ -107,7 +_,7 @@ +@@ -108,7 +_,7 @@ } this.powerLightningRod(); @@ -26,7 +26,7 @@ this.gameEvent(GameEvent.LIGHTNING_STRIKE); } } -@@ -130,7 +_,7 @@ +@@ -131,7 +_,7 @@ } } @@ -35,7 +35,7 @@ } else if (this.life < -this.random.nextInt(10)) { this.flashes--; this.life = 1; -@@ -139,10 +_,10 @@ +@@ -140,10 +_,10 @@ } } @@ -48,7 +48,7 @@ List entities = this.level() .getEntities( this, -@@ -168,44 +_,57 @@ +@@ -169,32 +_,45 @@ } private void spawnFire(int extraIgnitions) { @@ -87,16 +87,21 @@ - private static void clearCopperOnLightningStrike(Level level, BlockPos pos) { + private static void clearCopperOnLightningStrike(Level level, BlockPos pos, Entity lightning) { // Paper - Call EntityChangeBlockEvent BlockState blockState = level.getBlockState(pos); - if (blockState.getBlock() instanceof WeatheringCopper) { -- level.setBlockAndUpdate(pos, WeatheringCopper.getFirst(level.getBlockState(pos))); -+ // Paper start - Call EntityChangeBlockEvent -+ BlockState newBlockState = WeatheringCopper.getFirst(level.getBlockState(pos)); -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(lightning, pos, newBlockState)) { -+ level.setBlockAndUpdate(pos, newBlockState); -+ } -+ // Paper end - Call EntityChangeBlockEvent + boolean flag = HoneycombItem.WAX_OFF_BY_BLOCK.get().get(blockState.getBlock()) != null; + boolean flag1 = blockState.getBlock() instanceof WeatheringCopper; + if (flag1 || flag) { + if (flag1) { +- level.setBlockAndUpdate(pos, WeatheringCopper.getFirst(level.getBlockState(pos))); ++ // Paper start - Call EntityChangeBlockEvent ++ BlockState newBlockState = WeatheringCopper.getFirst(level.getBlockState(pos)); ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(lightning, pos, newBlockState)) { ++ level.setBlockAndUpdate(pos, newBlockState); ++ } ++ // Paper end - Call EntityChangeBlockEvent + } + BlockPos.MutableBlockPos mutableBlockPos = pos.mutable(); - int i = level.random.nextInt(3) + 3; +@@ -202,16 +_,16 @@ for (int i1 = 0; i1 < i; i1++) { int i2 = level.random.nextInt(8) + 1; @@ -116,7 +121,7 @@ if (optional.isEmpty()) { break; } -@@ -214,11 +_,17 @@ +@@ -220,11 +_,17 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index f4e9a83bba15..bce92573692e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -139,6 +_,17 @@ +@@ -141,6 +_,17 @@ import org.jetbrains.annotations.Contract; import org.slf4j.Logger; @@ -18,7 +18,7 @@ public abstract class LivingEntity extends Entity implements Attackable, WaypointTransmitter { private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; -@@ -265,11 +_,24 @@ +@@ -270,11 +_,25 @@ ); protected final EntityEquipment equipment; private Waypoint.Icon locatorBarIcon = new Waypoint.Icon(); @@ -32,6 +32,7 @@ + public org.bukkit.craftbukkit.entity.CraftLivingEntity getBukkitLivingEntity() { return (org.bukkit.craftbukkit.entity.CraftLivingEntity) super.getBukkitEntity(); } // Paper + public boolean silentDeath = false; // Paper - mark entity as dying silently for cancellable death event + public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API ++ public int invulnerableDuration = 20; // Paper - add back this field - it was already unused by vanilla in 1.21.10... // TODO - snapshot - audit this code + // CraftBukkit end protected LivingEntity(EntityType type, Level level) { @@ -44,7 +45,7 @@ this.equipment = this.createEquipment(); this.blocksBuilding = true; this.reapplyPosition(); -@@ -371,7 +_,13 @@ +@@ -376,7 +_,13 @@ double d1 = Math.min(0.2F + d / 15.0, 2.5); int i = (int)(150.0 * d1); @@ -59,7 +60,7 @@ } } -@@ -556,7 +_,7 @@ +@@ -561,7 +_,7 @@ this.deathTime++; if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { this.level().broadcastEntityEvent(this, (byte)60); @@ -68,7 +69,7 @@ } } -@@ -661,7 +_,7 @@ +@@ -666,7 +_,7 @@ } public boolean shouldDiscardFriction() { @@ -77,7 +78,7 @@ } public void setDiscardFriction(boolean discardFriction) { -@@ -673,10 +_,15 @@ +@@ -678,10 +_,15 @@ } public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem) { @@ -94,7 +95,7 @@ this.level() .playSeededSound( null, -@@ -703,12 +_,12 @@ +@@ -708,12 +_,12 @@ } @Override @@ -109,7 +110,7 @@ this.brain.clearMemories(); } -@@ -725,11 +_,17 @@ +@@ -730,11 +_,17 @@ mobEffectInstance.onMobRemoved(level, this, removalReason); } @@ -127,7 +128,7 @@ output.putFloat("Health", this.getHealth()); output.putShort("HurtTime", (short)this.hurtTime); output.putInt("HurtByTimestamp", this.lastHurtByMobTimestamp); -@@ -763,8 +_,15 @@ +@@ -768,8 +_,15 @@ } } @@ -145,7 +146,7 @@ if (stack.isEmpty()) { return null; } else if (this.level().isClientSide()) { -@@ -773,6 +_,31 @@ +@@ -778,6 +_,31 @@ } else { ItemEntity itemEntity = this.createItemStackToDrop(stack, randomizeMotion, includeThrower); if (itemEntity != null) { @@ -177,7 +178,7 @@ this.level().addFreshEntity(itemEntity); } -@@ -782,7 +_,22 @@ +@@ -787,7 +_,22 @@ @Override protected void readAdditionalSaveData(ValueInput input) { @@ -201,8 +202,8 @@ if (this.level() != null && !this.level().isClientSide()) { input.read("attributes", AttributeInstance.Packed.LIST_CODEC).ifPresent(this.getAttributes()::apply); } -@@ -794,6 +_,11 @@ - this.activeEffects.put(mobEffectInstance.getEffect(), mobEffectInstance); +@@ -800,6 +_,11 @@ + this.effectsDirty = true; } + // CraftBukkit start @@ -213,7 +214,7 @@ this.setHealth(input.getFloatOr("Health", this.getMaxHealth())); this.hurtTime = input.getShortOr("HurtTime", (short)0); this.deathTime = input.getShortOr("DeathTime", (short)0); -@@ -801,6 +_,7 @@ +@@ -807,6 +_,7 @@ input.getString("Team").ifPresent(string -> { Scoreboard scoreboard = this.level().getScoreboard(); PlayerTeam playerTeam = scoreboard.getPlayerTeam(string); @@ -221,7 +222,7 @@ boolean flag = playerTeam != null && scoreboard.addPlayerToTeam(this.getStringUUID(), playerTeam); if (!flag) { LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", string); -@@ -808,11 +_,13 @@ +@@ -814,11 +_,13 @@ }); this.setSharedFlag(7, input.getBooleanOr("FallFlying", false)); input.read("sleeping_pos", BlockPos.CODEC).ifPresentOrElse(blockPos -> { @@ -235,8 +236,8 @@ }, this::clearSleepingPos); input.read("Brain", Codec.PASSTHROUGH).ifPresent(dynamic -> this.brain = this.makeBrain((Dynamic)dynamic)); this.lastHurtByPlayer = EntityReference.read(input, "last_hurt_by_player"); -@@ -823,15 +_,44 @@ - this.locatorBarIcon = input.read("locator_bar_icon", Waypoint.Icon.CODEC).orElseGet(Waypoint.Icon::new); +@@ -835,15 +_,44 @@ + this.updateDirtyEffects(); } + // CraftBukkit start @@ -280,10 +281,11 @@ iterator.remove(); this.onEffectsRemoved(List.of(mobEffectInstance)); } else if (mobEffectInstance.getDuration() % 600 == 0) { -@@ -841,6 +_,17 @@ +@@ -852,6 +_,18 @@ + } } catch (ConcurrentModificationException var6) { } - ++ + // CraftBukkit start + this.isTickingEffects = false; + for (ProcessableEffect effect : this.effectsToProcess) { @@ -295,10 +297,10 @@ + } + this.effectsToProcess.clear(); + // CraftBukkit end - if (this.effectsDirty) { - this.updateInvisibilityStatus(); - this.updateGlowingStatus(); -@@ -948,15 +_,33 @@ + } else { + for (MobEffectInstance mobEffectInstance1 : this.activeEffects.values()) { + mobEffectInstance1.tickClient(); +@@ -962,15 +_,33 @@ } public boolean removeAllEffects() { @@ -336,7 +338,7 @@ } } -@@ -983,21 +_,57 @@ +@@ -997,21 +_,57 @@ } public final boolean addEffect(MobEffectInstance effectInstance) { @@ -396,7 +398,7 @@ this.onEffectUpdated(mobEffectInstance, true, entity); flag = true; } -@@ -1036,11 +_,37 @@ +@@ -1050,11 +_,37 @@ @Nullable public final MobEffectInstance removeEffectNoUpdate(Holder effect) { @@ -435,7 +437,7 @@ if (mobEffectInstance != null) { this.onEffectsRemoved(List.of(mobEffectInstance)); return true; -@@ -1131,17 +_,62 @@ +@@ -1145,17 +_,62 @@ } public void heal(float amount) { @@ -499,7 +501,7 @@ this.entityData.set(DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth())); } -@@ -1153,7 +_,7 @@ +@@ -1167,7 +_,7 @@ public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { if (this.isInvulnerableTo(level, damageSource)) { return false; @@ -508,7 +510,7 @@ return false; } else if (damageSource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1169,35 +_,58 @@ +@@ -1183,35 +_,58 @@ ItemStack useItem = this.getUseItem(); float originAmount = amount; @@ -575,7 +577,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1212,7 +_,7 @@ +@@ -1226,7 +_,7 @@ level.broadcastDamageEvent(this, damageSource); } @@ -584,7 +586,7 @@ this.markHurt(); } -@@ -1227,8 +_,16 @@ +@@ -1241,8 +_,16 @@ d = damageSource.getSourcePosition().x() - this.getX(); d1 = damageSource.getSourcePosition().z() - this.getZ(); } @@ -602,7 +604,7 @@ if (!flag) { this.indicateDamage(d, d1); } -@@ -1237,19 +_,19 @@ +@@ -1251,19 +_,19 @@ if (this.isDeadOrDying()) { if (!this.checkTotemDeathProtection(damageSource)) { @@ -627,7 +629,7 @@ if (flag2) { this.lastDamageSource = damageSource; this.lastDamageStamp = this.level().getGameTime(); -@@ -1275,6 +_,12 @@ +@@ -1289,6 +_,12 @@ } public float applyItemBlocking(ServerLevel level, DamageSource damageSource, float damageAmount) { @@ -640,7 +642,7 @@ if (damageAmount <= 0.0F) { return 0.0F; } else { -@@ -1299,10 +_,12 @@ +@@ -1313,10 +_,12 @@ } float f = blocksAttacks.resolveBlockedDamage(damageSource, damageAmount, acos); @@ -654,7 +656,7 @@ return f; } -@@ -1313,6 +_,59 @@ +@@ -1327,6 +_,59 @@ } } @@ -714,7 +716,7 @@ public void playSecondaryHurtSound(DamageSource damageSource) { if (damageSource.is(DamageTypes.THORNS)) { SoundSource soundSource = this instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE; -@@ -1345,12 +_,24 @@ +@@ -1359,12 +_,24 @@ return EntityReference.getPlayer(this.lastHurtByPlayer, this.level()); } @@ -740,7 +742,7 @@ } private boolean checkTotemDeathProtection(DamageSource damageSource) { -@@ -1360,18 +_,39 @@ +@@ -1374,18 +_,39 @@ ItemStack itemStack = null; DeathProtection deathProtection = null; @@ -787,7 +789,7 @@ serverPlayer.awardStat(Stats.ITEM_USED.get(itemStack.getItem())); CriteriaTriggers.USED_TOTEM.trigger(serverPlayer, itemStack); this.gameEvent(GameEvent.ITEM_INTERACT_FINISH); -@@ -1430,6 +_,7 @@ +@@ -1444,6 +_,7 @@ if (!this.isRemoved() && !this.dead) { Entity entity = damageSource.getEntity(); LivingEntity killCredit = this.getKillCredit(); @@ -795,7 +797,7 @@ if (killCredit != null) { killCredit.awardKillScore(this, damageSource); } -@@ -1439,68 +_,147 @@ +@@ -1453,68 +_,147 @@ } if (!this.level().isClientSide() && this.hasCustomName()) { @@ -956,7 +958,7 @@ } protected void dropCustomDeathLoot(ServerLevel level, DamageSource damageSource, boolean recentlyHit) { -@@ -1604,9 +_,14 @@ +@@ -1618,9 +_,14 @@ } public void knockback(double strength, double x, double z) { @@ -973,7 +975,7 @@ Vec3 deltaMovement = this.getDeltaMovement(); while (x * x + z * z < 1.0E-5F) { -@@ -1615,11 +_,22 @@ +@@ -1629,11 +_,22 @@ } Vec3 vec3 = new Vec3(x, 0.0, z).normalize().scale(strength); @@ -997,7 +999,7 @@ } } -@@ -1704,7 +_,7 @@ +@@ -1726,7 +_,7 @@ @Override public boolean isAlive() { @@ -1006,7 +1008,7 @@ } public boolean isLookingAtMe(LivingEntity entity, double tolerance, boolean scaleByDistance, boolean visual, double... yValues) { -@@ -1738,9 +_,14 @@ +@@ -1760,9 +_,14 @@ boolean flag = super.causeFallDamage(fallDistance, damageMultiplier, damageSource); int i = this.calculateFallDamage(fallDistance, damageMultiplier); if (i > 0) { @@ -1022,7 +1024,7 @@ return true; } else { return flag; -@@ -1805,7 +_,7 @@ +@@ -1827,7 +_,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damageSource, float damageAmount) { if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -1031,7 +1033,7 @@ damageAmount = CombatRules.getDamageAfterAbsorb( this, damageAmount, damageSource, this.getArmorValue(), (float)this.getAttributeValue(Attributes.ARMOR_TOUGHNESS) ); -@@ -1818,7 +_,8 @@ +@@ -1840,7 +_,8 @@ if (damageSource.is(DamageTypeTags.BYPASSES_EFFECTS)) { return damageAmount; } else { @@ -1041,7 +1043,7 @@ int i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int i1 = 25 - i; float f = damageAmount * i1; -@@ -1855,24 +_,201 @@ +@@ -1877,24 +_,201 @@ } } @@ -1143,14 +1145,14 @@ + + if (damageSource.getEntity() instanceof net.minecraft.world.entity.player.Player) { + // Paper start - PlayerAttackEntityCooldownResetEvent -+ //((net.minecraft.world.entity.player.Player) damagesource.getEntity()).resetAttackStrengthTicker(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired ++ //((net.minecraft.world.entity.player.Player) damagesource.getEntity()).resetOnlyAttackStrengthTicker(); // Moved from Player in order to make the cooldown reset get called after the damage event is fired + if (damageSource.getEntity() instanceof ServerPlayer) { + ServerPlayer player = (ServerPlayer) damageSource.getEntity(); + if (new com.destroystokyo.paper.event.player.PlayerAttackEntityCooldownResetEvent(player.getBukkitEntity(), this.getBukkitEntity(), player.getAttackStrengthScale(0F)).callEvent()) { -+ player.resetAttackStrengthTicker(); ++ player.resetOnlyAttackStrengthTicker(); + } + } else { -+ ((net.minecraft.world.entity.player.Player) damageSource.getEntity()).resetAttackStrengthTicker(); ++ ((net.minecraft.world.entity.player.Player) damageSource.getEntity()).resetOnlyAttackStrengthTicker(); + } + // Paper end - PlayerAttackEntityCooldownResetEvent + } @@ -1253,7 +1255,7 @@ } public CombatTracker getCombatTracker() { -@@ -1901,7 +_,17 @@ +@@ -1923,7 +_,17 @@ } public final void setArrowCount(int count) { @@ -1272,7 +1274,7 @@ } public final int getStingerCount() { -@@ -2056,7 +_,7 @@ +@@ -2080,7 +_,7 @@ @Override protected void onBelowWorld() { @@ -1281,7 +1283,7 @@ } protected void updateSwingTime() { -@@ -2152,8 +_,15 @@ +@@ -2176,8 +_,15 @@ } public void setItemSlot(EquipmentSlot slot, ItemStack stack) { @@ -1299,7 +1301,7 @@ public float getArmorCoverPercentage() { int i = 0; -@@ -2245,14 +_,27 @@ +@@ -2269,14 +_,27 @@ return this.hasEffect(MobEffects.JUMP_BOOST) ? 0.1F * (this.getEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1.0F) : 0.0F; } @@ -1327,7 +1329,7 @@ this.addDeltaMovement(new Vec3(-Mth.sin(f) * 0.2, 0.0, Mth.cos(f) * 0.2)); } -@@ -2412,8 +_,10 @@ +@@ -2436,8 +_,10 @@ } public void stopFallFlying() { @@ -1338,7 +1340,16 @@ } private Vec3 updateFallFlyingMovement(Vec3 deltaMovement) { -@@ -2623,37 +_,15 @@ +@@ -2581,7 +_,7 @@ + + public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { + if (strength > 0.0F && target instanceof LivingEntity livingEntity) { +- livingEntity.knockback(strength, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); ++ livingEntity.knockback(strength, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // CraftBukkit // Paper - knockback events + this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); + } + } +@@ -2657,37 +_,15 @@ profilerFiller.pop(); profilerFiller.push("rangeChecks"); @@ -1385,7 +1396,7 @@ profilerFiller.pop(); if (this.isFallFlying()) { -@@ -2683,16 +_,39 @@ +@@ -2769,16 +_,39 @@ @Nullable private Map collectEquipmentChanges() { Map map = null; @@ -1425,7 +1436,7 @@ AttributeMap attributes = this.getAttributes(); if (!itemStack.isEmpty()) { this.stopLocationBasedEffects(itemStack, equipmentSlot, attributes); -@@ -2717,6 +_,8 @@ +@@ -2803,6 +_,8 @@ } } } @@ -1434,7 +1445,7 @@ } return map; -@@ -2748,7 +_,7 @@ +@@ -2834,7 +_,7 @@ list.add(Pair.of(equipmentSlot, itemStack1)); this.lastEquipmentItems.put(equipmentSlot, itemStack1); }); @@ -1443,7 +1454,7 @@ } protected void tickHeadTurn(float yBodyRot) { -@@ -2834,8 +_,10 @@ +@@ -2920,8 +_,10 @@ if (!flag || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if (!this.isInLava() || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if ((this.onGround() || flag && fluidHeight <= fluidJumpThreshold) && this.noJumpDelay == 0) { @@ -1454,7 +1465,7 @@ } } else { this.jumpInLiquid(FluidTags.LAVA); -@@ -2876,7 +_,7 @@ +@@ -2962,7 +_,7 @@ profilerFiller.pop(); if (this.level() instanceof ServerLevel serverLevel) { profilerFiller.push("freezing"); @@ -1463,7 +1474,7 @@ this.setTicksFrozen(Math.max(0, this.getTicksFrozen() - 2)); } -@@ -2897,6 +_,20 @@ +@@ -2983,6 +_,20 @@ this.pushEntities(); profilerFiller.pop(); @@ -1484,7 +1495,7 @@ if (this.level() instanceof ServerLevel serverLevel && this.isSensitiveToWater() && this.isInWaterOrRain()) { this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F); } -@@ -2919,6 +_,7 @@ +@@ -3005,6 +_,7 @@ this.checkFallDistanceAccumulation(); if (!this.level().isClientSide()) { if (!this.canGlide()) { @@ -1492,7 +1503,7 @@ this.setSharedFlag(7, false); return; } -@@ -2958,10 +_,25 @@ +@@ -3044,10 +_,25 @@ } protected void pushEntities() { @@ -1519,7 +1530,7 @@ if (_int > 0 && pushableEntities.size() > _int - 1 && this.random.nextInt(4) == 0) { int i = 0; -@@ -2977,7 +_,16 @@ +@@ -3063,7 +_,16 @@ } } @@ -1536,7 +1547,7 @@ this.doPush(entity1); } } -@@ -2986,16 +_,32 @@ +@@ -3072,16 +_,32 @@ protected void checkAutoSpinAttack(AABB boundingBoxBeforeSpin, AABB boundingBoxAfterSpin) { AABB aabb = boundingBoxBeforeSpin.minmax(boundingBoxAfterSpin); List entities = this.level().getEntities(this, aabb); @@ -1570,7 +1581,7 @@ this.autoSpinAttackTicks = 0; } -@@ -3018,10 +_,10 @@ +@@ -3104,10 +_,10 @@ } @Override @@ -1584,7 +1595,7 @@ this.dismountVehicle(vehicle); } } -@@ -3048,7 +_,7 @@ +@@ -3134,7 +_,7 @@ } public void onItemPickup(ItemEntity itemEntity) { @@ -1593,7 +1604,7 @@ if (owner instanceof ServerPlayer) { CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer)owner, itemEntity.getItem(), this); } -@@ -3060,7 +_,7 @@ +@@ -3146,7 +_,7 @@ && (entity instanceof ItemEntity || entity instanceof AbstractArrow || entity instanceof ExperienceOrb)) { ((ServerLevel)this.level()) .getChunkSource() @@ -1602,7 +1613,7 @@ } } -@@ -3074,7 +_,8 @@ +@@ -3160,7 +_,8 @@ } else { Vec3 vec3 = new Vec3(this.getX(), this.getEyeY(), this.getZ()); Vec3 vec31 = new Vec3(entity.getX(), y, entity.getZ()); @@ -1612,7 +1623,7 @@ } } -@@ -3094,13 +_,27 @@ +@@ -3180,13 +_,27 @@ @Override public boolean isPickable() { @@ -1643,7 +1654,7 @@ @Override public float getYHeadRot() { -@@ -3131,7 +_,7 @@ +@@ -3217,7 +_,7 @@ } public final void setAbsorptionAmount(float absorptionAmount) { @@ -1652,7 +1663,7 @@ } protected void internalSetAbsorptionAmount(float absorptionAmount) { -@@ -3158,6 +_,15 @@ +@@ -3244,6 +_,15 @@ return (this.entityData.get(DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; } @@ -1668,7 +1679,7 @@ private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { -@@ -3175,6 +_,11 @@ +@@ -3261,6 +_,11 @@ return null; } else { double d = this.getEyeY() - 0.3F; @@ -1680,7 +1691,7 @@ ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), d, this.getZ(), stack); itemEntity.setPickUpDelay(40); if (includeThrower) { -@@ -3206,7 +_,12 @@ +@@ -3292,7 +_,12 @@ protected void updateUsingItem(ItemStack usingItem) { usingItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); @@ -1694,7 +1705,7 @@ this.completeUsingItem(); } } -@@ -3232,10 +_,19 @@ +@@ -3318,10 +_,19 @@ } public void startUsingItem(InteractionHand hand) { @@ -1716,7 +1727,7 @@ if (!this.level().isClientSide()) { this.setLivingEntityFlag(1, true); this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND); -@@ -3259,7 +_,10 @@ +@@ -3348,7 +_,10 @@ } } else if (!this.isUsingItem() && !this.useItem.isEmpty()) { this.useItem = ItemStack.EMPTY; @@ -1728,7 +1739,7 @@ } } } -@@ -3298,7 +_,38 @@ +@@ -3387,7 +_,38 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1768,7 +1779,7 @@ if (itemStack != this.useItem) { this.setItemInHand(usedItemHand, itemStack); } -@@ -3328,6 +_,7 @@ +@@ -3421,6 +_,7 @@ ItemStack itemInHand = this.getItemInHand(this.getUsedItemHand()); if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemInHand, this.useItem)) { this.useItem = itemInHand; @@ -1776,7 +1787,7 @@ this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); if (this.useItem.useOnRelease()) { this.updatingUsingItem(); -@@ -3347,7 +_,10 @@ +@@ -3441,7 +_,10 @@ } this.useItem = ItemStack.EMPTY; @@ -1788,7 +1799,7 @@ } public boolean isBlocking() { -@@ -3371,6 +_,60 @@ +@@ -3465,6 +_,60 @@ } } @@ -1849,7 +1860,7 @@ public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); } -@@ -3389,6 +_,12 @@ +@@ -3483,6 +_,12 @@ } public boolean randomTeleport(double x, double y, double z, boolean broadcastTeleport) { @@ -1862,7 +1873,7 @@ double x1 = this.getX(); double y1 = this.getY(); double z1 = this.getZ(); -@@ -3411,16 +_,39 @@ +@@ -3505,16 +_,39 @@ } if (flag1) { @@ -1905,7 +1916,7 @@ } else { if (broadcastTeleport) { level.broadcastEntityEvent(this, (byte)46); -@@ -3430,7 +_,7 @@ +@@ -3524,7 +_,7 @@ pathfinderMob.getNavigation().stop(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch index 594d9cb62a2f..22481cc35513 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -90,6 +_,14 @@ +@@ -91,6 +_,14 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.ticks.ContainerSingleItem; @@ -15,7 +15,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashable, Targeting { private static final EntityDataAccessor DATA_MOB_FLAGS_ID = SynchedEntityData.defineId(Mob.class, EntityDataSerializers.BYTE); private static final int MOB_FLAG_NO_AI = 1; -@@ -125,6 +_,7 @@ +@@ -126,6 +_,7 @@ private final BodyRotationControl bodyRotationControl; protected PathNavigation navigation; public GoalSelector goalSelector; @@ -23,7 +23,7 @@ public GoalSelector targetSelector; @Nullable private LivingEntity target; -@@ -139,6 +_,8 @@ +@@ -140,6 +_,8 @@ private Leashable.LeashData leashData; private BlockPos homePosition = BlockPos.ZERO; private int homeRadius = -1; @@ -32,7 +32,7 @@ protected Mob(EntityType type, Level level) { super(type, level); -@@ -155,6 +_,12 @@ +@@ -156,6 +_,12 @@ } } @@ -45,7 +45,7 @@ protected void registerGoals() { } -@@ -235,7 +_,39 @@ +@@ -236,7 +_,39 @@ } public void setTarget(@Nullable LivingEntity target) { @@ -85,7 +85,7 @@ } @Override -@@ -375,13 +_,27 @@ +@@ -376,13 +_,27 @@ if (this.isNoAi()) { output.putBoolean("NoAI", this.isNoAi()); } @@ -115,7 +115,7 @@ this.dropChances = input.read("drop_chances", DropChances.CODEC).orElse(DropChances.DEFAULT); this.readLeashData(input); this.homeRadius = input.getIntOr("home_radius", -1); -@@ -393,6 +_,13 @@ +@@ -394,6 +_,13 @@ this.lootTable = input.read("DeathLootTable", LootTable.KEY_CODEC); this.lootTableSeed = input.getLongOr("DeathLootTableSeed", 0L); this.setNoAi(input.getBooleanOr("NoAI", false)); @@ -129,7 +129,7 @@ } @Override -@@ -456,6 +_,11 @@ +@@ -461,6 +_,11 @@ && !itemEntity.getItem().isEmpty() && !itemEntity.hasPickUpDelay() && this.wantsToPickUp(serverLevel, itemEntity.getItem())) { @@ -141,7 +141,7 @@ this.pickUpItem(serverLevel, itemEntity); } } -@@ -470,18 +_,24 @@ +@@ -514,18 +_,24 @@ protected void pickUpItem(ServerLevel level, ItemEntity entity) { ItemStack item = entity.getItem(); @@ -168,7 +168,7 @@ EquipmentSlot equipmentSlotForItem = this.getEquipmentSlotForItem(stack); if (!this.isEquippableInSlot(stack, equipmentSlotForItem)) { return ItemStack.EMPTY; -@@ -494,10 +_,18 @@ +@@ -538,10 +_,18 @@ canReplaceCurrentItem = itemBySlot.isEmpty(); } @@ -188,7 +188,7 @@ } ItemStack itemStack = equipmentSlotForItem.limit(stack); -@@ -611,25 +_,38 @@ +@@ -655,25 +_,38 @@ return this.isPassenger(); } @@ -241,7 +241,7 @@ this.noActionTime = 0; } } -@@ -641,6 +_,15 @@ +@@ -685,6 +_,15 @@ @Override protected final void serverAiStep() { this.noActionTime++; @@ -257,7 +257,7 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("sensing"); this.sensing.tick(); -@@ -815,14 +_,69 @@ +@@ -859,14 +_,69 @@ public boolean stillValid(Player player) { return player.getVehicle() == Mob.this || player.canInteractWithEntity(Mob.this, 4.0); } @@ -327,7 +327,7 @@ ItemStack itemBySlot = this.getItemBySlot(equipmentSlot); float f = this.dropChances.byEquipment(equipmentSlot); if (f != 0.0F) { -@@ -842,7 +_,13 @@ +@@ -886,7 +_,13 @@ } this.spawnAtLocation(level, itemBySlot); @@ -341,7 +341,7 @@ } } } -@@ -866,7 +_,9 @@ +@@ -910,7 +_,9 @@ set.add(equipmentSlot); } else if (this.dropChances.isPreserved(equipmentSlot)) { this.setItemSlot(equipmentSlot, ItemStack.EMPTY); @@ -351,7 +351,7 @@ } } } -@@ -1161,6 +_,21 @@ +@@ -1205,6 +_,21 @@ public T convertTo( EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.AfterConversion afterConversion ) { @@ -373,7 +373,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1169,13 +_,23 @@ +@@ -1213,13 +_,23 @@ return null; } else { conversionParams.type().convert(this, mob, conversionParams); @@ -400,7 +400,7 @@ } return mob; -@@ -1185,7 +_,18 @@ +@@ -1229,7 +_,18 @@ @Nullable public T convertTo(EntityType entityType, ConversionParams conversionParams, ConversionParams.AfterConversion afterConversion) { @@ -420,7 +420,7 @@ } @Nullable -@@ -1227,7 +_,17 @@ +@@ -1271,7 +_,17 @@ public boolean startRiding(Entity entity, boolean force, boolean triggerEvents) { boolean flag = super.startRiding(entity, force, triggerEvents); if (flag && this.isLeashed()) { @@ -439,12 +439,3 @@ } return flag; -@@ -1310,7 +_,7 @@ - float knockback = this.getKnockback(target, damageSource); - if (knockback > 0.0F && target instanceof LivingEntity livingEntity) { - livingEntity.knockback( -- knockback * 0.5F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) -+ knockback * 0.5F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK // CraftBukkit // Paper - knockback events - ); - this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); - } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch index e1f064ef586b..d3a4fd531dc6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch @@ -1,12 +1,10 @@ --- a/net/minecraft/world/entity/NeutralMob.java +++ b/net/minecraft/world/entity/NeutralMob.java -@@ -36,9 +_,11 @@ - if (level instanceof ServerLevel serverLevel) { - UUID uuid = input.read("AngryAt", UUIDUtil.CODEC).orElse(null); - this.setPersistentAngerTarget(uuid); -- if ((uuid != null ? serverLevel.getEntity(uuid) : null) instanceof LivingEntity livingEntity) { -- this.setTarget(livingEntity); -- } +@@ -51,7 +_,11 @@ + + if (level instanceof ServerLevel) { + this.setPersistentAngerTarget(EntityReference.read(input, "angry_at")); +- this.setTarget(EntityReference.getLivingEntity(this.getPersistentAngerTarget(), level)); + // Paper - Prevent entity loading causing async lookups; Moved diff to separate method + // If this entity already survived its first tick, e.g. is loaded and ticked in sync, actively + // tick the initial persistent anger. @@ -15,16 +13,16 @@ } } -@@ -91,7 +_,7 @@ +@@ -118,7 +_,7 @@ default void stopBeingAngry() { this.setLastHurtByMob(null); this.setPersistentAngerTarget(null); - this.setTarget(null); + this.setTarget(null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); // CraftBukkit - this.setRemainingPersistentAngerTime(0); + this.setPersistentAngerEndTime(-1L); } -@@ -102,8 +_,24 @@ +@@ -129,8 +_,20 @@ void setTarget(@Nullable LivingEntity target); @@ -38,12 +36,8 @@ + // Paper start - Prevent entity loading causing async lookups + // Update last hurt when ticking + default void tickInitialPersistentAnger(Level level) { -+ UUID uuid = getPersistentAngerTarget(); -+ if (uuid == null) { -+ return; -+ } -+ -+ if (level.getEntity(uuid) instanceof LivingEntity target) { ++ LivingEntity target = EntityReference.getLivingEntity(this.getPersistentAngerTarget(), level); ++ if (target != null) { + this.setTarget(target, null); + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/Attributes.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/Attributes.java.patch index ae547448e8b2..266bf345f9a1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/Attributes.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/Attributes.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/attributes/Attributes.java +++ b/net/minecraft/world/entity/ai/attributes/Attributes.java -@@ -10,7 +_,7 @@ +@@ -11,7 +_,7 @@ public static final Holder ARMOR_TOUGHNESS = register( "armor_toughness", new RangedAttribute("attribute.name.armor_toughness", 0.0, 0.0, 20.0).setSyncable(true) ); @@ -9,7 +9,7 @@ public static final Holder ATTACK_KNOCKBACK = register("attack_knockback", new RangedAttribute("attribute.name.attack_knockback", 0.0, 0.0, 5.0)); public static final Holder ATTACK_SPEED = register( "attack_speed", new RangedAttribute("attribute.name.attack_speed", 4.0, 0.0, 1024.0).setSyncable(true) -@@ -52,10 +_,10 @@ +@@ -53,10 +_,10 @@ ); public static final Holder LUCK = register("luck", new RangedAttribute("attribute.name.luck", 0.0, -1024.0, 1024.0).setSyncable(true)); public static final Holder MAX_ABSORPTION = register( @@ -22,7 +22,7 @@ ); public static final Holder MINING_EFFICIENCY = register( "mining_efficiency", new RangedAttribute("attribute.name.mining_efficiency", 0.0, 0.0, 1024.0).setSyncable(true) -@@ -64,7 +_,7 @@ +@@ -65,7 +_,7 @@ "movement_efficiency", new RangedAttribute("attribute.name.movement_efficiency", 0.0, 0.0, 1.0).setSyncable(true) ); public static final Holder MOVEMENT_SPEED = register( diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch index 27a429e81440..86700d60d21c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch @@ -30,7 +30,7 @@ this.tame(player); this.setOrderedToSit(true); this.level().broadcastEntityEvent(this, (byte)7); -@@ -581,15 +_,20 @@ +@@ -585,15 +_,20 @@ .dropFromGiftLootTable( getServerLevel(this.cat), BuiltInLootTables.CAT_MORNING_GIFT, @@ -55,7 +55,7 @@ ); } -@@ -616,7 +_,7 @@ +@@ -620,7 +_,7 @@ static class CatTemptGoal extends TemptGoal { @Nullable diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch index ae9f4a434fdd..e94a54442e10 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch @@ -108,7 +108,7 @@ } public static boolean isPathClear(Fox fox, LivingEntity livingEntity) { -@@ -873,6 +_,19 @@ +@@ -872,6 +_,19 @@ fox.addTrustedEntity(loveCause1); } @@ -128,17 +128,17 @@ if (serverPlayer != null) { serverPlayer.awardStat(Stats.ANIMALS_BRED); CriteriaTriggers.BRED_ANIMALS.trigger(serverPlayer, this.animal, this.partner, fox); -@@ -882,14 +_,12 @@ +@@ -881,14 +_,12 @@ this.partner.setAge(6000); this.animal.resetLove(); this.partner.resetLove(); - fox.setAge(-24000); - fox.snapTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F); -- serverLevel.addFreshEntityWithPassengers(fox); -+ serverLevel.addFreshEntityWithPassengers(fox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason +- this.level.addFreshEntityWithPassengers(fox); ++ this.level.addFreshEntityWithPassengers(fox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason this.level.broadcastEntityEvent(this.animal, (byte)18); -- if (serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { -+ if (experience > 0 && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - call EntityBreedEvent +- if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { ++ if (experience > 0 && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - call EntityBreedEvent this.level .addFreshEntity( - new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), this.animal.getRandom().nextInt(7) + 1) @@ -146,7 +146,7 @@ ); } } -@@ -953,6 +_,7 @@ +@@ -952,6 +_,7 @@ private void pickSweetBerries(BlockState state) { int ageValue = state.getValue(SweetBerryBushBlock.AGE); state.setValue(SweetBerryBushBlock.AGE, 1); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch index a98d84c3be5d..44e765ab9cf5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch @@ -3,7 +3,7 @@ @@ -92,7 +_,7 @@ super.aiStep(); if (this.level() instanceof ServerLevel serverLevel) { - if (this.level().getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) { + if (serverLevel.environmentAttributes().getValue(EnvironmentAttributes.SNOW_GOLEM_MELTS, this.position())) { - this.hurtServer(serverLevel, this.damageSources().onFire(), 1.0F); + this.hurtServer(serverLevel, this.damageSources().onFire().knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.MELTING), 1.0F); // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch index 1cb6e9741ef7..b4ecf723acc2 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch @@ -67,7 +67,7 @@ if (this.level() instanceof ServerLevel serverLevel) { - this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), mob -> { + Frog converted = this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), mob -> { // CraftBukkit - mob.finalizeSpawn(serverLevel, this.level().getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CONVERSION, null); + mob.finalizeSpawn(serverLevel, serverLevel.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CONVERSION, null); mob.setPersistenceRequired(); mob.fudgePositionAfterSizeChange(this.getDimensions(this.getPose())); this.playSound(SoundEvents.TADPOLE_GROW_UP, 0.15F, 1.0F); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch index 2ce69e951fff..4e9f79e182eb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch @@ -35,7 +35,7 @@ } @Override -@@ -456,7 +_,7 @@ +@@ -460,7 +_,7 @@ i1 = 5; if (!this.level().isClientSide() && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { flag = true; @@ -44,7 +44,7 @@ } } else if (stack.is(Items.GOLDEN_APPLE) || stack.is(Items.ENCHANTED_GOLDEN_APPLE)) { f = 10.0F; -@@ -464,12 +_,12 @@ +@@ -468,12 +_,12 @@ i1 = 10; if (!this.level().isClientSide() && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { flag = true; @@ -59,7 +59,7 @@ flag = true; } -@@ -540,7 +_,7 @@ +@@ -544,7 +_,7 @@ super.aiStep(); if (this.level() instanceof ServerLevel serverLevel && this.isAlive()) { if (this.random.nextInt(900) == 0 && this.deathTime == 0) { @@ -68,7 +68,7 @@ } if (this.canEatGrass()) { -@@ -642,6 +_,16 @@ +@@ -646,6 +_,16 @@ } } @@ -85,7 +85,7 @@ @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { if (this.isVehicle() || this.isBaby()) { -@@ -794,6 +_,7 @@ +@@ -798,6 +_,7 @@ output.putInt("Temper", this.getTemper()); output.putBoolean("Tame", this.isTamed()); EntityReference.store(this.owner, output, "Owner"); @@ -93,7 +93,7 @@ } @Override -@@ -804,6 +_,7 @@ +@@ -808,6 +_,7 @@ this.setTemper(input.getIntOr("Temper", 0)); this.setTamed(input.getBooleanOr("Tame", false)); this.owner = EntityReference.readWithOldOwnerConversion(input, "Owner", this.level()); @@ -101,7 +101,7 @@ } @Override -@@ -892,6 +_,17 @@ +@@ -896,6 +_,17 @@ @Override public void handleStartJump(int jumpPower) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch index e8f62ab1ae4b..8c4fc2feacc5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch @@ -8,7 +8,7 @@ protected AbstractSkeleton(EntityType type, Level level) { super(type, level); -@@ -88,6 +_,16 @@ +@@ -88,6 +_,21 @@ return Monster.createMonsterAttributes().add(Attributes.MOVEMENT_SPEED, 0.25); } @@ -20,21 +20,17 @@ + public void setShouldBurnInDay(boolean shouldBurnInDay) { + this.shouldBurnInDay = shouldBurnInDay; + } ++ ++ @Override ++ public boolean isSunBurnTick() { ++ return this.shouldBurnInDay && super.isSunBurnTick(); ++ } + // Paper end - shouldBurnInDay API + @Override protected void playStepSound(BlockPos pos, BlockState block) { this.playSound(this.getStepSound(), 0.15F, 1.0F); -@@ -97,7 +_,7 @@ - - @Override - public void aiStep() { -- boolean isSunBurnTick = this.isSunBurnTick(); -+ boolean isSunBurnTick = this.shouldBurnInDay && this.isSunBurnTick(); // Paper - shouldBurnInDay API - if (isSunBurnTick) { - ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.HEAD); - if (!itemBySlot.isEmpty()) { -@@ -145,7 +_,7 @@ +@@ -119,7 +_,7 @@ this.populateDefaultEquipmentSlots(random, difficulty); this.populateDefaultEquipmentEnchantments(level, random, difficulty); this.reassessWeaponGoal(); @@ -43,7 +39,7 @@ if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { LocalDate localDate = LocalDate.now(); int i = localDate.get(ChronoField.DAY_OF_MONTH); -@@ -188,7 +_,8 @@ +@@ -162,7 +_,8 @@ @Override public void performRangedAttack(LivingEntity target, float distanceFactor) { @@ -53,7 +49,7 @@ ItemStack projectile = this.getProjectile(itemInHand); AbstractArrow arrow = this.getArrow(projectile, distanceFactor, itemInHand); double d = target.getX() - this.getX(); -@@ -196,9 +_,21 @@ +@@ -170,9 +_,21 @@ double d2 = target.getZ() - this.getZ(); double squareRoot = Math.sqrt(d * d + d2 * d2); if (this.level() instanceof ServerLevel serverLevel) { @@ -76,7 +72,7 @@ } this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); -@@ -222,11 +_,22 @@ +@@ -196,11 +_,22 @@ protected void readAdditionalSaveData(ValueInput input) { super.readAdditionalSaveData(input); this.reassessWeaponGoal(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch index 766d4594dab8..28b883945a16 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Drowned.java +++ b/net/minecraft/world/entity/monster/Drowned.java -@@ -86,7 +_,7 @@ +@@ -88,7 +_,7 @@ this.goalSelector.addGoal(7, new RandomStrollGoal(this, 1.0)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this, Drowned.class).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, (entity, level) -> this.okTarget(entity))); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch index e8ddd1c1a47e..ed6795582ae6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch @@ -3,7 +3,7 @@ @@ -56,7 +_,7 @@ boolean flag = super.doHurtTarget(level, target); if (flag && this.getMainHandItem().isEmpty() && target instanceof LivingEntity) { - float effectiveDifficulty = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); + float effectiveDifficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); - ((LivingEntity)target).addEffect(new MobEffectInstance(MobEffects.HUNGER, 140 * (int)effectiveDifficulty), this); + ((LivingEntity)target).addEffect(new MobEffectInstance(MobEffects.HUNGER, 140 * (int)effectiveDifficulty), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch index f4acc3a40ad0..15cfa2deb98e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch @@ -12,16 +12,21 @@ public Phantom(EntityType type, Level level) { super(type, level); -@@ -138,7 +_,7 @@ - - @Override - public void aiStep() { -- if (this.isAlive() && this.isSunBurnTick()) { -+ if (this.isAlive() && this.shouldBurnInDay && this.isSunBurnTick()) { // Paper - shouldBurnInDay API - this.igniteForSeconds(8.0F); +@@ -136,6 +_,13 @@ } + } -@@ -173,6 +_,10 @@ ++ // Paper start ++ @Override ++ public boolean isSunBurnTick() { ++ return this.shouldBurnInDay && super.isSunBurnTick(); ++ } ++ // Paper end ++ + @Override + protected void checkFallDamage(double y, boolean onGround, BlockState state, BlockPos pos) { + } +@@ -164,6 +_,10 @@ super.readAdditionalSaveData(input); this.anchorPoint = input.read("anchor_pos", BlockPos.CODEC).orElse(null); this.setPhantomSize(input.getIntOr("size", 0)); @@ -32,7 +37,7 @@ } @Override -@@ -180,6 +_,10 @@ +@@ -171,6 +_,10 @@ super.addAdditionalSaveData(output); output.storeNullable("anchor_pos", BlockPos.CODEC, this.anchorPoint); output.putInt("size", this.getPhantomSize()); @@ -43,7 +48,7 @@ } @Override -@@ -253,8 +_,10 @@ +@@ -244,8 +_,10 @@ for (Player player : nearbyPlayers) { if (Phantom.this.canAttack(serverLevel, player, TargetingConditions.DEFAULT)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch index 0c16bf27fdb9..79605ed9a1e1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch @@ -81,23 +81,20 @@ } @Override -@@ -278,9 +_,13 @@ +@@ -278,7 +_,11 @@ return checkMobSpawnRules(entityType, level, spawnReason, pos, random); } +- if (level.getBiome(pos).is(BiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS) && pos.getY() > 50 && pos.getY() < 70) { + // Paper start - Replace rules for Height in Swamp Biomes + final double maxHeightSwamp = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.maximum; + final double minHeightSwamp = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.minimum; + // Paper end - Replace rules for Height in Swamp Biomes - if (level.getBiome(pos).is(BiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS) -- && pos.getY() > 50 -- && pos.getY() < 70 -+ && pos.getY() > minHeightSwamp // Paper - Replace rules for Height in Swamp Biomes -+ && pos.getY() < maxHeightSwamp // Paper - Replace rules for Height in Swamp Biomes - && random.nextFloat() < 0.5F - && random.nextFloat() < level.getMoonBrightness() - && level.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) { -@@ -292,8 +_,11 @@ ++ if (level.getBiome(pos).is(BiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS) && pos.getY() > minHeightSwamp && pos.getY() < maxHeightSwamp) { // Paper - Replace rules for Height in Swamp Biomes + float f = level.getMoonBrightness() * 0.5F; + if (random.nextFloat() < f && level.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) { + return checkMobSpawnRules(entityType, level, spawnReason, pos, random); +@@ -290,8 +_,11 @@ } ChunkPos chunkPos = new ChunkPos(pos); @@ -111,7 +108,7 @@ return checkMobSpawnRules(entityType, level, spawnReason, pos, random); } } -@@ -352,6 +_,16 @@ +@@ -350,6 +_,16 @@ return super.getDefaultDimensions(pose).scale(this.getSize()); } @@ -128,7 +125,7 @@ static class SlimeAttackGoal extends Goal { private final Slime slime; private int growTiredTimer; -@@ -364,7 +_,16 @@ +@@ -362,7 +_,16 @@ @Override public boolean canUse() { LivingEntity target = this.slime.getTarget(); @@ -146,7 +143,7 @@ } @Override -@@ -376,7 +_,16 @@ +@@ -374,7 +_,16 @@ @Override public boolean canContinueToUse() { LivingEntity target = this.slime.getTarget(); @@ -164,7 +161,7 @@ } @Override -@@ -395,6 +_,13 @@ +@@ -393,6 +_,13 @@ slimeMoveControl.setDirection(this.slime.getYRot(), this.slime.isDealsDamage()); } } @@ -178,7 +175,7 @@ } static class SlimeFloatGoal extends Goal { -@@ -408,7 +_,7 @@ +@@ -406,7 +_,7 @@ @Override public boolean canUse() { @@ -187,7 +184,7 @@ } @Override -@@ -438,7 +_,7 @@ +@@ -436,7 +_,7 @@ @Override public boolean canUse() { @@ -196,7 +193,7 @@ } @Override -@@ -516,7 +_,7 @@ +@@ -514,7 +_,7 @@ @Override public boolean canUse() { @@ -205,7 +202,7 @@ && (this.slime.onGround() || this.slime.isInWater() || this.slime.isInLava() || this.slime.hasEffect(MobEffects.LEVITATION)) && this.slime.getMoveControl() instanceof Slime.SlimeMoveControl; } -@@ -526,6 +_,11 @@ +@@ -524,6 +_,11 @@ if (--this.nextRandomizeTime <= 0) { this.nextRandomizeTime = this.adjustedTickDelay(40 + this.slime.getRandom().nextInt(60)); this.chosenDegrees = this.slime.getRandom().nextInt(360); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch index 1fa1e4b6e2e5..82b1d9726046 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch @@ -37,7 +37,7 @@ this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F)); this.goalSelector.addGoal(8, new RandomLookAroundGoal(this)); this.addBehaviourGoals(); -@@ -116,7 +_,7 @@ +@@ -117,7 +_,7 @@ this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); @@ -46,7 +46,7 @@ this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true)); this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR)); } -@@ -170,11 +_,16 @@ +@@ -171,11 +_,16 @@ @Override protected int getBaseExperienceReward(ServerLevel level) { @@ -64,7 +64,7 @@ } @Override -@@ -182,9 +_,9 @@ +@@ -183,9 +_,9 @@ this.getEntityData().set(DATA_BABY_ID, childZombie); if (this.level() != null && !this.level().isClientSide()) { AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED); @@ -76,8 +76,8 @@ } } } -@@ -253,6 +_,13 @@ - super.aiStep(); +@@ -226,6 +_,13 @@ + super.tick(); } + // Paper start - Add more Zombie API @@ -90,18 +90,18 @@ public void startUnderWaterConversion(int conversionTime) { this.conversionTime = conversionTime; this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, true); -@@ -266,31 +_,50 @@ +@@ -239,31 +_,50 @@ } - protected void convertToZombieType(EntityType entityType) { + protected void convertToZombieType(ServerLevel level, EntityType entityType) { - this.convertTo( + Zombie converted = this.convertTo( // CraftBukkit entityType, ConversionParams.single(this, true, true), -- zombie -> zombie.handleAttributes(zombie.level().getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()) +- zombie -> zombie.handleAttributes(level.getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()) - ); + // CraftBukkit start -+ zombie -> { zombie.handleAttributes(zombie.level().getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()); }, ++ zombie -> { zombie.handleAttributes(level.getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()); }, + org.bukkit.event.entity.EntityTransformEvent.TransformReason.DROWNED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DROWNED); + if (converted == null) { + ((org.bukkit.entity.Zombie) this.getBukkitEntity()).setConversionTime(-1); // CraftBukkit - SPIGOT-5208: End conversion to stop event spam @@ -150,7 +150,7 @@ @Override public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { -@@ -323,13 +_,13 @@ +@@ -296,13 +_,13 @@ if (SpawnPlacements.isSpawnPositionOk(type, level, blockPos) && SpawnPlacements.checkSpawnRules(type, level, EntitySpawnReason.REINFORCEMENT, blockPos, level.random)) { zombie.setPos(i1, i2, i3); @@ -167,9 +167,9 @@ AttributeInstance attribute = this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE); AttributeModifier modifier = attribute.getModifier(REINFORCEMENT_CALLER_CHARGE_ID); double d = modifier != null ? modifier.amount() : 0.0; -@@ -354,7 +_,12 @@ +@@ -327,7 +_,12 @@ if (flag) { - float effectiveDifficulty = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); + float effectiveDifficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < effectiveDifficulty * 0.3F) { - target.igniteForSeconds(2 * (int)effectiveDifficulty); + // CraftBukkit start @@ -181,7 +181,7 @@ } } -@@ -414,6 +_,7 @@ +@@ -389,6 +_,7 @@ output.putBoolean("CanBreakDoors", this.canBreakDoors()); output.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1); output.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1); @@ -189,7 +189,7 @@ } @Override -@@ -428,13 +_,15 @@ +@@ -403,13 +_,15 @@ } else { this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, false); } @@ -207,7 +207,7 @@ return flag; } -@@ -470,7 +_,7 @@ +@@ -445,7 +_,7 @@ spawnGroupData = super.finalizeSpawn(level, difficulty, spawnReason, spawnGroupData); float specialMultiplier = difficulty.getSpecialMultiplier(); if (spawnReason != EntitySpawnReason.CONVERSION) { @@ -216,7 +216,7 @@ } if (spawnGroupData == null) { -@@ -497,7 +_,7 @@ +@@ -472,7 +_,7 @@ chicken1.finalizeSpawn(level, difficulty, EntitySpawnReason.JOCKEY, null); chicken1.setChickenJockey(true); this.startRiding(chicken1, false, false); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch index aaf4a55a1b34..3ffae817d785 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/ZombifiedPiglin.java +++ b/net/minecraft/world/entity/monster/ZombifiedPiglin.java -@@ -57,6 +_,7 @@ +@@ -58,6 +_,7 @@ private static final int ALERT_RANGE_Y = 10; private static final UniformInt ALERT_INTERVAL = TimeUtil.rangeOfSeconds(4, 6); private int ticksUntilNextAlert; @@ -8,8 +8,8 @@ public ZombifiedPiglin(EntityType type, Level level) { super(type, level); -@@ -72,7 +_,7 @@ - protected void addBehaviourGoals() { +@@ -69,7 +_,7 @@ + this.goalSelector.addGoal(1, new SpearUseGoal<>(this, 1.0, 1.0, 10.0F, 2.0F)); this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0, false)); this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0)); - this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers()); @@ -17,7 +17,7 @@ this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt)); this.targetSelector.addGoal(3, new ResetUniversalAngerTargetGoal<>(this, true)); } -@@ -145,7 +_,7 @@ +@@ -142,7 +_,7 @@ .filter(zombifiedPiglin -> zombifiedPiglin != this) .filter(zombifiedPiglin -> zombifiedPiglin.getTarget() == null) .filter(zombifiedPiglin -> !zombifiedPiglin.isAlliedTo(this.getTarget())) @@ -26,7 +26,7 @@ } private void playAngerSound() { -@@ -153,18 +_,27 @@ +@@ -150,18 +_,27 @@ } @Override @@ -43,16 +43,16 @@ @Override public void startPersistentAngerTimer() { -- this.setRemainingPersistentAngerTime(PERSISTENT_ANGER_TIME.sample(this.random)); +- this.setTimeToRemainAngry(PERSISTENT_ANGER_TIME.sample(this.random)); + // CraftBukkit start -+ net.minecraft.world.entity.Entity entity = this.level().getEntity(this.getPersistentAngerTarget()); ++ net.minecraft.world.entity.Entity entity = EntityReference.getLivingEntity(this.getPersistentAngerTarget(), this.level()); + org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), PERSISTENT_ANGER_TIME.sample(this.random)); + if (!event.callEvent()) { + this.setPersistentAngerTarget(null); + this.hurtByTargetGoal.stop(); + return; + } -+ this.setRemainingPersistentAngerTime(event.getNewAnger()); ++ this.setTimeToRemainAngry(event.getNewAnger()); + // CraftBukkit end } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch index b77879c62178..05245de11466 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch @@ -21,7 +21,7 @@ } public void creakingDeathEffects(DamageSource damageSource) { -@@ -465,9 +_,9 @@ +@@ -448,9 +_,9 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch index 1f8045297320..3d2981564dac 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -265,7 +_,12 @@ +@@ -266,7 +_,12 @@ } private void finishConversion() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch index c56f122490b8..c8b899872eaf 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java -@@ -99,9 +_,14 @@ +@@ -102,9 +_,14 @@ } protected void finishConversion(ServerLevel level) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch index 2a270086eedc..93e2f77079ee 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch @@ -45,7 +45,7 @@ super.finishConversion(level); } -@@ -386,7 +_,7 @@ +@@ -388,7 +_,7 @@ } protected void holdInOffHand(ItemStack stack) { @@ -54,7 +54,7 @@ this.setItemSlot(EquipmentSlot.OFFHAND, stack); this.setGuaranteedDrop(EquipmentSlot.OFFHAND); } else { -@@ -411,15 +_,15 @@ +@@ -413,15 +_,15 @@ return false; } else { TagKey preferredWeaponType = this.getPreferredWeaponType(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch index fbfd47d8f601..f201ac3c58ee 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/AbstractVillager.java +++ b/net/minecraft/world/entity/npc/AbstractVillager.java -@@ -42,7 +_,7 @@ +@@ -43,7 +_,7 @@ private Player tradingPlayer; @Nullable protected MerchantOffers offers; @@ -9,7 +9,7 @@ public AbstractVillager(EntityType type, Level level) { super(type, level); -@@ -95,6 +_,20 @@ +@@ -96,6 +_,20 @@ return this.tradingPlayer != null; } @@ -23,14 +23,14 @@ + // Paper start - Villager#resetOffers + public void resetOffers() { + this.offers = new MerchantOffers(); -+ this.updateTrades(); ++ this.updateTrades((net.minecraft.server.level.ServerLevel) this.level()); + } + // Paper end - Villager#resetOffers + @Override public MerchantOffers getOffers() { - if (this.level().isClientSide()) { -@@ -117,11 +_,24 @@ + if (this.level() instanceof ServerLevel serverLevel) { +@@ -118,11 +_,24 @@ public void overrideXp(int xp) { } @@ -57,9 +57,9 @@ if (this.tradingPlayer instanceof ServerPlayer) { CriteriaTriggers.TRADE.trigger((ServerPlayer)this.tradingPlayer, this, offer.getResult()); } -@@ -226,7 +_,20 @@ +@@ -227,7 +_,20 @@ while (i < maxNumbers && !list.isEmpty()) { - MerchantOffer offer = list.remove(this.random.nextInt(list.size())).getOffer(this, this.random); + MerchantOffer offer = list.remove(this.random.nextInt(list.size())).getOffer(level, this, this.random); if (offer != null) { - givenMerchantOffers.add(offer); + // CraftBukkit start diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch index 146e0945c326..c6bc2830f74d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch @@ -23,7 +23,7 @@ } this.resendOffersToTradingPlayer(); -@@ -456,7 +_,12 @@ +@@ -451,7 +_,12 @@ int i = 2 - this.numberOfRestocksToday; if (i > 0) { for (MerchantOffer merchantOffer : this.getOffers()) { @@ -37,7 +37,7 @@ } } -@@ -477,6 +_,7 @@ +@@ -472,6 +_,7 @@ int playerReputation = this.getPlayerReputation(player); if (playerReputation != 0) { for (MerchantOffer merchantOffer : this.getOffers()) { @@ -45,7 +45,7 @@ merchantOffer.addToSpecialPriceDiff(-Mth.floor(playerReputation * merchantOffer.getPriceMultiplier())); } } -@@ -486,6 +_,7 @@ +@@ -481,6 +_,7 @@ int amplifier = effect.getAmplifier(); for (MerchantOffer merchantOffer1 : this.getOffers()) { @@ -53,7 +53,7 @@ double d = 0.3 + 0.0625 * amplifier; int i = (int)Math.floor(d * merchantOffer1.getBaseCostA().getCount()); merchantOffer1.addToSpecialPriceDiff(-Math.max(i, 1)); -@@ -594,7 +_,7 @@ +@@ -589,7 +_,7 @@ } if (offer.shouldRewardExp()) { @@ -62,7 +62,7 @@ } } -@@ -612,7 +_,7 @@ +@@ -607,7 +_,7 @@ @Override public void die(DamageSource damageSource) { @@ -71,7 +71,16 @@ Entity entity = damageSource.getEntity(); if (entity != null) { this.tellWitnessesThatIWasMurdered(entity); -@@ -780,12 +_,19 @@ +@@ -706,7 +_,7 @@ + return VillagerData.canLevelUp(level) && this.villagerXp >= VillagerData.getMaxXpPerLevel(level); + } + +- private void increaseMerchantCareer(ServerLevel serverLevel) { ++ public void increaseMerchantCareer(ServerLevel serverLevel) { // Paper - public + this.setVillagerData(this.getVillagerData().withLevel(this.getVillagerData().level() + 1)); + this.updateTrades(serverLevel); + } +@@ -775,12 +_,19 @@ @Override public void thunderHit(ServerLevel level, LightningBolt lightning) { if (level.getDifficulty() != Difficulty.PEACEFUL) { @@ -93,10 +102,10 @@ if (witch == null) { super.thunderHit(level, lightning); } -@@ -825,6 +_,12 @@ +@@ -820,6 +_,12 @@ @Override - protected void updateTrades() { + protected void updateTrades(ServerLevel level) { + // Paper start - More vanilla friendly methods to update trades + this.updateTrades(TRADES_PER_LEVEL); + } @@ -106,14 +115,15 @@ VillagerData villagerData = this.getVillagerData(); ResourceKey resourceKey = villagerData.profession().unwrapKey().orElse(null); if (resourceKey != null) { -@@ -840,13 +_,15 @@ +@@ -835,13 +_,15 @@ VillagerTrades.ItemListing[] itemListings = map1.get(villagerData.level()); if (itemListings != null) { MerchantOffers offers = this.getOffers(); -- this.addOffersFromItemListings(offers, itemListings, 2); -+ this.addOffersFromItemListings(offers, itemListings, amount); // Paper - More vanilla friendly methods to update trades +- this.addOffersFromItemListings(level, offers, itemListings, 2); ++ this.addOffersFromItemListings((net.minecraft.server.level.ServerLevel) this.level(), offers, itemListings, amount); // Paper - More vanilla friendly methods to update trades if (SharedConstants.DEBUG_UNLOCK_ALL_TRADES && villagerData.level() < map1.size()) { - this.increaseMerchantCareer(); +- this.increaseMerchantCareer(level); ++ this.increaseMerchantCareer((net.minecraft.server.level.ServerLevel) this.level()); } + return true; // Paper - More vanilla friendly methods to update trades } @@ -123,7 +133,7 @@ } public void gossip(ServerLevel level, Villager target, long gameTime) { -@@ -875,7 +_,7 @@ +@@ -870,7 +_,7 @@ List entitiesOfClass = level.getEntitiesOfClass(Villager.class, aabb); List list = entitiesOfClass.stream().filter(villager -> villager.wantsToSpawnGolem(gameTime)).limit(5L).toList(); if (list.size() >= minVillagerAmount) { @@ -132,7 +142,7 @@ EntityType.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, level, -@@ -884,9 +_,11 @@ +@@ -879,9 +_,11 @@ 8, 6, SpawnUtil.Strategy.LEGACY_IRON_GOLEM, diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch index 08fa52754fdf..96af2b92ea84 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/entity/npc/VillagerTrades.java +++ b/net/minecraft/world/entity/npc/VillagerTrades.java -@@ -1747,7 +_,8 @@ +@@ -1742,7 +_,8 @@ + @Nullable @Override - public MerchantOffer getOffer(Entity trader, RandomSource random) { - if (trader.level() instanceof ServerLevel serverLevel) { -- BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, trader.blockPosition(), 100, true); -+ if (!serverLevel.paperConfig().environment.treasureMaps.enabled) return null; // Paper - Configurable cartographer treasure maps -+ BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, trader.blockPosition(), 100, !serverLevel.paperConfig().environment.treasureMaps.findAlreadyDiscoveredVillager); // Paper - Configurable cartographer treasure maps - if (blockPos != null) { - ItemStack itemStack = MapItem.create(serverLevel, blockPos.getX(), blockPos.getZ(), (byte)2, true, true); - MapItem.renderBiomePreviewMap(serverLevel, itemStack); + public MerchantOffer getOffer(ServerLevel level, Entity trader, RandomSource random) { +- BlockPos blockPos = level.findNearestMapStructure(this.destination, trader.blockPosition(), 100, true); ++ if (!level.paperConfig().environment.treasureMaps.enabled) return null; // Paper - Configurable cartographer treasure maps ++ BlockPos blockPos = level.findNearestMapStructure(this.destination, trader.blockPosition(), 100, !level.paperConfig().environment.treasureMaps.findAlreadyDiscoveredVillager); // Paper - Configurable cartographer treasure maps + if (blockPos != null) { + ItemStack itemStack = MapItem.create(level, blockPos.getX(), blockPos.getZ(), (byte)2, true, true); + MapItem.renderBiomePreviewMap(level, itemStack); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index d18815c923a7..9ab9a793ed41 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -147,7 +_,7 @@ +@@ -149,7 +_,7 @@ private static final boolean DEFAULT_IGNORE_FALL_DAMAGE_FROM_CURRENT_IMPULSE = false; private static final int DEFAULT_CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME = 0; final Inventory inventory; @@ -9,7 +9,7 @@ public final InventoryMenu inventoryMenu; public AbstractContainerMenu containerMenu; protected FoodData foodData = new FoodData(); -@@ -178,6 +_,18 @@ +@@ -180,6 +_,18 @@ public Entity currentExplosionCause; private boolean ignoreFallDamageFromCurrentImpulse = false; private int currentImpulseContextResetGraceTime = 0; @@ -28,7 +28,7 @@ public Player(Level level, GameProfile gameProfile) { super(EntityType.PLAYER, level); -@@ -245,6 +_,13 @@ +@@ -247,6 +_,13 @@ if (this.isSleeping()) { this.sleepCounter++; @@ -42,7 +42,7 @@ if (this.sleepCounter > 100) { this.sleepCounter = 100; } -@@ -326,7 +_,7 @@ +@@ -329,7 +_,7 @@ } private void turtleHelmetTick() { @@ -51,7 +51,7 @@ } private boolean isEquipped(Item item) { -@@ -430,6 +_,18 @@ +@@ -433,6 +_,18 @@ } } @@ -70,7 +70,7 @@ public void closeContainer() { this.containerMenu = this.inventoryMenu; } -@@ -441,8 +_,14 @@ +@@ -444,8 +_,14 @@ public void rideTick() { if (!this.level().isClientSide() && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -87,7 +87,7 @@ super.rideTick(); } } -@@ -703,10 +_,10 @@ +@@ -706,10 +_,10 @@ if (this.isDeadOrDying()) { return false; } else { @@ -100,7 +100,7 @@ } if (level.getDifficulty() == Difficulty.EASY) { -@@ -718,7 +_,14 @@ +@@ -721,7 +_,14 @@ } } @@ -116,7 +116,7 @@ } } } -@@ -730,7 +_,7 @@ +@@ -733,7 +_,7 @@ BlocksAttacks blocksAttacks = itemBlockingWith != null ? itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS) : null; float secondsToDisableBlocking = entity.getSecondsToDisableBlocking(); if (secondsToDisableBlocking > 0.0F && blocksAttacks != null) { @@ -125,7 +125,7 @@ } } -@@ -740,9 +_,29 @@ +@@ -743,9 +_,29 @@ } public boolean canHarmPlayer(Player other) { @@ -158,7 +158,7 @@ } @Override -@@ -756,7 +_,12 @@ +@@ -759,7 +_,12 @@ } @Override @@ -172,7 +172,7 @@ if (!this.isInvulnerableTo(level, damageSource)) { amount = this.getDamageAfterArmorAbsorb(damageSource, amount); amount = this.getDamageAfterMagicAbsorb(damageSource, amount); -@@ -768,7 +_,7 @@ +@@ -771,7 +_,7 @@ } if (var8 != 0.0F) { @@ -181,7 +181,7 @@ this.getCombatTracker().recordDamage(damageSource, var8); this.setHealth(this.getHealth() - var8); if (var8 < 3.4028235E37F) { -@@ -778,6 +_,7 @@ +@@ -781,6 +_,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -189,7 +189,7 @@ } public boolean isTextFilteringEnabled() { -@@ -861,14 +_,16 @@ +@@ -864,14 +_,16 @@ } @Override @@ -209,14 +209,13 @@ } @Override -@@ -947,8 +_,17 @@ +@@ -950,21 +_,31 @@ } public void attack(Entity target) { -- if (target.isAttackable()) { -- if (!target.skipAttackInteraction(this)) { +- if (!this.cannotAttack(target)) { + // Paper start - PlayerAttackEntityEvent -+ boolean willAttack = target.isAttackable() && !target.skipAttackInteraction(this); // Vanilla logic ++ boolean willAttack = !this.cannotAttack(target); // Vanilla logic + io.papermc.paper.event.player.PrePlayerAttackEntityEvent playerAttackEntityEvent = new io.papermc.paper.event.player.PrePlayerAttackEntityEvent( + (org.bukkit.entity.Player) this.getBukkitEntity(), + target.getBukkitEntity(), @@ -224,164 +223,162 @@ + ); + + if (playerAttackEntityEvent.callEvent() && willAttack) { // Logic moved to willAttack local variable. -+ { + // Paper end - PlayerAttackEntityEvent - float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); - ItemStack weaponItem = this.getWeaponItem(); - DamageSource damageSource = Optional.ofNullable(weaponItem.getItem().getDamageSource(this)).orElse(this.damageSources().playerAttack(this)); -@@ -956,18 +_,25 @@ - float attackStrengthScale = this.getAttackStrengthScale(0.5F); - f *= 0.2F + attackStrengthScale * attackStrengthScale * 0.8F; - f1 *= attackStrengthScale; -- this.resetAttackStrengthTicker(); -+ // this.resetAttackStrengthTicker(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt - if (target.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) -- && target instanceof Projectile projectile -- && projectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, EntityReference.of(this), true)) { -- this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); -- } else { -+ && target instanceof Projectile projectile) { -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(target, damageSource, f1, false)) { -+ return; -+ } -+ if (projectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, EntityReference.of(this), true)) { -+ this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); -+ return; -+ } -+ } -+ { -+ // CraftBukkit end - if (f > 0.0F || f1 > 0.0F) { - boolean flag = attackStrengthScale > 0.9F; - boolean flag1; - if (this.isSprinting() && flag) { -- this.level() -- .playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); -+ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility - flag1 = true; - } else { - flag1 = false; -@@ -983,7 +_,9 @@ - && !this.isPassenger() - && target instanceof LivingEntity - && !this.isSprinting(); -+ flag2 = flag2 && !this.level().paperConfig().entities.behavior.disablePlayerCrits; // Paper - Toggleable player crits - if (flag2) { -+ damageSource = damageSource.critical(); // Paper - critical damage API - f *= 1.5F; - } - -@@ -1010,17 +_,23 @@ - if (target instanceof LivingEntity livingEntity1) { - livingEntity1.knockback( - f4 * 0.5F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) -+ , this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK // Paper - knockback events - ); - } else { - target.push( - -Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)) * f4 * 0.5F, - 0.1, - Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) * f4 * 0.5F -+ , this // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent - ); - } - - this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); -+ // Paper start - Configurable sprint interruption on attack -+ if (!this.level().paperConfig().misc.disableSprintInterruptionOnAttack) { - this.setSprinting(false); -+ } -+ // Paper end - Configurable sprint interruption on attack - } - - if (flag3) { -@@ -1034,42 +_,59 @@ - && !(livingEntity2 instanceof ArmorStand armorStand && armorStand.isMarker()) - && this.distanceToSqr(livingEntity2) < 9.0) { - float f6 = this.getEnchantedDamage(livingEntity2, f5, damageSource) * attackStrengthScale; -- if (this.level() instanceof ServerLevel serverLevel && livingEntity2.hurtServer(serverLevel, damageSource, f6)) { -+ // Paper start - Only apply knockback if the event is not cancelled -+ livingEntity2.lastDamageCancelled = false; -+ if (this.level() instanceof ServerLevel serverLevel && livingEntity2.hurtServer(serverLevel, damageSource.knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK), f6) && !livingEntity2.lastDamageCancelled) { -+ // Paper end - Only apply knockback if the event is not cancelled - livingEntity2.knockback( - 0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) -+ , this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK // Paper - knockback events - ); - EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity2, damageSource); - } - } - } - -- this.level() -- .playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, this.getSoundSource(), 1.0F, 1.0F); -+ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility - this.sweepAttack(); - } - - if (target instanceof ServerPlayer && target.hurtMarked) { -+ // CraftBukkit start - Add Velocity Event -+ boolean cancelled = false; -+ org.bukkit.entity.Player player = (org.bukkit.entity.Player) target.getBukkitEntity(); -+ org.bukkit.util.Vector velocity = org.bukkit.craftbukkit.util.CraftVector.toBukkit(deltaMovement); + float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); + ItemStack weaponItem = this.getWeaponItem(); +- DamageSource damageSource = this.createAttackSource(weaponItem); ++ DamageSource damageSource = this.createAttackSource(weaponItem); final DamageSource dmgSourceFinal = damageSource; // Paper - damage events + float f1 = this.getEnchantedDamage(target, f, damageSource) - f; + float attackStrengthScale = this.getAttackStrengthScale(0.5F); + f *= 0.2F + attackStrengthScale * attackStrengthScale * 0.8F; + f1 *= attackStrengthScale; + this.onAttack(); +- if (!this.deflectProjectile(target)) { ++ final float dmgFinal = f1; // Paper - damage events ++ if (!this.deflectProjectile(target, () -> !org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(target, dmgSourceFinal, dmgFinal, false))) { + if (f > 0.0F || f1 > 0.0F) { + boolean flag = attackStrengthScale > 0.9F; + boolean flag1; + if (this.isSprinting() && flag) { +- this.makeSound(SoundEvents.PLAYER_ATTACK_KNOCKBACK); ++ this.makeSound(SoundEvents.PLAYER_ATTACK_KNOCKBACK); // TODO - snapshot - not sure how to port the diff from this line yet (used to be this.level().playSound(...)) + flag1 = true; + } else { + flag1 = false; +@@ -972,7 +_,9 @@ + + f += weaponItem.getItem().getAttackDamageBonus(target, f, damageSource); + boolean flag2 = flag && this.canCriticalAttack(target); ++ flag2 = flag2 && !this.level().paperConfig().entities.behavior.disablePlayerCrits; // Paper - Toggleable player crits + if (flag2) { ++ damageSource = damageSource.critical(); // Paper - critical damage API + f *= 1.5F; + } + +@@ -997,7 +_,7 @@ + this.damageStatsAndHearts(target, f3); + this.causeFoodExhaustion(0.1F); + } else { +- this.makeSound(SoundEvents.PLAYER_ATTACK_NODAMAGE); ++ this.makeSound(SoundEvents.PLAYER_ATTACK_NODAMAGE); // TODO - snapshot - not sure how to port the diff from this line yet (used to be this.level().playSound(...) + } + } + +@@ -1014,11 +_,12 @@ + return !target.isAttackable() || target.skipAttackInteraction(this); + } + +- private boolean deflectProjectile(Entity target) { ++ private boolean deflectProjectile(Entity target, java.util.function.BooleanSupplier callEvent) { // Paper - damage events + if (target.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) + && target instanceof Projectile projectile ++ && callEvent.getAsBoolean() // Paper - damage events + && projectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, EntityReference.of(this), true)) { +- this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); ++ this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); // TODO - snapshot - should this line also get the sound diff? + return true; + } else { + return false; +@@ -1050,12 +_,12 @@ + + private void attackVisualEffects(Entity target, boolean isCritical, boolean isSweep, boolean isStrong, float damageAmount) { + if (isCritical) { +- this.makeSound(SoundEvents.PLAYER_ATTACK_CRIT); ++ this.makeSound(SoundEvents.PLAYER_ATTACK_CRIT); // TODO - snapshot - not sure how to port the diff from this line yet (used to be this.level().playSound(...)) + this.crit(target); + } + + if (!isCritical && !isSweep) { +- this.makeSound(isStrong ? SoundEvents.PLAYER_ATTACK_STRONG : SoundEvents.PLAYER_ATTACK_WEAK); ++ this.makeSound(isStrong ? SoundEvents.PLAYER_ATTACK_STRONG : SoundEvents.PLAYER_ATTACK_WEAK); // TODO - snapshot - not sure how to port the diff from this line yet (used to be this.level().playSound(...)) + } + + if (damageAmount > 0.0F) { +@@ -1111,21 +_,43 @@ + public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { + if (strength > 0.0F) { + if (target instanceof LivingEntity livingEntity) { +- livingEntity.knockback(strength, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); ++ livingEntity.knockback(strength, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // Paper - knockback events + } else { + target.push( + -Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)) * strength, 0.1, Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) * strength ++ , this // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent + ); + } + + this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); ++ // Paper start - Configurable sprint interruption on attack ++ if (!this.level().paperConfig().misc.disableSprintInterruptionOnAttack) { + this.setSprinting(false); ++ } ++ // Paper end - Configurable sprint interruption on attack + } + + if (target instanceof ServerPlayer && target.hurtMarked) { ++ // CraftBukkit start - Add Velocity Event ++ boolean cancelled = false; ++ org.bukkit.entity.Player player = (org.bukkit.entity.Player) target.getBukkitEntity(); ++ org.bukkit.util.Vector velocity = org.bukkit.craftbukkit.util.CraftVector.toBukkit(currentMovement); + -+ org.bukkit.event.player.PlayerVelocityEvent event = new org.bukkit.event.player.PlayerVelocityEvent(player, velocity.clone()); -+ this.level().getCraftServer().getPluginManager().callEvent(event); ++ org.bukkit.event.player.PlayerVelocityEvent event = new org.bukkit.event.player.PlayerVelocityEvent(player, velocity.clone()); ++ this.level().getCraftServer().getPluginManager().callEvent(event); + -+ if (event.isCancelled()) { -+ cancelled = true; -+ } else if (!velocity.equals(event.getVelocity())) { -+ player.setVelocity(event.getVelocity()); -+ } ++ if (event.isCancelled()) { ++ cancelled = true; ++ } else if (!velocity.equals(event.getVelocity())) { ++ player.setVelocity(event.getVelocity()); ++ } + -+ if (!cancelled) { - ((ServerPlayer)target).connection.send(new ClientboundSetEntityMotionPacket(target)); - target.hurtMarked = false; - target.setDeltaMovement(deltaMovement); -+ } -+ // CraftBukkit end - } - - if (flag2) { -- this.level() -- .playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, this.getSoundSource(), 1.0F, 1.0F); -+ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility - this.crit(target); - } - - if (!flag2 && !flag3) { - if (flag) { -- this.level() -- .playSound( -- null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_STRONG, this.getSoundSource(), 1.0F, 1.0F -+ sendSoundEffect( -+ this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_STRONG, this.getSoundSource(), 1.0F, 1.0F // Paper - send while respecting visibility - ); - } else { -- this.level() -- .playSound( -- null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_WEAK, this.getSoundSource(), 1.0F, 1.0F -+ sendSoundEffect( -+ this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_WEAK, this.getSoundSource(), 1.0F, 1.0F // Paper - send while respecting visibility - ); - } - } -@@ -1117,10 +_,10 @@ - } - } - -- this.causeFoodExhaustion(0.1F); -+ this.causeFoodExhaustion(this.level().spigotConfig.combatExhaustion, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent // Spigot - Change to use configurable value - } else { -- this.level() -- .playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); -+ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility -+ // CraftBukkit end - } ++ if (!cancelled) { + ((ServerPlayer)target).connection.send(new ClientboundSetEntityMotionPacket(target)); + target.hurtMarked = false; + target.setDeltaMovement(currentMovement); ++ } ++ // CraftBukkit end + } + } + +@@ -1135,7 +_,7 @@ + } + + private void doSweepAttack(Entity entity, float damageAmount, DamageSource damageSource, float strengthScale) { +- this.makeSound(SoundEvents.PLAYER_ATTACK_SWEEP); ++ this.makeSound(SoundEvents.PLAYER_ATTACK_SWEEP); // TODO - snapshot - not sure how to port the diff from this line yet (used to be this.level().playSound(...)) + if (this.level() instanceof ServerLevel serverLevel) { + float var12 = 1.0F + (float)this.getAttributeValue(Attributes.SWEEPING_DAMAGE_RATIO) * damageAmount; + +@@ -1146,7 +_,10 @@ + && !(livingEntity instanceof ArmorStand armorStand && armorStand.isMarker()) + && this.distanceToSqr(livingEntity) < 9.0) { + float f1 = this.getEnchantedDamage(livingEntity, var12, damageSource) * strengthScale; +- if (livingEntity.hurtServer(serverLevel, damageSource, f1)) { ++ // Paper start - Only apply knockback if the event is not canceled ++ livingEntity.lastDamageCancelled = false; ++ if (livingEntity.hurtServer(serverLevel, damageSource.knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK), f1) && !livingEntity.lastDamageCancelled) { ++ // Paper end - Only apply knockback if the event is not canceled + livingEntity.knockback(0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); + EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity, damageSource); } +@@ -1179,7 +_,7 @@ + ItemStack itemBySlot = this.getItemBySlot(slot); + DamageSource damageSource = this.createAttackSource(itemBySlot); + float f = this.getEnchantedDamage(target, damageAmount, damageSource) - damageAmount; +- if (knockback && this.deflectProjectile(target)) { ++ if (knockback && this.deflectProjectile(target, () -> org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(target, damageSource, f, false))) { // Paper - damage events + return true; + } else { + float f1 = damage ? damageAmount + f : 0.0F; +@@ -1207,7 +_,7 @@ + this.setLastHurtMob(target); + this.itemAttackInteraction(target, itemBySlot, damageSource, flag); + this.damageStatsAndHearts(target, f2); +- this.causeFoodExhaustion(0.1F); ++ this.causeFoodExhaustion(this.level().spigotConfig.combatExhaustion, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent // Spigot - Change to use configurable value + return true; } -@@ -1155,8 +_,8 @@ + } +@@ -1218,8 +_,8 @@ } @Override @@ -392,7 +389,7 @@ this.inventoryMenu.removed(this); if (this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1224,6 +_,12 @@ +@@ -1287,6 +_,12 @@ } public Either startSleepInBed(BlockPos bedPos) { @@ -405,7 +402,7 @@ this.startSleeping(bedPos); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1335,7 +_,7 @@ +@@ -1398,7 +_,7 @@ @Override public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) { @@ -414,7 +411,7 @@ return false; } else { if (fallDistance >= 2.0) { -@@ -1376,7 +_,15 @@ +@@ -1439,7 +_,15 @@ } public void startFallFlying() { @@ -431,7 +428,7 @@ } @Override -@@ -1482,15 +_,35 @@ +@@ -1545,15 +_,35 @@ public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { return 112 + (this.experienceLevel - 30) * 9; @@ -469,7 +466,16 @@ } } } -@@ -1759,17 +_,32 @@ +@@ -1804,7 +_,7 @@ + + @Override + public void onAttack() { +- this.resetOnlyAttackStrengthTicker(); ++ // this.resetOnlyAttackStrengthTicker(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt + super.onAttack(); + } + +@@ -1839,17 +_,32 @@ return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } @@ -504,7 +510,7 @@ for (int i = 0; i < this.inventory.getContainerSize(); i++) { ItemStack item = this.inventory.getItem(i); -@@ -1778,6 +_,7 @@ +@@ -1858,6 +_,7 @@ } } @@ -512,7 +518,7 @@ return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; } } -@@ -1864,12 +_,20 @@ +@@ -1944,12 +_,20 @@ } public boolean hasClientLoaded() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch index 1d4e63f3c04e..8c4c1b262292 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/AbstractArrow.java +++ b/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -84,7 +_,14 @@ +@@ -87,7 +_,14 @@ protected AbstractArrow( EntityType type, double x, double y, double z, Level level, ItemStack pickupItemStack, @Nullable ItemStack firedFromWeapon ) { @@ -15,7 +15,7 @@ this.pickupItemStack = pickupItemStack.copy(); this.applyComponentsFromItemStack(pickupItemStack); Unit unit = pickupItemStack.remove(DataComponents.INTANGIBLE_PROJECTILE); -@@ -109,8 +_,8 @@ +@@ -112,8 +_,8 @@ protected AbstractArrow( EntityType type, LivingEntity owner, Level level, ItemStack pickupItemStack, @Nullable ItemStack firedFromWeapon ) { @@ -26,7 +26,7 @@ } public void setSoundEvent(SoundEvent soundEvent) { -@@ -205,6 +_,7 @@ +@@ -208,6 +_,7 @@ this.setSharedFlagOnFire(this.getRemainingFireTicks() > 0); } } else { @@ -34,22 +34,25 @@ this.inGroundTime = 0; Vec3 vec31 = this.position(); if (this.isInWater()) { -@@ -272,12 +_,12 @@ +@@ -277,7 +_,7 @@ - if (entityHitResult == null) { + if (list.isEmpty()) { if (this.isAlive() && hitResult.getType() != HitResult.Type.MISS) { - this.hitTargetOrDeflectSelf(hitResult); + this.preHitTargetOrDeflectSelf(hitResult); // CraftBukkit - projectile hit event this.hasImpulse = true; } break; - } else if (this.isAlive() && !this.noPhysics) { -- ProjectileDeflection projectileDeflection = this.hitTargetOrDeflectSelf(entityHitResult); -+ ProjectileDeflection projectileDeflection = this.preHitTargetOrDeflectSelf(entityHitResult); // CraftBukkit - projectile hit event - this.hasImpulse = true; - if (this.getPierceLevel() > 0 && projectileDeflection == ProjectileDeflection.NONE) { - continue; -@@ -310,13 +_,26 @@ +@@ -294,7 +_,7 @@ + + private ProjectileDeflection hitTargetsOrDeflectSelf(Collection hitResults) { + for (EntityHitResult entityHitResult : hitResults) { +- ProjectileDeflection projectileDeflection = this.hitTargetOrDeflectSelf(entityHitResult); ++ ProjectileDeflection projectileDeflection = this.preHitTargetOrDeflectSelf(entityHitResult); // CraftBukkit - projectile hit event + if (!this.isAlive() || projectileDeflection != ProjectileDeflection.NONE) { + return projectileDeflection; + } +@@ -326,13 +_,26 @@ } } @@ -77,7 +80,7 @@ } private void startFalling() { -@@ -349,8 +_,8 @@ +@@ -365,8 +_,8 @@ protected void tickDespawn() { this.life++; @@ -88,7 +91,7 @@ } } -@@ -384,9 +_,9 @@ +@@ -400,9 +_,9 @@ } @Override @@ -100,7 +103,7 @@ } } -@@ -413,7 +_,7 @@ +@@ -429,7 +_,7 @@ } if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) { @@ -109,7 +112,7 @@ return; } -@@ -429,10 +_,16 @@ +@@ -445,10 +_,16 @@ livingEntity.setLastHurtMob(entity); } @@ -127,7 +130,7 @@ } if (entity.hurtOrSimulate(damageSource, ceil)) { -@@ -470,7 +_,7 @@ +@@ -486,7 +_,7 @@ this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); if (this.getPierceLevel() <= 0) { @@ -136,7 +139,7 @@ } } else { entity.setRemainingFireTicks(remainingFireTicks); -@@ -481,7 +_,7 @@ +@@ -497,7 +_,7 @@ this.spawnAtLocation(serverLevel2, this.getPickupItem(), 0.1F); } @@ -145,7 +148,7 @@ } } } -@@ -494,7 +_,7 @@ +@@ -510,7 +_,7 @@ double max = Math.max(0.0, 1.0 - entity.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); Vec3 vec3 = this.getDeltaMovement().multiply(1.0, 0.0, 1.0).normalize().scale(d * 0.6 * max); if (vec3.lengthSqr() > 0.0) { @@ -154,7 +157,7 @@ } } } -@@ -601,7 +_,14 @@ +@@ -623,7 +_,14 @@ @Override public void setOwner(@Nullable Entity entity) { @@ -169,7 +172,7 @@ this.pickup = switch (entity) { case Player player when this.pickup == AbstractArrow.Pickup.DISALLOWED -> AbstractArrow.Pickup.ALLOWED; -@@ -613,9 +_,22 @@ +@@ -635,9 +_,22 @@ @Override public void playerTouch(Player entity) { if (!this.level().isClientSide() && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch index 955181e9c8e4..f0cdb389cdd5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch @@ -22,7 +22,7 @@ ) .apply(instance, Raid::new) ); -@@ -128,6 +_,7 @@ +@@ -127,6 +_,7 @@ this.center = center; this.numGroups = this.getNumGroups(difficulty); this.status = Raid.RaidStatus.ONGOING; @@ -30,7 +30,7 @@ } private Raid( -@@ -143,6 +_,7 @@ +@@ -142,6 +_,7 @@ Raid.RaidStatus status, BlockPos center, Set heroesOfTheVillage @@ -38,7 +38,7 @@ ) { this.started = started; this.active = active; -@@ -156,6 +_,7 @@ +@@ -155,6 +_,7 @@ this.numGroups = numGroups; this.status = status; this.heroesOfTheVillage.addAll(heroesOfTheVillage); @@ -46,7 +46,7 @@ } public boolean isOver() { -@@ -182,6 +_,12 @@ +@@ -181,6 +_,12 @@ return this.status == Raid.RaidStatus.LOSS; } @@ -59,7 +59,7 @@ public float getTotalHealth() { return this.totalHealth; } -@@ -268,6 +_,7 @@ +@@ -267,6 +_,7 @@ boolean flag = this.active; this.active = level.hasChunkAt(this.center); if (level.getDifficulty() == Difficulty.PEACEFUL) { @@ -67,7 +67,7 @@ this.stop(); return; } -@@ -287,13 +_,16 @@ +@@ -286,13 +_,16 @@ if (!level.isVillage(this.center)) { if (this.groupsSpawned > 0) { this.status = Raid.RaidStatus.LOSS; @@ -84,7 +84,7 @@ this.stop(); return; } -@@ -382,6 +_,7 @@ +@@ -381,6 +_,7 @@ } if (i > 5) { @@ -92,7 +92,7 @@ this.stop(); break; } -@@ -393,6 +_,7 @@ +@@ -392,6 +_,7 @@ } else { this.status = Raid.RaidStatus.VICTORY; @@ -100,7 +100,7 @@ for (UUID uuid : this.heroesOfTheVillage) { Entity entity = level.getEntity(uuid); if (entity instanceof LivingEntity livingEntity && !entity.isSpectator()) { -@@ -400,9 +_,11 @@ +@@ -399,9 +_,11 @@ if (livingEntity instanceof ServerPlayer serverPlayer) { serverPlayer.awardStat(Stats.RAID_WIN); CriteriaTriggers.RAID_WIN.trigger(serverPlayer); @@ -112,7 +112,7 @@ } } -@@ -410,6 +_,7 @@ +@@ -409,6 +_,7 @@ } else if (this.isOver()) { this.celebrationTicks++; if (this.celebrationTicks >= 600) { @@ -120,7 +120,7 @@ this.stop(); return; } -@@ -514,7 +_,7 @@ +@@ -513,7 +_,7 @@ private void spawnGroup(ServerLevel level, BlockPos pos) { boolean flag = false; @@ -129,7 +129,7 @@ this.totalHealth = 0.0F; DifficultyInstance currentDifficultyAt = level.getCurrentDifficultyAt(pos); boolean shouldSpawnBonusGroup = this.shouldSpawnBonusGroup(); -@@ -563,6 +_,7 @@ +@@ -562,6 +_,7 @@ this.groupsSpawned++; this.updateBossbar(); this.setDirty(level); @@ -137,7 +137,7 @@ } public void joinRaid(ServerLevel level, int wave, Raider raider, @Nullable BlockPos pos, boolean isRecruited) { -@@ -577,7 +_,7 @@ +@@ -576,7 +_,7 @@ raider.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EntitySpawnReason.EVENT, null); raider.applyRaidBuffs(level, wave, false); raider.setOnGround(true); @@ -146,7 +146,7 @@ } } } -@@ -796,6 +_,12 @@ +@@ -795,6 +_,12 @@ public void addHeroOfTheVillage(Entity player) { this.heroesOfTheVillage.add(player.getUUID()); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch index ec707b410408..d2ff3f1e6120 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/Raids.java +++ b/net/minecraft/world/entity/raid/Raids.java -@@ -58,6 +_,7 @@ +@@ -59,6 +_,7 @@ private Raids(List raids, int nextId, int tick) { for (Raids.RaidWithId raidWithId : raids) { this.raidMap.put(raidWithId.id, raidWithId.raid); @@ -8,32 +8,32 @@ } this.nextId = nextId; -@@ -140,11 +_,23 @@ - } +@@ -139,11 +_,23 @@ + } - Raid raid = this.getOrCreateRaid(serverLevel, blockPos); -- if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { -- this.raidMap.put(this.getUniqueId(), raid); -- } + Raid raid = this.getOrCreateRaid(serverLevel, blockPos); +- if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { +- this.raidMap.put(this.getUniqueId(), raid); +- } - -- if (!raid.isStarted() || raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel()) { -+ // CraftBukkit - moved down -+ // if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { -+ // this.raidMap.put(this.getUniqueId(), raid); -+ // } +- if (!raid.isStarted() || raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel()) { ++ // CraftBukkit - moved down ++ // if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { ++ // this.raidMap.put(this.getUniqueId(), raid); ++ // } + -+ if (!raid.isStarted() || (raid.isInProgress() && raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel())) { // CraftBukkit - fixed a bug with raid: players could add up Bad Omen level even when the raid had finished -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callRaidTriggerEvent(serverLevel, raid, player)) { -+ player.removeEffect(net.minecraft.world.effect.MobEffects.RAID_OMEN); -+ return null; -+ } ++ if (!raid.isStarted() || (raid.isInProgress() && raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel())) { // CraftBukkit - fixed a bug with raid: players could add up Bad Omen level even when the raid had finished ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callRaidTriggerEvent(serverLevel, raid, player)) { ++ player.removeEffect(net.minecraft.world.effect.MobEffects.RAID_OMEN); ++ return null; ++ } + -+ if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { -+ this.raidMap.put(this.getUniqueId(), raid); -+ raid.idOrNegativeOne = this.nextId; // Paper - expose id of raids while method is kept around as deprecated for removal -+ } -+ // CraftBukkit end - raid.absorbRaidOmen(player); - } ++ if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { ++ this.raidMap.put(this.getUniqueId(), raid); ++ raid.idOrNegativeOne = this.nextId; // Paper - expose id of raids while method is kept around as deprecated for removal ++ } ++ // CraftBukkit end + raid.absorbRaidOmen(player); + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch index 16dc59fd85db..cb5267b68e44 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch @@ -1,15 +1,24 @@ --- a/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java +++ b/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java -@@ -128,7 +_,7 @@ +@@ -84,7 +_,7 @@ + + @Override + public InteractionResult interact(Player player, InteractionHand hand) { +- if (!player.canUseGameMasterBlocks()) { ++ if (!player.canUseGameMasterBlocks() && (!player.isCreative() || !player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission + return InteractionResult.PASS; + } else { + if (player.level().isClientSide()) { +@@ -122,7 +_,7 @@ MinecartCommandBlock.this.position(), MinecartCommandBlock.this.getRotationVector(), - this.getLevel(), -- 2, -+ this.getLevel().paperConfig().commandBlocks.permissionsLevel, // Paper - configurable command block perm level + level, +- LevelBasedPermissionSet.GAMEMASTER, ++ LevelBasedPermissionSet.forLevel(net.minecraft.server.permissions.PermissionLevel.byId(level.paperConfig().commandBlocks.permissionsLevel)), // Paper - configurable command block perm level this.getName().getString(), MinecartCommandBlock.this.getDisplayName(), - this.getLevel().getServer(), -@@ -140,5 +_,12 @@ + level.getServer(), +@@ -134,5 +_,17 @@ public boolean isValid() { return !MinecartCommandBlock.this.isRemoved(); } @@ -19,6 +28,11 @@ + public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { + return net.minecraft.world.entity.vehicle.MinecartCommandBlock.this.getBukkitEntity(); + } ++ ++ @Override ++ public net.minecraft.server.level.ServerLevel getLevel() { ++ return (net.minecraft.server.level.ServerLevel) MinecartCommandBlock.this.level(); ++ } + // CraftBukkit end } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch index 6e71e7a03766..ef6420a14fa6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java +++ b/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java -@@ -479,6 +_,12 @@ +@@ -480,6 +_,12 @@ @Override public double getMaxSpeed(ServerLevel level) { @@ -13,7 +13,7 @@ return level.getGameRules().getInt(GameRules.RULE_MINECART_MAX_SPEED) * (this.minecart.isInWater() ? 0.5 : 1.0) / 20.0; } -@@ -494,7 +_,8 @@ +@@ -495,7 +_,8 @@ @Override public double getSlowdownFactor() { @@ -23,7 +23,7 @@ } @Override -@@ -518,6 +_,13 @@ +@@ -519,6 +_,13 @@ && !(entity instanceof AbstractMinecart) && !this.minecart.isVehicle() && !entity.isPassenger()) { @@ -37,7 +37,7 @@ boolean flag = entity.startRiding(this.minecart); if (flag) { return true; -@@ -541,6 +_,17 @@ +@@ -542,6 +_,17 @@ || entity instanceof AbstractMinecart || this.minecart.isVehicle() || entity.isPassenger()) { @@ -55,7 +55,7 @@ entity.push(this.minecart); flag = true; } -@@ -549,6 +_,15 @@ +@@ -550,6 +_,15 @@ } else { for (Entity entity1 : this.level().getEntities(this.minecart, box)) { if (!this.minecart.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof AbstractMinecart) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch index d32f30a99646..5f34e50bb287 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -56,6 +_,14 @@ +@@ -57,6 +_,14 @@ return InteractionResult.FAIL; } else { BlockState placementState = this.getPlacementState(blockPlaceContext); @@ -15,7 +15,7 @@ if (placementState == null) { return InteractionResult.FAIL; } else if (!this.placeBlock(blockPlaceContext, placementState)) { -@@ -68,15 +_,39 @@ +@@ -69,15 +_,39 @@ BlockState blockState = level.getBlockState(clickedPos); if (blockState.is(placementState.getBlock())) { blockState = this.updateBlockStateFromTag(clickedPos, level, itemInHand, blockState); @@ -55,7 +55,7 @@ level.playSound( player, clickedPos, -@@ -87,7 +_,7 @@ +@@ -88,7 +_,7 @@ ); level.gameEvent(GameEvent.BLOCK_PLACE, clickedPos, GameEvent.Context.of(player, blockState)); itemInHand.consume(1, player); @@ -64,7 +64,7 @@ } } } -@@ -136,8 +_,19 @@ +@@ -137,8 +_,19 @@ protected boolean canPlace(BlockPlaceContext context, BlockState state) { Player player = context.getPlayer(); @@ -86,7 +86,7 @@ } protected boolean mustSurvive() { -@@ -161,7 +_,7 @@ +@@ -162,7 +_,7 @@ return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch index 037a3a22ac8f..45110e1aa9e3 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BucketItem.java +++ b/net/minecraft/world/item/BucketItem.java -@@ -30,6 +_,7 @@ +@@ -31,6 +_,7 @@ import net.minecraft.world.phys.HitResult; public class BucketItem extends Item implements DispensibleContainerItem { @@ -8,7 +8,7 @@ public final Fluid content; public BucketItem(Fluid content, Item.Properties properties) { -@@ -56,12 +_,22 @@ +@@ -57,12 +_,22 @@ } else if (this.content == Fluids.EMPTY) { BlockState blockState = level.getBlockState(blockPos); if (blockState.getBlock() instanceof BucketPickup bucketPickup) { @@ -32,7 +32,7 @@ if (!level.isClientSide()) { CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer)player, itemStack); } -@@ -74,7 +_,7 @@ +@@ -75,7 +_,7 @@ } else { BlockState blockState = level.getBlockState(blockPos); BlockPos blockPos2 = blockState.getBlock() instanceof LiquidBlockContainer && this.content == Fluids.WATER ? blockPos : blockPos1; @@ -41,7 +41,7 @@ this.checkExtraContent(player, level, itemInHand, blockPos2); if (player instanceof ServerPlayer) { CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)player, blockPos2, itemInHand); -@@ -91,6 +_,13 @@ +@@ -92,6 +_,13 @@ } public static ItemStack getEmptySuccessItem(ItemStack bucketStack, Player player) { @@ -55,7 +55,7 @@ return !player.hasInfiniteMaterials() ? new ItemStack(Items.BUCKET) : bucketStack; } -@@ -100,6 +_,12 @@ +@@ -101,6 +_,12 @@ @Override public boolean emptyContents(@Nullable LivingEntity entity, Level level, BlockPos pos, @Nullable BlockHitResult hitResult) { @@ -68,7 +68,7 @@ if (!(this.content instanceof FlowingFluid flowingFluid)) { return false; } else { -@@ -111,8 +_,18 @@ +@@ -112,8 +_,18 @@ || block instanceof LiquidBlockContainer liquidBlockContainer && liquidBlockContainer.canPlaceLiquid(entity, level, pos, blockState, this.content); boolean flag2 = blockState.isAir() || flag1 && (!flag || hitResult == null); @@ -85,6 +85,6 @@ if (!flag2) { - return hitResult != null && this.emptyContents(entity, level, hitResult.getBlockPos().relative(hitResult.getDirection()), null); + return hitResult != null && this.emptyContents(entity, level, hitResult.getBlockPos().relative(hitResult.getDirection()), null, direction, clicked, itemstack, hand); // CraftBukkit - } else if (level.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { + } else if (level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos) && this.content.is(FluidTags.WATER)) { int x = pos.getX(); int y = pos.getY(); diff --git a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch index a58ba461cc28..7b169b409e4d 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -197,12 +_,20 @@ +@@ -202,12 +_,20 @@ @Override public void encode(RegistryFriendlyByteBuf buffer, ItemStack value) { @@ -23,7 +23,7 @@ } } }; -@@ -366,10 +_,166 @@ +@@ -371,10 +_,166 @@ return InteractionResult.PASS; } else { Item item = this.getItem(); @@ -192,7 +192,7 @@ return interactionResult; } -@@ -450,31 +_,67 @@ +@@ -455,31 +_,67 @@ return this.isDamageableItem() && this.getDamageValue() >= this.getMaxDamage() - 1; } @@ -268,7 +268,7 @@ this.shrink(1); onBreak.accept(item); } -@@ -487,7 +_,26 @@ +@@ -492,7 +_,26 @@ return; } @@ -296,7 +296,7 @@ this.applyDamage(min, serverPlayer, item -> {}); } } -@@ -497,9 +_,14 @@ +@@ -502,9 +_,14 @@ } public void hurtAndBreak(int amount, LivingEntity entity, EquipmentSlot slot) { @@ -312,7 +312,7 @@ ); } } -@@ -713,6 +_,12 @@ +@@ -746,6 +_,12 @@ return this.getItem().useOnRelease(this); } @@ -325,7 +325,7 @@ @Nullable public T set(DataComponentType component, @Nullable T value) { return this.components.set(component, value); -@@ -761,6 +_,28 @@ +@@ -794,6 +_,28 @@ this.components.setAll(components); } @@ -354,7 +354,7 @@ public Component getHoverName() { Component customName = this.getCustomName(); return customName != null ? customName : this.getItemName(); -@@ -990,6 +_,19 @@ +@@ -1027,6 +_,19 @@ EnchantmentHelper.forEachModifier(this, slot, action); } @@ -374,7 +374,7 @@ public Component getDisplayName() { MutableComponent mutableComponent = Component.empty().append(this.getHoverName()); if (this.has(DataComponents.CUSTOM_NAME)) { -@@ -1045,7 +_,7 @@ +@@ -1086,7 +_,7 @@ } public void consume(int amount, @Nullable LivingEntity entity) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch index 6b1fc360fe1c..ee96528330c7 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/SpawnEggItem.java +++ b/net/minecraft/world/item/SpawnEggItem.java -@@ -67,6 +_,7 @@ +@@ -68,6 +_,7 @@ return InteractionResult.FAIL; } else { @@ -8,7 +8,7 @@ spawner.setEntityId(type, level.getRandom()); level.sendBlockUpdated(clickedPos, blockState, blockState, 3); level.gameEvent(context.getPlayer(), GameEvent.BLOCK_CHANGE, clickedPos); -@@ -94,7 +_,7 @@ +@@ -95,7 +_,7 @@ EntityType type = this.getType(stack); if (type == null) { return InteractionResult.FAIL; @@ -17,7 +17,7 @@ return InteractionResult.FAIL; } else { if (type.spawn((ServerLevel)level, stack, owner, pos, EntitySpawnReason.SPAWN_ITEM_USE, shouldOffsetY, shouldOffsetYMore) != null) { -@@ -178,7 +_,7 @@ +@@ -179,7 +_,7 @@ } else { breedOffspring.snapTo(pos.x(), pos.y(), pos.z(), 0.0F, 0.0F); breedOffspring.applyComponentsFromItemStack(stack); diff --git a/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch index f3763cb34a6c..242a90a4421e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch @@ -1,57 +1,55 @@ --- a/net/minecraft/world/level/BaseCommandBlock.java +++ b/net/minecraft/world/level/BaseCommandBlock.java -@@ -35,6 +_,9 @@ +@@ -31,6 +_,10 @@ private String command = ""; @Nullable private Component customName; + // CraftBukkit start + protected abstract org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper); ++ public abstract ServerLevel getLevel(); + // CraftBukkit end public int getSuccessCount() { return this.successCount; -@@ -112,7 +_,13 @@ +@@ -107,7 +_,13 @@ this.successCount++; } }); -- server.getCommands().performPrefixedCommand(commandSourceStack, this.command); +- level.getServer().getCommands().performPrefixedCommand(commandSourceStack, this.command); + // Paper start - ServerCommandEvent + org.bukkit.event.server.ServerCommandEvent event = new org.bukkit.event.server.ServerCommandEvent(commandSourceStack.getBukkitSender(), net.minecraft.commands.Commands.trimOptionalPrefix(this.command)); + if (!event.callEvent()) { + return true; + } -+ server.getCommands().performPrefixedCommand(commandSourceStack, event.getCommand()); ++ level.getServer().getCommands().performPrefixedCommand(commandSourceStack, event.getCommand()); + // Paper end - ServerCommandEvent } - } catch (Throwable var8) { - CrashReport crashReport = CrashReport.forThrowable(var8, "Executing command block"); -@@ -168,7 +_,7 @@ - } - - public InteractionResult usedBy(Player player) { -- if (!player.canUseGameMasterBlocks()) { -+ if (!player.canUseGameMasterBlocks() && (!player.isCreative() || !player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission - return InteractionResult.PASS; - } else { - if (player.level().isClientSide()) { -@@ -185,7 +_,7 @@ + } catch (Throwable var7) { + CrashReport crashReport = CrashReport.forThrowable(var7, "Executing command block"); +@@ -164,12 +_,12 @@ public abstract boolean isValid(); - protected class CloseableCommandBlockSource implements CommandSource, AutoCloseable { + public class CloseableCommandBlockSource implements CommandSource, AutoCloseable { // Paper - public + private final ServerLevel level; private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss", Locale.ROOT); private boolean closed; -@@ -207,6 +_,7 @@ +- protected CloseableCommandBlockSource(final ServerLevel level) { ++ public CloseableCommandBlockSource(final ServerLevel level) { // Paper - public + this.level = level; + } + +@@ -191,6 +_,7 @@ @Override public void sendSystemMessage(Component message) { if (!this.closed) { + org.spigotmc.AsyncCatcher.catchOp("sendSystemMessage to a command block"); // Paper - Don't broadcast messages to command blocks BaseCommandBlock.this.lastOutput = Component.literal("[" + TIME_FORMAT.format(ZonedDateTime.now()) + "] ").append(message); - BaseCommandBlock.this.onUpdated(); + BaseCommandBlock.this.onUpdated(this.level); } -@@ -216,5 +_,12 @@ +@@ -200,5 +_,12 @@ public void close() throws Exception { this.closed = true; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch index aa8ab8b3d750..00e90e85d929 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch @@ -27,7 +27,7 @@ + tickDelay = level.paperConfig().tickRates.mobSpawner; + if (tickDelay == -1) { return; } // If disabled + // Paper end - Configurable mob spawner tick rate - if (this.isNearPlayer(level, pos) && level.getServer().isSpawnerBlockEnabled()) { + if (this.isNearPlayer(level, pos) && level.isSpawnerBlockEnabled()) { - if (this.spawnDelay == -1) { + if (this.spawnDelay < -tickDelay) { // Paper - Configurable mob spawner tick rate this.delay(level, pos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch index 9faba997517f..da8c2f8920fa 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch @@ -18,7 +18,7 @@ public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("overworld")); @@ -126,6 +_,57 @@ - private final PalettedContainerFactory palettedContainerFactory; + private final EnvironmentAttributeSystem environmentAttributes; private long subTickCount; + // CraftBukkit start @@ -100,9 +100,9 @@ + // CraftBukkit end this.levelData = levelData; this.dimensionTypeRegistration = dimensionTypeRegistration; - DimensionType dimensionType = dimensionTypeRegistration.value(); + this.dimension = dimension; @@ -150,6 +_,46 @@ - this.damageSources = new DamageSources(registryAccess); + this.environmentAttributes = new EnvironmentAttributeSystem(dimensionTypeRegistration, registryAccess, this.biomeManager); } + // Paper start - Cancel hit for vanished players @@ -260,7 +260,7 @@ @@ -204,6 +_,22 @@ @Override - public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) { + public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags, int recursionLeft) { + // CraftBukkit start - tree generation + if (this.captureTreeGeneration) { + // Paper start - Protect Bedrock and End Portal/Frames from being destroyed @@ -416,7 +416,7 @@ } boolean flag = this.setBlock(pos, fluidState.createLegacyBlock(), 3, recursionLeft); -@@ -335,10 +_,18 @@ +@@ -337,10 +_,18 @@ @Override public BlockState getBlockState(BlockPos pos) { @@ -436,7 +436,7 @@ return chunk.getBlockState(pos); } } -@@ -451,31 +_,47 @@ +@@ -453,31 +_,47 @@ this.pendingBlockEntityTickers.clear(); } @@ -492,7 +492,7 @@ public boolean shouldTickDeath(Entity entity) { return true; -@@ -600,6 +_,12 @@ +@@ -602,6 +_,12 @@ @Nullable @Override public BlockEntity getBlockEntity(BlockPos pos) { @@ -505,7 +505,7 @@ if (this.isOutsideBuildHeight(pos)) { return null; } else { -@@ -612,6 +_,12 @@ +@@ -614,6 +_,12 @@ public void setBlockEntity(BlockEntity blockEntity) { BlockPos blockPos = blockEntity.getBlockPos(); if (!this.isOutsideBuildHeight(blockPos)) { @@ -518,7 +518,7 @@ this.getChunkAt(blockPos).addAndRegisterBlockEntity(blockEntity); } } -@@ -1038,7 +_,8 @@ +@@ -1029,7 +_,8 @@ BLOCK("block"), MOB("mob"), TNT("tnt"), diff --git a/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch b/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch index 1540db17ec5f..ff24d69ed4ea 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/LevelAccessor.java +++ b/net/minecraft/world/level/LevelAccessor.java -@@ -100,4 +_,6 @@ +@@ -103,4 +_,6 @@ default void gameEvent(ResourceKey gameEvent, BlockPos pos, GameEvent.Context context) { this.gameEvent(this.registryAccess().lookupOrThrow(Registries.GAME_EVENT).getOrThrow(gameEvent), pos, context); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/LevelReader.java.patch b/paper-server/patches/sources/net/minecraft/world/level/LevelReader.java.patch index c740a23a7f9f..dcab01a22675 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/LevelReader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/LevelReader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/LevelReader.java +++ b/net/minecraft/world/level/LevelReader.java -@@ -26,6 +_,9 @@ +@@ -27,6 +_,9 @@ @Nullable ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk); diff --git a/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch index d752f6bafce3..d126b117ae13 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/LevelWriter.java +++ b/net/minecraft/world/level/LevelWriter.java -@@ -27,4 +_,10 @@ +@@ -28,4 +_,10 @@ default boolean addFreshEntity(Entity entity) { return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/ServerLevelAccessor.java.patch b/paper-server/patches/sources/net/minecraft/world/level/ServerLevelAccessor.java.patch index 0d2900e6a1aa..0f1af218f263 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/ServerLevelAccessor.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/ServerLevelAccessor.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/ServerLevelAccessor.java +++ b/net/minecraft/world/level/ServerLevelAccessor.java -@@ -7,6 +_,17 @@ - ServerLevel getLevel(); +@@ -11,6 +_,17 @@ + DifficultyInstance getCurrentDifficultyAt(BlockPos pos); default void addFreshEntityWithPassengers(Entity entity) { - entity.getSelfAndPassengers().forEach(this::addFreshEntity); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch index 71f1ac88dd66..be634ae10560 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/level/block/BedBlock.java +++ b/net/minecraft/world/level/block/BedBlock.java -@@ -90,7 +_,7 @@ - } +@@ -93,7 +_,7 @@ } -- if (!canSetSpawn(level)) { -+ if (false && !canSetSpawn(level)) { // CraftBukkit - moved world and biome check into Player + BedRule bedRule = level.environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos); +- if (bedRule.explodes()) { ++ if (false && bedRule.explodes()) { // CraftBukkit - moved world and biome check into Player + bedRule.errorMessage().ifPresent(component -> player.displayClientMessage(component, true)); level.removeBlock(pos, false); BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); - if (level.getBlockState(blockPos).is(this)) { -@@ -101,22 +_,56 @@ +@@ -105,22 +_,56 @@ level.explode(null, level.damageSources().badRespawnPointExplosion(center), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); return InteractionResult.SUCCESS_SERVER; } else if (state.getValue(OCCUPIED)) { -+ if (!BedBlock.canSetSpawn(level)) return this.explodeBed(state, level, pos); // Paper - check explode first ++ if (!bedRule.explodes()) return this.explodeBed(state, level, pos); // Paper - check explode first if (!this.kickVillagerOutOfBed(level, pos)) { player.displayClientMessage(Component.translatable("block.minecraft.bed.occupied"), true); } @@ -27,8 +27,8 @@ player.startSleepInBed(pos).ifLeft(bedSleepingProblem -> { + // Paper start - PlayerBedFailEnterEvent + if (bedSleepingProblem != null) { -+ io.papermc.paper.event.player.PlayerBedFailEnterEvent event = new io.papermc.paper.event.player.PlayerBedFailEnterEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.event.player.PlayerBedFailEnterEvent.FailReason.values()[bedSleepingProblem.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(level, finalBlockPos), !level.dimensionType().bedWorks(), io.papermc.paper.adventure.PaperAdventure.asAdventure(bedSleepingProblem.getMessage())); -+ if (!event.callEvent()) { ++ io.papermc.paper.event.player.PlayerBedFailEnterEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBedFailEnterEvent(player, finalBlockPos, bedSleepingProblem); ++ if (event.isCancelled()) { + return; + } + // Paper end - PlayerBedFailEnterEvent @@ -37,8 +37,8 @@ + this.explodeBed(finalBlockState, level, finalBlockPos); + } else + // CraftBukkit end - if (bedSleepingProblem.getMessage() != null) { -- player.displayClientMessage(bedSleepingProblem.getMessage(), true); + if (bedSleepingProblem.message() != null) { +- player.displayClientMessage(bedSleepingProblem.message(), true); + final net.kyori.adventure.text.Component message = event.getMessage(); // Paper - PlayerBedFailEnterEvent + if (message != null) player.displayClientMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), true); // Paper - PlayerBedFailEnterEvent } @@ -61,12 +61,12 @@ + Vec3 center = pos.getCenter(); + level.explode(null, level.damageSources().badRespawnPointExplosion(center).causingBlockSnapshot(blockState), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state + return InteractionResult.SUCCESS_SERVER; -+ } ++ } + // CraftBukkit end + - public static boolean canSetSpawn(Level level) { - return level.dimensionType().bedWorks(); - } + private boolean kickVillagerOutOfBed(Level level, BlockPos pos) { + List entitiesOfClass = level.getEntitiesOfClass(Villager.class, new AABB(pos), LivingEntity::isSleeping); + if (entitiesOfClass.isEmpty()) { @@ -299,6 +_,11 @@ if (!level.isClientSide()) { BlockPos blockPos = pos.relative(state.getValue(FACING)); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch index ab894a1611e7..34e039f9036f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -103,6 +_,21 @@ +@@ -111,6 +_,21 @@ public static final int UPDATE_LIMIT = 512; protected final StateDefinition stateDefinition; private BlockState defaultBlockState; @@ -22,7 +22,7 @@ @Nullable private Item item; private static final int CACHE_SIZE = 256; -@@ -357,6 +_,27 @@ +@@ -367,6 +_,27 @@ return state.getDrops(builder); } @@ -50,7 +50,7 @@ public static void dropResources(BlockState state, Level level, BlockPos pos) { if (level instanceof ServerLevel) { getDrops(state, (ServerLevel)level, pos, null).forEach(stack -> popResource(level, pos, stack)); -@@ -372,9 +_,14 @@ +@@ -382,9 +_,14 @@ } public static void dropResources(BlockState state, Level level, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool) { @@ -66,7 +66,7 @@ } } -@@ -405,13 +_,25 @@ +@@ -415,13 +_,25 @@ if (level instanceof ServerLevel serverLevel && !stack.isEmpty() && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { ItemEntity itemEntity = itemEntitySupplier.get(); itemEntity.setDefaultPickUpDelay(); @@ -94,7 +94,7 @@ } } -@@ -430,10 +_,19 @@ +@@ -440,10 +_,19 @@ return this.defaultBlockState(); } @@ -116,7 +116,7 @@ } public void setPlacedBy(Level level, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { -@@ -572,12 +_,20 @@ +@@ -582,12 +_,20 @@ return this.builtInRegistryHolder; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch index 9bc5a61bb3d9..5c7131c155f4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch @@ -46,7 +46,7 @@ + } + // CraftBukkit end if (!level.isClientSide()) { - Vec3 vec3 = Vec3.atLowerCornerWithOffset(pos, 0.5, 1.01, 0.5).offsetRandom(level.random, 0.7F); + Vec3 vec3 = Vec3.atLowerCornerWithOffset(pos, 0.5, 1.01, 0.5).offsetRandomXZ(level.random, 0.7F); ItemEntity itemEntity = new ItemEntity(level, vec3.x(), vec3.y(), vec3.z(), new ItemStack(Items.BONE_MEAL)); @@ -305,14 +_,39 @@ return blockState; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch index 597e210ac0d1..a2a880ee4b87 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CopperGolemStatueBlock.java +++ b/net/minecraft/world/level/block/CopperGolemStatueBlock.java -@@ -113,15 +_,21 @@ +@@ -107,15 +_,21 @@ if (stack.is(ItemTags.AXES)) { return InteractionResult.PASS; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch index 78c104798d01..3a48b0d8d0c1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch @@ -67,8 +67,8 @@ } } - boolean isIncreasedFireBurnout = level.getBiome(pos).is(BiomeTags.INCREASED_FIRE_BURNOUT); - int i = isIncreasedFireBurnout ? -50 : 0; + boolean value = level.environmentAttributes().getValue(EnvironmentAttributes.INCREASED_FIRE_BURNOUT, pos); + int i = value ? -50 : 0; - this.checkBurnOut(level, pos.east(), 300 + i, random, ageValue); - this.checkBurnOut(level, pos.west(), 300 + i, random, ageValue); - this.checkBurnOut(level, pos.below(), 250 + i, random, ageValue); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/IceBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/IceBlock.java.patch index 4950d358fd5e..8f529c109ad5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/IceBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/IceBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/IceBlock.java +++ b/net/minecraft/world/level/block/IceBlock.java -@@ -32,8 +_,13 @@ +@@ -33,8 +_,13 @@ } @Override @@ -14,17 +14,20 @@ + public void afterDestroy(Level level, BlockPos pos, ItemStack stack) { + // Paper end - Improve Block#breakNaturally API if (!EnchantmentHelper.hasTag(stack, EnchantmentTags.PREVENTS_ICE_MELTING)) { - if (level.dimensionType().ultraWarm()) { + if (level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos)) { level.removeBlock(pos, false); -@@ -55,6 +_,11 @@ +@@ -56,7 +_,13 @@ } protected void melt(BlockState state, Level level, BlockPos pos) { -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(level, pos, level.dimensionType().ultraWarm() ? Blocks.AIR.defaultBlockState() : Blocks.WATER.defaultBlockState()).isCancelled()) { +- if (level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos)) { ++ // Paper start - call BlockFadeEvent ++ final boolean waterEvaporates = level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos); ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(level, pos, waterEvaporates ? Blocks.AIR.defaultBlockState() : Blocks.WATER.defaultBlockState()).isCancelled()) { + return; + } -+ // CraftBukkit end - if (level.dimensionType().ultraWarm()) { ++ if (waterEvaporates) { ++ // Paper end - call BlockFadeEvent level.removeBlock(pos, false); } else { + level.setBlockAndUpdate(pos, meltsInto()); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch index c1ff8391ccb7..b7a9709aa995 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/NetherPortalBlock.java +++ b/net/minecraft/world/level/block/NetherPortalBlock.java -@@ -65,7 +_,7 @@ +@@ -66,7 +_,7 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { -- if (level.dimensionType().natural() -+ if (level.spigotConfig.enableZombiePigmenPortalSpawns && level.dimensionType().natural() // Spigot - && level.isSpawningMonsters() +- if (level.isSpawningMonsters() ++ if (level.spigotConfig.enableZombiePigmenPortalSpawns && level.isSpawningMonsters() // Spigot + && level.environmentAttributes().getValue(EnvironmentAttributes.NETHER_PORTAL_SPAWNS_PIGLINS, pos) && random.nextInt(2000) < level.getDifficulty().getId() && level.anyPlayerCloseEnoughForSpawning(pos)) { -@@ -74,9 +_,13 @@ +@@ -75,9 +_,13 @@ } if (level.getBlockState(pos).isValidSpawn(level, pos, EntityType.ZOMBIFIED_PIGLIN)) { @@ -24,7 +24,7 @@ Entity vehicle = entity.getVehicle(); if (vehicle != null) { vehicle.setPortalCooldown(); -@@ -107,7 +_,13 @@ +@@ -108,7 +_,13 @@ @Override protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean pastEdges) { @@ -38,7 +38,7 @@ entity.setAsInsidePortal(this, pos); } } -@@ -130,22 +_,46 @@ +@@ -131,22 +_,46 @@ @Nullable @Override public TeleportTransition getPortalDestination(ServerLevel level, Entity entity, BlockPos pos) { @@ -90,7 +90,7 @@ BlockUtil.FoundRectangle largestRectangleAround; TeleportTransition.PostTeleportTransition postTeleportTransition; if (optional.isPresent()) { -@@ -160,17 +_,22 @@ +@@ -161,17 +_,22 @@ blockPos1 -> level.getBlockState(blockPos1) == blockState ); postTeleportTransition = TeleportTransition.PLAY_PORTAL_SOUND.then(entity1 -> entity1.placePortalTicket(blockPos)); @@ -116,7 +116,7 @@ return getDimensionTransitionFromExit(entity, pos, largestRectangleAround, level, postTeleportTransition); } -@@ -216,7 +_,7 @@ +@@ -217,7 +_,7 @@ boolean flag = axis1 == Direction.Axis.X; Vec3 vec3 = new Vec3(blockPos.getX() + (flag ? d2 : d4), blockPos.getY() + d3, blockPos.getZ() + (flag ? d4 : d2)); Vec3 vec31 = PortalShape.findCollisionFreePosition(vec3, level, entity, dimensions); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch index bb7905752c34..b3505974a391 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PointedDripstoneBlock.java +++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java -@@ -143,6 +_,11 @@ +@@ -144,6 +_,11 @@ && projectile.mayBreak(serverLevel) && projectile instanceof ThrownTrident && projectile.getDeltaMovement().length() > 0.6) { @@ -12,7 +12,7 @@ level.destroyBlock(blockPos, true); } } -@@ -151,7 +_,7 @@ +@@ -152,7 +_,7 @@ @Override public void fallOn(Level level, BlockState state, BlockPos pos, Entity entity, double fallDistance) { if (state.getValue(TIP_DIRECTION) == Direction.UP && state.getValue(THICKNESS) == DripstoneThickness.TIP) { @@ -21,7 +21,7 @@ } else { super.fallOn(level, state, pos, entity, fallDistance); } -@@ -209,10 +_,11 @@ +@@ -210,10 +_,11 @@ if (blockPos != null) { if (fluidAboveStalactite.get().sourceState.is(Blocks.MUD) && fluid == Fluids.WATER) { BlockState blockState = Blocks.CLAY.defaultBlockState(); @@ -34,7 +34,7 @@ } else { BlockPos blockPos1 = findFillableCauldronBelowStalactiteTip(level, blockPos, fluid); if (blockPos1 != null) { -@@ -364,17 +_,17 @@ +@@ -360,17 +_,17 @@ if (isUnmergedTipWithDirection(blockState, direction.getOpposite())) { createMergedTips(blockState, server, blockPos); } else if (blockState.isAir() || blockState.is(Blocks.WATER)) { @@ -55,7 +55,7 @@ } private static void createMergedTips(BlockState state, LevelAccessor level, BlockPos pos) { -@@ -388,8 +_,8 @@ +@@ -384,8 +_,8 @@ blockPos = pos.below(); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch index cc868f6373da..392898ca5c6f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch @@ -1,32 +1,32 @@ --- a/net/minecraft/world/level/block/RespawnAnchorBlock.java +++ b/net/minecraft/world/level/block/RespawnAnchorBlock.java -@@ -104,11 +_,16 @@ - ServerPlayer.RespawnConfig respawnConfig = serverPlayer.getRespawnConfig(); - ServerPlayer.RespawnConfig respawnConfig1 = new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(level.dimension(), pos, 0.0F, 0.0F), false); - if (respawnConfig == null || !respawnConfig.isSamePosition(respawnConfig1)) { -- serverPlayer.setRespawnPosition(respawnConfig1, true); -+ if (serverPlayer.setRespawnPosition(respawnConfig1, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR)) { // Paper - Add PlayerSetSpawnEvent - level.playSound( - null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F +@@ -106,11 +_,16 @@ + LevelData.RespawnData.of(serverLevel.dimension(), pos, 0.0F, 0.0F), false ); - return InteractionResult.SUCCESS_SERVER; -+ // Paper start - Add PlayerSetSpawnEvent -+ } else { -+ return InteractionResult.FAIL; -+ } -+ // Paper end - Add PlayerSetSpawnEvent + if (respawnConfig == null || !respawnConfig.isSamePosition(respawnConfig1)) { +- serverPlayer.setRespawnPosition(respawnConfig1, true); ++ if (serverPlayer.setRespawnPosition(respawnConfig1, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR)) { // Paper - Add PlayerSetSpawnEvent + serverLevel.playSound( + null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F + ); + return InteractionResult.SUCCESS_SERVER; ++ // Paper start - Add PlayerSetSpawnEvent ++ } else { ++ return InteractionResult.FAIL; ++ } ++ // Paper end - Add PlayerSetSpawnEvent + } } - } -@@ -142,6 +_,7 @@ +@@ -147,6 +_,7 @@ } - private void explode(BlockState state, Level level, final BlockPos pos2) { + private void explode(BlockState state, ServerLevel level, final BlockPos pos2) { + org.bukkit.block.BlockState blockState = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos2).getState(); // CraftBukkit - capture BlockState before remove block level.removeBlock(pos2, false); boolean flag = Direction.Plane.HORIZONTAL.stream().map(pos2::relative).anyMatch(blockPos -> isWaterThatWouldFlow(blockPos, level)); final boolean flag1 = flag || level.getFluidState(pos2.above()).is(FluidTags.WATER); -@@ -155,7 +_,7 @@ +@@ -160,7 +_,7 @@ }; Vec3 center = pos2.getCenter(); level.explode( diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch index f75ba6f20ac6..975f24284f56 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch @@ -50,7 +50,7 @@ } } } -@@ -138,8 +_,8 @@ +@@ -142,8 +_,8 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch index a6e5091f7471..aaa4eb961a99 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/CommandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CommandBlockEntity.java -@@ -26,6 +_,13 @@ +@@ -27,6 +_,18 @@ private boolean auto = false; private boolean conditionMet = false; private final BaseCommandBlock commandBlock = new BaseCommandBlock() { @@ -9,17 +9,22 @@ + public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { + return new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, CommandBlockEntity.this); + } ++ ++ @Override ++ public net.minecraft.server.level.ServerLevel getLevel() { ++ return (net.minecraft.server.level.ServerLevel) CommandBlockEntity.this.getLevel(); ++ } + // CraftBukkit end + @Override public void setCommand(String command) { super.setCommand(command); -@@ -56,7 +_,7 @@ +@@ -47,7 +_,7 @@ Vec3.atCenterOf(CommandBlockEntity.this.worldPosition), new Vec2(0.0F, direction.toYRot()), - this.getLevel(), -- 2, -+ this.getLevel().paperConfig().commandBlocks.permissionsLevel, // Paper - configurable command block perm level + level, +- LevelBasedPermissionSet.GAMEMASTER, ++ LevelBasedPermissionSet.forLevel(net.minecraft.server.permissions.PermissionLevel.byId(level.paperConfig().commandBlocks.permissionsLevel)), // Paper - configurable command block perm level this.getName().getString(), this.getName(), - this.getLevel().getServer(), + level.getServer(), diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch index a40508627f18..2370e2afb8ce 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch @@ -45,7 +45,7 @@ public static final String SONG_ITEM_TAG_ID = "RecordItem"; public static final String TICKS_SINCE_SONG_STARTED_TAG_ID = "ticks_since_song_started"; private ItemStack item = ItemStack.EMPTY; -@@ -130,7 +_,7 @@ +@@ -131,7 +_,7 @@ @Override public int getMaxStackSize() { @@ -54,7 +54,7 @@ } @Override -@@ -154,11 +_,16 @@ +@@ -155,11 +_,16 @@ } @VisibleForTesting diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch index aaa6977fcd07..8a59797f674b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/LecternBlockEntity.java +++ b/net/minecraft/world/level/block/entity/LecternBlockEntity.java -@@ -33,7 +_,53 @@ +@@ -34,7 +_,53 @@ public static final int NUM_DATA = 1; public static final int SLOT_BOOK = 0; public static final int NUM_SLOTS = 1; @@ -55,7 +55,7 @@ @Override public int getContainerSize() { return 1; -@@ -77,11 +_,19 @@ +@@ -78,11 +_,19 @@ @Override public void setItem(int slot, ItemStack stack) { @@ -76,7 +76,7 @@ } @Override -@@ -159,7 +_,7 @@ +@@ -160,7 +_,7 @@ if (i != this.page) { this.page = i; this.setChanged(); @@ -85,7 +85,7 @@ } } -@@ -180,6 +_,36 @@ +@@ -181,6 +_,36 @@ return stack; } @@ -122,16 +122,18 @@ private CommandSourceStack createCommandSourceStack(@Nullable Player player, ServerLevel level) { String string; Component component; -@@ -192,7 +_,7 @@ - } +@@ -194,8 +_,8 @@ Vec3 vec3 = Vec3.atCenterOf(this.worldPosition); -- return new CommandSourceStack(CommandSource.NULL, vec3, Vec2.ZERO, level, 2, string, component, level.getServer(), player); -+ return new CommandSourceStack(this.commandSource, vec3, Vec2.ZERO, level, 2, string, component, level.getServer(), player); // CraftBukkit - commandSource + return new CommandSourceStack( +- CommandSource.NULL, vec3, Vec2.ZERO, level, LevelBasedPermissionSet.GAMEMASTER, string, component, level.getServer(), player +- ); ++ this.commandSource, vec3, Vec2.ZERO, level, LevelBasedPermissionSet.GAMEMASTER, string, component, level.getServer(), player ++ ); // CraftBukkit - commandSource } @Override -@@ -232,7 +_,7 @@ +@@ -235,7 +_,7 @@ @Override public AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch index 1174894713e9..6dfea40f5c40 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SignBlockEntity.java -@@ -57,10 +_,15 @@ +@@ -58,10 +_,15 @@ } public boolean isFacingFrontText(Player player) { @@ -18,7 +18,7 @@ float yRotationDegrees = signBlock.getYRotationDegrees(this.getBlockState()); float f = (float)(Mth.atan2(d1, d) * 180.0F / (float)Math.PI) - 90.0F; return Mth.degreesDifferenceAbs(yRotationDegrees, f) <= 90.0F; -@@ -128,11 +_,13 @@ +@@ -129,11 +_,13 @@ public void updateSignText(Player player, boolean isFrontText, List filteredText) { if (!this.isWaxed() && player.getUUID().equals(this.getPlayerWhoMayEdit()) && this.level != null) { @@ -33,7 +33,7 @@ } } -@@ -141,19 +_,41 @@ +@@ -142,19 +_,41 @@ return this.setText(updater.apply(text), isFrontText); } @@ -78,7 +78,7 @@ return text; } -@@ -192,7 +_,23 @@ +@@ -193,7 +_,23 @@ Style style = component.getStyle(); switch (style.getClickEvent()) { case ClickEvent.RunCommand runCommand: @@ -103,7 +103,7 @@ flag = true; break; case ClickEvent.ShowDialog showDialog: -@@ -211,10 +_,55 @@ +@@ -212,12 +_,56 @@ return flag; } @@ -139,7 +139,9 @@ + // CraftBukkit end String string = player == null ? "Sign" : player.getPlainTextName(); Component component = (Component)(player == null ? Component.literal("Sign") : player.getDisplayName()); -- return new CommandSourceStack(CommandSource.NULL, Vec3.atCenterOf(pos), Vec2.ZERO, level, 2, string, component, level.getServer(), player); +- return new CommandSourceStack( +- CommandSource.NULL, Vec3.atCenterOf(pos), Vec2.ZERO, level, LevelBasedPermissionSet.GAMEMASTER, string, component, level.getServer(), player +- ); + + // Paper start - Fix commands from signs not firing command events + CommandSource commandSource = level.paperConfig().misc.showSignClickCommandFailureMsgsToPlayer ? new io.papermc.paper.commands.DelegatingCommandSource(this.commandSource) { @@ -157,11 +159,12 @@ + } : this.commandSource; + // Paper end - Fix commands from signs not firing command events + // CraftBukkit - this -+ return new CommandSourceStack(commandSource, Vec3.atCenterOf(pos), Vec2.ZERO, level, 2, string, component, level.getServer(), player); // Paper - Fix commands from signs not firing command events ++ return new CommandSourceStack(commandSource, Vec3.atCenterOf(pos), Vec2.ZERO, level, LevelBasedPermissionSet.GAMEMASTER, string, component, level.getServer(), player ++ ); // Paper - Fix commands from signs not firing command events } @Override -@@ -233,12 +_,17 @@ +@@ -236,12 +_,17 @@ @Nullable public UUID getPlayerWhoMayEdit() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch index 44b507e43b7b..e857245761ff 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/EmptyLevelChunk.java +++ b/net/minecraft/world/level/chunk/EmptyLevelChunk.java -@@ -26,6 +_,13 @@ +@@ -27,6 +_,13 @@ return Blocks.VOID_AIR.defaultBlockState(); } @@ -13,4 +13,4 @@ + @Nullable @Override - public BlockState setBlockState(BlockPos pos, BlockState state, int flags) { + public BlockState setBlockState(BlockPos pos, BlockState state, @Block.UpdateFlags int flags) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch index 911686196d51..45c18d59cd3d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch @@ -11,8 +11,8 @@ - this.nextTick--; - if (this.nextTick <= 0) { - this.nextTick = this.nextTick + 12000 + randomSource.nextInt(1200); -- long l = level.getDayTime() / 24000L; -- if (l >= 5L && level.isBrightOutside()) { +- long dayCount = level.getDayCount(); +- if (dayCount >= 5L && level.isBrightOutside()) { - if (randomSource.nextInt(5) == 0) { - int size = level.players().size(); + // this.nextTick--; @@ -36,11 +36,11 @@ + patrolSpawnDelay = this.nextTick; + } + if (patrolSpawnDelay <= 0) { -+ long days; ++ long dayCount; + if (level.paperConfig().entities.behavior.pillagerPatrols.start.perPlayer) { -+ days = player.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.PLAY_TIME)) / 24000L; // PLAY_TIME is counting in ticks ++ dayCount = player.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.PLAY_TIME)) / 24000L; // PLAY_TIME is counting in ticks + } else { -+ days = level.getDayTime() / 24000L; ++ dayCount = level.getDayCount(); + } + if (level.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.perPlayer) { + player.patrolSpawnDelay += level.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.ticks + randomSource.nextInt(1200); @@ -48,7 +48,7 @@ + this.nextTick += level.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.ticks + randomSource.nextInt(1200); + } + -+ if (days >= level.paperConfig().entities.behavior.pillagerPatrols.start.day && level.isBrightOutside()) { ++ if (dayCount >= level.paperConfig().entities.behavior.pillagerPatrols.start.day && level.isBrightOutside()) { + if (randomSource.nextDouble() < level.paperConfig().entities.behavior.pillagerPatrols.spawnChance) { + // Paper end - Pillager patrol spawn settings and per player options if (size >= 1) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch index d15a6a7750eb..719e8cbc54a4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -11,7 +11,7 @@ public Vec3i getSize() { return this.size; -@@ -256,6 +_,19 @@ +@@ -258,6 +_,19 @@ if (this.palettes.isEmpty()) { return false; } else { @@ -31,7 +31,7 @@ List list = settings.getRandomPalette(this.palettes, offset).blocks(); if ((!list.isEmpty() || !settings.isIgnoreEntities() && !this.entityInfoList.isEmpty()) && this.size.getX() >= 1 -@@ -283,6 +_,21 @@ +@@ -285,6 +_,21 @@ level.setBlock(blockPos, Blocks.BARRIER.defaultBlockState(), 820); } @@ -53,7 +53,7 @@ if (level.setBlock(blockPos, blockState, flags)) { i = Math.min(i, blockPos.getX()); i1 = Math.min(i1, blockPos.getY()); -@@ -294,7 +_,7 @@ +@@ -296,7 +_,7 @@ if (structureBlockInfo.nbt != null) { BlockEntity blockEntity = level.getBlockEntity(blockPos); if (blockEntity != null) { @@ -62,7 +62,7 @@ structureBlockInfo.nbt.putLong("LootTableSeed", random.nextLong()); } -@@ -381,7 +_,11 @@ +@@ -383,7 +_,11 @@ if (pair1.getSecond() != null) { BlockEntity blockEntity = level.getBlockEntity(blockPos4); if (blockEntity != null) { @@ -75,7 +75,7 @@ } } } -@@ -389,7 +_,7 @@ +@@ -391,7 +_,7 @@ if (!settings.isIgnoreEntities()) { this.placeEntities( @@ -84,7 +84,7 @@ offset, settings.getMirror(), settings.getRotation(), -@@ -502,14 +_,17 @@ +@@ -504,14 +_,17 @@ }); } } @@ -107,7 +107,7 @@ } public Vec3i getSize(Rotation rotation) { -@@ -702,6 +_,11 @@ +@@ -704,6 +_,11 @@ tag.put("entities", listTag3); tag.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ())); @@ -119,7 +119,7 @@ return NbtUtils.addCurrentDataVersion(tag); } -@@ -732,6 +_,11 @@ +@@ -734,6 +_,11 @@ .ifPresent(compoundTag1 -> this.entityInfoList.add(new StructureTemplate.StructureEntityInfo(vec3, blockPos, compoundTag1))); } ); @@ -131,7 +131,7 @@ } private void loadPalette(HolderGetter blockGetter, ListTag paletteTag, ListTag blocksTag) { -@@ -831,7 +_,7 @@ +@@ -833,7 +_,7 @@ public static final class Palette { private final List blocks; diff --git a/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch b/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch index 44b6cdfccac3..ed6198164489 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java -@@ -92,6 +_,13 @@ +@@ -93,6 +_,13 @@ BlockState blockState = level.getBlockState(blockPos); if (blockState.isAir()) { if (this.hasFlammableNeighbours(level, blockPos)) { @@ -14,7 +14,7 @@ level.setBlockAndUpdate(blockPos, BaseFireBlock.getState(level, blockPos)); return; } -@@ -107,6 +_,14 @@ +@@ -108,6 +_,14 @@ } if (level.isEmptyBlock(blockPos1.above()) && this.isFlammable(level, blockPos1)) { @@ -29,7 +29,7 @@ level.setBlockAndUpdate(blockPos1.above(), BaseFireBlock.getState(level, blockPos1)); } } -@@ -117,9 +_,10 @@ +@@ -118,9 +_,10 @@ @Override protected void entityInside(Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { @@ -41,7 +41,7 @@ } private boolean hasFlammableNeighbours(LevelReader level, BlockPos pos) { -@@ -207,7 +_,11 @@ +@@ -208,7 +_,11 @@ FluidState fluidState1 = level.getFluidState(pos); if (this.is(FluidTags.LAVA) && fluidState1.is(FluidTags.WATER)) { if (state.getBlock() instanceof LiquidBlock) { @@ -54,7 +54,7 @@ } this.fizz(level, pos); -@@ -225,7 +_,7 @@ +@@ -226,7 +_,7 @@ @Override protected float getExplosionResistance() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch index 7fb3ede9cd79..b0c2fbfb7f92 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/DimensionDataStorage.java +++ b/net/minecraft/world/level/storage/DimensionDataStorage.java -@@ -150,7 +_,7 @@ +@@ -147,7 +_,7 @@ } else { int i = Util.maxAllowedExecutorThreads(); int size = map.size(); @@ -9,7 +9,7 @@ this.pendingWriteFuture = this.pendingWriteFuture.thenCompose(object -> { List> list = new ArrayList<>(i); int i1 = Mth.positiveCeilDiv(size, i); -@@ -171,7 +_,7 @@ +@@ -168,7 +_,7 @@ object -> CompletableFuture.allOf( map.entrySet() .stream() diff --git a/paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch b/paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch new file mode 100644 index 000000000000..dc31c0bf3027 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/scores/Scoreboard.java ++++ b/net/minecraft/world/scores/Scoreboard.java +@@ -381,7 +_,7 @@ + } + + protected List packPlayerTeams() { +- return this.getPlayerTeams().stream().map(PlayerTeam::pack).toList(); ++ return this.getPlayerTeams().stream().filter(p -> io.papermc.paper.configuration.GlobalConfiguration.get().scoreboards.saveEmptyScoreboardTeams || !p.getPlayers().isEmpty()).map(PlayerTeam::pack).toList(); // Paper - Don't save empty scoreboard teams to scoreboard.dat + } + + protected void loadPlayerTeam(PlayerTeam.Packed packed) { diff --git a/paper-server/patches/sources/net/minecraft/world/scores/ScoreboardSaveData.java.patch b/paper-server/patches/sources/net/minecraft/world/scores/ScoreboardSaveData.java.patch deleted file mode 100644 index 35907f4c14ed..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/scores/ScoreboardSaveData.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/scores/ScoreboardSaveData.java -+++ b/net/minecraft/world/scores/ScoreboardSaveData.java -@@ -39,7 +_,7 @@ - this.scoreboard.getObjectives().stream().map(Objective::pack).toList(), - this.scoreboard.packPlayerScores(), - map, -- this.scoreboard.getPlayerTeams().stream().map(PlayerTeam::pack).toList() -+ this.scoreboard.getPlayerTeams().stream().filter(p -> io.papermc.paper.configuration.GlobalConfiguration.get().scoreboards.saveEmptyScoreboardTeams || !p.getPlayers().isEmpty()).map(PlayerTeam::pack).toList() // Paper - Don't save empty scoreboard teams to scoreboard.dat - ); - } - diff --git a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java index 771c6b266b91..f4b9ee6acd3d 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java @@ -135,6 +135,9 @@ public class MobGoalHelper { map.put(net.minecraft.world.entity.animal.AbstractCow.class, AbstractCow.class); map.put(net.minecraft.world.entity.animal.HappyGhast.class, HappyGhast.class); map.put(net.minecraft.world.entity.animal.coppergolem.CopperGolem.class, CopperGolem.class); + map.put(net.minecraft.world.entity.animal.nautilus.AbstractNautilus.class, AbstractNautilus.class); + map.put(net.minecraft.world.entity.animal.nautilus.Nautilus.class, Nautilus.class); + map.put(net.minecraft.world.entity.animal.nautilus.ZombieNautilus.class, ZombieNautilus.class); // End generate - MobGoalHelper#BUKKIT_BRIDGE // }); diff --git a/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java b/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java index 677b72f56db1..c87a7f8caf5f 100644 --- a/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java +++ b/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java @@ -12,7 +12,7 @@ import io.papermc.paper.world.damagesource.PaperCombatTrackerWrapper; import net.kyori.adventure.text.Component; import net.minecraft.Optionull; -import net.minecraft.commands.PermissionSource; +import net.minecraft.commands.Commands; import net.minecraft.world.damagesource.FallLocation; import net.minecraft.world.entity.decoration.Mannequin; import org.bukkit.block.Biome; @@ -84,7 +84,7 @@ private CombatEntry createCombatEntry( @Override public Predicate restricted(final Predicate predicate) { - record RestrictedPredicate(Predicate predicate) implements Predicate, PermissionSource.RestrictedMarker { + record RestrictedPredicate(Predicate predicate) implements Predicate, Commands.RestrictedMarker { @Override public boolean test(final CommandSourceStack commandSourceStack) { return this.predicate.test(commandSourceStack); diff --git a/paper-server/src/main/java/io/papermc/paper/command/brigadier/PaperBrigadier.java b/paper-server/src/main/java/io/papermc/paper/command/brigadier/PaperBrigadier.java index 2d1de331ae0e..c40dc26e7da4 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/brigadier/PaperBrigadier.java +++ b/paper-server/src/main/java/io/papermc/paper/command/brigadier/PaperBrigadier.java @@ -9,6 +9,7 @@ import net.minecraft.commands.CommandSource; import net.minecraft.commands.Commands; import net.minecraft.network.chat.CommonComponents; +import net.minecraft.server.permissions.LevelBasedPermissionSet; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; import org.bukkit.command.Command; @@ -22,7 +23,7 @@ public final class PaperBrigadier { Vec3.ZERO, Vec2.ZERO, null, - 4, + LevelBasedPermissionSet.OWNER, "", CommonComponents.EMPTY, null, diff --git a/paper-server/src/main/java/io/papermc/paper/commands/FeedbackForwardingSender.java b/paper-server/src/main/java/io/papermc/paper/commands/FeedbackForwardingSender.java index 7aa78cc98de8..b84c2c663e9b 100644 --- a/paper-server/src/main/java/io/papermc/paper/commands/FeedbackForwardingSender.java +++ b/paper-server/src/main/java/io/papermc/paper/commands/FeedbackForwardingSender.java @@ -1,7 +1,6 @@ package io.papermc.paper.commands; import io.papermc.paper.adventure.PaperAdventure; -import java.util.UUID; import java.util.function.Consumer; import net.kyori.adventure.audience.MessageType; import net.kyori.adventure.identity.Identity; @@ -10,6 +9,7 @@ import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.permissions.LevelBasedPermissionSet; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; import org.bukkit.command.CommandSender; @@ -74,7 +74,7 @@ public CommandSourceStack asVanilla() { respawnDimension == null ? Vec3.ZERO : Vec3.atLowerCornerOf(respawnDimension.getRespawnData().pos()), Vec2.ZERO, respawnDimension, - 4, + LevelBasedPermissionSet.OWNER, this.getName(), net.minecraft.network.chat.Component.literal(this.getName()), this.server.getServer(), diff --git a/paper-server/src/main/java/io/papermc/paper/util/PaperScoreboardFormat.java b/paper-server/src/main/java/io/papermc/paper/util/PaperScoreboardFormat.java index 6064086cc76e..9b1ae8f191a6 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/PaperScoreboardFormat.java +++ b/paper-server/src/main/java/io/papermc/paper/util/PaperScoreboardFormat.java @@ -26,9 +26,9 @@ public static net.minecraft.network.chat.numbers.NumberFormat asVanilla(final Nu public static NumberFormat asPaper(final net.minecraft.network.chat.numbers.NumberFormat vanilla) { if (vanilla instanceof final net.minecraft.network.chat.numbers.StyledFormat styled) { - return NumberFormat.styled(PaperAdventure.asAdventure(styled.style)); + return NumberFormat.styled(PaperAdventure.asAdventure(styled.style())); } else if (vanilla instanceof final net.minecraft.network.chat.numbers.FixedFormat fixed) { - return NumberFormat.fixed(io.papermc.paper.adventure.PaperAdventure.asAdventure(fixed.value)); + return NumberFormat.fixed(io.papermc.paper.adventure.PaperAdventure.asAdventure(fixed.value())); } else if (vanilla instanceof net.minecraft.network.chat.numbers.BlankFormat) { return NumberFormat.blank(); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java index a760b60f6e46..be00c9afa998 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java @@ -7,6 +7,7 @@ import java.util.Random; import java.util.function.Consumer; import java.util.function.Predicate; +import net.minecraft.SharedConstants; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; @@ -465,7 +466,7 @@ public net.minecraft.world.entity.Entity createEntity(Location location, Class(EntityType.HAPPY_GHAST, HappyGhast.class, CraftHappyGhast::new, createLiving(net.minecraft.world.entity.EntityType.HAPPY_GHAST))); register(new EntityTypeData<>(EntityType.COPPER_GOLEM, CopperGolem.class, CraftCopperGolem::new, createLiving(net.minecraft.world.entity.EntityType.COPPER_GOLEM))); register(new EntityTypeData<>(EntityType.MANNEQUIN, Mannequin.class, CraftMannequin::new, createLiving(net.minecraft.world.entity.EntityType.MANNEQUIN))); + register(new EntityTypeData<>(EntityType.NAUTILUS, Nautilus.class, CraftNautilus::new, createLiving(net.minecraft.world.entity.EntityType.NAUTILUS))); + register(new EntityTypeData<>(EntityType.ZOMBIE_NAUTILUS, ZombieNautilus.class, CraftZombieNautilus::new, createLiving(net.minecraft.world.entity.EntityType.ZOMBIE_NAUTILUS))); Function dragonFunction = createLiving(net.minecraft.world.entity.EntityType.ENDER_DRAGON); register(new EntityTypeData<>(EntityType.ENDER_DRAGON, EnderDragon.class, CraftEnderDragon::new, spawnData -> { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java index 4279824f8a0e..bbfb29ebb674 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.entity; import java.util.Set; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.vehicle.MinecartCommandBlock; import org.bukkit.Bukkit; import org.bukkit.Server; @@ -68,7 +69,7 @@ public net.minecraft.world.level.BaseCommandBlock getCommandBlockHandle() { @Override public void lastOutput(net.kyori.adventure.text.Component lastOutput) { io.papermc.paper.commands.PaperCommandBlockHolder.super.lastOutput(lastOutput); - this.getCommandBlockHandle().onUpdated(); + this.getCommandBlockHandle().onUpdated((ServerLevel) this.getHandle().level()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftNautilus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftNautilus.java new file mode 100644 index 000000000000..53ae1f30ce68 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftNautilus.java @@ -0,0 +1,15 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.world.entity.animal.nautilus.Nautilus; +import org.bukkit.craftbukkit.CraftServer; + +public class CraftNautilus extends CraftAbstractNautilus implements org.bukkit.entity.Nautilus { + public CraftNautilus(final CraftServer server, final Nautilus entity) { + super(server, entity); + } + + @Override + public Nautilus getHandle() { + return (Nautilus) this.entity; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java index fa9d7a532e9a..c5fcdde22826 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java @@ -17,12 +17,12 @@ public ZombifiedPiglin getHandle() { @Override public int getAnger() { - return this.getHandle().getRemainingPersistentAngerTime(); + return (int) (this.getHandle().getPersistentAngerEndTime() - this.getHandle().level().getGameTime()); } @Override public void setAnger(int level) { - this.getHandle().setRemainingPersistentAngerTime(level); + this.getHandle().setTimeToRemainAngry(level); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 975bc2bf7c19..ed52973a4880 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -105,6 +105,8 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.ServerGamePacketListenerImpl; +import net.minecraft.server.permissions.LevelBasedPermissionSet; +import net.minecraft.server.permissions.PermissionLevel; import net.minecraft.server.players.UserWhiteListEntry; import net.minecraft.sounds.SoundEvent; import net.minecraft.util.ProblemReporter; @@ -684,9 +686,9 @@ public T getClientOption(com.destroystokyo.paper.ClientOption type) { @Override public void sendOpLevel(byte level) { - Preconditions.checkArgument(level >= Commands.LEVEL_ALL && level <= Commands.LEVEL_OWNERS, "Level must be within [%s, %s]", Commands.LEVEL_ALL, Commands.LEVEL_OWNERS); + Preconditions.checkArgument(level >= PermissionLevel.ALL.id() && level <= PermissionLevel.OWNERS.id(), "Level must be within [%s, %s]", PermissionLevel.ALL.id(), PermissionLevel.OWNERS.id()); - this.server.getServer().getPlayerList().sendPlayerPermissionLevel(this.getHandle(), level, false); + this.server.getServer().getPlayerList().sendPlayerPermissionLevel(this.getHandle(), LevelBasedPermissionSet.forLevel(PermissionLevel.byId(level)), false); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index df332b6938b8..e823f362af9b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -8,6 +8,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.monster.Zombie; import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.entity.npc.VillagerType; @@ -103,7 +104,7 @@ public boolean increaseLevel(int amount) { } while (amount > 0) { - this.getHandle().increaseMerchantCareer(); + this.getHandle().increaseMerchantCareer((ServerLevel) this.getHandle().level()); amount--; } return true; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java new file mode 100644 index 000000000000..489508fbab7d --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java @@ -0,0 +1,15 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.world.entity.animal.nautilus.ZombieNautilus; +import org.bukkit.craftbukkit.CraftServer; + +public class CraftZombieNautilus extends CraftAbstractNautilus implements org.bukkit.entity.ZombieNautilus { + public CraftZombieNautilus(final CraftServer server, final ZombieNautilus entity) { + super(server, entity); + } + + @Override + public ZombieNautilus getHandle() { + return (ZombieNautilus) this.entity; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index bd2a19ae8ee8..277d3b755c14 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -19,6 +19,7 @@ import io.papermc.paper.connection.PlayerConnection; import io.papermc.paper.event.connection.PlayerConnectionValidateLoginEvent; import io.papermc.paper.event.entity.ItemTransportingEntityValidateTargetEvent; +import io.papermc.paper.event.player.PlayerBedFailEnterEvent; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.network.Connection; @@ -33,6 +34,8 @@ import net.minecraft.util.Unit; import net.minecraft.world.Container; import net.minecraft.world.InteractionHand; +import net.minecraft.world.attribute.EnvironmentAttribute; +import net.minecraft.world.attribute.EnvironmentAttributes; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.effect.MobEffectInstance; @@ -285,16 +288,43 @@ public static boolean callPlayerSignOpenEvent(Player player, Sign sign, Side sid return !event.isCancelled(); } + public static PlayerBedFailEnterEvent.FailReason asFailReason(final net.minecraft.world.entity.player.Player.BedSleepingProblem sleepingProblem) { + if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.OTHER_PROBLEM) { + return PlayerBedFailEnterEvent.FailReason.OTHER_PROBLEM; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.NOT_SAFE) { + return PlayerBedFailEnterEvent.FailReason.NOT_SAFE; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.OBSTRUCTED) { + return PlayerBedFailEnterEvent.FailReason.OBSTRUCTED; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.TOO_FAR_AWAY) { + return PlayerBedFailEnterEvent.FailReason.TOO_FAR_AWAY; + } + throw new IllegalArgumentException(sleepingProblem.toString()); + } + + public static PlayerBedFailEnterEvent callPlayerBedFailEnterEvent( + net.minecraft.world.entity.player.Player player, BlockPos bed, net.minecraft.world.entity.player.Player.BedSleepingProblem bedSleepingProblem) { + final var event = new PlayerBedFailEnterEvent( + (org.bukkit.entity.Player) player.getBukkitEntity(), + asFailReason(bedSleepingProblem), + org.bukkit.craftbukkit.block.CraftBlock.at(player.level(), bed), + !player.level().environmentAttributes().getDimensionValue(EnvironmentAttributes.BED_RULE).canSleep().test(player.level()), // TODO - snapshot - check if canSleep is correct + io.papermc.paper.adventure.PaperAdventure.asAdventure(bedSleepingProblem.message())); + event.callEvent(); + return event; + } + public static Either callPlayerBedEnterEvent(net.minecraft.world.entity.player.Player player, BlockPos bed, Either nmsBedResult) { BedEnterResult bedEnterResult = nmsBedResult.mapBoth(sleepingProblem -> { - return switch (sleepingProblem) { - case NOT_POSSIBLE_HERE -> BedEnterResult.NOT_POSSIBLE_HERE; - case NOT_POSSIBLE_NOW -> BedEnterResult.NOT_POSSIBLE_NOW; - case TOO_FAR_AWAY -> BedEnterResult.TOO_FAR_AWAY; - case NOT_SAFE -> BedEnterResult.NOT_SAFE; - case OBSTRUCTED -> BedEnterResult.OBSTRUCTED; - default -> BedEnterResult.OTHER_PROBLEM; - }; + if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.OTHER_PROBLEM) { + return BedEnterResult.OTHER_PROBLEM; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.NOT_SAFE) { + return BedEnterResult.NOT_SAFE; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.OBSTRUCTED) { + return BedEnterResult.OBSTRUCTED; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.TOO_FAR_AWAY) { + return BedEnterResult.TOO_FAR_AWAY; + } + throw new IllegalStateException(); }, t -> BedEnterResult.OK).map(java.util.function.Function.identity(), java.util.function.Function.identity()); PlayerBedEnterEvent event = new PlayerBedEnterEvent((Player) player.getBukkitEntity(), CraftBlock.at(player.level(), bed), bedEnterResult); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java index 0e14f962b268..15367aa8300d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java @@ -21,6 +21,7 @@ import net.minecraft.util.RandomSource; import net.minecraft.world.Difficulty; import net.minecraft.world.DifficultyInstance; +import net.minecraft.world.attribute.EnvironmentAttributeReader; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.flag.FeatureFlagSet; @@ -29,6 +30,7 @@ import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.ColorResolver; import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.MoonPhase; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.BiomeManager; @@ -256,7 +258,7 @@ public float getTimeOfDay(float tickDelta) { } @Override - public int getMoonPhase() { + public MoonPhase getMoonPhase() { return this.delegate.getMoonPhase(); } @@ -425,6 +427,11 @@ public FeatureFlagSet enabledFeatures() { return this.delegate.enabledFeatures(); } + @Override + public EnvironmentAttributeReader environmentAttributes() { + return this.delegate.environmentAttributes(); + } + @Override public HolderLookup holderLookup(ResourceKey> registryKey) { return this.delegate.holderLookup(registryKey); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java index b6132095828b..f64bcc041a2e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -13,6 +13,7 @@ import net.minecraft.sounds.SoundSource; import net.minecraft.util.RandomSource; import net.minecraft.world.DifficultyInstance; +import net.minecraft.world.attribute.EnvironmentAttributeReader; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.flag.FeatureFlagSet; @@ -188,6 +189,11 @@ public FeatureFlagSet enabledFeatures() { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public EnvironmentAttributeReader environmentAttributes() { + return EnvironmentAttributeReader.EMPTY; + } + @Override public float getShade(Direction direction, boolean shaded) { throw new UnsupportedOperationException("Not supported yet."); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java index 8893a94d5429..a454350085f2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java @@ -98,6 +98,7 @@ public static Permission registerPermissions(Permission parent) { DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "weather", "Allows the user to set the weather", PermissionDefault.OP, commands); DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "whitelist", "Allows the user to manage the server whitelist", PermissionDefault.OP, commands); DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "worldborder", "Allows the user to manage the world border", PermissionDefault.OP, commands); + DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "stopwatch", "Allows the user to use the /stopwatch command", PermissionDefault.OP, commands); // Paper end DefaultPermissions.registerPermission("minecraft.admin.command_feedback", "Receive command broadcasts when sendCommandFeedback is true", PermissionDefault.OP, commands); diff --git a/paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java b/paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java index 1d707114f53e..01bc3f54a27f 100644 --- a/paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java +++ b/paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java @@ -8,6 +8,7 @@ import org.bukkit.support.RegistryHelper; import org.bukkit.support.environment.AllFeatures; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.lang.reflect.Field; import java.util.Set; diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/entity/EntityTypesTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/entity/EntityTypesTest.java index e0e35de06a77..76573dbcf8e7 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/entity/EntityTypesTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/entity/EntityTypesTest.java @@ -13,6 +13,7 @@ import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.AbstractCow; import org.bukkit.entity.AbstractHorse; +import org.bukkit.entity.AbstractNautilus; import org.bukkit.entity.AbstractSkeleton; import org.bukkit.entity.AbstractVillager; import org.bukkit.entity.AbstractWindCharge; @@ -122,7 +123,8 @@ public class EntityTypesTest { ThrownPotion.class, TippedArrow.class, Vehicle.class, - WaterMob.class + WaterMob.class, + AbstractNautilus.class ); static { diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java index 24548ad643d8..20eb623f1e48 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java @@ -153,6 +153,9 @@ public class LegacyTest { Material.WAXED_OXIDIZED_COPPER_BARS, Material.WAXED_OXIDIZED_COPPER_CHAIN, Material.WAXED_OXIDIZED_COPPER_CHEST, Material.WAXED_OXIDIZED_COPPER_GOLEM_STATUE, Material.WAXED_OXIDIZED_COPPER_LANTERN, Material.WAXED_OXIDIZED_LIGHTNING_ROD, Material.WAXED_WEATHERED_COPPER_BARS, Material.WAXED_WEATHERED_COPPER_CHAIN, Material.WAXED_WEATHERED_COPPER_CHEST, Material.WAXED_WEATHERED_COPPER_GOLEM_STATUE, Material.WAXED_WEATHERED_COPPER_LANTERN, Material.WAXED_WEATHERED_LIGHTNING_ROD, Material.WEATHERED_COPPER_BARS, Material.WEATHERED_COPPER_CHAIN, Material.WEATHERED_COPPER_CHEST, Material.WEATHERED_COPPER_GOLEM_STATUE, Material.WEATHERED_COPPER_LANTERN, Material.WEATHERED_LIGHTNING_ROD, + // 1.21.11 + Material.COPPER_NAUTILUS_ARMOR, Material.COPPER_SPEAR, Material.DIAMOND_NAUTILUS_ARMOR, Material.DIAMOND_SPEAR, Material.GOLDEN_NAUTILUS_ARMOR, Material.GOLDEN_SPEAR, Material.IRON_NAUTILUS_ARMOR, Material.IRON_SPEAR, Material.NAUTILUS_SPAWN_EGG, + Material.NETHERITE_NAUTILUS_ARMOR, Material.NETHERITE_SPEAR, Material.STONE_SPEAR, Material.WOODEN_SPEAR, Material.ZOMBIE_NAUTILUS_SPAWN_EGG, // Material.LEGACY_AIR, Material.LEGACY_DEAD_BUSH, Material.LEGACY_BURNING_FURNACE, Material.LEGACY_WALL_SIGN, Material.LEGACY_REDSTONE_TORCH_OFF, Material.LEGACY_SKULL, Material.LEGACY_REDSTONE_COMPARATOR_ON, Material.LEGACY_WALL_BANNER, Material.LEGACY_MONSTER_EGG)); diff --git a/paper-server/src/test/java/org/bukkit/support/RegistryHelper.java b/paper-server/src/test/java/org/bukkit/support/RegistryHelper.java index 7af2acd0fc1d..0fb62211dbae 100644 --- a/paper-server/src/test/java/org/bukkit/support/RegistryHelper.java +++ b/paper-server/src/test/java/org/bukkit/support/RegistryHelper.java @@ -20,6 +20,7 @@ import net.minecraft.server.packs.repository.ServerPacksSource; import net.minecraft.server.packs.resources.MultiPackResourceManager; import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.server.permissions.LevelBasedPermissionSet; import net.minecraft.tags.TagLoader; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.level.biome.Biome; @@ -102,7 +103,7 @@ public static void setup(FeatureFlagSet featureFlagSet) { // Paper end - load registry here to ensure bukkit object registry are correctly delayed if needed RegistryHelper.registry = layers.compositeAccess().freeze(); // Register vanilla pack - RegistryHelper.dataPack = ReloadableServerResources.loadResources(ireloadableresourcemanager, layers, list, featureFlagSet, Commands.CommandSelection.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join(); + RegistryHelper.dataPack = ReloadableServerResources.loadResources(ireloadableresourcemanager, layers, list, featureFlagSet, Commands.CommandSelection.DEDICATED, LevelBasedPermissionSet.ALL_PERMISSIONS, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join(); // Bind tags RegistryHelper.dataPack.updateStaticRegistryTags(); // Biome shortcut diff --git a/todo-snapshot.txt b/todo-snapshot.txt new file mode 100644 index 000000000000..3ff72f433bd6 --- /dev/null +++ b/todo-snapshot.txt @@ -0,0 +1,3 @@ +- Player.java: several TODOs related to sound effect diffs +- Check ServerPlayer bed diffs +- anything marked with 'TODO - snapshot' From c591966a57ffb9ad78ce3af8ecabd6f4657276f3 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 16 Oct 2025 15:02:25 -0700 Subject: [PATCH 004/112] Further CONTRIBUTING.md updates --- CONTRIBUTING.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a2811d2b0068..8ecb5b530d23 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -210,7 +210,11 @@ Golem is going to be added in 1.21.9, you can PR to the relevant dev branch as i not make sense to merge that into `main`. Or, if you are fixing a bug that only exists in a dev branch, you should target that branch. When submitting PRs to dev branches, please coordinate with the dev team in Discord or open an issue before starting work to ensure -it's an area we want to accept changes for. +it's an area we want to accept changes for. The team prefers to handle initial updating +work through to the server running ourselves, so do not attempt to PR version updates +(i.e. 25w42a -> 25w43a, etc.) or while there are still unapplied source patches. Feature +patches are also not applied until at earliest the pre-release phase to avoid unnecessary +churn. ## Formatting From 3a7f89bc832a8e9c38477fd42532ce6c2a0486fd Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 16 Oct 2025 15:09:00 -0700 Subject: [PATCH 005/112] fix: Nautilus is Tameable --- paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java | 2 +- .../org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java b/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java index 1b4c1d7b6491..7d700fe1f9d6 100644 --- a/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java +++ b/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java @@ -1,4 +1,4 @@ package org.bukkit.entity; -public interface AbstractNautilus extends Animals { +public interface AbstractNautilus extends Animals, Tameable { } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java index 3e1409a82da4..e6c0134bc58b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java @@ -3,7 +3,7 @@ import net.minecraft.world.entity.animal.nautilus.AbstractNautilus; import org.bukkit.craftbukkit.CraftServer; -public class CraftAbstractNautilus extends CraftAnimals implements org.bukkit.entity.AbstractNautilus { +public class CraftAbstractNautilus extends CraftTameableAnimal implements org.bukkit.entity.AbstractNautilus { public CraftAbstractNautilus(final CraftServer server, final AbstractNautilus entity) { super(server, entity); } From 0db7727b821dd6ab71a3c65ca64d4292141d02cb Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 16 Oct 2025 17:17:02 -0700 Subject: [PATCH 006/112] Drop Player sound playing diff, vanilla properly passes the entity source now --- .../world/entity/player/Player.java.patch | 48 ++----------------- todo-snapshot.txt | 1 - 2 files changed, 3 insertions(+), 46 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index 9ab9a793ed41..1b2c2678f6ef 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -209,7 +209,7 @@ } @Override -@@ -950,21 +_,31 @@ +@@ -950,16 +_,26 @@ } public void attack(Entity target) { @@ -239,12 +239,6 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = attackStrengthScale > 0.9F; boolean flag1; - if (this.isSprinting() && flag) { -- this.makeSound(SoundEvents.PLAYER_ATTACK_KNOCKBACK); -+ this.makeSound(SoundEvents.PLAYER_ATTACK_KNOCKBACK); // TODO - snapshot - not sure how to port the diff from this line yet (used to be this.level().playSound(...)) - flag1 = true; - } else { - flag1 = false; @@ -972,7 +_,9 @@ f += weaponItem.getItem().getAttackDamageBonus(target, f, damageSource); @@ -255,16 +249,7 @@ f *= 1.5F; } -@@ -997,7 +_,7 @@ - this.damageStatsAndHearts(target, f3); - this.causeFoodExhaustion(0.1F); - } else { -- this.makeSound(SoundEvents.PLAYER_ATTACK_NODAMAGE); -+ this.makeSound(SoundEvents.PLAYER_ATTACK_NODAMAGE); // TODO - snapshot - not sure how to port the diff from this line yet (used to be this.level().playSound(...) - } - } - -@@ -1014,11 +_,12 @@ +@@ -1014,9 +_,10 @@ return !target.isAttackable() || target.skipAttackInteraction(this); } @@ -274,26 +259,8 @@ && target instanceof Projectile projectile + && callEvent.getAsBoolean() // Paper - damage events && projectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, EntityReference.of(this), true)) { -- this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); -+ this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); // TODO - snapshot - should this line also get the sound diff? + this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); return true; - } else { - return false; -@@ -1050,12 +_,12 @@ - - private void attackVisualEffects(Entity target, boolean isCritical, boolean isSweep, boolean isStrong, float damageAmount) { - if (isCritical) { -- this.makeSound(SoundEvents.PLAYER_ATTACK_CRIT); -+ this.makeSound(SoundEvents.PLAYER_ATTACK_CRIT); // TODO - snapshot - not sure how to port the diff from this line yet (used to be this.level().playSound(...)) - this.crit(target); - } - - if (!isCritical && !isSweep) { -- this.makeSound(isStrong ? SoundEvents.PLAYER_ATTACK_STRONG : SoundEvents.PLAYER_ATTACK_WEAK); -+ this.makeSound(isStrong ? SoundEvents.PLAYER_ATTACK_STRONG : SoundEvents.PLAYER_ATTACK_WEAK); // TODO - snapshot - not sure how to port the diff from this line yet (used to be this.level().playSound(...)) - } - - if (damageAmount > 0.0F) { @@ -1111,21 +_,43 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F) { @@ -339,15 +306,6 @@ } } -@@ -1135,7 +_,7 @@ - } - - private void doSweepAttack(Entity entity, float damageAmount, DamageSource damageSource, float strengthScale) { -- this.makeSound(SoundEvents.PLAYER_ATTACK_SWEEP); -+ this.makeSound(SoundEvents.PLAYER_ATTACK_SWEEP); // TODO - snapshot - not sure how to port the diff from this line yet (used to be this.level().playSound(...)) - if (this.level() instanceof ServerLevel serverLevel) { - float var12 = 1.0F + (float)this.getAttributeValue(Attributes.SWEEPING_DAMAGE_RATIO) * damageAmount; - @@ -1146,7 +_,10 @@ && !(livingEntity instanceof ArmorStand armorStand && armorStand.isMarker()) && this.distanceToSqr(livingEntity) < 9.0) { diff --git a/todo-snapshot.txt b/todo-snapshot.txt index 3ff72f433bd6..2113000c14fd 100644 --- a/todo-snapshot.txt +++ b/todo-snapshot.txt @@ -1,3 +1,2 @@ -- Player.java: several TODOs related to sound effect diffs - Check ServerPlayer bed diffs - anything marked with 'TODO - snapshot' From 0447aedfdee1e28491dcd81baaffaa5dfff3bcb0 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 16 Oct 2025 17:40:08 -0700 Subject: [PATCH 007/112] Call PrePlayerAttackEntityEvent for stab attacks --- .../world/entity/player/Player.java.patch | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index 1b2c2678f6ef..fac083af0ece 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -318,7 +318,23 @@ livingEntity.knockback(0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity, damageSource); } -@@ -1179,7 +_,7 @@ +@@ -1173,13 +_,22 @@ + + @Override + public boolean stabAttack(EquipmentSlot slot, Entity target, float damageAmount, boolean damage, boolean knockback, boolean dismount) { +- if (this.cannotAttack(target)) { ++ // Paper start - PlayerAttackEntityEvent ++ boolean cannotAttack = this.cannotAttack(target); // Vanilla logic ++ io.papermc.paper.event.player.PrePlayerAttackEntityEvent playerAttackEntityEvent = new io.papermc.paper.event.player.PrePlayerAttackEntityEvent( ++ (org.bukkit.entity.Player) this.getBukkitEntity(), ++ target.getBukkitEntity(), ++ !cannotAttack ++ ); ++ ++ if (!playerAttackEntityEvent.callEvent() || cannotAttack) { // Logic moved to cannotAttack local variable. ++ // Paper end - PlayerAttackEntityEvent + return false; + } else { ItemStack itemBySlot = this.getItemBySlot(slot); DamageSource damageSource = this.createAttackSource(itemBySlot); float f = this.getEnchantedDamage(target, damageAmount, damageSource) - damageAmount; From 1833b7203301e6d5a13b6a0226532b3b0dd93ede Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 16 Oct 2025 17:46:04 -0700 Subject: [PATCH 008/112] Fix stab attack projectile deflection param --- .../sources/net/minecraft/world/entity/player/Player.java.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index fac083af0ece..d530f91bf996 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -339,7 +339,7 @@ DamageSource damageSource = this.createAttackSource(itemBySlot); float f = this.getEnchantedDamage(target, damageAmount, damageSource) - damageAmount; - if (knockback && this.deflectProjectile(target)) { -+ if (knockback && this.deflectProjectile(target, () -> org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(target, damageSource, f, false))) { // Paper - damage events ++ if (knockback && this.deflectProjectile(target, () -> !org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(target, damageSource, f, false))) { // Paper - damage events return true; } else { float f1 = damage ? damageAmount + f : 0.0F; From 4920630212edf17f61d5943096dae40a91f0f434 Mon Sep 17 00:00:00 2001 From: roro1506HD Date: Fri, 17 Oct 2025 18:01:31 +0200 Subject: [PATCH 009/112] Use correct playSound methods to respect entity visibility (#13198) Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com> --- .../world/entity/player/Player.java.patch | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index d530f91bf996..4c254e2c6c41 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -249,7 +249,7 @@ f *= 1.5F; } -@@ -1014,9 +_,10 @@ +@@ -1014,11 +_,12 @@ return !target.isAttackable() || target.skipAttackInteraction(this); } @@ -259,8 +259,11 @@ && target instanceof Projectile projectile + && callEvent.getAsBoolean() // Paper - damage events && projectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, EntityReference.of(this), true)) { - this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); +- this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); ++ this.makeSound(SoundEvents.PLAYER_ATTACK_NODAMAGE); // Paper - Use makeSound to avoid duplicating client-side sound for source player return true; + } else { + return false; @@ -1111,21 +_,43 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F) { @@ -402,6 +405,15 @@ } @Override +@@ -1537,7 +_,7 @@ + + if (levels > 0 && this.experienceLevel % 5 == 0 && this.lastLevelUpTime < this.tickCount - 100.0F) { + float f = this.experienceLevel > 30 ? 1.0F : this.experienceLevel / 30.0F; +- this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_LEVELUP, this.getSoundSource(), f * 0.75F, 1.0F); ++ Player.sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_LEVELUP, this.getSoundSource(), f * 0.75F, 1.0F); // Paper - send while respecting visibility + this.lastLevelUpTime = this.tickCount; + } + } @@ -1545,15 +_,35 @@ public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { From e04557bf6bdffdca8807526e2dd1fed4500fca4c Mon Sep 17 00:00:00 2001 From: roro1506HD Date: Fri, 17 Oct 2025 18:15:01 +0200 Subject: [PATCH 010/112] Fixes for configurable invulnerable duration (#13199) --- .../minecraft/world/entity/LivingEntity.java.patch | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index bce92573692e..2e12b6bc1116 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -32,7 +32,7 @@ + public org.bukkit.craftbukkit.entity.CraftLivingEntity getBukkitLivingEntity() { return (org.bukkit.craftbukkit.entity.CraftLivingEntity) super.getBukkitEntity(); } // Paper + public boolean silentDeath = false; // Paper - mark entity as dying silently for cancellable death event + public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API -+ public int invulnerableDuration = 20; // Paper - add back this field - it was already unused by vanilla in 1.21.10... // TODO - snapshot - audit this code ++ public int invulnerableDuration = LivingEntity.INVULNERABLE_DURATION; // Paper - configurable invulnerable duration + // CraftBukkit end protected LivingEntity(EntityType type, Level level) { @@ -1274,6 +1274,15 @@ } public final int getStingerCount() { +@@ -1968,7 +_,7 @@ + @Override + public void handleDamageEvent(DamageSource damageSource) { + this.walkAnimation.setSpeed(1.5F); +- this.invulnerableTime = 20; ++ this.invulnerableTime = this.invulnerableDuration; // Paper - configurable invulnerable duration + this.hurtDuration = 10; + this.hurtTime = this.hurtDuration; + SoundEvent hurtSound = this.getHurtSound(damageSource); @@ -2080,7 +_,7 @@ @Override From 21bbb117bc1aab3d1516ec6a5d2b3ac425824f33 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Fri, 17 Oct 2025 13:30:31 -0400 Subject: [PATCH 011/112] Data component API --- .../datacomponent/DataComponentTypes.java | 16 ++ .../item/ItemComponentTypesBridge.java | 10 + .../datacomponent/item/KineticWeapon.java | 120 +++++++++ .../datacomponent/item/PiercingWeapon.java | 68 +++++ .../datacomponent/item/SwingAnimation.java | 58 ++++ .../paper/datacomponent/item/UseEffects.java | 57 ++++ .../data/EnchantmentRegistryEntry.java | 4 +- .../datacomponent/DataComponentAdapters.java | 12 +- .../item/ItemComponentTypesBridgesImpl.java | 27 ++ .../item/PaperKineticWeapon.java | 249 ++++++++++++++++++ .../item/PaperPiercingWeapon.java | 142 ++++++++++ .../item/PaperSwingAnimation.java | 71 +++++ .../datacomponent/item/PaperUseEffects.java | 63 +++++ 13 files changed, 894 insertions(+), 3 deletions(-) create mode 100644 paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java create mode 100644 paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java create mode 100644 paper-api/src/main/java/io/papermc/paper/datacomponent/item/SwingAnimation.java create mode 100644 paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java create mode 100644 paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java create mode 100644 paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java create mode 100644 paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java create mode 100644 paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java index 9e7ff539ee35..76f33fddf017 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java @@ -21,20 +21,24 @@ import io.papermc.paper.datacomponent.item.ItemEnchantments; import io.papermc.paper.datacomponent.item.ItemLore; import io.papermc.paper.datacomponent.item.JukeboxPlayable; +import io.papermc.paper.datacomponent.item.KineticWeapon; import io.papermc.paper.datacomponent.item.LodestoneTracker; import io.papermc.paper.datacomponent.item.MapDecorations; import io.papermc.paper.datacomponent.item.MapId; import io.papermc.paper.datacomponent.item.MapItemColor; import io.papermc.paper.datacomponent.item.OminousBottleAmplifier; +import io.papermc.paper.datacomponent.item.PiercingWeapon; import io.papermc.paper.datacomponent.item.PotDecorations; import io.papermc.paper.datacomponent.item.PotionContents; import io.papermc.paper.datacomponent.item.Repairable; import io.papermc.paper.datacomponent.item.ResolvableProfile; import io.papermc.paper.datacomponent.item.SeededContainerLoot; import io.papermc.paper.datacomponent.item.SuspiciousStewEffects; +import io.papermc.paper.datacomponent.item.SwingAnimation; import io.papermc.paper.datacomponent.item.Tool; import io.papermc.paper.datacomponent.item.TooltipDisplay; import io.papermc.paper.datacomponent.item.UseCooldown; +import io.papermc.paper.datacomponent.item.UseEffects; import io.papermc.paper.datacomponent.item.UseRemainder; import io.papermc.paper.datacomponent.item.Weapon; import io.papermc.paper.datacomponent.item.WritableBookContent; @@ -51,6 +55,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.Registry; import org.bukkit.block.banner.PatternType; +import org.bukkit.damage.DamageType; import org.bukkit.entity.Axolotl; import org.bukkit.entity.Cat; import org.bukkit.entity.Chicken; @@ -73,6 +78,7 @@ import org.checkerframework.checker.index.qual.Positive; import org.checkerframework.common.value.qual.IntRange; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Range; import org.jspecify.annotations.NullMarked; import static java.util.Objects.requireNonNull; @@ -111,12 +117,19 @@ public final class DataComponentTypes { * If set, the item will not lose any durability when used. */ public static final DataComponentType.NonValued UNBREAKABLE = unvalued("unbreakable"); + + public static final DataComponentType.Valued USE_EFFECTS = valued("use_effects"); /** * Custom name override for an item (as set by renaming with an Anvil). * * @see #ITEM_NAME */ public static final DataComponentType.Valued CUSTOM_NAME = valued("custom_name"); + /** + * TODO: 0-1 + */ + public static final DataComponentType.Valued MINIMUM_ATTACK_CHARGE = valued("minimum_attack_charge"); + public static final DataComponentType.Valued DAMAGE_TYPE = valued("damage_type"); /** * When present, replaces default item name with contained chat component. *

@@ -210,6 +223,9 @@ public final class DataComponentTypes { public static final DataComponentType.Valued TOOLTIP_STYLE = valued("tooltip_style"); public static final DataComponentType.Valued DEATH_PROTECTION = valued("death_protection"); public static final DataComponentType.Valued BLOCKS_ATTACKS = valued("blocks_attacks"); + public static final DataComponentType.Valued PIERCING_WEAPON = valued("piercing_weapon"); + public static final DataComponentType.Valued KINETIC_WEAPON = valued("kinetic_weapon"); + public static final DataComponentType.Valued SWING_ANIMATION = valued("swing_animation"); /** * Stores list of enchantments and their levels for an Enchanted Book. * Unlike {@link #ENCHANTMENTS}, the effects provided by enchantments diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java index 8ed4388b19a0..bf00003d10a2 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java @@ -117,4 +117,14 @@ static ItemComponentTypesBridge bridge() { TooltipDisplay.Builder tooltipDisplay(); Weapon.Builder weapon(); + + KineticWeapon.Builder kineticWeapon(); + + UseEffects.Builder useEffects(); + + PiercingWeapon.Builder piercingWeapon(); + + SwingAnimation.Builder swingAnimation(); + + KineticWeapon.Condition kineticWeaponCondition(int maxDurationTicks, float minSpeed, float minRelativeSpeed); } diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java new file mode 100644 index 000000000000..69d3962e612e --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java @@ -0,0 +1,120 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.datacomponent.DataComponentBuilder; +import net.kyori.adventure.key.Key; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; + +@NullMarked +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface KineticWeapon { + + /** + * Returns a new builder for creating a Kinetic Weapon. + * + * @return a builder instance. + */ + @Contract(value = "-> new", pure = true) + static Builder kineticWeapon() { + return ItemComponentTypesBridge.bridge().kineticWeapon(); + } + + /** + * Creates a {@link Condition} object. + */ + @Contract(value = "_,_,_ -> new", pure = true) + static Condition condition(final int maxDurationTicks, final float minSpeed, final float minRelativeSpeed) { + return ItemComponentTypesBridge.bridge().kineticWeaponCondition(maxDurationTicks, minSpeed, minRelativeSpeed); + } + + @Contract(pure = true) + float minReach(); + + @Contract(pure = true) + float maxReach(); + + @Contract(pure = true) + float hitboxMargin(); + + @Contract(pure = true) + int contactCooldownTicks(); + + @Contract(pure = true) + int delayTicks(); + + @Contract(pure = true) + @Nullable Condition dismountConditions(); + + @Contract(pure = true) + @Nullable Condition knockbackConditions(); + + @Contract(pure = true) + @Nullable Condition damageConditions(); + + float forwardMovement(); + + float damageMultiplier(); + + @Contract(pure = true) + @Nullable Key sound(); + + @Contract(pure = true) + @Nullable Key hitSound(); + + interface Condition { + @Contract(pure = true) + int maxDurationTicks(); + @Contract(pure = true) + float minSpeed(); + @Contract(pure = true) + float minRelativeSpeed(); + } + + /** + * Builder for {@link KineticWeapon}. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends DataComponentBuilder { + + @Contract(value = "_ -> this", mutates = "this") + Builder minReach(float minReach); + + @Contract(value = "_ -> this", mutates = "this") + Builder maxReach(float maxReach); + + @Contract(value = "_ -> this", mutates = "this") + Builder hitboxMargin(float hitboxMargin); + + @Contract(value = "_ -> this", mutates = "this") + Builder contactCooldownTicks(int ticks); + + @Contract(value = "_ -> this", mutates = "this") + Builder delayTicks(int ticks); + + @Contract(value = "_ -> this", mutates = "this") + Builder dismountConditions(@Nullable Condition condition); + + @Contract(value = "_ -> this", mutates = "this") + Builder knockbackConditions(@Nullable Condition condition); + + @Contract(value = "_ -> this", mutates = "this") + Builder damageConditions(@Nullable Condition condition); + + @Contract(value = "_ -> this", mutates = "this") + Builder forwardMovement(float forwardMovement); + + @Contract(value = "_ -> this", mutates = "this") + Builder damageMultiplier(float damageMultiplier); + + @Contract(value = "_ -> this", mutates = "this") + Builder sound(Key sound); + + @Contract(value = "_ -> this", mutates = "this") + Builder hitSound(Key sound); + + } +} \ No newline at end of file diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java new file mode 100644 index 000000000000..b7c20f51f4a8 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java @@ -0,0 +1,68 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.datacomponent.DataComponentBuilder; +import net.kyori.adventure.key.Key; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; + +@NullMarked +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface PiercingWeapon { + + /** + * Returns a new builder for creating a Kinetic Weapon. + * + * @return a builder instance. + */ + static Builder kineticWeapon() { + return ItemComponentTypesBridge.bridge().piercingWeapon(); + } + + float minReach(); + + float maxReach(); + + float hitboxMargin(); + + boolean dealsKnockback(); + + boolean dismounts(); + + @Nullable + Key sound(); + + @Nullable + Key hitSound(); + + /** + * Builder for {@link PiercingWeapon}. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends DataComponentBuilder { + + @Contract(value = "_ -> this", mutates = "this") + Builder minReach(float minReach); + + @Contract(value = "_ -> this", mutates = "this") + Builder maxReach(float maxReach); + + @Contract(value = "_ -> this", mutates = "this") + Builder hitboxMargin(float hitboxMargin); + + @Contract(value = "_ -> this", mutates = "this") + Builder dealsKnockback(boolean dealsKnockback); + + @Contract(value = "_ -> this", mutates = "this") + Builder dismounts(boolean dismounts); + + @Contract(value = "_ -> this", mutates = "this") + Builder sound(@Nullable Key sound); + + @Contract(value = "_ -> this", mutates = "this") + Builder hitSound(@Nullable Key sound); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/SwingAnimation.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/SwingAnimation.java new file mode 100644 index 000000000000..47b749ae93b7 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/SwingAnimation.java @@ -0,0 +1,58 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.datacomponent.DataComponentBuilder; +import net.kyori.adventure.key.Key; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jspecify.annotations.NullMarked; + +@NullMarked +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface SwingAnimation { + + @Contract(value = "-> new", pure = true) + static Builder swingAnimation() { + return ItemComponentTypesBridge.bridge().swingAnimation(); + } + + @Contract(pure = true) + Animation type(); + + @Contract(pure = true) + int duration(); + + enum Animation { + NONE, + WHACK, + STAB + } + + /** + * Builder for {@link SwingAnimation}. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends DataComponentBuilder { + + /** + * Sets the swing animation type. + * + * @param type animation type + * @return the builder for chaining + * @see #type() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder type(Animation type); + + /** + * Sets the swing animation duration in ticks. + * + * @param duration duration (>= 0) + * @return the builder for chaining + * @see #duration() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder duration(int duration); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java new file mode 100644 index 000000000000..f5e37244f0bc --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java @@ -0,0 +1,57 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.datacomponent.DataComponentBuilder; +import net.kyori.adventure.key.Key; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; + +@NullMarked +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface UseEffects { + + /** + * Returns a new builder for creating a UseEffects component. + * + * @return a builder instance. + */ + static Builder useEffects() { + return ItemComponentTypesBridge.bridge().useEffects(); + } + + @Contract(pure = true) + boolean canSprint(); + + @Contract(pure = true) + float speedMultiplier(); + + /** + * Builder for {@link UseEffects}. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends DataComponentBuilder { + + /** + * Sets whether the player can sprint while using the item. + * + * @param canSprint true to allow sprinting + * @return the builder for chaining + * @see #canSprint() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder canSprint(boolean canSprint); + + /** + * Sets the speed multiplier while using the item. + * + * @param speedMultiplier multiplier (1.0 >= value >= 0.0) + * @return the builder for chaining + * @see #speedMultiplier() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder speedMultiplier(float speedMultiplier); + } +} \ No newline at end of file diff --git a/paper-api/src/main/java/io/papermc/paper/registry/data/EnchantmentRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/EnchantmentRegistryEntry.java index e5f851d427b0..d2e8eef232c2 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/data/EnchantmentRegistryEntry.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/data/EnchantmentRegistryEntry.java @@ -157,7 +157,7 @@ interface Builder extends EnchantmentRegistryEntry, RegistryBuilder * a tag obtained via {@link RegistryComposeEvent#getOrCreateTag(TagKey)} with * tag keys found in {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys} such as * {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#ENCHANTABLE_ARMOR} and - * {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#ENCHANTABLE_SWORD}. + * {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#ENCHANTABLE_MELEE_WEAPON}. * * @param supportedItems the registry key set representing the supported items. * @return this builder instance. @@ -174,7 +174,7 @@ interface Builder extends EnchantmentRegistryEntry, RegistryBuilder * {@link RegistryComposeEvent#getOrCreateTag(TagKey)} with * tag keys found in {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys} such as * {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#ENCHANTABLE_ARMOR} and - * {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#ENCHANTABLE_SWORD}. + * {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#ENCHANTABLE_MELEE_WEAPON}. *

* Defaults to {@code null} which means all {@link #supportedItems()} are considered primary items. * Additionally, the tag {@link io.papermc.paper.registry.keys.tags.EnchantmentTagKeys#IN_ENCHANTING_TABLE} defines diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java index 1249be9e9062..a66d2d0113fb 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java @@ -23,19 +23,23 @@ import io.papermc.paper.datacomponent.item.PaperItemLore; import io.papermc.paper.datacomponent.item.PaperItemTool; import io.papermc.paper.datacomponent.item.PaperJukeboxPlayable; +import io.papermc.paper.datacomponent.item.PaperKineticWeapon; import io.papermc.paper.datacomponent.item.PaperLodestoneTracker; import io.papermc.paper.datacomponent.item.PaperMapDecorations; import io.papermc.paper.datacomponent.item.PaperMapId; import io.papermc.paper.datacomponent.item.PaperMapItemColor; import io.papermc.paper.datacomponent.item.PaperOminousBottleAmplifier; +import io.papermc.paper.datacomponent.item.PaperPiercingWeapon; import io.papermc.paper.datacomponent.item.PaperPotDecorations; import io.papermc.paper.datacomponent.item.PaperPotionContents; import io.papermc.paper.datacomponent.item.PaperRepairable; import io.papermc.paper.datacomponent.item.PaperResolvableProfile; import io.papermc.paper.datacomponent.item.PaperSeededContainerLoot; import io.papermc.paper.datacomponent.item.PaperSuspiciousStewEffects; +import io.papermc.paper.datacomponent.item.PaperSwingAnimation; import io.papermc.paper.datacomponent.item.PaperTooltipDisplay; import io.papermc.paper.datacomponent.item.PaperUseCooldown; +import io.papermc.paper.datacomponent.item.PaperUseEffects; import io.papermc.paper.datacomponent.item.PaperUseRemainder; import io.papermc.paper.datacomponent.item.PaperWeapon; import io.papermc.paper.datacomponent.item.PaperWritableBookContent; @@ -59,6 +63,7 @@ import org.bukkit.craftbukkit.CraftArt; import org.bukkit.craftbukkit.CraftMusicInstrument; import org.bukkit.craftbukkit.CraftRegistry; +import org.bukkit.craftbukkit.damage.CraftDamageType; import org.bukkit.craftbukkit.entity.CraftCat; import org.bukkit.craftbukkit.entity.CraftChicken; import org.bukkit.craftbukkit.entity.CraftCow; @@ -98,8 +103,11 @@ public static void bootstrap() { registerIdentity(DataComponents.MAX_DAMAGE); registerIdentity(DataComponents.DAMAGE); registerUntyped(DataComponents.UNBREAKABLE); + register(DataComponents.USE_EFFECTS, PaperUseEffects::new); registerIdentity(DataComponents.POTION_DURATION_SCALE); register(DataComponents.CUSTOM_NAME, PaperAdventure::asAdventure, PaperAdventure::asVanilla); + registerIdentity(DataComponents.MINIMUM_ATTACK_CHARGE); + register(DataComponents.DAMAGE_TYPE, nms -> CraftDamageType.minecraftHolderToBukkit(nms.unwrap(CraftRegistry.getMinecraftRegistry()).orElseThrow()), api -> new EitherHolder<>(CraftDamageType.bukkitToMinecraftHolder(api))); register(DataComponents.ITEM_NAME, PaperAdventure::asAdventure, PaperAdventure::asVanilla); register(DataComponents.ITEM_MODEL, PaperAdventure::asAdventure, PaperAdventure::asVanilla); register(DataComponents.LORE, PaperItemLore::new); @@ -169,7 +177,9 @@ public static void bootstrap() { register(DataComponents.TOOLTIP_DISPLAY, PaperTooltipDisplay::new); register(DataComponents.WEAPON, PaperWeapon::new); register(DataComponents.BLOCKS_ATTACKS, PaperBlocksAttacks::new); - + register(DataComponents.PIERCING_WEAPON, PaperPiercingWeapon::new); + register(DataComponents.KINETIC_WEAPON, PaperKineticWeapon::new); + register(DataComponents.SWING_ANIMATION, PaperSwingAnimation::new); register(DataComponents.VILLAGER_VARIANT, CraftVillager.CraftType::minecraftHolderToBukkit, CraftVillager.CraftType::bukkitToMinecraftHolder); register(DataComponents.WOLF_VARIANT, CraftWolf.CraftVariant::minecraftHolderToBukkit, CraftWolf.CraftVariant::bukkitToMinecraftHolder); register(DataComponents.WOLF_COLLAR, nms -> DyeColor.getByWoolData((byte) nms.getId()), api -> net.minecraft.world.item.DyeColor.byId(api.getWoolData())); diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java index a415cf6ca7cf..582f3a7abf7b 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java @@ -256,4 +256,31 @@ public TooltipDisplay.Builder tooltipDisplay() { public Weapon.Builder weapon() { return new PaperWeapon.BuilderImpl(); } + + @Override + public KineticWeapon.Builder kineticWeapon() { + return new PaperKineticWeapon.BuilderImpl(); + } + + @Override + public UseEffects.Builder useEffects() { + return new PaperUseEffects.BuilderImpl(); + } + + @Override + public PiercingWeapon.Builder piercingWeapon() { + return new PaperPiercingWeapon.BuilderImpl(); + } + + @Override + public SwingAnimation.Builder swingAnimation() { + return new PaperSwingAnimation.BuilderImpl(); + } + + @Override + public KineticWeapon.Condition kineticWeaponCondition(int maxDurationTicks, float minSpeed, float minRelativeSpeed) { + return new PaperKineticWeapon.PaperKineticWeaponCondition(new net.minecraft.world.item.component.KineticWeapon.Condition( + maxDurationTicks, minSpeed, minRelativeSpeed + )); + } } diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java new file mode 100644 index 000000000000..d7ba7eaa22bd --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java @@ -0,0 +1,249 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.adventure.PaperAdventure; +import io.papermc.paper.datacomponent.item.KineticWeapon; +import io.papermc.paper.util.MCUtil; +import net.kyori.adventure.key.Key; +import net.minecraft.core.Holder; +import net.minecraft.sounds.SoundEvent; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.craftbukkit.util.Handleable; +import org.jetbrains.annotations.Nullable; + +import java.util.Optional; +import java.util.function.Function; + +@org.jspecify.annotations.NullMarked +public record PaperKineticWeapon( + net.minecraft.world.item.component.KineticWeapon impl +) implements KineticWeapon, Handleable { + + @Override + public net.minecraft.world.item.component.KineticWeapon getHandle() { + return this.impl; + } + + @Override + public float minReach() { + return this.impl.minReach(); + } + + @Override + public float maxReach() { + return this.impl.maxReach(); + } + + @Override + public float hitboxMargin() { + return this.impl.hitboxMargin(); + } + + @Override + public int contactCooldownTicks() { + return this.impl.contactCooldownTicks(); + } + + @Override + public int delayTicks() { + return this.impl.delayTicks(); + } + + @Override + public @Nullable KineticWeapon.Condition dismountConditions() { + return this.impl.dismountConditions().map(PaperKineticWeaponCondition::new) + .orElse(null); + } + + @Override + public @Nullable KineticWeapon.Condition knockbackConditions() { + return this.impl.knockbackConditions().map(PaperKineticWeaponCondition::new) + .orElse(null); + } + + @Override + public @Nullable KineticWeapon.Condition damageConditions() { + return this.impl.damageConditions().map(PaperKineticWeaponCondition::new) + .orElse(null); + } + + @Override + public float forwardMovement() { + return this.impl.forwardMovement(); + } + + @Override + public float damageMultiplier() { + return this.impl.damageMultiplier(); + } + + @Override + public @Nullable Key sound() { + return this.impl.sound() + .map(Holder::value) + .map(SoundEvent::location) + .map(PaperAdventure::asAdventure) + .orElse(null); + } + + @Override + public @Nullable Key hitSound() { + return this.impl.hitSound() + .map(Holder::value) + .map(SoundEvent::location) + .map(PaperAdventure::asAdventure) + .orElse(null); + } + + + public record PaperKineticWeaponCondition( + net.minecraft.world.item.component.KineticWeapon.Condition impl + ) implements KineticWeapon.Condition, Handleable { + + @Override + public net.minecraft.world.item.component.KineticWeapon.Condition getHandle() { + return this.impl; + } + + @Override + public int maxDurationTicks() { + return this.impl.maxDurationTicks(); + } + + @Override + public float minSpeed() { + return this.impl.minSpeed(); + } + + @Override + public float minRelativeSpeed() { + return this.impl.minRelativeSpeed(); + } + } + + // --- Builder --- + + static final class BuilderImpl implements KineticWeapon.Builder { + + private float minReach = 0.0F; + private float maxReach = 3.0F; + private float hitboxMargin = 0.3F; + private int contactCooldownTicks = 10; + private int delayTicks = 0; + + private @Nullable net.minecraft.world.item.component.KineticWeapon.Condition dismountConditions; + private @Nullable net.minecraft.world.item.component.KineticWeapon.Condition knockbackConditions; + private @Nullable net.minecraft.world.item.component.KineticWeapon.Condition damageConditions; + + private @Nullable Key sound = null; + private @Nullable Key hitSound = null; + + private float damageMultiplier = 1; + private float forwardMovement = 0.0F; + + @Override + public KineticWeapon.Builder minReach(final float minReach) { + com.google.common.base.Preconditions.checkArgument(minReach >= 0.0F, "minReach must be >= 0"); + this.minReach = minReach; + return this; + } + + @Override + public KineticWeapon.Builder maxReach(final float maxReach) { + com.google.common.base.Preconditions.checkArgument(maxReach >= 0.0F, "maxReach must be >= 0"); + this.maxReach = maxReach; + return this; + } + + @Override + public KineticWeapon.Builder hitboxMargin(final float hitboxMargin) { + com.google.common.base.Preconditions.checkArgument(hitboxMargin >= 0.0F, "hitboxMargin must be >= 0"); + this.hitboxMargin = hitboxMargin; + return this; + } + + @Override + public KineticWeapon.Builder contactCooldownTicks(final int ticks) { + com.google.common.base.Preconditions.checkArgument(ticks >= 0, "contactCooldownTicks must be >= 0"); + this.contactCooldownTicks = ticks; + return this; + } + + @Override + public KineticWeapon.Builder delayTicks(final int ticks) { + com.google.common.base.Preconditions.checkArgument(ticks >= 0, "delayTicks must be >= 0"); + this.delayTicks = ticks; + return this; + } + + @Override + public KineticWeapon.Builder dismountConditions(@Nullable final KineticWeapon.Condition condition) { + this.dismountConditions = toNms(condition); + return this; + } + + @Override + public KineticWeapon.Builder knockbackConditions(@Nullable final KineticWeapon.Condition condition) { + this.knockbackConditions = toNms(condition); + return this; + } + + @Override + public KineticWeapon.Builder damageConditions(@Nullable final KineticWeapon.Condition condition) { + this.damageConditions = toNms(condition); + return this; + } + + @Override + public Builder damageMultiplier(float damageMultiplier) { + this.damageMultiplier = damageMultiplier; + return this; + } + + @Override + public Builder forwardMovement(float forwardMovement) { + this.forwardMovement = forwardMovement; + return this; + } + + @Override + public KineticWeapon.Builder sound(final @Nullable Key sound) { + this.sound = sound; + return this; + } + + @Override + public KineticWeapon.Builder hitSound(final @Nullable Key sound) { + this.hitSound = sound; + return this; + } + + @Override + public KineticWeapon build() { + return new PaperKineticWeapon( + new net.minecraft.world.item.component.KineticWeapon( + this.minReach, + this.maxReach, + this.hitboxMargin, + this.contactCooldownTicks, + this.delayTicks, + Optional.ofNullable(this.dismountConditions), + Optional.ofNullable(this.knockbackConditions), + Optional.ofNullable(this.damageConditions), + this.forwardMovement, + this.damageMultiplier, + Optional.ofNullable(this.sound).map(PaperAdventure::resolveSound), + Optional.ofNullable(this.hitSound).map(PaperAdventure::resolveSound) + ) + ); + } + + } + + private static net.minecraft.world.item.component.KineticWeapon.Condition toNms(final KineticWeapon.Condition api) { + if (api instanceof PaperKineticWeaponCondition(net.minecraft.world.item.component.KineticWeapon.Condition cond)) { + return cond; + } else { + throw new UnsupportedOperationException("Could not decode " + api); + } + } +} \ No newline at end of file diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java new file mode 100644 index 000000000000..ca038ac01a53 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java @@ -0,0 +1,142 @@ +package io.papermc.paper.datacomponent.item; + + +import io.papermc.paper.adventure.PaperAdventure; +import io.papermc.paper.datacomponent.item.PiercingWeapon; +import net.kyori.adventure.key.Key; +import net.minecraft.core.Holder; +import net.minecraft.sounds.SoundEvent; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.craftbukkit.util.Handleable; +import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; + +import java.util.Optional; + +@org.jspecify.annotations.NullMarked +public record PaperPiercingWeapon( + net.minecraft.world.item.component.PiercingWeapon impl +) implements PiercingWeapon, Handleable { + + @Override + public net.minecraft.world.item.component.PiercingWeapon getHandle() { + return this.impl; + } + + @Override + public float minReach() { + return this.impl.minReach(); + } + + @Override + public float maxReach() { + return this.impl.maxReach(); + } + + @Override + public float hitboxMargin() { + return this.impl.hitboxMargin(); + } + + @Override + public boolean dealsKnockback() { + return this.impl.dealsKnockback(); + } + + @Override + public boolean dismounts() { + return this.impl.dismounts(); + } + + @Override + public @Nullable Key sound() { + return this.impl.sound() + .map(Holder::value) + .map(SoundEvent::location) + .map(PaperAdventure::asAdventure) + .orElse(null); + } + + @Override + public @Nullable Key hitSound() { + return this.impl.hitSound() + .map(Holder::value) + .map(SoundEvent::location) + .map(PaperAdventure::asAdventure) + .orElse(null); + } + + + static final class BuilderImpl implements PiercingWeapon.Builder { + + private float minReach = 0.0F; // CODEC default + private float maxReach = 3.0F; // CODEC default + private float hitboxMargin = 0.3F; // CODEC default + + private boolean dealsKnockback = true; // CODEC default + private boolean dismounts = false; // CODEC default + + private @Nullable Key sound = null; // optional + private @Nullable Key hitSound = null; // optional + + @Override + public PiercingWeapon.Builder minReach(final float minReach) { + com.google.common.base.Preconditions.checkArgument(minReach >= 0.0F, "minReach must be >= 0"); + this.minReach = minReach; + return this; + } + + @Override + public PiercingWeapon.Builder maxReach(final float maxReach) { + com.google.common.base.Preconditions.checkArgument(maxReach >= 0.0F, "maxReach must be >= 0"); + this.maxReach = maxReach; + return this; + } + + @Override + public PiercingWeapon.Builder hitboxMargin(final float hitboxMargin) { + com.google.common.base.Preconditions.checkArgument(hitboxMargin >= 0.0F, "hitboxMargin must be >= 0"); + this.hitboxMargin = hitboxMargin; + return this; + } + + @Override + public PiercingWeapon.Builder dealsKnockback(final boolean dealsKnockback) { + this.dealsKnockback = dealsKnockback; + return this; + } + + @Override + public PiercingWeapon.Builder dismounts(final boolean dismounts) { + this.dismounts = dismounts; + return this; + } + + @Override + public PiercingWeapon.Builder sound(final @Nullable Key sound) { + this.sound = sound; + return this; + } + + @Override + public PiercingWeapon.Builder hitSound(final @Nullable Key sound) { + this.hitSound = sound; + return this; + } + + @Override + public PiercingWeapon build() { + return new PaperPiercingWeapon( + new net.minecraft.world.item.component.PiercingWeapon( + this.minReach, + this.maxReach, + this.hitboxMargin, + this.dealsKnockback, + this.dismounts, + Optional.ofNullable(this.sound).map(PaperAdventure::resolveSound), + Optional.ofNullable(this.hitSound).map(PaperAdventure::resolveSound) + ) + ); + } + } +} \ No newline at end of file diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java new file mode 100644 index 000000000000..912c16a35ae3 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java @@ -0,0 +1,71 @@ +package io.papermc.paper.datacomponent.item; + +import net.minecraft.world.item.SwingAnimationType; +import org.bukkit.craftbukkit.util.Handleable; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public record PaperSwingAnimation( + net.minecraft.world.item.component.SwingAnimation impl +) implements SwingAnimation, Handleable { + + @Override + public net.minecraft.world.item.component.SwingAnimation getHandle() { + return this.impl; + } + + @Override + public SwingAnimation.Animation type() { + return fromNms(this.impl.type()); + } + + @Override + public int duration() { + return this.impl.duration(); + } + + private static SwingAnimation.Animation fromNms(final SwingAnimationType nms) { + return switch (nms) { + case NONE -> SwingAnimation.Animation.NONE; + case WHACK -> SwingAnimation.Animation.WHACK; + case STAB -> SwingAnimation.Animation.STAB; + }; + } + + private static SwingAnimationType toNms(final SwingAnimation.Animation api) { + return switch (api) { + case NONE -> SwingAnimationType.NONE; + case WHACK -> SwingAnimationType.WHACK; + case STAB -> SwingAnimationType.STAB; + }; + } + + static final class BuilderImpl implements SwingAnimation.Builder { + + private SwingAnimationType type = net.minecraft.world.item.component.SwingAnimation.DEFAULT.type(); + private int duration = net.minecraft.world.item.component.SwingAnimation.DEFAULT.duration(); + + @Override + public SwingAnimation.Builder type(final SwingAnimation.Animation type) { + this.type = toNms(type); + return this; + } + + @Override + public SwingAnimation.Builder duration(final int duration) { + com.google.common.base.Preconditions.checkArgument(duration >= 0, "duration must be >= 0"); + this.duration = duration; + return this; + } + + @Override + public SwingAnimation build() { + return new PaperSwingAnimation( + new net.minecraft.world.item.component.SwingAnimation( + this.type, + this.duration + ) + ); + } + } +} \ No newline at end of file diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java new file mode 100644 index 000000000000..bad81427e6a4 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java @@ -0,0 +1,63 @@ +package io.papermc.paper.datacomponent.item; + +import com.google.common.base.Preconditions; +import io.papermc.paper.util.MCUtil; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.world.item.component.FireworkExplosion; +import org.bukkit.FireworkEffect; +import org.bukkit.craftbukkit.inventory.CraftMetaFirework; +import org.bukkit.craftbukkit.util.Handleable; +import org.jetbrains.annotations.Unmodifiable; +import org.jspecify.annotations.NullMarked; + +import java.util.List; + +@NullMarked +public record PaperUseEffects( + net.minecraft.world.item.component.UseEffects impl +) implements UseEffects, Handleable { + + @Override + public net.minecraft.world.item.component.UseEffects getHandle() { + return this.impl; + } + + @Override + public boolean canSprint() { + return this.impl.canSprint(); + } + + @Override + public float speedMultiplier() { + return this.impl.speedMultiplier(); + } + + static final class BuilderImpl implements UseEffects.Builder { + + private boolean canSprint = net.minecraft.world.item.component.UseEffects.DEFAULT.canSprint(); + private float speedMultiplier = net.minecraft.world.item.component.UseEffects.DEFAULT.speedMultiplier(); + + @Override + public UseEffects.Builder canSprint(final boolean canSprint) { + this.canSprint = canSprint; + return this; + } + + @Override + public UseEffects.Builder speedMultiplier(final float speedMultiplier) { + com.google.common.base.Preconditions.checkArgument(speedMultiplier >= 0.0F && speedMultiplier <= 1.0F, "speedMultiplier must be between 0.0 and 1.0 (inclusive)"); + this.speedMultiplier = speedMultiplier; + return this; + } + + @Override + public UseEffects build() { + return new PaperUseEffects( + new net.minecraft.world.item.component.UseEffects( + this.canSprint, + this.speedMultiplier + ) + ); + } + } +} \ No newline at end of file From 4780e4dd7b74dac779aafedc9727fa365236d5f2 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Fri, 17 Oct 2025 13:32:54 -0400 Subject: [PATCH 012/112] Remove comments, cleanup imports, etc --- .../item/PaperKineticWeapon.java | 25 +++++++--------- .../item/PaperPiercingWeapon.java | 17 +++++------ .../item/PaperSwingAnimation.java | 30 +++++++++---------- .../datacomponent/item/PaperUseEffects.java | 9 ------ 4 files changed, 32 insertions(+), 49 deletions(-) diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java index d7ba7eaa22bd..a7ac0cb5ee61 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java @@ -1,23 +1,29 @@ package io.papermc.paper.datacomponent.item; import io.papermc.paper.adventure.PaperAdventure; -import io.papermc.paper.datacomponent.item.KineticWeapon; -import io.papermc.paper.util.MCUtil; import net.kyori.adventure.key.Key; import net.minecraft.core.Holder; import net.minecraft.sounds.SoundEvent; -import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.craftbukkit.util.Handleable; import org.jetbrains.annotations.Nullable; import java.util.Optional; -import java.util.function.Function; @org.jspecify.annotations.NullMarked public record PaperKineticWeapon( net.minecraft.world.item.component.KineticWeapon impl ) implements KineticWeapon, Handleable { + private static net.minecraft.world.item.component.KineticWeapon.Condition toNms(final KineticWeapon.Condition api) { + if (api instanceof PaperKineticWeaponCondition( + net.minecraft.world.item.component.KineticWeapon.Condition cond + )) { + return cond; + } else { + throw new UnsupportedOperationException("Could not decode " + api); + } + } + @Override public net.minecraft.world.item.component.KineticWeapon getHandle() { return this.impl; @@ -94,7 +100,6 @@ public float damageMultiplier() { .orElse(null); } - public record PaperKineticWeaponCondition( net.minecraft.world.item.component.KineticWeapon.Condition impl ) implements KineticWeapon.Condition, Handleable { @@ -120,8 +125,6 @@ public float minRelativeSpeed() { } } - // --- Builder --- - static final class BuilderImpl implements KineticWeapon.Builder { private float minReach = 0.0F; @@ -238,12 +241,4 @@ public KineticWeapon build() { } } - - private static net.minecraft.world.item.component.KineticWeapon.Condition toNms(final KineticWeapon.Condition api) { - if (api instanceof PaperKineticWeaponCondition(net.minecraft.world.item.component.KineticWeapon.Condition cond)) { - return cond; - } else { - throw new UnsupportedOperationException("Could not decode " + api); - } - } } \ No newline at end of file diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java index ca038ac01a53..955e934922c5 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java @@ -2,14 +2,11 @@ import io.papermc.paper.adventure.PaperAdventure; -import io.papermc.paper.datacomponent.item.PiercingWeapon; import net.kyori.adventure.key.Key; import net.minecraft.core.Holder; import net.minecraft.sounds.SoundEvent; -import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.craftbukkit.util.Handleable; import org.jetbrains.annotations.Nullable; -import org.jspecify.annotations.NullMarked; import java.util.Optional; @@ -69,15 +66,15 @@ public boolean dismounts() { static final class BuilderImpl implements PiercingWeapon.Builder { - private float minReach = 0.0F; // CODEC default - private float maxReach = 3.0F; // CODEC default - private float hitboxMargin = 0.3F; // CODEC default + private float minReach = 0.0F; + private float maxReach = 3.0F; + private float hitboxMargin = 0.3F; - private boolean dealsKnockback = true; // CODEC default - private boolean dismounts = false; // CODEC default + private boolean dealsKnockback = true; + private boolean dismounts = false; - private @Nullable Key sound = null; // optional - private @Nullable Key hitSound = null; // optional + private @Nullable Key sound = null; + private @Nullable Key hitSound = null; @Override public PiercingWeapon.Builder minReach(final float minReach) { diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java index 912c16a35ae3..7788e701800e 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java @@ -9,21 +9,6 @@ public record PaperSwingAnimation( net.minecraft.world.item.component.SwingAnimation impl ) implements SwingAnimation, Handleable { - @Override - public net.minecraft.world.item.component.SwingAnimation getHandle() { - return this.impl; - } - - @Override - public SwingAnimation.Animation type() { - return fromNms(this.impl.type()); - } - - @Override - public int duration() { - return this.impl.duration(); - } - private static SwingAnimation.Animation fromNms(final SwingAnimationType nms) { return switch (nms) { case NONE -> SwingAnimation.Animation.NONE; @@ -40,6 +25,21 @@ private static SwingAnimationType toNms(final SwingAnimation.Animation api) { }; } + @Override + public net.minecraft.world.item.component.SwingAnimation getHandle() { + return this.impl; + } + + @Override + public SwingAnimation.Animation type() { + return fromNms(this.impl.type()); + } + + @Override + public int duration() { + return this.impl.duration(); + } + static final class BuilderImpl implements SwingAnimation.Builder { private SwingAnimationType type = net.minecraft.world.item.component.SwingAnimation.DEFAULT.type(); diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java index bad81427e6a4..2c444955d215 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java @@ -1,17 +1,8 @@ package io.papermc.paper.datacomponent.item; -import com.google.common.base.Preconditions; -import io.papermc.paper.util.MCUtil; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.minecraft.world.item.component.FireworkExplosion; -import org.bukkit.FireworkEffect; -import org.bukkit.craftbukkit.inventory.CraftMetaFirework; import org.bukkit.craftbukkit.util.Handleable; -import org.jetbrains.annotations.Unmodifiable; import org.jspecify.annotations.NullMarked; -import java.util.List; - @NullMarked public record PaperUseEffects( net.minecraft.world.item.component.UseEffects impl From 55945f6e66686e852d4b198c1078200e20c3c2b5 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Fri, 17 Oct 2025 13:37:03 -0400 Subject: [PATCH 013/112] Fix nautilus setMaximumAir --- .../nautilus/AbstractNautilus.java.patch | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch new file mode 100644 index 000000000000..002e2b94031e --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java ++++ b/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java +@@ -138,8 +_,14 @@ + + @Override + public int getMaxAirSupply() { +- return 300; +- } ++ return this.maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() ++ } ++ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() ++ @Override ++ public int getDefaultMaxAirSupply() { ++ return TOTAL_AIR_SUPPLY; ++ } ++ // CraftBukkit end + + protected void handleAirSupply(ServerLevel level, int airSupply) { + if (this.isAlive() && !this.isInWater()) { +@@ -149,7 +_,7 @@ + this.hurtServer(level, this.damageSources().dryOut(), 2.0F); + } + } else { +- this.setAirSupply(300); ++ this.setAirSupply(this.maxAirTicks); // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + } + } + From 644534171e9e10e48460514c284f1cdc5edb5916 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 18 Oct 2025 18:35:40 +0200 Subject: [PATCH 014/112] update parchment --- paper-server/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 91c3d8490f70..090fe3bbf828 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:25w42a+build.3") + mache("io.papermc:mache:25w42a+build.4") paperclip("io.papermc:paperclip:3.0.3") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } From 65daa7962b2303515e3cf15a7e634927108f7dea Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 18 Oct 2025 18:51:59 +0200 Subject: [PATCH 015/112] bump api version and call EntityTameEvent for the nautilus --- .../entity/animal/nautilus/AbstractNautilus.java.patch | 9 +++++++++ .../minecraft/world/entity/animal/wolf/Wolf.java.patch | 2 +- .../java/org/bukkit/craftbukkit/util/ApiVersion.java | 2 +- test-plugin/build.gradle.kts | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch index 002e2b94031e..6e434e192312 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch @@ -26,3 +26,12 @@ } } +@@ -431,7 +_,7 @@ + } + + private void tryToTame(Player player) { +- if (this.random.nextInt(3) == 0) { ++ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit - added event call + this.tame(player); + this.navigation.stop(); + this.level().broadcastEntityEvent(this, (byte)7); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch index 9077f78bd5fa..d501b4837dbd 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch @@ -76,7 +76,7 @@ private void tryToTame(Player player) { - if (this.random.nextInt(3) == 0) { -+ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit - added event call and isCancelled check. ++ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit - added event call this.tame(player); this.navigation.stop(); this.setTarget(null); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java index d6d8840f3298..428bbce6cf9c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java @@ -17,7 +17,7 @@ public final class ApiVersion implements Comparable, Serializable { static { versions = new HashMap<>(); - CURRENT = getOrCreateVersion("1.21.10"); + CURRENT = getOrCreateVersion("1.21.11"); FLATTENING = getOrCreateVersion("1.13"); FIELD_NAME_PARITY = getOrCreateVersion("1.20.5"); ABSTRACT_COW = getOrCreateVersion("1.21.5"); diff --git a/test-plugin/build.gradle.kts b/test-plugin/build.gradle.kts index af38ca2cf1e3..d9dbb4196c82 100644 --- a/test-plugin/build.gradle.kts +++ b/test-plugin/build.gradle.kts @@ -8,6 +8,7 @@ tasks.processResources { var apiVersion = rootProject.providers.gradleProperty("mcVersion").get() // Bukkit api versioning does not support suffixed versions apiVersion = apiVersion.substringBefore('-') + apiVersion = "1.21.11" // TODO - snapshot - remove once pre-releases hit val props = mapOf( "version" to project.version, From 75a5a4311e92993ac7d1563ea7e2e7a793aade85 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sat, 18 Oct 2025 10:44:39 -0700 Subject: [PATCH 016/112] Improve API versioning file (#13204) --- gradle.properties | 3 ++ paper-api/build.gradle.kts | 38 +++++++++++---- .../bukkit/craftbukkit/util/ApiVersion.java | 2 +- .../bukkit/craftbukkit/util/Versioning.java | 47 ++++++++++++++----- test-plugin/build.gradle.kts | 7 +-- 5 files changed, 68 insertions(+), 29 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5911e180da2a..c3ed82ae35ba 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,9 @@ group=io.papermc.paper version=25w42a-R0.1-SNAPSHOT mcVersion=25w42a +# This is the current API version for use in (paper-)plugin.yml files +# During snapshot cycles this should be the anticipated version of the release target +apiVersion=1.21.11 # Set to true while updating Minecraft version updatingMinecraft=true diff --git a/paper-api/build.gradle.kts b/paper-api/build.gradle.kts index 66415f40b903..c8d3e6161629 100644 --- a/paper-api/build.gradle.kts +++ b/paper-api/build.gradle.kts @@ -1,3 +1,5 @@ +import paper.libs.com.google.gson.Gson + plugins { `java-library` `maven-publish` @@ -136,20 +138,36 @@ configure { } } -val generateApiVersioningFile by tasks.registering { - inputs.property("version", project.version) - val pomProps = layout.buildDirectory.file("pom.properties") - outputs.file(pomProps) - val projectVersion = project.version - doLast { - pomProps.get().asFile.writeText("version=$projectVersion") +abstract class GenerateApiVersioningFile : DefaultTask() { + @get:OutputFile + abstract val outputFile: RegularFileProperty + + @get:Input + abstract val projectVersion: Property + + @get:Input + abstract val apiVersion: Property + + @TaskAction + fun generate() { + val file = outputFile.get().asFile + file.parentFile.mkdirs() + val map = mapOf( + "version" to projectVersion.get(), + "currentApiVersion" to apiVersion.get() + ) + file.writeText(Gson().toJson(map)) } } +val generateApiVersioningFile = tasks.register("generateApiVersioningFile") { + outputFile.set(layout.buildDirectory.file("apiVersioning.json")) + projectVersion.set(project.version.toString()) + apiVersion.set(rootProject.providers.gradleProperty("apiVersion")) +} + tasks.jar { - from(generateApiVersioningFile.map { it.outputs.files.singleFile }) { - into("META-INF/maven/${project.group}/${project.name}") - } + from(generateApiVersioningFile.flatMap { it.outputFile }) manifest { attributes( "Automatic-Module-Name" to "org.bukkit" diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java index 428bbce6cf9c..4a1b8038a144 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java @@ -17,7 +17,7 @@ public final class ApiVersion implements Comparable, Serializable { static { versions = new HashMap<>(); - CURRENT = getOrCreateVersion("1.21.11"); + CURRENT = getOrCreateVersion(Versioning.getCurrentApiVersion()); FLATTENING = getOrCreateVersion("1.13"); FIELD_NAME_PARITY = getOrCreateVersion("1.20.5"); ABSTRACT_COW = getOrCreateVersion("1.21.5"); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Versioning.java index 774556a62eb2..e0d339bc9b5f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Versioning.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Versioning.java @@ -1,29 +1,52 @@ package org.bukkit.craftbukkit.util; +import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; -import java.util.Properties; +import java.io.InputStreamReader; import java.util.logging.Level; import java.util.logging.Logger; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import net.minecraft.SharedConstants; import org.bukkit.Bukkit; public final class Versioning { - public static String getBukkitVersion() { - String result = "Unknown-Version"; + private static final String BUKKIT_VERSION; + private static final String API_VERSION; - InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/io.papermc.paper/paper-api/pom.properties"); - Properties properties = new Properties(); + static { + String bukkitVersion = "Unknown-Version"; + String apiVersion = null; + try (final InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("apiVersioning.json")) { + if (stream == null) { + throw new IOException("apiVersioning.json not found in classpath"); + } - if (stream != null) { - try { - properties.load(stream); + final JsonObject jsonObject = new Gson() + .fromJson(new BufferedReader(new InputStreamReader(stream)), JsonObject.class); - result = properties.getProperty("version"); - } catch (IOException ex) { - Logger.getLogger(Versioning.class.getName()).log(Level.SEVERE, "Could not get Bukkit version!", ex); + if (jsonObject == null) { + throw new IOException("apiVersioning.json is not a valid JSON file"); } + + bukkitVersion = jsonObject.get("version").getAsString(); + apiVersion = jsonObject.get("currentApiVersion").getAsString(); + } catch (final IOException ex) { + Logger.getLogger(Versioning.class.getName()).log(Level.SEVERE, "Could not get Bukkit version!", ex); + } + BUKKIT_VERSION = bukkitVersion; + if (apiVersion == null) { + apiVersion = SharedConstants.getCurrentVersion().id(); } + API_VERSION = apiVersion; + } + + public static String getBukkitVersion() { + return BUKKIT_VERSION; + } - return result; + public static String getCurrentApiVersion() { + return API_VERSION; } } diff --git a/test-plugin/build.gradle.kts b/test-plugin/build.gradle.kts index d9dbb4196c82..3dd4b5f5cad5 100644 --- a/test-plugin/build.gradle.kts +++ b/test-plugin/build.gradle.kts @@ -5,14 +5,9 @@ dependencies { } tasks.processResources { - var apiVersion = rootProject.providers.gradleProperty("mcVersion").get() - // Bukkit api versioning does not support suffixed versions - apiVersion = apiVersion.substringBefore('-') - apiVersion = "1.21.11" // TODO - snapshot - remove once pre-releases hit - val props = mapOf( "version" to project.version, - "apiversion" to "\"$apiVersion\"", + "apiversion" to "\"${rootProject.providers.gradleProperty("apiVersion").get()}\"", ) inputs.properties(props) filesMatching("paper-plugin.yml") { From dc1178620a05a5395f783f58f172fd026884172a Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 18 Oct 2025 20:29:49 +0200 Subject: [PATCH 017/112] cleanup components --- .../datacomponent/DataComponentTypes.java | 6 +- .../datacomponent/item/BlocksAttacks.java | 16 +++- .../datacomponent/item/DyedItemColor.java | 2 +- .../datacomponent/item/ItemEnchantments.java | 2 +- .../datacomponent/item/KineticWeapon.java | 37 +++---- .../datacomponent/item/PiercingWeapon.java | 27 +++--- .../datacomponent/item/SwingAnimation.java | 10 +- .../datacomponent/item/TooltipDisplay.java | 3 +- .../paper/datacomponent/item/UseEffects.java | 4 +- .../java/io/papermc/generator/Rewriters.java | 3 + .../item/ItemComponentTypesBridgesImpl.java | 1 + .../item/PaperBlocksAttacks.java | 2 +- .../item/PaperCustomModelData.java | 2 +- .../item/PaperKineticWeapon.java | 96 +++++++++---------- .../item/PaperPiercingWeapon.java | 50 +++++----- .../item/PaperSwingAnimation.java | 39 +++----- .../datacomponent/item/PaperUseEffects.java | 15 ++- 17 files changed, 151 insertions(+), 164 deletions(-) diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java index 76f33fddf017..7ae54b2028cd 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java @@ -44,8 +44,8 @@ import io.papermc.paper.datacomponent.item.WritableBookContent; import io.papermc.paper.datacomponent.item.WrittenBookContent; import io.papermc.paper.item.MapPostProcessing; -import java.util.List; import io.papermc.paper.registry.tag.TagKey; +import java.util.List; import net.kyori.adventure.key.Key; import net.kyori.adventure.text.Component; import org.bukkit.Art; @@ -78,7 +78,6 @@ import org.checkerframework.checker.index.qual.Positive; import org.checkerframework.common.value.qual.IntRange; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Range; import org.jspecify.annotations.NullMarked; import static java.util.Objects.requireNonNull; @@ -125,9 +124,6 @@ public final class DataComponentTypes { * @see #ITEM_NAME */ public static final DataComponentType.Valued CUSTOM_NAME = valued("custom_name"); - /** - * TODO: 0-1 - */ public static final DataComponentType.Valued MINIMUM_ATTACK_CHARGE = valued("minimum_attack_charge"); public static final DataComponentType.Valued DAMAGE_TYPE = valued("damage_type"); /** diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/BlocksAttacks.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/BlocksAttacks.java index 5cfb65dfcfde..e36616f7ab30 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/BlocksAttacks.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/BlocksAttacks.java @@ -7,6 +7,7 @@ import java.util.List; import net.kyori.adventure.key.Key; import org.bukkit.damage.DamageType; +import org.checkerframework.checker.index.qual.NonNegative; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jspecify.annotations.NullMarked; @@ -32,7 +33,8 @@ static Builder blocksAttacks() { * * @return the delay in seconds */ - float blockDelaySeconds(); + @Contract(pure = true) + @NonNegative float blockDelaySeconds(); /** * Gets the multiplier applied to the cooldown time for the item when attacked by a disabling attack (the multiplier for {@link Weapon#disableBlockingForSeconds()}). @@ -41,13 +43,15 @@ static Builder blocksAttacks() { * * @return the multiplier for the cooldown time */ - float disableCooldownScale(); + @Contract(pure = true) + @NonNegative float disableCooldownScale(); /** * Gets a list of {@link DamageReduction} of how much damage should be blocked in a given attack. * * @return a list of damage reductions */ + @Contract(pure = true) List damageReductions(); /** @@ -55,6 +59,7 @@ static Builder blocksAttacks() { * * @return the damage function */ + @Contract(pure = true) ItemDamageFunction itemDamage(); /** @@ -62,6 +67,7 @@ static Builder blocksAttacks() { * * @return a damage type tag key, or null if there is no such tag key */ + @Contract(pure = true) @Nullable TagKey bypassedBy(); /** @@ -69,6 +75,7 @@ static Builder blocksAttacks() { * * @return a key of the sound */ + @Contract(pure = true) @Nullable Key blockSound(); /** @@ -76,6 +83,7 @@ static Builder blocksAttacks() { * * @return a key of the sound */ + @Contract(pure = true) @Nullable Key disableSound(); /** @@ -86,10 +94,10 @@ static Builder blocksAttacks() { interface Builder extends DataComponentBuilder { @Contract(value = "_ -> this", mutates = "this") - Builder blockDelaySeconds(float delay); + Builder blockDelaySeconds(@NonNegative float delay); @Contract(value = "_ -> this", mutates = "this") - Builder disableCooldownScale(float scale); + Builder disableCooldownScale(@NonNegative float scale); @Contract(value = "_ -> this", mutates = "this") Builder addDamageReduction(DamageReduction reduction); diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java index 73f4c73dabb5..f1587b243d0a 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java @@ -15,7 +15,7 @@ @ApiStatus.NonExtendable public interface DyedItemColor { - @Contract(value = "_, _ -> new", pure = true) + @Contract(value = "_ -> new", pure = true) static DyedItemColor dyedItemColor(final Color color) { return dyedItemColor().color(color).build(); } diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java index a36266df0f52..23115714ba2d 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java @@ -19,7 +19,7 @@ @ApiStatus.NonExtendable public interface ItemEnchantments { - @Contract(value = "_, _ -> new", pure = true) + @Contract(value = "_ -> new", pure = true) static ItemEnchantments itemEnchantments(final Map enchantments) { return itemEnchantments().addAll(enchantments).build(); } diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java index 69d3962e612e..a0b45bdd4ab2 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java @@ -2,10 +2,11 @@ import io.papermc.paper.datacomponent.DataComponentBuilder; import net.kyori.adventure.key.Key; +import org.checkerframework.checker.index.qual.NonNegative; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.Nullable; import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; @NullMarked @ApiStatus.Experimental @@ -15,7 +16,7 @@ public interface KineticWeapon { /** * Returns a new builder for creating a Kinetic Weapon. * - * @return a builder instance. + * @return a builder instance */ @Contract(value = "-> new", pure = true) static Builder kineticWeapon() { @@ -25,25 +26,25 @@ static Builder kineticWeapon() { /** * Creates a {@link Condition} object. */ - @Contract(value = "_,_,_ -> new", pure = true) - static Condition condition(final int maxDurationTicks, final float minSpeed, final float minRelativeSpeed) { + @Contract(value = "_, _, _ -> new", pure = true) + static Condition condition(final @NonNegative int maxDurationTicks, final float minSpeed, final float minRelativeSpeed) { return ItemComponentTypesBridge.bridge().kineticWeaponCondition(maxDurationTicks, minSpeed, minRelativeSpeed); } @Contract(pure = true) - float minReach(); + @NonNegative float minReach(); @Contract(pure = true) - float maxReach(); + @NonNegative float maxReach(); @Contract(pure = true) - float hitboxMargin(); + @NonNegative float hitboxMargin(); @Contract(pure = true) - int contactCooldownTicks(); + @NonNegative int contactCooldownTicks(); @Contract(pure = true) - int delayTicks(); + @NonNegative int delayTicks(); @Contract(pure = true) @Nullable Condition dismountConditions(); @@ -65,10 +66,13 @@ static Condition condition(final int maxDurationTicks, final float minSpeed, fin @Nullable Key hitSound(); interface Condition { + @Contract(pure = true) - int maxDurationTicks(); + @NonNegative int maxDurationTicks(); + @Contract(pure = true) float minSpeed(); + @Contract(pure = true) float minRelativeSpeed(); } @@ -81,19 +85,19 @@ interface Condition { interface Builder extends DataComponentBuilder { @Contract(value = "_ -> this", mutates = "this") - Builder minReach(float minReach); + Builder minReach(@NonNegative float minReach); @Contract(value = "_ -> this", mutates = "this") - Builder maxReach(float maxReach); + Builder maxReach(@NonNegative float maxReach); @Contract(value = "_ -> this", mutates = "this") - Builder hitboxMargin(float hitboxMargin); + Builder hitboxMargin(@NonNegative float hitboxMargin); @Contract(value = "_ -> this", mutates = "this") - Builder contactCooldownTicks(int ticks); + Builder contactCooldownTicks(@NonNegative int ticks); @Contract(value = "_ -> this", mutates = "this") - Builder delayTicks(int ticks); + Builder delayTicks(@NonNegative int ticks); @Contract(value = "_ -> this", mutates = "this") Builder dismountConditions(@Nullable Condition condition); @@ -115,6 +119,5 @@ interface Builder extends DataComponentBuilder { @Contract(value = "_ -> this", mutates = "this") Builder hitSound(Key sound); - } -} \ No newline at end of file +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java index b7c20f51f4a8..18bb6f9692bf 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java @@ -2,10 +2,11 @@ import io.papermc.paper.datacomponent.DataComponentBuilder; import net.kyori.adventure.key.Key; +import org.checkerframework.checker.index.qual.NonNegative; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.Nullable; import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; @NullMarked @ApiStatus.Experimental @@ -13,29 +14,27 @@ public interface PiercingWeapon { /** - * Returns a new builder for creating a Kinetic Weapon. + * Returns a new builder for creating a Piercing Weapon. * - * @return a builder instance. + * @return a builder instance */ - static Builder kineticWeapon() { + static Builder piercingWeapon() { return ItemComponentTypesBridge.bridge().piercingWeapon(); } - float minReach(); + @NonNegative float minReach(); - float maxReach(); + @NonNegative float maxReach(); - float hitboxMargin(); + @NonNegative float hitboxMargin(); boolean dealsKnockback(); boolean dismounts(); - @Nullable - Key sound(); + @Nullable Key sound(); - @Nullable - Key hitSound(); + @Nullable Key hitSound(); /** * Builder for {@link PiercingWeapon}. @@ -45,13 +44,13 @@ static Builder kineticWeapon() { interface Builder extends DataComponentBuilder { @Contract(value = "_ -> this", mutates = "this") - Builder minReach(float minReach); + Builder minReach(@NonNegative float minReach); @Contract(value = "_ -> this", mutates = "this") - Builder maxReach(float maxReach); + Builder maxReach(@NonNegative float maxReach); @Contract(value = "_ -> this", mutates = "this") - Builder hitboxMargin(float hitboxMargin); + Builder hitboxMargin(@NonNegative float hitboxMargin); @Contract(value = "_ -> this", mutates = "this") Builder dealsKnockback(boolean dealsKnockback); diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/SwingAnimation.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/SwingAnimation.java index 47b749ae93b7..83a4a44bc88a 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/SwingAnimation.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/SwingAnimation.java @@ -1,7 +1,7 @@ package io.papermc.paper.datacomponent.item; import io.papermc.paper.datacomponent.DataComponentBuilder; -import net.kyori.adventure.key.Key; +import org.checkerframework.checker.index.qual.Positive; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jspecify.annotations.NullMarked; @@ -20,12 +20,14 @@ static Builder swingAnimation() { Animation type(); @Contract(pure = true) - int duration(); + @Positive int duration(); enum Animation { + // Start generate - SwingAnimationType NONE, WHACK, - STAB + STAB; + // End generate - SwingAnimationType } /** @@ -53,6 +55,6 @@ interface Builder extends DataComponentBuilder { * @see #duration() */ @Contract(value = "_ -> this", mutates = "this") - Builder duration(int duration); + Builder duration(@Positive int duration); } } diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/TooltipDisplay.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/TooltipDisplay.java index 85aaae68adcf..382a9038d686 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/TooltipDisplay.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/TooltipDisplay.java @@ -2,12 +2,11 @@ import io.papermc.paper.datacomponent.DataComponentBuilder; import io.papermc.paper.datacomponent.DataComponentType; +import java.util.Set; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jspecify.annotations.NullMarked; -import java.util.Set; - @NullMarked @ApiStatus.Experimental @ApiStatus.NonExtendable diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java index f5e37244f0bc..a0f4aa455424 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java @@ -1,10 +1,8 @@ package io.papermc.paper.datacomponent.item; import io.papermc.paper.datacomponent.DataComponentBuilder; -import net.kyori.adventure.key.Key; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.Nullable; import org.jspecify.annotations.NullMarked; @NullMarked @@ -54,4 +52,4 @@ interface Builder extends DataComponentBuilder { @Contract(value = "_ -> this", mutates = "this") Builder speedMultiplier(float speedMultiplier); } -} \ No newline at end of file +} diff --git a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java index 38e81b3a7831..3cb31687e3a6 100644 --- a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java +++ b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java @@ -23,6 +23,7 @@ import io.papermc.generator.rewriter.types.simple.trial.VillagerProfessionRewriter; import io.papermc.generator.types.goal.MobGoalNames; import io.papermc.generator.utils.Formatting; +import io.papermc.paper.datacomponent.item.SwingAnimation; import io.papermc.paper.datacomponent.item.consumable.ItemUseAnimation; import io.papermc.paper.dialog.Dialog; import io.papermc.paper.world.WeatheringCopperState; @@ -41,6 +42,7 @@ import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.player.ChatVisiblity; import net.minecraft.world.item.Rarity; +import net.minecraft.world.item.SwingAnimationType; import net.minecraft.world.level.block.WeatheringCopper; import org.bukkit.Art; import org.bukkit.FeatureFlag; @@ -152,6 +154,7 @@ protected EnumValue.Builder rewriteEnumValue(ParticleStatus status) { }) )) .register("ItemUseAnimation", ItemUseAnimation.class, new EnumCloneRewriter<>(net.minecraft.world.item.ItemUseAnimation.class)) + .register("SwingAnimationType", SwingAnimation.Animation.class, new EnumCloneRewriter<>(SwingAnimationType.class)) .register("ItemRarity", ItemRarity.class, new EnumCloneRewriter<>(Rarity.class) { @Override protected EnumValue.Builder rewriteEnumValue(Rarity rarity) { diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java index 582f3a7abf7b..266296263849 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java @@ -279,6 +279,7 @@ public SwingAnimation.Builder swingAnimation() { @Override public KineticWeapon.Condition kineticWeaponCondition(int maxDurationTicks, float minSpeed, float minRelativeSpeed) { + Preconditions.checkArgument(maxDurationTicks >= 0, "maxDurationTicks must be non-negative"); return new PaperKineticWeapon.PaperKineticWeaponCondition(new net.minecraft.world.item.component.KineticWeapon.Condition( maxDurationTicks, minSpeed, minRelativeSpeed )); diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperBlocksAttacks.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperBlocksAttacks.java index 4e78722f80d4..71c927abdebc 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperBlocksAttacks.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperBlocksAttacks.java @@ -8,9 +8,9 @@ import io.papermc.paper.datacomponent.item.blocksattacks.PaperItemDamageFunction; import io.papermc.paper.registry.PaperRegistries; import io.papermc.paper.registry.tag.TagKey; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.List; import java.util.Optional; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.kyori.adventure.key.Key; import org.bukkit.craftbukkit.util.Handleable; import org.bukkit.damage.DamageType; diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java index e2f2d435b97a..9b36a53930ae 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java @@ -1,6 +1,7 @@ package io.papermc.paper.datacomponent.item; import com.google.common.base.Preconditions; +import io.papermc.paper.util.MCUtil; import it.unimi.dsi.fastutil.booleans.BooleanArrayList; import it.unimi.dsi.fastutil.booleans.BooleanList; import it.unimi.dsi.fastutil.floats.FloatArrayList; @@ -10,7 +11,6 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.Collections; import java.util.List; -import io.papermc.paper.util.MCUtil; import org.bukkit.Color; import org.bukkit.craftbukkit.util.Handleable; diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java index a7ac0cb5ee61..efa1d510415d 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java @@ -1,22 +1,21 @@ package io.papermc.paper.datacomponent.item; +import com.google.common.base.Preconditions; import io.papermc.paper.adventure.PaperAdventure; +import java.util.Optional; import net.kyori.adventure.key.Key; import net.minecraft.core.Holder; import net.minecraft.sounds.SoundEvent; import org.bukkit.craftbukkit.util.Handleable; -import org.jetbrains.annotations.Nullable; - -import java.util.Optional; +import org.jspecify.annotations.Nullable; -@org.jspecify.annotations.NullMarked public record PaperKineticWeapon( net.minecraft.world.item.component.KineticWeapon impl ) implements KineticWeapon, Handleable { private static net.minecraft.world.item.component.KineticWeapon.Condition toNms(final KineticWeapon.Condition api) { if (api instanceof PaperKineticWeaponCondition( - net.minecraft.world.item.component.KineticWeapon.Condition cond + net.minecraft.world.item.component.KineticWeapon.Condition cond )) { return cond; } else { @@ -55,21 +54,21 @@ public int delayTicks() { } @Override - public @Nullable KineticWeapon.Condition dismountConditions() { + public KineticWeapon.@Nullable Condition dismountConditions() { return this.impl.dismountConditions().map(PaperKineticWeaponCondition::new) - .orElse(null); + .orElse(null); } @Override - public @Nullable KineticWeapon.Condition knockbackConditions() { + public KineticWeapon.@Nullable Condition knockbackConditions() { return this.impl.knockbackConditions().map(PaperKineticWeaponCondition::new) - .orElse(null); + .orElse(null); } @Override - public @Nullable KineticWeapon.Condition damageConditions() { + public KineticWeapon.@Nullable Condition damageConditions() { return this.impl.damageConditions().map(PaperKineticWeaponCondition::new) - .orElse(null); + .orElse(null); } @Override @@ -85,19 +84,19 @@ public float damageMultiplier() { @Override public @Nullable Key sound() { return this.impl.sound() - .map(Holder::value) - .map(SoundEvent::location) - .map(PaperAdventure::asAdventure) - .orElse(null); + .map(Holder::value) + .map(SoundEvent::location) + .map(PaperAdventure::asAdventure) + .orElse(null); } @Override public @Nullable Key hitSound() { return this.impl.hitSound() - .map(Holder::value) - .map(SoundEvent::location) - .map(PaperAdventure::asAdventure) - .orElse(null); + .map(Holder::value) + .map(SoundEvent::location) + .map(PaperAdventure::asAdventure) + .orElse(null); } public record PaperKineticWeaponCondition( @@ -133,9 +132,9 @@ static final class BuilderImpl implements KineticWeapon.Builder { private int contactCooldownTicks = 10; private int delayTicks = 0; - private @Nullable net.minecraft.world.item.component.KineticWeapon.Condition dismountConditions; - private @Nullable net.minecraft.world.item.component.KineticWeapon.Condition knockbackConditions; - private @Nullable net.minecraft.world.item.component.KineticWeapon.Condition damageConditions; + private net.minecraft.world.item.component.KineticWeapon.@Nullable Condition dismountConditions; + private net.minecraft.world.item.component.KineticWeapon.@Nullable Condition knockbackConditions; + private net.minecraft.world.item.component.KineticWeapon.@Nullable Condition damageConditions; private @Nullable Key sound = null; private @Nullable Key hitSound = null; @@ -145,54 +144,54 @@ static final class BuilderImpl implements KineticWeapon.Builder { @Override public KineticWeapon.Builder minReach(final float minReach) { - com.google.common.base.Preconditions.checkArgument(minReach >= 0.0F, "minReach must be >= 0"); + Preconditions.checkArgument(minReach >= 0.0F, "minReach must be non-negative"); this.minReach = minReach; return this; } @Override public KineticWeapon.Builder maxReach(final float maxReach) { - com.google.common.base.Preconditions.checkArgument(maxReach >= 0.0F, "maxReach must be >= 0"); + Preconditions.checkArgument(maxReach >= 0.0F, "maxReach must be non-negative"); this.maxReach = maxReach; return this; } @Override public KineticWeapon.Builder hitboxMargin(final float hitboxMargin) { - com.google.common.base.Preconditions.checkArgument(hitboxMargin >= 0.0F, "hitboxMargin must be >= 0"); + Preconditions.checkArgument(hitboxMargin >= 0.0F, "hitboxMargin must be non-negative"); this.hitboxMargin = hitboxMargin; return this; } @Override public KineticWeapon.Builder contactCooldownTicks(final int ticks) { - com.google.common.base.Preconditions.checkArgument(ticks >= 0, "contactCooldownTicks must be >= 0"); + Preconditions.checkArgument(ticks >= 0, "contactCooldownTicks must be non-negative"); this.contactCooldownTicks = ticks; return this; } @Override public KineticWeapon.Builder delayTicks(final int ticks) { - com.google.common.base.Preconditions.checkArgument(ticks >= 0, "delayTicks must be >= 0"); + Preconditions.checkArgument(ticks >= 0, "delayTicks must be non-negative"); this.delayTicks = ticks; return this; } @Override - public KineticWeapon.Builder dismountConditions(@Nullable final KineticWeapon.Condition condition) { - this.dismountConditions = toNms(condition); + public KineticWeapon.Builder dismountConditions(final KineticWeapon.@Nullable Condition condition) { + this.dismountConditions = condition == null ? null : toNms(condition); return this; } @Override - public KineticWeapon.Builder knockbackConditions(@Nullable final KineticWeapon.Condition condition) { - this.knockbackConditions = toNms(condition); + public KineticWeapon.Builder knockbackConditions(final KineticWeapon.@Nullable Condition condition) { + this.knockbackConditions = condition == null ? null : toNms(condition); return this; } @Override - public KineticWeapon.Builder damageConditions(@Nullable final KineticWeapon.Condition condition) { - this.damageConditions = toNms(condition); + public KineticWeapon.Builder damageConditions(final KineticWeapon.@Nullable Condition condition) { + this.damageConditions = condition == null ? null : toNms(condition); return this; } @@ -223,22 +222,21 @@ public KineticWeapon.Builder hitSound(final @Nullable Key sound) { @Override public KineticWeapon build() { return new PaperKineticWeapon( - new net.minecraft.world.item.component.KineticWeapon( - this.minReach, - this.maxReach, - this.hitboxMargin, - this.contactCooldownTicks, - this.delayTicks, - Optional.ofNullable(this.dismountConditions), - Optional.ofNullable(this.knockbackConditions), - Optional.ofNullable(this.damageConditions), - this.forwardMovement, - this.damageMultiplier, - Optional.ofNullable(this.sound).map(PaperAdventure::resolveSound), - Optional.ofNullable(this.hitSound).map(PaperAdventure::resolveSound) - ) + new net.minecraft.world.item.component.KineticWeapon( + this.minReach, + this.maxReach, + this.hitboxMargin, + this.contactCooldownTicks, + this.delayTicks, + Optional.ofNullable(this.dismountConditions), + Optional.ofNullable(this.knockbackConditions), + Optional.ofNullable(this.damageConditions), + this.forwardMovement, + this.damageMultiplier, + Optional.ofNullable(this.sound).map(PaperAdventure::resolveSound), + Optional.ofNullable(this.hitSound).map(PaperAdventure::resolveSound) + ) ); } - } -} \ No newline at end of file +} diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java index 955e934922c5..762acfd2b33b 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java @@ -1,16 +1,14 @@ package io.papermc.paper.datacomponent.item; - +import com.google.common.base.Preconditions; import io.papermc.paper.adventure.PaperAdventure; +import java.util.Optional; import net.kyori.adventure.key.Key; import net.minecraft.core.Holder; import net.minecraft.sounds.SoundEvent; import org.bukkit.craftbukkit.util.Handleable; -import org.jetbrains.annotations.Nullable; - -import java.util.Optional; +import org.jspecify.annotations.Nullable; -@org.jspecify.annotations.NullMarked public record PaperPiercingWeapon( net.minecraft.world.item.component.PiercingWeapon impl ) implements PiercingWeapon, Handleable { @@ -48,19 +46,19 @@ public boolean dismounts() { @Override public @Nullable Key sound() { return this.impl.sound() - .map(Holder::value) - .map(SoundEvent::location) - .map(PaperAdventure::asAdventure) - .orElse(null); + .map(Holder::value) + .map(SoundEvent::location) + .map(PaperAdventure::asAdventure) + .orElse(null); } @Override public @Nullable Key hitSound() { return this.impl.hitSound() - .map(Holder::value) - .map(SoundEvent::location) - .map(PaperAdventure::asAdventure) - .orElse(null); + .map(Holder::value) + .map(SoundEvent::location) + .map(PaperAdventure::asAdventure) + .orElse(null); } @@ -78,21 +76,21 @@ static final class BuilderImpl implements PiercingWeapon.Builder { @Override public PiercingWeapon.Builder minReach(final float minReach) { - com.google.common.base.Preconditions.checkArgument(minReach >= 0.0F, "minReach must be >= 0"); + Preconditions.checkArgument(minReach >= 0.0F, "minReach must be non-negative"); this.minReach = minReach; return this; } @Override public PiercingWeapon.Builder maxReach(final float maxReach) { - com.google.common.base.Preconditions.checkArgument(maxReach >= 0.0F, "maxReach must be >= 0"); + Preconditions.checkArgument(maxReach >= 0.0F, "maxReach must be non-negative"); this.maxReach = maxReach; return this; } @Override public PiercingWeapon.Builder hitboxMargin(final float hitboxMargin) { - com.google.common.base.Preconditions.checkArgument(hitboxMargin >= 0.0F, "hitboxMargin must be >= 0"); + Preconditions.checkArgument(hitboxMargin >= 0.0F, "hitboxMargin must be non-negative"); this.hitboxMargin = hitboxMargin; return this; } @@ -124,16 +122,16 @@ public PiercingWeapon.Builder hitSound(final @Nullable Key sound) { @Override public PiercingWeapon build() { return new PaperPiercingWeapon( - new net.minecraft.world.item.component.PiercingWeapon( - this.minReach, - this.maxReach, - this.hitboxMargin, - this.dealsKnockback, - this.dismounts, - Optional.ofNullable(this.sound).map(PaperAdventure::resolveSound), - Optional.ofNullable(this.hitSound).map(PaperAdventure::resolveSound) - ) + new net.minecraft.world.item.component.PiercingWeapon( + this.minReach, + this.maxReach, + this.hitboxMargin, + this.dealsKnockback, + this.dismounts, + Optional.ofNullable(this.sound).map(PaperAdventure::resolveSound), + Optional.ofNullable(this.hitSound).map(PaperAdventure::resolveSound) + ) ); } } -} \ No newline at end of file +} diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java index 7788e701800e..cdc315158d62 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java @@ -1,38 +1,21 @@ package io.papermc.paper.datacomponent.item; +import com.google.common.base.Preconditions; import net.minecraft.world.item.SwingAnimationType; import org.bukkit.craftbukkit.util.Handleable; -import org.jspecify.annotations.NullMarked; -@NullMarked public record PaperSwingAnimation( - net.minecraft.world.item.component.SwingAnimation impl + net.minecraft.world.item.component.SwingAnimation impl ) implements SwingAnimation, Handleable { - private static SwingAnimation.Animation fromNms(final SwingAnimationType nms) { - return switch (nms) { - case NONE -> SwingAnimation.Animation.NONE; - case WHACK -> SwingAnimation.Animation.WHACK; - case STAB -> SwingAnimation.Animation.STAB; - }; - } - - private static SwingAnimationType toNms(final SwingAnimation.Animation api) { - return switch (api) { - case NONE -> SwingAnimationType.NONE; - case WHACK -> SwingAnimationType.WHACK; - case STAB -> SwingAnimationType.STAB; - }; - } - @Override public net.minecraft.world.item.component.SwingAnimation getHandle() { return this.impl; } @Override - public SwingAnimation.Animation type() { - return fromNms(this.impl.type()); + public Animation type() { + return Animation.valueOf(this.impl.type().name()); } @Override @@ -47,13 +30,13 @@ static final class BuilderImpl implements SwingAnimation.Builder { @Override public SwingAnimation.Builder type(final SwingAnimation.Animation type) { - this.type = toNms(type); + this.type = SwingAnimationType.valueOf(type.name()); return this; } @Override public SwingAnimation.Builder duration(final int duration) { - com.google.common.base.Preconditions.checkArgument(duration >= 0, "duration must be >= 0"); + Preconditions.checkArgument(duration > 0, "duration must be positive"); this.duration = duration; return this; } @@ -61,11 +44,11 @@ public SwingAnimation.Builder duration(final int duration) { @Override public SwingAnimation build() { return new PaperSwingAnimation( - new net.minecraft.world.item.component.SwingAnimation( - this.type, - this.duration - ) + new net.minecraft.world.item.component.SwingAnimation( + this.type, + this.duration + ) ); } } -} \ No newline at end of file +} diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java index 2c444955d215..33507c1eea24 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java @@ -1,9 +1,8 @@ package io.papermc.paper.datacomponent.item; +import com.google.common.base.Preconditions; import org.bukkit.craftbukkit.util.Handleable; -import org.jspecify.annotations.NullMarked; -@NullMarked public record PaperUseEffects( net.minecraft.world.item.component.UseEffects impl ) implements UseEffects, Handleable { @@ -36,7 +35,7 @@ public UseEffects.Builder canSprint(final boolean canSprint) { @Override public UseEffects.Builder speedMultiplier(final float speedMultiplier) { - com.google.common.base.Preconditions.checkArgument(speedMultiplier >= 0.0F && speedMultiplier <= 1.0F, "speedMultiplier must be between 0.0 and 1.0 (inclusive)"); + Preconditions.checkArgument(speedMultiplier >= 0.0F && speedMultiplier <= 1.0F, "speedMultiplier must be between 0.0 and 1.0 (inclusive)"); this.speedMultiplier = speedMultiplier; return this; } @@ -44,11 +43,11 @@ public UseEffects.Builder speedMultiplier(final float speedMultiplier) { @Override public UseEffects build() { return new PaperUseEffects( - new net.minecraft.world.item.component.UseEffects( - this.canSprint, - this.speedMultiplier - ) + new net.minecraft.world.item.component.UseEffects( + this.canSprint, + this.speedMultiplier + ) ); } } -} \ No newline at end of file +} From 674330896fde4c543c52d64a591d79c0c4d99f98 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 18 Oct 2025 21:15:32 +0200 Subject: [PATCH 018/112] set heal reason for nautilus eating --- .../entity/animal/nautilus/AbstractNautilus.java.patch | 9 +++++++++ .../paper/datacomponent/item/PaperKineticWeapon.java | 2 +- .../paper/datacomponent/item/PaperPiercingWeapon.java | 2 +- .../paper/datacomponent/item/PaperUseEffects.java | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch index 6e434e192312..01e4c66111a0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch @@ -26,6 +26,15 @@ } } +@@ -411,7 +_,7 @@ + if (this.isFood(itemInHand) && this.getHealth() < this.getMaxHealth()) { + this.usePlayerItem(player, hand, itemInHand); + FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); +- this.heal(foodProperties != null ? 2 * foodProperties.nutrition() : 1.0F); ++ this.heal(foodProperties != null ? 2 * foodProperties.nutrition() : 1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper - Add regain reason + return InteractionResult.SUCCESS; + } + @@ -431,7 +_,7 @@ } diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java index efa1d510415d..2590467c009b 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java @@ -10,7 +10,7 @@ import org.jspecify.annotations.Nullable; public record PaperKineticWeapon( - net.minecraft.world.item.component.KineticWeapon impl + net.minecraft.world.item.component.KineticWeapon impl ) implements KineticWeapon, Handleable { private static net.minecraft.world.item.component.KineticWeapon.Condition toNms(final KineticWeapon.Condition api) { diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java index 762acfd2b33b..a7ee81f23006 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java @@ -10,7 +10,7 @@ import org.jspecify.annotations.Nullable; public record PaperPiercingWeapon( - net.minecraft.world.item.component.PiercingWeapon impl + net.minecraft.world.item.component.PiercingWeapon impl ) implements PiercingWeapon, Handleable { @Override diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java index 33507c1eea24..46f0b0350aa1 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java @@ -4,7 +4,7 @@ import org.bukkit.craftbukkit.util.Handleable; public record PaperUseEffects( - net.minecraft.world.item.component.UseEffects impl + net.minecraft.world.item.component.UseEffects impl ) implements UseEffects, Handleable { @Override From 6b1dc1f1c22892a160de7034edaa334083746499 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sun, 19 Oct 2025 09:59:56 -0700 Subject: [PATCH 019/112] Update mache --- paper-server/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 090fe3bbf828..469a4b7abc07 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:25w42a+build.4") + mache("io.papermc:mache:25w42a+build.5") paperclip("io.papermc:paperclip:3.0.3") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } From 729e75eeaf2bf6f1a788c4eb8a263b529dc2a23a Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sun, 19 Oct 2025 15:53:11 -0700 Subject: [PATCH 020/112] Fix and deprecate World#isUltraWarm --- paper-api/src/main/java/org/bukkit/World.java | 2 ++ .../src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index 7b22c923b467..408f1ea16c42 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -2859,7 +2859,9 @@ default double getHumidity(int x, int z) { * * * @return true if this world has the above mechanics + * @deprecated as of 1.21.11, ultra warm is replaced by the WATER_EVAPORATES, FAST_LAVA, and DEFAULT_DRIPSTONE_PARTICLE environment attributes. */ + @Deprecated(since = "1.21.11") public boolean isUltraWarm(); /** diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index fac6f0e6019e..4513b1824bdd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1403,7 +1403,9 @@ public boolean hasRaids() { @Override public boolean isUltraWarm() { - return this.world.environmentAttributes().getDimensionValue(EnvironmentAttributes.WATER_EVAPORATES); + return this.world.environmentAttributes().getDimensionValue(EnvironmentAttributes.WATER_EVAPORATES) + && this.world.environmentAttributes().getDimensionValue(EnvironmentAttributes.FAST_LAVA) + && this.world.environmentAttributes().getDimensionValue(EnvironmentAttributes.DEFAULT_DRIPSTONE_PARTICLE).equals(ParticleTypes.DRIPPING_DRIPSTONE_LAVA); } @Override From 474d54da728306598f93b4a779578eee5cf54423 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 21 Oct 2025 09:28:43 -0700 Subject: [PATCH 021/112] Add back MagicConstant annotations (#13215) --- .../server/level/TicketType.java.patch | 26 ++++++++++++- .../world/level/block/Block.java.patch | 37 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch b/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch index 19a61c1fd8da..82f0cbabca18 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch @@ -1,5 +1,24 @@ --- a/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java +@@ -9,11 +_,13 @@ + + public record TicketType(long timeout, @TicketType.Flags int flags) { + public static final long NO_TIMEOUT = 0L; +- public static final int FLAG_PERSIST = 1; +- public static final int FLAG_LOADING = 2; +- public static final int FLAG_SIMULATION = 4; +- public static final int FLAG_KEEP_DIMENSION_ACTIVE = 8; +- public static final int FLAG_CAN_EXPIRE_IF_UNLOADED = 16; ++ // Paper start - diff on change - all listed in Flags annotation ++ public static final int FLAG_PERSIST = 1; // Paper - diff on change - all listed in Flags annotation ++ public static final int FLAG_LOADING = 2; // Paper - diff on change - all listed in Flags annotation ++ public static final int FLAG_SIMULATION = 4; // Paper - diff on change - all listed in Flags annotation ++ public static final int FLAG_KEEP_DIMENSION_ACTIVE = 8; // Paper - diff on change - all listed in Flags annotation ++ public static final int FLAG_CAN_EXPIRE_IF_UNLOADED = 16; // Paper - diff on change - all listed in Flags annotation ++ // Paper end - diff on change - all listed in Flags annotation + public static final TicketType PLAYER_SPAWN = register("player_spawn", 20L, 2); + public static final TicketType SPAWN_SEARCH = register("spawn_search", 1L, 2); + public static final TicketType DRAGON = register("dragon", 0L, 6); @@ -23,6 +_,11 @@ public static final TicketType PORTAL = register("portal", 300L, 15); public static final TicketType ENDER_PEARL = register("ender_pearl", 40L, 14); @@ -12,7 +31,7 @@ private static TicketType register(String name, long timeout, @TicketType.Flags int flags) { return Registry.register(BuiltInRegistries.TICKET_TYPE, name, new TicketType(timeout, flags)); -@@ -48,8 +_,15 @@ +@@ -48,12 +_,20 @@ return (this.flags & 16) != 0; } @@ -29,3 +48,8 @@ } @Retention(RetentionPolicy.CLASS) + @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.TYPE_USE}) ++ @org.intellij.lang.annotations.MagicConstant(flags = {FLAG_PERSIST, FLAG_LOADING, FLAG_SIMULATION, FLAG_KEEP_DIMENSION_ACTIVE, FLAG_CAN_EXPIRE_IF_UNLOADED}) // Paper - add back source-retention annotation for IDE + public @interface Flags { + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch index 34e039f9036f..d73bf195b882 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch @@ -1,5 +1,34 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java +@@ -88,16 +_,18 @@ + return !Shapes.joinIsNotEmpty(Shapes.block(), shape, BooleanOp.NOT_SAME); + } + }); +- public static final int UPDATE_NEIGHBORS = 1; +- public static final int UPDATE_CLIENTS = 2; +- public static final int UPDATE_INVISIBLE = 4; +- public static final int UPDATE_IMMEDIATE = 8; +- public static final int UPDATE_KNOWN_SHAPE = 16; +- public static final int UPDATE_SUPPRESS_DROPS = 32; +- public static final int UPDATE_MOVE_BY_PISTON = 64; +- public static final int UPDATE_SKIP_SHAPE_UPDATE_ON_WIRE = 128; +- public static final int UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS = 256; +- public static final int UPDATE_SKIP_ON_PLACE = 512; ++ // Paper start - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_NEIGHBORS = 1; // Paper - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_CLIENTS = 2; // Paper - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_INVISIBLE = 4; // Paper - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_IMMEDIATE = 8; // Paper - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_KNOWN_SHAPE = 16; // Paper - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_SUPPRESS_DROPS = 32; // Paper - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_MOVE_BY_PISTON = 64; // Paper - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_SKIP_SHAPE_UPDATE_ON_WIRE = 128; // Paper - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS = 256; // Paper - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_SKIP_ON_PLACE = 512; // Paper - diff on change - all listed in UpdateFlags annotation ++ // Paper end - diff on change - all listed in UpdateFlags annotation + @Block.UpdateFlags + public static final int UPDATE_NONE = 260; + @Block.UpdateFlags @@ -111,6 +_,21 @@ public static final int UPDATE_LIMIT = 512; protected final StateDefinition stateDefinition; @@ -140,3 +169,11 @@ record ShapePairKey(VoxelShape first, VoxelShape second) { @Override +@@ -603,6 +_,7 @@ + + @Retention(RetentionPolicy.CLASS) + @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.TYPE_USE}) ++ @org.intellij.lang.annotations.MagicConstant(flags = {UPDATE_NEIGHBORS, UPDATE_CLIENTS, UPDATE_INVISIBLE, UPDATE_IMMEDIATE, UPDATE_KNOWN_SHAPE, UPDATE_SUPPRESS_DROPS, UPDATE_MOVE_BY_PISTON, UPDATE_SKIP_SHAPE_UPDATE_ON_WIRE, UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS, UPDATE_SKIP_ON_PLACE}) // Paper - add back source-retention annotation for IDE + public @interface UpdateFlags { + } + } From d71ccc420e28958dca3af9d73ec4e5eb42d5bf75 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 21 Oct 2025 09:49:42 -0700 Subject: [PATCH 022/112] 25w43a --- gradle.properties | 4 +- paper-server/build.gradle.kts | 4 +- .../sources/net/minecraft/Util.java.patch | 36 +--- .../framework/GameTestServer.java.patch | 13 +- .../minecraft/network/Connection.java.patch | 45 ++--- .../network/FriendlyByteBuf.java.patch | 6 +- .../server/MinecraftServer.java.patch | 92 ++++----- .../commands/SetSpawnCommand.java.patch | 6 +- .../commands/WaypointCommand.java.patch | 2 +- .../server/gui/StatsComponent.java.patch | 4 +- .../server/level/ChunkMap.java.patch | 67 ++++--- .../server/level/ServerLevel.java.patch | 26 +-- .../network/EventLoopGroupHolder.java.patch | 40 ++++ .../ServerConnectionListener.java.patch | 44 +---- .../CachedUserNameToIdResolver.java.patch | 18 +- .../server/players/PlayerList.java.patch | 56 +++--- .../util/worldupdate/WorldUpgrader.java.patch | 12 +- .../minecraft/world/entity/Entity.java.patch | 181 +++++++++--------- .../world/entity/LivingEntity.java.patch | 148 +++++++------- .../world/entity/ambient/Bat.java.patch | 8 +- .../nautilus/AbstractNautilus.java.patch | 30 +-- .../animal/nautilus/Nautilus.java.patch | 28 +++ .../monster/AbstractSkeleton.java.patch | 20 +- .../world/entity/monster/Zombie.java.patch | 28 +-- .../world/entity/player/Player.java.patch | 62 +++--- .../world/level/border/WorldBorder.java.patch | 52 +++-- .../chunk/storage/ChunkStorage.java.patch | 97 ---------- .../storage/SerializableChunkData.java.patch | 2 +- .../storage/SimpleRegionStorage.java.patch | 66 +++++++ .../NoiseBasedChunkGenerator.java.patch | 4 +- .../LegacyStructureDataHandler.java.patch | 36 +++- .../structure/StructureCheck.java.patch | 8 +- .../world/level/storage/LevelData.java.patch | 2 +- .../storage/LevelStorageSource.java.patch | 8 +- .../storage/PlayerDataStorage.java.patch | 8 +- .../bukkit/craftbukkit/CraftWorldBorder.java | 2 +- .../craftbukkit/entity/CraftPlayer.java | 2 +- todo-snapshot.txt | 2 + 38 files changed, 627 insertions(+), 642 deletions(-) create mode 100644 paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch diff --git a/gradle.properties b/gradle.properties index c3ed82ae35ba..ece9e4f6128c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group=io.papermc.paper -version=25w42a-R0.1-SNAPSHOT -mcVersion=25w42a +version=25w43a-R0.1-SNAPSHOT +mcVersion=25w43a # This is the current API version for use in (paper-)plugin.yml files # During snapshot cycles this should be the anticipated version of the release target apiVersion=1.21.11 diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 469a4b7abc07..d4cdf26affec 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:25w42a+build.5") + mache("io.papermc:mache:25w43a+build.3") paperclip("io.papermc:paperclip:3.0.3") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } @@ -42,7 +42,7 @@ paperweight { ) updatingMinecraft { - //oldPaperCommit = "b57d6410f648268b62c674a754253fcbcc74cbb9" + oldPaperCommit = "474d54da728306598f93b4a779578eee5cf54423" } } diff --git a/paper-server/patches/sources/net/minecraft/Util.java.patch b/paper-server/patches/sources/net/minecraft/Util.java.patch index df31260643f2..32f814b74c27 100644 --- a/paper-server/patches/sources/net/minecraft/Util.java.patch +++ b/paper-server/patches/sources/net/minecraft/Util.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/Util.java +++ b/net/minecraft/Util.java -@@ -91,9 +_,25 @@ +@@ -89,9 +_,25 @@ private static final int DEFAULT_MAX_THREADS = 255; private static final int DEFAULT_SAFE_FILE_OPERATION_RETRIES = 10; private static final String MAX_THREADS_SYSTEM_PROPERTY = "max.bg.threads"; @@ -28,7 +28,7 @@ private static final DateTimeFormatter FILENAME_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss", Locale.ROOT); public static final int LINEAR_LOOKUP_THRESHOLD = 8; private static final Set ALLOWED_UNTRUSTED_LINK_PROTOCOLS = Set.of("http", "https"); -@@ -112,6 +_,7 @@ +@@ -110,6 +_,7 @@ .findFirst() .orElseThrow(() -> new IllegalStateException("No jar file system provider found")); private static Consumer thePauser = string -> {}; @@ -36,7 +36,7 @@ public static Collector, ?, Map> toMap() { return Collectors.toMap(Entry::getKey, Entry::getValue); -@@ -134,7 +_,7 @@ +@@ -132,7 +_,7 @@ } public static long getNanos() { @@ -45,7 +45,7 @@ } public static long getEpochMillis() { -@@ -145,9 +_,10 @@ +@@ -143,9 +_,10 @@ return FILENAME_DATE_TIME_FORMATTER.format(ZonedDateTime.now()); } @@ -58,7 +58,7 @@ if (i <= 0) { directExecutorService = MoreExecutors.newDirectExecutorService(); } else { -@@ -172,16 +_,30 @@ +@@ -170,16 +_,30 @@ super.onTermination(throwOnTermination); } }; @@ -91,10 +91,11 @@ } private static int getMaxThreads() { -@@ -232,6 +_,21 @@ +@@ -229,6 +_,21 @@ + return thread; })); } - ++ + // Paper start - Separate dimension data IO pool + private static TracingExecutor makeExtraIoExecutor(String namePrefix) { + AtomicInteger atomicInteger = new AtomicInteger(1); @@ -109,25 +110,6 @@ + })); + } + // Paper end - Separate dimension data IO pool -+ + public static void throwAsRuntime(Throwable throwable) { throw throwable instanceof RuntimeException ? (RuntimeException)throwable : new RuntimeException(throwable); - } -@@ -1116,16 +_,7 @@ - } - - public void openUri(URI uri) { -- try { -- Process process = AccessController.doPrivileged( -- (PrivilegedExceptionAction)(() -> Runtime.getRuntime().exec(this.getOpenUriArguments(uri))) -- ); -- process.getInputStream().close(); -- process.getErrorStream().close(); -- process.getOutputStream().close(); -- } catch (IOException | PrivilegedActionException var3) { -- Util.LOGGER.error("Couldn't open location '{}'", uri, var3); -- } -+ throw new IllegalStateException("This method is not useful on dedicated servers."); // Paper - Fix warnings on build by removing client-only code - } - - public void openFile(File file) { diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch index 60d0e26ddc85..f176aa3352b0 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java -@@ -145,6 +_,8 @@ +@@ -147,6 +_,8 @@ boolean verify ) { super( @@ -9,12 +9,11 @@ serverThread, storageSource, packRepository, -@@ -160,8 +_,16 @@ +@@ -162,9 +_,17 @@ @Override public boolean initServer() { - this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, new EmptyNotificationService()) {}); -- this.loadLevel(); + // Paper start + this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, new EmptyNotificationService()) { + @Override @@ -22,13 +21,15 @@ + throw new UnsupportedOperationException("Should not be called in a GameTestServer"); + } + }); -+ this.loadLevel("blah"); + this.initPostWorld(); + Gizmos.withCollector(GizmoCollector.NOOP); +- this.loadLevel(); ++ this.loadLevel("blah"); + // Paper end ServerLevel serverLevel = this.overworld(); this.testBatches = this.evaluateTestsToRun(serverLevel); LOGGER.info("Started game test server"); -@@ -346,6 +_,13 @@ +@@ -349,6 +_,13 @@ return false; } @@ -42,7 +43,7 @@ @Override public boolean isSingleplayerOwner(NameAndId nameAndId) { return false; -@@ -393,5 +_,16 @@ +@@ -396,5 +_,16 @@ @Override public void save() { } diff --git a/paper-server/patches/sources/net/minecraft/network/Connection.java.patch b/paper-server/patches/sources/net/minecraft/network/Connection.java.patch index 541952750e5b..dac3dc2e57ce 100644 --- a/paper-server/patches/sources/net/minecraft/network/Connection.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/Connection.java.patch @@ -1,23 +1,6 @@ --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -73,13 +_,13 @@ - public static final Marker PACKET_RECEIVED_MARKER = Util.make(MarkerFactory.getMarker("PACKET_RECEIVED"), marker -> marker.add(PACKET_MARKER)); - public static final Marker PACKET_SENT_MARKER = Util.make(MarkerFactory.getMarker("PACKET_SENT"), marker -> marker.add(PACKET_MARKER)); - public static final Supplier NETWORK_WORKER_GROUP = Suppliers.memoize( -- () -> new NioEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Client IO #%d").setDaemon(true).build()) -+ () -> new NioEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()) // Paper - ); - public static final Supplier NETWORK_EPOLL_WORKER_GROUP = Suppliers.memoize( -- () -> new EpollEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).build()) -+ () -> new EpollEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()) // Paper - ); - public static final Supplier LOCAL_WORKER_GROUP = Suppliers.memoize( -- () -> new DefaultEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Local Client IO #%d").setDaemon(true).build()) -+ () -> new DefaultEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Local Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()) // Paper - ); - private static final ProtocolInfo INITIAL_PROTOCOL = HandshakeProtocols.SERVERBOUND; - private final PacketFlow receiving; -@@ -87,6 +_,11 @@ +@@ -68,6 +_,11 @@ private final Queue> pendingActions = Queues.newConcurrentLinkedQueue(); public Channel channel; public SocketAddress address; @@ -29,7 +12,7 @@ @Nullable private volatile PacketListener disconnectListener; @Nullable -@@ -105,6 +_,43 @@ +@@ -86,6 +_,43 @@ private volatile DisconnectionDetails delayedDisconnect; @Nullable BandwidthDebugMonitor bandwidthDebugMonitor; @@ -73,7 +56,7 @@ public Connection(PacketFlow receiving) { this.receiving = receiving; -@@ -115,6 +_,7 @@ +@@ -96,6 +_,7 @@ super.channelActive(ctx); this.channel = ctx.channel(); this.address = this.channel.remoteAddress(); @@ -81,7 +64,7 @@ if (this.delayedDisconnect != null) { this.disconnect(this.delayedDisconnect); } -@@ -127,14 +_,31 @@ +@@ -108,14 +_,31 @@ @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable exception) { @@ -113,7 +96,7 @@ this.disconnect(Component.translatable("disconnect.timeout")); } else { Component component = Component.translatable("disconnect.genericReason", "Internal Exception: " + exception); -@@ -146,9 +_,11 @@ +@@ -127,9 +_,11 @@ disconnectionDetails = new DisconnectionDetails(component); } @@ -126,7 +109,7 @@ Packet packet = (Packet)(this.sendLoginDisconnect ? new ClientboundLoginDisconnectPacket(component) : new ClientboundDisconnectPacket(component)); -@@ -165,6 +_,7 @@ +@@ -146,6 +_,7 @@ } } } @@ -134,7 +117,7 @@ } @Override -@@ -174,10 +_,60 @@ +@@ -155,10 +_,60 @@ if (packetListener == null) { throw new IllegalStateException("Received a packet before the packet listener was initialized"); } else { @@ -195,7 +178,7 @@ } catch (RejectedExecutionException var6) { this.disconnect(Component.translatable("multiplayer.disconnect.server_shutdown")); } catch (ClassCastException var7) { -@@ -370,10 +_,30 @@ +@@ -351,10 +_,30 @@ } } @@ -226,7 +209,7 @@ } if (!this.isConnected() && !this.disconnectionHandled) { -@@ -381,7 +_,7 @@ +@@ -362,7 +_,7 @@ } if (this.channel != null) { @@ -235,7 +218,7 @@ } if (this.tickCount++ % 20 == 0) { -@@ -417,12 +_,13 @@ +@@ -398,12 +_,13 @@ } public void disconnect(DisconnectionDetails disconnectionDetails) { @@ -250,7 +233,7 @@ this.disconnectionDetails = disconnectionDetails; } } -@@ -569,6 +_,13 @@ +@@ -540,6 +_,13 @@ } } @@ -264,7 +247,7 @@ public void setupCompression(int threshold, boolean validateDecompressed) { if (threshold >= 0) { if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder compressionDecoder) { -@@ -582,6 +_,7 @@ +@@ -553,6 +_,7 @@ } else { this.channel.pipeline().addAfter("prepender", "compress", new CompressionEncoder(threshold)); } @@ -272,7 +255,7 @@ } else { if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder) { this.channel.pipeline().remove("decompress"); -@@ -590,6 +_,7 @@ +@@ -561,6 +_,7 @@ if (this.channel.pipeline().get("compress") instanceof CompressionEncoder) { this.channel.pipeline().remove("compress"); } @@ -280,7 +263,7 @@ } } -@@ -607,6 +_,26 @@ +@@ -578,6 +_,26 @@ ); packetListener1.onDisconnect(disconnectionDetails); } diff --git a/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch b/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch index a9b9b399fb70..c4a3ada187dc 100644 --- a/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/FriendlyByteBuf.java +++ b/net/minecraft/network/FriendlyByteBuf.java -@@ -72,14 +_,20 @@ +@@ -71,14 +_,20 @@ public class FriendlyByteBuf extends ByteBuf { public static final int DEFAULT_NBT_QUOTA = 2097152; private final ByteBuf source; @@ -21,7 +21,7 @@ this.source = source; } -@@ -108,8 +_,13 @@ +@@ -107,8 +_,13 @@ } public void writeJsonWithCodec(Codec codec, T value) { @@ -36,7 +36,7 @@ } public static IntFunction limitValue(IntFunction function, int limit) { -@@ -556,7 +_,7 @@ +@@ -555,7 +_,7 @@ try { NbtIo.writeAnyTag(tag, new ByteBufOutputStream(buffer)); diff --git a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch index 86ea8484bc9f..b25e192d9c9e 100644 --- a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -430,8 +430,8 @@ Optional legacyWorldBorderSettings = serverLevelData.getLegacyWorldBorderSettings(); if (legacyWorldBorderSettings.isPresent()) { WorldBorder.Settings settings = legacyWorldBorderSettings.get(); -@@ -495,16 +_,14 @@ - dataStorage1.set(WorldBorder.TYPE, settings1.toWorldBorder()); +@@ -497,16 +_,14 @@ + dataStorage1.set(WorldBorder.TYPE, worldBorder); } - flag = true; @@ -453,7 +453,7 @@ } private static void setInitialSpawn( -@@ -516,6 +_,30 @@ +@@ -518,6 +_,30 @@ levelData.setSpawn(LevelData.RespawnData.of(level.dimension(), BlockPos.ZERO.above(80), 0.0F, 0.0F)); } else { ServerChunkCache chunkSource = level.getChunkSource(); @@ -484,7 +484,7 @@ ChunkPos chunkPos = new ChunkPos(chunkSource.randomState().sampler().findSpawnPosition()); levelLoadListener.start(LevelLoadListener.Stage.PREPARE_GLOBAL_SPAWN, 0); levelLoadListener.updateFocus(level.dimension(), chunkPos); -@@ -572,10 +_,13 @@ +@@ -574,10 +_,13 @@ serverLevelData.setGameType(GameType.SPECTATOR); } @@ -500,7 +500,7 @@ chunkLoadCounter.track(serverLevel, () -> { TicketStorage ticketStorage = serverLevel.getDataStorage().get(TicketStorage.TYPE); if (ticketStorage != null) { -@@ -584,17 +_,19 @@ +@@ -586,17 +_,19 @@ }); } @@ -526,7 +526,7 @@ } protected GlobalPos selectLevelLoadFocusPos() { -@@ -628,8 +_,10 @@ +@@ -630,8 +_,10 @@ flag = true; } @@ -539,7 +539,7 @@ if (flush) { for (ServerLevel serverLevel : this.getAllLevels()) { LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", serverLevel.getChunkSource().chunkMap.getStorageName()); -@@ -659,19 +_,49 @@ +@@ -661,19 +_,49 @@ this.stopServer(); } @@ -590,7 +590,7 @@ } LOGGER.info("Saving worlds"); -@@ -713,6 +_,25 @@ +@@ -715,6 +_,25 @@ } catch (IOException var4) { LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), var4); } @@ -616,7 +616,7 @@ } public String getLocalIp() { -@@ -728,6 +_,14 @@ +@@ -730,6 +_,14 @@ } public void halt(boolean waitForShutdown) { @@ -631,7 +631,7 @@ this.running = false; if (waitForShutdown) { try { -@@ -738,6 +_,124 @@ +@@ -740,6 +_,124 @@ } } @@ -756,7 +756,7 @@ protected void runServer() { try { if (!this.initServer()) { -@@ -745,26 +_,68 @@ +@@ -747,26 +_,68 @@ } this.nextTickTimeNanos = Util.getNanos(); @@ -835,7 +835,7 @@ boolean flag = l == 0L; if (this.debugCommandProfilerDelayStart) { -@@ -772,22 +_,22 @@ +@@ -774,22 +_,22 @@ this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount); } @@ -863,7 +863,7 @@ this.finishMeasuringTaskExecutionTime(); if (flag) { this.tickRateManager.endTickWork(); -@@ -821,7 +_,7 @@ +@@ -823,7 +_,7 @@ } catch (Throwable var64) { LOGGER.error("Exception stopping the server", var64); } finally { @@ -872,7 +872,7 @@ } } } -@@ -873,7 +_,14 @@ +@@ -875,7 +_,14 @@ } private boolean haveTime() { @@ -888,7 +888,7 @@ } public static boolean throwIfFatalException() { -@@ -899,11 +_,11 @@ +@@ -901,11 +_,11 @@ } protected void waitUntilNextTick() { @@ -902,7 +902,7 @@ } finally { this.waitingForNextTick = false; } -@@ -922,17 +_,23 @@ +@@ -924,17 +_,23 @@ @Override public TickTask wrapRunnable(Runnable runnable) { @@ -928,7 +928,7 @@ this.mayHaveDelayedTasks = flag; return flag; } -@@ -941,15 +_,16 @@ +@@ -943,15 +_,16 @@ if (super.pollTask()) { return true; } else { @@ -947,7 +947,7 @@ } } -@@ -1001,26 +_,44 @@ +@@ -1003,26 +_,44 @@ } public void tickServer(BooleanSupplier hasTimeLeft) { @@ -993,7 +993,7 @@ this.tickCount++; this.tickRateManager.tick(); this.tickChildren(hasTimeLeft); -@@ -1030,11 +_,18 @@ +@@ -1032,11 +_,18 @@ } this.ticksUntilAutosave--; @@ -1013,7 +1013,7 @@ profilerFiller.push("tallying"); long l = Util.getNanos() - nanos; int i1 = this.tickCount % 100; -@@ -1047,7 +_,7 @@ +@@ -1049,7 +_,7 @@ } private void autoSave() { @@ -1022,7 +1022,7 @@ LOGGER.debug("Autosave started"); ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("save"); -@@ -1089,7 +_,7 @@ +@@ -1091,7 +_,7 @@ private ServerStatus buildServerStatus() { ServerStatus.Players players = this.buildPlayerStatus(); return new ServerStatus( @@ -1031,7 +1031,7 @@ Optional.of(players), Optional.of(ServerStatus.Version.current()), Optional.ofNullable(this.statusIcon), -@@ -1103,7 +_,7 @@ +@@ -1105,7 +_,7 @@ if (this.hidesOnlinePlayers()) { return new ServerStatus.Players(maxPlayers, players.size(), List.of()); } else { @@ -1040,7 +1040,7 @@ ObjectArrayList list = new ObjectArrayList<>(min); int randomInt = Mth.nextInt(this.random, 0, players.size() - min); -@@ -1120,18 +_,77 @@ +@@ -1122,18 +_,77 @@ protected void tickChildren(BooleanSupplier hasTimeLeft) { ProfilerFiller profilerFiller = Profiler.get(); this.getPlayerList().getPlayers().forEach(serverPlayer1 -> serverPlayer1.connection.suspendFlushing()); @@ -1118,7 +1118,7 @@ profilerFiller.push("tick"); -@@ -1145,7 +_,9 @@ +@@ -1147,7 +_,9 @@ profilerFiller.pop(); profilerFiller.pop(); @@ -1128,7 +1128,7 @@ profilerFiller.popPush("connection"); this.tickConnection(); -@@ -1175,9 +_,12 @@ +@@ -1177,9 +_,12 @@ this.serverActivityMonitor.tick(); } @@ -1143,7 +1143,7 @@ this.effectiveRespawnData = serverLevel.getWorldBorderAdjustedRespawnData(respawnData); } -@@ -1229,6 +_,22 @@ +@@ -1231,6 +_,22 @@ return this.levels.get(dimension); } @@ -1166,7 +1166,7 @@ public Set> levelKeys() { return this.levels.keySet(); } -@@ -1253,7 +_,7 @@ +@@ -1255,7 +_,7 @@ @DontObfuscate public String getServerModName() { @@ -1175,7 +1175,7 @@ } public SystemReport fillSystemReport(SystemReport systemReport) { -@@ -1288,7 +_,7 @@ +@@ -1290,7 +_,7 @@ @Override public void sendSystemMessage(Component message) { @@ -1184,7 +1184,7 @@ } public KeyPair getKeyPair() { -@@ -1326,11 +_,17 @@ +@@ -1328,11 +_,17 @@ } } @@ -1207,7 +1207,7 @@ } } -@@ -1402,10 +_,20 @@ +@@ -1404,10 +_,20 @@ @Override public String getMotd() { @@ -1229,7 +1229,7 @@ this.motd = motd; } -@@ -1434,9 +_,13 @@ +@@ -1436,9 +_,13 @@ int i = 0; for (ServerPlayer serverPlayer : this.getPlayerList().getPlayers()) { @@ -1245,7 +1245,7 @@ } return i; -@@ -1444,7 +_,7 @@ +@@ -1446,7 +_,7 @@ } public ServerConnectionListener getConnection() { @@ -1254,7 +1254,7 @@ } public boolean isReady() { -@@ -1512,7 +_,7 @@ +@@ -1514,7 +_,7 @@ @Override public void executeIfPossible(Runnable task) { if (this.isStopped()) { @@ -1263,7 +1263,7 @@ } else { super.executeIfPossible(task); } -@@ -1547,7 +_,14 @@ +@@ -1549,7 +_,14 @@ return this.functionManager; } @@ -1278,7 +1278,7 @@ CompletableFuture completableFuture = CompletableFuture.supplyAsync( () -> selectedIds.stream().map(this.packRepository::getPack).filter(Objects::nonNull).map(Pack::open).collect(ImmutableList.toImmutableList()), this -@@ -1555,7 +_,7 @@ +@@ -1557,7 +_,7 @@ .thenCompose( list -> { CloseableResourceManager closeableResourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, list); @@ -1287,7 +1287,7 @@ return ReloadableServerResources.loadResources( closeableResourceManager, this.registries, -@@ -1576,20 +_,39 @@ +@@ -1578,20 +_,39 @@ ) .thenAcceptAsync( reloadableResources -> { @@ -1329,7 +1329,7 @@ }, this ); -@@ -1606,7 +_,7 @@ +@@ -1608,7 +_,7 @@ DataPackConfig dataPackConfig = initialDataConfig.dataPacks(); FeatureFlagSet featureFlagSet = initMode ? FeatureFlagSet.of() : initialDataConfig.enabledFeatures(); FeatureFlagSet featureFlagSet1 = initMode ? FeatureFlags.REGISTRY.allFlags() : initialDataConfig.enabledFeatures(); @@ -1338,7 +1338,7 @@ if (safeMode) { return configureRepositoryWithSelection(packRepository, List.of("vanilla"), featureFlagSet, false); } else { -@@ -1661,7 +_,7 @@ +@@ -1663,7 +_,7 @@ private static WorldDataConfiguration configureRepositoryWithSelection( PackRepository packRepository, Collection selectedPacks, FeatureFlagSet enabledFeatures, boolean safeMode ) { @@ -1347,7 +1347,7 @@ enableForcedFeaturePacks(packRepository, enabledFeatures); DataPackConfig selectedPacks1 = getSelectedPacks(packRepository, safeMode); FeatureFlagSet featureFlagSet = packRepository.getRequestedFeatureFlags().join(enabledFeatures); -@@ -1693,7 +_,7 @@ +@@ -1695,7 +_,7 @@ } } @@ -1356,7 +1356,7 @@ } } -@@ -1710,8 +_,8 @@ +@@ -1712,8 +_,8 @@ UserWhiteList whiteList = playerList.getWhiteList(); for (ServerPlayer serverPlayer : Lists.newArrayList(playerList.getPlayers())) { @@ -1367,7 +1367,7 @@ } } } -@@ -1741,12 +_,12 @@ +@@ -1743,12 +_,12 @@ } public ServerLevel findRespawnDimension() { @@ -1382,7 +1382,7 @@ public void setRespawnData(LevelData.RespawnData respawnData) { ServerLevelData serverLevelData = this.worldData.overworldData(); LevelData.RespawnData respawnData1 = serverLevelData.getRespawnData(); -@@ -1948,6 +_,17 @@ +@@ -1950,6 +_,17 @@ } } @@ -1400,7 +1400,7 @@ private ProfilerFiller createProfiler() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted( -@@ -2069,16 +_,22 @@ +@@ -2071,16 +_,22 @@ } public void logChatMessage(Component content, ChatType.Bound boundChatType, @Nullable String header) { @@ -1427,7 +1427,7 @@ } public boolean logIPs() { -@@ -2089,8 +_,9 @@ +@@ -2091,8 +_,9 @@ LOGGER.debug("Received custom click action {} with payload {}", id, payload.orElse(null)); } @@ -1438,7 +1438,7 @@ } public boolean setAutoSave(boolean autoSave) { -@@ -2116,8 +_,9 @@ +@@ -2118,8 +_,9 @@ return false; } @@ -1449,7 +1449,7 @@ } public boolean acceptsTransfers() { -@@ -2251,4 +_,53 @@ +@@ -2253,4 +_,53 @@ }; } } diff --git a/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch index 5c5602ee100f..6a0d5e35ae9b 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/commands/SetSpawnCommand.java +++ b/net/minecraft/server/commands/SetSpawnCommand.java -@@ -73,24 +_,34 @@ - float f = rotation.y; - float f1 = rotation.x; +@@ -74,24 +_,34 @@ + float f = Mth.wrapDegrees(rotation.y); + float f1 = Mth.clamp(rotation.x, -90.0F, 90.0F); + final Collection actualTargets = new java.util.ArrayList<>(); // Paper - Add PlayerSetSpawnEvent for (ServerPlayer serverPlayer : targets) { diff --git a/paper-server/patches/sources/net/minecraft/server/commands/WaypointCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/WaypointCommand.java.patch index c5eb7abe8e42..e24fe52eb569 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/WaypointCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/WaypointCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/WaypointCommand.java +++ b/net/minecraft/server/commands/WaypointCommand.java -@@ -165,7 +_,7 @@ +@@ -168,7 +_,7 @@ } private static void mutateIcon(CommandSourceStack source, WaypointTransmitter waypoint, Consumer mutator) { diff --git a/paper-server/patches/sources/net/minecraft/server/gui/StatsComponent.java.patch b/paper-server/patches/sources/net/minecraft/server/gui/StatsComponent.java.patch index ab6d2d8cb54e..d1bc8cfa66c7 100644 --- a/paper-server/patches/sources/net/minecraft/server/gui/StatsComponent.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/gui/StatsComponent.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/gui/StatsComponent.java +++ b/net/minecraft/server/gui/StatsComponent.java -@@ -34,8 +_,17 @@ +@@ -31,8 +_,17 @@ private void tick() { long l = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); @@ -18,7 +18,7 @@ this.values[this.vp++ & 0xFF] = (int)(l * 100L / Runtime.getRuntime().maxMemory()); this.repaint(); } -@@ -64,4 +_,10 @@ +@@ -61,4 +_,10 @@ public void close() { this.timer.stop(); } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch index d1bb7820bdc7..8f4c256a0a51 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -147,6 +_,33 @@ +@@ -151,6 +_,33 @@ public int serverViewDistance; private final WorldGenContext worldGenContext; @@ -34,7 +34,7 @@ public ChunkMap( ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorageAccess, -@@ -173,13 +_,19 @@ +@@ -179,13 +_,19 @@ this.level = level; RegistryAccess registryAccess = level.registryAccess(); long seed = level.getSeed(); @@ -56,7 +56,7 @@ this.mainThreadExecutor = mainThreadExecutor; ConsecutiveExecutor consecutiveExecutor = new ConsecutiveExecutor(dispatcher, "worldgen"); this.chunkStatusListener = chunkStatusListener; -@@ -209,6 +_,12 @@ +@@ -214,6 +_,12 @@ this.chunksToEagerlySave.add(chunkPos.toLong()); } @@ -69,7 +69,7 @@ protected ChunkGenerator generator() { return this.worldGenContext.generator(); } -@@ -354,9 +_,9 @@ +@@ -359,9 +_,9 @@ } ); stringBuilder.append("Updating:").append(System.lineSeparator()); @@ -81,7 +81,7 @@ CrashReport crashReport = CrashReport.forThrowable(exception, "Chunk loading"); CrashReportCategory crashReportCategory = crashReport.addCategory("Chunk loading"); crashReportCategory.setDetail("Details", details); -@@ -392,6 +_,7 @@ +@@ -397,6 +_,7 @@ holder.setTicketLevel(newLevel); } else { holder = new ChunkHolder(new ChunkPos(chunkPos), newLevel, this.level, this.lightEngine, this::onLevelChange, this); @@ -89,7 +89,7 @@ } this.updatingChunkMap.put(chunkPos, holder); -@@ -420,8 +_,8 @@ +@@ -425,8 +_,8 @@ protected void saveAllChunks(boolean flush) { if (flush) { @@ -100,7 +100,7 @@ .stream() .filter(ChunkHolder::wasAccessibleSinceLastSave) .peek(ChunkHolder::refreshAccessibility) -@@ -447,7 +_,7 @@ +@@ -452,7 +_,7 @@ this.nextChunkSaveTime.clear(); long millis = Util.getMillis(); @@ -109,7 +109,7 @@ this.saveChunkIfNeeded(chunkHolder, millis); } } -@@ -468,6 +_,7 @@ +@@ -473,6 +_,7 @@ public boolean hasWork() { return this.lightEngine.hasLightWork() || !this.pendingUnloads.isEmpty() @@ -117,7 +117,7 @@ || !this.updatingChunkMap.isEmpty() || this.poiManager.hasWork() || !this.toDrop.isEmpty() -@@ -526,7 +_,11 @@ +@@ -531,7 +_,11 @@ this.scheduleUnload(chunkPos, chunkHolder); } else { ChunkAccess latestChunk = chunkHolder.getLatestChunk(); @@ -130,7 +130,7 @@ if (latestChunk instanceof LevelChunk levelChunk) { levelChunk.setLoaded(false); } -@@ -539,7 +_,9 @@ +@@ -544,7 +_,9 @@ this.lightEngine.updateChunkStatus(latestChunk.getPos()); this.lightEngine.tryScheduleUpdate(); this.nextChunkSaveTime.remove(latestChunk.getPos().toLong()); @@ -141,7 +141,7 @@ } }, this.unloadQueue::add).whenComplete((_void, error) -> { if (error != null) { -@@ -847,7 +_,7 @@ +@@ -852,7 +_,7 @@ } public int size() { @@ -150,7 +150,7 @@ } public net.minecraft.server.level.DistanceManager getDistanceManager() { -@@ -874,10 +_,10 @@ +@@ -879,10 +_,10 @@ .addColumn("fluid_ticks") .build(writer); @@ -164,24 +164,23 @@ Optional optional = Optional.ofNullable(chunkHolder.getLatestChunk()); Optional optional1 = optional.flatMap(chunk -> chunk instanceof LevelChunk ? Optional.of((LevelChunk)chunk) : Optional.empty()); csvOutput.writeRow( -@@ -917,11 +_,13 @@ +@@ -926,12 +_,12 @@ } - private CompletableFuture> readChunk(ChunkPos pos) { -- return this.read(pos).thenApplyAsync(optional -> optional.map(this::upgradeChunkTag), Util.backgroundExecutor().forName("upgradeChunk")); -+ return this.read(pos).thenApplyAsync(optional -> optional.map(tag -> upgradeChunkTag(tag, pos)), Util.backgroundExecutor().forName("upgradeChunk")); // CraftBukkit + private CompoundTag upgradeChunkTag(CompoundTag tag) { +- return this.upgradeChunkTag(tag, -1, getChunkDataFixContextTag(this.level.dimension(), this.generator().getTypeNameForDataFixer())); ++ return this.upgradeChunkTag(tag, -1, getChunkDataFixContextTag(this.level.getTypeKey(), this.generator().getTypeNameForDataFixer()), this.level); // CraftBukkit } -- private CompoundTag upgradeChunkTag(CompoundTag tag) { -- return this.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, tag, this.generator().getTypeNameForDataFixer()); -+ // CraftBukkit start -+ private CompoundTag upgradeChunkTag(CompoundTag tag, ChunkPos pos) { -+ return this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, tag, this.generator().getTypeNameForDataFixer(), pos, this.level); -+ // CraftBukkit end +- public static CompoundTag getChunkDataFixContextTag(ResourceKey dimension, Optional>> generator) { ++ public static CompoundTag getChunkDataFixContextTag(ResourceKey stemKey, Optional>> generator) { // CraftBukkit + CompoundTag compoundTag = new CompoundTag(); +- compoundTag.putString("dimension", dimension.location().toString()); ++ compoundTag.putString("dimension", stemKey.location().toString()); // CraftBukkit + generator.ifPresent(resourceKey -> compoundTag.putString("generator", resourceKey.location().toString())); + return compoundTag; } - - void collectSpawningChunks(List output) { -@@ -931,7 +_,7 @@ +@@ -943,7 +_,7 @@ ChunkHolder chunkHolder = this.visibleChunkMap.get(spawnCandidateChunks.nextLong()); if (chunkHolder != null) { LevelChunk tickingChunk = chunkHolder.getTickingChunk(); @@ -190,7 +189,7 @@ output.add(tickingChunk); } } -@@ -951,13 +_,35 @@ +@@ -963,13 +_,35 @@ } public boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkPos) { @@ -228,7 +227,7 @@ return true; } } -@@ -973,7 +_,7 @@ +@@ -985,7 +_,7 @@ Builder builder = ImmutableList.builder(); for (ServerPlayer serverPlayer : this.playerMap.getAllPlayers()) { @@ -237,7 +236,7 @@ builder.add(serverPlayer); } } -@@ -982,12 +_,12 @@ +@@ -994,12 +_,12 @@ } } @@ -252,7 +251,7 @@ } } -@@ -1109,9 +_,19 @@ +@@ -1121,9 +_,19 @@ } public void addEntity(Entity entity) { @@ -272,7 +271,7 @@ if (i != 0) { int updateInterval = type.updateInterval(); if (this.entityMap.containsKey(entity.getId())) { -@@ -1135,6 +_,7 @@ +@@ -1147,6 +_,7 @@ } protected void removeEntity(Entity entity) { @@ -280,7 +279,7 @@ if (entity instanceof ServerPlayer serverPlayer) { this.updatePlayerStatus(serverPlayer, false); -@@ -1296,10 +_,10 @@ +@@ -1308,10 +_,10 @@ final Entity entity; private final int range; SectionPos lastSectionPos; @@ -293,7 +292,7 @@ this.entity = entity; this.range = range; this.lastSectionPos = SectionPos.of(entity); -@@ -1346,6 +_,7 @@ +@@ -1358,6 +_,7 @@ } public void removePlayer(ServerPlayer player) { @@ -301,7 +300,7 @@ if (this.seenBy.remove(player.connection)) { this.serverEntity.removePairing(player); if (this.seenBy.isEmpty()) { -@@ -1355,23 +_,45 @@ +@@ -1367,23 +_,45 @@ } public void updatePlayer(ServerPlayer player) { @@ -352,7 +351,7 @@ } } else { this.removePlayer(player); -@@ -1388,6 +_,7 @@ +@@ -1400,6 +_,7 @@ for (Entity entity : this.entity.getIndirectPassengers()) { int i1 = entity.getType().clientTrackingRange() * 16; diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch index 56f78b6b8eaa..ddcca2e71b07 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -933,7 +933,7 @@ return null; } else { Optional> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag); -@@ -1423,10 +_,36 @@ +@@ -1425,10 +_,36 @@ @Nullable @Override public MapItemSavedData getMapData(MapId mapId) { @@ -971,7 +971,7 @@ this.getServer().overworld().getDataStorage().set(MapItemSavedData.type(mapId), data); } -@@ -1436,7 +_,19 @@ +@@ -1438,7 +_,19 @@ @Override public void setRespawnData(LevelData.RespawnData respawnData) { @@ -992,7 +992,7 @@ } @Override -@@ -1473,6 +_,11 @@ +@@ -1475,6 +_,11 @@ this.debugSynchronizers.dropPoi(blockPos); })); optional1.ifPresent(holder -> this.getServer().execute(() -> { @@ -1004,7 +1004,7 @@ PoiRecord poiRecord = this.getPoiManager().add(blockPos, (Holder)holder); if (poiRecord != null) { this.debugSynchronizers.registerPoi(poiRecord); -@@ -1627,12 +_,12 @@ +@@ -1629,12 +_,12 @@ } public boolean isFlat() { @@ -1019,7 +1019,7 @@ } @Nullable -@@ -1683,6 +_,7 @@ +@@ -1685,6 +_,7 @@ @Override public LevelEntityGetter getEntities() { @@ -1027,7 +1027,7 @@ return this.entityManager.getEntityGetter(); } -@@ -1793,6 +_,28 @@ +@@ -1795,6 +_,28 @@ return this.serverLevelData.getGameRules(); } @@ -1056,7 +1056,7 @@ @Override public CrashReportCategory fillReportDetails(CrashReport report) { CrashReportCategory crashReportCategory = super.fillReportDetails(report); -@@ -1837,6 +_,7 @@ +@@ -1839,6 +_,7 @@ if (entity instanceof WaypointTransmitter waypointTransmitter && waypointTransmitter.isTransmittingWaypoint()) { ServerLevel.this.getWaypointManager().trackWaypoint(waypointTransmitter); } @@ -1064,7 +1064,7 @@ } @Override -@@ -1850,17 +_,24 @@ +@@ -1852,17 +_,24 @@ @Override public void onTickingStart(Entity entity) { @@ -1090,7 +1090,7 @@ if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.add(serverPlayer); if (serverPlayer.isReceivingWaypoints()) { -@@ -1875,7 +_,7 @@ +@@ -1877,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1099,7 +1099,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1892,10 +_,52 @@ +@@ -1894,10 +_,52 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -1152,7 +1152,7 @@ ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); -@@ -1904,7 +_,7 @@ +@@ -1906,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1161,7 +1161,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1922,6 +_,15 @@ +@@ -1924,6 +_,15 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); ServerLevel.this.debugSynchronizers.dropEntity(entity); @@ -1177,7 +1177,7 @@ } @Override -@@ -1929,4 +_,24 @@ +@@ -1931,4 +_,24 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::move); } } diff --git a/paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch b/paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch new file mode 100644 index 000000000000..4afd453e3754 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch @@ -0,0 +1,40 @@ +--- a/net/minecraft/server/network/EventLoopGroupHolder.java ++++ b/net/minecraft/server/network/EventLoopGroupHolder.java +@@ -38,15 +_,37 @@ + return LocalIoHandler.newFactory(); + } + }; ++ // Paper start - Unix domain socket support ++ private static final EventLoopGroupHolder EPOLL_UNIX_DOMAIN = new EventLoopGroupHolder("Unix Domain Socket", io.netty.channel.epoll.EpollDomainSocketChannel.class, io.netty.channel.epoll.EpollServerDomainSocketChannel.class) { ++ @Override ++ protected IoHandlerFactory ioHandlerFactory() { ++ return EpollIoHandler.newFactory(); ++ } ++ }; ++ // Paper end - Unix domain socket support + private final String type; + private final Class channelCls; + private final Class serverChannelCls; + @Nullable + private volatile EventLoopGroup group; + ++ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - use variant with address param + public static EventLoopGroupHolder remote(boolean tryNativeTransport) { + return tryNativeTransport && Epoll.isAvailable() ? EPOLL : NIO; + } ++ ++ // Paper start - Unix domain socket support ++ public static EventLoopGroupHolder remote(java.net.SocketAddress address, boolean tryNativeTransport) { ++ if (tryNativeTransport && Epoll.isAvailable()) { ++ if (address instanceof io.netty.channel.unix.DomainSocketAddress) { ++ return EPOLL_UNIX_DOMAIN; ++ } else { ++ return EPOLL; ++ } ++ } ++ return NIO; ++ } ++ // Paper end - Unix domain socket support + + public static EventLoopGroupHolder local() { + return LOCAL; diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch index 88bee1b4283c..d4308c9813fd 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch @@ -1,19 +1,6 @@ --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -50,10 +_,10 @@ - public class ServerConnectionListener { - private static final Logger LOGGER = LogUtils.getLogger(); - public static final Supplier SERVER_EVENT_GROUP = Suppliers.memoize( -- () -> new NioEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Server IO #%d").setDaemon(true).build()) -+ () -> new NioEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Server IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()) // Paper - ); - public static final Supplier SERVER_EPOLL_EVENT_GROUP = Suppliers.memoize( -- () -> new EpollEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).build()) -+ () -> new EpollEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()) // Paper - ); - final MinecraftServer server; - public volatile boolean running; -@@ -65,12 +_,35 @@ +@@ -48,9 +_,31 @@ this.running = true; } @@ -36,34 +23,17 @@ + public void startTcpServerListener(SocketAddress address) throws IOException { + // Paper end - Unix domain socket support synchronized (this.channels) { -- Class clazz; -+ Class clazz; // Paper - Unix domain socket support - EventLoopGroup eventLoopGroup; - if (Epoll.isAvailable() && this.server.isEpollEnabled()) { -+ // Paper start - Unix domain socket support -+ if (address instanceof io.netty.channel.unix.DomainSocketAddress) { -+ clazz = io.netty.channel.epoll.EpollServerDomainSocketChannel.class; -+ } else { - clazz = EpollServerSocketChannel.class; -+ } -+ // Paper end - Unix domain socket support - eventLoopGroup = SERVER_EPOLL_EVENT_GROUP.get(); - LOGGER.info("Using epoll channel type"); - } else { -@@ -79,6 +_,12 @@ - LOGGER.info("Using default channel type"); - } - +- EventLoopGroupHolder eventLoopGroupHolder = EventLoopGroupHolder.remote(this.server.useNativeTransport()); ++ EventLoopGroupHolder eventLoopGroupHolder = EventLoopGroupHolder.remote(address, this.server.useNativeTransport()); // Paper - Unix domain socket support + // Paper start - Warn people with console access that HAProxy is in use. + if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.proxyProtocol) { + LOGGER.warn("Using HAProxy, please ensure the server port is adequately firewalled."); + } + // Paper end - Warn people with console access that HAProxy is in use. -+ this.channels .add( new ServerBootstrap() -@@ -102,22 +_,64 @@ +@@ -74,22 +_,64 @@ Connection connection = (Connection)(rateLimitPacketsPerSecond > 0 ? new RateKickingConnection(rateLimitPacketsPerSecond) : new Connection(PacketFlow.SERVERBOUND)); @@ -107,7 +77,7 @@ } } ) - .group(eventLoopGroup) + .group(eventLoopGroupHolder.eventLoopGroup()) - .localAddress(address, port) + .localAddress(address) // Paper - Unix domain socket support + .option(ChannelOption.AUTO_READ, false) // CraftBukkit @@ -130,7 +100,7 @@ public SocketAddress startMemoryChannel() { ChannelFuture channelFuture; synchronized (this.channels) { -@@ -169,6 +_,13 @@ +@@ -141,6 +_,13 @@ public void tick() { synchronized (this.connections) { @@ -144,7 +114,7 @@ Iterator iterator = this.connections.iterator(); while (iterator.hasNext()) { -@@ -188,6 +_,7 @@ +@@ -160,6 +_,7 @@ connection.setReadOnly(); } } else { diff --git a/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch b/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch index a3f47d46dee6..cdbf2f1a6c97 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/CachedUserNameToIdResolver.java +++ b/net/minecraft/server/players/CachedUserNameToIdResolver.java -@@ -45,6 +_,10 @@ +@@ -46,6 +_,10 @@ private final Gson gson = new GsonBuilder().create(); private final File file; private final AtomicLong operationCount = new AtomicLong(); @@ -11,7 +11,7 @@ public CachedUserNameToIdResolver(GameProfileRepository profileRepository, File file) { this.profileRepository = profileRepository; -@@ -53,23 +_,27 @@ +@@ -54,23 +_,27 @@ } private void safeAdd(CachedUserNameToIdResolver.GameProfileInfo profileInfo) { @@ -41,7 +41,7 @@ } @Override -@@ -89,7 +_,7 @@ +@@ -90,7 +_,7 @@ Date time = instance.getTime(); CachedUserNameToIdResolver.GameProfileInfo gameProfileInfo = new CachedUserNameToIdResolver.GameProfileInfo(nameAndId, time); this.safeAdd(gameProfileInfo); @@ -50,7 +50,7 @@ return gameProfileInfo; } -@@ -97,9 +_,24 @@ +@@ -98,9 +_,24 @@ return this.operationCount.incrementAndGet(); } @@ -75,7 +75,7 @@ CachedUserNameToIdResolver.GameProfileInfo gameProfileInfo = this.profilesByName.get(string); boolean flag = false; if (gameProfileInfo != null && new Date().getTime() >= gameProfileInfo.expirationDate.getTime()) { -@@ -113,8 +_,13 @@ +@@ -114,8 +_,13 @@ if (gameProfileInfo != null) { gameProfileInfo.setLastAccess(this.getNextOperation()); optional = Optional.of(gameProfileInfo.nameAndId()); @@ -90,7 +90,7 @@ if (optional1.isPresent()) { optional = Optional.of(this.addInternal(optional1.get()).nameAndId()); flag = false; -@@ -123,15 +_,17 @@ +@@ -124,15 +_,17 @@ } } @@ -110,7 +110,7 @@ CachedUserNameToIdResolver.GameProfileInfo gameProfileInfo = this.profilesByUUID.get(uuid); if (gameProfileInfo == null) { return Optional.empty(); -@@ -139,6 +_,7 @@ +@@ -140,6 +_,7 @@ gameProfileInfo.setLastAccess(this.getNextOperation()); return Optional.of(gameProfileInfo.nameAndId()); } @@ -118,7 +118,7 @@ } private static DateFormat createDateFormat() { -@@ -163,6 +_,11 @@ +@@ -164,6 +_,11 @@ return (List)var9; } catch (FileNotFoundException var7) { @@ -130,7 +130,7 @@ } catch (JsonParseException | IOException var8) { LOGGER.warn("Failed to load profile cache {}", this.file, var8); } -@@ -172,23 +_,51 @@ +@@ -173,23 +_,51 @@ @Override public void save() { diff --git a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch index 7d4a6b0d8807..18b2539e382b 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -110,14 +_,16 @@ +@@ -111,14 +_,16 @@ private static final int SEND_PLAYER_INFO_INTERVAL = 600; - private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); + private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z", Locale.ROOT); private final MinecraftServer server; - public final List players = Lists.newArrayList(); + public final List players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety @@ -20,7 +20,7 @@ public final PlayerDataStorage playerIo; private final LayeredRegistryAccess registries; private int viewDistance; -@@ -125,9 +_,17 @@ +@@ -126,9 +_,17 @@ private boolean allowCommandsForAllPlayers; private int sendAllPlayerInfoIn; @@ -38,7 +38,7 @@ this.server = server; this.registries = registries; this.playerIo = playerIo; -@@ -137,23 +_,19 @@ +@@ -138,23 +_,19 @@ this.ipBans = new IpBanList(IPBANLIST_FILE, notificationService); } @@ -67,7 +67,7 @@ LevelData levelData = serverLevel.getLevelData(); ServerGamePacketListenerImpl serverGamePacketListenerImpl = new ServerGamePacketListenerImpl(this.server, connection, player, cookie); connection.setupInboundProtocol( -@@ -171,8 +_,8 @@ +@@ -172,8 +_,8 @@ levelData.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), @@ -78,7 +78,7 @@ _boolean1, !_boolean, _boolean2, -@@ -180,6 +_,7 @@ +@@ -181,6 +_,7 @@ this.server.enforceSecureProfile() ) ); @@ -86,7 +86,7 @@ serverGamePacketListenerImpl.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); serverGamePacketListenerImpl.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities())); serverGamePacketListenerImpl.send(new ClientboundSetHeldSlotPacket(player.getInventory().getSelectedSlot())); -@@ -199,24 +_,129 @@ +@@ -200,24 +_,129 @@ mutableComponent = Component.translatable("multiplayer.player.joined.renamed", player.getDisplayName(), string); } @@ -220,7 +220,7 @@ } public void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) { -@@ -238,31 +_,40 @@ +@@ -239,31 +_,40 @@ } } @@ -242,7 +242,7 @@ } @Override - public void onLerpSize(WorldBorder border, double oldSize, double newSize, long time) { + public void onLerpSize(WorldBorder border, double oldSize, double newSize, long time, long gameTime) { - PlayerList.this.broadcastAll(new ClientboundSetBorderLerpSizePacket(border), level.dimension()); + PlayerList.this.broadcastWorldborder(new ClientboundSetBorderLerpSizePacket(border), level.dimension()); // Paper - virtual world border API } @@ -266,7 +266,7 @@ } @Override -@@ -286,57 +_,137 @@ +@@ -287,57 +_,137 @@ } protected void save(ServerPlayer player) { @@ -418,7 +418,7 @@ MutableComponent mutableComponent = Component.translatable("multiplayer.disconnect.banned.reason", userBanListEntry.getReasonMessage()); if (userBanListEntry.getExpires() != null) { mutableComponent.append( -@@ -344,9 +_,11 @@ +@@ -345,9 +_,11 @@ ); } @@ -433,7 +433,7 @@ } else if (this.ipBans.isBanned(socketAddress)) { IpBanListEntry ipBanListEntry = this.ipBans.get(socketAddress); MutableComponent mutableComponent = Component.translatable("multiplayer.disconnect.banned_ip.reason", ipBanListEntry.getReasonMessage()); -@@ -356,19 +_,18 @@ +@@ -357,19 +_,18 @@ ); } @@ -458,7 +458,7 @@ set.add(serverPlayer); } } -@@ -379,41 +_,87 @@ +@@ -380,41 +_,87 @@ } for (ServerPlayer serverPlayer2 : set) { @@ -557,7 +557,7 @@ serverPlayer.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); serverPlayer.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); serverPlayer.connection -@@ -421,10 +_,13 @@ +@@ -422,10 +_,13 @@ this.sendActivePlayerEffects(serverPlayer); this.sendLevelInfo(serverPlayer, level); this.sendPlayerPermissionLevel(serverPlayer); @@ -575,7 +575,7 @@ serverPlayer.setHealth(serverPlayer.getHealth()); ServerPlayer.RespawnConfig respawnConfig = serverPlayer.getRespawnConfig(); if (!keepInventory && respawnConfig != null) { -@@ -448,8 +_,52 @@ +@@ -449,8 +_,52 @@ ) ); } @@ -628,7 +628,7 @@ return serverPlayer; } -@@ -459,23 +_,58 @@ +@@ -460,23 +_,58 @@ } public void sendActiveEffects(LivingEntity entity, ServerGamePacketListenerImpl connection) { @@ -690,7 +690,7 @@ public void broadcastAll(Packet packet) { for (ServerPlayer serverPlayer : this.players) { serverPlayer.connection.send(packet); -@@ -561,6 +_,12 @@ +@@ -562,6 +_,12 @@ } private void sendPlayerPermissionLevel(ServerPlayer player, LevelBasedPermissionSet permissions) { @@ -703,7 +703,7 @@ if (player.connection != null) { byte b = switch (permissions.level()) { case ALL -> 24; -@@ -572,9 +_,48 @@ +@@ -573,9 +_,48 @@ player.connection.send(new ClientboundEntityEventPacket(player, b)); } @@ -754,7 +754,7 @@ public boolean isWhiteListed(NameAndId nameAndId) { return !this.isUsingWhitelist() || this.ops.contains(nameAndId) || this.whitelist.contains(nameAndId); } -@@ -587,21 +_,17 @@ +@@ -588,21 +_,17 @@ @Nullable public ServerPlayer getPlayerByName(String username) { @@ -782,7 +782,7 @@ if (serverPlayer != except && serverPlayer.level().dimension() == dimension) { double d = x - serverPlayer.getX(); double d1 = y - serverPlayer.getY(); -@@ -614,9 +_,11 @@ +@@ -615,9 +_,11 @@ } public void saveAll() { @@ -794,7 +794,7 @@ } public UserWhiteList getWhiteList() { -@@ -644,9 +_,13 @@ +@@ -645,9 +_,13 @@ player.connection.send(new ClientboundSetTimePacket(level.getGameTime(), level.getDayTime(), level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); if (level.isRaining()) { @@ -811,7 +811,7 @@ } player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F)); -@@ -655,8 +_,21 @@ +@@ -656,8 +_,21 @@ public void sendAllPlayerInfo(ServerPlayer player) { player.inventoryMenu.sendAllDataToRemote(); @@ -834,7 +834,7 @@ } public int getPlayerCount() { -@@ -705,9 +_,26 @@ +@@ -706,9 +_,26 @@ } public void removeAll() { @@ -864,7 +864,7 @@ } public void broadcastSystemMessage(Component message, boolean overlay) { -@@ -730,20 +_,39 @@ +@@ -731,20 +_,39 @@ } public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound boundChatType) { @@ -907,7 +907,7 @@ flag1 |= flag2 && message.isFullyFiltered(); } -@@ -756,15 +_,21 @@ +@@ -757,15 +_,21 @@ return message.hasSignature() && !message.hasExpiredServer(Instant.now()); } @@ -934,7 +934,7 @@ Path path = file2.toPath(); if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { file2.renameTo(file1); -@@ -772,7 +_,7 @@ +@@ -773,7 +_,7 @@ } serverStatsCounter = new ServerStatsCounter(this.server, file1); @@ -943,7 +943,7 @@ } return serverStatsCounter; -@@ -780,11 +_,11 @@ +@@ -781,11 +_,11 @@ public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) { UUID uuid = player.getUUID(); @@ -957,7 +957,7 @@ } playerAdvancements.setPlayer(player); -@@ -838,11 +_,34 @@ +@@ -839,11 +_,34 @@ } public void reloadResources() { diff --git a/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch b/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch index 77d62fe93850..bc8cee0c23f9 100644 --- a/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/worldupdate/WorldUpgrader.java +++ b/net/minecraft/util/worldupdate/WorldUpgrader.java -@@ -86,7 +_,7 @@ +@@ -89,7 +_,7 @@ boolean recreateRegionFiles ) { this.dimensions = registryAccess.lookupOrThrow(Registries.LEVEL_STEM); @@ -9,12 +9,12 @@ this.eraseCache = eraseCache; this.dataFixer = dataFixer; this.levelStorage = levelStorage; -@@ -365,7 +_,7 @@ - int version = ChunkStorage.getVersion(compoundTag); +@@ -368,7 +_,7 @@ + int dataVersion = NbtUtils.getDataVersion(compoundTag); ChunkGenerator chunkGenerator = WorldUpgrader.this.dimensions.getValueOrThrow(Registries.levelToLevelStem(dimension)).generator(); - CompoundTag compoundTag1 = chunkStorage.upgradeChunkTag( -- dimension, () -> WorldUpgrader.this.overworldDataStorage, compoundTag, chunkGenerator.getTypeNameForDataFixer() -+ Registries.levelToLevelStem(dimension), () -> WorldUpgrader.this.overworldDataStorage, compoundTag, chunkGenerator.getTypeNameForDataFixer(), chunkPos, null // CraftBukkit + CompoundTag compoundTag1 = regionStorage.upgradeChunkTag( +- compoundTag, -1, ChunkMap.getChunkDataFixContextTag(dimension, chunkGenerator.getTypeNameForDataFixer()) ++ compoundTag, -1, ChunkMap.getChunkDataFixContextTag(Registries.levelToLevelStem(dimension), chunkGenerator.getTypeNameForDataFixer()), null // CraftBukkit ); ChunkPos chunkPos1 = new ChunkPos(compoundTag1.getIntOr("xPos", 0), compoundTag1.getIntOr("zPos", 0)); if (!chunkPos1.equals(chunkPos)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch index e542ba5ef532..563af7155d24 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -125,16 +125,15 @@ private final double[] pistonDeltas = new double[]{0.0, 0.0, 0.0}; private long pistonDeltasGameTime; private EntityDimensions dimensions; -@@ -277,7 +_,7 @@ - private boolean onGroundNoBlocks = false; - private float crystalSoundIntensity; - private int lastCrystalSoundPlayTick; -- public boolean hasVisualFire; +@@ -281,6 +_,7 @@ + private Vec3 lastKnownMovement = Vec3.ZERO; + @Nullable + private Vec3 lastKnownPosition; + public net.kyori.adventure.util.TriState visualFire = net.kyori.adventure.util.TriState.NOT_SET; // Paper - improve visual fire API @Nullable private BlockState inBlockState = null; public static final int MAX_MOVEMENTS_HANDELED_PER_TICK = 100; -@@ -286,6 +_,41 @@ +@@ -289,6 +_,41 @@ private final LongSet visitedBlocks = new LongOpenHashSet(); private final InsideBlockEffectApplier.StepBasedCollector insideEffectCollector = new InsideBlockEffectApplier.StepBasedCollector(); private CustomData customData = CustomData.EMPTY; @@ -176,7 +175,7 @@ public Entity(EntityType type, Level level) { this.type = type; -@@ -307,6 +_,7 @@ +@@ -310,6 +_,7 @@ this.entityData = builder.build(); this.setPos(0.0, 0.0, 0.0); this.eyeHeight = this.dimensions.eyeHeight(); @@ -184,7 +183,7 @@ } public boolean isColliding(BlockPos pos, BlockState state) { -@@ -319,6 +_,12 @@ +@@ -322,6 +_,12 @@ return team != null && team.getColor().getColor() != null ? team.getColor().getColor() : 16777215; } @@ -197,7 +196,7 @@ public boolean isSpectator() { return false; } -@@ -371,7 +_,7 @@ +@@ -374,7 +_,7 @@ } public boolean addTag(String tag) { @@ -206,7 +205,7 @@ } public boolean removeTag(String tag) { -@@ -379,12 +_,18 @@ +@@ -382,12 +_,18 @@ } public void kill(ServerLevel level) { @@ -227,7 +226,7 @@ } protected abstract void defineSynchedData(SynchedEntityData.Builder builder); -@@ -393,6 +_,48 @@ +@@ -396,6 +_,48 @@ return this.entityData; } @@ -276,7 +275,7 @@ @Override public boolean equals(Object other) { return other instanceof Entity && ((Entity)other).id == this.id; -@@ -404,7 +_,13 @@ +@@ -407,7 +_,13 @@ } public void remove(Entity.RemovalReason reason) { @@ -291,7 +290,7 @@ } public void onClientRemoval() { -@@ -414,6 +_,15 @@ +@@ -417,6 +_,15 @@ } public void setPose(Pose pose) { @@ -307,7 +306,7 @@ this.entityData.set(DATA_POSE, pose); } -@@ -437,6 +_,32 @@ +@@ -440,6 +_,32 @@ } public void setRot(float yRot, float xRot) { @@ -340,7 +339,7 @@ this.setYRot(yRot % 360.0F); this.setXRot(xRot % 360.0F); } -@@ -446,8 +_,8 @@ +@@ -449,8 +_,8 @@ } public void setPos(double x, double y, double z) { @@ -351,7 +350,7 @@ } protected final AABB makeBoundingBox() { -@@ -480,12 +_,28 @@ +@@ -483,12 +_,28 @@ } public void tick() { @@ -377,10 +376,10 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("entityBaseTick"); + if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Prevent entity loading causing async lookups - this.inBlockState = null; - if (this.isPassenger() && this.getVehicle().isRemoved()) { - this.stopRiding(); -@@ -495,7 +_,7 @@ + if (this.lastKnownPosition == null) { + this.lastKnownPosition = this.position(); + } +@@ -505,7 +_,7 @@ this.boardingCooldown--; } @@ -389,7 +388,7 @@ if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -523,6 +_,10 @@ +@@ -533,6 +_,10 @@ if (this.isInLava()) { this.fallDistance *= 0.5; @@ -400,7 +399,7 @@ } this.checkBelowWorld(); -@@ -539,11 +_,16 @@ +@@ -549,11 +_,16 @@ } public void setSharedFlagOnFire(boolean isOnFire) { @@ -419,7 +418,7 @@ this.onBelowWorld(); } } -@@ -571,15 +_,41 @@ +@@ -581,15 +_,41 @@ } public void lavaIgnite() { @@ -463,7 +462,7 @@ && this.shouldPlayLavaHurtSound() && !this.isSilent()) { serverLevel.playSound( -@@ -594,6 +_,20 @@ +@@ -604,6 +_,20 @@ } public final void igniteForSeconds(float seconds) { @@ -484,7 +483,7 @@ this.igniteForTicks(Mth.floor(seconds * 20.0F)); } -@@ -618,7 +_,7 @@ +@@ -628,7 +_,7 @@ } protected void onBelowWorld() { @@ -493,7 +492,7 @@ } public boolean isFree(double x, double y, double z) { -@@ -674,7 +_,28 @@ +@@ -684,7 +_,28 @@ return this.onGround; } @@ -522,7 +521,7 @@ if (this.noPhysics) { this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); this.horizontalCollision = false; -@@ -757,6 +_,27 @@ +@@ -767,6 +_,27 @@ block.updateEntityMovementAfterFallOn(this.level(), this); } } @@ -550,7 +549,7 @@ if (!this.level().isClientSide() || this.isLocalInstanceAuthoritative()) { Entity.MovementEmission movementEmission = this.getMovementEmission(); -@@ -770,6 +_,13 @@ +@@ -780,6 +_,13 @@ profilerFiller.pop(); } } @@ -564,7 +563,7 @@ } private void applyMovementEmissionAndPlaySound(Entity.MovementEmission movementEmission, Vec3 movement, BlockPos pos, BlockState state) { -@@ -951,7 +_,7 @@ +@@ -961,7 +_,7 @@ } protected BlockPos getOnPos(float yOffset) { @@ -573,7 +572,7 @@ BlockPos blockPos = this.mainSupportingBlockPos.get(); if (!(yOffset > 1.0E-5F)) { return blockPos; -@@ -1206,7 +_,7 @@ +@@ -1216,7 +_,7 @@ if (flag2) { try { boolean flag4 = flag || aabb.intersects(pos); @@ -582,7 +581,7 @@ blockState.entityInside(this.level(), pos, this, stepBasedCollector, flag4); this.onInsideBlock(blockState); } catch (Throwable var20) { -@@ -1220,7 +_,7 @@ +@@ -1230,7 +_,7 @@ } if (flag3) { @@ -591,7 +590,7 @@ blockState.getFluidState().entityInside(this.level(), pos, this, stepBasedCollector); } -@@ -1657,6 +_,7 @@ +@@ -1667,6 +_,7 @@ this.setXRot(Mth.clamp(xRot, -90.0F, 90.0F) % 360.0F); this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); @@ -599,7 +598,7 @@ } public void absSnapTo(double x, double y, double z) { -@@ -1666,6 +_,7 @@ +@@ -1676,6 +_,7 @@ this.yo = y; this.zo = d1; this.setPos(d, y, d1); @@ -607,7 +606,7 @@ } public void snapTo(Vec3 pos) { -@@ -1685,11 +_,19 @@ +@@ -1695,11 +_,19 @@ } public void snapTo(double x, double y, double z, float yRot, float xRot) { @@ -627,7 +626,7 @@ } public final void setOldPosAndRot() { -@@ -1756,6 +_,7 @@ +@@ -1766,6 +_,7 @@ public void push(Entity entity) { if (!this.isPassengerOfSameVehicle(entity)) { if (!entity.noPhysics && !this.noPhysics) { @@ -635,7 +634,7 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double max = Mth.absMax(d, d1); -@@ -1789,7 +_,21 @@ +@@ -1799,7 +_,21 @@ } public void push(double x, double y, double z) { @@ -658,7 +657,7 @@ this.hasImpulse = true; } -@@ -1896,8 +_,20 @@ +@@ -1906,8 +_,20 @@ } public boolean isPushable() { @@ -679,7 +678,7 @@ public void awardKillScore(Entity entity, DamageSource damageSource) { if (entity instanceof ServerPlayer) { -@@ -1924,15 +_,23 @@ +@@ -1934,15 +_,23 @@ } public boolean saveAsPassenger(ValueOutput output) { @@ -707,7 +706,7 @@ return true; } } -@@ -1943,14 +_,35 @@ +@@ -1953,14 +_,35 @@ } public void saveWithoutId(ValueOutput output) { @@ -743,7 +742,7 @@ output.store("Rotation", Vec2.CODEC, new Vec2(this.getYRot(), this.getXRot())); output.putDouble("fall_distance", this.fallDistance); output.putShort("Fire", (short)this.remainingFireTicks); -@@ -1958,7 +_,29 @@ +@@ -1968,7 +_,29 @@ output.putBoolean("OnGround", this.onGround()); output.putBoolean("Invulnerable", this.invulnerable); output.putInt("PortalCooldown", this.portalCooldown); @@ -773,7 +772,7 @@ output.storeNullable("CustomName", ComponentSerialization.CODEC, this.getCustomName()); if (this.isCustomNameVisible()) { output.putBoolean("CustomNameVisible", this.isCustomNameVisible()); -@@ -1981,9 +_,12 @@ +@@ -1991,9 +_,12 @@ output.putInt("TicksFrozen", this.getTicksFrozen()); } @@ -788,7 +787,7 @@ if (!this.tags.isEmpty()) { output.store("Tags", TAG_LIST_CODEC, List.copyOf(this.tags)); -@@ -1993,13 +_,13 @@ +@@ -2003,13 +_,13 @@ output.store("data", CustomData.CODEC, this.customData); } @@ -804,7 +803,7 @@ valueOutputList.discardLast(); } } -@@ -2008,6 +_,34 @@ +@@ -2018,6 +_,34 @@ output.discard("Passengers"); } } @@ -839,7 +838,7 @@ } catch (Throwable var7) { CrashReport crashReport = CrashReport.forThrowable(var7, "Saving entity NBT"); CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being saved"); -@@ -2019,7 +_,7 @@ +@@ -2029,7 +_,7 @@ public void load(ValueInput input) { try { Vec3 vec3 = input.read("Pos", Vec3.CODEC).orElse(Vec3.ZERO); @@ -848,7 +847,7 @@ Vec2 vec2 = input.read("Rotation", Vec2.CODEC).orElse(Vec2.ZERO); this.setDeltaMovement(Math.abs(vec31.x) > 10.0 ? 0.0 : vec31.x, Math.abs(vec31.y) > 10.0 ? 0.0 : vec31.y, Math.abs(vec31.z) > 10.0 ? 0.0 : vec31.z); this.hasImpulse = true; -@@ -2051,7 +_,20 @@ +@@ -2061,7 +_,20 @@ this.setNoGravity(input.getBooleanOr("NoGravity", false)); this.setGlowingTag(input.getBooleanOr("Glowing", false)); this.setTicksFrozen(input.getIntOr("TicksFrozen", 0)); @@ -870,7 +869,7 @@ this.customData = input.read("data", CustomData.CODEC).orElse(CustomData.EMPTY); this.tags.clear(); input.read("Tags", TAG_LIST_CODEC).ifPresent(this.tags::addAll); -@@ -2062,6 +_,59 @@ +@@ -2072,6 +_,59 @@ } else { throw new IllegalStateException("Entity has invalid rotation"); } @@ -930,7 +929,7 @@ } catch (Throwable var7) { CrashReport crashReport = CrashReport.forThrowable(var7, "Loading entity NBT"); CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being loaded"); -@@ -2076,13 +_,24 @@ +@@ -2086,13 +_,24 @@ @Nullable public final String getEncodeId() { @@ -956,7 +955,7 @@ protected abstract void addAdditionalSaveData(ValueOutput output); @Nullable -@@ -2097,11 +_,62 @@ +@@ -2107,11 +_,62 @@ @Nullable public ItemEntity spawnAtLocation(ServerLevel level, ItemStack stack, Vec3 offset) { @@ -1021,7 +1020,7 @@ level.addFreshEntity(itemEntity); return itemEntity; } -@@ -2147,6 +_,15 @@ +@@ -2157,6 +_,15 @@ for (Leashable leashable1 : list) { if (leashable1.canHaveALeashAttachedTo(this)) { @@ -1037,7 +1036,7 @@ leashable1.setLeashedTo(this, true); flag = true; } -@@ -2161,7 +_,7 @@ +@@ -2171,7 +_,7 @@ } ItemStack itemInHand = player.getItemInHand(hand); @@ -1046,7 +1045,7 @@ itemInHand.hurtAndBreak(1, player, hand); return InteractionResult.SUCCESS; } else if (this instanceof Mob mob -@@ -2174,11 +_,13 @@ +@@ -2184,11 +_,13 @@ if (this.isAlive() && this instanceof Leashable leashable2) { if (leashable2.getLeashHolder() == player) { if (!this.level().isClientSide()) { @@ -1064,7 +1063,7 @@ this.gameEvent(GameEvent.ENTITY_INTERACT, player); this.playSound(SoundEvents.LEAD_UNTIED); -@@ -2191,9 +_,22 @@ +@@ -2201,9 +_,22 @@ if (itemInHand1.is(Items.LEAD) && !(leashable2.getLeashHolder() instanceof Player)) { if (!this.level().isClientSide() && leashable2.canHaveALeashAttachedTo(player)) { if (leashable2.isLeashed()) { @@ -1088,7 +1087,7 @@ leashable2.setLeashedTo(player, true); this.playSound(SoundEvents.LEAD_TIED); itemInHand1.shrink(1); -@@ -2208,7 +_,12 @@ +@@ -2218,7 +_,12 @@ } public boolean shearOffAllLeashConnections(@Nullable Player player) { @@ -1102,7 +1101,7 @@ if (flag && this.level() instanceof ServerLevel serverLevel) { serverLevel.playSound(null, this.blockPosition(), SoundEvents.SHEARS_SNIP, player != null ? player.getSoundSource() : this.getSoundSource()); } -@@ -2217,15 +_,38 @@ +@@ -2227,15 +_,38 @@ } public boolean dropAllLeashConnections(@Nullable Player player) { @@ -1145,7 +1144,7 @@ } if (flag) { -@@ -2249,7 +_,9 @@ +@@ -2259,7 +_,9 @@ this.gameEvent(GameEvent.SHEAR, player); this.playSound(equippable.shearingSound().value()); if (this.level() instanceof ServerLevel serverLevel) { @@ -1155,7 +1154,7 @@ CriteriaTriggers.PLAYER_SHEARED_EQUIPMENT.trigger((ServerPlayer)player, itemBySlot, mob); } -@@ -2322,11 +_,11 @@ +@@ -2332,11 +_,11 @@ } public boolean startRiding(Entity entity, boolean force, boolean triggerEvents) { @@ -1169,7 +1168,7 @@ return false; } else { for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) { -@@ -2336,6 +_,27 @@ +@@ -2346,6 +_,27 @@ } if (force || this.canRide(entity) && entity.canAddPassenger(this)) { @@ -1197,7 +1196,7 @@ if (this.isPassenger()) { this.stopRiding(); } -@@ -2368,10 +_,16 @@ +@@ -2378,10 +_,16 @@ } public void removeVehicle() { @@ -1215,7 +1214,7 @@ Entity.RemovalReason removalReason = this.getRemovalReason(); if (removalReason == null || removalReason.shouldDestroy()) { this.level().gameEvent(this, GameEvent.ENTITY_DISMOUNT, entity.position); -@@ -2380,7 +_,13 @@ +@@ -2390,7 +_,13 @@ } public void stopRiding() { @@ -1230,7 +1229,7 @@ } protected void addPassenger(Entity passenger) { -@@ -2402,10 +_,43 @@ +@@ -2412,10 +_,43 @@ } } @@ -1275,7 +1274,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == passenger) { this.passengers = ImmutableList.of(); } else { -@@ -2414,6 +_,7 @@ +@@ -2424,6 +_,7 @@ passenger.boardingCooldown = 60; } @@ -1283,7 +1282,7 @@ } protected boolean canAddPassenger(Entity passenger) { -@@ -2514,7 +_,8 @@ +@@ -2524,7 +_,8 @@ TeleportTransition portalDestination = this.portalProcess.getPortalDestination(serverLevel, this); if (portalDestination != null) { ServerLevel level = portalDestination.newLevel(); @@ -1293,7 +1292,7 @@ ) { this.teleport(portalDestination); -@@ -2597,7 +_,7 @@ +@@ -2607,7 +_,7 @@ } public boolean isCrouching() { @@ -1302,7 +1301,7 @@ } public boolean isSprinting() { -@@ -2613,7 +_,7 @@ +@@ -2623,7 +_,7 @@ } public boolean isVisuallySwimming() { @@ -1311,7 +1310,7 @@ } public boolean isVisuallyCrawling() { -@@ -2621,6 +_,13 @@ +@@ -2631,6 +_,13 @@ } public void setSwimming(boolean swimming) { @@ -1325,7 +1324,7 @@ this.setSharedFlag(4, swimming); } -@@ -2659,6 +_,7 @@ +@@ -2669,6 +_,7 @@ @Nullable public PlayerTeam getTeam() { @@ -1333,7 +1332,7 @@ return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -2675,7 +_,11 @@ +@@ -2685,7 +_,11 @@ } public void setInvisible(boolean invisible) { @@ -1346,7 +1345,7 @@ } public boolean getSharedFlag(int flag) { -@@ -2692,7 +_,7 @@ +@@ -2702,7 +_,7 @@ } public int getMaxAirSupply() { @@ -1355,7 +1354,7 @@ } public int getAirSupply() { -@@ -2700,10 +_,22 @@ +@@ -2710,10 +_,22 @@ } public void setAirSupply(int airSupply) { @@ -1379,7 +1378,7 @@ this.setTicksFrozen(0); } -@@ -2730,11 +_,43 @@ +@@ -2740,11 +_,43 @@ public void thunderHit(ServerLevel level, LightningBolt lightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -1427,7 +1426,7 @@ } public void onAboveBubbleColumn(boolean downwards, BlockPos pos) { -@@ -2890,26 +_,30 @@ +@@ -2900,26 +_,30 @@ return this.removalReason != null ? String.format( Locale.ROOT, @@ -1461,7 +1460,7 @@ ); } -@@ -2933,6 +_,13 @@ +@@ -2943,6 +_,13 @@ } public void restoreFrom(Entity entity) { @@ -1475,7 +1474,7 @@ try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) { TagValueOutput tagValueOutput = TagValueOutput.createWithContext(scopedCollector, entity.registryAccess()); entity.saveWithoutId(tagValueOutput); -@@ -2945,7 +_,65 @@ +@@ -2955,7 +_,65 @@ @Nullable public Entity teleport(TeleportTransition teleportTransition) { @@ -1541,7 +1540,7 @@ ServerLevel level = teleportTransition.newLevel(); boolean flag = level.dimension() != serverLevel.dimension(); if (!teleportTransition.asPassenger()) { -@@ -2995,10 +_,15 @@ +@@ -3005,10 +_,15 @@ profilerFiller.pop(); return null; } else { @@ -1558,7 +1557,7 @@ for (Entity entity2 : list) { entity2.startRiding(entityx, true, false); -@@ -3088,9 +_,17 @@ +@@ -3098,9 +_,17 @@ } protected void removeAfterChangingDimensions() { @@ -1579,7 +1578,7 @@ } if (this instanceof WaypointTransmitter waypointTransmitter && this.level instanceof ServerLevel serverLevel) { -@@ -3102,11 +_,37 @@ +@@ -3112,11 +_,37 @@ return PortalShape.getRelativePosition(portal, axis, this.position(), this.getDimensions(this.getPose())); } @@ -1617,7 +1616,7 @@ if (fromLevel.dimension() == Level.END && toLevel.dimension() == Level.OVERWORLD) { for (Entity entity : this.getPassengers()) { if (entity instanceof ServerPlayer serverPlayer && !serverPlayer.seenCredits) { -@@ -3214,8 +_,14 @@ +@@ -3224,8 +_,14 @@ return this.entityData.get(DATA_CUSTOM_NAME_VISIBLE); } @@ -1634,7 +1633,7 @@ return entity != null; } -@@ -3329,7 +_,26 @@ +@@ -3339,7 +_,26 @@ } public final void setBoundingBox(AABB bb) { @@ -1662,7 +1661,7 @@ } public final float getEyeHeight(Pose pose) { -@@ -3356,6 +_,12 @@ +@@ -3366,6 +_,12 @@ } public void stopSeenByPlayer(ServerPlayer player) { @@ -1675,7 +1674,7 @@ } public float rotate(Rotation transformRotation) { -@@ -3384,7 +_,7 @@ +@@ -3394,7 +_,7 @@ } @Nullable @@ -1684,7 +1683,7 @@ return null; } -@@ -3416,21 +_,32 @@ +@@ -3426,21 +_,32 @@ } private Stream getIndirectPassengersStream() { @@ -1718,7 +1717,7 @@ } public int countPlayerPassengers() { -@@ -3438,6 +_,7 @@ +@@ -3448,6 +_,7 @@ } public boolean hasExactlyOnePlayerPassenger() { @@ -1726,7 +1725,7 @@ return this.countPlayerPassengers() == 1; } -@@ -3520,9 +_,38 @@ +@@ -3530,9 +_,38 @@ return 0; } @@ -1766,7 +1765,7 @@ this.position(), this.getRotationVector(), level, -@@ -3588,6 +_,11 @@ +@@ -3598,6 +_,11 @@ vec3 = vec3.add(flow); i++; } @@ -1778,7 +1777,7 @@ } } } -@@ -3686,7 +_,9 @@ +@@ -3696,7 +_,9 @@ } public void setDeltaMovement(Vec3 deltaMovement) { @@ -1788,7 +1787,7 @@ } public void addDeltaMovement(Vec3 addend) { -@@ -3749,9 +_,35 @@ +@@ -3759,9 +_,35 @@ return this.getZ((2.0 * this.random.nextDouble() - 1.0) * scale); } @@ -1824,7 +1823,7 @@ int floor = Mth.floor(x); int floor1 = Mth.floor(y); int floor2 = Mth.floor(z); -@@ -3773,7 +_,18 @@ +@@ -3783,7 +_,18 @@ serverLevel.getWaypointManager().updatePlayer(serverPlayer); } } @@ -1844,7 +1843,7 @@ } public void checkDespawn() { -@@ -3826,6 +_,12 @@ +@@ -3836,6 +_,12 @@ return this.getTicksFrozen() > 0; } @@ -1857,7 +1856,7 @@ public float getYRot() { return this.yRot; } -@@ -3877,7 +_,9 @@ +@@ -3887,7 +_,9 @@ } @Override @@ -1868,7 +1867,7 @@ if (this.removalReason == null) { this.removalReason = removalReason; } -@@ -3889,12 +_,28 @@ +@@ -3899,12 +_,28 @@ this.getPassengers().forEach(Entity::stopRiding); this.levelCallback.onRemove(removalReason); this.onRemoval(removalReason); @@ -1897,7 +1896,7 @@ @Override public void setLevelCallback(EntityInLevelCallback levelCallback) { this.levelCallback = levelCallback; -@@ -4091,4 +_,14 @@ +@@ -4101,4 +_,14 @@ return this.save; } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index 2e12b6bc1116..9999d33313db 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -18,7 +18,7 @@ public abstract class LivingEntity extends Entity implements Attackable, WaypointTransmitter { private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; -@@ -270,11 +_,25 @@ +@@ -271,11 +_,25 @@ ); protected final EntityEquipment equipment; private Waypoint.Icon locatorBarIcon = new Waypoint.Icon(); @@ -45,7 +45,7 @@ this.equipment = this.createEquipment(); this.blocksBuilding = true; this.reapplyPosition(); -@@ -376,7 +_,13 @@ +@@ -377,7 +_,13 @@ double d1 = Math.min(0.2F + d / 15.0, 2.5); int i = (int)(150.0 * d1); @@ -60,7 +60,7 @@ } } -@@ -561,7 +_,7 @@ +@@ -562,7 +_,7 @@ this.deathTime++; if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { this.level().broadcastEntityEvent(this, (byte)60); @@ -69,7 +69,7 @@ } } -@@ -666,7 +_,7 @@ +@@ -667,7 +_,7 @@ } public boolean shouldDiscardFriction() { @@ -78,7 +78,7 @@ } public void setDiscardFriction(boolean discardFriction) { -@@ -678,10 +_,15 @@ +@@ -679,10 +_,15 @@ } public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem) { @@ -95,7 +95,7 @@ this.level() .playSeededSound( null, -@@ -708,12 +_,12 @@ +@@ -709,12 +_,12 @@ } @Override @@ -110,7 +110,7 @@ this.brain.clearMemories(); } -@@ -730,11 +_,17 @@ +@@ -731,11 +_,17 @@ mobEffectInstance.onMobRemoved(level, this, removalReason); } @@ -128,7 +128,7 @@ output.putFloat("Health", this.getHealth()); output.putShort("HurtTime", (short)this.hurtTime); output.putInt("HurtByTimestamp", this.lastHurtByMobTimestamp); -@@ -768,8 +_,15 @@ +@@ -769,8 +_,15 @@ } } @@ -146,7 +146,7 @@ if (stack.isEmpty()) { return null; } else if (this.level().isClientSide()) { -@@ -778,6 +_,31 @@ +@@ -779,6 +_,31 @@ } else { ItemEntity itemEntity = this.createItemStackToDrop(stack, randomizeMotion, includeThrower); if (itemEntity != null) { @@ -178,7 +178,7 @@ this.level().addFreshEntity(itemEntity); } -@@ -787,7 +_,22 @@ +@@ -788,7 +_,22 @@ @Override protected void readAdditionalSaveData(ValueInput input) { @@ -202,7 +202,7 @@ if (this.level() != null && !this.level().isClientSide()) { input.read("attributes", AttributeInstance.Packed.LIST_CODEC).ifPresent(this.getAttributes()::apply); } -@@ -800,6 +_,11 @@ +@@ -801,6 +_,11 @@ this.effectsDirty = true; } @@ -214,7 +214,7 @@ this.setHealth(input.getFloatOr("Health", this.getMaxHealth())); this.hurtTime = input.getShortOr("HurtTime", (short)0); this.deathTime = input.getShortOr("DeathTime", (short)0); -@@ -807,6 +_,7 @@ +@@ -808,6 +_,7 @@ input.getString("Team").ifPresent(string -> { Scoreboard scoreboard = this.level().getScoreboard(); PlayerTeam playerTeam = scoreboard.getPlayerTeam(string); @@ -222,7 +222,7 @@ boolean flag = playerTeam != null && scoreboard.addPlayerToTeam(this.getStringUUID(), playerTeam); if (!flag) { LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", string); -@@ -814,11 +_,13 @@ +@@ -815,11 +_,13 @@ }); this.setSharedFlag(7, input.getBooleanOr("FallFlying", false)); input.read("sleeping_pos", BlockPos.CODEC).ifPresentOrElse(blockPos -> { @@ -236,7 +236,7 @@ }, this::clearSleepingPos); input.read("Brain", Codec.PASSTHROUGH).ifPresent(dynamic -> this.brain = this.makeBrain((Dynamic)dynamic)); this.lastHurtByPlayer = EntityReference.read(input, "last_hurt_by_player"); -@@ -835,15 +_,44 @@ +@@ -836,15 +_,44 @@ this.updateDirtyEffects(); } @@ -281,7 +281,7 @@ iterator.remove(); this.onEffectsRemoved(List.of(mobEffectInstance)); } else if (mobEffectInstance.getDuration() % 600 == 0) { -@@ -852,6 +_,18 @@ +@@ -853,6 +_,18 @@ } } catch (ConcurrentModificationException var6) { } @@ -300,7 +300,7 @@ } else { for (MobEffectInstance mobEffectInstance1 : this.activeEffects.values()) { mobEffectInstance1.tickClient(); -@@ -962,15 +_,33 @@ +@@ -963,15 +_,33 @@ } public boolean removeAllEffects() { @@ -338,7 +338,7 @@ } } -@@ -997,21 +_,57 @@ +@@ -998,21 +_,57 @@ } public final boolean addEffect(MobEffectInstance effectInstance) { @@ -398,7 +398,7 @@ this.onEffectUpdated(mobEffectInstance, true, entity); flag = true; } -@@ -1050,11 +_,37 @@ +@@ -1051,11 +_,37 @@ @Nullable public final MobEffectInstance removeEffectNoUpdate(Holder effect) { @@ -437,7 +437,7 @@ if (mobEffectInstance != null) { this.onEffectsRemoved(List.of(mobEffectInstance)); return true; -@@ -1145,17 +_,62 @@ +@@ -1146,17 +_,62 @@ } public void heal(float amount) { @@ -501,7 +501,7 @@ this.entityData.set(DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth())); } -@@ -1167,7 +_,7 @@ +@@ -1168,7 +_,7 @@ public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { if (this.isInvulnerableTo(level, damageSource)) { return false; @@ -510,7 +510,7 @@ return false; } else if (damageSource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1183,35 +_,58 @@ +@@ -1184,35 +_,58 @@ ItemStack useItem = this.getUseItem(); float originAmount = amount; @@ -577,7 +577,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1226,7 +_,7 @@ +@@ -1227,7 +_,7 @@ level.broadcastDamageEvent(this, damageSource); } @@ -586,7 +586,7 @@ this.markHurt(); } -@@ -1241,8 +_,16 @@ +@@ -1242,8 +_,16 @@ d = damageSource.getSourcePosition().x() - this.getX(); d1 = damageSource.getSourcePosition().z() - this.getZ(); } @@ -604,7 +604,7 @@ if (!flag) { this.indicateDamage(d, d1); } -@@ -1251,19 +_,19 @@ +@@ -1252,19 +_,19 @@ if (this.isDeadOrDying()) { if (!this.checkTotemDeathProtection(damageSource)) { @@ -629,7 +629,7 @@ if (flag2) { this.lastDamageSource = damageSource; this.lastDamageStamp = this.level().getGameTime(); -@@ -1289,6 +_,12 @@ +@@ -1290,6 +_,12 @@ } public float applyItemBlocking(ServerLevel level, DamageSource damageSource, float damageAmount) { @@ -642,7 +642,7 @@ if (damageAmount <= 0.0F) { return 0.0F; } else { -@@ -1313,10 +_,12 @@ +@@ -1314,10 +_,12 @@ } float f = blocksAttacks.resolveBlockedDamage(damageSource, damageAmount, acos); @@ -656,7 +656,7 @@ return f; } -@@ -1327,6 +_,59 @@ +@@ -1328,6 +_,59 @@ } } @@ -716,7 +716,7 @@ public void playSecondaryHurtSound(DamageSource damageSource) { if (damageSource.is(DamageTypes.THORNS)) { SoundSource soundSource = this instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE; -@@ -1359,12 +_,24 @@ +@@ -1360,12 +_,24 @@ return EntityReference.getPlayer(this.lastHurtByPlayer, this.level()); } @@ -742,7 +742,7 @@ } private boolean checkTotemDeathProtection(DamageSource damageSource) { -@@ -1374,18 +_,39 @@ +@@ -1375,18 +_,39 @@ ItemStack itemStack = null; DeathProtection deathProtection = null; @@ -789,7 +789,7 @@ serverPlayer.awardStat(Stats.ITEM_USED.get(itemStack.getItem())); CriteriaTriggers.USED_TOTEM.trigger(serverPlayer, itemStack); this.gameEvent(GameEvent.ITEM_INTERACT_FINISH); -@@ -1444,6 +_,7 @@ +@@ -1445,6 +_,7 @@ if (!this.isRemoved() && !this.dead) { Entity entity = damageSource.getEntity(); LivingEntity killCredit = this.getKillCredit(); @@ -797,7 +797,7 @@ if (killCredit != null) { killCredit.awardKillScore(this, damageSource); } -@@ -1453,68 +_,147 @@ +@@ -1454,68 +_,147 @@ } if (!this.level().isClientSide() && this.hasCustomName()) { @@ -958,7 +958,7 @@ } protected void dropCustomDeathLoot(ServerLevel level, DamageSource damageSource, boolean recentlyHit) { -@@ -1618,9 +_,14 @@ +@@ -1619,9 +_,14 @@ } public void knockback(double strength, double x, double z) { @@ -975,7 +975,7 @@ Vec3 deltaMovement = this.getDeltaMovement(); while (x * x + z * z < 1.0E-5F) { -@@ -1629,11 +_,22 @@ +@@ -1630,11 +_,22 @@ } Vec3 vec3 = new Vec3(x, 0.0, z).normalize().scale(strength); @@ -999,7 +999,7 @@ } } -@@ -1726,7 +_,7 @@ +@@ -1727,7 +_,7 @@ @Override public boolean isAlive() { @@ -1008,7 +1008,7 @@ } public boolean isLookingAtMe(LivingEntity entity, double tolerance, boolean scaleByDistance, boolean visual, double... yValues) { -@@ -1760,9 +_,14 @@ +@@ -1761,9 +_,14 @@ boolean flag = super.causeFallDamage(fallDistance, damageMultiplier, damageSource); int i = this.calculateFallDamage(fallDistance, damageMultiplier); if (i > 0) { @@ -1024,7 +1024,7 @@ return true; } else { return flag; -@@ -1827,7 +_,7 @@ +@@ -1828,7 +_,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damageSource, float damageAmount) { if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -1033,7 +1033,7 @@ damageAmount = CombatRules.getDamageAfterAbsorb( this, damageAmount, damageSource, this.getArmorValue(), (float)this.getAttributeValue(Attributes.ARMOR_TOUGHNESS) ); -@@ -1840,7 +_,8 @@ +@@ -1841,7 +_,8 @@ if (damageSource.is(DamageTypeTags.BYPASSES_EFFECTS)) { return damageAmount; } else { @@ -1043,7 +1043,7 @@ int i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int i1 = 25 - i; float f = damageAmount * i1; -@@ -1877,24 +_,201 @@ +@@ -1878,24 +_,201 @@ } } @@ -1255,7 +1255,7 @@ } public CombatTracker getCombatTracker() { -@@ -1923,7 +_,17 @@ +@@ -1924,7 +_,17 @@ } public final void setArrowCount(int count) { @@ -1274,7 +1274,7 @@ } public final int getStingerCount() { -@@ -1968,7 +_,7 @@ +@@ -1969,7 +_,7 @@ @Override public void handleDamageEvent(DamageSource damageSource) { this.walkAnimation.setSpeed(1.5F); @@ -1283,7 +1283,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; SoundEvent hurtSound = this.getHurtSound(damageSource); -@@ -2080,7 +_,7 @@ +@@ -2088,7 +_,7 @@ @Override protected void onBelowWorld() { @@ -1292,7 +1292,7 @@ } protected void updateSwingTime() { -@@ -2176,8 +_,15 @@ +@@ -2184,8 +_,15 @@ } public void setItemSlot(EquipmentSlot slot, ItemStack stack) { @@ -1310,7 +1310,7 @@ public float getArmorCoverPercentage() { int i = 0; -@@ -2269,14 +_,27 @@ +@@ -2277,14 +_,27 @@ return this.hasEffect(MobEffects.JUMP_BOOST) ? 0.1F * (this.getEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1.0F) : 0.0F; } @@ -1338,7 +1338,7 @@ this.addDeltaMovement(new Vec3(-Mth.sin(f) * 0.2, 0.0, Mth.cos(f) * 0.2)); } -@@ -2436,8 +_,10 @@ +@@ -2444,8 +_,10 @@ } public void stopFallFlying() { @@ -1349,7 +1349,7 @@ } private Vec3 updateFallFlyingMovement(Vec3 deltaMovement) { -@@ -2581,7 +_,7 @@ +@@ -2589,7 +_,7 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F && target instanceof LivingEntity livingEntity) { @@ -1358,7 +1358,7 @@ this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); } } -@@ -2657,37 +_,15 @@ +@@ -2665,37 +_,15 @@ profilerFiller.pop(); profilerFiller.push("rangeChecks"); @@ -1405,7 +1405,7 @@ profilerFiller.pop(); if (this.isFallFlying()) { -@@ -2769,16 +_,39 @@ +@@ -2777,16 +_,39 @@ @Nullable private Map collectEquipmentChanges() { Map map = null; @@ -1445,7 +1445,7 @@ AttributeMap attributes = this.getAttributes(); if (!itemStack.isEmpty()) { this.stopLocationBasedEffects(itemStack, equipmentSlot, attributes); -@@ -2803,6 +_,8 @@ +@@ -2811,6 +_,8 @@ } } } @@ -1454,7 +1454,7 @@ } return map; -@@ -2834,7 +_,7 @@ +@@ -2842,7 +_,7 @@ list.add(Pair.of(equipmentSlot, itemStack1)); this.lastEquipmentItems.put(equipmentSlot, itemStack1); }); @@ -1463,7 +1463,7 @@ } protected void tickHeadTurn(float yBodyRot) { -@@ -2920,8 +_,10 @@ +@@ -2928,8 +_,10 @@ if (!flag || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if (!this.isInLava() || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if ((this.onGround() || flag && fluidHeight <= fluidJumpThreshold) && this.noJumpDelay == 0) { @@ -1474,7 +1474,7 @@ } } else { this.jumpInLiquid(FluidTags.LAVA); -@@ -2962,7 +_,7 @@ +@@ -2970,7 +_,7 @@ profilerFiller.pop(); if (this.level() instanceof ServerLevel serverLevel) { profilerFiller.push("freezing"); @@ -1483,7 +1483,7 @@ this.setTicksFrozen(Math.max(0, this.getTicksFrozen() - 2)); } -@@ -2983,6 +_,20 @@ +@@ -2991,6 +_,20 @@ this.pushEntities(); profilerFiller.pop(); @@ -1504,7 +1504,7 @@ if (this.level() instanceof ServerLevel serverLevel && this.isSensitiveToWater() && this.isInWaterOrRain()) { this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F); } -@@ -3005,6 +_,7 @@ +@@ -3013,6 +_,7 @@ this.checkFallDistanceAccumulation(); if (!this.level().isClientSide()) { if (!this.canGlide()) { @@ -1512,7 +1512,7 @@ this.setSharedFlag(7, false); return; } -@@ -3044,10 +_,25 @@ +@@ -3052,10 +_,25 @@ } protected void pushEntities() { @@ -1539,7 +1539,7 @@ if (_int > 0 && pushableEntities.size() > _int - 1 && this.random.nextInt(4) == 0) { int i = 0; -@@ -3063,7 +_,16 @@ +@@ -3071,7 +_,16 @@ } } @@ -1556,7 +1556,7 @@ this.doPush(entity1); } } -@@ -3072,16 +_,32 @@ +@@ -3080,16 +_,32 @@ protected void checkAutoSpinAttack(AABB boundingBoxBeforeSpin, AABB boundingBoxAfterSpin) { AABB aabb = boundingBoxBeforeSpin.minmax(boundingBoxAfterSpin); List entities = this.level().getEntities(this, aabb); @@ -1590,7 +1590,7 @@ this.autoSpinAttackTicks = 0; } -@@ -3104,10 +_,10 @@ +@@ -3112,10 +_,10 @@ } @Override @@ -1604,7 +1604,7 @@ this.dismountVehicle(vehicle); } } -@@ -3134,7 +_,7 @@ +@@ -3142,7 +_,7 @@ } public void onItemPickup(ItemEntity itemEntity) { @@ -1613,7 +1613,7 @@ if (owner instanceof ServerPlayer) { CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer)owner, itemEntity.getItem(), this); } -@@ -3146,7 +_,7 @@ +@@ -3154,7 +_,7 @@ && (entity instanceof ItemEntity || entity instanceof AbstractArrow || entity instanceof ExperienceOrb)) { ((ServerLevel)this.level()) .getChunkSource() @@ -1622,7 +1622,7 @@ } } -@@ -3160,7 +_,8 @@ +@@ -3168,7 +_,8 @@ } else { Vec3 vec3 = new Vec3(this.getX(), this.getEyeY(), this.getZ()); Vec3 vec31 = new Vec3(entity.getX(), y, entity.getZ()); @@ -1632,7 +1632,7 @@ } } -@@ -3180,13 +_,27 @@ +@@ -3188,13 +_,27 @@ @Override public boolean isPickable() { @@ -1663,7 +1663,7 @@ @Override public float getYHeadRot() { -@@ -3217,7 +_,7 @@ +@@ -3225,7 +_,7 @@ } public final void setAbsorptionAmount(float absorptionAmount) { @@ -1672,7 +1672,7 @@ } protected void internalSetAbsorptionAmount(float absorptionAmount) { -@@ -3244,6 +_,15 @@ +@@ -3252,6 +_,15 @@ return (this.entityData.get(DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; } @@ -1688,7 +1688,7 @@ private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { -@@ -3261,6 +_,11 @@ +@@ -3269,6 +_,11 @@ return null; } else { double d = this.getEyeY() - 0.3F; @@ -1700,7 +1700,7 @@ ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), d, this.getZ(), stack); itemEntity.setPickUpDelay(40); if (includeThrower) { -@@ -3292,7 +_,12 @@ +@@ -3300,7 +_,12 @@ protected void updateUsingItem(ItemStack usingItem) { usingItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); @@ -1714,7 +1714,7 @@ this.completeUsingItem(); } } -@@ -3318,10 +_,19 @@ +@@ -3326,10 +_,19 @@ } public void startUsingItem(InteractionHand hand) { @@ -1736,7 +1736,7 @@ if (!this.level().isClientSide()) { this.setLivingEntityFlag(1, true); this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND); -@@ -3348,7 +_,10 @@ +@@ -3356,7 +_,10 @@ } } else if (!this.isUsingItem() && !this.useItem.isEmpty()) { this.useItem = ItemStack.EMPTY; @@ -1748,7 +1748,7 @@ } } } -@@ -3387,7 +_,38 @@ +@@ -3395,7 +_,38 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1788,7 +1788,7 @@ if (itemStack != this.useItem) { this.setItemInHand(usedItemHand, itemStack); } -@@ -3421,6 +_,7 @@ +@@ -3429,6 +_,7 @@ ItemStack itemInHand = this.getItemInHand(this.getUsedItemHand()); if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemInHand, this.useItem)) { this.useItem = itemInHand; @@ -1796,7 +1796,7 @@ this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); if (this.useItem.useOnRelease()) { this.updatingUsingItem(); -@@ -3441,7 +_,10 @@ +@@ -3449,7 +_,10 @@ } this.useItem = ItemStack.EMPTY; @@ -1808,7 +1808,7 @@ } public boolean isBlocking() { -@@ -3465,6 +_,60 @@ +@@ -3473,6 +_,60 @@ } } @@ -1869,7 +1869,7 @@ public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); } -@@ -3483,6 +_,12 @@ +@@ -3491,6 +_,12 @@ } public boolean randomTeleport(double x, double y, double z, boolean broadcastTeleport) { @@ -1882,7 +1882,7 @@ double x1 = this.getX(); double y1 = this.getY(); double z1 = this.getZ(); -@@ -3505,16 +_,39 @@ +@@ -3513,16 +_,39 @@ } if (flag1) { @@ -1925,7 +1925,7 @@ } else { if (broadcastTeleport) { level.broadcastEntityEvent(this, (byte)46); -@@ -3524,7 +_,7 @@ +@@ -3532,7 +_,7 @@ pathfinderMob.getNavigation().stop(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch index 878b146c0d88..68b4b71bb321 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ambient/Bat.java +++ b/net/minecraft/world/entity/ambient/Bat.java -@@ -87,7 +_,7 @@ +@@ -86,7 +_,7 @@ } @Override @@ -9,7 +9,7 @@ return false; } -@@ -141,13 +_,13 @@ +@@ -140,13 +_,13 @@ this.yHeadRot = this.random.nextInt(360); } @@ -25,7 +25,7 @@ this.setResting(false); if (!isSilent) { level.levelEvent(null, 1025, blockPos, 0); -@@ -180,7 +_,7 @@ +@@ -179,7 +_,7 @@ float f1 = Mth.wrapDegrees(f - this.getYRot()); this.zza = 0.5F; this.setYRot(this.getYRot() + f1); @@ -34,7 +34,7 @@ this.setResting(true); } } -@@ -205,7 +_,7 @@ +@@ -204,7 +_,7 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch index 01e4c66111a0..d344dbd512d9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch @@ -1,32 +1,6 @@ --- a/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java +++ b/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java -@@ -138,8 +_,14 @@ - - @Override - public int getMaxAirSupply() { -- return 300; -- } -+ return this.maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() -+ } -+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() -+ @Override -+ public int getDefaultMaxAirSupply() { -+ return TOTAL_AIR_SUPPLY; -+ } -+ // CraftBukkit end - - protected void handleAirSupply(ServerLevel level, int airSupply) { - if (this.isAlive() && !this.isInWater()) { -@@ -149,7 +_,7 @@ - this.hurtServer(level, this.damageSources().dryOut(), 2.0F); - } - } else { -- this.setAirSupply(300); -+ this.setAirSupply(this.maxAirTicks); // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() - } - } - -@@ -411,7 +_,7 @@ +@@ -387,7 +_,7 @@ if (this.isFood(itemInHand) && this.getHealth() < this.getMaxHealth()) { this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); @@ -35,7 +9,7 @@ return InteractionResult.SUCCESS; } -@@ -431,7 +_,7 @@ +@@ -407,7 +_,7 @@ } private void tryToTame(Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch new file mode 100644 index 000000000000..89d5b05c01ed --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/world/entity/animal/nautilus/Nautilus.java ++++ b/net/minecraft/world/entity/animal/nautilus/Nautilus.java +@@ -98,8 +_,14 @@ + + @Override + public int getMaxAirSupply() { +- return 300; +- } ++ return this.maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() ++ } ++ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() ++ @Override ++ public int getDefaultMaxAirSupply() { ++ return TOTAL_AIR_SUPPLY; ++ } ++ // CraftBukkit end + + protected void handleAirSupply(ServerLevel level, int airSupply) { + if (this.isAlive() && !this.isInWater()) { +@@ -109,7 +_,7 @@ + this.hurtServer(level, this.damageSources().dryOut(), 2.0F); + } + } else { +- this.setAirSupply(300); ++ this.setAirSupply(this.maxAirTicks); // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + } + } + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch index 8c4fc2feacc5..53618c133cce 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/AbstractSkeleton.java +++ b/net/minecraft/world/entity/monster/AbstractSkeleton.java -@@ -64,6 +_,7 @@ +@@ -63,6 +_,7 @@ AbstractSkeleton.this.setAggressive(true); } }; @@ -8,7 +8,7 @@ protected AbstractSkeleton(EntityType type, Level level) { super(type, level); -@@ -88,6 +_,21 @@ +@@ -87,6 +_,21 @@ return Monster.createMonsterAttributes().add(Attributes.MOVEMENT_SPEED, 0.25); } @@ -30,16 +30,16 @@ @Override protected void playStepSound(BlockPos pos, BlockState block) { this.playSound(this.getStepSound(), 0.15F, 1.0F); -@@ -119,7 +_,7 @@ +@@ -118,7 +_,7 @@ this.populateDefaultEquipmentSlots(random, difficulty); this.populateDefaultEquipmentEnchantments(level, random, difficulty); this.reassessWeaponGoal(); - this.setCanPickUpLoot(random.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); -+ this.setCanPickUpLoot(this.level().paperConfig().entities.behavior.mobsCanAlwaysPickUpLoot.skeletons || random.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); // Paper - Add world settings for mobs picking up loot - if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { - LocalDate localDate = LocalDate.now(); - int i = localDate.get(ChronoField.DAY_OF_MONTH); -@@ -162,7 +_,8 @@ ++ this.setCanPickUpLoot(level.getLevel().paperConfig().entities.behavior.mobsCanAlwaysPickUpLoot.skeletons || random.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); // Paper - Add world settings for mobs picking up loot + if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty() && SpecialDates.isHalloween() && random.nextFloat() < 0.25F) { + this.setItemSlot(EquipmentSlot.HEAD, new ItemStack(random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN)); + this.setDropChance(EquipmentSlot.HEAD, 0.0F); +@@ -156,7 +_,8 @@ @Override public void performRangedAttack(LivingEntity target, float distanceFactor) { @@ -49,7 +49,7 @@ ItemStack projectile = this.getProjectile(itemInHand); AbstractArrow arrow = this.getArrow(projectile, distanceFactor, itemInHand); double d = target.getX() - this.getX(); -@@ -170,9 +_,21 @@ +@@ -164,9 +_,21 @@ double d2 = target.getZ() - this.getZ(); double squareRoot = Math.sqrt(d * d + d2 * d2); if (this.level() instanceof ServerLevel serverLevel) { @@ -72,7 +72,7 @@ } this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); -@@ -196,11 +_,22 @@ +@@ -190,11 +_,22 @@ protected void readAdditionalSaveData(ValueInput input) { super.readAdditionalSaveData(input); this.reassessWeaponGoal(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch index 82b1d9726046..74eb73b512bd 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Zombie.java +++ b/net/minecraft/world/entity/monster/Zombie.java -@@ -66,9 +_,7 @@ +@@ -65,9 +_,7 @@ public class Zombie extends Monster { private static final ResourceLocation SPEED_MODIFIER_BABY_ID = ResourceLocation.withDefaultNamespace("baby"); @@ -11,7 +11,7 @@ private static final ResourceLocation REINFORCEMENT_CALLER_CHARGE_ID = ResourceLocation.withDefaultNamespace("reinforcement_caller_charge"); private static final AttributeModifier ZOMBIE_REINFORCEMENT_CALLEE_CHARGE = new AttributeModifier( ResourceLocation.withDefaultNamespace("reinforcement_callee_charge"), -0.05F, AttributeModifier.Operation.ADD_VALUE -@@ -89,13 +_,15 @@ +@@ -88,13 +_,15 @@ private static final boolean DEFAULT_BABY = false; private static final boolean DEFAULT_CAN_BREAK_DOORS = false; private static final int DEFAULT_IN_WATER_TIME = 0; @@ -28,7 +28,7 @@ } public Zombie(Level level) { -@@ -104,7 +_,7 @@ +@@ -103,7 +_,7 @@ @Override protected void registerGoals() { @@ -37,7 +37,7 @@ this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F)); this.goalSelector.addGoal(8, new RandomLookAroundGoal(this)); this.addBehaviourGoals(); -@@ -117,7 +_,7 @@ +@@ -116,7 +_,7 @@ this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); @@ -46,7 +46,7 @@ this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true)); this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR)); } -@@ -171,11 +_,16 @@ +@@ -170,11 +_,16 @@ @Override protected int getBaseExperienceReward(ServerLevel level) { @@ -64,7 +64,7 @@ } @Override -@@ -183,9 +_,9 @@ +@@ -182,9 +_,9 @@ this.getEntityData().set(DATA_BABY_ID, childZombie); if (this.level() != null && !this.level().isClientSide()) { AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED); @@ -76,7 +76,7 @@ } } } -@@ -226,6 +_,13 @@ +@@ -225,6 +_,13 @@ super.tick(); } @@ -90,7 +90,7 @@ public void startUnderWaterConversion(int conversionTime) { this.conversionTime = conversionTime; this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, true); -@@ -239,31 +_,50 @@ +@@ -238,31 +_,50 @@ } protected void convertToZombieType(ServerLevel level, EntityType entityType) { @@ -150,7 +150,7 @@ @Override public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { -@@ -296,13 +_,13 @@ +@@ -295,13 +_,13 @@ if (SpawnPlacements.isSpawnPositionOk(type, level, blockPos) && SpawnPlacements.checkSpawnRules(type, level, EntitySpawnReason.REINFORCEMENT, blockPos, level.random)) { zombie.setPos(i1, i2, i3); @@ -167,7 +167,7 @@ AttributeInstance attribute = this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE); AttributeModifier modifier = attribute.getModifier(REINFORCEMENT_CALLER_CHARGE_ID); double d = modifier != null ? modifier.amount() : 0.0; -@@ -327,7 +_,12 @@ +@@ -326,7 +_,12 @@ if (flag) { float effectiveDifficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < effectiveDifficulty * 0.3F) { @@ -181,7 +181,7 @@ } } -@@ -389,6 +_,7 @@ +@@ -388,6 +_,7 @@ output.putBoolean("CanBreakDoors", this.canBreakDoors()); output.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1); output.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1); @@ -189,7 +189,7 @@ } @Override -@@ -403,13 +_,15 @@ +@@ -402,13 +_,15 @@ } else { this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, false); } @@ -207,7 +207,7 @@ return flag; } -@@ -445,7 +_,7 @@ +@@ -444,7 +_,7 @@ spawnGroupData = super.finalizeSpawn(level, difficulty, spawnReason, spawnGroupData); float specialMultiplier = difficulty.getSpecialMultiplier(); if (spawnReason != EntitySpawnReason.CONVERSION) { @@ -216,7 +216,7 @@ } if (spawnGroupData == null) { -@@ -472,7 +_,7 @@ +@@ -471,7 +_,7 @@ chicken1.finalizeSpawn(level, difficulty, EntitySpawnReason.JOCKEY, null); chicken1.setChickenJockey(true); this.startRiding(chicken1, false, false); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index 4c254e2c6c41..c3a1339faee4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -149,7 +_,7 @@ +@@ -150,7 +_,7 @@ private static final boolean DEFAULT_IGNORE_FALL_DAMAGE_FROM_CURRENT_IMPULSE = false; private static final int DEFAULT_CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME = 0; final Inventory inventory; @@ -9,7 +9,7 @@ public final InventoryMenu inventoryMenu; public AbstractContainerMenu containerMenu; protected FoodData foodData = new FoodData(); -@@ -180,6 +_,18 @@ +@@ -181,6 +_,18 @@ public Entity currentExplosionCause; private boolean ignoreFallDamageFromCurrentImpulse = false; private int currentImpulseContextResetGraceTime = 0; @@ -28,7 +28,7 @@ public Player(Level level, GameProfile gameProfile) { super(EntityType.PLAYER, level); -@@ -247,6 +_,13 @@ +@@ -248,6 +_,13 @@ if (this.isSleeping()) { this.sleepCounter++; @@ -42,7 +42,7 @@ if (this.sleepCounter > 100) { this.sleepCounter = 100; } -@@ -329,7 +_,7 @@ +@@ -331,7 +_,7 @@ } private void turtleHelmetTick() { @@ -51,7 +51,7 @@ } private boolean isEquipped(Item item) { -@@ -433,6 +_,18 @@ +@@ -435,6 +_,18 @@ } } @@ -70,7 +70,7 @@ public void closeContainer() { this.containerMenu = this.inventoryMenu; } -@@ -444,8 +_,14 @@ +@@ -446,8 +_,14 @@ public void rideTick() { if (!this.level().isClientSide() && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -87,7 +87,7 @@ super.rideTick(); } } -@@ -706,10 +_,10 @@ +@@ -708,10 +_,10 @@ if (this.isDeadOrDying()) { return false; } else { @@ -100,7 +100,7 @@ } if (level.getDifficulty() == Difficulty.EASY) { -@@ -721,7 +_,14 @@ +@@ -723,7 +_,14 @@ } } @@ -116,7 +116,7 @@ } } } -@@ -733,7 +_,7 @@ +@@ -735,7 +_,7 @@ BlocksAttacks blocksAttacks = itemBlockingWith != null ? itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS) : null; float secondsToDisableBlocking = entity.getSecondsToDisableBlocking(); if (secondsToDisableBlocking > 0.0F && blocksAttacks != null) { @@ -125,7 +125,7 @@ } } -@@ -743,9 +_,29 @@ +@@ -745,9 +_,29 @@ } public boolean canHarmPlayer(Player other) { @@ -158,7 +158,7 @@ } @Override -@@ -759,7 +_,12 @@ +@@ -761,7 +_,12 @@ } @Override @@ -172,7 +172,7 @@ if (!this.isInvulnerableTo(level, damageSource)) { amount = this.getDamageAfterArmorAbsorb(damageSource, amount); amount = this.getDamageAfterMagicAbsorb(damageSource, amount); -@@ -771,7 +_,7 @@ +@@ -773,7 +_,7 @@ } if (var8 != 0.0F) { @@ -181,7 +181,7 @@ this.getCombatTracker().recordDamage(damageSource, var8); this.setHealth(this.getHealth() - var8); if (var8 < 3.4028235E37F) { -@@ -781,6 +_,7 @@ +@@ -783,6 +_,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -189,7 +189,7 @@ } public boolean isTextFilteringEnabled() { -@@ -864,14 +_,16 @@ +@@ -866,14 +_,16 @@ } @Override @@ -209,7 +209,7 @@ } @Override -@@ -950,16 +_,26 @@ +@@ -952,16 +_,26 @@ } public void attack(Entity target) { @@ -239,7 +239,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = attackStrengthScale > 0.9F; boolean flag1; -@@ -972,7 +_,9 @@ +@@ -974,7 +_,9 @@ f += weaponItem.getItem().getAttackDamageBonus(target, f, damageSource); boolean flag2 = flag && this.canCriticalAttack(target); @@ -249,7 +249,7 @@ f *= 1.5F; } -@@ -1014,11 +_,12 @@ +@@ -1016,11 +_,12 @@ return !target.isAttackable() || target.skipAttackInteraction(this); } @@ -264,7 +264,7 @@ return true; } else { return false; -@@ -1111,21 +_,43 @@ +@@ -1113,21 +_,43 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F) { if (target instanceof LivingEntity livingEntity) { @@ -309,7 +309,7 @@ } } -@@ -1146,7 +_,10 @@ +@@ -1148,7 +_,10 @@ && !(livingEntity instanceof ArmorStand armorStand && armorStand.isMarker()) && this.distanceToSqr(livingEntity) < 9.0) { float f1 = this.getEnchantedDamage(livingEntity, var12, damageSource) * strengthScale; @@ -321,7 +321,7 @@ livingEntity.knockback(0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity, damageSource); } -@@ -1173,13 +_,22 @@ +@@ -1175,13 +_,22 @@ @Override public boolean stabAttack(EquipmentSlot slot, Entity target, float damageAmount, boolean damage, boolean knockback, boolean dismount) { @@ -346,7 +346,7 @@ return true; } else { float f1 = damage ? damageAmount + f : 0.0F; -@@ -1207,7 +_,7 @@ +@@ -1209,7 +_,7 @@ this.setLastHurtMob(target); this.itemAttackInteraction(target, itemBySlot, damageSource, flag); this.damageStatsAndHearts(target, f2); @@ -355,7 +355,7 @@ return true; } } -@@ -1218,8 +_,8 @@ +@@ -1220,8 +_,8 @@ } @Override @@ -366,7 +366,7 @@ this.inventoryMenu.removed(this); if (this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1287,6 +_,12 @@ +@@ -1289,6 +_,12 @@ } public Either startSleepInBed(BlockPos bedPos) { @@ -379,7 +379,7 @@ this.startSleeping(bedPos); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1398,7 +_,7 @@ +@@ -1400,7 +_,7 @@ @Override public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) { @@ -388,7 +388,7 @@ return false; } else { if (fallDistance >= 2.0) { -@@ -1439,7 +_,15 @@ +@@ -1441,7 +_,15 @@ } public void startFallFlying() { @@ -405,7 +405,7 @@ } @Override -@@ -1537,7 +_,7 @@ +@@ -1539,7 +_,7 @@ if (levels > 0 && this.experienceLevel % 5 == 0 && this.lastLevelUpTime < this.tickCount - 100.0F) { float f = this.experienceLevel > 30 ? 1.0F : this.experienceLevel / 30.0F; @@ -414,7 +414,7 @@ this.lastLevelUpTime = this.tickCount; } } -@@ -1545,15 +_,35 @@ +@@ -1547,15 +_,35 @@ public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { return 112 + (this.experienceLevel - 30) * 9; @@ -452,7 +452,7 @@ } } } -@@ -1804,7 +_,7 @@ +@@ -1813,7 +_,7 @@ @Override public void onAttack() { @@ -461,7 +461,7 @@ super.onAttack(); } -@@ -1839,17 +_,32 @@ +@@ -1848,17 +_,32 @@ return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } @@ -496,7 +496,7 @@ for (int i = 0; i < this.inventory.getContainerSize(); i++) { ItemStack item = this.inventory.getItem(i); -@@ -1858,6 +_,7 @@ +@@ -1867,6 +_,7 @@ } } @@ -504,7 +504,7 @@ return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; } } -@@ -1944,12 +_,20 @@ +@@ -1953,12 +_,20 @@ } public boolean hasClientLoaded() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch b/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch index 72cab22c3dda..d58fceb5ede5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/border/WorldBorder.java +++ b/net/minecraft/world/level/border/WorldBorder.java -@@ -34,6 +_,7 @@ +@@ -33,6 +_,7 @@ double centerZ; int absoluteMaxSize = 29999984; WorldBorder.BorderExtent extent = new WorldBorder.StaticBorderExtent(5.999997E7F); + public net.minecraft.server.level.ServerLevel world; // CraftBukkit - public boolean isWithinBounds(BlockPos pos) { - return this.isWithinBounds(pos.getX(), pos.getZ()); -@@ -47,6 +_,20 @@ + public WorldBorder() { + this(WorldBorder.Settings.DEFAULT); +@@ -54,6 +_,20 @@ return this.isWithinBounds(chunkPos.getMinBlockX(), chunkPos.getMinBlockZ()) && this.isWithinBounds(chunkPos.getMaxBlockX(), chunkPos.getMaxBlockZ()); } @@ -29,7 +29,7 @@ public boolean isWithinBounds(AABB box) { return this.isWithinBounds(box.minX, box.minZ, box.maxX - 1.0E-5F, box.maxZ - 1.0E-5F); } -@@ -135,6 +_,14 @@ +@@ -158,6 +_,14 @@ } public void setCenter(double x, double z) { @@ -44,7 +44,7 @@ this.centerX = x; this.centerZ = z; this.extent.onCenterChange(); -@@ -158,6 +_,17 @@ +@@ -181,6 +_,17 @@ } public void setSize(double size) { @@ -53,7 +53,7 @@ + io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent event = new io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type.INSTANT_MOVE, getSize(), size, 0); + if (!event.callEvent()) return; + if (event.getType() == io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type.STARTED_MOVE && event.getDuration() > 0) { // If changed to a timed transition -+ lerpSizeBetween(event.getOldSize(), event.getNewSize(), event.getDuration()); ++ lerpSizeBetween(event.getOldSize(), event.getNewSize(), event.getDuration(), this.world.getGameTime()); + return; + } + size = event.getNewSize(); @@ -62,10 +62,10 @@ this.extent = new WorldBorder.StaticBorderExtent(size); this.setDirty(); -@@ -167,6 +_,20 @@ +@@ -190,6 +_,20 @@ } - public void lerpSizeBetween(double oldSize, double newSize, long time) { + public void lerpSizeBetween(double oldSize, double newSize, long time, long gameTime) { + // Paper start - Add worldborder events + if (this.world != null) { + io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type type; @@ -82,8 +82,8 @@ + // Paper end - Add worldborder events this.extent = (WorldBorder.BorderExtent)(oldSize == newSize ? new WorldBorder.StaticBorderExtent(newSize) - : new WorldBorder.MovingBorderExtent(oldSize, newSize, time)); -@@ -182,6 +_,7 @@ + : new WorldBorder.MovingBorderExtent(oldSize, newSize, time, gameTime)); +@@ -205,6 +_,7 @@ } public void addListener(BorderChangeListener listener) { @@ -91,10 +91,32 @@ this.listeners.add(listener); } -@@ -379,6 +_,7 @@ - @Override - public WorldBorder.BorderExtent update() { - if (this.getLerpTime() <= 0L) { +@@ -298,6 +_,21 @@ + } + } + ++ // Paper start - add back applySettings ++ public void applySettings(net.minecraft.world.level.border.WorldBorder.Settings settings) { ++ this.setCenter(settings.centerX(), settings.centerZ()); ++ this.setDamagePerBlock(settings.damagePerBlock()); ++ this.setSafeZone(settings.safeZone()); ++ this.setWarningBlocks(settings.warningBlocks()); ++ this.setWarningTime(settings.warningTime()); ++ if (settings.lerpTime() > 0L) { ++ this.lerpSizeBetween(settings.size(), settings.lerpTarget(), settings.lerpTime(), this.world.getGameTime()); ++ } else { ++ this.setSize(settings.size()); ++ } ++ } ++ // Paper end - add back applySettings ++ + interface BorderExtent { + double getMinX(float partialTick); + +@@ -432,6 +_,7 @@ + this.previousSize = this.size; + this.size = this.calculateSize(); + if (this.lerpProgress <= 0L) { + if (world != null) new io.papermc.paper.event.world.border.WorldBorderBoundsChangeFinishEvent(world.getWorld(), world.getWorld().getWorldBorder(), this.from, this.to, this.lerpDuration).callEvent(); // Paper - Add worldborder events WorldBorder.this.setDirty(); return WorldBorder.this.new StaticBorderExtent(this.to); diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch deleted file mode 100644 index 38bdc3df492c..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch +++ /dev/null @@ -1,97 +0,0 @@ ---- a/net/minecraft/world/level/chunk/storage/ChunkStorage.java -+++ b/net/minecraft/world/level/chunk/storage/ChunkStorage.java -@@ -38,17 +_,30 @@ - return this.worker.isOldChunkAround(pos, radius); - } - -+ // CraftBukkit start - public CompoundTag upgradeChunkTag( -- ResourceKey levelKey, -+ ResourceKey levelKey, - Supplier storage, - CompoundTag chunkData, -- Optional>> chunkGeneratorKey -+ Optional>> chunkGeneratorKey, -+ ChunkPos pos, -+ @Nullable net.minecraft.world.level.LevelAccessor levelAccessor -+ // CraftBukkit end - ) { - int version = getVersion(chunkData); - if (version == SharedConstants.getCurrentVersion().dataVersion().version()) { - return chunkData; - } else { - try { -+ // CraftBukkit start -+ if (version < 1466) { -+ CompoundTag level = chunkData.getCompoundOrEmpty("Level"); -+ if (level.getBooleanOr("TerrainPopulated", false) && !level.getBooleanOr("LightPopulated", false)) { -+ // Light is purged updating to 1.14+. We need to set light populated to true so the converter recognizes the chunk as being "full" -+ level.putBoolean("LightPopulated", true); -+ } -+ } -+ // CraftBukkit end - if (version < 1493) { - chunkData = DataFixTypes.CHUNK.update(this.fixerUpper, chunkData, version, 1493); - if (chunkData.getCompound("Level").flatMap(compoundTag -> compoundTag.getBoolean("hasLegacyStructureData")).orElse(false)) { -@@ -57,8 +_,22 @@ - } - } - -+ // Spigot start - SPIGOT-6806: Quick and dirty way to prevent below zero generation in old chunks, by setting the status to heightmap instead of empty -+ boolean stopBelowZero = false; -+ boolean belowZeroGenerationInExistingChunks = (levelAccessor != null) ? ((net.minecraft.server.level.ServerLevel) levelAccessor).spigotConfig.belowZeroGenerationInExistingChunks : org.spigotmc.SpigotConfig.belowZeroGenerationInExistingChunks; -+ -+ if (version <= 2730 && !belowZeroGenerationInExistingChunks) { -+ stopBelowZero = "full".equals(chunkData.getCompound("Level").flatMap(l -> l.getString("Status")).orElse(null)); -+ } -+ // Spigot end -+ - injectDatafixingContext(chunkData, levelKey, chunkGeneratorKey); - chunkData = DataFixTypes.CHUNK.updateToCurrentVersion(this.fixerUpper, chunkData, Math.max(1493, version)); -+ // Spigot start -+ if (stopBelowZero) { -+ chunkData.putString("Status", net.minecraft.core.registries.BuiltInRegistries.CHUNK_STATUS.getKey(net.minecraft.world.level.chunk.status.ChunkStatus.SPAWN).toString()); -+ } -+ // Spigot end - removeDatafixingContext(chunkData); - NbtUtils.addCurrentDataVersion(chunkData); - return chunkData; -@@ -71,7 +_,7 @@ - } - } - -- private LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, Supplier storage) { -+ private LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, Supplier storage) { // CraftBukkit - LegacyStructureDataHandler legacyStructureDataHandler = this.legacyStructureHandler; - if (legacyStructureDataHandler == null) { - synchronized (this) { -@@ -86,7 +_,7 @@ - } - - public static void injectDatafixingContext( -- CompoundTag chunkData, ResourceKey levelKey, Optional>> chunkGeneratorKey -+ CompoundTag chunkData, ResourceKey levelKey, Optional>> chunkGeneratorKey // CraftBukkit - ) { - CompoundTag compoundTag = new CompoundTag(); - compoundTag.putString("dimension", levelKey.location().toString()); -@@ -107,8 +_,19 @@ - } - - public CompletableFuture write(ChunkPos pos, Supplier tagSupplier) { -+ // Paper start - guard against possible chunk pos desync -+ final Supplier guardedPosCheck = () -> { -+ CompoundTag nbt = tagSupplier.get(); -+ if (nbt != null && !pos.equals(SerializableChunkData.getChunkCoordinate(nbt))) { -+ final String world = (ChunkStorage.this instanceof net.minecraft.server.level.ChunkMap) ? ((net.minecraft.server.level.ChunkMap) ChunkStorage.this).level.getWorld().getName() : null; -+ throw new IllegalArgumentException("Chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + pos -+ + " but compound says coordinate is " + SerializableChunkData.getChunkCoordinate(nbt) + (world == null ? " for an unknown world" : (" for world: " + world))); -+ } -+ return nbt; -+ }; -+ // Paper end - guard against possible chunk pos desync - this.handleLegacyStructureIndex(pos); -- return this.worker.store(pos, tagSupplier); -+ return this.worker.store(pos, guardedPosCheck); // Paper - guard against possible chunk pos desync - } - - protected void handleLegacyStructureIndex(ChunkPos chunkPos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch index cb9fbc094cf6..d35be8fc46a9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch @@ -15,7 +15,7 @@ + // Paper start - guard against serializing mismatching coordinates + // TODO Note: This needs to be re-checked each update + public static ChunkPos getChunkCoordinate(final CompoundTag chunkData) { -+ final int dataVersion = ChunkStorage.getVersion(chunkData); ++ final int dataVersion = NbtUtils.getDataVersion(chunkData); + if (dataVersion < 2842) { // Level tag is removed after this version + final CompoundTag levelData = chunkData.getCompoundOrEmpty("Level"); + return new ChunkPos(levelData.getIntOr("xPos", 0), levelData.getIntOr("zPos", 0)); diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch new file mode 100644 index 000000000000..ad78c58b3e8e --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch @@ -0,0 +1,66 @@ +--- a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java ++++ b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java +@@ -51,19 +_,47 @@ + } + + public CompletableFuture write(ChunkPos chunkPos, Supplier data) { ++ // Paper start - guard against possible chunk pos desync ++ final Supplier guardedPosCheck = () -> { ++ CompoundTag nbt = data.get(); ++ final boolean chunkStorage = this.dataFixType == net.minecraft.util.datafix.DataFixTypes.CHUNK; ++ if (chunkStorage && nbt != null && !chunkPos.equals(SerializableChunkData.getChunkCoordinate(nbt))) { ++ final String world = (SimpleRegionStorage.this instanceof net.minecraft.server.level.ChunkMap) ? ((net.minecraft.server.level.ChunkMap) SimpleRegionStorage.this).level.getWorld().getName() : null; ++ throw new IllegalArgumentException("Chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + chunkPos ++ + " but compound says coordinate is " + SerializableChunkData.getChunkCoordinate(nbt) + (world == null ? " for an unknown world" : (" for world: " + world))); ++ } ++ return nbt; ++ }; ++ // Paper end - guard against possible chunk pos desync + this.markChunkDone(chunkPos); +- return this.worker.store(chunkPos, data); ++ return this.worker.store(chunkPos, guardedPosCheck); // Paper - guard against possible chunk pos desync + } + +- public CompoundTag upgradeChunkTag(CompoundTag tag, int fallbackVersion, @Nullable CompoundTag contextTag) { ++ public CompoundTag upgradeChunkTag(CompoundTag tag, int fallbackVersion, @Nullable CompoundTag contextTag, @Nullable net.minecraft.world.level.LevelAccessor levelAccessor) { // CraftBukkit + int dataVersion = NbtUtils.getDataVersion(tag, fallbackVersion); + if (dataVersion == SharedConstants.getCurrentVersion().dataVersion().version()) { + return tag; + } else { + try { + tag = this.legacyFixer.get().applyFix(tag); ++ // Spigot start - SPIGOT-6806: Quick and dirty way to prevent below zero generation in old chunks, by setting the status to heightmap instead of empty ++ boolean stopBelowZero = false; ++ final boolean chunkStorage = this.dataFixType == net.minecraft.util.datafix.DataFixTypes.CHUNK; ++ if (chunkStorage) { ++ boolean belowZeroGenerationInExistingChunks = (levelAccessor != null) ? ((net.minecraft.server.level.ServerLevel) levelAccessor).spigotConfig.belowZeroGenerationInExistingChunks : org.spigotmc.SpigotConfig.belowZeroGenerationInExistingChunks; ++ ++ if (dataVersion <= 2730 && !belowZeroGenerationInExistingChunks) { ++ stopBelowZero = "full".equals(tag.getCompound("Level").flatMap(l -> l.getString("Status")).orElse(null)); ++ } ++ } ++ // Spigot end + injectDatafixingContext(tag, contextTag); + tag = this.dataFixType.updateToCurrentVersion(this.fixerUpper, tag, Math.max(this.legacyFixer.get().targetDataVersion(), dataVersion)); ++ // Spigot start ++ if (stopBelowZero) { ++ tag.putString("Status", net.minecraft.core.registries.BuiltInRegistries.CHUNK_STATUS.getKey(net.minecraft.world.level.chunk.status.ChunkStatus.SPAWN).toString()); ++ } ++ // Spigot end + removeDatafixingContext(tag); + NbtUtils.addCurrentDataVersion(tag); + return tag; +@@ -77,11 +_,11 @@ + } + + public CompoundTag upgradeChunkTag(CompoundTag tag, int version) { +- return this.upgradeChunkTag(tag, version, null); ++ return this.upgradeChunkTag(tag, version, null, null); // CraftBukkit + } + + public Dynamic upgradeChunkTag(Dynamic tag, int version) { +- return new Dynamic<>(tag.getOps(), this.upgradeChunkTag((CompoundTag)tag.getValue(), version, null)); ++ return new Dynamic<>(tag.getOps(), this.upgradeChunkTag((CompoundTag)tag.getValue(), version, null, null)); // CraftBukkit + } + + public static void injectDatafixingContext(CompoundTag tag, @Nullable CompoundTag contextTag) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch index 5216f0dba60a..0b411864f6da 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -@@ -224,7 +_,7 @@ +@@ -226,7 +_,7 @@ @Override public void buildSurface(WorldGenRegion region, StructureManager structureManager, RandomState random, ChunkAccess chunk) { if (!SharedConstants.debugVoidTerrain(chunk.getPos()) && !SharedConstants.DEBUG_DISABLE_SURFACE) { @@ -9,7 +9,7 @@ this.buildSurface( chunk, worldGenerationContext, -@@ -267,7 +_,7 @@ +@@ -269,7 +_,7 @@ NoiseChunk noiseChunk = chunk.getOrCreateNoiseChunk(chunkAccess -> this.createNoiseChunk(chunkAccess, structureManager, Blender.of(region), random)); Aquifer aquifer = noiseChunk.aquifer(); CarvingContext carvingContext = new CarvingContext( diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch index ae7f643e1962..5c305f72a32d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch @@ -1,24 +1,40 @@ --- a/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java +++ b/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java -@@ -221,17 +_,17 @@ - } +@@ -107,6 +_,15 @@ + @Override + public CompoundTag applyFix(CompoundTag tag) { + int dataVersion = NbtUtils.getDataVersion(tag); ++ // CraftBukkit start ++ if (dataVersion < 1466) { ++ CompoundTag level = tag.getCompoundOrEmpty("Level"); ++ if (level.getBooleanOr("TerrainPopulated", false) && !level.getBooleanOr("LightPopulated", false)) { ++ // Light is purged updating to 1.14+. We need to set light populated to true so the converter recognizes the chunk as being "full" ++ level.putBoolean("LightPopulated", true); ++ } ++ } ++ // CraftBukkit end + if (dataVersion < 1493) { + tag = DataFixTypes.CHUNK.update(this.dataFixer, tag, dataVersion, 1493); + if (tag.getCompound("Level").flatMap(compoundTag -> compoundTag.getBoolean("hasLegacyStructureData")).orElse(false)) { +@@ -249,17 +_,18 @@ } -- public static LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, @Nullable DimensionDataStorage storage) { + public static LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, @Nullable DimensionDataStorage storage, DataFixer dataFixer) { - if (level == Level.OVERWORLD) { -+ public static LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, @Nullable DimensionDataStorage storage) { // CraftBukkit -+ if (level == net.minecraft.world.level.dimension.LevelStem.OVERWORLD) { // CraftBukkit ++ ResourceKey stemKey = net.minecraft.core.registries.Registries.levelToLevelStem(level); // CraftBukkit ++ if (stemKey == net.minecraft.world.level.dimension.LevelStem.OVERWORLD) { // CraftBukkit return new LegacyStructureDataHandler( storage, ImmutableList.of("Monument", "Stronghold", "Village", "Mineshaft", "Temple", "Mansion"), - ImmutableList.of("Village", "Mineshaft", "Mansion", "Igloo", "Desert_Pyramid", "Jungle_Pyramid", "Swamp_Hut", "Stronghold", "Monument") + ImmutableList.of("Village", "Mineshaft", "Mansion", "Igloo", "Desert_Pyramid", "Jungle_Pyramid", "Swamp_Hut", "Stronghold", "Monument"), + dataFixer ); - } else if (level == Level.NETHER) { -+ } else if (level == net.minecraft.world.level.dimension.LevelStem.NETHER) { // CraftBukkit ++ } else if (stemKey == net.minecraft.world.level.dimension.LevelStem.NETHER) { // CraftBukkit List list = ImmutableList.of("Fortress"); - return new LegacyStructureDataHandler(storage, list, list); + return new LegacyStructureDataHandler(storage, list, list, dataFixer); - } else if (level == Level.END) { -+ } else if (level == net.minecraft.world.level.dimension.LevelStem.END) { // CraftBukkit ++ } else if (stemKey == net.minecraft.world.level.dimension.LevelStem.END) { // CraftBukkit List list = ImmutableList.of("EndCity"); - return new LegacyStructureDataHandler(storage, list, list); + return new LegacyStructureDataHandler(storage, list, list, dataFixer); } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch index 30e8373a4848..89126f2147fe 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/StructureCheck.java +++ b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -@@ -41,7 +_,7 @@ +@@ -43,7 +_,7 @@ private final ChunkScanAccess storageAccess; private final RegistryAccess registryAccess; private final StructureTemplateManager structureTemplateManager; @@ -9,7 +9,7 @@ private final ChunkGenerator chunkGenerator; private final RandomState randomState; private final LevelHeightAccessor heightAccessor; -@@ -55,7 +_,7 @@ +@@ -57,7 +_,7 @@ ChunkScanAccess storageAccess, RegistryAccess registryAccess, StructureTemplateManager structureTemplateManager, @@ -18,7 +18,7 @@ ChunkGenerator chunkGenerator, RandomState randomState, LevelHeightAccessor heightAccessor, -@@ -75,6 +_,20 @@ +@@ -77,6 +_,20 @@ this.fixerUpper = fixerUpper; } @@ -39,7 +39,7 @@ public StructureCheckResult checkStart(ChunkPos chunkPos, Structure structure, StructurePlacement placement, boolean skipKnownStructures) { long packedChunkPos = chunkPos.toLong(); Object2IntMap map = this.loadedChunks.get(packedChunkPos); -@@ -84,7 +_,7 @@ +@@ -86,7 +_,7 @@ StructureCheckResult structureCheckResult = this.tryLoadFromStorage(chunkPos, structure, skipKnownStructures, packedChunkPos); if (structureCheckResult != null) { return structureCheckResult; diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelData.java.patch index 06fe93b17e45..41797a9d2508 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/LevelData.java +++ b/net/minecraft/world/level/storage/LevelData.java -@@ -71,5 +_,25 @@ +@@ -72,5 +_,25 @@ public BlockPos pos() { return this.globalPos.pos(); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch index 9ddec50747a5..b157d72a9e89 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/LevelStorageSource.java +++ b/net/minecraft/world/level/storage/LevelStorageSource.java -@@ -145,6 +_,7 @@ +@@ -143,6 +_,7 @@ PrimaryLevelData primaryLevelData = PrimaryLevelData.parse( dynamic, levelSettings, complete.specialWorldProperty(), worldGenSettings.options(), lifecycle ); @@ -8,7 +8,7 @@ return new LevelDataAndDimensions(primaryLevelData, complete); } -@@ -341,25 +_,39 @@ +@@ -339,25 +_,39 @@ return this.backupDir; } @@ -53,7 +53,7 @@ public record LevelCandidates(List levels) implements Iterable { public boolean isEmpty() { return this.levels.isEmpty(); -@@ -410,8 +_,12 @@ +@@ -408,8 +_,12 @@ public final LevelStorageSource.LevelDirectory levelDirectory; private final String levelId; private final Map resources = Maps.newHashMap(); @@ -67,7 +67,7 @@ this.levelId = levelId; this.levelDirectory = new LevelStorageSource.LevelDirectory(levelDir); this.lock = DirectoryLock.create(levelDir); -@@ -454,7 +_,7 @@ +@@ -452,7 +_,7 @@ } public Path getDimensionPath(ResourceKey dimensionPath) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch index 4cd5a8519012..3a9a49e7ff97 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/PlayerDataStorage.java +++ b/net/minecraft/world/level/storage/PlayerDataStorage.java -@@ -33,6 +_,7 @@ +@@ -31,6 +_,7 @@ } public void save(Player player) { @@ -8,7 +8,7 @@ try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(player.problemPath(), LOGGER)) { TagValueOutput tagValueOutput = TagValueOutput.createWithContext(scopedCollector, player.registryAccess()); player.saveWithoutId(tagValueOutput); -@@ -44,7 +_,7 @@ +@@ -42,7 +_,7 @@ Path path3 = path.resolve(player.getStringUUID() + ".dat_old"); Util.safeReplaceFile(path2, path1, path3); } catch (Exception var11) { @@ -17,7 +17,7 @@ } } -@@ -64,9 +_,25 @@ +@@ -62,9 +_,25 @@ private Optional load(NameAndId nameAndId, String suffix) { File file = new File(this.playerDir, nameAndId.id().toString() + suffix); @@ -44,7 +44,7 @@ } catch (Exception var5) { LOGGER.warn("Failed to load player data for {}", nameAndId.name()); } -@@ -86,4 +_,10 @@ +@@ -84,4 +_,10 @@ return DataFixTypes.PLAYER.updateToCurrentVersion(this.fixerUpper, compoundTag, dataVersion); }); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java index d3bb33464742..c9da9c271af2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java @@ -54,7 +54,7 @@ public void setSize(double newSize, TimeUnit unit, long time) { Preconditions.checkArgument(newSize >= 1.0D && newSize <= this.getMaxSize(), "newSize must be between 1.0D and %s", this.getMaxSize()); if (time > 0L) { - this.handle.lerpSizeBetween(this.handle.getSize(), newSize, unit.toMillis(time)); + this.handle.lerpSizeBetween(this.handle.getSize(), newSize, unit.toMillis(time), this.getWorld().getGameTime()); } else { this.handle.setSize(newSize); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index ed52973a4880..70b1792b5f25 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1168,7 +1168,7 @@ public void onSetSize(net.minecraft.world.level.border.WorldBorder border, doubl } @Override - public void onLerpSize(net.minecraft.world.level.border.WorldBorder border, double fromSize, double toSize, long time) { + public void onLerpSize(net.minecraft.world.level.border.WorldBorder border, double fromSize, double toSize, long time, long gameTime) { CraftPlayer.this.getHandle().connection.send(new ClientboundSetBorderLerpSizePacket(border)); } diff --git a/todo-snapshot.txt b/todo-snapshot.txt index 2113000c14fd..fe60a0cdacf9 100644 --- a/todo-snapshot.txt +++ b/todo-snapshot.txt @@ -1,2 +1,4 @@ - Check ServerPlayer bed diffs - anything marked with 'TODO - snapshot' +- 25w43a: + - Connection, ServerConnectionListener - dropped diff for thread pool config (fields gone) From 6e632f5dc18ec162eabb6307508b68b7f794e692 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 21 Oct 2025 11:55:36 -0700 Subject: [PATCH 023/112] Disable oldPaperCommit --- paper-server/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index d4cdf26affec..969f50147faa 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -42,7 +42,7 @@ paperweight { ) updatingMinecraft { - oldPaperCommit = "474d54da728306598f93b4a779578eee5cf54423" + //oldPaperCommit = "474d54da728306598f93b4a779578eee5cf54423" } } From 36624ca53454fee5776b27442176f203a62499fc Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:22:04 -0700 Subject: [PATCH 024/112] Fix ChatTest - use structural comparison instead of string --- paper-server/src/test/java/org/bukkit/ChatTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paper-server/src/test/java/org/bukkit/ChatTest.java b/paper-server/src/test/java/org/bukkit/ChatTest.java index f0d2a694c504..df746527706a 100644 --- a/paper-server/src/test/java/org/bukkit/ChatTest.java +++ b/paper-server/src/test/java/org/bukkit/ChatTest.java @@ -32,8 +32,8 @@ public void testURLJsonConversion() { CraftChatMessage.toJSON(components[0])); components = CraftChatMessage.fromString("123 " + ChatColor.GOLD + "https://spigotmc.org " + ChatColor.BOLD + "test"); - assertEquals("{\"text\":\"\",\"extra\":[\"123 \",{\"text\":\"https://spigotmc.org\",\"strikethrough\":false,\"obfuscated\":false,\"click_event\":{\"url\":\"https://spigotmc.org\",\"action\":\"open_url\"},\"bold\":false,\"italic\":false,\"underlined\":false,\"color\":\"gold\"},{\"text\":\" \",\"strikethrough\":false,\"obfuscated\":false,\"bold\":false,\"italic\":false,\"underlined\":false,\"color\":\"gold\"},{\"text\":\"test\",\"strikethrough\":false,\"obfuscated\":false,\"bold\":true,\"italic\":false,\"underlined\":false,\"color\":\"gold\"}]}", - CraftChatMessage.toJSON(components[0])); + Component expected = CraftChatMessage.fromJSON("{\"text\":\"\",\"extra\":[\"123 \",{\"text\":\"https://spigotmc.org\",\"strikethrough\":false,\"obfuscated\":false,\"click_event\":{\"url\":\"https://spigotmc.org\",\"action\":\"open_url\"},\"bold\":false,\"italic\":false,\"underlined\":false,\"color\":\"gold\"},{\"text\":\" \",\"strikethrough\":false,\"obfuscated\":false,\"bold\":false,\"italic\":false,\"underlined\":false,\"color\":\"gold\"},{\"text\":\"test\",\"strikethrough\":false,\"obfuscated\":false,\"bold\":true,\"italic\":false,\"underlined\":false,\"color\":\"gold\"}]}"); + assertEquals(expected, components[0]); components = CraftChatMessage.fromString("multiCase http://SpigotMC.ORg/SpOngeBobMeEMeGoESHeRE"); assertEquals("{\"text\":\"\",\"extra\":[\"multiCase \",{\"text\":\"http://SpigotMC.ORg/SpOngeBobMeEMeGoESHeRE\",\"click_event\":{\"url\":\"http://SpigotMC.ORg/SpOngeBobMeEMeGoESHeRE\",\"action\":\"open_url\"}}]}", From ec8f013d00fc627220a7213b306017df36dce830 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 21 Oct 2025 17:58:31 -0700 Subject: [PATCH 025/112] Add EntityEffect.HIT --- paper-api/src/main/java/org/bukkit/EntityEffect.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/EntityEffect.java b/paper-api/src/main/java/org/bukkit/EntityEffect.java index 3a53a48472ae..84d2a21a68c7 100644 --- a/paper-api/src/main/java/org/bukkit/EntityEffect.java +++ b/paper-api/src/main/java/org/bukkit/EntityEffect.java @@ -60,6 +60,10 @@ public enum EntityEffect { * delay, only the speed at which the entity in the spawner spins. */ RESET_SPAWNER_MINECART_DELAY(1, SpawnerMinecart.class), + /** + * When a kinetic weapon hits an entity. + */ + HIT(2, LivingEntity.class), /** * When mobs get hurt. * From c663f7c169e900d4723847fcb1ff4a2ee86c8e03 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Thu, 23 Oct 2025 18:15:52 +0200 Subject: [PATCH 026/112] update parchment --- paper-server/build.gradle.kts | 2 +- .../net/minecraft/server/players/PlayerList.java.patch | 2 +- .../net/minecraft/world/level/border/WorldBorder.java.patch | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 969f50147faa..9eedd43da471 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:25w43a+build.3") + mache("io.papermc:mache:25w43a+build.4") paperclip("io.papermc:paperclip:3.0.3") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch index 18b2539e382b..816a7b68f58a 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch @@ -242,7 +242,7 @@ } @Override - public void onLerpSize(WorldBorder border, double oldSize, double newSize, long time, long gameTime) { + public void onLerpSize(WorldBorder border, double oldSize, double newSize, long time, long startTime) { - PlayerList.this.broadcastAll(new ClientboundSetBorderLerpSizePacket(border), level.dimension()); + PlayerList.this.broadcastWorldborder(new ClientboundSetBorderLerpSizePacket(border), level.dimension()); // Paper - virtual world border API } diff --git a/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch b/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch index d58fceb5ede5..5cf15a163f16 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch @@ -65,7 +65,7 @@ @@ -190,6 +_,20 @@ } - public void lerpSizeBetween(double oldSize, double newSize, long time, long gameTime) { + public void lerpSizeBetween(double oldSize, double newSize, long time, long startTime) { + // Paper start - Add worldborder events + if (this.world != null) { + io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type type; @@ -82,7 +82,7 @@ + // Paper end - Add worldborder events this.extent = (WorldBorder.BorderExtent)(oldSize == newSize ? new WorldBorder.StaticBorderExtent(newSize) - : new WorldBorder.MovingBorderExtent(oldSize, newSize, time, gameTime)); + : new WorldBorder.MovingBorderExtent(oldSize, newSize, time, startTime)); @@ -205,6 +_,7 @@ } From bf3c997a0f65cd782b8b8aefb9d5d2c3a31a3930 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Fri, 24 Oct 2025 17:13:17 +0200 Subject: [PATCH 027/112] use the right var for nautilus max air supply --- .../minecraft/world/entity/animal/nautilus/Nautilus.java.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch index 89d5b05c01ed..770f05b5920e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch @@ -11,7 +11,7 @@ + // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + @Override + public int getDefaultMaxAirSupply() { -+ return TOTAL_AIR_SUPPLY; ++ return NAUTILUS_TOTAL_AIR_SUPPLY; + } + // CraftBukkit end From 32ce3d00640995af7dc11fdea8e1aa5361ce9307 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Fri, 24 Oct 2025 17:18:42 +0200 Subject: [PATCH 028/112] run generator --- .../io/papermc/paper/registry/keys/SoundEventKeys.java | 7 +++++++ paper-api/src/main/java/org/bukkit/Sound.java | 2 ++ 2 files changed, 9 insertions(+) diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java index d036d41bcaed..44e34687732d 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java @@ -12156,6 +12156,13 @@ public final class SoundEventKeys { */ public static final TypedKey ITEM_TRIDENT_THUNDER = create(key("item.trident.thunder")); + /** + * {@code minecraft:item.underwater_saddle.equip} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_UNDERWATER_SADDLE_EQUIP = create(key("item.underwater_saddle.equip")); + /** * {@code minecraft:item.wolf_armor.break} * diff --git a/paper-api/src/main/java/org/bukkit/Sound.java b/paper-api/src/main/java/org/bukkit/Sound.java index 7ebb488f47a2..98af1dcf5ae4 100644 --- a/paper-api/src/main/java/org/bukkit/Sound.java +++ b/paper-api/src/main/java/org/bukkit/Sound.java @@ -3489,6 +3489,8 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ITEM_TRIDENT_THUNDER = getSound("item.trident.thunder"); + Sound ITEM_UNDERWATER_SADDLE_EQUIP = getSound("item.underwater_saddle.equip"); + Sound ITEM_WOLF_ARMOR_BREAK = getSound("item.wolf_armor.break"); Sound ITEM_WOLF_ARMOR_CRACK = getSound("item.wolf_armor.crack"); From f7ccc0e32e18f3d6661280458a99053f24aaef7d Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 24 Oct 2025 10:33:54 -0700 Subject: [PATCH 029/112] Fixes after main merge --- .../server/level/ChunkLevel.java.patch | 11 ++++++++ .../server/level/ServerPlayer.java.patch | 16 +++++------ .../server/players/PlayerList.java.patch | 27 ++++++------------- .../minecraft/world/entity/Entity.java.patch | 25 ++++------------- 4 files changed, 32 insertions(+), 47 deletions(-) create mode 100644 paper-server/patches/sources/net/minecraft/server/level/ChunkLevel.java.patch diff --git a/paper-server/patches/sources/net/minecraft/server/level/ChunkLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ChunkLevel.java.patch new file mode 100644 index 000000000000..dd7a296972b8 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/level/ChunkLevel.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/level/ChunkLevel.java ++++ b/net/minecraft/server/level/ChunkLevel.java +@@ -7,7 +_,7 @@ + import org.jetbrains.annotations.Contract; + + public class ChunkLevel { +- private static final int FULL_CHUNK_LEVEL = 33; ++ public static final int FULL_CHUNK_LEVEL = 33; // Paper - public + private static final int BLOCK_TICKING_LEVEL = 32; + public static final int ENTITY_TICKING_LEVEL = 31; + private static final ChunkStep FULL_CHUNK_STEP = ChunkPyramid.GENERATION_PYRAMID.getStepTo(ChunkStatus.FULL); diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index 622e57e6d690..51d856f4c0fd 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -609,7 +609,7 @@ } } -@@ -1001,25 +_,86 @@ +@@ -1001,25 +_,95 @@ } private boolean isPvpAllowed() { @@ -750,7 +750,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1096,17 +_,52 @@ +@@ -1096,13 +_,48 @@ ServerLevel level = teleportTransition.newLevel(); ServerLevel serverLevel = this.level(); @@ -802,7 +802,7 @@ this.connection.resetPosition(); teleportTransition.postTeleportTransition().onTransition(this); return this; -@@ -1101,18 +_,19 @@ +@@ -1113,18 +_,19 @@ this.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); PlayerList playerList = this.server.getPlayerList(); playerList.sendPlayerPermissionLevel(this); @@ -824,7 +824,7 @@ this.connection.resetPosition(); level.addDuringTeleport(this); profilerFiller.pop(); -@@ -1139,10 +_,37 @@ +@@ -1139,6 +_,15 @@ this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(teleportTransition, serverLevel); @@ -840,7 +840,7 @@ return this; } } -@@ -1141,12 +_,26 @@ +@@ -1153,12 +_,26 @@ public void triggerDimensionChangeTriggers(ServerLevel level) { ResourceKey resourceKey = level.dimension(); ResourceKey resourceKey1 = this.level().dimension(); @@ -1226,7 +1226,7 @@ this.seenCredits = that.seenCredits; this.enteredNetherPosition = that.enteredNetherPosition; this.chunkTrackingView = that.chunkTrackingView; -@@ -1629,9 +_,22 @@ +@@ -1651,9 +_,22 @@ CriteriaTriggers.EFFECTS_CHANGED.trigger(this, null); } @@ -1250,7 +1250,7 @@ } @Override -@@ -1640,7 +_,7 @@ +@@ -1662,7 +_,7 @@ } @Override @@ -1526,7 +1526,7 @@ } private static float calculateLookAtYaw(Vec3 position, BlockPos towardsPos) { -@@ -2289,4 +_,138 @@ +@@ -2289,4 +_,135 @@ ); public static final ServerPlayer.SavedPosition EMPTY = new ServerPlayer.SavedPosition(Optional.empty(), Optional.empty(), Optional.empty()); } diff --git a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch index f0fc58d625af..ef9850543f77 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch @@ -458,7 +458,7 @@ set.add(serverPlayer); } } -@@ -380,41 +_,87 @@ +@@ -380,23 +_,31 @@ } for (ServerPlayer serverPlayer2 : set) { @@ -495,7 +495,7 @@ serverPlayer.copyRespawnPosition(player); } -@@ -400,17 +_,26 @@ +@@ -404,17 +_,26 @@ serverPlayer.addTag(string); } @@ -523,9 +523,7 @@ serverPlayer.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); serverPlayer.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); serverPlayer.connection -@@ -422,10 +_,13 @@ - this.sendActivePlayerEffects(serverPlayer); - this.sendLevelInfo(serverPlayer, level); +@@ -424,9 +_,15 @@ this.sendPlayerPermissionLevel(serverPlayer); level.addRespawnedPlayer(serverPlayer); this.players.add(serverPlayer); @@ -540,19 +538,8 @@ + // Paper end ServerPlayer.RespawnConfig respawnConfig = serverPlayer.getRespawnConfig(); if (!keepInventory && respawnConfig != null) { -@@ -449,8 +_,52 @@ - ) - ); - } -+ // Paper start - Add PlayerPostRespawnEvent -+ if (!teleportTransition.missingRespawnBlock()) { -+ if (blockState.is(net.minecraft.tags.BlockTags.BEDS)) { -+ isBedSpawn = true; -+ } else if (blockState.is(Blocks.RESPAWN_ANCHOR)) { -+ isAnchorSpawn = true; -+ } -+ } -+ // Paper end - Add PlayerPostRespawnEvent + LevelData.RespawnData respawnData = respawnConfig.respawnData(); +@@ -452,6 +_,29 @@ } } @@ -581,6 +568,7 @@ + return serverPlayer; } + @@ -460,23 +_,58 @@ } @@ -747,7 +735,8 @@ } public UserWhiteList getWhiteList() { -@@ -645,9 +_,13 @@ +@@ -644,10 +_,18 @@ + player.connection.send(new ClientboundInitializeBorderPacket(worldBorder)); player.connection.send(new ClientboundSetTimePacket(level.getGameTime(), level.getDayTime(), level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); + // Paper start diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch index 986082fb5230..4e937ceab1cb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -152,6 +_,106 @@ +@@ -152,6 +_,105 @@ import org.slf4j.Logger; public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, EntityAccess, ScoreHolder, DataComponentGetter { @@ -605,21 +605,7 @@ } public void snapTo(Vec3 pos) { -<<<<<<< HEAD -@@ -1695,11 +_,19 @@ - } - - public void snapTo(double x, double y, double z, float yRot, float xRot) { -+ // Paper start - Fix Entity Teleportation and cancel velocity if teleported -+ if (!this.preserveMotion) { -+ this.deltaMovement = Vec3.ZERO; -+ } else { -+ this.preserveMotion = false; -+ } -+ // Paper end - Fix Entity Teleportation and cancel velocity if teleported - this.setPosRaw(x, y, z); - this.setYRot(yRot); -@@ -1685,6 +_,7 @@ +@@ -1700,6 +_,7 @@ this.setXRot(xRot); this.setOldPosAndRot(); this.reapplyPosition(); @@ -1579,7 +1565,7 @@ } if (this instanceof WaypointTransmitter waypointTransmitter && this.level instanceof ServerLevel serverLevel) { -@@ -3097,6 +_,7 @@ +@@ -3117,6 +_,7 @@ } public boolean canTeleport(Level fromLevel, Level toLevel) { @@ -1587,7 +1573,7 @@ if (fromLevel.dimension() == Level.END && toLevel.dimension() == Level.OVERWORLD) { for (Entity entity : this.getPassengers()) { if (entity instanceof ServerPlayer serverPlayer && !serverPlayer.seenCredits) { -@@ -3224,8 +_,14 @@ +@@ -3224,13 +_,19 @@ return this.entityData.get(DATA_CUSTOM_NAME_VISIBLE); } @@ -1604,14 +1590,13 @@ return entity != null; } -@@ -3319,7 +_,26 @@ public void dismountTo(double x, double y, double z) { - this.teleportTo(x, y, z); + this.teleportTo(x, y, z); // Paper - diff on change for override } public void teleportTo(double x, double y, double z) { -@@ -3319,7 +_,26 @@ +@@ -3339,7 +_,26 @@ } public final void setBoundingBox(AABB bb) { From a2c5f913c94a7588666a192bac17a60a34e53822 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 24 Oct 2025 13:57:46 -0700 Subject: [PATCH 030/112] Fix removed diff being added back --- .../network/ServerGamePacketListenerImpl.java.patch | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index dde9b33fd8af..56811f7cf333 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -365,7 +365,7 @@ this.player.level().getChunkSource().move(this.player); Vec3 vec3 = new Vec3(rootVehicle.getX() - x, rootVehicle.getY() - y, rootVehicle.getZ() - z); this.handlePlayerKnownMovement(vec3); -@@ -517,12 +_,12 @@ +@@ -517,7 +_,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (packet.getId() == this.awaitingTeleport) { if (this.awaitingPositionFromClient == null) { @@ -374,12 +374,6 @@ return; } - this.player -- .absSnapTo( -+ .snapTo( // Paper - Fix Entity Teleportation and cancel velocity if teleported - this.awaitingPositionFromClient.x, - this.awaitingPositionFromClient.y, - this.awaitingPositionFromClient.z, @@ -534,12 +_,20 @@ this.lastGoodZ = this.awaitingPositionFromClient.z; this.player.hasChangedDimension(); From 8e99d11df968b9f88a108f29e7bfb51f4e1a1e5e Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sun, 26 Oct 2025 11:02:10 -0700 Subject: [PATCH 031/112] Enable unpick on snapshot branch (#13240) --- paper-server/build.gradle.kts | 2 +- .../BoatDispenseItemBehavior.java.patch | 2 +- .../DefaultDispenseItemBehavior.java.patch | 4 +- .../dispenser/DispenseItemBehavior.java.patch | 42 ++--- .../MinecartDispenseItemBehavior.java.patch | 2 +- .../framework/StructureUtils.java.patch | 2 +- .../net/minecraft/network/VarInt.java.patch | 2 +- .../server/ServerScoreboard.java.patch | 2 +- .../server/commands/PlaceCommand.java.patch | 2 +- .../server/level/ServerLevel.java.patch | 58 +++--- .../server/level/ServerPlayer.java.patch | 144 +++++++-------- .../level/ServerPlayerGameMode.java.patch | 2 +- .../server/level/TicketType.java.patch | 12 +- .../ServerGamePacketListenerImpl.java.patch | 160 ++++++++--------- .../server/players/PlayerList.java.patch | 65 +++---- .../world/effect/WeavingMobEffect.java.patch | 8 +- .../minecraft/world/entity/Entity.java.patch | 6 +- .../world/entity/LightningBolt.java.patch | 18 +- .../world/entity/LivingEntity.java.patch | 170 +++++++++--------- .../entity/OminousItemSpawner.java.patch | 8 +- .../AssignProfessionFromJobSite.java.patch | 2 +- .../PrepareRamNearestTarget.java.patch | 2 +- .../entity/ai/behavior/RamTarget.java.patch | 2 +- .../TryLaySpawnOnWaterNearLand.java.patch | 2 +- .../ai/behavior/VillagerMakeLove.java.patch | 4 +- .../ai/behavior/WorkAtComposter.java.patch | 2 +- .../ai/behavior/warden/SonicBoom.java.patch | 2 +- .../entity/ai/goal/BreakDoorGoal.java.patch | 6 +- .../entity/ai/goal/EatBlockGoal.java.patch | 8 +- .../ai/goal/RunAroundLikeCrazyGoal.java.patch | 2 +- .../world/entity/ambient/Bat.java.patch | 12 +- .../world/entity/animal/Animal.java.patch | 12 +- .../world/entity/animal/Bee.java.patch | 24 +-- .../world/entity/animal/Cat.java.patch | 12 +- .../world/entity/animal/Dolphin.java.patch | 12 +- .../world/entity/animal/Fox.java.patch | 22 +-- .../world/entity/animal/IronGolem.java.patch | 4 +- .../world/entity/animal/Ocelot.java.patch | 6 +- .../world/entity/animal/Panda.java.patch | 2 +- .../world/entity/animal/Parrot.java.patch | 10 +- .../world/entity/animal/Pufferfish.java.patch | 12 +- .../world/entity/animal/Rabbit.java.patch | 10 +- .../world/entity/animal/Squid.java.patch | 2 +- .../world/entity/animal/Turtle.java.patch | 14 +- .../entity/animal/allay/Allay.java.patch | 16 +- .../animal/armadillo/Armadillo.java.patch | 8 +- .../animal/coppergolem/CopperGolem.java.patch | 14 +- .../world/entity/animal/goat/Goat.java.patch | 6 +- .../animal/horse/AbstractHorse.java.patch | 22 +-- .../nautilus/AbstractNautilus.java.patch | 6 +- .../entity/animal/sheep/Sheep.java.patch | 6 +- .../entity/animal/sniffer/Sniffer.java.patch | 4 +- .../world/entity/animal/wolf/Wolf.java.patch | 14 +- .../boss/enderdragon/EnderDragon.java.patch | 34 ++-- .../phases/DragonStrafePlayerPhase.java.patch | 4 +- .../entity/boss/wither/WitherBoss.java.patch | 16 +- .../entity/decoration/ArmorStand.java.patch | 30 ++-- .../entity/item/FallingBlockEntity.java.patch | 4 +- .../entity/monster/ElderGuardian.java.patch | 2 +- .../world/entity/monster/EnderMan.java.patch | 2 +- .../world/entity/monster/Ghast.java.patch | 4 +- .../world/entity/monster/Guardian.java.patch | 4 +- .../world/entity/monster/Husk.java.patch | 2 +- .../world/entity/monster/Phantom.java.patch | 10 +- .../world/entity/monster/Ravager.java.patch | 4 +- .../entity/monster/Silverfish.java.patch | 2 +- .../world/entity/monster/Skeleton.java.patch | 4 +- .../world/entity/monster/Witch.java.patch | 8 +- .../world/entity/monster/Zombie.java.patch | 30 ++-- .../entity/monster/ZombieVillager.java.patch | 10 +- .../monster/creaking/Creaking.java.patch | 6 +- .../entity/monster/hoglin/Hoglin.java.patch | 2 +- .../entity/monster/warden/Warden.java.patch | 4 +- .../world/entity/npc/Villager.java.patch | 26 +-- .../world/entity/player/Player.java.patch | 64 +++---- .../projectile/AbstractArrow.java.patch | 10 +- .../AbstractThrownPotion.java.patch | 8 +- .../projectile/DragonFireball.java.patch | 4 +- .../entity/projectile/EvokerFangs.java.patch | 4 +- .../entity/projectile/EyeOfEnder.java.patch | 6 +- .../FireworkRocketEntity.java.patch | 16 +- .../entity/projectile/FishingHook.java.patch | 30 ++-- .../entity/projectile/Snowball.java.patch | 4 +- .../entity/projectile/ThrownEgg.java.patch | 4 +- .../ThrownExperienceBottle.java.patch | 4 +- .../entity/vehicle/MinecartTNT.java.patch | 8 +- .../AbstractContainerMenu.java.patch | 2 +- .../world/inventory/AnvilMenu.java.patch | 26 +-- .../world/inventory/GrindstoneMenu.java.patch | 16 +- .../world/inventory/SmithingMenu.java.patch | 8 +- .../world/item/BoneMealItem.java.patch | 8 +- .../world/item/EnderEyeItem.java.patch | 10 +- .../world/item/FlintAndSteelItem.java.patch | 8 +- .../world/item/HoneycombItem.java.patch | 2 +- .../minecraft/world/item/MaceItem.java.patch | 4 +- .../world/item/ShovelItem.java.patch | 6 +- .../world/item/SpawnEggItem.java.patch | 8 +- .../world/level/BaseSpawner.java.patch | 14 +- .../world/level/GameRules.java.patch | 86 ++++----- .../minecraft/world/level/Level.java.patch | 34 ++-- .../level/block/BambooSaplingBlock.java.patch | 2 +- .../level/block/BambooStalkBlock.java.patch | 6 +- .../block/BasePressurePlateBlock.java.patch | 2 +- .../world/level/block/BedBlock.java.patch | 4 +- .../level/block/BigDripleafBlock.java.patch | 2 +- .../world/level/block/ButtonBlock.java.patch | 2 +- .../world/level/block/CactusBlock.java.patch | 2 +- .../world/level/block/CakeBlock.java.patch | 2 +- .../level/block/CampfireBlock.java.patch | 2 +- .../level/block/CauldronBlock.java.patch | 4 +- .../level/block/ChorusFlowerBlock.java.patch | 12 +- .../world/level/block/CocoaBlock.java.patch | 4 +- .../level/block/ComparatorBlock.java.patch | 4 +- .../level/block/ComposterBlock.java.patch | 6 +- .../block/ConcretePowderBlock.java.patch | 2 +- .../block/CopperGolemStatueBlock.java.patch | 2 +- .../world/level/block/CoralBlock.java.patch | 2 +- .../level/block/CoralFanBlock.java.patch | 2 +- .../level/block/CoralPlantBlock.java.patch | 2 +- .../level/block/CoralWallFanBlock.java.patch | 2 +- .../world/level/block/CrafterBlock.java.patch | 2 +- .../world/level/block/CropBlock.java.patch | 4 +- .../block/DaylightDetectorBlock.java.patch | 2 +- .../level/block/DecoratedPotBlock.java.patch | 2 +- .../level/block/DetectorRailBlock.java.patch | 2 +- .../world/level/block/DiodeBlock.java.patch | 4 +- .../level/block/DispenserBlock.java.patch | 2 +- .../level/block/DriedGhastBlock.java.patch | 2 +- .../world/level/block/DropperBlock.java.patch | 2 +- .../world/level/block/FarmBlock.java.patch | 4 +- .../level/block/FenceGateBlock.java.patch | 2 +- .../world/level/block/FireBlock.java.patch | 4 +- .../level/block/FlowerPotBlock.java.patch | 2 +- .../world/level/block/HoneyBlock.java.patch | 2 +- .../block/LayeredCauldronBlock.java.patch | 2 +- .../world/level/block/LecternBlock.java.patch | 2 +- .../level/block/LightningRodBlock.java.patch | 2 +- .../level/block/MultifaceSpreader.java.patch | 2 +- .../level/block/MushroomBlock.java.patch | 2 +- .../level/block/NetherWartBlock.java.patch | 2 +- .../world/level/block/NoteBlock.java.patch | 4 +- .../level/block/ObserverBlock.java.patch | 4 +- .../level/block/PitcherCropBlock.java.patch | 4 +- .../block/PointedDripstoneBlock.java.patch | 4 +- .../level/block/PoweredRailBlock.java.patch | 2 +- .../world/level/block/PumpkinBlock.java.patch | 2 +- .../world/level/block/RailState.java.patch | 2 +- .../level/block/RedStoneOreBlock.java.patch | 4 +- .../level/block/RedstoneLampBlock.java.patch | 4 +- .../level/block/RedstoneTorchBlock.java.patch | 6 +- .../world/level/block/SaplingBlock.java.patch | 2 +- .../world/level/block/SculkBlock.java.patch | 2 +- .../level/block/SculkSensorBlock.java.patch | 4 +- .../level/block/SculkVeinBlock.java.patch | 2 +- .../level/block/SnifferEggBlock.java.patch | 4 +- .../world/level/block/SpongeBlock.java.patch | 4 +- .../world/level/block/StemBlock.java.patch | 4 +- .../level/block/SugarCaneBlock.java.patch | 4 +- .../block/SweetBerryBushBlock.java.patch | 2 +- .../world/level/block/TntBlock.java.patch | 2 +- .../level/block/TripWireBlock.java.patch | 2 +- .../level/block/TripWireHookBlock.java.patch | 6 +- .../level/block/TurtleEggBlock.java.patch | 2 +- .../world/level/block/VineBlock.java.patch | 18 +- .../AbstractFurnaceBlockEntity.java.patch | 20 +-- .../block/entity/BarrelBlockEntity.java.patch | 2 +- .../entity/BrewingStandBlockEntity.java.patch | 16 +- .../entity/BrushableBlockEntity.java.patch | 16 +- .../entity/CampfireBlockEntity.java.patch | 12 +- .../ChiseledBookShelfBlockEntity.java.patch | 8 +- .../entity/CrafterBlockEntity.java.patch | 2 +- .../entity/JukeboxBlockEntity.java.patch | 6 +- .../SculkCatalystBlockEntity.java.patch | 2 +- .../SculkShriekerBlockEntity.java.patch | 4 +- .../block/entity/ShelfBlockEntity.java.patch | 2 +- .../block/entity/SignBlockEntity.java.patch | 16 +- .../entity/TestInstanceBlockEntity.java.patch | 4 +- .../trialspawner/TrialSpawner.java.patch | 6 +- .../TrialSpawnerStateData.java.patch | 2 +- .../entity/vault/VaultBlockEntity.java.patch | 10 +- .../level/block/grower/TreeGrower.java.patch | 2 +- .../block/piston/PistonBaseBlock.java.patch | 18 +- .../piston/PistonMovingBlockEntity.java.patch | 4 +- .../world/level/chunk/ChunkAccess.java.patch | 2 +- .../world/level/chunk/LevelChunk.java.patch | 14 +- .../end/DragonRespawnAnimation.java.patch | 4 +- .../dimension/end/EndDragonFight.java.patch | 24 +-- .../feature/EndPlatformFeature.java.patch | 2 +- .../structure/StructurePiece.java.patch | 4 +- .../DesertPyramidStructure.java.patch | 4 +- .../structures/IglooPieces.java.patch | 4 +- .../structures/MineshaftPieces.java.patch | 2 +- .../NetherFortressPieces.java.patch | 4 +- .../structures/OceanRuinPieces.java.patch | 12 +- .../structures/StrongholdPieces.java.patch | 4 +- .../StructureTemplate.java.patch | 2 +- .../level/material/FlowingFluid.java.patch | 6 +- .../world/level/material/LavaFluid.java.patch | 12 +- .../level/portal/PortalForcer.java.patch | 18 +- .../world/level/portal/PortalShape.java.patch | 16 +- .../portal/TeleportTransition.java.patch | 10 +- .../DefaultRedstoneWireEvaluator.java.patch | 4 +- ...perimentalRedstoneWireEvaluator.java.patch | 6 +- 203 files changed, 1058 insertions(+), 1051 deletions(-) diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 9eedd43da471..a4aefc863e16 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:25w43a+build.4") + mache("io.papermc:mache:25w43a+build.5") paperclip("io.papermc:paperclip:3.0.3") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch index e0aa37968018..cdf7f08ddbe2 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java -@@ -40,13 +_,36 @@ +@@ -41,13 +_,36 @@ d4 = 0.0; } diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java.patch index 603010595cd9..9007c067cefe 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java -@@ -9,24 +_,37 @@ +@@ -10,24 +_,37 @@ public class DefaultDispenseItemBehavior implements DispenseItemBehavior { private static final int DEFAULT_ACCURACY = 6; @@ -41,7 +41,7 @@ double d = position.x(); double d1 = position.y(); double d2 = position.z(); -@@ -43,7 +_,43 @@ +@@ -44,7 +_,43 @@ level.random.triangle(0.2, 0.0172275 * speed), level.random.triangle(facing.getStepZ() * d3, 0.0172275 * speed) ); diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index 886acbeaaad2..b104f6654b05 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -85,10 +_,38 @@ +@@ -87,10 +_,38 @@ if (type == null) { return item; } else { @@ -40,7 +40,7 @@ null, blockSource.pos().relative(direction), EntitySpawnReason.DISPENSER, -@@ -100,7 +_,8 @@ +@@ -102,7 +_,8 @@ return ItemStack.EMPTY; } @@ -50,7 +50,7 @@ blockSource.level().gameEvent(null, GameEvent.ENTITY_PLACE, blockSource.pos()); return item; } -@@ -119,12 +_,38 @@ +@@ -121,12 +_,38 @@ Direction direction = blockSource.state().getValue(DispenserBlock.FACING); BlockPos blockPos = blockSource.pos().relative(direction); ServerLevel serverLevel = blockSource.level(); @@ -91,7 +91,7 @@ } return item; -@@ -144,8 +_,35 @@ +@@ -146,8 +_,35 @@ new AABB(blockPos), abstractChestedHorse1 -> abstractChestedHorse1.isAlive() && !abstractChestedHorse1.hasChest() )) { @@ -129,7 +129,7 @@ this.setSuccess(true); return item; } -@@ -183,8 +_,45 @@ +@@ -185,8 +_,45 @@ DispensibleContainerItem dispensibleContainerItem = (DispensibleContainerItem)item.getItem(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); Level level = blockSource.level(); @@ -176,7 +176,7 @@ return this.consumeWithRemainder(blockSource, item, new ItemStack(Items.BUCKET)); } else { return this.defaultDispenseItemBehavior.dispense(blockSource, item); -@@ -207,12 +_,19 @@ +@@ -209,12 +_,19 @@ BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); BlockState blockState = levelAccessor.getBlockState(blockPos); if (blockState.getBlock() instanceof BucketPickup bucketPickup) { @@ -197,7 +197,7 @@ return this.consumeWithRemainder(blockSource, item, new ItemStack(item1)); } } else { -@@ -227,15 +_,26 @@ +@@ -229,15 +_,26 @@ this.setSuccess(true); Direction direction = blockSource.state().getValue(DispenserBlock.FACING); BlockPos blockPos = blockSource.pos().relative(direction); @@ -227,7 +227,7 @@ serverLevel.removeBlock(blockPos, false); } else { this.setSuccess(false); -@@ -257,11 +_,46 @@ +@@ -259,11 +_,46 @@ this.setSuccess(true); Level level = blockSource.level(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); @@ -242,7 +242,7 @@ if (!BoneMealItem.growCrop(item, level, blockPos) && !BoneMealItem.growWaterPlant(item, level, blockPos, null)) { this.setSuccess(false); } else if (!level.isClientSide()) { - level.levelEvent(1505, blockPos, 15); + level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, blockPos, 15); } + // CraftBukkit start + level.captureTreeGeneration = false; @@ -274,7 +274,7 @@ return item; } -@@ -275,11 +_,36 @@ +@@ -277,11 +_,36 @@ return item; } else { BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); @@ -314,7 +314,7 @@ this.setSuccess(true); return item; } -@@ -293,6 +_,13 @@ +@@ -295,6 +_,13 @@ Level level = blockSource.level(); Direction direction = blockSource.state().getValue(DispenserBlock.FACING); BlockPos blockPos = blockSource.pos().relative(direction); @@ -328,7 +328,7 @@ if (level.isEmptyBlock(blockPos) && WitherSkullBlock.canSpawnMob(level, blockPos, item)) { level.setBlock( blockPos, -@@ -308,7 +_,7 @@ +@@ -310,7 +_,7 @@ item.shrink(1); this.setSuccess(true); } else { @@ -337,7 +337,7 @@ } return item; -@@ -321,6 +_,13 @@ +@@ -323,6 +_,13 @@ Level level = blockSource.level(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); CarvedPumpkinBlock carvedPumpkinBlock = (CarvedPumpkinBlock)Blocks.CARVED_PUMPKIN; @@ -350,8 +350,8 @@ + // Paper end - Call BlockDispenseEvent if (level.isEmptyBlock(blockPos) && carvedPumpkinBlock.canSpawnGolem(level, blockPos)) { if (!level.isClientSide()) { - level.setBlock(blockPos, carvedPumpkinBlock.defaultBlockState(), 3); -@@ -330,7 +_,7 @@ + level.setBlock(blockPos, carvedPumpkinBlock.defaultBlockState(), Block.UPDATE_ALL); +@@ -332,7 +_,7 @@ item.shrink(1); this.setSuccess(true); } else { @@ -360,7 +360,7 @@ } return item; -@@ -356,6 +_,12 @@ +@@ -358,6 +_,12 @@ ServerLevel serverLevel = blockSource.level(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); BlockState blockState = serverLevel.getBlockState(blockPos); @@ -373,7 +373,7 @@ if (blockState.is( BlockTags.BEEHIVES, blockStateBase -> blockStateBase.hasProperty(BeehiveBlock.HONEY_LEVEL) && blockStateBase.getBlock() instanceof BeehiveBlock -@@ -384,6 +_,13 @@ +@@ -386,6 +_,13 @@ this.setSuccess(true); if (blockState.is(Blocks.RESPAWN_ANCHOR)) { if (blockState.getValue(RespawnAnchorBlock.CHARGE) != 4) { @@ -387,7 +387,7 @@ RespawnAnchorBlock.charge(null, level, blockPos, blockState); item.shrink(1); } else { -@@ -407,6 +_,28 @@ +@@ -409,6 +_,28 @@ this.setSuccess(false); return item; } else { @@ -416,7 +416,7 @@ for (Armadillo armadillo : entitiesOfClass) { if (armadillo.brushOffScute(null, item)) { item.hurtAndBreak(16, serverLevel, null, item1 -> {}); -@@ -427,6 +_,13 @@ +@@ -429,6 +_,13 @@ BlockState blockState = level.getBlockState(blockPos); Optional waxed = HoneycombItem.getWaxed(blockState); if (waxed.isPresent()) { @@ -428,9 +428,9 @@ + } + // Paper end - Call BlockDispenseEvent level.setBlockAndUpdate(blockPos, waxed.get()); - level.levelEvent(3003, blockPos, 0); + level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_WAX_ON, blockPos, 0); item.shrink(1); -@@ -454,6 +_,12 @@ +@@ -456,6 +_,12 @@ if (!serverLevel.getBlockState(blockPos1).is(BlockTags.CONVERTABLE_TO_MUD)) { return this.defaultDispenseItemBehavior.dispense(blockSource, item); } else { diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java.patch index 4622e161cd0e..0acafa1f5ab3 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java -@@ -57,12 +_,35 @@ +@@ -58,12 +_,35 @@ } Vec3 vec31 = new Vec3(d, d1 + d3, d2); diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch index b39ead649c35..b367e2c5afda 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/StructureUtils.java +++ b/net/minecraft/gametest/framework/StructureUtils.java -@@ -84,7 +_,7 @@ +@@ -85,7 +_,7 @@ level.clearBlockEvents(boundingBox); AABB aabb = AABB.of(boundingBox); List entitiesOfClass = level.getEntitiesOfClass(Entity.class, aabb, entity -> !(entity instanceof Player)); diff --git a/paper-server/patches/sources/net/minecraft/network/VarInt.java.patch b/paper-server/patches/sources/net/minecraft/network/VarInt.java.patch index 0a231249691f..8604de1e1d78 100644 --- a/paper-server/patches/sources/net/minecraft/network/VarInt.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/VarInt.java.patch @@ -16,7 +16,7 @@ + } + public static int getByteSizeOld(int data) { + // Paper end - Optimize VarInts - for (int i = 1; i < 5; i++) { + for (int i = 1; i < MAX_VARINT_SIZE; i++) { if ((data & -1 << i * 7) == 0) { return i; @@ -39,6 +_,21 @@ diff --git a/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch b/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch index 619f2eb4210e..bde4eb4ab7c6 100644 --- a/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch @@ -110,7 +110,7 @@ public void onObjectiveChanged(Objective objective) { super.onObjectiveChanged(objective); if (this.trackedObjectives.contains(objective)) { -- this.server.getPlayerList().broadcastAll(new ClientboundSetObjectivePacket(objective, 2)); +- this.server.getPlayerList().broadcastAll(new ClientboundSetObjectivePacket(objective, ClientboundSetObjectivePacket.METHOD_CHANGE)); + this.broadcastAll(new ClientboundSetObjectivePacket(objective, 2)); // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch index b84004a499f8..2fd0cc8bcb2a 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/PlaceCommand.java +++ b/net/minecraft/server/commands/PlaceCommand.java -@@ -301,6 +_,7 @@ +@@ -302,6 +_,7 @@ if (!structureStart.isValid()) { throw ERROR_STRUCTURE_FAILED.create(); } else { diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch index ddcca2e71b07..0fcaf074de05 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -409,7 +409,7 @@ if (this.oRainLevel != this.rainLevel) { this.server .getPlayerList() -@@ -765,14 +_,47 @@ +@@ -769,14 +_,47 @@ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -461,7 +461,7 @@ } public void resetEmptyTime() { -@@ -794,18 +_,46 @@ +@@ -798,18 +_,46 @@ } } @@ -508,7 +508,7 @@ } private void tickPassenger(Entity ridingEntity, Entity passengerEntity) { -@@ -814,10 +_,12 @@ +@@ -818,10 +_,12 @@ } else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) { passengerEntity.setOldPosAndRot(); passengerEntity.tickCount++; @@ -521,7 +521,7 @@ profilerFiller.pop(); for (Entity entity : passengerEntity.getPassengers()) { -@@ -848,6 +_,7 @@ +@@ -852,6 +_,7 @@ public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) { ServerChunkCache chunkSource = this.getChunkSource(); if (!skipSave) { @@ -529,7 +529,7 @@ if (progress != null) { progress.progressStartNoAbort(Component.translatable("menu.savingLevel")); } -@@ -864,11 +_,18 @@ +@@ -868,11 +_,18 @@ this.entityManager.autoSave(); } } @@ -549,7 +549,7 @@ } DimensionDataStorage dataStorage = this.getChunkSource().getDataStorage(); -@@ -933,18 +_,40 @@ +@@ -937,18 +_,40 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -593,7 +593,7 @@ } } -@@ -967,41 +_,120 @@ +@@ -971,41 +_,120 @@ this.entityManager.addNewEntity(player); } @@ -719,7 +719,7 @@ if (d * d + d1 * d1 + d2 * d2 < 1024.0) { serverPlayer.connection.send(new ClientboundBlockDestructionPacket(breakerId, pos, progress)); } -@@ -1076,7 +_,7 @@ +@@ -1080,7 +_,7 @@ pos.getX(), pos.getY(), pos.getZ(), @@ -728,7 +728,7 @@ this.dimension(), new ClientboundLevelEventPacket(type, pos, data, false) ); -@@ -1088,6 +_,11 @@ +@@ -1092,6 +_,11 @@ @Override public void gameEvent(Holder gameEvent, Vec3 pos, GameEvent.Context context) { @@ -740,7 +740,7 @@ this.gameEventDispatcher.post(gameEvent, pos, context); } -@@ -1100,17 +_,28 @@ +@@ -1104,17 +_,28 @@ this.getChunkSource().blockChanged(pos); this.pathTypesByPosCache.invalidate(pos); @@ -769,7 +769,7 @@ try { this.isUpdatingNavigations = true; -@@ -1122,15 +_,23 @@ +@@ -1126,15 +_,23 @@ this.isUpdatingNavigations = false; } } @@ -793,7 +793,7 @@ this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, block, null, orientation); } -@@ -1180,6 +_,44 @@ +@@ -1184,6 +_,44 @@ WeightedList blockParticles, Holder explosionSound ) { @@ -838,7 +838,7 @@ Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) { case NONE -> Explosion.BlockInteraction.KEEP; case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); -@@ -1188,10 +_,17 @@ +@@ -1192,10 +_,17 @@ : Explosion.BlockInteraction.KEEP; case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY); case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; @@ -856,7 +856,7 @@ ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles; for (ServerPlayer serverPlayer : this.players) { -@@ -1200,6 +_,8 @@ +@@ -1204,6 +_,8 @@ serverPlayer.connection.send(new ClientboundExplodePacket(vec3, radius, i, optional, particleOptions, explosionSound, blockParticles)); } } @@ -865,7 +865,7 @@ } private Explosion.BlockInteraction getDestroyType(GameRules.Key decayGameRule) { -@@ -1270,19 +_,55 @@ +@@ -1274,19 +_,55 @@ public int sendParticles( T options, double x, double y, double z, int count, double xDist, double yDist, double zDist, double speed ) { @@ -924,7 +924,7 @@ if (this.sendParticles(serverPlayer, overrideLimiter, x, y, z, clientboundLevelParticlesPacket)) { i++; } -@@ -1371,7 +_,7 @@ +@@ -1375,7 +_,7 @@ @Nullable public BlockPos findNearestMapStructure(TagKey structureTag, BlockPos pos, int radius, boolean skipKnownStructures) { @@ -933,7 +933,7 @@ return null; } else { Optional> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag); -@@ -1425,10 +_,36 @@ +@@ -1429,10 +_,36 @@ @Nullable @Override public MapItemSavedData getMapData(MapId mapId) { @@ -971,7 +971,7 @@ this.getServer().overworld().getDataStorage().set(MapItemSavedData.type(mapId), data); } -@@ -1438,7 +_,19 @@ +@@ -1442,7 +_,19 @@ @Override public void setRespawnData(LevelData.RespawnData respawnData) { @@ -992,7 +992,7 @@ } @Override -@@ -1475,6 +_,11 @@ +@@ -1479,6 +_,11 @@ this.debugSynchronizers.dropPoi(blockPos); })); optional1.ifPresent(holder -> this.getServer().execute(() -> { @@ -1004,7 +1004,7 @@ PoiRecord poiRecord = this.getPoiManager().add(blockPos, (Holder)holder); if (poiRecord != null) { this.debugSynchronizers.registerPoi(poiRecord); -@@ -1629,12 +_,12 @@ +@@ -1633,12 +_,12 @@ } public boolean isFlat() { @@ -1019,7 +1019,7 @@ } @Nullable -@@ -1685,6 +_,7 @@ +@@ -1689,6 +_,7 @@ @Override public LevelEntityGetter getEntities() { @@ -1027,7 +1027,7 @@ return this.entityManager.getEntityGetter(); } -@@ -1795,6 +_,28 @@ +@@ -1799,6 +_,28 @@ return this.serverLevelData.getGameRules(); } @@ -1056,7 +1056,7 @@ @Override public CrashReportCategory fillReportDetails(CrashReport report) { CrashReportCategory crashReportCategory = super.fillReportDetails(report); -@@ -1839,6 +_,7 @@ +@@ -1843,6 +_,7 @@ if (entity instanceof WaypointTransmitter waypointTransmitter && waypointTransmitter.isTransmittingWaypoint()) { ServerLevel.this.getWaypointManager().trackWaypoint(waypointTransmitter); } @@ -1064,7 +1064,7 @@ } @Override -@@ -1852,17 +_,24 @@ +@@ -1856,17 +_,24 @@ @Override public void onTickingStart(Entity entity) { @@ -1090,7 +1090,7 @@ if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.add(serverPlayer); if (serverPlayer.isReceivingWaypoints()) { -@@ -1877,7 +_,7 @@ +@@ -1881,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1099,7 +1099,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1894,10 +_,52 @@ +@@ -1898,10 +_,52 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -1152,7 +1152,7 @@ ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); -@@ -1906,7 +_,7 @@ +@@ -1910,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1161,7 +1161,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1924,6 +_,15 @@ +@@ -1928,6 +_,15 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); ServerLevel.this.debugSynchronizers.dropEntity(entity); @@ -1177,7 +1177,7 @@ } @Override -@@ -1931,4 +_,24 @@ +@@ -1935,4 +_,24 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::move); } } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index 51d856f4c0fd..cbe6cd1e9946 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -256,7 +_,8 @@ +@@ -257,7 +_,8 @@ private int levitationStartTime; private boolean disconnected; private int requestedViewDistance = 2; @@ -10,7 +10,7 @@ @Nullable private Vec3 startingToFallPosition; @Nullable -@@ -305,6 +_,13 @@ +@@ -306,6 +_,13 @@ } } @@ -24,7 +24,7 @@ @Override public void sendSlotChange(AbstractContainerMenu container, int slot, ItemStack stack) { ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(container.containerId, container.incrementStateId(), slot, stack)); -@@ -340,6 +_,32 @@ +@@ -341,6 +_,32 @@ } } @@ -57,7 +57,7 @@ @Override public void dataChanged(AbstractContainerMenu containerMenu, int dataSlotIndex, int value) { } -@@ -368,10 +_,43 @@ +@@ -369,10 +_,43 @@ public void sendSystemMessage(Component message) { ServerPlayer.this.sendSystemMessage(message); } @@ -101,7 +101,7 @@ public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) { super(level, gameProfile); -@@ -382,8 +_,14 @@ +@@ -383,8 +_,14 @@ this.recipeBook = new ServerRecipeBook((recipe, output) -> server.getRecipeManager().listDisplaysForRecipe(recipe, output)); this.stats = server.getPlayerList().getPlayerStats(this); this.advancements = server.getPlayerList().getPlayerAdvancements(this); @@ -117,7 +117,7 @@ } @Override -@@ -401,6 +_,7 @@ +@@ -402,6 +_,7 @@ this.seenCredits = input.getBooleanOr("seenCredits", false); input.read("recipeBook", ServerRecipeBook.Packed.CODEC) .ifPresent(packed -> this.recipeBook.loadUntrusted(packed, key -> this.server.getRecipeManager().byKey(key).isPresent())); @@ -125,7 +125,7 @@ if (this.isSleeping()) { this.stopSleeping(); } -@@ -408,6 +_,19 @@ +@@ -409,6 +_,19 @@ this.respawnConfig = input.read("respawn", ServerPlayer.RespawnConfig.CODEC).orElse(null); this.spawnExtraParticlesOnFall = input.getBooleanOr("spawn_extra_particles_on_fall", false); this.raidOmenPosition = input.read("raid_omen_position", BlockPos.CODEC).orElse(null); @@ -145,7 +145,7 @@ this.gameMode .setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(input, "playerGameType")), readPlayerMode(input, "previousPlayerGameType")); this.setShoulderEntityLeft(input.read("ShoulderEntityLeft", CompoundTag.CODEC).orElseGet(CompoundTag::new)); -@@ -435,12 +_,24 @@ +@@ -436,12 +_,24 @@ if (!this.getShoulderEntityRight().isEmpty()) { output.store("ShoulderEntityRight", CompoundTag.CODEC, this.getShoulderEntityRight()); } @@ -171,7 +171,7 @@ ValueOutput valueOutput = output.child("RootVehicle"); valueOutput.store("Attach", UUIDUtil.CODEC, vehicle.getUUID()); rootVehicle.save(valueOutput.child("Entity")); -@@ -452,7 +_,7 @@ +@@ -453,7 +_,7 @@ if (!optional.isEmpty()) { ServerLevel serverLevel = this.level(); Entity entity = EntityType.loadEntityRecursive( @@ -180,7 +180,7 @@ ); if (entity != null) { UUID uuid = optional.get().read("Attach", UUIDUtil.CODEC).orElse(null); -@@ -469,10 +_,10 @@ +@@ -470,10 +_,10 @@ if (!this.isPassenger()) { LOGGER.warn("Couldn't reattach entity to player"); @@ -193,7 +193,7 @@ } } } -@@ -484,6 +_,7 @@ +@@ -485,6 +_,7 @@ ValueOutput.ValueOutputList valueOutputList = output.childrenList("ender_pearls"); for (ThrownEnderpearl thrownEnderpearl : this.enderPearls) { @@ -201,7 +201,7 @@ if (thrownEnderpearl.isRemoved()) { LOGGER.warn("Trying to save removed ender pearl, skipping"); } else { -@@ -516,6 +_,16 @@ +@@ -517,6 +_,16 @@ } } @@ -218,7 +218,7 @@ public void setExperiencePoints(int experiencePoints) { float f = this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -580,6 +_,11 @@ +@@ -581,6 +_,11 @@ @Override public void tick() { @@ -230,7 +230,7 @@ this.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); -@@ -587,9 +_,18 @@ +@@ -588,9 +_,18 @@ this.invulnerableTime--; } @@ -252,7 +252,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -648,10 +_,10 @@ +@@ -649,10 +_,10 @@ public void doTick() { try { @@ -265,7 +265,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -681,7 +_,7 @@ +@@ -682,7 +_,7 @@ if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -274,7 +274,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -712,6 +_,12 @@ +@@ -713,6 +_,12 @@ this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float)this.lastRecordedExperience)); } @@ -287,7 +287,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float)this.lastRecordedLevel)); -@@ -725,6 +_,21 @@ +@@ -726,6 +_,21 @@ if (this.tickCount % 20 == 0) { CriteriaTriggers.LOCATION.trigger(this); } @@ -309,7 +309,7 @@ } catch (Throwable var4) { CrashReport crashReport = CrashReport.forThrowable(var4, "Ticking player"); CrashReportCategory crashReportCategory = crashReport.addCategory("Player being ticked"); -@@ -749,7 +_,7 @@ +@@ -750,7 +_,7 @@ if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { if (this.tickCount % 20 == 0) { if (this.getHealth() < this.getMaxHealth()) { @@ -318,7 +318,7 @@ } float saturationLevel = this.foodData.getSaturationLevel(); -@@ -769,6 +_,7 @@ +@@ -770,6 +_,7 @@ this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft()); this.playShoulderEntityAmbientSound(this.getShoulderEntityRight()); if (this.fallDistance > 0.5 || this.isInWater() || this.getAbilities().flying || this.isSleeping() || this.isInPowderSnow) { @@ -326,7 +326,7 @@ this.removeEntitiesOnShoulder(); } } -@@ -813,35 +_,64 @@ +@@ -814,35 +_,64 @@ @Override public void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { @@ -398,7 +398,7 @@ } @Override -@@ -878,15 +_,36 @@ +@@ -879,15 +_,36 @@ } private void updateScoreForCriteria(ObjectiveCriteria criteria, int points) { @@ -444,7 +444,7 @@ this.connection .send( new ClientboundPlayerCombatKillPacket(this.getId(), deathMessage), -@@ -903,6 +_,65 @@ +@@ -904,6 +_,65 @@ } ) ); @@ -510,7 +510,7 @@ Team team = this.getTeam(); if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) { this.server.getPlayerList().broadcastSystemMessage(deathMessage, false); -@@ -912,7 +_,7 @@ +@@ -913,7 +_,7 @@ this.server.getPlayerList().broadcastSystemToAllExceptTeam(this, deathMessage); } } else { @@ -519,7 +519,7 @@ } this.removeEntitiesOnShoulder(); -@@ -920,11 +_,35 @@ +@@ -921,11 +_,35 @@ this.tellNeutralMobsThatIDied(); } @@ -558,7 +558,7 @@ LivingEntity killCredit = this.getKillCredit(); if (killCredit != null) { this.awardStat(Stats.ENTITY_KILLED_BY.get(killCredit.getType())); -@@ -958,10 +_,10 @@ +@@ -959,10 +_,10 @@ if (entity != this) { super.awardKillScore(entity, damageSource); Scoreboard scoreboard = this.level().getScoreboard(); @@ -571,7 +571,7 @@ } else { this.awardStat(Stats.MOB_KILLS); } -@@ -973,12 +_,11 @@ +@@ -974,12 +_,11 @@ } private void handleTeamKill(ScoreHolder scoreHolder, ScoreHolder teamMember, ObjectiveCriteria[] criteria) { @@ -586,7 +586,7 @@ } } } -@@ -989,9 +_,20 @@ +@@ -990,9 +_,20 @@ return false; } else { Entity entity = damageSource.getEntity(); @@ -609,7 +609,7 @@ } } -@@ -1001,25 +_,95 @@ +@@ -1002,25 +_,95 @@ } private boolean isPvpAllowed() { @@ -713,13 +713,13 @@ } public boolean isReceivingWaypoints() { -@@ -1054,14 +_,16 @@ +@@ -1055,14 +_,16 @@ && (flag || blockState.getValue(RespawnAnchorBlock.CHARGE) > 0) && RespawnAnchorBlock.canSetSpawn(level, blockPos)) { Optional optional = RespawnAnchorBlock.findStandUpPosition(EntityType.PLAYER, level, blockPos); + Runnable consumeAnchorCharge = null; // Paper - Fix SPIGOT-5989 (don't use charge until after respawn event) if (!flag && useCharge && optional.isPresent()) { -- level.setBlock(blockPos, blockState.setValue(RespawnAnchorBlock.CHARGE, blockState.getValue(RespawnAnchorBlock.CHARGE) - 1), 3); +- level.setBlock(blockPos, blockState.setValue(RespawnAnchorBlock.CHARGE, blockState.getValue(RespawnAnchorBlock.CHARGE) - 1), Block.UPDATE_ALL); + consumeAnchorCharge = () -> level.setBlock(blockPos, blockState.setValue(RespawnAnchorBlock.CHARGE, blockState.getValue(RespawnAnchorBlock.CHARGE) - 1), 3); // Paper - Fix SPIGOT-5989 (don't use charge until after respawn event) } + final Runnable finalConsumeAnchorCharge = consumeAnchorCharge; // Paper - Fix SPIGOT-5989 @@ -733,7 +733,7 @@ } else if (!flag) { return Optional.empty(); } else { -@@ -1069,7 +_,7 @@ +@@ -1070,7 +_,7 @@ BlockState blockState1 = level.getBlockState(blockPos.above()); boolean isPossibleToRespawnInThis1 = blockState1.getBlock().isPossibleToRespawnInThis(blockState1); return isPossibleToRespawnInThis && isPossibleToRespawnInThis1 @@ -742,7 +742,7 @@ : Optional.empty(); } } -@@ -1087,6 +_,7 @@ +@@ -1088,6 +_,7 @@ @Nullable @Override public ServerPlayer teleport(TeleportTransition teleportTransition) { @@ -750,7 +750,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1096,13 +_,48 @@ +@@ -1098,13 +_,48 @@ ServerLevel level = teleportTransition.newLevel(); ServerLevel serverLevel = this.level(); @@ -802,7 +802,7 @@ this.connection.resetPosition(); teleportTransition.postTeleportTransition().onTransition(this); return this; -@@ -1113,18 +_,19 @@ +@@ -1115,18 +_,19 @@ this.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); PlayerList playerList = this.server.getPlayerList(); playerList.sendPlayerPermissionLevel(this); @@ -824,7 +824,7 @@ this.connection.resetPosition(); level.addDuringTeleport(this); profilerFiller.pop(); -@@ -1139,6 +_,15 @@ +@@ -1141,6 +_,15 @@ this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(teleportTransition, serverLevel); @@ -840,7 +840,7 @@ return this; } } -@@ -1153,12 +_,26 @@ +@@ -1155,12 +_,26 @@ public void triggerDimensionChangeTriggers(ServerLevel level) { ResourceKey resourceKey = level.dimension(); ResourceKey resourceKey1 = this.level().dimension(); @@ -870,7 +870,7 @@ this.enteredNetherPosition = null; } } -@@ -1174,9 +_,8 @@ +@@ -1176,9 +_,8 @@ this.containerMenu.broadcastChanges(); } @@ -882,7 +882,7 @@ if (!this.isSleeping() && this.isAlive()) { BedRule bedRule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, bedPos); boolean canSleep = bedRule.canSleep(this.level()); -@@ -1190,7 +_,7 @@ +@@ -1192,7 +_,7 @@ } else { if (canSetSpawn) { this.setRespawnPosition( @@ -891,7 +891,7 @@ ); } -@@ -1212,7 +_,37 @@ +@@ -1214,7 +_,37 @@ } } @@ -930,7 +930,7 @@ this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1222,10 +_,7 @@ +@@ -1224,10 +_,7 @@ this.level().updateSleepingPlayerList(); return either; @@ -941,7 +941,7 @@ } } -@@ -1251,21 +_,29 @@ +@@ -1253,21 +_,29 @@ @Override public void stopSleepInBed(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) { @@ -954,7 +954,7 @@ + } + // CraftBukkit end if (this.isSleeping()) { - this.level().getChunkSource().sendToTrackingPlayersAndSelf(this, new ClientboundAnimatePacket(this, 2)); + this.level().getChunkSource().sendToTrackingPlayersAndSelf(this, new ClientboundAnimatePacket(this, ClientboundAnimatePacket.WAKE_UP)); } super.stopSleepInBed(wakeImmediately, updateLevelForSleepingPlayers); @@ -974,7 +974,7 @@ } @Override -@@ -1313,8 +_,9 @@ +@@ -1315,8 +_,9 @@ this.connection.send(new ClientboundShowDialogPacket(dialog)); } @@ -985,7 +985,7 @@ } @Override -@@ -1322,12 +_,39 @@ +@@ -1324,12 +_,39 @@ if (menu == null) { return OptionalInt.empty(); } else { @@ -1026,7 +1026,7 @@ if (abstractContainerMenu == null) { if (this.isSpectator()) { this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true); -@@ -1335,10 +_,14 @@ +@@ -1337,10 +_,14 @@ return OptionalInt.empty(); } else { @@ -1043,7 +1043,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1351,14 +_,25 @@ +@@ -1353,14 +_,25 @@ @Override public void openHorseInventory(AbstractHorse horse, Container inventory) { @@ -1072,7 +1072,7 @@ this.initMenu(this.containerMenu); } -@@ -1380,10 +_,30 @@ +@@ -1382,10 +_,30 @@ @Override public void closeContainer() { @@ -1103,7 +1103,7 @@ @Override public void doCloseContainer() { this.containerMenu.removed(this); -@@ -1406,19 +_,19 @@ +@@ -1408,19 +_,19 @@ int rounded = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); if (rounded > 0) { this.awardStat(Stats.SWIM_ONE_CM, rounded); @@ -1126,7 +1126,7 @@ } } else if (this.onClimbable()) { if (dy > 0.0) { -@@ -1429,13 +_,13 @@ +@@ -1431,13 +_,13 @@ if (rounded > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, rounded); @@ -1143,7 +1143,7 @@ } } } else if (this.isFallFlying()) { -@@ -1477,13 +_,13 @@ +@@ -1479,13 +_,13 @@ @Override public void awardStat(Stat stat, int amount) { this.stats.increment(this, stat, amount); @@ -1159,7 +1159,7 @@ } @Override -@@ -1514,9 +_,9 @@ +@@ -1516,9 +_,9 @@ super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1171,7 +1171,7 @@ } } -@@ -1531,6 +_,13 @@ +@@ -1533,6 +_,13 @@ public void disconnect() { this.disconnected = true; this.ejectPassengers(); @@ -1185,7 +1185,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, false); } -@@ -1542,6 +_,7 @@ +@@ -1544,6 +_,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1193,7 +1193,7 @@ } @Override -@@ -1576,12 +_,12 @@ +@@ -1578,12 +_,12 @@ this.onUpdateAbilities(); if (keepEverything) { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1208,7 +1208,7 @@ } this.getInventory().replaceWith(that.getInventory()); -@@ -1592,7 +_,7 @@ +@@ -1594,7 +_,7 @@ this.portalProcess = that.portalProcess; } else { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1217,7 +1217,7 @@ if (this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || that.isSpectator()) { this.getInventory().replaceWith(that.getInventory()); this.experienceLevel = that.experienceLevel; -@@ -1608,7 +_,7 @@ +@@ -1610,7 +_,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1226,7 +1226,7 @@ this.seenCredits = that.seenCredits; this.enteredNetherPosition = that.enteredNetherPosition; this.chunkTrackingView = that.chunkTrackingView; -@@ -1651,9 +_,22 @@ +@@ -1653,9 +_,22 @@ CriteriaTriggers.EFFECTS_CHANGED.trigger(this, null); } @@ -1250,7 +1250,7 @@ } @Override -@@ -1662,7 +_,7 @@ +@@ -1664,7 +_,7 @@ } @Override @@ -1259,7 +1259,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, true); } -@@ -1671,7 +_,7 @@ +@@ -1673,7 +_,7 @@ this.setCamera(this); } @@ -1268,7 +1268,7 @@ if (flag) { this.setYHeadRot(relativeMovements.contains(Relative.Y_ROT) ? this.getYHeadRot() + yaw : yaw); this.connection.resetFlyingTicks(); -@@ -1710,9 +_,19 @@ +@@ -1712,9 +_,19 @@ } public boolean setGameMode(GameType gameMode) { @@ -1290,7 +1290,7 @@ } else { this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, gameMode.getId())); if (gameMode == GameType.SPECTATOR) { -@@ -1728,7 +_,7 @@ +@@ -1730,7 +_,7 @@ this.onUpdateAbilities(); this.updateEffectVisibility(); @@ -1299,7 +1299,7 @@ } } -@@ -1784,8 +_,13 @@ +@@ -1786,8 +_,13 @@ } public void sendChatMessage(OutgoingChatMessage message, boolean filtered, ChatType.Bound boundChatType) { @@ -1314,7 +1314,7 @@ } } -@@ -1796,7 +_,42 @@ +@@ -1798,7 +_,42 @@ } public void updateOptions(ClientInformation clientInformation) { @@ -1357,7 +1357,7 @@ this.requestedViewDistance = clientInformation.viewDistance(); this.chatVisibility = clientInformation.chatVisibility(); this.canChatColor = clientInformation.chatColors(); -@@ -1882,8 +_,23 @@ +@@ -1884,8 +_,23 @@ Entity camera = this.getCamera(); this.camera = (Entity)(entityToSpectate == null ? this : entityToSpectate); if (camera != this.camera) { @@ -1382,7 +1382,7 @@ } if (entityToSpectate != null) { -@@ -1917,11 +_,11 @@ +@@ -1919,11 +_,11 @@ @Nullable public Component getTabListDisplayName() { @@ -1396,7 +1396,7 @@ } @Override -@@ -1952,11 +_,62 @@ +@@ -1954,11 +_,62 @@ } public void setRespawnPosition(@Nullable ServerPlayer.RespawnConfig respawnConfig, boolean displayInChat) { @@ -1461,7 +1461,7 @@ } public SectionPos getLastSectionPos() { -@@ -1986,16 +_,23 @@ +@@ -1988,16 +_,23 @@ } @Override @@ -1490,7 +1490,7 @@ return itemEntity; } -@@ -2118,9 +_,9 @@ +@@ -2120,9 +_,9 @@ } @Override @@ -1502,7 +1502,7 @@ if (vehicle instanceof LivingEntity livingEntity) { for (MobEffectInstance mobEffectInstance : livingEntity.getActiveEffects()) { this.connection.send(new ClientboundRemoveMobEffectPacket(vehicle.getId(), mobEffectInstance.getEffect())); -@@ -2237,7 +_,7 @@ +@@ -2239,7 +_,7 @@ } public static long placeEnderPearlTicket(ServerLevel level, ChunkPos pos) { @@ -1511,7 +1511,7 @@ return TicketType.ENDER_PEARL.timeout(); } -@@ -2267,9 +_,11 @@ +@@ -2269,9 +_,11 @@ } } @@ -1526,7 +1526,7 @@ } private static float calculateLookAtYaw(Vec3 position, BlockPos towardsPos) { -@@ -2289,4 +_,135 @@ +@@ -2291,4 +_,135 @@ ); public static final ServerPlayer.SavedPosition EMPTY = new ServerPlayer.SavedPosition(Optional.empty(), Optional.empty(), Optional.empty()); } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 09d7f5c3af7b..2c7b90a2f63e 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -245,7 +245,7 @@ Block block = blockState.getBlock(); - if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks()) { + if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks() && !(block instanceof net.minecraft.world.level.block.CommandBlock && (this.player.isCreative() && this.player.getBukkitEntity().hasPermission("minecraft.commandblock")))) { // Paper - command block permission - this.level.sendBlockUpdated(pos, blockState, blockState, 3); + this.level.sendBlockUpdated(pos, blockState, blockState, Block.UPDATE_ALL); return false; } else if (this.player.blockActionRestricted(this.level, pos, this.gameModeForPlayer)) { return false; diff --git a/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch b/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch index 82f0cbabca18..c81767550de6 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch @@ -16,13 +16,13 @@ + public static final int FLAG_KEEP_DIMENSION_ACTIVE = 8; // Paper - diff on change - all listed in Flags annotation + public static final int FLAG_CAN_EXPIRE_IF_UNLOADED = 16; // Paper - diff on change - all listed in Flags annotation + // Paper end - diff on change - all listed in Flags annotation - public static final TicketType PLAYER_SPAWN = register("player_spawn", 20L, 2); - public static final TicketType SPAWN_SEARCH = register("spawn_search", 1L, 2); - public static final TicketType DRAGON = register("dragon", 0L, 6); + public static final TicketType PLAYER_SPAWN = register("player_spawn", 20L, FLAG_LOADING); + public static final TicketType SPAWN_SEARCH = register("spawn_search", 1L, FLAG_LOADING); + public static final TicketType DRAGON = register("dragon", NO_TIMEOUT, FLAG_LOADING | FLAG_SIMULATION); @@ -23,6 +_,11 @@ - public static final TicketType PORTAL = register("portal", 300L, 15); - public static final TicketType ENDER_PEARL = register("ender_pearl", 40L, 14); - public static final TicketType UNKNOWN = register("unknown", 1L, 18); + public static final TicketType PORTAL = register("portal", 300L, FLAG_PERSIST | FLAG_LOADING | FLAG_SIMULATION | FLAG_KEEP_DIMENSION_ACTIVE); + public static final TicketType ENDER_PEARL = register("ender_pearl", 40L, FLAG_LOADING | FLAG_SIMULATION | FLAG_KEEP_DIMENSION_ACTIVE); + public static final TicketType UNKNOWN = register("unknown", 1L, FLAG_CAN_EXPIRE_IF_UNLOADED | FLAG_LOADING); + public static final TicketType PLUGIN = register("plugin", 0L, FLAG_LOADING | FLAG_SIMULATION); // CraftBukkit + public static final TicketType POST_TELEPORT = register("post_teleport", 5L, FLAG_LOADING | FLAG_SIMULATION); // Paper + public static final TicketType PLUGIN_TICKET = register("plugin_ticket", NO_TIMEOUT, FLAG_LOADING | FLAG_SIMULATION); // Paper diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 56811f7cf333..dea22a407438 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -213,6 +_,38 @@ +@@ -214,6 +_,38 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.slf4j.Logger; @@ -39,7 +39,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements GameProtocols.Context, -@@ -232,7 +_,9 @@ +@@ -233,7 +_,9 @@ private int tickCount; private int ackBlockChangesUpTo = -1; private final TickThrottler chatSpamThrottler = new TickThrottler(20, 200); @@ -49,7 +49,7 @@ private double firstGoodX; private double firstGoodY; private double firstGoodZ; -@@ -258,14 +_,33 @@ +@@ -259,14 +_,33 @@ private int receivedMovePacketCount; private int knownMovePacketCount; private boolean receivedMovementThisTick; @@ -83,7 +83,7 @@ public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player, CommonListenerCookie cookie) { super(server, connection, cookie); -@@ -274,8 +_,22 @@ +@@ -275,8 +_,22 @@ player.connection = this; player.getTextFilter().join(); this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(player.getUUID(), server::enforceSecureProfile); @@ -108,7 +108,7 @@ @Override public void tick() { -@@ -288,11 +_,13 @@ +@@ -289,11 +_,13 @@ this.keepConnectionAlive(); this.chatSpamThrottler.tick(); this.dropSpamThrottler.tick(); @@ -123,7 +123,7 @@ } } } -@@ -308,8 +_,8 @@ +@@ -309,8 +_,8 @@ this.knownMovePacketCount = this.receivedMovePacketCount; if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger() && !this.player.isDeadOrDying()) { if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player)) { @@ -134,7 +134,7 @@ return true; } } else { -@@ -327,8 +_,8 @@ +@@ -328,8 +_,8 @@ this.vehicleLastGoodZ = this.lastVehicle.getZ(); if (this.clientVehicleIsFloating && this.lastVehicle.getControllingPassenger() == this.player) { if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle)) { @@ -145,7 +145,7 @@ return true; } } else { -@@ -341,6 +_,12 @@ +@@ -342,6 +_,12 @@ this.aboveGroundVehicleTickCount = 0; } @@ -158,7 +158,7 @@ return false; } -@@ -406,11 +_,37 @@ +@@ -407,11 +_,37 @@ @Override public void handlePlayerInput(ServerboundPlayerInputPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -198,7 +198,7 @@ } private static boolean containsInvalidValues(double x, double y, double z, float yRot, float xRot) { -@@ -429,17 +_,29 @@ +@@ -430,17 +_,29 @@ public void handleMoveVehicle(ServerboundMoveVehiclePacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (containsInvalidValues(packet.position().x(), packet.position().y(), packet.position().z(), packet.yRot(), packet.xRot())) { @@ -232,7 +232,7 @@ float f = Mth.wrapDegrees(packet.yRot()); float f1 = Mth.wrapDegrees(packet.xRot()); double d3 = d - this.vehicleFirstGoodX; -@@ -447,16 +_,61 @@ +@@ -448,16 +_,61 @@ double d5 = d2 - this.vehicleFirstGoodZ; double d6 = rootVehicle.getDeltaMovement().lengthSqr(); double d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -298,7 +298,7 @@ boolean flag = rootVehicle.verticalCollisionBelow; if (rootVehicle instanceof LivingEntity livingEntity && livingEntity.onClimbable()) { livingEntity.resetFallDistance(); -@@ -473,7 +_,7 @@ +@@ -474,7 +_,7 @@ d5 = d2 - rootVehicle.getZ(); d7 = d3 * d3 + d4 * d4 + d5 * d5; boolean flag1 = false; @@ -307,7 +307,7 @@ flag1 = true; LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", rootVehicle.getPlainTextName(), this.player.getPlainTextName(), Math.sqrt(d7)); } -@@ -487,6 +_,57 @@ +@@ -488,6 +_,57 @@ } rootVehicle.absSnapTo(d, d1, d2, f, f1); @@ -365,7 +365,7 @@ this.player.level().getChunkSource().move(this.player); Vec3 vec3 = new Vec3(rootVehicle.getX() - x, rootVehicle.getY() - y, rootVehicle.getZ() - z); this.handlePlayerKnownMovement(vec3); -@@ -517,7 +_,7 @@ +@@ -518,7 +_,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (packet.getId() == this.awaitingTeleport) { if (this.awaitingPositionFromClient == null) { @@ -374,7 +374,7 @@ return; } -@@ -534,12 +_,20 @@ +@@ -535,12 +_,20 @@ this.lastGoodZ = this.awaitingPositionFromClient.z; this.player.hasChangedDimension(); this.awaitingPositionFromClient = null; @@ -395,7 +395,7 @@ this.player.setClientLoaded(true); } -@@ -561,6 +_,7 @@ +@@ -562,6 +_,7 @@ @Override public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -403,7 +403,7 @@ this.player.getRecipeBook().setBookSetting(packet.getBookType(), packet.isOpen(), packet.isFiltering()); } -@@ -576,25 +_,110 @@ +@@ -577,25 +_,110 @@ } } @@ -519,7 +519,7 @@ } ); } -@@ -602,7 +_,7 @@ +@@ -603,7 +_,7 @@ @Override public void handleSetCommandBlock(ServerboundSetCommandBlockPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -528,7 +528,7 @@ this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock baseCommandBlock = null; -@@ -663,7 +_,7 @@ +@@ -664,7 +_,7 @@ @Override public void handleSetCommandMinecart(ServerboundSetCommandMinecartPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -537,7 +537,7 @@ this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock commandBlock = packet.getCommandBlock(this.player.level()); -@@ -701,11 +_,11 @@ +@@ -702,11 +_,11 @@ boolean flag = this.player.hasInfiniteMaterials() && packet.includeData(); ItemStack cloneItemStack = blockState.getCloneItemStack(serverLevel, blockPos, flag); if (!cloneItemStack.isEmpty()) { @@ -551,7 +551,7 @@ } } } -@@ -732,27 +_,40 @@ +@@ -733,27 +_,40 @@ if (entityOrPart != null && this.player.canInteractWithEntity(entityOrPart, 3.0)) { ItemStack pickResult = entityOrPart.getPickResult(); if (pickResult != null && !pickResult.isEmpty()) { @@ -598,7 +598,7 @@ } } -@@ -930,6 +_,13 @@ +@@ -931,6 +_,13 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); int item = packet.getItem(); if (this.player.containerMenu instanceof MerchantMenu merchantMenu) { @@ -612,7 +612,7 @@ if (!merchantMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, merchantMenu); return; -@@ -942,6 +_,51 @@ +@@ -943,6 +_,51 @@ @Override public void handleEditBook(ServerboundEditBookPacket packet) { @@ -664,7 +664,7 @@ int slot = packet.slot(); if (Inventory.isHotbarSlot(slot) || slot == 40) { List list = Lists.newArrayList(); -@@ -956,10 +_,14 @@ +@@ -957,10 +_,14 @@ } private void updateBookContents(List pages, int index) { @@ -680,7 +680,7 @@ } } -@@ -972,7 +_,8 @@ +@@ -973,7 +_,8 @@ itemStack.set( DataComponents.WRITTEN_BOOK_CONTENT, new WrittenBookContent(this.filterableFromOutgoing(title), this.player.getPlainTextName(), 0, list, true) ); @@ -690,7 +690,7 @@ } } -@@ -1020,27 +_,35 @@ +@@ -1021,27 +_,35 @@ public void handleMovePlayer(ServerboundMovePlayerPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (containsInvalidValues(packet.getX(0.0), packet.getY(0.0), packet.getZ(0.0), packet.getYRot(0.0F), packet.getXRot(0.0F))) { @@ -733,7 +733,7 @@ double x = this.player.getX(); double y = this.player.getY(); double z = this.player.getZ(); -@@ -1049,6 +_,16 @@ +@@ -1050,6 +_,16 @@ double d5 = d2 - this.firstGoodZ; double d6 = this.player.getDeltaMovement().lengthSqr(); double d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -750,7 +750,7 @@ if (this.player.isSleeping()) { if (d7 > 1.0) { this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); -@@ -1058,36 +_,108 @@ +@@ -1059,36 +_,108 @@ if (serverLevel.tickRateManager().runsNormally()) { this.receivedMovePacketCount++; int i = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -869,7 +869,7 @@ double verticalDelta = d4; d3 = d - this.player.getX(); d4 = d1 - this.player.getY(); -@@ -1097,20 +_,100 @@ +@@ -1098,20 +_,100 @@ d5 = d2 - this.player.getZ(); d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -979,7 +979,7 @@ this.player.absSnapTo(d, d1, d2, f, f1); boolean isAutoSpinAttack = this.player.isAutoSpinAttack(); this.clientIsFloating = verticalDelta >= -0.03125 -@@ -1145,7 +_,7 @@ +@@ -1146,7 +_,7 @@ this.lastGoodY = this.player.getY(); this.lastGoodZ = this.player.getZ(); } else { @@ -988,7 +988,7 @@ this.player.doCheckFallDamage(this.player.getX() - x, this.player.getY() - y, this.player.getZ() - z, packet.isOnGround()); this.player.removeLatestMovementRecording(); } -@@ -1181,6 +_,7 @@ +@@ -1182,6 +_,7 @@ this.player.getXRot() ); } @@ -996,7 +996,7 @@ return true; } else { -@@ -1204,10 +_,77 @@ +@@ -1205,10 +_,77 @@ } public void teleport(double x, double y, double z, float yRot, float xRot) { @@ -1075,7 +1075,7 @@ this.awaitingTeleportTime = this.tickCount; if (++this.awaitingTeleport == Integer.MAX_VALUE) { this.awaitingTeleport = 0; -@@ -1215,12 +_,20 @@ +@@ -1216,12 +_,20 @@ this.player.teleportSetPosition(posMoveRotation, relatives); this.awaitingPositionFromClient = this.player.position(); @@ -1096,7 +1096,7 @@ if (this.player.hasClientLoaded()) { BlockPos pos = packet.getPos(); this.player.resetLastActionTime(); -@@ -1245,32 +_,95 @@ +@@ -1246,32 +_,95 @@ case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { ItemStack itemInHand1 = this.player.getItemInHand(InteractionHand.OFF_HAND); @@ -1194,7 +1194,7 @@ return; default: throw new IllegalArgumentException("Invalid player action"); -@@ -1288,9 +_,31 @@ +@@ -1289,9 +_,31 @@ } } @@ -1226,7 +1226,7 @@ if (this.player.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel serverLevel = this.player.level(); -@@ -1299,6 +_,11 @@ +@@ -1300,6 +_,11 @@ if (itemInHand.isItemEnabled(serverLevel.enabledFeatures())) { BlockHitResult hitResult = packet.getHitResult(); Vec3 location = hitResult.getLocation(); @@ -1238,7 +1238,7 @@ BlockPos blockPos = hitResult.getBlockPos(); if (this.player.canInteractWithBlock(blockPos, 1.0)) { Vec3 vec3 = location.subtract(Vec3.atCenterOf(blockPos)); -@@ -1308,7 +_,8 @@ +@@ -1309,7 +_,8 @@ this.player.resetLastActionTime(); int maxY = this.player.level().getMaxY(); if (blockPos.getY() <= maxY) { @@ -1248,7 +1248,7 @@ InteractionResult interactionResult = this.player.gameMode.useItemOn(this.player, serverLevel, itemInHand, hand, hitResult); if (interactionResult.consumesAction()) { CriteriaTriggers.ANY_BLOCK_USE.trigger(this.player, hitResult.getBlockPos(), itemInHand.copy()); -@@ -1321,10 +_,10 @@ +@@ -1322,10 +_,10 @@ Component component = Component.translatable("build.tooHigh", maxY).withStyle(ChatFormatting.RED); this.player.sendSystemMessage(component, true); } else if (interactionResult instanceof InteractionResult.Success success @@ -1261,7 +1261,7 @@ } else { Component component1 = Component.translatable("build.tooHigh", maxY).withStyle(ChatFormatting.RED); this.player.sendSystemMessage(component1, true); -@@ -1332,13 +_,8 @@ +@@ -1333,13 +_,8 @@ this.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos)); this.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos.relative(direction))); @@ -1277,7 +1277,7 @@ } } } -@@ -1348,6 +_,8 @@ +@@ -1349,6 +_,8 @@ @Override public void handleUseItem(ServerboundUseItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1286,7 +1286,7 @@ if (this.player.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel serverLevel = this.player.level(); -@@ -1361,6 +_,48 @@ +@@ -1362,6 +_,48 @@ this.player.absSnapRotationTo(f, f1); } @@ -1335,7 +1335,7 @@ if (this.player.gameMode.useItem(this.player, serverLevel, itemInHand, hand) instanceof InteractionResult.Success success && success.swingSource() == InteractionResult.SwingSource.SERVER) { this.player.swing(hand, true); -@@ -1376,7 +_,7 @@ +@@ -1377,7 +_,7 @@ for (ServerLevel serverLevel : this.server.getAllLevels()) { Entity entity = packet.getEntity(serverLevel); if (entity != null) { @@ -1344,7 +1344,7 @@ return; } } -@@ -1393,24 +_,50 @@ +@@ -1394,24 +_,50 @@ @Override public void onDisconnect(DisconnectionDetails details) { @@ -1397,7 +1397,7 @@ throw new IllegalArgumentException("Expected packet sequence nr >= 0"); } else { this.ackBlockChangesUpTo = Math.max(sequence, this.ackBlockChangesUpTo); -@@ -1420,20 +_,38 @@ +@@ -1421,20 +_,38 @@ @Override public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1436,7 +1436,7 @@ Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { this.tryHandleChat(packet.message(), false, () -> { -@@ -1445,25 +_,45 @@ +@@ -1446,25 +_,45 @@ return; } @@ -1489,7 +1489,7 @@ ParseResults parseResults = this.parseCommand(command); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseResults)) { LOGGER.error( -@@ -1480,28 +_,57 @@ +@@ -1481,28 +_,57 @@ Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { this.tryHandleChat(packet.command(), true, () -> { @@ -1550,7 +1550,7 @@ } private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) { -@@ -1565,14 +_,20 @@ +@@ -1566,14 +_,20 @@ return dispatcher.parse(command, this.player.createCommandSourceStack()); } @@ -1575,7 +1575,7 @@ } } -@@ -1584,7 +_,7 @@ +@@ -1585,7 +_,7 @@ var10000 = Optional.of(lastSeenMessages); } catch (LastSeenMessagesValidator.ValidationException var5) { LOGGER.error("Failed to validate message acknowledgements from {}: {}", this.player.getPlainTextName(), var5.getMessage()); @@ -1584,7 +1584,7 @@ return Optional.empty(); } -@@ -1602,22 +_,81 @@ +@@ -1603,22 +_,81 @@ return false; } @@ -1672,7 +1672,7 @@ } } -@@ -1628,7 +_,7 @@ +@@ -1629,7 +_,7 @@ this.lastSeenMessages.applyOffset(packet.offset()); } catch (LastSeenMessagesValidator.ValidationException var5) { LOGGER.error("Failed to validate message acknowledgement offset from {}: {}", this.player.getPlainTextName(), var5.getMessage()); @@ -1681,7 +1681,7 @@ } } } -@@ -1636,7 +_,40 @@ +@@ -1637,7 +_,40 @@ @Override public void handleAnimate(ServerboundSwingPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1722,7 +1722,7 @@ this.player.swing(packet.getHand()); } -@@ -1644,6 +_,22 @@ +@@ -1645,6 +_,22 @@ public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (this.player.hasClientLoaded()) { @@ -1745,7 +1745,7 @@ this.player.resetLastActionTime(); switch (packet.getAction()) { case START_SPRINTING: -@@ -1688,6 +_,14 @@ +@@ -1689,6 +_,14 @@ } public void sendPlayerChatMessage(PlayerChatMessage chatMessage, ChatType.Bound boundChatType) { @@ -1760,7 +1760,7 @@ this.send( new ClientboundPlayerChatPacket( this.nextChatIndex++, -@@ -1710,9 +_,11 @@ +@@ -1711,9 +_,11 @@ } if (i > 4096) { @@ -1773,7 +1773,7 @@ } public void sendDisguisedChatMessage(Component message, ChatType.Bound boundChatType) { -@@ -1723,6 +_,17 @@ +@@ -1724,6 +_,17 @@ return this.connection.getRemoteAddress(); } @@ -1791,7 +1791,7 @@ public void switchToConfig() { this.waitingForSwitchToConfig = true; this.removePlayerFromWorld(); -@@ -1738,9 +_,16 @@ +@@ -1739,9 +_,16 @@ @Override public void handleInteract(ServerboundInteractPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1808,7 +1808,7 @@ this.player.resetLastActionTime(); this.player.setShiftKeyDown(packet.isUsingSecondaryAction()); if (target != null) { -@@ -1749,16 +_,54 @@ +@@ -1750,16 +_,54 @@ } AABB boundingBox = target.getBoundingBox(); @@ -1868,7 +1868,7 @@ ItemStack itemStack1 = success.wasItemInteraction() ? itemStack : ItemStack.EMPTY; CriteriaTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(ServerGamePacketListenerImpl.this.player, itemStack1, target); if (success.swingSource() == InteractionResult.SwingSource.SERVER) { -@@ -1770,13 +_,13 @@ +@@ -1771,13 +_,13 @@ @Override public void onInteraction(InteractionHand hand) { @@ -1884,7 +1884,7 @@ ); } -@@ -1784,7 +_,7 @@ +@@ -1785,7 +_,7 @@ public void onAttack() { if (!(target instanceof ItemEntity) && !(target instanceof ExperienceOrb) @@ -1893,7 +1893,7 @@ && !(target instanceof AbstractArrow abstractArrow && !abstractArrow.isAttackable())) { ItemStack itemInHand = ServerGamePacketListenerImpl.this.player.getItemInHand(InteractionHand.MAIN_HAND); if (itemInHand.isItemEnabled(serverLevel.enabledFeatures())) { -@@ -1793,7 +_,7 @@ +@@ -1794,7 +_,7 @@ } } } else { @@ -1902,7 +1902,7 @@ ServerGamePacketListenerImpl.LOGGER .warn("Player {} tried to attack an invalid entity", ServerGamePacketListenerImpl.this.player.getPlainTextName()); } -@@ -1802,6 +_,27 @@ +@@ -1803,6 +_,27 @@ ); } } @@ -1930,7 +1930,7 @@ } } -@@ -1814,7 +_,7 @@ +@@ -1815,7 +_,7 @@ case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; @@ -1939,7 +1939,7 @@ this.resetPosition(); CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); } else { -@@ -1822,11 +_,11 @@ +@@ -1823,11 +_,11 @@ return; } @@ -1954,7 +1954,7 @@ } } break; -@@ -1837,16 +_,27 @@ +@@ -1838,16 +_,27 @@ @Override public void handleContainerClose(ServerboundContainerClosePacket packet) { @@ -1984,7 +1984,7 @@ this.player.containerMenu.sendAllDataToRemote(); } else if (!this.player.containerMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); -@@ -1862,7 +_,298 @@ +@@ -1863,7 +_,298 @@ } else { boolean flag = packet.stateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -2284,7 +2284,7 @@ for (Entry entry : Int2ObjectMaps.fastIterable(packet.changedSlots())) { this.player.containerMenu.setRemoteSlotUnsafe(entry.getIntKey(), entry.getValue()); -@@ -1875,6 +_,8 @@ +@@ -1876,6 +_,8 @@ } else { this.player.containerMenu.broadcastChanges(); } @@ -2293,7 +2293,7 @@ } } } -@@ -1882,6 +_,14 @@ +@@ -1883,6 +_,14 @@ @Override public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) { @@ -2308,7 +2308,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); this.player.resetLastActionTime(); if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) { -@@ -1898,9 +_,44 @@ +@@ -1899,9 +_,44 @@ return; } @@ -2354,7 +2354,7 @@ if (postPlaceAction == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) { this.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, recipeFromDisplay.display().display())); } -@@ -1914,6 +_,7 @@ +@@ -1915,6 +_,7 @@ @Override public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2362,7 +2362,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -1923,6 +_,7 @@ +@@ -1924,6 +_,7 @@ if (flag) { this.player.containerMenu.broadcastChanges(); } @@ -2370,7 +2370,7 @@ } } } -@@ -1939,10 +_,48 @@ +@@ -1940,10 +_,48 @@ boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45; boolean flag2 = itemStack.isEmpty() || itemStack.getCount() <= itemStack.getMaxStackSize(); @@ -2419,7 +2419,7 @@ } else if (flag && flag2) { if (this.dropSpamThrottler.isUnderThreshold()) { this.dropSpamThrottler.increment(); -@@ -1956,15 +_,38 @@ +@@ -1957,15 +_,38 @@ @Override public void handleSignUpdate(ServerboundSignUpdatePacket packet) { @@ -2459,7 +2459,7 @@ if (!(serverLevel.getBlockEntity(pos) instanceof SignBlockEntity signBlockEntity)) { return; } -@@ -1976,14 +_,32 @@ +@@ -1977,14 +_,32 @@ @Override public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2493,7 +2493,7 @@ if (this.player.isModelPartShown(PlayerModelPart.HAT) != isModelPartShown) { this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player)); } -@@ -1999,7 +_,7 @@ +@@ -2000,7 +_,7 @@ packet.difficulty().getDisplayName() ); } else { @@ -2502,7 +2502,7 @@ } } -@@ -2013,7 +_,7 @@ +@@ -2014,7 +_,7 @@ packet.mode().getShortDisplayName().getString() ); } else { @@ -2511,7 +2511,7 @@ } } -@@ -2033,7 +_,7 @@ +@@ -2034,7 +_,7 @@ ProfilePublicKey.Data data2 = data.profilePublicKey(); if (!Objects.equals(data1, data2)) { if (data1 != null && data2.expiresAt().isBefore(data1.expiresAt())) { @@ -2520,7 +2520,7 @@ } else { try { SignatureValidator signatureValidator = this.server.services().profileKeySignatureValidator(); -@@ -2044,8 +_,8 @@ +@@ -2045,8 +_,8 @@ this.resetPlayerChatState(data.validate(this.player.getGameProfile(), signatureValidator)); } catch (ProfilePublicKey.ValidationException var6) { @@ -2531,7 +2531,7 @@ } } } -@@ -2056,11 +_,13 @@ +@@ -2057,11 +_,13 @@ if (!this.waitingForSwitchToConfig) { throw new IllegalStateException("Client acknowledged config, but none was requested"); } else { @@ -2546,7 +2546,7 @@ } } -@@ -2078,27 +_,32 @@ +@@ -2079,27 +_,32 @@ private void resetPlayerChatState(RemoteChatSession chatSession) { this.chatSession = chatSession; @@ -2580,7 +2580,7 @@ if (!this.receivedMovementThisTick) { this.player.setKnownMovement(Vec3.ZERO); } -@@ -2129,4 +_,80 @@ +@@ -2130,4 +_,80 @@ interface EntityInteraction { InteractionResult run(ServerPlayer player, Entity entity, InteractionHand hand); } diff --git a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch index ef9850543f77..ae9a5339b899 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -111,14 +_,16 @@ +@@ -112,14 +_,16 @@ private static final int SEND_PLAYER_INFO_INTERVAL = 600; private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z", Locale.ROOT); private final MinecraftServer server; @@ -20,7 +20,7 @@ public final PlayerDataStorage playerIo; private final LayeredRegistryAccess registries; private int viewDistance; -@@ -126,9 +_,17 @@ +@@ -127,9 +_,17 @@ private boolean allowCommandsForAllPlayers; private int sendAllPlayerInfoIn; @@ -38,7 +38,7 @@ this.server = server; this.registries = registries; this.playerIo = playerIo; -@@ -138,23 +_,19 @@ +@@ -139,23 +_,19 @@ this.ipBans = new IpBanList(IPBANLIST_FILE, notificationService); } @@ -67,7 +67,7 @@ LevelData levelData = serverLevel.getLevelData(); ServerGamePacketListenerImpl serverGamePacketListenerImpl = new ServerGamePacketListenerImpl(this.server, connection, player, cookie); connection.setupInboundProtocol( -@@ -172,8 +_,8 @@ +@@ -173,8 +_,8 @@ levelData.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), @@ -78,7 +78,7 @@ _boolean1, !_boolean, _boolean2, -@@ -181,6 +_,7 @@ +@@ -182,6 +_,7 @@ this.server.enforceSecureProfile() ) ); @@ -86,7 +86,7 @@ serverGamePacketListenerImpl.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); serverGamePacketListenerImpl.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities())); serverGamePacketListenerImpl.send(new ClientboundSetHeldSlotPacket(player.getInventory().getSelectedSlot())); -@@ -200,24 +_,129 @@ +@@ -201,24 +_,129 @@ mutableComponent = Component.translatable("multiplayer.player.joined.renamed", player.getDisplayName(), string); } @@ -220,7 +220,7 @@ } public void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) { -@@ -239,31 +_,40 @@ +@@ -240,31 +_,40 @@ } } @@ -266,7 +266,7 @@ } @Override -@@ -287,57 +_,137 @@ +@@ -288,57 +_,137 @@ } protected void save(ServerPlayer player) { @@ -418,7 +418,7 @@ MutableComponent mutableComponent = Component.translatable("multiplayer.disconnect.banned.reason", userBanListEntry.getReasonMessage()); if (userBanListEntry.getExpires() != null) { mutableComponent.append( -@@ -345,9 +_,11 @@ +@@ -346,9 +_,11 @@ ); } @@ -433,7 +433,7 @@ } else if (this.ipBans.isBanned(socketAddress)) { IpBanListEntry ipBanListEntry = this.ipBans.get(socketAddress); MutableComponent mutableComponent = Component.translatable("multiplayer.disconnect.banned_ip.reason", ipBanListEntry.getReasonMessage()); -@@ -357,19 +_,18 @@ +@@ -358,19 +_,18 @@ ); } @@ -458,7 +458,7 @@ set.add(serverPlayer); } } -@@ -380,23 +_,31 @@ +@@ -381,23 +_,31 @@ } for (ServerPlayer serverPlayer2 : set) { @@ -495,7 +495,7 @@ serverPlayer.copyRespawnPosition(player); } -@@ -404,17 +_,26 @@ +@@ -405,18 +_,27 @@ serverPlayer.addTag(string); } @@ -510,11 +510,12 @@ + serverPlayer.connection.resetPosition(); // Paper - Fix SPIGOT-1903, MC-98153 + level.getChunkSource().addTicketWithRadius(net.minecraft.server.level.TicketType.POST_TELEPORT, new net.minecraft.world.level.ChunkPos(net.minecraft.util.Mth.floor(vec3.x()) >> 4, net.minecraft.util.Mth.floor(vec3.z()) >> 4), 1); // Paper - post teleport ticket type if (teleportTransition.missingRespawnBlock()) { - serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); + serverPlayer.connection + .send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, ClientboundGameEventPacket.DEMO_PARAM_INTRO)); + serverPlayer.setRespawnPosition(null, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed } - byte b = (byte)(keepInventory ? 1 : 0); + byte b = keepInventory ? ClientboundRespawnPacket.KEEP_ATTRIBUTE_MODIFIERS : 0; ServerLevel serverLevel = serverPlayer.level(); LevelData levelData = serverLevel.getLevelData(); serverPlayer.connection.send(new ClientboundRespawnPacket(serverPlayer.createCommonSpawnInfo(serverLevel), b)); @@ -523,7 +524,7 @@ serverPlayer.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); serverPlayer.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); serverPlayer.connection -@@ -424,9 +_,15 @@ +@@ -426,9 +_,15 @@ this.sendPlayerPermissionLevel(serverPlayer); level.addRespawnedPlayer(serverPlayer); this.players.add(serverPlayer); @@ -539,7 +540,7 @@ ServerPlayer.RespawnConfig respawnConfig = serverPlayer.getRespawnConfig(); if (!keepInventory && respawnConfig != null) { LevelData.RespawnData respawnData = respawnConfig.respawnData(); -@@ -452,6 +_,29 @@ +@@ -454,6 +_,29 @@ } } @@ -569,7 +570,7 @@ return serverPlayer; } -@@ -460,23 +_,58 @@ +@@ -462,23 +_,58 @@ } public void sendActiveEffects(LivingEntity entity, ServerGamePacketListenerImpl connection) { @@ -631,7 +632,7 @@ public void broadcastAll(Packet packet) { for (ServerPlayer serverPlayer : this.players) { serverPlayer.connection.send(packet); -@@ -562,6 +_,12 @@ +@@ -564,6 +_,12 @@ } private void sendPlayerPermissionLevel(ServerPlayer player, LevelBasedPermissionSet permissions) { @@ -643,8 +644,8 @@ + // Paper end - Add sendOpLevel API if (player.connection != null) { byte b = switch (permissions.level()) { - case ALL -> 24; -@@ -573,9 +_,48 @@ + case ALL -> EntityEvent.PERMISSION_LEVEL_ALL; +@@ -575,9 +_,48 @@ player.connection.send(new ClientboundEntityEventPacket(player, b)); } @@ -695,7 +696,7 @@ public boolean isWhiteListed(NameAndId nameAndId) { return !this.isUsingWhitelist() || this.ops.contains(nameAndId) || this.whitelist.contains(nameAndId); } -@@ -588,21 +_,17 @@ +@@ -590,21 +_,17 @@ @Nullable public ServerPlayer getPlayerByName(String username) { @@ -723,7 +724,7 @@ if (serverPlayer != except && serverPlayer.level().dimension() == dimension) { double d = x - serverPlayer.getX(); double d1 = y - serverPlayer.getY(); -@@ -615,9 +_,11 @@ +@@ -617,9 +_,11 @@ } public void saveAll() { @@ -735,7 +736,7 @@ } public UserWhiteList getWhiteList() { -@@ -644,10 +_,18 @@ +@@ -646,10 +_,18 @@ player.connection.send(new ClientboundInitializeBorderPacket(worldBorder)); player.connection.send(new ClientboundSetTimePacket(level.getGameTime(), level.getDayTime(), level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); @@ -744,7 +745,7 @@ + player.connection.send(new ClientboundSetSimulationDistancePacket(level.spigotConfig.simulationDistance)); + // Paper end if (level.isRaining()) { -- player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0.0F)); +- player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, ClientboundGameEventPacket.DEMO_PARAM_INTRO)); - player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, level.getRainLevel(1.0F))); - player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, level.getThunderLevel(1.0F))); + // CraftBukkit start - handle player weather @@ -756,8 +757,8 @@ + // CraftBukkit end } - player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F)); -@@ -656,8 +_,21 @@ + player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, ClientboundGameEventPacket.DEMO_PARAM_INTRO)); +@@ -658,8 +_,21 @@ public void sendAllPlayerInfo(ServerPlayer player) { player.inventoryMenu.sendAllDataToRemote(); @@ -780,7 +781,7 @@ } public int getPlayerCount() { -@@ -706,9 +_,26 @@ +@@ -708,9 +_,26 @@ } public void removeAll() { @@ -810,7 +811,7 @@ } public void broadcastSystemMessage(Component message, boolean overlay) { -@@ -731,20 +_,39 @@ +@@ -733,20 +_,39 @@ } public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound boundChatType) { @@ -853,7 +854,7 @@ flag1 |= flag2 && message.isFullyFiltered(); } -@@ -757,15 +_,21 @@ +@@ -759,15 +_,21 @@ return message.hasSignature() && !message.hasExpiredServer(Instant.now()); } @@ -880,7 +881,7 @@ Path path = file2.toPath(); if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { file2.renameTo(file1); -@@ -773,7 +_,7 @@ +@@ -775,7 +_,7 @@ } serverStatsCounter = new ServerStatsCounter(this.server, file1); @@ -889,7 +890,7 @@ } return serverStatsCounter; -@@ -781,11 +_,11 @@ +@@ -783,11 +_,11 @@ public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) { UUID uuid = player.getUUID(); @@ -903,7 +904,7 @@ } playerAdvancements.setPlayer(player); -@@ -839,11 +_,34 @@ +@@ -841,11 +_,34 @@ } public void reloadResources() { diff --git a/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch index 66fd20e36bea..dedc162cba80 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/WeavingMobEffect.java +++ b/net/minecraft/world/effect/WeavingMobEffect.java -@@ -25,11 +_,11 @@ +@@ -27,11 +_,11 @@ @Override public void onMobRemoved(ServerLevel level, LivingEntity entity, int amplifier, Entity.RemovalReason reason) { if (reason == Entity.RemovalReason.KILLED && (entity instanceof Player || level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { @@ -14,11 +14,11 @@ Set set = Sets.newHashSet(); int i = this.maxCobwebs.applyAsInt(random); -@@ -46,6 +_,7 @@ +@@ -48,6 +_,7 @@ } for (BlockPos blockPosx : set) { + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockPosx, Blocks.COBWEB.defaultBlockState())) continue; // Paper - Fire EntityChangeBlockEvent in more places - level.setBlock(blockPosx, Blocks.COBWEB.defaultBlockState(), 3); - level.levelEvent(3018, blockPosx, 0); + level.setBlock(blockPosx, Blocks.COBWEB.defaultBlockState(), Block.UPDATE_ALL); + level.levelEvent(LevelEvent.ANIMATION_SPAWN_COBWEB, blockPosx, 0); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch index 4e937ceab1cb..58918ddb5edf 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -402,7 +402,7 @@ } public void setSharedFlagOnFire(boolean isOnFire) { -- this.setSharedFlag(0, isOnFire || this.hasVisualFire); +- this.setSharedFlag(FLAG_ONFIRE, isOnFire || this.hasVisualFire); + this.setSharedFlag(0, this.visualFire.toBooleanOrElse(isOnFire)); // Paper - improve visual fire API } @@ -1308,7 +1308,7 @@ + } + } + // CraftBukkit end - this.setSharedFlag(4, swimming); + this.setSharedFlag(FLAG_SWIMMING, swimming); } @@ -2669,6 +_,7 @@ @@ -1323,7 +1323,7 @@ } public void setInvisible(boolean invisible) { -- this.setSharedFlag(5, invisible); +- this.setSharedFlag(FLAG_INVISIBLE, invisible); + // CraftBukkit - start + if (!this.persistentInvisibility) { // Prevent Minecraft from removing our invisibility flag + this.setSharedFlag(5, invisible); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch index 6ba4467572df..2e1221d33669 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LightningBolt.java +++ b/net/minecraft/world/entity/LightningBolt.java -@@ -40,6 +_,7 @@ +@@ -41,6 +_,7 @@ private ServerPlayer cause; private final Set hitEntities = Sets.newHashSet(); private int blocksSetOnFire; @@ -8,7 +8,7 @@ public LightningBolt(EntityType type, Level level) { super(type, level); -@@ -77,7 +_,7 @@ +@@ -78,7 +_,7 @@ @Override public void tick() { super.tick(); @@ -17,7 +17,7 @@ if (this.level().isClientSide()) { this.level() .playLocalSound( -@@ -108,7 +_,7 @@ +@@ -109,7 +_,7 @@ } this.powerLightningRod(); @@ -26,7 +26,7 @@ this.gameEvent(GameEvent.LIGHTNING_STRIKE); } } -@@ -131,7 +_,7 @@ +@@ -132,7 +_,7 @@ } } @@ -35,7 +35,7 @@ } else if (this.life < -this.random.nextInt(10)) { this.flashes--; this.life = 1; -@@ -140,10 +_,10 @@ +@@ -141,10 +_,10 @@ } } @@ -48,7 +48,7 @@ List entities = this.level() .getEntities( this, -@@ -169,32 +_,45 @@ +@@ -170,32 +_,45 @@ } private void spawnFire(int extraIgnitions) { @@ -101,7 +101,7 @@ } BlockPos.MutableBlockPos mutableBlockPos = pos.mutable(); -@@ -202,16 +_,16 @@ +@@ -203,16 +_,16 @@ for (int i1 = 0; i1 < i; i1++) { int i2 = level.random.nextInt(8) + 1; @@ -121,7 +121,7 @@ if (optional.isEmpty()) { break; } -@@ -220,11 +_,17 @@ +@@ -221,11 +_,17 @@ } } @@ -138,6 +138,6 @@ + } + }); + // Paper end - call EntityChangeBlockEvent - level.levelEvent(3002, blockPos, -1); + level.levelEvent(LevelEvent.PARTICLES_ELECTRIC_SPARK, blockPos, -1); return Optional.of(blockPos); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index 9999d33313db..61427a84a015 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -141,6 +_,17 @@ +@@ -142,6 +_,17 @@ import org.jetbrains.annotations.Contract; import org.slf4j.Logger; @@ -18,7 +18,7 @@ public abstract class LivingEntity extends Entity implements Attackable, WaypointTransmitter { private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; -@@ -271,11 +_,25 @@ +@@ -272,11 +_,25 @@ ); protected final EntityEquipment equipment; private Waypoint.Icon locatorBarIcon = new Waypoint.Icon(); @@ -45,7 +45,7 @@ this.equipment = this.createEquipment(); this.blocksBuilding = true; this.reapplyPosition(); -@@ -377,7 +_,13 @@ +@@ -378,7 +_,13 @@ double d1 = Math.min(0.2F + d / 15.0, 2.5); int i = (int)(150.0 * d1); @@ -60,16 +60,16 @@ } } -@@ -562,7 +_,7 @@ +@@ -563,7 +_,7 @@ this.deathTime++; if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { - this.level().broadcastEntityEvent(this, (byte)60); + this.level().broadcastEntityEvent(this, EntityEvent.POOF); - this.remove(Entity.RemovalReason.KILLED); + this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause } } -@@ -667,7 +_,7 @@ +@@ -668,7 +_,7 @@ } public boolean shouldDiscardFriction() { @@ -78,7 +78,7 @@ } public void setDiscardFriction(boolean discardFriction) { -@@ -679,10 +_,15 @@ +@@ -680,10 +_,15 @@ } public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem) { @@ -95,7 +95,7 @@ this.level() .playSeededSound( null, -@@ -709,12 +_,12 @@ +@@ -710,12 +_,12 @@ } @Override @@ -110,7 +110,7 @@ this.brain.clearMemories(); } -@@ -731,11 +_,17 @@ +@@ -732,11 +_,17 @@ mobEffectInstance.onMobRemoved(level, this, removalReason); } @@ -128,7 +128,7 @@ output.putFloat("Health", this.getHealth()); output.putShort("HurtTime", (short)this.hurtTime); output.putInt("HurtByTimestamp", this.lastHurtByMobTimestamp); -@@ -769,8 +_,15 @@ +@@ -770,8 +_,15 @@ } } @@ -146,7 +146,7 @@ if (stack.isEmpty()) { return null; } else if (this.level().isClientSide()) { -@@ -779,6 +_,31 @@ +@@ -780,6 +_,31 @@ } else { ItemEntity itemEntity = this.createItemStackToDrop(stack, randomizeMotion, includeThrower); if (itemEntity != null) { @@ -178,7 +178,7 @@ this.level().addFreshEntity(itemEntity); } -@@ -788,7 +_,22 @@ +@@ -789,7 +_,22 @@ @Override protected void readAdditionalSaveData(ValueInput input) { @@ -202,7 +202,7 @@ if (this.level() != null && !this.level().isClientSide()) { input.read("attributes", AttributeInstance.Packed.LIST_CODEC).ifPresent(this.getAttributes()::apply); } -@@ -801,6 +_,11 @@ +@@ -802,6 +_,11 @@ this.effectsDirty = true; } @@ -214,7 +214,7 @@ this.setHealth(input.getFloatOr("Health", this.getMaxHealth())); this.hurtTime = input.getShortOr("HurtTime", (short)0); this.deathTime = input.getShortOr("DeathTime", (short)0); -@@ -808,6 +_,7 @@ +@@ -809,6 +_,7 @@ input.getString("Team").ifPresent(string -> { Scoreboard scoreboard = this.level().getScoreboard(); PlayerTeam playerTeam = scoreboard.getPlayerTeam(string); @@ -222,9 +222,9 @@ boolean flag = playerTeam != null && scoreboard.addPlayerToTeam(this.getStringUUID(), playerTeam); if (!flag) { LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", string); -@@ -815,11 +_,13 @@ +@@ -816,11 +_,13 @@ }); - this.setSharedFlag(7, input.getBooleanOr("FallFlying", false)); + this.setSharedFlag(Entity.FLAG_FALL_FLYING, input.getBooleanOr("FallFlying", false)); input.read("sleeping_pos", BlockPos.CODEC).ifPresentOrElse(blockPos -> { + if (this.position().distanceToSqr(blockPos.getX(), blockPos.getY(), blockPos.getZ()) < Mth.square(16)) { // Paper - The sleeping pos will always also set the actual pos, so a desync suggests something is wrong this.setSleepingPos(blockPos); @@ -236,7 +236,7 @@ }, this::clearSleepingPos); input.read("Brain", Codec.PASSTHROUGH).ifPresent(dynamic -> this.brain = this.makeBrain((Dynamic)dynamic)); this.lastHurtByPlayer = EntityReference.read(input, "last_hurt_by_player"); -@@ -836,15 +_,44 @@ +@@ -837,15 +_,44 @@ this.updateDirtyEffects(); } @@ -281,7 +281,7 @@ iterator.remove(); this.onEffectsRemoved(List.of(mobEffectInstance)); } else if (mobEffectInstance.getDuration() % 600 == 0) { -@@ -853,6 +_,18 @@ +@@ -854,6 +_,18 @@ } } catch (ConcurrentModificationException var6) { } @@ -300,7 +300,7 @@ } else { for (MobEffectInstance mobEffectInstance1 : this.activeEffects.values()) { mobEffectInstance1.tickClient(); -@@ -963,15 +_,33 @@ +@@ -964,15 +_,33 @@ } public boolean removeAllEffects() { @@ -338,7 +338,7 @@ } } -@@ -998,21 +_,57 @@ +@@ -999,21 +_,57 @@ } public final boolean addEffect(MobEffectInstance effectInstance) { @@ -398,7 +398,7 @@ this.onEffectUpdated(mobEffectInstance, true, entity); flag = true; } -@@ -1051,11 +_,37 @@ +@@ -1052,11 +_,37 @@ @Nullable public final MobEffectInstance removeEffectNoUpdate(Holder effect) { @@ -437,7 +437,7 @@ if (mobEffectInstance != null) { this.onEffectsRemoved(List.of(mobEffectInstance)); return true; -@@ -1146,17 +_,62 @@ +@@ -1147,17 +_,62 @@ } public void heal(float amount) { @@ -501,7 +501,7 @@ this.entityData.set(DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth())); } -@@ -1168,7 +_,7 @@ +@@ -1169,7 +_,7 @@ public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { if (this.isInvulnerableTo(level, damageSource)) { return false; @@ -510,7 +510,7 @@ return false; } else if (damageSource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1184,35 +_,58 @@ +@@ -1185,35 +_,58 @@ ItemStack useItem = this.getUseItem(); float originAmount = amount; @@ -577,7 +577,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1227,7 +_,7 @@ +@@ -1228,7 +_,7 @@ level.broadcastDamageEvent(this, damageSource); } @@ -586,7 +586,7 @@ this.markHurt(); } -@@ -1242,8 +_,16 @@ +@@ -1243,8 +_,16 @@ d = damageSource.getSourcePosition().x() - this.getX(); d1 = damageSource.getSourcePosition().z() - this.getZ(); } @@ -604,7 +604,7 @@ if (!flag) { this.indicateDamage(d, d1); } -@@ -1252,19 +_,19 @@ +@@ -1253,19 +_,19 @@ if (this.isDeadOrDying()) { if (!this.checkTotemDeathProtection(damageSource)) { @@ -629,7 +629,7 @@ if (flag2) { this.lastDamageSource = damageSource; this.lastDamageStamp = this.level().getGameTime(); -@@ -1290,6 +_,12 @@ +@@ -1291,6 +_,12 @@ } public float applyItemBlocking(ServerLevel level, DamageSource damageSource, float damageAmount) { @@ -642,7 +642,7 @@ if (damageAmount <= 0.0F) { return 0.0F; } else { -@@ -1314,10 +_,12 @@ +@@ -1315,10 +_,12 @@ } float f = blocksAttacks.resolveBlockedDamage(damageSource, damageAmount, acos); @@ -656,7 +656,7 @@ return f; } -@@ -1328,6 +_,59 @@ +@@ -1329,6 +_,59 @@ } } @@ -716,7 +716,7 @@ public void playSecondaryHurtSound(DamageSource damageSource) { if (damageSource.is(DamageTypes.THORNS)) { SoundSource soundSource = this instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE; -@@ -1360,12 +_,24 @@ +@@ -1361,12 +_,24 @@ return EntityReference.getPlayer(this.lastHurtByPlayer, this.level()); } @@ -742,7 +742,7 @@ } private boolean checkTotemDeathProtection(DamageSource damageSource) { -@@ -1375,18 +_,39 @@ +@@ -1376,18 +_,39 @@ ItemStack itemStack = null; DeathProtection deathProtection = null; @@ -789,7 +789,7 @@ serverPlayer.awardStat(Stats.ITEM_USED.get(itemStack.getItem())); CriteriaTriggers.USED_TOTEM.trigger(serverPlayer, itemStack); this.gameEvent(GameEvent.ITEM_INTERACT_FINISH); -@@ -1445,6 +_,7 @@ +@@ -1446,6 +_,7 @@ if (!this.isRemoved() && !this.dead) { Entity entity = damageSource.getEntity(); LivingEntity killCredit = this.getKillCredit(); @@ -797,7 +797,7 @@ if (killCredit != null) { killCredit.awardKillScore(this, damageSource); } -@@ -1454,68 +_,147 @@ +@@ -1455,68 +_,147 @@ } if (!this.level().isClientSide() && this.hasCustomName()) { @@ -857,7 +857,7 @@ + // Paper start + if (this.dead) { // Paper - this.level().broadcastEntityEvent(this, (byte)3); + this.level().broadcastEntityEvent(this, EntityEvent.DEATH); - } this.setPose(Pose.DYING); @@ -875,7 +875,7 @@ BlockPos blockPos = this.blockPosition(); BlockState blockState = Blocks.WITHER_ROSE.defaultBlockState(); if (this.level().getBlockState(blockPos).isAir() && blockState.canSurvive(this.level(), blockPos)) { -- this.level().setBlock(blockPos, blockState, 3); +- this.level().setBlock(blockPos, blockState, Block.UPDATE_ALL); - var6 = true; + var6 = CraftEventFactory.handleBlockFormEvent(this.level(), blockPos, blockState, 3, this); // CraftBukkit - call EntityBlockFormEvent for Wither Rose } @@ -958,7 +958,7 @@ } protected void dropCustomDeathLoot(ServerLevel level, DamageSource damageSource, boolean recentlyHit) { -@@ -1619,9 +_,14 @@ +@@ -1620,9 +_,14 @@ } public void knockback(double strength, double x, double z) { @@ -975,7 +975,7 @@ Vec3 deltaMovement = this.getDeltaMovement(); while (x * x + z * z < 1.0E-5F) { -@@ -1630,11 +_,22 @@ +@@ -1631,11 +_,22 @@ } Vec3 vec3 = new Vec3(x, 0.0, z).normalize().scale(strength); @@ -999,7 +999,7 @@ } } -@@ -1727,7 +_,7 @@ +@@ -1728,7 +_,7 @@ @Override public boolean isAlive() { @@ -1008,7 +1008,7 @@ } public boolean isLookingAtMe(LivingEntity entity, double tolerance, boolean scaleByDistance, boolean visual, double... yValues) { -@@ -1761,9 +_,14 @@ +@@ -1762,9 +_,14 @@ boolean flag = super.causeFallDamage(fallDistance, damageMultiplier, damageSource); int i = this.calculateFallDamage(fallDistance, damageMultiplier); if (i > 0) { @@ -1024,7 +1024,7 @@ return true; } else { return flag; -@@ -1828,7 +_,7 @@ +@@ -1829,7 +_,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damageSource, float damageAmount) { if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -1033,7 +1033,7 @@ damageAmount = CombatRules.getDamageAfterAbsorb( this, damageAmount, damageSource, this.getArmorValue(), (float)this.getAttributeValue(Attributes.ARMOR_TOUGHNESS) ); -@@ -1841,7 +_,8 @@ +@@ -1842,7 +_,8 @@ if (damageSource.is(DamageTypeTags.BYPASSES_EFFECTS)) { return damageAmount; } else { @@ -1043,7 +1043,7 @@ int i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int i1 = 25 - i; float f = damageAmount * i1; -@@ -1878,24 +_,201 @@ +@@ -1879,24 +_,201 @@ } } @@ -1255,7 +1255,7 @@ } public CombatTracker getCombatTracker() { -@@ -1924,7 +_,17 @@ +@@ -1925,7 +_,17 @@ } public final void setArrowCount(int count) { @@ -1274,7 +1274,7 @@ } public final int getStingerCount() { -@@ -1969,7 +_,7 @@ +@@ -1972,7 +_,7 @@ @Override public void handleDamageEvent(DamageSource damageSource) { this.walkAnimation.setSpeed(1.5F); @@ -1283,7 +1283,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; SoundEvent hurtSound = this.getHurtSound(damageSource); -@@ -2088,7 +_,7 @@ +@@ -2091,7 +_,7 @@ @Override protected void onBelowWorld() { @@ -1292,7 +1292,7 @@ } protected void updateSwingTime() { -@@ -2184,8 +_,15 @@ +@@ -2187,8 +_,15 @@ } public void setItemSlot(EquipmentSlot slot, ItemStack stack) { @@ -1310,7 +1310,7 @@ public float getArmorCoverPercentage() { int i = 0; -@@ -2277,14 +_,27 @@ +@@ -2280,14 +_,27 @@ return this.hasEffect(MobEffects.JUMP_BOOST) ? 0.1F * (this.getEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1.0F) : 0.0F; } @@ -1338,18 +1338,18 @@ this.addDeltaMovement(new Vec3(-Mth.sin(f) * 0.2, 0.0, Mth.cos(f) * 0.2)); } -@@ -2444,8 +_,10 @@ +@@ -2447,8 +_,10 @@ } public void stopFallFlying() { + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) { // Paper - this.setSharedFlag(7, true); - this.setSharedFlag(7, false); + this.setSharedFlag(Entity.FLAG_FALL_FLYING, true); + this.setSharedFlag(Entity.FLAG_FALL_FLYING, false); + } // Paper } private Vec3 updateFallFlyingMovement(Vec3 deltaMovement) { -@@ -2589,7 +_,7 @@ +@@ -2592,7 +_,7 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F && target instanceof LivingEntity livingEntity) { @@ -1358,7 +1358,7 @@ this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); } } -@@ -2665,37 +_,15 @@ +@@ -2668,37 +_,15 @@ profilerFiller.pop(); profilerFiller.push("rangeChecks"); @@ -1405,7 +1405,7 @@ profilerFiller.pop(); if (this.isFallFlying()) { -@@ -2777,16 +_,39 @@ +@@ -2780,16 +_,39 @@ @Nullable private Map collectEquipmentChanges() { Map map = null; @@ -1445,7 +1445,7 @@ AttributeMap attributes = this.getAttributes(); if (!itemStack.isEmpty()) { this.stopLocationBasedEffects(itemStack, equipmentSlot, attributes); -@@ -2811,6 +_,8 @@ +@@ -2814,6 +_,8 @@ } } } @@ -1454,7 +1454,7 @@ } return map; -@@ -2842,7 +_,7 @@ +@@ -2845,7 +_,7 @@ list.add(Pair.of(equipmentSlot, itemStack1)); this.lastEquipmentItems.put(equipmentSlot, itemStack1); }); @@ -1463,7 +1463,7 @@ } protected void tickHeadTurn(float yBodyRot) { -@@ -2928,8 +_,10 @@ +@@ -2931,8 +_,10 @@ if (!flag || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if (!this.isInLava() || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if ((this.onGround() || flag && fluidHeight <= fluidJumpThreshold) && this.noJumpDelay == 0) { @@ -1474,7 +1474,7 @@ } } else { this.jumpInLiquid(FluidTags.LAVA); -@@ -2970,7 +_,7 @@ +@@ -2973,7 +_,7 @@ profilerFiller.pop(); if (this.level() instanceof ServerLevel serverLevel) { profilerFiller.push("freezing"); @@ -1483,7 +1483,7 @@ this.setTicksFrozen(Math.max(0, this.getTicksFrozen() - 2)); } -@@ -2991,6 +_,20 @@ +@@ -2994,6 +_,20 @@ this.pushEntities(); profilerFiller.pop(); @@ -1504,15 +1504,15 @@ if (this.level() instanceof ServerLevel serverLevel && this.isSensitiveToWater() && this.isInWaterOrRain()) { this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F); } -@@ -3013,6 +_,7 @@ +@@ -3016,6 +_,7 @@ this.checkFallDistanceAccumulation(); if (!this.level().isClientSide()) { if (!this.canGlide()) { + if (this.getSharedFlag(7) != false && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit - this.setSharedFlag(7, false); + this.setSharedFlag(Entity.FLAG_FALL_FLYING, false); return; } -@@ -3052,10 +_,25 @@ +@@ -3055,10 +_,25 @@ } protected void pushEntities() { @@ -1539,7 +1539,7 @@ if (_int > 0 && pushableEntities.size() > _int - 1 && this.random.nextInt(4) == 0) { int i = 0; -@@ -3071,7 +_,16 @@ +@@ -3074,7 +_,16 @@ } } @@ -1556,7 +1556,7 @@ this.doPush(entity1); } } -@@ -3080,16 +_,32 @@ +@@ -3083,16 +_,32 @@ protected void checkAutoSpinAttack(AABB boundingBoxBeforeSpin, AABB boundingBoxAfterSpin) { AABB aabb = boundingBoxBeforeSpin.minmax(boundingBoxAfterSpin); List entities = this.level().getEntities(this, aabb); @@ -1590,7 +1590,7 @@ this.autoSpinAttackTicks = 0; } -@@ -3112,10 +_,10 @@ +@@ -3115,10 +_,10 @@ } @Override @@ -1604,7 +1604,7 @@ this.dismountVehicle(vehicle); } } -@@ -3142,7 +_,7 @@ +@@ -3145,7 +_,7 @@ } public void onItemPickup(ItemEntity itemEntity) { @@ -1613,7 +1613,7 @@ if (owner instanceof ServerPlayer) { CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer)owner, itemEntity.getItem(), this); } -@@ -3154,7 +_,7 @@ +@@ -3157,7 +_,7 @@ && (entity instanceof ItemEntity || entity instanceof AbstractArrow || entity instanceof ExperienceOrb)) { ((ServerLevel)this.level()) .getChunkSource() @@ -1622,7 +1622,7 @@ } } -@@ -3168,7 +_,8 @@ +@@ -3171,7 +_,8 @@ } else { Vec3 vec3 = new Vec3(this.getX(), this.getEyeY(), this.getZ()); Vec3 vec31 = new Vec3(entity.getX(), y, entity.getZ()); @@ -1632,7 +1632,7 @@ } } -@@ -3188,13 +_,27 @@ +@@ -3191,13 +_,27 @@ @Override public boolean isPickable() { @@ -1663,7 +1663,7 @@ @Override public float getYHeadRot() { -@@ -3225,7 +_,7 @@ +@@ -3228,7 +_,7 @@ } public final void setAbsorptionAmount(float absorptionAmount) { @@ -1672,7 +1672,7 @@ } protected void internalSetAbsorptionAmount(float absorptionAmount) { -@@ -3252,6 +_,15 @@ +@@ -3255,6 +_,15 @@ return (this.entityData.get(DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; } @@ -1688,7 +1688,7 @@ private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { -@@ -3269,6 +_,11 @@ +@@ -3272,6 +_,11 @@ return null; } else { double d = this.getEyeY() - 0.3F; @@ -1700,7 +1700,7 @@ ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), d, this.getZ(), stack); itemEntity.setPickUpDelay(40); if (includeThrower) { -@@ -3300,7 +_,12 @@ +@@ -3303,7 +_,12 @@ protected void updateUsingItem(ItemStack usingItem) { usingItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); @@ -1714,7 +1714,7 @@ this.completeUsingItem(); } } -@@ -3326,10 +_,19 @@ +@@ -3329,10 +_,19 @@ } public void startUsingItem(InteractionHand hand) { @@ -1734,9 +1734,9 @@ + this.eatStartTime = System.nanoTime(); + // Paper end - lag compensate eating if (!this.level().isClientSide()) { - this.setLivingEntityFlag(1, true); - this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND); -@@ -3356,7 +_,10 @@ + this.setLivingEntityFlag(LIVING_ENTITY_FLAG_IS_USING, true); + this.setLivingEntityFlag(LIVING_ENTITY_FLAG_OFF_HAND, hand == InteractionHand.OFF_HAND); +@@ -3359,7 +_,10 @@ } } else if (!this.isUsingItem() && !this.useItem.isEmpty()) { this.useItem = ItemStack.EMPTY; @@ -1748,7 +1748,7 @@ } } } -@@ -3395,7 +_,38 @@ +@@ -3398,7 +_,38 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1788,7 +1788,7 @@ if (itemStack != this.useItem) { this.setItemInHand(usedItemHand, itemStack); } -@@ -3429,6 +_,7 @@ +@@ -3432,6 +_,7 @@ ItemStack itemInHand = this.getItemInHand(this.getUsedItemHand()); if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemInHand, this.useItem)) { this.useItem = itemInHand; @@ -1796,7 +1796,7 @@ this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); if (this.useItem.useOnRelease()) { this.updatingUsingItem(); -@@ -3449,7 +_,10 @@ +@@ -3452,7 +_,10 @@ } this.useItem = ItemStack.EMPTY; @@ -1808,7 +1808,7 @@ } public boolean isBlocking() { -@@ -3473,6 +_,60 @@ +@@ -3476,6 +_,60 @@ } } @@ -1869,7 +1869,7 @@ public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); } -@@ -3491,6 +_,12 @@ +@@ -3494,6 +_,12 @@ } public boolean randomTeleport(double x, double y, double z, boolean broadcastTeleport) { @@ -1882,7 +1882,7 @@ double x1 = this.getX(); double y1 = this.getY(); double z1 = this.getZ(); -@@ -3513,16 +_,39 @@ +@@ -3516,16 +_,39 @@ } if (flag1) { @@ -1924,8 +1924,8 @@ + return Optional.of(false); // CraftBukkit } else { if (broadcastTeleport) { - level.broadcastEntityEvent(this, (byte)46); -@@ -3532,7 +_,7 @@ + level.broadcastEntityEvent(this, EntityEvent.TELEPORT); +@@ -3535,7 +_,7 @@ pathfinderMob.getNavigation().stop(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/OminousItemSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/OminousItemSpawner.java.patch index 636d2542f880..e3f3fdd9e410 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/OminousItemSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/OminousItemSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/OminousItemSpawner.java +++ b/net/minecraft/world/entity/OminousItemSpawner.java -@@ -77,7 +_,7 @@ +@@ -78,7 +_,7 @@ entity = this.spawnProjectile(serverLevel, projectileItem, item); } else { entity = new ItemEntity(serverLevel, this.getX(), this.getY(), this.getZ(), item); @@ -8,8 +8,8 @@ + serverLevel.addFreshEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.OMINOUS_ITEM_SPAWNER); // Paper - fixes and addition to spawn reason API } - serverLevel.levelEvent(3021, this.blockPosition(), 1); -@@ -91,7 +_,7 @@ + serverLevel.levelEvent(LevelEvent.PARTICLES_TRIAL_SPAWNER_SPAWN_ITEM, this.blockPosition(), 1); +@@ -92,7 +_,7 @@ ProjectileItem.DispenseConfig dispenseConfig = projectileItem.createDispenseConfig(); dispenseConfig.overrideDispenseEvent().ifPresent(i -> level.levelEvent(i, this.blockPosition(), 0)); Direction direction = Direction.DOWN; @@ -18,7 +18,7 @@ projectileItem.asProjectile(level, this.position(), stack, direction), level, stack, -@@ -100,7 +_,7 @@ +@@ -101,7 +_,7 @@ direction.getStepZ(), dispenseConfig.power(), dispenseConfig.uncertainty() diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch index 43404a071aaf..cfc60b55d7ee 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java +++ b/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java -@@ -38,7 +_,14 @@ +@@ -39,7 +_,14 @@ .findFirst() ) .ifPresent(reference -> { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java.patch index 41b07e6724f1..7a3f753af534 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java +++ b/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java -@@ -75,6 +_,16 @@ +@@ -76,6 +_,16 @@ .flatMap( nearestVisibleLivingEntities -> nearestVisibleLivingEntities.findClosest(livingEntity -> this.ramTargeting.test(level, entity, livingEntity)) ) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/RamTarget.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/RamTarget.java.patch index dc1f5963bff3..f1551b7ce4ca 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/RamTarget.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/RamTarget.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/RamTarget.java +++ b/net/minecraft/world/entity/ai/behavior/RamTarget.java -@@ -92,7 +_,7 @@ +@@ -93,7 +_,7 @@ DamageSource damageSource1 = level.damageSources().mobAttack(owner); float f3 = livingEntity.applyItemBlocking(level, damageSource1, f); float f4 = f3 > 0.0F ? 0.5F : 1.0F; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java.patch index da9c51684439..be0a7c556113 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java.patch @@ -10,6 +10,6 @@ + return true; + } + // CraftBukkit end - level.setBlock(blockPos2, blockState, 3); + level.setBlock(blockPos2, blockState, Block.UPDATE_ALL); level.gameEvent(GameEvent.BLOCK_PLACE, blockPos2, GameEvent.Context.of(entity, blockState)); level.playSound(null, entity, SoundEvents.FROG_LAY_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch index aef09991e284..0a009423ec25 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java +++ b/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java -@@ -110,11 +_,17 @@ +@@ -111,11 +_,17 @@ if (breedOffspring == null) { return Optional.empty(); } else { @@ -18,6 +18,6 @@ + partner.setAge(6000); + level.addFreshEntityWithPassengers(breedOffspring, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); + // CraftBukkit end - call EntityBreedEvent - level.broadcastEntityEvent(breedOffspring, (byte)12); + level.broadcastEntityEvent(breedOffspring, EntityEvent.LOVE_HEARTS); return Optional.of(breedOffspring); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java.patch index 9f783335fbf1..55a834a3c650 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java +++ b/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java -@@ -86,7 +_,9 @@ +@@ -87,7 +_,9 @@ inventory.removeItemType(Items.WHEAT, i3); ItemStack itemStack = inventory.addItem(new ItemStack(Items.BREAD, min)); if (!itemStack.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/warden/SonicBoom.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/warden/SonicBoom.java.patch index 4289534ef34c..37f0c908483d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/warden/SonicBoom.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/warden/SonicBoom.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/warden/SonicBoom.java +++ b/net/minecraft/world/entity/ai/behavior/warden/SonicBoom.java -@@ -83,7 +_,7 @@ +@@ -84,7 +_,7 @@ if (livingEntity.hurtServer(level, level.damageSources().sonicBoom(owner), 10.0F)) { double d = 0.5 * (1.0 - livingEntity.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); double d1 = 2.5 * (1.0 - livingEntity.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch index 9fd1ccd71c9e..52c673130d83 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java +++ b/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java -@@ -73,9 +_,16 @@ +@@ -74,9 +_,16 @@ } if (this.breakTime == this.getDoorBreakTime() && this.isValidDifficulty(this.mob.level().getDifficulty())) { @@ -12,8 +12,8 @@ + // CraftBukkit end + final net.minecraft.world.level.block.state.BlockState oldState = this.mob.level().getBlockState(this.doorPos); // Paper - fix MC-263999 this.mob.level().removeBlock(this.doorPos, false); - this.mob.level().levelEvent(1021, this.doorPos, 0); -- this.mob.level().levelEvent(2001, this.doorPos, Block.getId(this.mob.level().getBlockState(this.doorPos))); + this.mob.level().levelEvent(LevelEvent.SOUND_ZOMBIE_DOOR_CRASH, this.doorPos, 0); +- this.mob.level().levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, this.doorPos, Block.getId(this.mob.level().getBlockState(this.doorPos))); + this.mob.level().levelEvent(2001, this.doorPos, Block.getId(oldState)); // Paper - fix MC-263999 } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch index 299aafaef13d..e92a3969ffe1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/EatBlockGoal.java +++ b/net/minecraft/world/entity/ai/goal/EatBlockGoal.java -@@ -60,8 +_,9 @@ +@@ -62,8 +_,9 @@ this.eatAnimationTick = Math.max(0, this.eatAnimationTick - 1); if (this.eatAnimationTick == this.adjustedTickDelay(4)) { BlockPos blockPos = this.mob.blockPosition(); @@ -12,12 +12,12 @@ this.level.destroyBlock(blockPos, false); } -@@ -69,7 +_,7 @@ +@@ -71,7 +_,7 @@ } else { BlockPos blockPos1 = blockPos.below(); if (this.level.getBlockState(blockPos1).is(Blocks.GRASS_BLOCK)) { - if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockPos1, Blocks.DIRT.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit // Paper - Fix wrong block state - this.level.levelEvent(2001, blockPos1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); - this.level.setBlock(blockPos1, Blocks.DIRT.defaultBlockState(), 2); + this.level.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, blockPos1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); + this.level.setBlock(blockPos1, Blocks.DIRT.defaultBlockState(), Block.UPDATE_CLIENTS); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch index bab3ed29fe01..402f2ab1caa5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java +++ b/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java -@@ -58,7 +_,7 @@ +@@ -59,7 +_,7 @@ if (firstPassenger instanceof Player player) { int temper = this.horse.getTemper(); int maxTemper = this.horse.getMaxTemper(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch index 68b4b71bb321..a4af5a390093 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ambient/Bat.java +++ b/net/minecraft/world/entity/ambient/Bat.java -@@ -86,7 +_,7 @@ +@@ -87,7 +_,7 @@ } @Override @@ -9,7 +9,7 @@ return false; } -@@ -140,13 +_,13 @@ +@@ -141,13 +_,13 @@ this.yHeadRot = this.random.nextInt(360); } @@ -17,15 +17,15 @@ + if (level.getNearestPlayer(BAT_RESTING_TARGETING, this) != null && org.bukkit.craftbukkit.event.CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent this.setResting(false); if (!isSilent) { - level.levelEvent(null, 1025, blockPos, 0); + level.levelEvent(null, LevelEvent.SOUND_BAT_LIFTOFF, blockPos, 0); } } - } else { + } else if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent this.setResting(false); if (!isSilent) { - level.levelEvent(null, 1025, blockPos, 0); -@@ -179,7 +_,7 @@ + level.levelEvent(null, LevelEvent.SOUND_BAT_LIFTOFF, blockPos, 0); +@@ -180,7 +_,7 @@ float f1 = Mth.wrapDegrees(f - this.getYRot()); this.zza = 0.5F; this.setYRot(this.getYRot() + f1); @@ -34,7 +34,7 @@ this.setResting(true); } } -@@ -204,7 +_,7 @@ +@@ -205,7 +_,7 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch index 0fb91259a502..a0e5270649be 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Animal.java +++ b/net/minecraft/world/entity/animal/Animal.java -@@ -40,6 +_,7 @@ +@@ -41,6 +_,7 @@ public int inLove = 0; @Nullable public EntityReference loveCause; @@ -8,7 +8,7 @@ protected Animal(EntityType type, Level level) { super(type, level); -@@ -79,9 +_,13 @@ +@@ -80,9 +_,13 @@ } @Override @@ -24,7 +24,7 @@ } @Override -@@ -137,8 +_,9 @@ +@@ -138,8 +_,9 @@ if (this.isFood(itemInHand)) { int age = this.getAge(); if (player instanceof ServerPlayer serverPlayer && age == 0 && this.canFallInLove()) { @@ -35,7 +35,7 @@ this.playEatingSound(); return InteractionResult.SUCCESS_SERVER; } -@@ -165,8 +_,23 @@ +@@ -166,8 +_,23 @@ return this.inLove <= 0; } @@ -60,7 +60,7 @@ if (player instanceof ServerPlayer serverPlayer) { this.loveCause = EntityReference.of(serverPlayer); } -@@ -204,23 +_,45 @@ +@@ -205,23 +_,45 @@ if (breedOffspring != null) { breedOffspring.setBaby(true); breedOffspring.snapTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); @@ -104,7 +104,7 @@ animal.setAge(6000); this.resetLove(); animal.resetLove(); - level.broadcastEntityEvent(this, (byte)18); + level.broadcastEntityEvent(this, EntityEvent.IN_LOVE_HEARTS); - if (level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - level.addFreshEntity(new ExperienceOrb(level, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1)); + if (experience > 0 && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - Call EntityBreedEvent diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch index 018670a6557c..aaf4047d34b9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Bee.java +++ b/net/minecraft/world/entity/animal/Bee.java -@@ -148,10 +_,26 @@ +@@ -149,10 +_,26 @@ Bee.BeeGoToHiveGoal goToHiveGoal; private Bee.BeeGoToKnownFlowerGoal goToKnownFlowerGoal; private int underWaterTicks; @@ -28,7 +28,7 @@ this.lookControl = new Bee.BeeLookControl(this); this.setPathfindingMalus(PathType.DANGER_FIRE, -1.0F); this.setPathfindingMalus(PathType.WATER, -1.0F); -@@ -198,9 +_,18 @@ +@@ -199,9 +_,18 @@ @Override protected void addAdditionalSaveData(ValueOutput output) { @@ -47,7 +47,7 @@ output.putBoolean("HasNectar", this.hasNectar()); output.putBoolean("HasStung", this.hasStung()); output.putInt("TicksSincePollination", this.ticksWithoutNectarSinceExitingHive); -@@ -238,7 +_,7 @@ +@@ -239,7 +_,7 @@ } if (i > 0) { @@ -56,7 +56,7 @@ } } -@@ -485,7 +_,11 @@ +@@ -486,7 +_,11 @@ if (this.hivePos == null) { return null; } else { @@ -69,15 +69,15 @@ } } -@@ -518,6 +_,7 @@ +@@ -519,6 +_,7 @@ } public void setRolling(boolean isRolling) { + isRolling = this.rollingOverride.toBooleanOrElse(isRolling); // Paper - Rolling override - this.setFlag(2, isRolling); + this.setFlag(FLAG_ROLL, isRolling); } -@@ -574,7 +_,7 @@ +@@ -575,7 +_,7 @@ if (beeInteractionEffect != null) { this.usePlayerItem(player, hand, itemInHand); if (!this.level().isClientSide()) { @@ -86,7 +86,7 @@ } return InteractionResult.SUCCESS; -@@ -643,8 +_,9 @@ +@@ -644,8 +_,9 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { @@ -97,16 +97,16 @@ } } -@@ -986,7 +_,7 @@ +@@ -987,7 +_,7 @@ } } - if (blockState1 != null) { + if (blockState1 != null && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(Bee.this, blockPos, blockState1)) { // CraftBukkit - Bee.this.level().levelEvent(2011, blockPos, 15); + Bee.this.level().levelEvent(LevelEvent.PARTICLES_BEE_GROWTH, blockPos, 15); Bee.this.level().setBlockAndUpdate(blockPos, blockState1); Bee.this.incrementNumCropsGrownSincePollination(); -@@ -1010,7 +_,7 @@ +@@ -1011,7 +_,7 @@ @Override protected void alertOther(Mob mob, LivingEntity target) { if (mob instanceof Bee && this.mob.hasLineOfSight(target)) { @@ -115,7 +115,7 @@ } } } -@@ -1168,7 +_,7 @@ +@@ -1169,7 +_,7 @@ Bee.this.dropFlower(); this.pollinating = false; Bee.this.remainingCooldownBeforeLocatingNewFlower = 200; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch index 86700d60d21c..097c820fb681 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Cat.java +++ b/net/minecraft/world/entity/animal/Cat.java -@@ -373,6 +_,11 @@ +@@ -374,6 +_,11 @@ if (item instanceof DyeItem dyeItem) { DyeColor dyeColor = dyeItem.getDyeColor(); if (dyeColor != this.getCollarColor()) { @@ -12,7 +12,7 @@ if (!this.level().isClientSide()) { this.setCollarColor(dyeColor); itemInHand.consume(1, player); -@@ -385,7 +_,7 @@ +@@ -386,7 +_,7 @@ if (!this.level().isClientSide()) { this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); @@ -21,7 +21,7 @@ this.playEatingSound(); } -@@ -447,7 +_,7 @@ +@@ -448,7 +_,7 @@ } private void tryToTame(Player player) { @@ -29,8 +29,8 @@ + if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit this.tame(player); this.setOrderedToSit(true); - this.level().broadcastEntityEvent(this, (byte)7); -@@ -585,15 +_,20 @@ + this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); +@@ -586,15 +_,20 @@ .dropFromGiftLootTable( getServerLevel(this.cat), BuiltInLootTables.CAT_MORNING_GIFT, @@ -55,7 +55,7 @@ ); } -@@ -620,7 +_,7 @@ +@@ -621,7 +_,7 @@ static class CatTemptGoal extends TemptGoal { @Nullable diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch index d010ebedbda6..b3a85bb49fb2 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Dolphin.java +++ b/net/minecraft/world/entity/animal/Dolphin.java -@@ -99,6 +_,13 @@ +@@ -100,6 +_,13 @@ return EntityType.DOLPHIN.create(level, EntitySpawnReason.BREEDING); } @@ -14,7 +14,7 @@ @Override public float getAgeScale() { return this.isBaby() ? 0.65F : 1.0F; -@@ -183,7 +_,7 @@ +@@ -184,7 +_,7 @@ @Override public int getMaxAirSupply() { @@ -23,7 +23,7 @@ } @Override -@@ -216,11 +_,15 @@ +@@ -217,11 +_,15 @@ if (this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) { ItemStack item = entity.getItem(); if (this.canHoldItem(item)) { @@ -40,7 +40,7 @@ } } } -@@ -487,7 +_,7 @@ +@@ -488,7 +_,7 @@ @Override public void start() { @@ -49,7 +49,7 @@ } @Override -@@ -506,7 +_,7 @@ +@@ -507,7 +_,7 @@ } if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) { @@ -58,7 +58,7 @@ } } } -@@ -576,7 +_,7 @@ +@@ -577,7 +_,7 @@ 0.3F * Mth.cos(Dolphin.this.getYRot() * (float) (Math.PI / 180.0)) * Mth.cos(Dolphin.this.getXRot() * (float) (Math.PI / 180.0)) + Mth.sin(f1) * f2 ); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch index e94a54442e10..a7adf614b850 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Fox.java +++ b/net/minecraft/world/entity/animal/Fox.java -@@ -430,7 +_,7 @@ +@@ -432,7 +_,7 @@ input.read("Trusted", TRUSTED_LIST_CODEC).orElse(List.of()).forEach(this::addTrustedEntity); this.setSleeping(input.getBooleanOr("Sleeping", false)); this.setVariant(input.read("Type", Fox.Variant.CODEC).orElse(Fox.Variant.DEFAULT)); @@ -9,7 +9,7 @@ this.setIsCrouching(input.getBooleanOr("Crouching", false)); if (this.level() instanceof ServerLevel) { this.setTargetGoals(); -@@ -447,6 +_,12 @@ +@@ -449,6 +_,12 @@ } public void setSitting(boolean sitting) { @@ -19,10 +19,10 @@ + public void setSitting(boolean sitting, boolean fireEvent) { + if (fireEvent && !new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), sitting).callEvent()) return; + // Paper end - Add EntityToggleSitEvent - this.setFlag(1, sitting); + this.setFlag(FLAG_SITTING, sitting); } -@@ -506,19 +_,20 @@ +@@ -508,19 +_,20 @@ itemEntity.setPickUpDelay(40); itemEntity.setThrower(this); this.playSound(SoundEvents.FOX_SPIT, 1.0F, 1.0F); @@ -46,7 +46,7 @@ int count = item.getCount(); if (count > 1) { this.dropItemStack(item.split(count - 1)); -@@ -529,7 +_,7 @@ +@@ -531,7 +_,7 @@ this.setItemSlot(EquipmentSlot.MAINHAND, item.split(1)); this.setGuaranteedDrop(EquipmentSlot.MAINHAND); this.take(entity, item.getCount()); @@ -55,7 +55,7 @@ this.ticksSinceEaten = 0; } } -@@ -620,12 +_,12 @@ +@@ -622,12 +_,12 @@ } @Override @@ -70,7 +70,7 @@ } void wakeUp() { -@@ -689,15 +_,33 @@ +@@ -691,15 +_,33 @@ return this.getTrustedEntities().anyMatch(entityReference -> entityReference.matches(entity)); } @@ -108,7 +108,7 @@ } public static boolean isPathClear(Fox fox, LivingEntity livingEntity) { -@@ -872,6 +_,19 @@ +@@ -874,6 +_,19 @@ fox.addTrustedEntity(loveCause1); } @@ -128,7 +128,7 @@ if (serverPlayer != null) { serverPlayer.awardStat(Stats.ANIMALS_BRED); CriteriaTriggers.BRED_ANIMALS.trigger(serverPlayer, this.animal, this.partner, fox); -@@ -881,14 +_,12 @@ +@@ -883,14 +_,12 @@ this.partner.setAge(6000); this.animal.resetLove(); this.partner.resetLove(); @@ -136,7 +136,7 @@ - fox.snapTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F); - this.level.addFreshEntityWithPassengers(fox); + this.level.addFreshEntityWithPassengers(fox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason - this.level.broadcastEntityEvent(this.animal, (byte)18); + this.level.broadcastEntityEvent(this.animal, EntityEvent.IN_LOVE_HEARTS); - if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (experience > 0 && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - call EntityBreedEvent this.level @@ -146,7 +146,7 @@ ); } } -@@ -952,6 +_,7 @@ +@@ -954,6 +_,7 @@ private void pickSweetBerries(BlockState state) { int ageValue = state.getValue(SweetBerryBushBlock.AGE); state.setValue(SweetBerryBushBlock.AGE, 1); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch index 4ba5d7aedee9..de8e39c3864c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/IronGolem.java +++ b/net/minecraft/world/entity/animal/IronGolem.java -@@ -106,7 +_,7 @@ +@@ -107,7 +_,7 @@ @Override protected void doPush(Entity entity) { if (entity instanceof Enemy && !(entity instanceof Creeper) && this.getRandom().nextInt(20) == 0) { @@ -9,7 +9,7 @@ } super.doPush(entity); -@@ -305,7 +_,7 @@ +@@ -306,7 +_,7 @@ BlockPos blockPos = this.blockPosition(); BlockPos blockPos1 = blockPos.below(); BlockState blockState = level.getBlockState(blockPos1); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch index 7de4c925fa12..e9414924cb20 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Ocelot.java +++ b/net/minecraft/world/entity/animal/Ocelot.java -@@ -127,7 +_,7 @@ +@@ -128,7 +_,7 @@ @Override public boolean removeWhenFarAway(double distanceToClosestPlayer) { @@ -9,7 +9,7 @@ } public static AttributeSupplier.Builder createAttributes() { -@@ -161,7 +_,7 @@ +@@ -162,7 +_,7 @@ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemInHand) && player.distanceToSqr(this) < 9.0) { this.usePlayerItem(player, hand, itemInHand); if (!this.level().isClientSide()) { @@ -17,4 +17,4 @@ + if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit - added event call and isCancelled check this.setTrusting(true); this.spawnTrustingParticles(true); - this.level().broadcastEntityEvent(this, (byte)41); + this.level().broadcastEntityEvent(this, EntityEvent.TRUSTING_SUCCEEDED); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch index d25762bb6594..3dd7c3341de6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch @@ -5,7 +5,7 @@ public void sit(boolean sitting) { + if (!new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), sitting).callEvent()) return; // Paper - Add EntityToggleSitEvent - this.setFlag(8, sitting); + this.setFlag(FLAG_SIT, sitting); } @@ -518,24 +_,28 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch index 274da16f43a2..bd95bd002b39 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/animal/Parrot.java +++ b/net/minecraft/world/entity/animal/Parrot.java -@@ -264,7 +_,7 @@ +@@ -265,7 +_,7 @@ } if (!this.level().isClientSide()) { - if (this.random.nextInt(10) == 0) { + if (this.random.nextInt(10) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit this.tame(player); - this.level().broadcastEntityEvent(this, (byte)7); + this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); } else { -@@ -285,7 +_,7 @@ +@@ -286,7 +_,7 @@ } } else { this.usePlayerItem(player, hand, itemInHand); @@ -18,7 +18,7 @@ if (player.isCreative() || !this.isInvulnerable()) { this.hurt(this.damageSources().playerAttack(player), Float.MAX_VALUE); } -@@ -380,8 +_,8 @@ +@@ -381,8 +_,8 @@ } @Override @@ -29,7 +29,7 @@ } @Override -@@ -396,8 +_,13 @@ +@@ -397,8 +_,13 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch index 0981dc189dcf..542f5ff8e889 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch @@ -8,12 +8,12 @@ if (this.getPuffState() == 0) { + if (new io.papermc.paper.event.entity.PufferFishStateChangeEvent((org.bukkit.entity.PufferFish) getBukkitEntity(), 1).callEvent()) { // Paper - Add PufferFishStateChangeEvent this.makeSound(SoundEvents.PUFFER_FISH_BLOW_UP); - this.setPuffState(1); + this.setPuffState(STATE_MID); + } else { increase = false; } // Paper - Add PufferFishStateChangeEvent } else if (this.inflateCounter > 40 && this.getPuffState() == 1) { + if (new io.papermc.paper.event.entity.PufferFishStateChangeEvent((org.bukkit.entity.PufferFish) getBukkitEntity(), 2).callEvent()) { // Paper - Add PufferFishStateChangeEvent this.makeSound(SoundEvents.PUFFER_FISH_BLOW_UP); - this.setPuffState(2); + this.setPuffState(STATE_FULL); + } else { increase = false; } // Paper - Add PufferFishStateChangeEvent } @@ -24,12 +24,12 @@ if (this.deflateTimer > 60 && this.getPuffState() == 2) { + if (new io.papermc.paper.event.entity.PufferFishStateChangeEvent((org.bukkit.entity.PufferFish) getBukkitEntity(), 1).callEvent()) { // Paper - Add PufferFishStateChangeEvent this.makeSound(SoundEvents.PUFFER_FISH_BLOW_OUT); - this.setPuffState(1); + this.setPuffState(STATE_MID); + } else { increase = false; } // Paper - Add PufferFishStateChangeEvent } else if (this.deflateTimer > 100 && this.getPuffState() == 1) { + if (new io.papermc.paper.event.entity.PufferFishStateChangeEvent((org.bukkit.entity.PufferFish) getBukkitEntity(), 0).callEvent()) { // Paper - Add PufferFishStateChangeEvent this.makeSound(SoundEvents.PUFFER_FISH_BLOW_OUT); - this.setPuffState(0); + this.setPuffState(STATE_SMALL); + } else { increase = false; } // Paper - Add PufferFishStateChangeEvent } @@ -46,8 +46,8 @@ this.playSound(SoundEvents.PUFFER_FISH_STING, 1.0F, 1.0F); } } -@@ -153,7 +_,7 @@ - serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.PUFFER_FISH_STING, 0.0F)); +@@ -154,7 +_,7 @@ + .send(new ClientboundGameEventPacket(ClientboundGameEventPacket.PUFFER_FISH_STING, ClientboundGameEventPacket.DEMO_PARAM_INTRO)); } - entity.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * puffState, 0), this); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch index 86db74c96bbe..4cbf9b68f433 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Rabbit.java +++ b/net/minecraft/world/entity/animal/Rabbit.java -@@ -96,7 +_,7 @@ +@@ -98,7 +_,7 @@ super(type, level); this.jumpControl = new Rabbit.RabbitJumpControl(this); this.moveControl = new Rabbit.RabbitMoveControl(this); @@ -9,15 +9,15 @@ } @Override -@@ -589,9 +_,11 @@ +@@ -591,9 +_,11 @@ if (this.canRaid && block instanceof CarrotBlock) { int ageValue = blockState.getValue(CarrotBlock.AGE); if (ageValue == 0) { + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockPos, blockState.getFluidState().createLegacyBlock())) return; // CraftBukkit // Paper - fix wrong block state - level.setBlock(blockPos, Blocks.AIR.defaultBlockState(), 2); + level.setBlock(blockPos, Blocks.AIR.defaultBlockState(), Block.UPDATE_CLIENTS); level.destroyBlock(blockPos, true, this.rabbit); } else { + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockPos, blockState.setValue(CarrotBlock.AGE, ageValue - 1))) return; // CraftBukkit // Paper - fix wrong block state - level.setBlock(blockPos, blockState.setValue(CarrotBlock.AGE, ageValue - 1), 2); + level.setBlock(blockPos, blockState.setValue(CarrotBlock.AGE, ageValue - 1), Block.UPDATE_CLIENTS); level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(this.rabbit)); - level.levelEvent(2001, blockPos, Block.getId(blockState)); + level.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, blockPos, Block.getId(blockState)); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Squid.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Squid.java.patch index 0ce7335a9959..e7d710d0d619 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Squid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Squid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Squid.java +++ b/net/minecraft/world/entity/animal/Squid.java -@@ -46,7 +_,7 @@ +@@ -47,7 +_,7 @@ public Squid(EntityType type, Level level) { super(type, level); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch index 13e0a3566da6..df21684efb8e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Turtle.java +++ b/net/minecraft/world/entity/animal/Turtle.java -@@ -260,7 +_,9 @@ +@@ -261,7 +_,9 @@ protected void ageBoundaryReached() { super.ageBoundaryReached(); if (!this.isBaby() && this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { @@ -10,7 +10,7 @@ } } -@@ -285,7 +_,7 @@ +@@ -286,7 +_,7 @@ @Override public void thunderHit(ServerLevel level, LightningBolt lightning) { @@ -19,7 +19,7 @@ } @Override -@@ -312,6 +_,10 @@ +@@ -313,6 +_,10 @@ if (loveCause == null && this.partner.getLoveCause() != null) { loveCause = this.partner.getLoveCause(); } @@ -30,7 +30,7 @@ if (loveCause != null) { loveCause.awardStat(Stats.ANIMALS_BRED); -@@ -325,7 +_,7 @@ +@@ -326,7 +_,7 @@ this.partner.resetLove(); RandomSource random = this.animal.getRandom(); if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { @@ -39,7 +39,7 @@ } } } -@@ -348,7 +_,7 @@ +@@ -349,7 +_,7 @@ && ( this.turtle.hasEgg() || this.turtle.getRandom().nextInt(reducedTickDelay(700)) == 0 && !this.turtle.homePos.closerToCenterThan(this.turtle.position(), 64.0) @@ -48,7 +48,7 @@ } @Override -@@ -456,14 +_,20 @@ +@@ -457,14 +_,20 @@ BlockPos blockPos = this.turtle.blockPosition(); if (!this.turtle.isInWater() && this.isReachedTarget()) { if (this.turtle.layEggCounter < 1) { @@ -65,7 +65,7 @@ BlockPos blockPos1 = this.blockPos.above(); - BlockState blockState = Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.random.nextInt(4) + 1); + BlockState blockState = Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, layEggEvent.getEggCount()); // Paper - level.setBlock(blockPos1, blockState, 3); + level.setBlock(blockPos1, blockState, Block.UPDATE_ALL); level.gameEvent(GameEvent.BLOCK_PLACE, blockPos1, GameEvent.Context.of(this.turtle, blockState)); + } // CraftBukkit this.turtle.setHasEgg(false); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch index e337415bd365..ef8378b2a1cf 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/allay/Allay.java +++ b/net/minecraft/world/entity/animal/allay/Allay.java -@@ -112,6 +_,7 @@ +@@ -113,6 +_,7 @@ private float dancingAnimationTicks; private float spinningAnimationTicks; private float spinningAnimationTicks0; @@ -8,7 +8,7 @@ public Allay(EntityType type, Level level) { super(type, level); -@@ -125,6 +_,12 @@ +@@ -126,6 +_,12 @@ ); } @@ -21,7 +21,7 @@ @Override protected Brain.Provider brainProvider() { return Brain.provider(MEMORY_TYPES, SENSOR_TYPES); -@@ -232,7 +_,7 @@ +@@ -233,7 +_,7 @@ public void aiStep() { super.aiStep(); if (!this.level().isClientSide() && this.isAlive() && this.tickCount % 10 == 0) { @@ -30,7 +30,7 @@ } if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) { -@@ -300,7 +_,12 @@ +@@ -301,7 +_,12 @@ ItemStack itemInHand = player.getItemInHand(hand); ItemStack itemInHand1 = this.getItemInHand(InteractionHand.MAIN_HAND); if (this.isDancing() && itemInHand.is(ItemTags.DUPLICATES_ALLAYS) && this.canDuplicate()) { @@ -41,10 +41,10 @@ + return InteractionResult.SUCCESS; + } + // CraftBukkit end - this.level().broadcastEntityEvent(this, (byte)18); + this.level().broadcastEntityEvent(this, EntityEvent.IN_LOVE_HEARTS); this.level().playSound(player, this, SoundEvents.AMETHYST_BLOCK_CHIME, SoundSource.NEUTRAL, 2.0F, 1.0F); this.removeInteractionItem(player, itemInHand); -@@ -399,6 +_,7 @@ +@@ -400,6 +_,7 @@ } private boolean shouldStopDancing() { @@ -52,7 +52,7 @@ return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), GameEvent.JUKEBOX_PLAY.value().notificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX); -@@ -451,7 +_,7 @@ +@@ -452,7 +_,7 @@ super.readAdditionalSaveData(input); this.readInventoryFromTag(input); this.vibrationData = input.read("listener", VibrationSystem.Data.CODEC).orElseGet(VibrationSystem.Data::new); @@ -61,7 +61,7 @@ } @Override -@@ -470,15 +_,17 @@ +@@ -471,15 +_,17 @@ this.entityData.set(DATA_CAN_DUPLICATE, duplicationCooldown == 0L); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch index 24fa5f2176eb..714cacd93e93 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -137,10 +_,12 @@ +@@ -138,10 +_,12 @@ ArmadilloAi.updateActivity(this); profilerFiller.pop(); if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) { @@ -13,7 +13,7 @@ this.scuteTime = this.pickNextScuteDropTime(); } -@@ -277,8 +_,11 @@ +@@ -278,8 +_,11 @@ } @Override @@ -27,7 +27,7 @@ if (!this.isNoAi() && !this.isDeadOrDying()) { if (damageSource.getEntity() instanceof LivingEntity) { this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L); -@@ -289,6 +_,7 @@ +@@ -290,6 +_,7 @@ this.rollOut(); } } @@ -35,7 +35,7 @@ } @Override -@@ -307,7 +_,9 @@ +@@ -308,7 +_,9 @@ return false; } else { if (this.level() instanceof ServerLevel serverLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch index 9718b9d15150..67806aa82794 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java +++ b/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java -@@ -56,8 +_,8 @@ +@@ -58,8 +_,8 @@ import net.minecraft.world.phys.Vec3; public class CopperGolem extends AbstractGolem implements ContainerUser, Shearable { @@ -11,7 +11,7 @@ private static final int WEATHERING_TICK_FROM = 504000; private static final int WEATHERING_TICK_TO = 552000; private static final int SPIN_ANIMATION_MIN_COOLDOWN = 200; -@@ -76,7 +_,7 @@ +@@ -78,7 +_,7 @@ private BlockPos openedChestPos; @Nullable private UUID lastLightningBoltUUID; @@ -20,7 +20,7 @@ private int idleAnimationStartTick = 0; private final AnimationState idleAnimationState = new AnimationState(); private final AnimationState interactionGetItemAnimationState = new AnimationState(); -@@ -220,7 +_,15 @@ +@@ -222,7 +_,15 @@ Level level = this.level(); if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { if (level instanceof ServerLevel serverLevel) { @@ -37,7 +37,7 @@ this.gameEvent(GameEvent.SHEAR, player); itemInHand.hurtAndBreak(1, player, hand); } -@@ -283,20 +_,27 @@ +@@ -285,20 +_,27 @@ private void turnToStatue(ServerLevel level) { BlockPos blockPos = this.blockPosition(); @@ -53,7 +53,7 @@ CopperGolemStatueBlock.POSE, CopperGolemStatueBlock.Pose.values()[this.random.nextInt(0, CopperGolemStatueBlock.Pose.values().length)] ) - .setValue(CopperGolemStatueBlock.FACING, Direction.fromYRot(this.getYRot())), -- 3 +- Block.UPDATE_ALL - ); + .setValue(CopperGolemStatueBlock.FACING, Direction.fromYRot(this.getYRot())); + // 3 @@ -71,7 +71,7 @@ this.playSound(SoundEvents.COPPER_GOLEM_BECOME_STATUE); if (this.isLeashed()) { if (level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { -@@ -427,12 +_,32 @@ +@@ -429,12 +_,32 @@ } @Override @@ -108,7 +108,7 @@ @Override public boolean readyForShearing() { -@@ -446,9 +_,13 @@ +@@ -448,9 +_,13 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch index a05540f3cdf0..25ba8b853664 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/goat/Goat.java +++ b/net/minecraft/world/entity/animal/goat/Goat.java -@@ -234,13 +_,22 @@ +@@ -235,13 +_,22 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.BUCKET) && !this.isBaby()) { @@ -25,7 +25,7 @@ this.playEatingSound(); } -@@ -346,8 +_,7 @@ +@@ -347,8 +_,7 @@ double d1 = Mth.randomBetween(this.random, 0.3F, 0.7F); double d2 = Mth.randomBetween(this.random, -0.2F, 0.2F); ItemEntity itemEntity = new ItemEntity(this.level(), vec3.x(), vec3.y(), vec3.z(), itemStack, d, d1, d2); @@ -35,7 +35,7 @@ } } -@@ -378,4 +_,15 @@ +@@ -379,4 +_,15 @@ ) { return level.getBlockState(pos.below()).is(BlockTags.GOATS_SPAWNABLE_ON) && isBrightEnoughToSpawn(level, pos); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch index 4e9f79e182eb..59ace8c45609 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java -@@ -123,6 +_,7 @@ +@@ -124,6 +_,7 @@ protected int gallopSoundCounter; @Nullable public EntityReference owner; @@ -8,7 +8,7 @@ protected AbstractHorse(EntityType type, Level level) { super(type, level); -@@ -252,7 +_,7 @@ +@@ -253,7 +_,7 @@ } @Override @@ -17,7 +17,7 @@ return !this.isVehicle(); } -@@ -303,7 +_,7 @@ +@@ -304,7 +_,7 @@ public void createInventory() { SimpleContainer simpleContainer = this.inventory; @@ -26,7 +26,7 @@ if (simpleContainer != null) { int min = Math.min(simpleContainer.getContainerSize(), this.inventory.getContainerSize()); -@@ -397,7 +_,7 @@ +@@ -398,7 +_,7 @@ } public int getMaxTemper() { @@ -35,7 +35,7 @@ } @Override -@@ -460,7 +_,7 @@ +@@ -461,7 +_,7 @@ i1 = 5; if (!this.level().isClientSide() && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { flag = true; @@ -44,7 +44,7 @@ } } else if (stack.is(Items.GOLDEN_APPLE) || stack.is(Items.ENCHANTED_GOLDEN_APPLE)) { f = 10.0F; -@@ -468,12 +_,12 @@ +@@ -469,12 +_,12 @@ i1 = 10; if (!this.level().isClientSide() && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { flag = true; @@ -59,7 +59,7 @@ flag = true; } -@@ -544,7 +_,7 @@ +@@ -545,7 +_,7 @@ super.aiStep(); if (this.level() instanceof ServerLevel serverLevel && this.isAlive()) { if (this.random.nextInt(900) == 0 && this.deathTime == 0) { @@ -68,7 +68,7 @@ } if (this.canEatGrass()) { -@@ -646,6 +_,16 @@ +@@ -647,6 +_,16 @@ } } @@ -85,7 +85,7 @@ @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { if (this.isVehicle() || this.isBaby()) { -@@ -798,6 +_,7 @@ +@@ -799,6 +_,7 @@ output.putInt("Temper", this.getTemper()); output.putBoolean("Tame", this.isTamed()); EntityReference.store(this.owner, output, "Owner"); @@ -93,7 +93,7 @@ } @Override -@@ -808,6 +_,7 @@ +@@ -809,6 +_,7 @@ this.setTemper(input.getIntOr("Temper", 0)); this.setTamed(input.getBooleanOr("Tame", false)); this.owner = EntityReference.readWithOldOwnerConversion(input, "Owner", this.level()); @@ -101,7 +101,7 @@ } @Override -@@ -896,6 +_,17 @@ +@@ -897,6 +_,17 @@ @Override public void handleStartJump(int jumpPower) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch index d344dbd512d9..27e74cafe633 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java +++ b/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java -@@ -387,7 +_,7 @@ +@@ -388,7 +_,7 @@ if (this.isFood(itemInHand) && this.getHealth() < this.getMaxHealth()) { this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); @@ -9,7 +9,7 @@ return InteractionResult.SUCCESS; } -@@ -407,7 +_,7 @@ +@@ -408,7 +_,7 @@ } private void tryToTame(Player player) { @@ -17,4 +17,4 @@ + if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit - added event call this.tame(player); this.navigation.stop(); - this.level().broadcastEntityEvent(this, (byte)7); + this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch index c565a800fc07..b9fb8d4ec5e7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/sheep/Sheep.java +++ b/net/minecraft/world/entity/animal/sheep/Sheep.java -@@ -139,7 +_,19 @@ +@@ -140,7 +_,19 @@ ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.SHEARS)) { if (this.level() instanceof ServerLevel serverLevel && this.readyForShearing()) { @@ -21,7 +21,7 @@ this.gameEvent(GameEvent.SHEAR, player); itemInHand.hurtAndBreak(1, player, hand.asEquipmentSlot()); return InteractionResult.SUCCESS_SERVER; -@@ -153,14 +_,28 @@ +@@ -154,14 +_,28 @@ @Override public void shear(ServerLevel level, SoundSource source, ItemStack shears) { @@ -57,7 +57,7 @@ if (itemEntity != null) { itemEntity.setDeltaMovement( itemEntity.getDeltaMovement() -@@ -280,6 +_,7 @@ +@@ -281,6 +_,7 @@ @Override public void ate() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch index 98be544db614..915d16ecb441 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java +++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java -@@ -277,6 +_,13 @@ +@@ -278,6 +_,13 @@ this.dropFromGiftLootTable(serverLevel, BuiltInLootTables.SNIFFER_DIGGING, (serverLevel1, itemStack) -> { ItemEntity itemEntity = new ItemEntity(this.level(), headBlock.getX(), headBlock.getY(), headBlock.getZ(), itemStack); itemEntity.setDefaultPickUpDelay(); @@ -14,7 +14,7 @@ serverLevel1.addFreshEntity(itemEntity); }); this.playSound(SoundEvents.SNIFFER_DROP_SEED, 1.0F, 1.0F); -@@ -335,12 +_,17 @@ +@@ -336,12 +_,17 @@ @Override public void spawnChildFromBreeding(ServerLevel level, Animal partner) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch index d501b4837dbd..f93ff3c4f8ab 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/wolf/Wolf.java +++ b/net/minecraft/world/entity/animal/wolf/Wolf.java -@@ -399,16 +_,18 @@ +@@ -400,16 +_,18 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { @@ -22,7 +22,7 @@ ItemStack bodyArmorItem = this.getBodyArmorItem(); int damageValue = bodyArmorItem.getDamageValue(); int maxDamage = bodyArmorItem.getMaxDamage(); -@@ -428,6 +_,7 @@ +@@ -429,6 +_,7 @@ ); } } @@ -30,7 +30,7 @@ } private boolean canArmorAbsorb(DamageSource damageSource) { -@@ -438,7 +_,7 @@ +@@ -439,7 +_,7 @@ protected void applyTamingSideEffects() { if (this.isTame()) { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(40.0); @@ -39,7 +39,7 @@ } else { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(8.0); } -@@ -463,7 +_,7 @@ +@@ -464,7 +_,7 @@ this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); float f = foodProperties != null ? foodProperties.nutrition() : 1.0F; @@ -48,7 +48,7 @@ return InteractionResult.SUCCESS; } -@@ -492,7 +_,7 @@ +@@ -493,7 +_,7 @@ this.setOrderedToSit(!this.isOrderedToSit()); this.jumping = false; this.navigation.stop(); @@ -57,7 +57,7 @@ return InteractionResult.SUCCESS.withoutItem(); } -@@ -501,6 +_,13 @@ +@@ -502,6 +_,13 @@ DyeColor dyeColor = dyeItem.getDyeColor(); if (dyeColor != this.getCollarColor()) { @@ -71,7 +71,7 @@ this.setCollarColor(dyeColor); itemInHand.consume(1, player); return InteractionResult.SUCCESS; -@@ -515,7 +_,7 @@ +@@ -516,7 +_,7 @@ } private void tryToTame(Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch index cd207c8493d5..f2476c893834 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -@@ -88,6 +_,10 @@ +@@ -89,6 +_,10 @@ private final Node[] nodes = new Node[24]; private final int[] nodeAdjacency = new int[24]; private final BinaryHeap openSet = new BinaryHeap(); @@ -11,7 +11,7 @@ public EnderDragon(EntityType type, Level level) { super(EntityType.ENDER_DRAGON, level); -@@ -103,6 +_,7 @@ +@@ -104,6 +_,7 @@ this.setHealth(this.getMaxHealth()); this.noPhysics = true; this.phaseManager = new EnderDragonPhaseManager(this); @@ -19,7 +19,7 @@ } public void setDragonFight(EndDragonFight dragonFight) { -@@ -121,6 +_,19 @@ +@@ -122,6 +_,19 @@ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 200.0).add(Attributes.CAMERA_DISTANCE, 16.0); } @@ -39,7 +39,7 @@ @Override public boolean isFlapping() { float cos = Mth.cos(this.flapTime * (float) (Math.PI * 2)); -@@ -212,7 +_,7 @@ +@@ -213,7 +_,7 @@ } Vec3 flyTargetLocation = currentPhase.getFlyTargetLocation(); @@ -48,7 +48,7 @@ double d = flyTargetLocation.x - this.getX(); double d1 = flyTargetLocation.y - this.getY(); double d2 = flyTargetLocation.z - this.getZ(); -@@ -367,7 +_,12 @@ +@@ -368,7 +_,12 @@ if (this.nearestCrystal.isRemoved()) { this.nearestCrystal = null; } else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -62,7 +62,7 @@ } } -@@ -397,7 +_,7 @@ +@@ -398,7 +_,7 @@ double d2 = entity.getX() - d; double d3 = entity.getZ() - d1; double max = Math.max(d2 * d2 + d3 * d3, 0.1); @@ -71,7 +71,7 @@ if (!this.phaseManager.getCurrentPhase().isSitting() && livingEntity.getLastHurtByMobTimestamp() < entity.tickCount - 2) { DamageSource damageSource = this.damageSources().mobAttack(this); entity.hurtServer(level, damageSource, 5.0F); -@@ -430,6 +_,7 @@ +@@ -431,6 +_,7 @@ int floor5 = Mth.floor(box.maxZ); boolean flag = false; boolean flag1 = false; @@ -79,7 +79,7 @@ for (int i = floor; i <= floor3; i++) { for (int i1 = floor1; i1 <= floor4; i1++) { -@@ -438,7 +_,11 @@ +@@ -439,7 +_,11 @@ BlockState blockState = level.getBlockState(blockPos); if (!blockState.isAir() && !blockState.is(BlockTags.DRAGON_TRANSPARENT)) { if (level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !blockState.is(BlockTags.DRAGON_IMMUNE)) { @@ -92,7 +92,7 @@ } else { flag = true; } -@@ -447,6 +_,58 @@ +@@ -448,6 +_,58 @@ } } @@ -151,7 +151,7 @@ if (flag1) { BlockPos blockPos1 = new BlockPos( floor + this.random.nextInt(floor3 - floor + 1), -@@ -504,7 +_,15 @@ +@@ -505,7 +_,15 @@ @Override public void kill(ServerLevel level) { @@ -168,7 +168,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); if (this.dragonFight != null) { this.dragonFight.updateDragon(this); -@@ -526,18 +_,41 @@ +@@ -527,18 +_,41 @@ this.level().addParticle(ParticleTypes.EXPLOSION_EMITTER, this.getX() + f, this.getY() + 2.0 + f1, this.getZ() + f2, 0.0, 0.0, 0.0); } @@ -190,7 +190,7 @@ } if (this.dragonDeathTime == 1 && !this.isSilent()) { -- serverLevel.globalLevelEvent(1028, this.blockPosition(), 0); +- serverLevel.globalLevelEvent(LevelEvent.SOUND_DRAGON_DEATH, this.blockPosition(), 0); + // CraftBukkit start - Use relative location for far away sounds + // serverLevel.globalLevelEvent(1028, this.blockPosition(), 0); + int viewDistance = serverLevel.getCraftServer().getViewDistance() * 16; @@ -213,7 +213,7 @@ } } -@@ -550,15 +_,15 @@ +@@ -551,15 +_,15 @@ } if (this.dragonDeathTime == 200 && this.level() instanceof ServerLevel serverLevel1) { @@ -232,7 +232,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); } } -@@ -740,6 +_,7 @@ +@@ -741,6 +_,7 @@ super.addAdditionalSaveData(output); output.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId()); output.putInt("DragonDeathTime", this.dragonDeathTime); @@ -240,7 +240,7 @@ } @Override -@@ -747,6 +_,7 @@ +@@ -748,6 +_,7 @@ super.readAdditionalSaveData(input); input.getInt("DragonPhase").ifPresent(integer -> this.phaseManager.setPhase(EnderDragonPhase.getById(integer))); this.dragonDeathTime = input.getIntOr("DragonDeathTime", 0); @@ -248,7 +248,7 @@ } @Override -@@ -787,7 +_,7 @@ +@@ -788,7 +_,7 @@ EnderDragonPhase phase = currentPhase.getPhase(); Vec3 viewVector; if (phase == EnderDragonPhase.LANDING || phase == EnderDragonPhase.TAKEOFF) { @@ -257,7 +257,7 @@ float max = Math.max((float)Math.sqrt(heightmapPos.distToCenterSqr(this.position())) / 4.0F, 1.0F); float f = 6.0F / max; float xRot = this.getXRot(); -@@ -875,4 +_,19 @@ +@@ -876,4 +_,19 @@ protected float sanitizeScale(float scale) { return 1.0F; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch index 6a16e9f21ed5..afcef46ed1de 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java -@@ -72,13 +_,16 @@ +@@ -73,13 +_,16 @@ double d6 = this.attackTarget.getY(0.5) - d3; double d7 = this.attackTarget.getZ() - d4; Vec3 vec32 = new Vec3(d5, d6, d7); - if (!this.dragon.isSilent()) { + if (false && !this.dragon.isSilent()) { // Paper - EnderDragon Events; Fire after shoot fireball event - level.levelEvent(null, 1017, this.dragon.blockPosition(), 0); + level.levelEvent(null, LevelEvent.SOUND_DRAGON_FIREBALL, this.dragon.blockPosition(), 0); } DragonFireball dragonFireball = new DragonFireball(level, this.dragon, vec32.normalize()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch index a9bbe42fa1fb..980373b3f609 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java -@@ -71,6 +_,7 @@ +@@ -72,6 +_,7 @@ private final int[] nextHeadUpdate = new int[2]; private final int[] idleHeadUpdates = new int[2]; private int destroyBlocksTick; @@ -8,7 +8,7 @@ public final ServerBossEvent bossEvent = (ServerBossEvent)new ServerBossEvent( this.getDisplayName(), BossEvent.BossBarColor.PURPLE, BossEvent.BossBarOverlay.PROGRESS ) -@@ -262,15 +_,40 @@ +@@ -263,15 +_,40 @@ int i = this.getInvulnerableTicks() - 1; this.bossEvent.setProgress(1.0F - i / 220.0F); if (i <= 0) { @@ -22,7 +22,7 @@ + } + // CraftBukkit end if (!this.isSilent()) { -- level.globalLevelEvent(1023, this.blockPosition(), 0); +- level.globalLevelEvent(LevelEvent.SOUND_WITHER_BOSS_SPAWN, this.blockPosition(), 0); + // CraftBukkit start - Use relative location for far away sounds + // level.globalLevelEvent(1023, this.blockPosition(), 0); + int viewDistance = level.getCraftServer().getViewDistance() * 16; @@ -52,7 +52,7 @@ } } else { super.customServerAiStep(level); -@@ -307,6 +_,7 @@ +@@ -308,6 +_,7 @@ ); if (!nearbyEntities.isEmpty()) { LivingEntity livingEntity1 = nearbyEntities.get(this.random.nextInt(nearbyEntities.size())); @@ -60,7 +60,7 @@ this.setAlternativeTarget(ix, livingEntity1.getId()); } } -@@ -336,6 +_,11 @@ +@@ -337,6 +_,11 @@ )) { BlockState blockState = level.getBlockState(blockPos); if (canDestroy(blockState)) { @@ -72,7 +72,7 @@ flag = level.destroyBlock(blockPos, true, this) || flag; } } -@@ -347,7 +_,7 @@ +@@ -348,7 +_,7 @@ } if (this.tickCount % 20 == 0) { @@ -81,7 +81,7 @@ } this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth()); -@@ -485,16 +_,16 @@ +@@ -486,16 +_,16 @@ @Override protected void dropCustomDeathLoot(ServerLevel level, DamageSource damageSource, boolean recentlyHit) { super.dropCustomDeathLoot(level, damageSource, recentlyHit); @@ -102,7 +102,7 @@ } else { this.noActionTime = 0; } -@@ -549,12 +_,18 @@ +@@ -550,12 +_,18 @@ @Override public boolean canUsePortal(boolean allowPassengers) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch index 8b358df00eef..8c0e896aba23 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -85,9 +_,16 @@ +@@ -86,9 +_,16 @@ private boolean invisible = false; public long lastHit; public int disabledSlots = 0; @@ -17,7 +17,7 @@ } public ArmorStand(Level level, double x, double y, double z) { -@@ -99,6 +_,13 @@ +@@ -100,6 +_,13 @@ return createLivingAttributes().add(Attributes.STEP_HEIGHT, 0.0); } @@ -31,7 +31,7 @@ @Override public void refreshDimensions() { double x = this.getX(); -@@ -134,6 +_,14 @@ +@@ -135,6 +_,14 @@ return slot != EquipmentSlot.BODY && slot != EquipmentSlot.SADDLE && !this.isDisabled(slot); } @@ -46,7 +46,7 @@ @Override protected void addAdditionalSaveData(ValueOutput output) { super.addAdditionalSaveData(output); -@@ -147,6 +_,7 @@ +@@ -148,6 +_,7 @@ } output.store("Pose", ArmorStand.ArmorStandPose.CODEC, this.getArmorStandPose()); @@ -54,7 +54,7 @@ } @Override -@@ -160,10 +_,16 @@ +@@ -161,10 +_,16 @@ this.setMarker(input.getBooleanOr("Marker", false)); this.noPhysics = !this.hasPhysics(); input.read("Pose", ArmorStand.ArmorStandPose.CODEC).ifPresent(this::setArmorStandPose); @@ -72,7 +72,7 @@ return false; } -@@ -173,6 +_,7 @@ +@@ -174,6 +_,7 @@ @Override protected void pushEntities() { @@ -80,7 +80,7 @@ for (Entity entity : this.level().getEntities(this, this.getBoundingBox(), RIDABLE_MINECARTS)) { if (this.distanceToSqr(entity) <= 0.2) { entity.push(this); -@@ -245,7 +_,25 @@ +@@ -246,7 +_,25 @@ return false; } else if (itemBySlot.isEmpty() && (this.disabledSlots & 1 << slot.getFilterBit(16)) != 0) { return false; @@ -107,7 +107,7 @@ this.setItemSlot(slot, stack.copyWithCount(1)); return true; } else if (stack.isEmpty() || stack.getCount() <= 1) { -@@ -258,6 +_,7 @@ +@@ -259,6 +_,7 @@ this.setItemSlot(slot, stack.split(1)); return true; } @@ -115,7 +115,7 @@ } @Override -@@ -267,15 +_,32 @@ +@@ -268,15 +_,32 @@ } else if (!level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && damageSource.getEntity() instanceof Mob) { return false; } else if (damageSource.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { @@ -152,7 +152,7 @@ if (this.isOnFire()) { this.causeDamage(level, damageSource, 0.15F); } else { -@@ -284,9 +_,19 @@ +@@ -285,9 +_,19 @@ return false; } else if (damageSource.is(DamageTypeTags.BURNS_ARMOR_STANDS) && this.getHealth() > 0.5F) { @@ -172,7 +172,7 @@ boolean isCanBreakArmorStand = damageSource.is(DamageTypeTags.CAN_BREAK_ARMOR_STAND); boolean isAlwaysKillsArmorStands = damageSource.is(DamageTypeTags.ALWAYS_KILLS_ARMOR_STANDS); if (!isCanBreakArmorStand && !isAlwaysKillsArmorStands) { -@@ -296,7 +_,7 @@ +@@ -297,7 +_,7 @@ } else if (damageSource.isCreativePlayer()) { this.playBrokenSound(); this.showBreakingParticles(); @@ -181,7 +181,7 @@ return true; } else { long gameTime = level.getGameTime(); -@@ -305,9 +_,9 @@ +@@ -306,9 +_,9 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE, damageSource.getEntity()); this.lastHit = gameTime; } else { @@ -193,7 +193,7 @@ } return true; -@@ -359,31 +_,42 @@ +@@ -360,31 +_,42 @@ float health = this.getHealth(); health -= damageAmount; if (health <= 0.5F) { @@ -247,7 +247,7 @@ } private void playBrokenSound() { -@@ -431,9 +_,40 @@ +@@ -432,9 +_,40 @@ return this.isSmall(); } @@ -289,7 +289,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); } -@@ -684,4 +_,13 @@ +@@ -685,4 +_,13 @@ .apply(instance, ArmorStand.ArmorStandPose::new) ); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch index defb35a15067..b6351e4095a2 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -13,7 +13,7 @@ state.hasProperty(BlockStateProperties.WATERLOGGED) ? state.setValue(BlockStateProperties.WATERLOGGED, false) : state ); + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(fallingBlockEntity, pos, state.getFluidState().createLegacyBlock())) return fallingBlockEntity; // CraftBukkit - level.setBlock(pos, state.getFluidState().createLegacyBlock(), 3); + level.setBlock(pos, state.getFluidState().createLegacyBlock(), Block.UPDATE_ALL); level.addFreshEntity(fallingBlockEntity); return fallingBlockEntity; @@ -147,13 +_,22 @@ @@ -65,7 +65,7 @@ + return; + } + // CraftBukkit end - if (this.level().setBlock(blockPos, this.blockState, 3)) { + if (this.level().setBlock(blockPos, this.blockState, Block.UPDATE_ALL)) { serverLevel.getChunkSource() .chunkMap .sendToTrackingPlayers(this, new ClientboundBlockUpdatePacket(blockPos, this.level().getBlockState(blockPos))); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch index c3d2fb4778d2..b98d049e03a7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch @@ -8,4 +8,4 @@ + List list = MobEffectUtil.addEffectToPlayersAround(level, this, this.position(), 50.0, mobEffectInstance, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK, (player) -> new io.papermc.paper.event.entity.ElderGuardianAppearanceEvent((org.bukkit.entity.ElderGuardian) this.getBukkitEntity(), player.getBukkitEntity()).callEvent()); // CraftBukkit // Paper - Add ElderGuardianAppearanceEvent list.forEach( serverPlayer -> serverPlayer.connection - .send(new ClientboundGameEventPacket(ClientboundGameEventPacket.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F)) + .send( diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch index 7e8fb14383ad..4b176b45835a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -114,7 +114,7 @@ carriedBlock = Block.updateFromNeighbourShapes(carriedBlock, this.enderman.level(), blockPos); if (this.canPlaceBlock(level, blockPos, carriedBlock, blockState, blockState1, blockPos1)) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockPos, carriedBlock)) { // CraftBukkit - Place event - level.setBlock(blockPos, carriedBlock, 3); + level.setBlock(blockPos, carriedBlock, Block.UPDATE_ALL); level.gameEvent(GameEvent.BLOCK_PLACE, blockPos, GameEvent.Context.of(this.enderman, carriedBlock)); this.enderman.setCarriedBlock(null); + } // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch index 808b5477ab0d..39e04cd088fe 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Ghast.java +++ b/net/minecraft/world/entity/monster/Ghast.java -@@ -73,6 +_,12 @@ +@@ -74,6 +_,12 @@ return this.explosionPower; } @@ -13,7 +13,7 @@ private static boolean isReflectedFireball(DamageSource damageSource) { return damageSource.getDirectEntity() instanceof LargeFireball && damageSource.getEntity() instanceof Player; } -@@ -367,6 +_,7 @@ +@@ -368,6 +_,7 @@ } LargeFireball largeFireball = new LargeFireball(level, this.ghast, vec3.normalize(), this.ghast.getExplosionPower()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Guardian.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Guardian.java.patch index b630ae4a7296..b7602f075136 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Guardian.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Guardian.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Guardian.java +++ b/net/minecraft/world/entity/monster/Guardian.java -@@ -59,6 +_,7 @@ +@@ -60,6 +_,7 @@ private boolean clientSideTouchedGround; @Nullable public RandomStrollGoal randomStrollGoal; @@ -8,7 +8,7 @@ public Guardian(EntityType type, Level level) { super(type, level); -@@ -73,7 +_,7 @@ +@@ -74,7 +_,7 @@ protected void registerGoals() { MoveTowardsRestrictionGoal moveTowardsRestrictionGoal = new MoveTowardsRestrictionGoal(this, 1.0); this.randomStrollGoal = new RandomStrollGoal(this, 1.0, 80); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch index ed6795582ae6..fdf5692e3319 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Husk.java +++ b/net/minecraft/world/entity/monster/Husk.java -@@ -56,7 +_,7 @@ +@@ -57,7 +_,7 @@ boolean flag = super.doHurtTarget(level, target); if (flag && this.getMainHandItem().isEmpty() && target instanceof LivingEntity) { float effectiveDifficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch index 15cfa2deb98e..2c3ddeef49ae 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Phantom.java +++ b/net/minecraft/world/entity/monster/Phantom.java -@@ -49,6 +_,11 @@ +@@ -50,6 +_,11 @@ @Nullable public BlockPos anchorPoint; Phantom.AttackPhase attackPhase = Phantom.AttackPhase.CIRCLE; @@ -12,7 +12,7 @@ public Phantom(EntityType type, Level level) { super(type, level); -@@ -136,6 +_,13 @@ +@@ -137,6 +_,13 @@ } } @@ -26,7 +26,7 @@ @Override protected void checkFallDamage(double y, boolean onGround, BlockState state, BlockPos pos) { } -@@ -164,6 +_,10 @@ +@@ -165,6 +_,10 @@ super.readAdditionalSaveData(input); this.anchorPoint = input.read("anchor_pos", BlockPos.CODEC).orElse(null); this.setPhantomSize(input.getIntOr("size", 0)); @@ -37,7 +37,7 @@ } @Override -@@ -171,6 +_,10 @@ +@@ -172,6 +_,10 @@ super.addAdditionalSaveData(output); output.storeNullable("anchor_pos", BlockPos.CODEC, this.anchorPoint); output.putInt("size", this.getPhantomSize()); @@ -48,7 +48,7 @@ } @Override -@@ -244,8 +_,10 @@ +@@ -245,8 +_,10 @@ for (Player player : nearbyPlayers) { if (Phantom.this.canAttack(serverLevel, player, TargetingConditions.DEFAULT)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch index 2e53eba6add9..071ea14cdf53 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Ravager.java +++ b/net/minecraft/world/entity/monster/Ravager.java -@@ -155,12 +_,19 @@ +@@ -156,12 +_,19 @@ BlockState blockState = serverLevel.getBlockState(blockPos); Block block = blockState.getBlock(); if (block instanceof LeavesBlock) { @@ -20,7 +20,7 @@ } } -@@ -252,7 +_,7 @@ +@@ -253,7 +_,7 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double max = Math.max(d * d + d1 * d1, 0.001); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch index a8c9b55110f4..d3a8325d0377 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -18,7 +18,7 @@ + return; + } + // CraftBukkit end - levelAccessor.setBlock(blockPos, InfestedBlock.infestedStateByHost(blockState), 3); + levelAccessor.setBlock(blockPos, InfestedBlock.infestedStateByHost(blockState), Block.UPDATE_ALL); this.mob.spawnAnim(); - this.mob.discard(); + this.mob.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.ENTER_BLOCK); // CraftBukkit - add Bukkit remove cause diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Skeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Skeleton.java.patch index 85cd2adbbb17..1176065314ba 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Skeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Skeleton.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/entity/monster/Skeleton.java +++ b/net/minecraft/world/entity/monster/Skeleton.java -@@ -92,11 +_,17 @@ +@@ -93,11 +_,17 @@ } protected void doFreezeConversion() { - this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), mob -> { + final Stray stray = this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), mob -> { // Paper - Fix issues with mob conversion; reset conversion time to prevent event spam if (!this.isSilent()) { - this.level().levelEvent(null, 1048, this.blockPosition(), 0); + this.level().levelEvent(null, LevelEvent.SOUND_SKELETON_TO_STRAY, this.blockPosition(), 0); } - }); + // Paper start - add spawn and transform reasons diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch index ce92fe45cbab..a0ab0a12072c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Witch.java +++ b/net/minecraft/world/entity/monster/Witch.java -@@ -122,8 +_,14 @@ +@@ -123,8 +_,14 @@ ItemStack mainHandItem = this.getMainHandItem(); this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); PotionContents potionContents = mainHandItem.get(DataComponents.POTION_CONTENTS); @@ -16,7 +16,7 @@ } this.gameEvent(GameEvent.DRINK); -@@ -147,26 +_,7 @@ +@@ -148,26 +_,7 @@ } if (holder != null) { @@ -44,7 +44,7 @@ } } -@@ -178,6 +_,23 @@ +@@ -179,6 +_,23 @@ super.aiStep(); } @@ -68,7 +68,7 @@ @Override public SoundEvent getCelebrateSound() { return SoundEvents.WITCH_CELEBRATE; -@@ -244,6 +_,13 @@ +@@ -245,6 +_,13 @@ if (this.level() instanceof ServerLevel serverLevel) { ItemStack itemStack = PotionContents.createItemStack(Items.SPLASH_POTION, holder); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch index 74eb73b512bd..63939b3ebef4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Zombie.java +++ b/net/minecraft/world/entity/monster/Zombie.java -@@ -65,9 +_,7 @@ +@@ -66,9 +_,7 @@ public class Zombie extends Monster { private static final ResourceLocation SPEED_MODIFIER_BABY_ID = ResourceLocation.withDefaultNamespace("baby"); @@ -11,7 +11,7 @@ private static final ResourceLocation REINFORCEMENT_CALLER_CHARGE_ID = ResourceLocation.withDefaultNamespace("reinforcement_caller_charge"); private static final AttributeModifier ZOMBIE_REINFORCEMENT_CALLEE_CHARGE = new AttributeModifier( ResourceLocation.withDefaultNamespace("reinforcement_callee_charge"), -0.05F, AttributeModifier.Operation.ADD_VALUE -@@ -88,13 +_,15 @@ +@@ -89,13 +_,15 @@ private static final boolean DEFAULT_BABY = false; private static final boolean DEFAULT_CAN_BREAK_DOORS = false; private static final int DEFAULT_IN_WATER_TIME = 0; @@ -28,7 +28,7 @@ } public Zombie(Level level) { -@@ -103,7 +_,7 @@ +@@ -104,7 +_,7 @@ @Override protected void registerGoals() { @@ -37,7 +37,7 @@ this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F)); this.goalSelector.addGoal(8, new RandomLookAroundGoal(this)); this.addBehaviourGoals(); -@@ -116,7 +_,7 @@ +@@ -117,7 +_,7 @@ this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); @@ -46,7 +46,7 @@ this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true)); this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR)); } -@@ -170,11 +_,16 @@ +@@ -171,11 +_,16 @@ @Override protected int getBaseExperienceReward(ServerLevel level) { @@ -64,7 +64,7 @@ } @Override -@@ -182,9 +_,9 @@ +@@ -183,9 +_,9 @@ this.getEntityData().set(DATA_BABY_ID, childZombie); if (this.level() != null && !this.level().isClientSide()) { AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED); @@ -76,7 +76,7 @@ } } } -@@ -225,6 +_,13 @@ +@@ -226,6 +_,13 @@ super.tick(); } @@ -90,7 +90,7 @@ public void startUnderWaterConversion(int conversionTime) { this.conversionTime = conversionTime; this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, true); -@@ -238,31 +_,50 @@ +@@ -239,31 +_,50 @@ } protected void convertToZombieType(ServerLevel level, EntityType entityType) { @@ -124,7 +124,7 @@ mob.setTradeOffers(villager.getOffers().copy()); mob.setVillagerXp(villager.getVillagerXp()); - if (!this.isSilent()) { -- level.levelEvent(null, 1026, this.blockPosition(), 0); +- level.levelEvent(null, LevelEvent.SOUND_ZOMBIE_INFECTED, this.blockPosition(), 0); + // CraftBukkit start + if (!silent) { + level.levelEvent(null, 1026, blockPosition, 0); @@ -150,7 +150,7 @@ @Override public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { -@@ -295,13 +_,13 @@ +@@ -296,13 +_,13 @@ if (SpawnPlacements.isSpawnPositionOk(type, level, blockPos) && SpawnPlacements.checkSpawnRules(type, level, EntitySpawnReason.REINFORCEMENT, blockPos, level.random)) { zombie.setPos(i1, i2, i3); @@ -167,7 +167,7 @@ AttributeInstance attribute = this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE); AttributeModifier modifier = attribute.getModifier(REINFORCEMENT_CALLER_CHARGE_ID); double d = modifier != null ? modifier.amount() : 0.0; -@@ -326,7 +_,12 @@ +@@ -327,7 +_,12 @@ if (flag) { float effectiveDifficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < effectiveDifficulty * 0.3F) { @@ -181,7 +181,7 @@ } } -@@ -388,6 +_,7 @@ +@@ -389,6 +_,7 @@ output.putBoolean("CanBreakDoors", this.canBreakDoors()); output.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1); output.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1); @@ -189,7 +189,7 @@ } @Override -@@ -402,13 +_,15 @@ +@@ -403,13 +_,15 @@ } else { this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, false); } @@ -207,7 +207,7 @@ return flag; } -@@ -444,7 +_,7 @@ +@@ -445,7 +_,7 @@ spawnGroupData = super.finalizeSpawn(level, difficulty, spawnReason, spawnGroupData); float specialMultiplier = difficulty.getSpecialMultiplier(); if (spawnReason != EntitySpawnReason.CONVERSION) { @@ -216,7 +216,7 @@ } if (spawnGroupData == null) { -@@ -471,7 +_,7 @@ +@@ -472,7 +_,7 @@ chicken1.finalizeSpawn(level, difficulty, EntitySpawnReason.JOCKEY, null); chicken1.setChickenJockey(true); this.startRiding(chicken1, false, false); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch index ab52640b228c..e1e2648a7f26 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/net/minecraft/world/entity/monster/ZombieVillager.java -@@ -168,12 +_,20 @@ +@@ -170,12 +_,20 @@ } public void startConverting(@Nullable UUID conversionStarter, int villagerConversionTime) { @@ -15,7 +15,7 @@ this.getEntityData().set(DATA_CONVERTING_ID, true); - this.removeEffect(MobEffects.WEAKNESS); - this.addEffect(new MobEffectInstance(MobEffects.STRENGTH, villagerConversionTime, Math.min(this.level().getDifficulty().getId() - 1, 0))); -- this.level().broadcastEntityEvent(this, (byte)16); +- this.level().broadcastEntityEvent(this, EntityEvent.ZOMBIE_CONVERTING); + // CraftBukkit start + this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); + this.addEffect(new MobEffectInstance(MobEffects.STRENGTH, villagerConversionTime, Math.min(this.level().getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); @@ -24,7 +24,7 @@ } @Override -@@ -198,7 +_,7 @@ +@@ -200,7 +_,7 @@ } private void finishConversion(ServerLevel level) { @@ -33,7 +33,7 @@ EntityType.VILLAGER, ConversionParams.single(this, false, false), mob -> { -@@ -222,19 +_,24 @@ +@@ -224,19 +_,24 @@ mob.finalizeSpawn(level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CONVERSION, null); mob.refreshBrain(level); if (this.conversionStarter != null) { @@ -48,7 +48,7 @@ - mob.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)); + mob.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit if (!this.isSilent()) { - level.levelEvent(null, 1027, this.blockPosition(), 0); + level.levelEvent(null, LevelEvent.SOUND_ZOMBIE_CONVERTED, this.blockPosition(), 0); } - } + // CraftBukkit start diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch index 05245de11466..530599b19567 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/creaking/Creaking.java +++ b/net/minecraft/world/entity/monster/creaking/Creaking.java -@@ -191,9 +_,9 @@ +@@ -192,9 +_,9 @@ } @Override @@ -12,7 +12,7 @@ } } -@@ -318,7 +_,7 @@ +@@ -319,7 +_,7 @@ } this.makeSound(this.getDeathSound()); @@ -21,7 +21,7 @@ } public void creakingDeathEffects(DamageSource damageSource) { -@@ -448,9 +_,9 @@ +@@ -449,9 +_,9 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch index 3d2981564dac..527914ad088b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -266,7 +_,12 @@ +@@ -267,7 +_,12 @@ } private void finishConversion() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch index 0cc4dc341d9a..14e482b4939e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/warden/Warden.java +++ b/net/minecraft/world/entity/monster/warden/Warden.java -@@ -395,7 +_,7 @@ +@@ -396,7 +_,7 @@ public static void applyDarknessAround(ServerLevel level, Vec3 pos, @Nullable Entity source, int radius) { MobEffectInstance mobEffectInstance = new MobEffectInstance(MobEffects.DARKNESS, 260, 0, false, false); @@ -9,7 +9,7 @@ } @Override -@@ -439,6 +_,15 @@ +@@ -440,6 +_,15 @@ @VisibleForTesting public void increaseAngerAt(@Nullable Entity entity, int offset, boolean playListeningSound) { if (!this.isNoAi() && this.canTargetEntity(entity)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch index c6bc2830f74d..ddf2db4bd4f0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/Villager.java +++ b/net/minecraft/world/entity/npc/Villager.java -@@ -286,7 +_,7 @@ +@@ -287,7 +_,7 @@ this.increaseProfessionLevelOnUpdate = false; } @@ -9,7 +9,7 @@ } } -@@ -395,7 +_,12 @@ +@@ -396,7 +_,12 @@ this.updateDemand(); for (MerchantOffer merchantOffer : this.getOffers()) { @@ -23,7 +23,7 @@ } this.resendOffersToTradingPlayer(); -@@ -451,7 +_,12 @@ +@@ -452,7 +_,12 @@ int i = 2 - this.numberOfRestocksToday; if (i > 0) { for (MerchantOffer merchantOffer : this.getOffers()) { @@ -37,7 +37,7 @@ } } -@@ -472,6 +_,7 @@ +@@ -473,6 +_,7 @@ int playerReputation = this.getPlayerReputation(player); if (playerReputation != 0) { for (MerchantOffer merchantOffer : this.getOffers()) { @@ -45,7 +45,7 @@ merchantOffer.addToSpecialPriceDiff(-Mth.floor(playerReputation * merchantOffer.getPriceMultiplier())); } } -@@ -481,6 +_,7 @@ +@@ -482,6 +_,7 @@ int amplifier = effect.getAmplifier(); for (MerchantOffer merchantOffer1 : this.getOffers()) { @@ -53,7 +53,7 @@ double d = 0.3 + 0.0625 * amplifier; int i = (int)Math.floor(d * merchantOffer1.getBaseCostA().getCount()); merchantOffer1.addToSpecialPriceDiff(-Math.max(i, 1)); -@@ -589,7 +_,7 @@ +@@ -590,7 +_,7 @@ } if (offer.shouldRewardExp()) { @@ -62,7 +62,7 @@ } } -@@ -607,7 +_,7 @@ +@@ -608,7 +_,7 @@ @Override public void die(DamageSource damageSource) { @@ -71,7 +71,7 @@ Entity entity = damageSource.getEntity(); if (entity != null) { this.tellWitnessesThatIWasMurdered(entity); -@@ -706,7 +_,7 @@ +@@ -707,7 +_,7 @@ return VillagerData.canLevelUp(level) && this.villagerXp >= VillagerData.getMaxXpPerLevel(level); } @@ -80,7 +80,7 @@ this.setVillagerData(this.getVillagerData().withLevel(this.getVillagerData().level() + 1)); this.updateTrades(serverLevel); } -@@ -775,12 +_,19 @@ +@@ -776,12 +_,19 @@ @Override public void thunderHit(ServerLevel level, LightningBolt lightning) { if (level.getDifficulty() != Difficulty.PEACEFUL) { @@ -102,7 +102,7 @@ if (witch == null) { super.thunderHit(level, lightning); } -@@ -820,6 +_,12 @@ +@@ -821,6 +_,12 @@ @Override protected void updateTrades(ServerLevel level) { @@ -115,7 +115,7 @@ VillagerData villagerData = this.getVillagerData(); ResourceKey resourceKey = villagerData.profession().unwrapKey().orElse(null); if (resourceKey != null) { -@@ -835,13 +_,15 @@ +@@ -836,13 +_,15 @@ VillagerTrades.ItemListing[] itemListings = map1.get(villagerData.level()); if (itemListings != null) { MerchantOffers offers = this.getOffers(); @@ -133,7 +133,7 @@ } public void gossip(ServerLevel level, Villager target, long gameTime) { -@@ -870,7 +_,7 @@ +@@ -871,7 +_,7 @@ List entitiesOfClass = level.getEntitiesOfClass(Villager.class, aabb); List list = entitiesOfClass.stream().filter(villager -> villager.wantsToSpawnGolem(gameTime)).limit(5L).toList(); if (list.size() >= minVillagerAmount) { @@ -142,7 +142,7 @@ EntityType.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, level, -@@ -879,9 +_,11 @@ +@@ -880,9 +_,11 @@ 8, 6, SpawnUtil.Strategy.LEGACY_IRON_GOLEM, diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index c3a1339faee4..5c7d2845116a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -150,7 +_,7 @@ +@@ -151,7 +_,7 @@ private static final boolean DEFAULT_IGNORE_FALL_DAMAGE_FROM_CURRENT_IMPULSE = false; private static final int DEFAULT_CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME = 0; final Inventory inventory; @@ -9,7 +9,7 @@ public final InventoryMenu inventoryMenu; public AbstractContainerMenu containerMenu; protected FoodData foodData = new FoodData(); -@@ -181,6 +_,18 @@ +@@ -182,6 +_,18 @@ public Entity currentExplosionCause; private boolean ignoreFallDamageFromCurrentImpulse = false; private int currentImpulseContextResetGraceTime = 0; @@ -28,7 +28,7 @@ public Player(Level level, GameProfile gameProfile) { super(EntityType.PLAYER, level); -@@ -248,6 +_,13 @@ +@@ -249,6 +_,13 @@ if (this.isSleeping()) { this.sleepCounter++; @@ -42,7 +42,7 @@ if (this.sleepCounter > 100) { this.sleepCounter = 100; } -@@ -331,7 +_,7 @@ +@@ -332,7 +_,7 @@ } private void turtleHelmetTick() { @@ -51,7 +51,7 @@ } private boolean isEquipped(Item item) { -@@ -435,6 +_,18 @@ +@@ -436,6 +_,18 @@ } } @@ -70,7 +70,7 @@ public void closeContainer() { this.containerMenu = this.inventoryMenu; } -@@ -446,8 +_,14 @@ +@@ -447,8 +_,14 @@ public void rideTick() { if (!this.level().isClientSide() && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -87,7 +87,7 @@ super.rideTick(); } } -@@ -708,10 +_,10 @@ +@@ -709,10 +_,10 @@ if (this.isDeadOrDying()) { return false; } else { @@ -100,7 +100,7 @@ } if (level.getDifficulty() == Difficulty.EASY) { -@@ -723,7 +_,14 @@ +@@ -724,7 +_,14 @@ } } @@ -116,7 +116,7 @@ } } } -@@ -735,7 +_,7 @@ +@@ -736,7 +_,7 @@ BlocksAttacks blocksAttacks = itemBlockingWith != null ? itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS) : null; float secondsToDisableBlocking = entity.getSecondsToDisableBlocking(); if (secondsToDisableBlocking > 0.0F && blocksAttacks != null) { @@ -125,7 +125,7 @@ } } -@@ -745,9 +_,29 @@ +@@ -746,9 +_,29 @@ } public boolean canHarmPlayer(Player other) { @@ -158,7 +158,7 @@ } @Override -@@ -761,7 +_,12 @@ +@@ -762,7 +_,12 @@ } @Override @@ -172,7 +172,7 @@ if (!this.isInvulnerableTo(level, damageSource)) { amount = this.getDamageAfterArmorAbsorb(damageSource, amount); amount = this.getDamageAfterMagicAbsorb(damageSource, amount); -@@ -773,7 +_,7 @@ +@@ -774,7 +_,7 @@ } if (var8 != 0.0F) { @@ -181,7 +181,7 @@ this.getCombatTracker().recordDamage(damageSource, var8); this.setHealth(this.getHealth() - var8); if (var8 < 3.4028235E37F) { -@@ -783,6 +_,7 @@ +@@ -784,6 +_,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -189,7 +189,7 @@ } public boolean isTextFilteringEnabled() { -@@ -866,14 +_,16 @@ +@@ -867,14 +_,16 @@ } @Override @@ -209,7 +209,7 @@ } @Override -@@ -952,16 +_,26 @@ +@@ -953,16 +_,26 @@ } public void attack(Entity target) { @@ -239,7 +239,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = attackStrengthScale > 0.9F; boolean flag1; -@@ -974,7 +_,9 @@ +@@ -975,7 +_,9 @@ f += weaponItem.getItem().getAttackDamageBonus(target, f, damageSource); boolean flag2 = flag && this.canCriticalAttack(target); @@ -249,7 +249,7 @@ f *= 1.5F; } -@@ -1016,11 +_,12 @@ +@@ -1017,11 +_,12 @@ return !target.isAttackable() || target.skipAttackInteraction(this); } @@ -264,7 +264,7 @@ return true; } else { return false; -@@ -1113,21 +_,43 @@ +@@ -1114,21 +_,43 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F) { if (target instanceof LivingEntity livingEntity) { @@ -309,7 +309,7 @@ } } -@@ -1148,7 +_,10 @@ +@@ -1149,7 +_,10 @@ && !(livingEntity instanceof ArmorStand armorStand && armorStand.isMarker()) && this.distanceToSqr(livingEntity) < 9.0) { float f1 = this.getEnchantedDamage(livingEntity, var12, damageSource) * strengthScale; @@ -321,7 +321,7 @@ livingEntity.knockback(0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity, damageSource); } -@@ -1175,13 +_,22 @@ +@@ -1176,13 +_,22 @@ @Override public boolean stabAttack(EquipmentSlot slot, Entity target, float damageAmount, boolean damage, boolean knockback, boolean dismount) { @@ -346,7 +346,7 @@ return true; } else { float f1 = damage ? damageAmount + f : 0.0F; -@@ -1209,7 +_,7 @@ +@@ -1210,7 +_,7 @@ this.setLastHurtMob(target); this.itemAttackInteraction(target, itemBySlot, damageSource, flag); this.damageStatsAndHearts(target, f2); @@ -355,7 +355,7 @@ return true; } } -@@ -1220,8 +_,8 @@ +@@ -1221,8 +_,8 @@ } @Override @@ -366,7 +366,7 @@ this.inventoryMenu.removed(this); if (this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1289,6 +_,12 @@ +@@ -1290,6 +_,12 @@ } public Either startSleepInBed(BlockPos bedPos) { @@ -379,7 +379,7 @@ this.startSleeping(bedPos); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1400,7 +_,7 @@ +@@ -1401,7 +_,7 @@ @Override public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) { @@ -388,11 +388,11 @@ return false; } else { if (fallDistance >= 2.0) { -@@ -1441,7 +_,15 @@ +@@ -1442,7 +_,15 @@ } public void startFallFlying() { -- this.setSharedFlag(7, true); +- this.setSharedFlag(Entity.FLAG_FALL_FLYING, true); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, true).isCancelled()) { + this.setSharedFlag(7, true); @@ -405,7 +405,7 @@ } @Override -@@ -1539,7 +_,7 @@ +@@ -1540,7 +_,7 @@ if (levels > 0 && this.experienceLevel % 5 == 0 && this.lastLevelUpTime < this.tickCount - 100.0F) { float f = this.experienceLevel > 30 ? 1.0F : this.experienceLevel / 30.0F; @@ -414,7 +414,7 @@ this.lastLevelUpTime = this.tickCount; } } -@@ -1547,15 +_,35 @@ +@@ -1548,15 +_,35 @@ public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { return 112 + (this.experienceLevel - 30) * 9; @@ -452,7 +452,7 @@ } } } -@@ -1813,7 +_,7 @@ +@@ -1814,7 +_,7 @@ @Override public void onAttack() { @@ -461,7 +461,7 @@ super.onAttack(); } -@@ -1848,17 +_,32 @@ +@@ -1849,17 +_,32 @@ return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } @@ -496,7 +496,7 @@ for (int i = 0; i < this.inventory.getContainerSize(); i++) { ItemStack item = this.inventory.getItem(i); -@@ -1867,6 +_,7 @@ +@@ -1868,6 +_,7 @@ } } @@ -504,7 +504,7 @@ return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; } } -@@ -1953,12 +_,20 @@ +@@ -1954,12 +_,20 @@ } public boolean hasClientLoaded() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch index 8c4c1b262292..a707ad40d3d2 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -130,7 +130,7 @@ } if (entity.hurtOrSimulate(damageSource, ceil)) { -@@ -486,7 +_,7 @@ +@@ -487,7 +_,7 @@ this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); if (this.getPierceLevel() <= 0) { @@ -139,7 +139,7 @@ } } else { entity.setRemainingFireTicks(remainingFireTicks); -@@ -497,7 +_,7 @@ +@@ -498,7 +_,7 @@ this.spawnAtLocation(serverLevel2, this.getPickupItem(), 0.1F); } @@ -148,7 +148,7 @@ } } } -@@ -510,7 +_,7 @@ +@@ -511,7 +_,7 @@ double max = Math.max(0.0, 1.0 - entity.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); Vec3 vec3 = this.getDeltaMovement().multiply(1.0, 0.0, 1.0).normalize().scale(d * 0.6 * max); if (vec3.lengthSqr() > 0.0) { @@ -157,7 +157,7 @@ } } } -@@ -623,7 +_,14 @@ +@@ -624,7 +_,14 @@ @Override public void setOwner(@Nullable Entity entity) { @@ -172,7 +172,7 @@ this.pickup = switch (entity) { case Player player when this.pickup == AbstractArrow.Pickup.DISALLOWED -> AbstractArrow.Pickup.ALLOWED; -@@ -635,9 +_,22 @@ +@@ -636,9 +_,22 @@ @Override public void playerTouch(Player entity) { if (!this.level().isClientSide() && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch index c060924241c1..719320435111 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/AbstractThrownPotion.java +++ b/net/minecraft/world/entity/projectile/AbstractThrownPotion.java -@@ -67,54 +_,95 @@ +@@ -68,56 +_,97 @@ @Override protected void onHit(HitResult result) { super.onHit(result); @@ -24,7 +24,9 @@ } + if (showParticles) { // Paper - Fix potions splash events - int i = potionContents.potion().isPresent() && potionContents.potion().get().value().hasInstantEffects() ? 2007 : 2002; + int i = potionContents.potion().isPresent() && potionContents.potion().get().value().hasInstantEffects() + ? LevelEvent.PARTICLES_INSTANT_POTION_SPLASH + : LevelEvent.PARTICLES_SPELL_POTION_SPLASH; serverLevel.levelEvent(i, this.blockPosition(), potionContents.getColor()); - this.discard(); + } // Paper - Fix potions splash events @@ -100,7 +102,7 @@ + } // CraftBukkit } else if (CampfireBlock.isLitCampfire(blockState)) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, blockState.setValue(CampfireBlock.LIT, false))) { // CraftBukkit - this.level().levelEvent(null, 1009, pos, 0); + this.level().levelEvent(null, LevelEvent.SOUND_EXTINGUISH_FIRE, pos, 0); CampfireBlock.dowse(this.getOwner(), this.level(), pos, blockState); this.level().setBlockAndUpdate(pos, blockState.setValue(CampfireBlock.LIT, false)); + } // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch index d2f45e162211..9697917eaaf7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/DragonFireball.java +++ b/net/minecraft/world/entity/projectile/DragonFireball.java -@@ -54,9 +_,11 @@ +@@ -55,9 +_,11 @@ } } + if (new com.destroystokyo.paper.event.entity.EnderDragonFireballHitEvent((org.bukkit.entity.DragonFireball) this.getBukkitEntity(), entitiesOfClass.stream().map(LivingEntity::getBukkitLivingEntity).collect(java.util.stream.Collectors.toList()), (org.bukkit.entity.AreaEffectCloud) areaEffectCloud.getBukkitEntity()).callEvent()) { // Paper - EnderDragon Events - this.level().levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1); + this.level().levelEvent(LevelEvent.PARTICLES_DRAGON_FIREBALL_SPLASH, this.blockPosition(), this.isSilent() ? -1 : 1); - this.level().addFreshEntity(areaEffectCloud); - this.discard(); + this.level().addFreshEntity(areaEffectCloud, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EXPLOSION); // Paper - use correct spawn reason diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch index e606fa686289..e667ea089ee1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EvokerFangs.java +++ b/net/minecraft/world/entity/projectile/EvokerFangs.java -@@ -97,7 +_,7 @@ +@@ -98,7 +_,7 @@ } if (--this.lifeTicks < 0) { @@ -9,7 +9,7 @@ } } } -@@ -106,7 +_,7 @@ +@@ -107,7 +_,7 @@ LivingEntity owner = this.getOwner(); if (target.isAlive() && !target.isInvulnerable() && target != owner) { if (owner == null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch index 060c0ec1b92e..69a8e815ddb3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EyeOfEnder.java +++ b/net/minecraft/world/entity/projectile/EyeOfEnder.java -@@ -72,6 +_,12 @@ +@@ -73,6 +_,12 @@ } public void signalTo(Vec3 pos) { @@ -13,7 +13,7 @@ Vec3 vec3 = pos.subtract(this.position()); double d = vec3.horizontalDistance(); if (d > 12.0) { -@@ -80,8 +_,10 @@ +@@ -81,8 +_,10 @@ this.target = pos; } @@ -24,7 +24,7 @@ } @Override -@@ -102,7 +_,7 @@ +@@ -103,7 +_,7 @@ this.life++; if (this.life > 80 && !this.level().isClientSide()) { this.playSound(SoundEvents.ENDER_EYE_DEATH, 1.0F, 1.0F); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch index 9008190bfae1..9a9d61c83368 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -48,6 +_,7 @@ +@@ -49,6 +_,7 @@ public int lifetime = 0; @Nullable public LivingEntity attachedToEntity; @@ -8,7 +8,7 @@ public FireworkRocketEntity(EntityType type, Level level) { super(type, level); -@@ -163,7 +_,7 @@ +@@ -164,7 +_,7 @@ } if (!this.noPhysics && this.isAlive() && hitResultOnMoveVector.getType() != HitResult.Type.MISS) { @@ -17,7 +17,7 @@ this.hasImpulse = true; } -@@ -187,7 +_,11 @@ +@@ -188,7 +_,11 @@ } if (this.life > this.lifetime && this.level() instanceof ServerLevel serverLevel) { @@ -30,8 +30,8 @@ } } -@@ -195,14 +_,18 @@ - level.broadcastEntityEvent(this, (byte)17); +@@ -196,14 +_,18 @@ + level.broadcastEntityEvent(this, EntityEvent.FIREWORKS_EXPLODE); this.gameEvent(GameEvent.EXPLODE, this.getOwner()); this.dealExplosionDamage(level); - this.discard(); @@ -51,7 +51,7 @@ } } -@@ -211,7 +_,11 @@ +@@ -212,7 +_,11 @@ BlockPos blockPos = new BlockPos(result.getBlockPos()); this.level().getBlockState(blockPos).entityInside(this.level(), blockPos, this, InsideBlockEffectApplier.NOOP, true); if (this.level() instanceof ServerLevel serverLevel && this.hasExplosion()) { @@ -64,7 +64,7 @@ } super.onHitBlock(result); -@@ -283,6 +_,7 @@ +@@ -284,6 +_,7 @@ output.putInt("LifeTime", this.lifetime); output.store("FireworksItem", ItemStack.CODEC, this.getItem()); output.putBoolean("ShotAtAngle", this.entityData.get(DATA_SHOT_AT_ANGLE)); @@ -72,7 +72,7 @@ } @Override -@@ -292,6 +_,7 @@ +@@ -293,6 +_,7 @@ this.lifetime = input.getIntOr("LifeTime", 0); this.entityData.set(DATA_ID_FIREWORKS_ITEM, input.read("FireworksItem", ItemStack.CODEC).orElse(getDefaultItem())); this.entityData.set(DATA_SHOT_AT_ANGLE, input.getBooleanOr("ShotAtAngle", false)); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch index b4cbea3c98d2..1e6738898fc7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/FishingHook.java +++ b/net/minecraft/world/entity/projectile/FishingHook.java -@@ -70,10 +_,26 @@ +@@ -71,10 +_,26 @@ private final int lureSpeed; private final InterpolationHandler interpolationHandler = new InterpolationHandler(this); @@ -27,7 +27,7 @@ } public FishingHook(EntityType type, Level level) { -@@ -154,12 +_,12 @@ +@@ -155,12 +_,12 @@ super.tick(); Player playerOwner = this.getPlayerOwner(); if (playerOwner == null) { @@ -42,7 +42,7 @@ return; } } else { -@@ -177,12 +_,14 @@ +@@ -178,12 +_,14 @@ if (this.currentState == FishingHook.FishHookState.FLYING) { if (this.hookedIn != null) { this.setDeltaMovement(Vec3.ZERO); @@ -57,7 +57,7 @@ this.currentState = FishingHook.FishHookState.BOBBING; return; } -@@ -197,6 +_,7 @@ +@@ -198,6 +_,7 @@ this.setPos(this.hookedIn.getX(), this.hookedIn.getY(0.8), this.hookedIn.getZ()); } else { this.setHookedEntity(null); @@ -65,7 +65,7 @@ this.currentState = FishingHook.FishHookState.FLYING; } } -@@ -263,13 +_,13 @@ +@@ -264,13 +_,13 @@ } } @@ -81,7 +81,7 @@ } @Override -@@ -300,11 +_,11 @@ +@@ -301,11 +_,11 @@ ServerLevel serverLevel = (ServerLevel)this.level(); int i = 1; BlockPos blockPos = pos.above(); @@ -95,7 +95,7 @@ i--; } -@@ -314,6 +_,10 @@ +@@ -315,6 +_,10 @@ this.timeUntilLured = 0; this.timeUntilHooked = 0; this.getEntityData().set(DATA_BITING, false); @@ -106,7 +106,7 @@ } } else if (this.timeUntilHooked > 0) { this.timeUntilHooked -= i; -@@ -337,6 +_,12 @@ +@@ -338,6 +_,12 @@ serverLevel.sendParticles(ParticleTypes.FISHING, d, d1, d2, 0, -f2, 0.01, f1, 1.0); } } else { @@ -119,7 +119,7 @@ this.playSound(SoundEvents.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); double d3 = this.getY() + 0.5; serverLevel.sendParticles( -@@ -388,14 +_,31 @@ +@@ -389,14 +_,31 @@ } if (this.timeUntilLured <= 0) { @@ -155,7 +155,7 @@ public boolean calculateOpenWater(BlockPos pos) { FishingHook.OpenWaterType openWaterType = FishingHook.OpenWaterType.INVALID; -@@ -454,15 +_,31 @@ +@@ -455,15 +_,31 @@ protected void readAdditionalSaveData(ValueInput input) { } @@ -181,13 +181,13 @@ + // CraftBukkit end this.pullEntity(this.hookedIn); CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer)playerOwner, stack, this, Collections.emptyList()); - this.level().broadcastEntityEvent(this, (byte)31); + this.level().broadcastEntityEvent(this, EntityEvent.FISHING_ROD_REEL_IN); i = this.hookedIn instanceof ItemEntity ? 3 : 5; + } // Paper - re-check to see if there is a hooked entity } else if (this.nibble > 0) { LootParams lootParams = new LootParams.Builder((ServerLevel)this.level()) .withParameter(LootContextParams.ORIGIN, this.position()) -@@ -476,18 +_,27 @@ +@@ -477,18 +_,27 @@ for (ItemStack itemStack : randomItems) { ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemStack); @@ -221,7 +221,7 @@ if (itemStack.is(ItemTags.FISHES)) { playerOwner.awardStat(Stats.FISH_CAUGHT, 1); } -@@ -497,10 +_,24 @@ +@@ -498,10 +_,24 @@ } if (this.onGround()) { @@ -247,7 +247,7 @@ return i; } else { return 0; -@@ -530,9 +_,9 @@ +@@ -531,9 +_,9 @@ } @Override @@ -259,7 +259,7 @@ } @Override -@@ -580,7 +_,7 @@ +@@ -581,7 +_,7 @@ if (this.getPlayerOwner() == null) { int data = packet.getData(); LOGGER.error("Failed to recreate fishing hook on client. {} (id: {}) is not a valid owner.", this.level().getEntity(data), data); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Snowball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Snowball.java.patch index 881f478e3f50..440d63416474 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Snowball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Snowball.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/projectile/Snowball.java +++ b/net/minecraft/world/entity/projectile/Snowball.java -@@ -61,7 +_,7 @@ +@@ -62,7 +_,7 @@ super.onHit(result); if (!this.level().isClientSide()) { - this.level().broadcastEntityEvent(this, (byte)3); + this.level().broadcastEntityEvent(this, EntityEvent.DEATH); - this.discard(); + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch index 7928e1e5dbe8..59fda363d32e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ThrownEgg.java +++ b/net/minecraft/world/entity/projectile/ThrownEgg.java -@@ -61,31 +_,66 @@ +@@ -62,31 +_,66 @@ protected void onHit(HitResult result) { super.onHit(result); if (!this.level().isClientSide()) { @@ -69,7 +69,7 @@ } } - this.level().broadcastEntityEvent(this, (byte)3); + this.level().broadcastEntityEvent(this, EntityEvent.DEATH); - this.discard(); + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch index 5c4dabc73493..1cb59c72ff4e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java +++ b/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java -@@ -39,16 +_,25 @@ +@@ -40,16 +_,25 @@ protected void onHit(HitResult result) { super.onHit(result); if (this.level() instanceof ServerLevel serverLevel) { -- serverLevel.levelEvent(2002, this.blockPosition(), -13083194); +- serverLevel.levelEvent(LevelEvent.PARTICLES_SPELL_POTION_SPLASH, this.blockPosition(), -13083194); + // CraftBukkit - moved to after event int i = 3 + serverLevel.random.nextInt(5) + serverLevel.random.nextInt(5); + // Paper start - exp bottle event diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch index da75cc2ef73f..da13294e34b0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/MinecartTNT.java +++ b/net/minecraft/world/entity/vehicle/MinecartTNT.java -@@ -39,6 +_,7 @@ +@@ -40,6 +_,7 @@ public int fuse = -1; public float explosionPowerBase = 4.0F; public float explosionSpeedFactor = 1.0F; @@ -8,7 +8,7 @@ public MinecartTNT(EntityType type, Level level) { super(type, level); -@@ -53,6 +_,12 @@ +@@ -54,6 +_,12 @@ public void tick() { super.tick(); if (this.fuse > 0) { @@ -21,7 +21,7 @@ this.fuse--; this.level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5, this.getZ(), 0.0, 0.0, 0.0); } else if (this.fuse == 0) { -@@ -104,6 +_,17 @@ +@@ -105,6 +_,17 @@ if (this.level() instanceof ServerLevel serverLevel) { if (serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) { double min = Math.min(Math.sqrt(radiusModifier), 5.0); @@ -39,7 +39,7 @@ serverLevel.explode( this, damageSource, -@@ -111,13 +_,13 @@ +@@ -112,13 +_,13 @@ this.getX(), this.getY(), this.getZ(), diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch index 4b19bb01a481..66bf34a8d618 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch @@ -162,7 +162,7 @@ this.resetQuickCraft(); @@ -406,8 +_,11 @@ - if (slotIndex == -999) { + if (slotIndex == SLOT_CLICKED_OUTSIDE) { if (!this.getCarried().isEmpty()) { if (clickAction == ClickAction.PRIMARY) { - player.drop(this.getCarried(), true); diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch index 3bfe900bd49f..184b89d203bd 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/AnvilMenu.java +++ b/net/minecraft/world/inventory/AnvilMenu.java -@@ -44,6 +_,12 @@ +@@ -46,6 +_,12 @@ private static final int ADDITIONAL_SLOT_X_PLACEMENT = 76; private static final int RESULT_SLOT_X_PLACEMENT = 134; private static final int SLOT_Y_PLACEMENT = 47; @@ -13,7 +13,7 @@ public AnvilMenu(int containerId, Inventory playerInventory) { this(containerId, playerInventory, ContainerLevelAccess.NULL); -@@ -69,7 +_,7 @@ +@@ -71,7 +_,7 @@ @Override protected boolean mayPickup(Player player, boolean hasStack) { @@ -22,7 +22,7 @@ } @Override -@@ -90,7 +_,7 @@ +@@ -92,7 +_,7 @@ this.inputSlots.setItem(1, ItemStack.EMPTY); } @@ -31,7 +31,7 @@ if (player instanceof ServerPlayer serverPlayer && !StringUtil.isBlank(this.itemName) && !this.inputSlots.getItem(0).getHoverName().getString().equals(this.itemName)) { -@@ -102,6 +_,16 @@ +@@ -104,6 +_,16 @@ BlockState blockState = level.getBlockState(blockPos); if (!player.hasInfiniteMaterials() && blockState.is(BlockTags.ANVIL) && player.getRandom().nextFloat() < 0.12F) { BlockState blockState1 = AnvilBlock.damage(blockState); @@ -47,8 +47,8 @@ + // Paper end - AnvilDamageEvent if (blockState1 == null) { level.removeBlock(blockPos, false); - level.levelEvent(1029, blockPos, 0); -@@ -134,8 +_,8 @@ + level.levelEvent(LevelEvent.SOUND_ANVIL_BROKEN, blockPos, 0); +@@ -136,8 +_,8 @@ if (itemStack.isDamageableItem() && item.isValidRepairItem(item1)) { int min = Math.min(itemStack.getDamageValue(), itemStack.getMaxDamage() / 4); if (min <= 0) { @@ -59,7 +59,7 @@ return; } -@@ -150,8 +_,8 @@ +@@ -152,8 +_,8 @@ this.repairItemCountCost = i2; } else { if (!hasStoredEnchantments && (!itemStack.is(item1.getItem()) || !itemStack.isDamageableItem())) { @@ -70,7 +70,7 @@ return; } -@@ -197,7 +_,7 @@ +@@ -199,7 +_,7 @@ flag1 = true; } else { flag = true; @@ -79,7 +79,7 @@ intValue = enchantment.getMaxLevel(); } -@@ -215,8 +_,8 @@ +@@ -217,8 +_,8 @@ } if (flag1 && !flag) { @@ -90,7 +90,7 @@ return; } } -@@ -241,14 +_,16 @@ +@@ -243,14 +_,16 @@ } if (i1 == i && i1 > 0) { @@ -110,7 +110,7 @@ itemStack = ItemStack.EMPTY; } -@@ -266,12 +_,13 @@ +@@ -268,12 +_,13 @@ EnchantmentHelper.setEnchantments(itemStack, mutable.toImmutable()); } @@ -127,7 +127,7 @@ } public static int calculateIncreasedRepairCost(int oldRepairCost) { -@@ -292,6 +_,7 @@ +@@ -294,6 +_,7 @@ } this.createResult(); @@ -135,7 +135,7 @@ return true; } else { return false; -@@ -307,4 +_,19 @@ +@@ -309,4 +_,19 @@ public int getCost() { return this.cost.get(); } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch index 39b09b925f9e..06fc1bb17cde 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/GrindstoneMenu.java +++ b/net/minecraft/world/inventory/GrindstoneMenu.java -@@ -20,6 +_,21 @@ +@@ -21,6 +_,21 @@ import net.minecraft.world.phys.Vec3; public class GrindstoneMenu extends AbstractContainerMenu { @@ -22,7 +22,7 @@ public static final int MAX_NAME_LENGTH = 35; public static final int INPUT_SLOT = 0; public static final int ADDITIONAL_SLOT = 1; -@@ -28,14 +_,8 @@ +@@ -29,14 +_,8 @@ private static final int INV_SLOT_END = 30; private static final int USE_ROW_SLOT_START = 30; private static final int USE_ROW_SLOT_END = 39; @@ -39,7 +39,7 @@ private final ContainerLevelAccess access; public GrindstoneMenu(int containerId, Inventory playerInventory) { -@@ -44,6 +_,22 @@ +@@ -45,6 +_,22 @@ public GrindstoneMenu(int containerId, Inventory playerInventory, final ContainerLevelAccess access) { super(MenuType.GRINDSTONE, containerId); @@ -62,7 +62,7 @@ this.access = access; this.addSlot(new Slot(this.repairSlots, 0, 49, 19) { @Override -@@ -67,7 +_,11 @@ +@@ -68,7 +_,11 @@ public void onTake(Player player, ItemStack stack) { access.execute((level, blockPos) -> { if (level instanceof ServerLevel) { @@ -74,8 +74,8 @@ + // Paper end - Fire BlockExpEvent on grindstone use } - level.levelEvent(1042, blockPos, 0); -@@ -104,6 +_,7 @@ + level.levelEvent(LevelEvent.SOUND_GRINDSTONE_USED, blockPos, 0); +@@ -105,6 +_,7 @@ } }); this.addStandardInventorySlots(playerInventory, 8, 84); @@ -83,7 +83,7 @@ } @Override -@@ -111,11 +_,13 @@ +@@ -112,11 +_,13 @@ super.slotsChanged(inventory); if (inventory == this.repairSlots) { this.createResult(); @@ -98,7 +98,7 @@ this.broadcastChanges(); } -@@ -201,6 +_,7 @@ +@@ -202,6 +_,7 @@ @Override public boolean stillValid(Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/SmithingMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/SmithingMenu.java.patch index 1277f3d7ac9d..afdbf864d4af 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/SmithingMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/SmithingMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/SmithingMenu.java +++ b/net/minecraft/world/inventory/SmithingMenu.java -@@ -32,6 +_,9 @@ +@@ -33,6 +_,9 @@ private final RecipePropertySet templateItemTest; private final RecipePropertySet additionItemTest; private final DataSlot hasRecipeError = DataSlot.standalone(); @@ -10,7 +10,7 @@ public SmithingMenu(int containerId, Inventory playerInventory) { this(containerId, playerInventory, ContainerLevelAccess.NULL); -@@ -99,6 +_,7 @@ +@@ -100,6 +_,7 @@ if (this.level instanceof ServerLevel) { boolean flag = this.getSlot(0).hasItem() && this.getSlot(1).hasItem() && this.getSlot(2).hasItem() && !this.getSlot(this.getResultSlot()).hasItem(); this.hasRecipeError.set(flag ? 1 : 0); @@ -18,7 +18,7 @@ } } -@@ -115,7 +_,9 @@ +@@ -116,7 +_,9 @@ recipeFor.ifPresentOrElse(recipe -> { ItemStack itemStack = recipe.value().assemble(smithingRecipeInput, this.level.registryAccess()); this.resultSlots.setRecipeUsed((RecipeHolder)recipe); @@ -29,7 +29,7 @@ }, () -> { this.resultSlots.setRecipeUsed(null); this.resultSlots.setItem(0, ItemStack.EMPTY); -@@ -137,4 +_,18 @@ +@@ -138,4 +_,18 @@ public boolean hasRecipeError() { return this.hasRecipeError.get() > 0; } diff --git a/paper-server/patches/sources/net/minecraft/world/item/BoneMealItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/BoneMealItem.java.patch index e048d570ed14..a286e29b55e2 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BoneMealItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/BoneMealItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BoneMealItem.java +++ b/net/minecraft/world/item/BoneMealItem.java -@@ -33,12 +_,17 @@ +@@ -35,12 +_,17 @@ @Override public InteractionResult useOn(UseOnContext context) { @@ -16,15 +16,15 @@ if (!level.isClientSide()) { - context.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); + if (context.getPlayer() != null) context.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518 - level.levelEvent(1505, clickedPos, 15); + level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, clickedPos, 15); } -@@ -48,7 +_,7 @@ +@@ -50,7 +_,7 @@ boolean isFaceSturdy = blockState.isFaceSturdy(level, clickedPos, context.getClickedFace()); if (isFaceSturdy && growWaterPlant(context.getItemInHand(), level, blockPos, context.getClickedFace())) { if (!level.isClientSide()) { - context.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); + if (context.getPlayer() != null) context.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518 - level.levelEvent(1505, blockPos, 15); + level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, blockPos, 15); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch index c699e34a3688..b797b0751900 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/EnderEyeItem.java +++ b/net/minecraft/world/item/EnderEyeItem.java -@@ -43,6 +_,11 @@ +@@ -44,6 +_,11 @@ return InteractionResult.SUCCESS; } else { BlockState blockState1 = blockState.setValue(EndPortalFrameBlock.HAS_EYE, true); @@ -10,13 +10,13 @@ + } + // Paper end Block.pushEntitiesUp(blockState, blockState1, level, clickedPos); - level.setBlock(clickedPos, blockState1, 2); + level.setBlock(clickedPos, blockState1, Block.UPDATE_CLIENTS); level.updateNeighbourForOutputSignal(clickedPos, Blocks.END_PORTAL_FRAME); -@@ -60,7 +_,27 @@ +@@ -61,7 +_,27 @@ } } -- level.globalLevelEvent(1038, blockPos.offset(1, 0, 1), 0); +- level.globalLevelEvent(LevelEvent.SOUND_END_PORTAL_SPAWN, blockPos.offset(1, 0, 1), 0); + // CraftBukkit start - Use relative location for far away sounds + // level.globalLevelEvent(1038, blockPos.offset(1, 0, 1), 0); + int viewDistance = level.getCraftServer().getViewDistance() * 16; @@ -41,7 +41,7 @@ } return InteractionResult.SUCCESS; -@@ -90,7 +_,11 @@ +@@ -91,7 +_,11 @@ eyeOfEnder.setItem(itemInHand); eyeOfEnder.signalTo(Vec3.atLowerCornerOf(blockPos)); level.gameEvent(GameEvent.PROJECTILE_SHOOT, eyeOfEnder.position(), GameEvent.Context.of(player)); diff --git a/paper-server/patches/sources/net/minecraft/world/item/FlintAndSteelItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/FlintAndSteelItem.java.patch index 0c3abf93fc42..f9aef7b267bf 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/FlintAndSteelItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/FlintAndSteelItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/FlintAndSteelItem.java +++ b/net/minecraft/world/item/FlintAndSteelItem.java -@@ -31,6 +_,12 @@ +@@ -32,6 +_,12 @@ if (!CampfireBlock.canLight(blockState) && !CandleBlock.canLight(blockState) && !CandleCakeBlock.canLight(blockState)) { BlockPos blockPos = clickedPos.relative(context.getClickedFace()); if (BaseFireBlock.canBePlacedAt(level, blockPos, context.getHorizontalDirection())) { @@ -12,8 +12,8 @@ + // CraftBukkit end level.playSound(player, blockPos, SoundEvents.FLINTANDSTEEL_USE, SoundSource.BLOCKS, 1.0F, level.getRandom().nextFloat() * 0.4F + 0.8F); BlockState state = BaseFireBlock.getState(level, blockPos); - level.setBlock(blockPos, state, 11); -@@ -46,6 +_,12 @@ + level.setBlock(blockPos, state, Block.UPDATE_ALL_IMMEDIATE); +@@ -47,6 +_,12 @@ return InteractionResult.FAIL; } } else { @@ -24,5 +24,5 @@ + } + // CraftBukkit end level.playSound(player, clickedPos, SoundEvents.FLINTANDSTEEL_USE, SoundSource.BLOCKS, 1.0F, level.getRandom().nextFloat() * 0.4F + 0.8F); - level.setBlock(clickedPos, blockState.setValue(BlockStateProperties.LIT, true), 11); + level.setBlock(clickedPos, blockState.setValue(BlockStateProperties.LIT, true), Block.UPDATE_ALL_IMMEDIATE); level.gameEvent(player, GameEvent.BLOCK_CHANGE, clickedPos); diff --git a/paper-server/patches/sources/net/minecraft/world/item/HoneycombItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/HoneycombItem.java.patch index ce0263c34803..5c696fc98097 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/HoneycombItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/HoneycombItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/HoneycombItem.java +++ b/net/minecraft/world/item/HoneycombItem.java -@@ -91,6 +_,14 @@ +@@ -92,6 +_,14 @@ return getWaxed(blockState).map(blockState1 -> { Player player = context.getPlayer(); ItemStack itemInHand = context.getItemInHand(); diff --git a/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch index 3eb3315bb40b..1cdcd7b2ee57 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/MaceItem.java +++ b/net/minecraft/world/item/MaceItem.java -@@ -52,7 +_,13 @@ +@@ -53,7 +_,13 @@ @Override public void hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) { @@ -15,7 +15,7 @@ ServerLevel serverLevel = (ServerLevel)attacker.level(); attacker.setDeltaMovement(attacker.getDeltaMovement().with(Direction.Axis.Y, 0.01F)); if (attacker instanceof ServerPlayer serverPlayer) { -@@ -127,7 +_,7 @@ +@@ -128,7 +_,7 @@ double knockbackPower = getKnockbackPower(attacker, livingEntity, vec3); Vec3 vec31 = vec3.normalize().scale(knockbackPower); if (knockbackPower > 0.0) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch index 72ceea15cc78..01d29fae90da 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ShovelItem.java +++ b/net/minecraft/world/item/ShovelItem.java -@@ -44,20 +_,29 @@ +@@ -45,20 +_,29 @@ Player player = context.getPlayer(); BlockState blockState1 = FLATTENABLES.get(blockState.getBlock()); BlockState blockState2 = null; @@ -12,7 +12,7 @@ } else if (blockState.getBlock() instanceof CampfireBlock && blockState.getValue(CampfireBlock.LIT)) { + afterAction = () -> { // Paper if (!level.isClientSide()) { - level.levelEvent(null, 1009, clickedPos, 0); + level.levelEvent(null, LevelEvent.SOUND_EXTINGUISH_FIRE, clickedPos, 0); } CampfireBlock.dowse(context.getPlayer(), level, clickedPos, blockState); @@ -28,6 +28,6 @@ + } + afterAction.run(); + // Paper end - level.setBlock(clickedPos, blockState2, 11); + level.setBlock(clickedPos, blockState2, Block.UPDATE_ALL_IMMEDIATE); level.gameEvent(GameEvent.BLOCK_CHANGE, clickedPos, GameEvent.Context.of(player, blockState2)); if (player != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch index ee96528330c7..0ee6be7e5610 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/item/SpawnEggItem.java +++ b/net/minecraft/world/item/SpawnEggItem.java -@@ -68,6 +_,7 @@ +@@ -69,6 +_,7 @@ return InteractionResult.FAIL; } else { + if (level.paperConfig().entities.spawning.disableMobSpawnerSpawnEggTransformation) return InteractionResult.FAIL; // Paper - Allow disabling mob spawner spawn egg transformation spawner.setEntityId(type, level.getRandom()); - level.sendBlockUpdated(clickedPos, blockState, blockState, 3); + level.sendBlockUpdated(clickedPos, blockState, blockState, Block.UPDATE_ALL); level.gameEvent(context.getPlayer(), GameEvent.BLOCK_CHANGE, clickedPos); -@@ -95,7 +_,7 @@ +@@ -96,7 +_,7 @@ EntityType type = this.getType(stack); if (type == null) { return InteractionResult.FAIL; @@ -17,7 +17,7 @@ return InteractionResult.FAIL; } else { if (type.spawn((ServerLevel)level, stack, owner, pos, EntitySpawnReason.SPAWN_ITEM_USE, shouldOffsetY, shouldOffsetYMore) != null) { -@@ -179,7 +_,7 @@ +@@ -180,7 +_,7 @@ } else { breedOffspring.snapTo(pos.x(), pos.y(), pos.z(), 0.0F, 0.0F); breedOffspring.applyComponentsFromItemStack(stack); diff --git a/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch index 48659a3bc264..ff35481106fb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/BaseSpawner.java +++ b/net/minecraft/world/level/BaseSpawner.java -@@ -53,13 +_,15 @@ +@@ -54,13 +_,15 @@ public int maxNearbyEntities = 6; public int requiredPlayerRange = 16; public int spawnRange = 4; @@ -17,7 +17,7 @@ } public void clientTick(Level level, BlockPos pos) { -@@ -82,13 +_,19 @@ +@@ -83,13 +_,19 @@ } public void serverTick(ServerLevel level, BlockPos pos) { @@ -39,7 +39,7 @@ } else { boolean flag = false; RandomSource random = level.getRandom(); -@@ -126,6 +_,21 @@ +@@ -127,6 +_,21 @@ continue; } @@ -61,7 +61,7 @@ Entity entity = EntityType.loadEntityRecursive(valueInput, level, EntitySpawnReason.SPAWNER, entity1 -> { entity1.snapTo(vec3.x, vec3.y, vec3.z, entity1.getYRot(), entity1.getXRot()); return entity1; -@@ -159,9 +_,22 @@ +@@ -160,9 +_,22 @@ } nextSpawnData.getEquipment().ifPresent(mob::equip); @@ -85,7 +85,7 @@ this.delay(level, pos); return; } -@@ -172,7 +_,7 @@ +@@ -173,7 +_,7 @@ ((Mob)entity).spawnAnim(); } @@ -94,7 +94,7 @@ } } } -@@ -199,12 +_,14 @@ +@@ -200,12 +_,14 @@ } public void load(@Nullable Level level, BlockPos pos, ValueInput input) { @@ -112,7 +112,7 @@ this.spawnCount = input.getIntOr("SpawnCount", 4); this.maxNearbyEntities = input.getIntOr("MaxNearbyEntities", 6); this.requiredPlayerRange = input.getIntOr("RequiredPlayerRange", 16); -@@ -213,9 +_,19 @@ +@@ -214,9 +_,19 @@ } public void save(ValueOutput output) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch b/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch index 11a8d1ed42dc..116f0da8b9f0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/GameRules.java +++ b/net/minecraft/world/level/GameRules.java -@@ -35,6 +_,14 @@ +@@ -36,6 +_,14 @@ import org.slf4j.Logger; public class GameRules { @@ -15,42 +15,42 @@ public static final int DEFAULT_RANDOM_TICK_SPEED = 3; static final Logger LOGGER = LogUtils.getLogger(); public static final Map, GameRules.Type> GAME_RULE_TYPES = Maps.newTreeMap(Comparator.comparing(entry -> entry.id)); -@@ -87,10 +_,10 @@ +@@ -88,10 +_,10 @@ "sendCommandFeedback", GameRules.Category.CHAT, GameRules.BooleanValue.create(true) ); public static final GameRules.Key RULE_REDUCEDDEBUGINFO = register( - "reducedDebugInfo", GameRules.Category.MISC, GameRules.BooleanValue.create(false, (server, value) -> { + "reducedDebugInfo", GameRules.Category.MISC, GameRules.BooleanValue.create(false, (level, value) -> { // Paper - rename param to match changes - byte b = (byte)(value.get() ? 22 : 23); + byte b = value.get() ? EntityEvent.REDUCED_DEBUG_INFO : EntityEvent.FULL_DEBUG_INFO; - for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { + for (ServerPlayer serverPlayer : level.players()) { serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, b)); } }) -@@ -114,8 +_,8 @@ - "doWeatherCycle", GameRules.Category.UPDATES, GameRules.BooleanValue.create(!SharedConstants.DEBUG_WORLD_RECREATE) - ); - public static final GameRules.Key RULE_LIMITED_CRAFTING = register( -- "doLimitedCrafting", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (server, value) -> { -- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { -+ "doLimitedCrafting", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (level, value) -> { // Paper - rename param to match changes -+ for (ServerPlayer serverPlayer : level.players()) { - serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LIMITED_CRAFTING, value.get() ? 1.0F : 0.0F)); - } - }) -@@ -139,8 +_,8 @@ - "doInsomnia", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true) - ); - public static final GameRules.Key RULE_DO_IMMEDIATE_RESPAWN = register( -- "doImmediateRespawn", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (server, value) -> { -- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { -+ "doImmediateRespawn", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (level, value) -> { // Paper - rename param to match changes -+ for (ServerPlayer serverPlayer : level.players()) { - serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.IMMEDIATE_RESPAWN, value.get() ? 1.0F : 0.0F)); - } - }) -@@ -211,13 +_,13 @@ +@@ -119,8 +_,8 @@ + GameRules.Category.PLAYER, + GameRules.BooleanValue.create( + false, +- (server, value) -> { +- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { ++ (level, value) -> { // Paper - rename param to match changes ++ for (ServerPlayer serverPlayer : level.players()) { // Paper - per world gamerules + serverPlayer.connection + .send( + new ClientboundGameEventPacket( +@@ -154,8 +_,8 @@ + GameRules.Category.PLAYER, + GameRules.BooleanValue.create( + false, +- (server, value) -> { +- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { ++ (level, value) -> { // Paper - rename param to match changes ++ for (ServerPlayer serverPlayer : level.players()) { // Paper - per world gamerules + serverPlayer.connection + .send( + new ClientboundGameEventPacket( +@@ -232,13 +_,13 @@ public static final GameRules.Key RULE_MINECART_MAX_SPEED = register( "minecartMaxSpeed", GameRules.Category.MISC, @@ -66,7 +66,7 @@ ServerWaypointManager waypointManager = level.getWaypointManager(); if (value.get()) { level.players().forEach(waypointManager::updatePlayer); -@@ -231,7 +_,11 @@ +@@ -252,7 +_,11 @@ "allowEnteringNetherUsingPortals", GameRules.Category.MISC, GameRules.BooleanValue.create(true) ); public static final GameRules.Key RULE_SPAWN_MONSTERS = register( @@ -79,7 +79,7 @@ ); public static final GameRules.Key RULE_COMMAND_BLOCKS_ENABLED = register( "commandBlocksEnabled", GameRules.Category.MISC, GameRules.BooleanValue.create(true) -@@ -241,6 +_,7 @@ +@@ -262,6 +_,7 @@ ); private final Map, GameRules.Value> rules; private final FeatureFlagSet enabledFeatures; @@ -87,7 +87,7 @@ public static > GameRules.Type getType(GameRules.Key key) { return (GameRules.Type)GAME_RULE_TYPES.get(key); -@@ -288,10 +_,21 @@ +@@ -309,10 +_,21 @@ private GameRules(Map, GameRules.Value> rules, FeatureFlagSet enabledFeatures) { this.rules = rules; this.enabledFeatures = enabledFeatures; @@ -110,7 +110,7 @@ if (value == null) { throw new IllegalArgumentException("Tried to access invalid game rule"); } else { -@@ -332,13 +_,13 @@ +@@ -353,13 +_,13 @@ } } @@ -128,7 +128,7 @@ } public boolean getBoolean(GameRules.Key key) { -@@ -353,7 +_,7 @@ +@@ -374,7 +_,7 @@ private boolean value; private static GameRules.Type create( @@ -137,7 +137,7 @@ ) { return new GameRules.Type<>( BoolArgumentType::bool, -@@ -365,7 +_,7 @@ +@@ -386,7 +_,7 @@ ); } @@ -146,7 +146,7 @@ return new GameRules.Type<>( BoolArgumentType::bool, type -> new GameRules.BooleanValue(type, defaultValue), -@@ -386,17 +_,21 @@ +@@ -407,17 +_,21 @@ } @Override @@ -172,7 +172,7 @@ } @Override -@@ -425,9 +_,9 @@ +@@ -446,9 +_,9 @@ } @Override @@ -184,7 +184,7 @@ } } -@@ -465,7 +_,7 @@ +@@ -486,7 +_,7 @@ public static class IntegerValue extends GameRules.Value { private int value; @@ -193,7 +193,7 @@ return new GameRules.Type<>( IntegerArgumentType::integer, type -> new GameRules.IntegerValue(type, defaultValue), -@@ -477,7 +_,7 @@ +@@ -498,7 +_,7 @@ } static GameRules.Type create( @@ -202,7 +202,7 @@ ) { return new GameRules.Type<>( () -> IntegerArgumentType.integer(min, max), -@@ -499,17 +_,21 @@ +@@ -520,17 +_,21 @@ } @Override @@ -228,7 +228,7 @@ } @Override -@@ -560,13 +_,17 @@ +@@ -581,13 +_,17 @@ } @Override @@ -248,7 +248,7 @@ final String id; private final GameRules.Category category; -@@ -606,7 +_,7 @@ +@@ -627,7 +_,7 @@ public static class Type> { final Supplier> argument; private final Function, T> constructor; @@ -257,7 +257,7 @@ private final GameRules.VisitorCaller visitorCaller; final Class valueClass; final FeatureFlagSet requiredFeatures; -@@ -614,7 +_,7 @@ +@@ -635,7 +_,7 @@ Type( Supplier> argument, Function, T> constructor, @@ -266,7 +266,7 @@ GameRules.VisitorCaller visitorCaller, Class valueClass, FeatureFlagSet requiredFeatures -@@ -642,6 +_,12 @@ +@@ -663,6 +_,12 @@ public FeatureFlagSet requiredFeatures() { return this.requiredFeatures; } @@ -279,7 +279,7 @@ } public abstract static class Value> { -@@ -651,16 +_,16 @@ +@@ -672,16 +_,16 @@ this.type = type; } @@ -303,7 +303,7 @@ } } -@@ -679,7 +_,7 @@ +@@ -700,7 +_,7 @@ protected abstract T copy(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch index da8c2f8920fa..6aba2789a38b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -84,6 +_,16 @@ +@@ -85,6 +_,16 @@ import net.minecraft.world.scores.Scoreboard; import org.apache.commons.lang3.mutable.MutableBoolean; @@ -17,7 +17,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("overworld")); -@@ -126,6 +_,57 @@ +@@ -127,6 +_,57 @@ private final EnvironmentAttributeSystem environmentAttributes; private long subTickCount; @@ -75,7 +75,7 @@ protected Level( WritableLevelData levelData, ResourceKey dimension, -@@ -134,8 +_,24 @@ +@@ -135,8 +_,24 @@ boolean isClientSide, boolean isDebug, long biomeZoomSeed, @@ -101,7 +101,7 @@ this.levelData = levelData; this.dimensionTypeRegistration = dimensionTypeRegistration; this.dimension = dimension; -@@ -150,6 +_,46 @@ +@@ -151,6 +_,46 @@ this.environmentAttributes = new EnvironmentAttributeSystem(dimensionTypeRegistration, registryAccess, this.biomeManager); } @@ -148,7 +148,7 @@ @Override public boolean isClientSide() { return this.isClientSide; -@@ -161,8 +_,15 @@ +@@ -162,8 +_,15 @@ return null; } @@ -165,7 +165,7 @@ } public static boolean isInSpawnableBounds(BlockPos pos) { -@@ -170,21 +_,86 @@ +@@ -171,21 +_,86 @@ } private static boolean isInWorldBoundsHorizontal(BlockPos pos) { @@ -257,7 +257,7 @@ @Nullable @Override -@@ -204,6 +_,22 @@ +@@ -205,6 +_,22 @@ @Override public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags, int recursionLeft) { @@ -280,7 +280,7 @@ if (this.isOutsideBuildHeight(pos)) { return false; } else if (!this.isClientSide() && this.isDebug()) { -@@ -211,11 +_,31 @@ +@@ -212,11 +_,31 @@ } else { LevelChunk chunkAt = this.getChunkAt(pos); Block block = state.getBlock(); @@ -312,7 +312,7 @@ if (blockState1 == state) { if (blockState != blockState1) { this.setBlocksDirty(pos, blockState, blockState1); -@@ -243,12 +_,68 @@ +@@ -244,12 +_,68 @@ this.updatePOIOnBlockStateChange(pos, blockState, blockState1); } @@ -381,12 +381,12 @@ public void updatePOIOnBlockStateChange(BlockPos pos, BlockState oldState, BlockState newState) { } -@@ -265,13 +_,31 @@ +@@ -266,13 +_,31 @@ return false; } else { FluidState fluidState = this.getFluidState(pos); - if (!(blockState.getBlock() instanceof BaseFireBlock)) { -- this.levelEvent(2001, pos, Block.getId(blockState)); +- this.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, Block.getId(blockState)); + // Paper start - BlockDestroyEvent; while the above removeBlock method looks very similar + // they are NOT used with same intent and the above should not fire this event. The above method is more of a BlockSetToAirEvent, + // it doesn't imply destruction of a block that plays a sound effect / drops an item. @@ -415,8 +415,8 @@ + blockState.getBlock().popExperience((ServerLevel) this, pos, xp, entity); // Paper - Properly handle xp dropping; custom amount } - boolean flag = this.setBlock(pos, fluidState.createLegacyBlock(), 3, recursionLeft); -@@ -337,10 +_,18 @@ + boolean flag = this.setBlock(pos, fluidState.createLegacyBlock(), Block.UPDATE_ALL, recursionLeft); +@@ -338,10 +_,18 @@ @Override public BlockState getBlockState(BlockPos pos) { @@ -436,7 +436,7 @@ return chunk.getBlockState(pos); } } -@@ -453,31 +_,47 @@ +@@ -454,31 +_,47 @@ this.pendingBlockEntityTickers.clear(); } @@ -492,7 +492,7 @@ public boolean shouldTickDeath(Entity entity) { return true; -@@ -602,6 +_,12 @@ +@@ -603,6 +_,12 @@ @Nullable @Override public BlockEntity getBlockEntity(BlockPos pos) { @@ -505,7 +505,7 @@ if (this.isOutsideBuildHeight(pos)) { return null; } else { -@@ -614,6 +_,12 @@ +@@ -615,6 +_,12 @@ public void setBlockEntity(BlockEntity blockEntity) { BlockPos blockPos = blockEntity.getBlockPos(); if (!this.isOutsideBuildHeight(blockPos)) { @@ -518,7 +518,7 @@ this.getChunkAt(blockPos).addAndRegisterBlockEntity(blockEntity); } } -@@ -1029,7 +_,8 @@ +@@ -1030,7 +_,8 @@ BLOCK("block"), MOB("mob"), TNT("tnt"), diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BambooSaplingBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BambooSaplingBlock.java.patch index 82f3adbbac62..e26417670652 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BambooSaplingBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BambooSaplingBlock.java.patch @@ -13,7 +13,7 @@ } protected void growBamboo(Level level, BlockPos state) { -- level.setBlock(state.above(), Blocks.BAMBOO.defaultBlockState().setValue(BambooStalkBlock.LEAVES, BambooLeaves.SMALL), 3); +- level.setBlock(state.above(), Blocks.BAMBOO.defaultBlockState().setValue(BambooStalkBlock.LEAVES, BambooLeaves.SMALL), Block.UPDATE_ALL); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, state, state.above(), Blocks.BAMBOO.defaultBlockState().setValue(BambooStalkBlock.LEAVES, BambooLeaves.SMALL), 3); // CraftBukkit - BlockSpreadEvent } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch index e34999376076..ce188d7f0471 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch @@ -41,8 +41,8 @@ } else if (blockState.is(Blocks.BAMBOO) && blockState.getValue(LEAVES) != BambooLeaves.NONE) { bambooLeaves = BambooLeaves.LARGE; if (blockState1.is(Blocks.BAMBOO)) { -- level.setBlock(pos.below(), blockState.setValue(LEAVES, BambooLeaves.SMALL), 3); -- level.setBlock(blockPos, blockState1.setValue(LEAVES, BambooLeaves.NONE), 3); +- level.setBlock(pos.below(), blockState.setValue(LEAVES, BambooLeaves.SMALL), Block.UPDATE_ALL); +- level.setBlock(blockPos, blockState1.setValue(LEAVES, BambooLeaves.NONE), Block.UPDATE_ALL); + // CraftBukkit start - moved down + // level.setBlock(pos.below(), blockState.setValue(LEAVES, BambooLeaves.SMALL), 3); + // level.setBlock(blockPos, blockState1.setValue(LEAVES, BambooLeaves.NONE), 3); @@ -54,7 +54,7 @@ int i = state.getValue(AGE) != 1 && !blockState1.is(Blocks.BAMBOO) ? 0 : 1; - int i1 = (age < 11 || !(random.nextFloat() < 0.25F)) && age != 15 ? 0 : 1; -- level.setBlock(pos.above(), this.defaultBlockState().setValue(AGE, i).setValue(LEAVES, bambooLeaves).setValue(STAGE, i1), 3); +- level.setBlock(pos.above(), this.defaultBlockState().setValue(AGE, i).setValue(LEAVES, bambooLeaves).setValue(STAGE, i1), Block.UPDATE_ALL); + int i1 = (age < level.paperConfig().maxGrowthHeight.bamboo.min || random.nextFloat() >= 0.25F) && age != (level.paperConfig().maxGrowthHeight.bamboo.max - 1) ? 0 : 1; // Paper - Configurable cactus/bamboo/reed growth height + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, pos.above(), this.defaultBlockState().setValue(AGE, i).setValue(LEAVES, bambooLeaves).setValue(STAGE, i1), 3)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch index 2a7628d98c0b..81437c45bd61 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch @@ -24,7 +24,7 @@ + // CraftBukkit end if (currentSignal != signalStrength) { BlockState blockState = this.setSignalForState(state, signalStrength); - level.setBlock(pos, blockState, 2); + level.setBlock(pos, blockState, Block.UPDATE_CLIENTS); @@ -142,7 +_,13 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch index be634ae10560..d8818f0b904d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch @@ -70,12 +70,12 @@ @@ -299,6 +_,11 @@ if (!level.isClientSide()) { BlockPos blockPos = pos.relative(state.getValue(FACING)); - level.setBlock(blockPos, state.setValue(PART, BedPart.HEAD), 3); + level.setBlock(blockPos, state.setValue(PART, BedPart.HEAD), Block.UPDATE_ALL); + // CraftBukkit start - SPIGOT-7315: Don't updated if we capture block states + if (level.captureBlockStates) { + return; + } + // CraftBukkit end level.updateNeighborsAt(pos, Blocks.AIR); - state.updateNeighbourShapes(level, pos, 3); + state.updateNeighbourShapes(level, pos, Block.UPDATE_ALL); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch index bdc23e46d443..d3b3ba927b8a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch @@ -81,7 +81,7 @@ + } + // CraftBukkit end Tilt tilt1 = state.getValue(TILT); - level.setBlock(pos, state.setValue(TILT, tilt), 2); + level.setBlock(pos, state.setValue(TILT, tilt), Block.UPDATE_CLIENTS); if (tilt.causesVibration() && tilt != tilt1) { level.gameEvent(null, GameEvent.BLOCK_CHANGE, pos); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ButtonBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ButtonBlock.java.patch index e982925a178f..245dc1efd101 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ButtonBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ButtonBlock.java.patch @@ -57,6 +57,6 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, flag), 3); + level.setBlock(pos, state.setValue(POWERED, flag), Block.UPDATE_ALL); this.updateNeighbours(state, level, pos); this.playSound(null, level, pos, flag); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch index 084fe6b742e5..a7aee271f08e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch @@ -27,7 +27,7 @@ + } + // Paper end BlockState blockState = state.setValue(AGE, 0); - level.setBlock(pos, blockState, 260); + level.setBlock(pos, blockState, Block.UPDATE_NONE); level.neighborChanged(blockState, blockPos, this, null, false); @@ -124,7 +_,8 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch index cb9c40d7d16b..c0319559ed1e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch @@ -43,4 +43,4 @@ + // Paper - move up level.gameEvent(player, GameEvent.EAT, pos); if (bitesValue < 6) { - level.setBlock(pos, state.setValue(BITES, bitesValue + 1), 3); + level.setBlock(pos, state.setValue(BITES, bitesValue + 1), Block.UPDATE_ALL); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch index 5d97e004d1a9..c5b619fdead2 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch @@ -20,6 +20,6 @@ + return; + } + // CraftBukkit end - level.setBlock(blockPos, state.setValue(BlockStateProperties.LIT, true), 11); + level.setBlock(blockPos, state.setValue(BlockStateProperties.LIT, true), Block.UPDATE_ALL_IMMEDIATE); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CauldronBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CauldronBlock.java.patch index 84db4f9fcc83..dd650a6c3c59 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CauldronBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CauldronBlock.java.patch @@ -31,7 +31,7 @@ + return; + } + // Paper end - Call CauldronLevelChangeEvent - level.levelEvent(1047, pos, 0); + level.levelEvent(LevelEvent.SOUND_DRIP_WATER_INTO_CAULDRON, pos, 0); } else if (fluid == Fluids.LAVA) { BlockState blockState = Blocks.LAVA_CAULDRON.defaultBlockState(); - level.setBlockAndUpdate(pos, blockState); @@ -41,6 +41,6 @@ + return; + } + // Paper end - Call CauldronLevelChangeEvent - level.levelEvent(1046, pos, 0); + level.levelEvent(LevelEvent.SOUND_DRIP_LAVA_INTO_CAULDRON, pos, 0); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch index cca4519239b1..da4211c122af 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch @@ -5,7 +5,7 @@ if (flag && allNeighborsEmpty(level, blockPos, null) && level.isEmptyBlock(pos.above(2))) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, this.defaultBlockState().setValue(AGE, ageValue), 2)) { // CraftBukkit - add event - level.setBlock(pos, ChorusPlantBlock.getStateWithConnections(level, pos, this.plant.defaultBlockState()), 2); + level.setBlock(pos, ChorusPlantBlock.getStateWithConnections(level, pos, this.plant.defaultBlockState()), Block.UPDATE_CLIENTS); this.placeGrownFlower(level, blockPos, ageValue); + } // CraftBukkit } else if (ageValue < 4) { @@ -23,7 +23,7 @@ } if (flag2) { - level.setBlock(pos, ChorusPlantBlock.getStateWithConnections(level, pos, this.plant.defaultBlockState()), 2); + level.setBlock(pos, ChorusPlantBlock.getStateWithConnections(level, pos, this.plant.defaultBlockState()), Block.UPDATE_CLIENTS); } else { + // CraftBukkit start - add event + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, this.defaultBlockState().setValue(AGE, 5), 2)) { @@ -43,15 +43,15 @@ } private void placeGrownFlower(Level level, BlockPos pos, int age) { -- level.setBlock(pos, this.defaultBlockState().setValue(AGE, age), 2); +- level.setBlock(pos, this.defaultBlockState().setValue(AGE, age), Block.UPDATE_CLIENTS); + // level.setBlock(pos, this.defaultBlockState().setValue(AGE, age), 2); // Paper - already done above in the event call - level.levelEvent(1033, pos, 0); + level.levelEvent(LevelEvent.SOUND_CHORUS_GROW, pos, 0); } private void placeDeadFlower(Level level, BlockPos pos) { -- level.setBlock(pos, this.defaultBlockState().setValue(AGE, 5), 2); +- level.setBlock(pos, this.defaultBlockState().setValue(AGE, 5), Block.UPDATE_CLIENTS); + // level.setBlock(pos, this.defaultBlockState().setValue(AGE, 5), 2); // Paper - already done above in the event call - level.levelEvent(1034, pos, 0); + level.levelEvent(LevelEvent.SOUND_CHORUS_DEATH, pos, 0); } @@ -261,6 +_,11 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch index 963613a8d5ee..e48da683f8f1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch @@ -8,7 +8,7 @@ + if (level.random.nextFloat() < (level.spigotConfig.cocoaModifier / (100.0F * 5))) { // Spigot - SPIGOT-7159: Better modifier resolution int ageValue = state.getValue(AGE); if (ageValue < 2) { -- level.setBlock(pos, state.setValue(AGE, ageValue + 1), 2); +- level.setBlock(pos, state.setValue(AGE, ageValue + 1), Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(AGE, ageValue + 1), 2); // CraftBukkit } } @@ -17,7 +17,7 @@ @Override public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) { -- level.setBlock(pos, state.setValue(AGE, state.getValue(AGE) + 1), 2); +- level.setBlock(pos, state.setValue(AGE, state.getValue(AGE) + 1), Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(AGE, state.getValue(AGE) + 1), 2); // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch index af8a2f18f945..8e9d308cadec 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch @@ -9,13 +9,13 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, false), 2); + level.setBlock(pos, state.setValue(POWERED, false), Block.UPDATE_CLIENTS); } else if (!poweredValue && shouldTurnOn) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(level, pos, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, true), 2); + level.setBlock(pos, state.setValue(POWERED, true), Block.UPDATE_CLIENTS); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch index 5c7131c155f4..70d5463e279a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch @@ -9,7 +9,7 @@ + return InteractionResult.PASS; + } + // Paper end - level.levelEvent(1500, pos, state != blockState ? 1 : 0); + level.levelEvent(LevelEvent.COMPOSTER_FILL, pos, state != blockState ? 1 : 0); player.awardStat(Stats.ITEM_USED.get(stack.getItem())); stack.consume(1, player); @@ -277,7 +_,19 @@ @@ -86,7 +86,7 @@ + return null; + } + // Paper end - level.setBlock(pos, blockState, 3); + level.setBlock(pos, blockState, Block.UPDATE_ALL); level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(entity, blockState)); if (i == 7) { @@ -357,13 +_,14 @@ @@ -123,7 +123,7 @@ + return; + } + // Paper end - Add CompostItemEvent and EntityCompostItemEvent - this.level.levelEvent(1500, this.pos, blockState != this.state ? 1 : 0); + this.level.levelEvent(LevelEvent.COMPOSTER_FILL, this.pos, blockState != this.state ? 1 : 0); this.removeItemNoUpdate(0); } @@ -435,6 +_,7 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ConcretePowderBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ConcretePowderBlock.java.patch index 3c8335c0a587..b1a4d935350f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ConcretePowderBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ConcretePowderBlock.java.patch @@ -4,7 +4,7 @@ @Override public void onLand(Level level, BlockPos pos, BlockState state, BlockState replaceableState, FallingBlockEntity fallingBlock) { if (shouldSolidify(level, pos, replaceableState)) { -- level.setBlock(pos, this.concrete.defaultBlockState(), 3); +- level.setBlock(pos, this.concrete.defaultBlockState(), Block.UPDATE_ALL); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, this.concrete.defaultBlockState(), 3); // CraftBukkit } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch index a2a880ee4b87..04e4b761cd90 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch @@ -18,7 +18,7 @@ + return InteractionResult.PASS; + } level.playSound(null, pos, SoundEvents.COPPER_GOLEM_BECOME_STATUE, SoundSource.BLOCKS); -- level.setBlock(pos, state.setValue(POSE, state.getValue(POSE).getNextPose()), 3); +- level.setBlock(pos, state.setValue(POSE, state.getValue(POSE).getNextPose()), Block.UPDATE_ALL); + level.setBlock(pos, newState, 3); level.gameEvent(player, GameEvent.BLOCK_CHANGE, pos); + return InteractionResult.SUCCESS; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CoralBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CoralBlock.java.patch index 87d67142fb03..685f6f642edc 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CoralBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CoralBlock.java.patch @@ -9,6 +9,6 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, this.deadBlock.defaultBlockState(), 2); + level.setBlock(pos, this.deadBlock.defaultBlockState(), Block.UPDATE_CLIENTS); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CoralFanBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CoralFanBlock.java.patch index 99203da0ae6b..107d539fbbf9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CoralFanBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CoralFanBlock.java.patch @@ -9,6 +9,6 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, false), 2); + level.setBlock(pos, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, false), Block.UPDATE_CLIENTS); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CoralPlantBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CoralPlantBlock.java.patch index 92526024d181..d898a4c15b35 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CoralPlantBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CoralPlantBlock.java.patch @@ -9,6 +9,6 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, false), 2); + level.setBlock(pos, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, false), Block.UPDATE_CLIENTS); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CoralWallFanBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CoralWallFanBlock.java.patch index 896584437270..e21227fb17c6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CoralWallFanBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CoralWallFanBlock.java.patch @@ -9,6 +9,6 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, false).setValue(FACING, state.getValue(FACING)), 2); + level.setBlock(pos, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, false).setValue(FACING, state.getValue(FACING)), Block.UPDATE_CLIENTS); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch index dbd5408e23c6..532af18fbb92 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch @@ -12,7 +12,7 @@ + itemStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getResult()); + // CraftBukkit end if (itemStack.isEmpty()) { - level.levelEvent(1050, pos, 0); + level.levelEvent(LevelEvent.SOUND_CRAFTER_FAIL, pos, 0); } else { @@ -186,7 +_,25 @@ Container containerAt = HopperBlockEntity.getContainerAt(level, pos.relative(direction)); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch index 5d3e4d2b479e..587f3aac91c7 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch @@ -5,7 +5,7 @@ if (age < this.getMaxAge()) { float growthSpeed = getGrowthSpeed(this, level, pos); - if (random.nextInt((int)(25.0F / growthSpeed) + 1) == 0) { -- level.setBlock(pos, this.getStateForAge(age + 1), 2); +- level.setBlock(pos, this.getStateForAge(age + 1), Block.UPDATE_CLIENTS); + // Spigot start + int modifier = 100; + if (this == Blocks.BEETROOTS) { @@ -32,7 +32,7 @@ public void growCrops(Level level, BlockPos pos, BlockState state) { int min = Math.min(this.getMaxAge(), this.getAge(state) + this.getBonemealAgeIncrease(level)); -- level.setBlock(pos, this.getStateForAge(min), 2); +- level.setBlock(pos, this.getStateForAge(min), Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, this.getStateForAge(min), 2); // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch index 1857abf850f5..e0cfede41022 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch @@ -5,6 +5,6 @@ i = Mth.clamp(i, 0, 15); if (state.getValue(POWER) != i) { + i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(level, pos, state.getValue(DaylightDetectorBlock.POWER), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent - level.setBlock(pos, state.setValue(POWER, i), 3); + level.setBlock(pos, state.setValue(POWER, i), Block.UPDATE_ALL); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch index 491493f97239..1c008e5b842c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch @@ -9,6 +9,6 @@ + return; + } + // CraftBukkit end - level.setBlock(blockPos, state.setValue(CRACKED, true), 260); + level.setBlock(blockPos, state.setValue(CRACKED, true), Block.UPDATE_NONE); level.destroyBlock(blockPos, true, projectile); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch index b8c6dc848f13..865623c40a09 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch @@ -32,4 +32,4 @@ + // CraftBukkit end if (flag && !poweredValue) { BlockState blockState = state.setValue(POWERED, true); - level.setBlock(pos, blockState, 3); + level.setBlock(pos, blockState, Block.UPDATE_ALL); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DiodeBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DiodeBlock.java.patch index 94ed51c9c84a..df692dfea0dc 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DiodeBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DiodeBlock.java.patch @@ -9,13 +9,13 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, false), 2); + level.setBlock(pos, state.setValue(POWERED, false), Block.UPDATE_CLIENTS); } else if (!poweredValue) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(level, pos, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, true), 2); + level.setBlock(pos, state.setValue(POWERED, true), Block.UPDATE_CLIENTS); if (!shouldTurnOn) { level.scheduleTick(pos, this, this.getDelay(state), TickPriority.VERY_HIGH); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DispenserBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DispenserBlock.java.patch index 0a207b1f082b..190bf71c49a0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DispenserBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DispenserBlock.java.patch @@ -15,7 +15,7 @@ int randomSlot = dispenserBlockEntity.getRandomSlot(level.random); if (randomSlot < 0) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFailedDispenseEvent(level, pos)) { // Paper - Add BlockFailedDispenseEvent - level.levelEvent(1001, pos, 0); + level.levelEvent(LevelEvent.SOUND_DISPENSER_FAIL, pos, 0); level.gameEvent(GameEvent.BLOCK_ACTIVATE, pos, GameEvent.Context.of(dispenserBlockEntity.getBlockState())); + } // Paper - Add BlockFailedDispenseEvent } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DriedGhastBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DriedGhastBlock.java.patch index 2cef4d9a1642..c7780f86fdcc 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DriedGhastBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DriedGhastBlock.java.patch @@ -10,7 +10,7 @@ + } + // Paper end - Call BlockGrowEvent level.playSound(null, pos, SoundEvents.DRIED_GHAST_TRANSITION, SoundSource.BLOCKS, 1.0F, 1.0F); -- level.setBlock(pos, state.setValue(HYDRATION_LEVEL, this.getHydrationLevel(state) + 1), 2); +- level.setBlock(pos, state.setValue(HYDRATION_LEVEL, this.getHydrationLevel(state) + 1), Block.UPDATE_CLIENTS); + // level.setBlock(pos, state.setValue(HYDRATION_LEVEL, this.getHydrationLevel(state) + 1), 2); // Paper - handled above level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(state)); } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DropperBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DropperBlock.java.patch index e1fc914b4794..97d52b1a403e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DropperBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DropperBlock.java.patch @@ -5,7 +5,7 @@ int randomSlot = dispenserBlockEntity.getRandomSlot(level.random); if (randomSlot < 0) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFailedDispenseEvent(level, pos)) // Paper - Add BlockFailedDispenseEvent - level.levelEvent(1001, pos, 0); + level.levelEvent(LevelEvent.SOUND_DISPENSER_FAIL, pos, 0); } else { ItemStack item = dispenserBlockEntity.getItem(randomSlot); @@ -61,10 +_,29 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch index acdb36a41ee3..0f801757a1dc 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch @@ -8,13 +8,13 @@ + if (moistureValue == 0 && level.paperConfig().tickRates.dryFarmland != 1 && (level.paperConfig().tickRates.dryFarmland < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % level.paperConfig().tickRates.dryFarmland != 0)) { return; } // Paper - Configurable random tick rates for blocks if (!isNearWater(level, pos) && !level.isRainingAt(pos.above())) { if (moistureValue > 0) { -- level.setBlock(pos, state.setValue(MOISTURE, moistureValue - 1), 2); +- level.setBlock(pos, state.setValue(MOISTURE, moistureValue - 1), Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(level, pos, state.setValue(MOISTURE, moistureValue - 1), 2); // CraftBukkit } else if (!shouldMaintainFarmland(level, pos)) { turnToDirt(null, state, level, pos); } } else if (moistureValue < 7) { -- level.setBlock(pos, state.setValue(MOISTURE, 7), 2); +- level.setBlock(pos, state.setValue(MOISTURE, 7), Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(level, pos, state.setValue(MOISTURE, 7), 2); // CraftBukkit } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FenceGateBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FenceGateBlock.java.patch index 056af923641d..c9a1747db626 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FenceGateBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FenceGateBlock.java.patch @@ -16,5 +16,5 @@ + } + // CraftBukkit end if (state.getValue(POWERED) != hasNeighborSignal) { - level.setBlock(pos, state.setValue(POWERED, hasNeighborSignal).setValue(OPEN, hasNeighborSignal), 2); + level.setBlock(pos, state.setValue(POWERED, hasNeighborSignal).setValue(OPEN, hasNeighborSignal), Block.UPDATE_CLIENTS); if (state.getValue(OPEN) != hasNeighborSignal) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch index 3a48b0d8d0c1..9b166cf09b4b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch @@ -90,7 +90,7 @@ if (i5 > 0 && random.nextInt(i4) <= i5 && (!level.isRaining() || !this.isNearRain(level, mutableBlockPos))) { int min1 = Math.min(15, ageValue + random.nextInt(5) / 4); -- level.setBlock(mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), 3); +- level.setBlock(mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), Block.UPDATE_ALL); + // CraftBukkit start - Call to stop spread of fire + if (!level.getBlockState(mutableBlockPos).is(Blocks.FIRE)) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, mutableBlockPos, pos).isCancelled()) { @@ -128,7 +128,7 @@ + // CraftBukkit end if (random.nextInt(age + 10) < 5 && !level.isRainingAt(pos)) { int min = Math.min(age + random.nextInt(5) / 4, 15); - level.setBlock(pos, this.getStateWithAge(level, pos, min), 3); + level.setBlock(pos, this.getStateWithAge(level, pos, min), Block.UPDATE_ALL); } else { - level.removeBlock(pos, false); + if (!blockState.is(Blocks.TNT)) level.removeBlock(pos, false); // Paper - TNTPrimeEvent; We might be cancelling it below, move the setAir down diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch index c98f6d64e572..9d85e5f8b437 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -16,7 +16,7 @@ + return InteractionResult.CONSUME; + } + // Paper end - Add PlayerFlowerPotManipulateEvent - level.setBlock(pos, blockState, 3); + level.setBlock(pos, blockState, Block.UPDATE_ALL); level.gameEvent(player, GameEvent.BLOCK_CHANGE, pos); player.awardStat(Stats.POT_FLOWER); @@ -80,6 +_,18 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/HoneyBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/HoneyBlock.java.patch index 48182581129f..56d52b467968 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/HoneyBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/HoneyBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/HoneyBlock.java +++ b/net/minecraft/world/level/block/HoneyBlock.java -@@ -61,6 +_,7 @@ +@@ -62,6 +_,7 @@ @Override protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean pastEdges) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch index a4cd7ca3c7e8..b477c022c3c0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch @@ -94,6 +94,6 @@ + return; + } + // CraftBukkit end - level.levelEvent(1047, pos, 0); + level.levelEvent(LevelEvent.SOUND_DRIP_WATER_INTO_CAULDRON, pos, 0); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch index 9259b78d6566..a2e5f2f1ce5d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch @@ -40,7 +40,7 @@ + } + } + // Paper end - Call BlockRedstoneEvent properly - level.setBlock(pos, state.setValue(POWERED, powered), 3); + level.setBlock(pos, state.setValue(POWERED, powered), Block.UPDATE_ALL); updateBelow(level, pos, state); } @@ -244,8 +_,7 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LightningRodBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LightningRodBlock.java.patch index b61914b8d30d..9d7c7a1f2797 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LightningRodBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LightningRodBlock.java.patch @@ -16,6 +16,6 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, true), 3); + level.setBlock(pos, state.setValue(POWERED, true), Block.UPDATE_ALL); this.updateNeighbours(state, level, pos); level.scheduleTick(pos, this, 8); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch index 804fee5220bc..ea4a2323a87d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch @@ -4,7 +4,7 @@ level.getChunk(pos.pos()).markPosForPostprocessing(pos.pos()); } -- return level.setBlock(pos.pos(), stateForPlacement, 2); +- return level.setBlock(pos.pos(), stateForPlacement, Block.UPDATE_CLIENTS); + return org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos.source(), pos.pos(), stateForPlacement, 2, true); // CraftBukkit } else { return false; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/MushroomBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/MushroomBlock.java.patch index 70703637ab3b..8c29da0b812b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/MushroomBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/MushroomBlock.java.patch @@ -21,7 +21,7 @@ } if (level.isEmptyBlock(blockPos1) && state.canSurvive(level, blockPos1)) { -- level.setBlock(blockPos1, state, 2); +- level.setBlock(blockPos1, state, Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, sourcePos, blockPos1, state, 2); // CraftBukkit // Paper - Use correct source for mushroom block spread event } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/NetherWartBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/NetherWartBlock.java.patch index 4432a695656a..cf76dc52a63f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/NetherWartBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/NetherWartBlock.java.patch @@ -7,7 +7,7 @@ - if (ageValue < 3 && random.nextInt(10) == 0) { + if (ageValue < 3 && random.nextFloat() < (level.spigotConfig.wartModifier / (100.0F * 10))) { // Spigot - SPIGOT-7159: Better modifier resolution state = state.setValue(AGE, ageValue + 1); -- level.setBlock(pos, state, 2); +- level.setBlock(pos, state, Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state, 2); // CraftBukkit } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/NoteBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/NoteBlock.java.patch index 1fb8d7b1c289..db0d3e70e01e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/NoteBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/NoteBlock.java.patch @@ -28,14 +28,14 @@ + state = level.getBlockState(pos); // CraftBukkit - SPIGOT-5617: update in case changed in event } - level.setBlock(pos, state.setValue(POWERED, hasNeighborSignal), 3); + level.setBlock(pos, state.setValue(POWERED, hasNeighborSignal), Block.UPDATE_ALL); @@ -115,7 +_,7 @@ @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { if (!level.isClientSide()) { - state = state.cycle(NOTE); + if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableNoteblockUpdates) state = state.cycle(NoteBlock.NOTE); // Paper - prevent noteblock note from updating - level.setBlock(pos, state, 3); + level.setBlock(pos, state, Block.UPDATE_ALL); this.playNote(player, state, level, pos); player.awardStat(Stats.TUNE_NOTEBLOCK); @@ -139,9 +_,13 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ObserverBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ObserverBlock.java.patch index 9def2f110b65..88732b7a4a91 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ObserverBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ObserverBlock.java.patch @@ -9,13 +9,13 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, false), 2); + level.setBlock(pos, state.setValue(POWERED, false), Block.UPDATE_CLIENTS); } else { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(level, pos, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, true), 2); + level.setBlock(pos, state.setValue(POWERED, true), Block.UPDATE_CLIENTS); level.scheduleTick(pos, this, 2); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch index be0e96ce8513..ec52a7b6e9f5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch @@ -21,8 +21,8 @@ int min = Math.min(state.getValue(AGE) + ageIncrement, 4); if (this.canGrow(level, pos, state, min)) { BlockState blockState = state.setValue(AGE, min); -- level.setBlock(pos, blockState, 2); +- level.setBlock(pos, blockState, Block.UPDATE_CLIENTS); + if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, blockState, 2)) return; // Paper if (isDouble(min)) { - level.setBlock(pos.above(), blockState.setValue(HALF, DoubleBlockHalf.UPPER), 3); + level.setBlock(pos.above(), blockState.setValue(HALF, DoubleBlockHalf.UPPER), Block.UPDATE_ALL); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch index b3505974a391..1600c0c27a33 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch @@ -29,7 +29,7 @@ + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, fluidAboveStalactite.get().pos, blockState, 3)) { // Paper - Call BlockFormEvent Block.pushEntitiesUp(fluidAboveStalactite.get().sourceState, blockState, level, fluidAboveStalactite.get().pos); level.gameEvent(GameEvent.BLOCK_CHANGE, fluidAboveStalactite.get().pos, GameEvent.Context.of(blockState)); - level.levelEvent(1504, blockPos, 0); + level.levelEvent(LevelEvent.DRIPSTONE_DRIP, blockPos, 0); + } // Paper - Call BlockFormEvent } else { BlockPos blockPos1 = findFillableCauldronBelowStalactiteTip(level, blockPos, fluid); @@ -50,7 +50,7 @@ .setValue(TIP_DIRECTION, direction) .setValue(THICKNESS, thickness) .setValue(WATERLOGGED, level.getFluidState(pos).getType() == Fluids.WATER); -- level.setBlock(pos, blockState, 3); +- level.setBlock(pos, blockState, Block.UPDATE_ALL); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, pos, blockState, 3); // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PoweredRailBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PoweredRailBlock.java.patch index 6662416ba62d..dcc5b44fbbe8 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PoweredRailBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PoweredRailBlock.java.patch @@ -11,6 +11,6 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, flag), 3); + level.setBlock(pos, state.setValue(POWERED, flag), Block.UPDATE_ALL); level.updateNeighborsAt(pos.below(), this); if (state.getValue(SHAPE).isSlope()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PumpkinBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PumpkinBlock.java.patch index 185e84d1ab33..3b1123b07c12 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PumpkinBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PumpkinBlock.java.patch @@ -40,5 +40,5 @@ + } + // Paper end - Add PlayerShearBlockEvent level.playSound(null, pos, SoundEvents.PUMPKIN_CARVE, SoundSource.BLOCKS, 1.0F, 1.0F); - level.setBlock(pos, Blocks.CARVED_PUMPKIN.defaultBlockState().setValue(CarvedPumpkinBlock.FACING, direction1), 11); + level.setBlock(pos, Blocks.CARVED_PUMPKIN.defaultBlockState().setValue(CarvedPumpkinBlock.FACING, direction1), Block.UPDATE_ALL_IMMEDIATE); stack.hurtAndBreak(1, player, hand.asEquipmentSlot()); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch index 1a9dbf420d97..8b4e8f8001fd 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch @@ -28,7 +28,7 @@ @@ -331,10 +_,15 @@ this.state = this.state.setValue(this.block.getShapeProperty(), railShape); if (alwaysPlace || this.level.getBlockState(this.pos) != this.state) { - this.level.setBlock(this.pos, this.state, 3); + this.level.setBlock(this.pos, this.state, Block.UPDATE_ALL); + // Paper start - Fix some rails connecting improperly + if (!this.isValid()) { + return this; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RedStoneOreBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RedStoneOreBlock.java.patch index 1d5a054a2f03..43b482cd10e6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RedStoneOreBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RedStoneOreBlock.java.patch @@ -52,7 +52,7 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(LIT, true), 3); + level.setBlock(pos, state.setValue(LIT, true), Block.UPDATE_ALL); } } @@ -80,6 +_,11 @@ @@ -64,7 +64,7 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(LIT, false), 3); + level.setBlock(pos, state.setValue(LIT, false), Block.UPDATE_ALL); } } @@ -87,9 +_,17 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneLampBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneLampBlock.java.patch index 32b4488b6dfc..40638c1dbbf1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneLampBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneLampBlock.java.patch @@ -9,7 +9,7 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.cycle(LIT), 2); + level.setBlock(pos, state.cycle(LIT), Block.UPDATE_CLIENTS); } } @@ -50,6 +_,11 @@ @@ -21,6 +21,6 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.cycle(LIT), 2); + level.setBlock(pos, state.cycle(LIT), Block.UPDATE_CLIENTS); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch index af1fbe9bc532..86fdd6576331 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch @@ -46,9 +46,9 @@ + } + } + // CraftBukkit end - level.setBlock(pos, state.setValue(LIT, false), 3); + level.setBlock(pos, state.setValue(LIT, false), Block.UPDATE_ALL); if (isToggledTooFrequently(level, pos, true)) { - level.levelEvent(1502, pos, 0); + level.levelEvent(LevelEvent.REDSTONE_TORCH_BURNOUT, pos, 0); @@ -87,6 +_,15 @@ } } @@ -62,7 +62,7 @@ + } + } + // CraftBukkit end - level.setBlock(pos, state.setValue(LIT, true), 3); + level.setBlock(pos, state.setValue(LIT, true), Block.UPDATE_ALL); } } @@ -124,7 +_,12 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SaplingBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SaplingBlock.java.patch index 6ebe3a62cc08..d6efefbb6639 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SaplingBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SaplingBlock.java.patch @@ -19,7 +19,7 @@ } @@ -53,7 +_,34 @@ if (state.getValue(STAGE) == 0) { - level.setBlock(pos, state.cycle(STAGE), 260); + level.setBlock(pos, state.cycle(STAGE), Block.UPDATE_NONE); } else { - this.treeGrower.growTree(level, level.getChunkSource().getGenerator(), pos, state, random); + // CraftBukkit start diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SculkBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SculkBlock.java.patch index f17c4e7aa69a..cc84c14624e5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SculkBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SculkBlock.java.patch @@ -4,7 +4,7 @@ if (random.nextInt(growthSpawnCost) < charge) { BlockPos blockPos = pos1.above(); BlockState randomGrowthState = this.getRandomGrowthState(level, blockPos, random, spreader.isWorldGeneration()); -- level.setBlock(blockPos, randomGrowthState, 3); +- level.setBlock(blockPos, randomGrowthState, Block.UPDATE_ALL); + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, randomGrowthState, 3)) { // CraftBukkit - Call BlockSpreadEvent level.playSound(null, pos1, randomGrowthState.getSoundType().getPlaceSound(), SoundSource.BLOCKS, 1.0F, 1.0F); + } // CraftBukkit - Call BlockSpreadEvent diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch index f251ca822a48..20d1353b1c5c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch @@ -37,7 +37,7 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.COOLDOWN).setValue(POWER, 0), 3); + level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.COOLDOWN).setValue(POWER, 0), Block.UPDATE_ALL); level.scheduleTick(pos, state.getBlock(), 10); updateNeighbours(level, pos, state); @@ -206,6 +_,15 @@ @@ -53,7 +53,7 @@ + } + power = eventRedstone.getNewCurrent(); + // CraftBukkit end - level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.ACTIVE).setValue(POWER, power), 3); + level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.ACTIVE).setValue(POWER, power), Block.UPDATE_ALL); level.scheduleTick(pos, state.getBlock(), this.getActiveTicks()); updateNeighbours(level, pos, state); @@ -283,8 +_,16 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SculkVeinBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SculkVeinBlock.java.patch index bc1a1f3a4810..d3fb9fb7857c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SculkVeinBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SculkVeinBlock.java.patch @@ -21,7 +21,7 @@ BlockState blockState1 = level.getBlockState(blockPos); if (blockState1.is(tagKey)) { BlockState blockState2 = Blocks.SCULK.defaultBlockState(); -- level.setBlock(blockPos, blockState2, 3); +- level.setBlock(blockPos, blockState2, Block.UPDATE_ALL); + // CraftBukkit start - Call BlockSpreadEvent + if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, sourceBlock, blockPos, blockState2, 3)) { + return false; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SnifferEggBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SnifferEggBlock.java.patch index eb378047b37c..0e7c03227123 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SnifferEggBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SnifferEggBlock.java.patch @@ -22,7 +22,7 @@ + } + // Paper end level.playSound(null, pos, SoundEvents.SNIFFER_EGG_CRACK, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); -- level.setBlock(pos, state.setValue(HATCH, this.getHatchLevel(state) + 1), 2); +- level.setBlock(pos, state.setValue(HATCH, this.getHatchLevel(state) + 1), Block.UPDATE_CLIENTS); } else { + // Paper start - Call BlockFadeEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(level, pos, state.getFluidState().createLegacyBlock()).isCancelled()) { @@ -43,7 +43,7 @@ } } @@ -86,7 +_,7 @@ - level.levelEvent(3009, pos, 0); + level.levelEvent(LevelEvent.PARTICLES_EGG_CRACK, pos, 0); } - int i = flag ? 12000 : 24000; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SpongeBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SpongeBlock.java.patch index 650392ae7dc6..2678f3b88860 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SpongeBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SpongeBlock.java.patch @@ -28,7 +28,7 @@ return BlockPos.TraversalNodeStatus.ACCEPT; } else { if (blockState.getBlock() instanceof LiquidBlock) { -- level.setBlock(blockPos, Blocks.AIR.defaultBlockState(), 3); +- level.setBlock(blockPos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL); + blockList.setBlock(blockPos, Blocks.AIR.defaultBlockState(), 3); // CraftBukkit } else { if (!blockState.is(Blocks.KELP) @@ -39,7 +39,7 @@ - BlockEntity blockEntity = blockState.hasBlockEntity() ? level.getBlockEntity(blockPos) : null; - dropResources(blockState, level, blockPos, blockEntity); -- level.setBlock(blockPos, Blocks.AIR.defaultBlockState(), 3); +- level.setBlock(blockPos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL); + // CraftBukkit start + // BlockEntity blockEntity = blockState.hasBlockEntity() ? level.getBlockEntity(blockPos) : null; + // dropResources(blockState, level, blockPos, blockEntity); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/StemBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/StemBlock.java.patch index aa85bf463f3b..9bcd11379dd4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/StemBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/StemBlock.java.patch @@ -9,7 +9,7 @@ int ageValue = state.getValue(AGE); if (ageValue < 7) { state = state.setValue(AGE, ageValue + 1); -- level.setBlock(pos, state, 2); +- level.setBlock(pos, state, Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state, 2); // CraftBukkit } else { Direction randomDirection = Direction.Plane.HORIZONTAL.getRandomDirection(random); @@ -31,7 +31,7 @@ public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) { int min = Math.min(7, state.getValue(AGE) + Mth.nextInt(level.random, 2, 5)); BlockState blockState = state.setValue(AGE, min); -- level.setBlock(pos, blockState, 2); +- level.setBlock(pos, blockState, Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, blockState, 2); // CraftBukkit if (min == 7) { blockState.randomTick(level, pos, level.random); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SugarCaneBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SugarCaneBlock.java.patch index c9e65a7d7e4a..ceb1360b03d1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SugarCaneBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SugarCaneBlock.java.patch @@ -12,9 +12,9 @@ + int modifier = level.spigotConfig.caneModifier; // Spigot - SPIGOT-7159: Better modifier resolution + if (ageValue >= 15 || (modifier != 100 && random.nextFloat() < (modifier / (100.0F * 16)))) { // Spigot - SPIGOT-7159: Better modifier resolution + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos.above(), this.defaultBlockState(), 3); // CraftBukkit - level.setBlock(pos, state.setValue(AGE, 0), 260); + level.setBlock(pos, state.setValue(AGE, 0), Block.UPDATE_NONE); - } else { + } else if (modifier == 100 || random.nextFloat() < (modifier / (100.0F * 16))) { // Spigot - SPIGOT-7159: Better modifier resolution - level.setBlock(pos, state.setValue(AGE, ageValue + 1), 260); + level.setBlock(pos, state.setValue(AGE, ageValue + 1), Block.UPDATE_NONE); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch index 644c0fb9aea1..f2a9c4f88438 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch @@ -7,7 +7,7 @@ - if (ageValue < 3 && random.nextInt(5) == 0 && level.getRawBrightness(pos.above(), 0) >= 9) { + if (ageValue < 3 && random.nextFloat() < (level.spigotConfig.sweetBerryModifier / (100.0F * 5)) && level.getRawBrightness(pos.above(), 0) >= 9) { // Spigot - SPIGOT-7159: Better modifier resolution BlockState blockState = state.setValue(AGE, ageValue + 1); -- level.setBlock(pos, blockState, 2); +- level.setBlock(pos, blockState, Block.UPDATE_CLIENTS); + if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, blockState, 2)) return; // CraftBukkit level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(blockState)); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch index b5c06f625479..5661b3fd72df 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch @@ -53,7 +53,7 @@ } else { - if (prime(level, pos, player)) { + if (prime(level, pos, player, () -> org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.PLAYER, player, null))) { // Paper - level.setBlock(pos, Blocks.AIR.defaultBlockState(), 11); + level.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL_IMMEDIATE); Item item = stack.getItem(); if (stack.is(Items.FLINT_AND_STEEL)) { @@ -128,7 +_,7 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireBlock.java.patch index fc0139d06be3..3b60250e8717 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireBlock.java.patch @@ -38,7 +38,7 @@ public BlockState playerWillDestroy(Level level, BlockPos pos, BlockState state, Player player) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return state; // Paper - prevent disarming tripwires if (!level.isClientSide() && !player.getMainHandItem().isEmpty() && player.getMainHandItem().is(Items.SHEARS)) { - level.setBlock(pos, state.setValue(DISARMED, true), 260); + level.setBlock(pos, state.setValue(DISARMED, true), Block.UPDATE_NONE); level.gameEvent(player, GameEvent.SHEAR, pos); @@ -123,6 +_,7 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch index 89c2581d9547..bb0a61839340 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch @@ -33,7 +33,7 @@ + if (!cancelledReceiverHook) { // always trigger two events even when the first hook current change is cancelled + // Paper end - Call BlockRedstoneEvent Direction opposite = direction.getOpposite(); - level.setBlock(blockPosx, blockState1.setValue(FACING, opposite), 3); + level.setBlock(blockPosx, blockState1.setValue(FACING, opposite), Block.UPDATE_ALL); notifyNeighbors(block, level, blockPosx, opposite); emitState(level, blockPosx, flag2, flag3, flag, flag1); - } @@ -54,7 +54,7 @@ emitState(level, pos, flag2, flag3, flag, flag1); if (!attaching) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.skipTripwireHookPlacementValidation || level.getBlockState(pos).is(Blocks.TRIPWIRE_HOOK)) // Paper - Validate tripwire hook placement before update - level.setBlock(pos, blockState1.setValue(FACING, direction), 3); + level.setBlock(pos, blockState1.setValue(FACING, direction), Block.UPDATE_ALL); if (shouldNotifyNeighbours) { notifyNeighbors(block, level, pos, direction); } @@ -67,7 +67,7 @@ if (blockState2 != null) { BlockState blockState3 = level.getBlockState(blockPos1); if (blockState3.is(Blocks.TRIPWIRE) || blockState3.is(Blocks.TRIPWIRE_HOOK)) { -- level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, flag2), 3); +- level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, flag2), Block.UPDATE_ALL); + if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !blockState3.is(Blocks.TRIPWIRE)) level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, flag2), 3); // Paper - prevent tripwire from updating } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch index 975f24284f56..0efd1a5c33fa 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch @@ -30,7 +30,7 @@ + } + // CraftBukkit end level.playSound(null, pos, SoundEvents.TURTLE_EGG_CRACK, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); -- level.setBlock(pos, state.setValue(HATCH, hatchValue + 1), 2); +- level.setBlock(pos, state.setValue(HATCH, hatchValue + 1), Block.UPDATE_CLIENTS); level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(state)); } else { + // CraftBukkit start - Call BlockFadeEvent diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch index 28c32d2c0ab6..705f3164b2fa 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch @@ -16,34 +16,34 @@ + // CraftBukkit start - Call BlockSpreadEvent + BlockPos source = pos; if (value && isAcceptableNeighbour(level, blockPos2, clockWise)) { -- level.setBlock(blockPos1, this.defaultBlockState().setValue(getPropertyForFace(clockWise), true), 2); +- level.setBlock(blockPos1, this.defaultBlockState().setValue(getPropertyForFace(clockWise), true), Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos1, this.defaultBlockState().setValue(getPropertyForFace(clockWise), true), 2); } else if (value1 && isAcceptableNeighbour(level, blockPos3, counterClockWise)) { -- level.setBlock(blockPos1, this.defaultBlockState().setValue(getPropertyForFace(counterClockWise), true), 2); +- level.setBlock(blockPos1, this.defaultBlockState().setValue(getPropertyForFace(counterClockWise), true), Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos1, this.defaultBlockState().setValue(getPropertyForFace(counterClockWise), true), 2); } else { Direction opposite = random1.getOpposite(); if (value && level.isEmptyBlock(blockPos2) && isAcceptableNeighbour(level, pos.relative(clockWise), opposite)) { -- level.setBlock(blockPos2, this.defaultBlockState().setValue(getPropertyForFace(opposite), true), 2); +- level.setBlock(blockPos2, this.defaultBlockState().setValue(getPropertyForFace(opposite), true), Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos2, this.defaultBlockState().setValue(getPropertyForFace(opposite), true), 2); } else if (value1 && level.isEmptyBlock(blockPos3) && isAcceptableNeighbour(level, pos.relative(counterClockWise), opposite)) { -- level.setBlock(blockPos3, this.defaultBlockState().setValue(getPropertyForFace(opposite), true), 2); +- level.setBlock(blockPos3, this.defaultBlockState().setValue(getPropertyForFace(opposite), true), Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos3, this.defaultBlockState().setValue(getPropertyForFace(opposite), true), 2); } else if (random.nextFloat() < 0.05 && isAcceptableNeighbour(level, blockPos1.above(), Direction.UP)) { -- level.setBlock(blockPos1, this.defaultBlockState().setValue(UP, true), 2); +- level.setBlock(blockPos1, this.defaultBlockState().setValue(UP, true), Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos1, this.defaultBlockState().setValue(UP, true), 2); } + // CraftBukkit end } } else if (isAcceptableNeighbour(level, blockPos1, random1)) { -- level.setBlock(pos, state.setValue(getPropertyForFace(random1), true), 2); +- level.setBlock(pos, state.setValue(getPropertyForFace(random1), true), Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, (BlockState) state.setValue(VineBlock.getPropertyForFace(random1), true), 2); // CraftBukkit } } } else { if (random1 == Direction.UP && pos.getY() < level.getMaxY()) { if (this.canSupportAtFace(level, pos, random1)) { -- level.setBlock(pos, state.setValue(UP, true), 2); +- level.setBlock(pos, state.setValue(UP, true), Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(UP, true), 2); // CraftBukkit return; } @@ -52,7 +52,7 @@ } if (this.hasHorizontalConnection(blockState1)) { -- level.setBlock(blockPos, blockState1, 2); +- level.setBlock(blockPos, blockState1, Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, blockState1, 2); // CraftBukkit } @@ -61,7 +61,7 @@ BlockState blockState2 = blockState.isAir() ? this.defaultBlockState() : blockState; BlockState blockState3 = this.copyRandomFaces(state, blockState2, random); if (blockState2 != blockState3 && this.hasHorizontalConnection(blockState3)) { -- level.setBlock(blockPos1, blockState3, 2); +- level.setBlock(blockPos1, blockState3, Block.UPDATE_CLIENTS); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos1, blockState3, 2); // CraftBukkit } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch index 6145f471fc96..add1fa3677cb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -@@ -104,11 +_,49 @@ +@@ -105,11 +_,49 @@ }; public final Reference2IntOpenHashMap>> recipesUsed = new Reference2IntOpenHashMap<>(); private final RecipeManager.CachedCheck quickCheck; @@ -51,7 +51,7 @@ private boolean isLit() { return this.litTimeRemaining > 0; -@@ -125,6 +_,7 @@ +@@ -126,6 +_,7 @@ this.litTotalTime = input.getShortOr("lit_total_time", (short)0); this.recipesUsed.clear(); this.recipesUsed.putAll(input.read("RecipesUsed", RECIPES_USED_CODEC).orElse(Map.of())); @@ -59,7 +59,7 @@ } @Override -@@ -134,6 +_,7 @@ +@@ -135,6 +_,7 @@ output.putShort("cooking_total_time", (short)this.cookingTotalTime); output.putShort("lit_time_remaining", (short)this.litTimeRemaining); output.putShort("lit_total_time", (short)this.litTotalTime); @@ -67,7 +67,7 @@ ContainerHelper.saveAllItems(output, this.items); output.store("RecipesUsed", RECIPES_USED_CODEC, this.recipesUsed); } -@@ -160,11 +_,22 @@ +@@ -161,11 +_,22 @@ int maxStackSize = furnace.getMaxStackSize(); if (!furnace.isLit() && canBurn(level.registryAccess(), recipeHolder, singleRecipeInput, furnace.items, maxStackSize)) { @@ -93,7 +93,7 @@ Item item = itemStack.getItem(); itemStack.shrink(1); if (itemStack.isEmpty()) { -@@ -175,11 +_,28 @@ +@@ -176,11 +_,28 @@ } if (furnace.isLit() && canBurn(level.registryAccess(), recipeHolder, singleRecipeInput, furnace.items, maxStackSize)) { @@ -125,7 +125,7 @@ furnace.setRecipeUsed(recipeHolder); } -@@ -233,17 +_,47 @@ +@@ -234,17 +_,47 @@ @Nullable RecipeHolder recipe, SingleRecipeInput recipeInput, NonNullList items, @@ -177,7 +177,7 @@ if (itemStack.is(Blocks.WET_SPONGE.asItem()) && !items.get(1).isEmpty() && items.get(1).is(Items.BUCKET)) { items.set(1, new ItemStack(Items.WATER_BUCKET)); -@@ -260,9 +_,16 @@ +@@ -261,9 +_,16 @@ return fuelValues.burnDuration(stack); } @@ -196,7 +196,7 @@ } @Override -@@ -306,7 +_,7 @@ +@@ -307,7 +_,7 @@ this.items.set(index, stack); stack.limitSize(this.getMaxStackSize(stack)); if (index == 0 && !flag && this.level instanceof ServerLevel serverLevel) { @@ -205,7 +205,7 @@ this.cookingTimer = 0; this.setChanged(); } -@@ -342,8 +_,8 @@ +@@ -343,8 +_,8 @@ public void awardUsedRecipes(Player player, List items) { } @@ -216,7 +216,7 @@ player.awardRecipes(recipesToAwardAndPopExperience); for (RecipeHolder recipeHolder : recipesToAwardAndPopExperience) { -@@ -356,30 +_,60 @@ +@@ -357,30 +_,60 @@ } public List> getRecipesToAwardAndPopExperience(ServerLevel level, Vec3 popVec) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch index 686b471a5f85..262672ce2551 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java -@@ -23,6 +_,40 @@ +@@ -24,6 +_,40 @@ import net.minecraft.world.level.storage.ValueOutput; public class BarrelBlockEntity extends RandomizableContainerBlockEntity { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch index c253dbf96a34..a3402fa98d97 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -@@ -39,6 +_,7 @@ +@@ -41,6 +_,7 @@ private static final Component DEFAULT_NAME = Component.translatable("container.brewing"); private NonNullList items = NonNullList.withSize(5, ItemStack.EMPTY); public int brewTime; @@ -8,7 +8,7 @@ private boolean[] lastPotionCount; private Item ingredient; public int fuel; -@@ -48,6 +_,7 @@ +@@ -50,6 +_,7 @@ return switch (index) { case 0 -> BrewingStandBlockEntity.this.brewTime; case 1 -> BrewingStandBlockEntity.this.fuel; @@ -16,7 +16,7 @@ default -> 0; }; } -@@ -60,14 +_,54 @@ +@@ -62,14 +_,54 @@ break; case 1: BrewingStandBlockEntity.this.fuel = value; @@ -72,7 +72,7 @@ public BrewingStandBlockEntity(BlockPos pos, BlockState blockState) { super(BlockEntityType.BREWING_STAND, pos, blockState); -@@ -96,8 +_,21 @@ +@@ -98,8 +_,21 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, BrewingStandBlockEntity blockEntity) { ItemStack itemStack = blockEntity.items.get(4); if (blockEntity.fuel <= 0 && itemStack.is(ItemTags.BREWING_FUEL)) { @@ -96,7 +96,7 @@ setChanged(level, pos, state); } -@@ -108,7 +_,7 @@ +@@ -110,7 +_,7 @@ blockEntity.brewTime--; boolean flag1 = blockEntity.brewTime == 0; if (flag1 && isBrewable) { @@ -105,7 +105,7 @@ } else if (!isBrewable || !itemStack1.is(blockEntity.ingredient)) { blockEntity.brewTime = 0; } -@@ -116,7 +_,14 @@ +@@ -118,7 +_,14 @@ setChanged(level, pos, state); } else if (isBrewable && blockEntity.fuel > 0) { blockEntity.fuel--; @@ -121,7 +121,7 @@ blockEntity.ingredient = itemStack1.getItem(); setChanged(level, pos, state); } -@@ -167,13 +_,37 @@ +@@ -169,13 +_,37 @@ } } @@ -162,7 +162,7 @@ itemStack.shrink(1); ItemStack craftingRemainder = itemStack.getItem().getCraftingRemainder(); -@@ -212,13 +_,13 @@ +@@ -214,13 +_,13 @@ @Override public boolean canPlaceItem(int index, ItemStack stack) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch index 5d7c86f4f358..d84df75e0ba4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BrushableBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrushableBlockEntity.java -@@ -67,9 +_,26 @@ +@@ -68,9 +_,26 @@ return false; } else { this.coolDownEndsAtTick = startTick + 10L; @@ -29,19 +29,19 @@ this.brushingCompleted(level, brusher, stack); return true; } else { -@@ -77,7 +_,7 @@ +@@ -78,7 +_,7 @@ int completionState1 = this.getCompletionState(); if (completionState != completionState1) { BlockState blockState = this.getBlockState(); - BlockState blockState1 = blockState.setValue(BlockStateProperties.DUSTED, completionState1); + BlockState blockState1 = nextBrokenBlockState; // Paper - EntityChangeBlockEvent - use precomputed - diff on change - level.setBlock(this.getBlockPos(), blockState1, 3); + level.setBlock(this.getBlockPos(), blockState1, Block.UPDATE_ALL); } -@@ -118,6 +_,11 @@ +@@ -119,6 +_,11 @@ this.dropContent(level, brusher, stack); BlockState blockState = this.getBlockState(); - level.levelEvent(3008, this.getBlockPos(), Block.getId(blockState)); + level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_BRUSH_BLOCK_COMPLETE, this.getBlockPos(), Block.getId(blockState)); + // Paper start - EntityChangeEvent - extract result block logic + this.brushingCompleteUpdateBlock(this.computeTurnsTo()); + } @@ -50,7 +50,7 @@ Block turnsInto; if (this.getBlockState().getBlock() instanceof BrushableBlock brushableBlock) { turnsInto = brushableBlock.getTurnsInto(); -@@ -125,6 +_,11 @@ +@@ -126,6 +_,11 @@ turnsInto = Blocks.AIR; } @@ -59,10 +59,10 @@ + } + public void brushingCompleteUpdateBlock(final Block turnsInto) { + // Paper end - EntityChangeEvent - extract result block logic - level.setBlock(this.worldPosition, turnsInto.defaultBlockState(), 3); + level.setBlock(this.worldPosition, turnsInto.defaultBlockState(), Block.UPDATE_ALL); } -@@ -141,7 +_,12 @@ +@@ -142,7 +_,12 @@ double d5 = blockPos.getZ() + 0.5 * d1 + d2; ItemEntity itemEntity = new ItemEntity(level, d3, d4, d5, this.item.split(level.random.nextInt(21) + 10)); itemEntity.setDeltaMovement(Vec3.ZERO); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch index 6bcd4fbe9138..b55ef3a0b745 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/CampfireBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CampfireBlockEntity.java -@@ -45,6 +_,7 @@ +@@ -46,6 +_,7 @@ private final NonNullList items = NonNullList.withSize(4, ItemStack.EMPTY); public final int[] cookingProgress = new int[4]; public final int[] cookingTime = new int[4]; @@ -8,7 +8,7 @@ public CampfireBlockEntity(BlockPos pos, BlockState blockState) { super(BlockEntityType.CAMPFIRE, pos, blockState); -@@ -63,14 +_,44 @@ +@@ -64,14 +_,44 @@ ItemStack itemStack = campfire.items.get(i); if (!itemStack.isEmpty()) { flag = true; @@ -53,9 +53,9 @@ + } + // Paper end - Fix item locations dropped from campfires campfire.items.set(i, ItemStack.EMPTY); - level.sendBlockUpdated(pos, state, state, 3); + level.sendBlockUpdated(pos, state, state, Block.UPDATE_ALL); level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(state)); -@@ -142,6 +_,16 @@ +@@ -143,6 +_,16 @@ .ifPresentOrElse( ints -> System.arraycopy(ints, 0, this.cookingTime, 0, Math.min(this.cookingTime.length, ints.length)), () -> Arrays.fill(this.cookingTime, 0) ); @@ -72,7 +72,7 @@ } @Override -@@ -150,6 +_,13 @@ +@@ -151,6 +_,13 @@ ContainerHelper.saveAllItems(output, this.items, true); output.putIntArray("CookingTimes", this.cookingProgress); output.putIntArray("CookingTotalTimes", this.cookingTime); @@ -86,7 +86,7 @@ } @Override -@@ -179,7 +_,15 @@ +@@ -180,7 +_,15 @@ return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch index 340e29caf88e..b9714df750b2 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java -@@ -28,6 +_,42 @@ +@@ -29,6 +_,42 @@ private final NonNullList items = NonNullList.withSize(6, ItemStack.EMPTY); public int lastInteractedSlot = -1; @@ -43,7 +43,7 @@ public ChiseledBookShelfBlockEntity(BlockPos pos, BlockState blockState) { super(BlockEntityType.CHISELED_BOOKSHELF, pos, blockState); } -@@ -67,7 +_,7 @@ +@@ -68,7 +_,7 @@ @Override public int getMaxStackSize() { @@ -52,7 +52,7 @@ } @Override -@@ -80,7 +_,7 @@ +@@ -81,7 +_,7 @@ ItemStack itemStack = Objects.requireNonNullElse(this.getItems().get(slot), ItemStack.EMPTY); this.getItems().set(slot, ItemStack.EMPTY); if (!itemStack.isEmpty()) { @@ -61,7 +61,7 @@ } return itemStack; -@@ -90,7 +_,7 @@ +@@ -91,7 +_,7 @@ public void setItem(int slot, ItemStack stack) { if (this.acceptsItemType(stack)) { this.getItems().set(slot, stack); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CrafterBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CrafterBlockEntity.java.patch index d08bc1d3fe4b..14acb4180199 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CrafterBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CrafterBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/CrafterBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CrafterBlockEntity.java -@@ -59,6 +_,47 @@ +@@ -60,6 +_,47 @@ } }; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch index 2370e2afb8ce..004ae297513a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java +++ b/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java -@@ -20,6 +_,44 @@ +@@ -22,6 +_,44 @@ import net.minecraft.world.ticks.ContainerSingleItem; public class JukeboxBlockEntity extends BlockEntity implements ContainerSingleItem.BlockContainerSingleItem { @@ -45,7 +45,7 @@ public static final String SONG_ITEM_TAG_ID = "RecordItem"; public static final String TICKS_SINCE_SONG_STARTED_TAG_ID = "ticks_since_song_started"; private ItemStack item = ItemStack.EMPTY; -@@ -131,7 +_,7 @@ +@@ -133,7 +_,7 @@ @Override public int getMaxStackSize() { @@ -54,7 +54,7 @@ } @Override -@@ -155,11 +_,16 @@ +@@ -157,11 +_,16 @@ } @VisibleForTesting diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java.patch index 657dcc09679e..27421fe52fed 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java -@@ -34,8 +_,18 @@ +@@ -35,8 +_,18 @@ this.catalystListener = new SculkCatalystBlockEntity.CatalystListener(blockState, new BlockPositionSource(pos)); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch index c7d6e63f7349..320946a1b736 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java -@@ -86,6 +_,13 @@ +@@ -88,6 +_,13 @@ @Nullable public static ServerPlayer tryGetPlayer(@Nullable Entity entity) { @@ -14,7 +14,7 @@ if (entity instanceof ServerPlayer serverPlayer) { return serverPlayer; } else if (entity != null && entity.getControllingPassenger() instanceof ServerPlayer serverPlayer) { -@@ -161,7 +_,7 @@ +@@ -163,7 +_,7 @@ private boolean trySummonWarden(ServerLevel level) { return this.warningLevel >= 4 && SpawnUtil.trySpawnMob( diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShelfBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShelfBlockEntity.java.patch index 4c540dc0b063..cce435d19b5a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShelfBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShelfBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ShelfBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ShelfBlockEntity.java -@@ -34,6 +_,47 @@ +@@ -35,6 +_,47 @@ private final NonNullList items = NonNullList.withSize(3, ItemStack.EMPTY); private boolean alignItemsToBottom; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch index 6dfea40f5c40..8ab294db9ede 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SignBlockEntity.java -@@ -58,10 +_,15 @@ +@@ -59,10 +_,15 @@ } public boolean isFacingFrontText(Player player) { @@ -18,14 +18,14 @@ float yRotationDegrees = signBlock.getYRotationDegrees(this.getBlockState()); float f = (float)(Mth.atan2(d1, d) * 180.0F / (float)Math.PI) - 90.0F; return Mth.degreesDifferenceAbs(yRotationDegrees, f) <= 90.0F; -@@ -129,11 +_,13 @@ +@@ -130,11 +_,13 @@ public void updateSignText(Player player, boolean isFrontText, List filteredText) { if (!this.isWaxed() && player.getUUID().equals(this.getPlayerWhoMayEdit()) && this.level != null) { - this.updateText(signText -> this.setMessages(player, filteredText, signText), isFrontText); + this.updateText(signText -> this.setMessages(player, filteredText, signText, isFrontText), isFrontText); // CraftBukkit this.setAllowedPlayerEditor(null); - this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3); + this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), Block.UPDATE_ALL); } else { LOGGER.warn("Player {} just tried to change non-editable sign", player.getPlainTextName()); + if (player.distanceToSqr(this.getBlockPos().getX(), this.getBlockPos().getY(), this.getBlockPos().getZ()) < Mth.square(32)) // Paper - Don't send far away sign update @@ -33,7 +33,7 @@ } } -@@ -142,19 +_,41 @@ +@@ -143,19 +_,41 @@ return this.setText(updater.apply(text), isFrontText); } @@ -78,7 +78,7 @@ return text; } -@@ -193,7 +_,23 @@ +@@ -194,7 +_,23 @@ Style style = component.getStyle(); switch (style.getClickEvent()) { case ClickEvent.RunCommand runCommand: @@ -103,7 +103,7 @@ flag = true; break; case ClickEvent.ShowDialog showDialog: -@@ -212,12 +_,56 @@ +@@ -213,12 +_,56 @@ return flag; } @@ -164,7 +164,7 @@ } @Override -@@ -236,12 +_,17 @@ +@@ -237,12 +_,17 @@ @Nullable public UUID getPlayerWhoMayEdit() { @@ -178,7 +178,7 @@ private void markUpdated() { this.setChanged(); -- this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3); +- this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), Block.UPDATE_ALL); + if (this.level != null) this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3); // CraftBukkit - skip notify if world is null (SPIGOT-5122) } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java.patch index c6d0055ea181..f6bbb048d83e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java +++ b/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java -@@ -156,6 +_,7 @@ +@@ -157,6 +_,7 @@ @Override protected void loadAdditional(ValueInput input) { @@ -8,7 +8,7 @@ input.read("data", TestInstanceBlockEntity.Data.CODEC).ifPresent(this::set); this.errorMarkers.clear(); this.errorMarkers.addAll(input.read("errors", TestInstanceBlockEntity.ErrorMarker.LIST_CODEC).orElse(List.of())); -@@ -326,7 +_,7 @@ +@@ -329,7 +_,7 @@ } private void removeEntities() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch index 95dbf2259849..bcf8b430a4d4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java +++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java -@@ -217,7 +_,14 @@ +@@ -219,7 +_,14 @@ nextSpawnData.getEquipment().ifPresent(mob::equip); } @@ -16,7 +16,7 @@ return Optional.empty(); } -@@ -232,10 +_,24 @@ +@@ -234,10 +_,24 @@ } public void ejectReward(ServerLevel level, BlockPos pos, ResourceKey lootTable) { @@ -42,7 +42,7 @@ for (ItemStack itemStack : randomItems) { DefaultDispenseItemBehavior.spawnItem(level, itemStack, 2, Direction.UP, Vec3.atBottomCenterOf(pos).relative(Direction.UP, 1.2)); } -@@ -405,6 +_,35 @@ +@@ -407,6 +_,35 @@ this.requiredPlayerRange ); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java.patch index e9c7b1566acf..702a9a8f1cff 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java +++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java -@@ -185,7 +_,7 @@ +@@ -188,7 +_,7 @@ mob.dropPreservedEquipment(level); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch index 1982d28315ef..8c272f01a761 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java +++ b/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java -@@ -257,7 +_,13 @@ +@@ -258,7 +_,13 @@ if (!list.isEmpty()) { player.awardStat(Stats.ITEM_USED.get(stack.getItem())); stack.consume(config.keyItem().getCount(), player); @@ -15,7 +15,7 @@ serverData.addToRewardedPlayers(player); sharedData.updateConnectedPlayersWithinRange(level, pos, serverData, config, config.deactivationRange()); } -@@ -266,8 +_,30 @@ +@@ -267,8 +_,30 @@ } static void setVaultState(ServerLevel level, BlockPos pos, BlockState oldState, BlockState newState, VaultConfig config, VaultSharedData sharedData) { @@ -45,10 +45,10 @@ + ); + if (!event.callEvent()) return; + // Paper end - Vault API - level.setBlock(pos, newState, 3); + level.setBlock(pos, newState, Block.UPDATE_ALL); vaultState.onTransition(level, pos, vaultState1, config, sharedData, newState.getValue(VaultBlock.OMINOUS)); } -@@ -279,6 +_,11 @@ +@@ -280,6 +_,11 @@ ItemStack randomDisplayItemFromLootTable = getRandomDisplayItemFromLootTable( level, pos, config.overrideLootTableToDisplay().orElse(config.lootTable()) ); @@ -60,7 +60,7 @@ sharedData.setDisplayItem(randomDisplayItemFromLootTable); } } -@@ -301,10 +_,24 @@ +@@ -302,10 +_,24 @@ VaultSharedData sharedData, List itemsToEject ) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch index 90872ab8d634..1ad9aa9a7d14 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch @@ -15,7 +15,7 @@ + this.setTreeType(holder1); // CraftBukkit ConfiguredFeature configuredFeature2 = holder1.value(); BlockState blockState1 = level.getFluidState(pos).createLegacyBlock(); - level.setBlock(pos, blockState1, 260); + level.setBlock(pos, blockState1, Block.UPDATE_NONE); @@ -198,4 +_,58 @@ return false; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch index 473d6ff4588d..656349adc962 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java -@@ -151,6 +_,12 @@ +@@ -152,6 +_,12 @@ @Override protected boolean triggerEvent(BlockState state, Level level, BlockPos pos, int id, int param) { Direction direction = state.getValue(FACING); @@ -13,7 +13,7 @@ BlockState blockState = state.setValue(EXTENDED, true); if (!level.isClientSide()) { boolean neighborSignal = this.getNeighborSignal(level, pos, direction); -@@ -182,10 +_,17 @@ +@@ -183,10 +_,17 @@ .defaultBlockState() .setValue(MovingPistonBlock.FACING, direction) .setValue(MovingPistonBlock.TYPE, this.isSticky ? PistonType.STICKY : PistonType.DEFAULT); @@ -24,7 +24,7 @@ + } + } + // Paper end - Fix sticky pistons and BlockPistonRetractEvent - level.setBlock(pos, blockState1, 276); + level.setBlock(pos, blockState1, Block.UPDATE_NONE | Block.UPDATE_KNOWN_SHAPE); level.setBlockEntity( MovingPistonBlock.newMovingBlockEntity( - pos, blockState1, this.defaultBlockState().setValue(FACING, Direction.from3DDataValue(param & 7)), direction, false, true @@ -32,7 +32,7 @@ ) ); level.updateNeighborsAt(pos, blockState1.getBlock()); -@@ -209,13 +_,27 @@ +@@ -210,13 +_,27 @@ || blockState2.getPistonPushReaction() != PushReaction.NORMAL && !blockState2.is(Blocks.PISTON) && !blockState2.is(Blocks.STICKY_PISTON)) { @@ -61,7 +61,7 @@ } level.playSound(null, pos, SoundEvents.PISTON_CONTRACT, SoundSource.BLOCKS, 0.5F, level.random.nextFloat() * 0.15F + 0.6F); -@@ -226,7 +_,7 @@ +@@ -227,7 +_,7 @@ } public static boolean isPushable(BlockState state, Level level, BlockPos pos, Direction movementDirection, boolean allowDestroy, Direction pistonFacing) { @@ -70,7 +70,7 @@ return false; } else if (state.isAir()) { return true; -@@ -282,12 +_,54 @@ +@@ -283,12 +_,54 @@ BlockState[] blockStates = new BlockState[toPush.size() + toDestroy.size()]; Direction direction = extending ? facing : facing.getOpposite(); int i = 0; @@ -124,9 +124,9 @@ - dropResources(blockState1, level, blockPos2, blockEntity); + dropResources(blockState1, level, blockPos2, blockEntity, pos); // Paper - Add BlockBreakBlockEvent if (!blockState1.is(BlockTags.FIRE) && level.isClientSide()) { - level.levelEvent(2001, blockPos2, getId(blockState1)); + level.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, blockPos2, getId(blockState1)); } -@@ -298,13 +_,26 @@ +@@ -299,13 +_,26 @@ } for (int i1 = toPush.size() - 1; i1 >= 0; i1--) { @@ -141,7 +141,7 @@ blockPos2 = blockPos2.relative(direction); map.remove(blockPos2); BlockState blockState2 = Blocks.MOVING_PISTON.defaultBlockState().setValue(FACING, facing); - level.setBlock(blockPos2, blockState2, 324); + level.setBlock(blockPos2, blockState2, Block.UPDATE_NONE | Block.UPDATE_MOVE_BY_PISTON); - level.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockPos2, blockState2, list.get(i1), facing, extending, false)); + // Paper start - fix a variety of piston desync dupes + if (!allowDesync) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch index c83366549bd9..899a929ba95d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch @@ -13,8 +13,8 @@ if (level.getBlockState(pos).is(Blocks.MOVING_PISTON)) { BlockState blockState = Block.updateFromNeighbourShapes(blockEntity.movedState, level, pos); if (blockState.isAir()) { -- level.setBlock(pos, blockEntity.movedState, 340); +- level.setBlock(pos, blockEntity.movedState, Block.UPDATE_NONE | Block.UPDATE_MOVE_BY_PISTON | Block.UPDATE_KNOWN_SHAPE); + level.setBlock(pos, blockEntity.movedState, io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPistonDuplication ? 340 : (340 | Block.UPDATE_CLIENTS)); // Paper - fix a variety of piston desync dupes; force notify (flag 2), it's possible the set type by the piston block (which doesn't notify) set this block to air - Block.updateOrDestroy(blockEntity.movedState, blockState, level, pos, 3); + Block.updateOrDestroy(blockEntity.movedState, blockState, level, pos, Block.UPDATE_ALL); } else { if (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch index b85fb975a9b5..8028eaa10955 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch @@ -38,7 +38,7 @@ + @Nullable public BlockState setBlockState(BlockPos pos, BlockState state) { - return this.setBlockState(pos, state, 3); + return this.setBlockState(pos, state, Block.UPDATE_ALL); @@ -274,6 +_,7 @@ public boolean tryMarkSaved() { if (this.unsaved) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch index ce91ad48cf37..c6fcf3b3d1df 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -131,16 +131,16 @@ } @Nullable -@@ -322,7 +_,7 @@ +@@ -324,7 +_,7 @@ if (!section.getBlockState(i, i1, i2).is(block)) { return null; } else { -- if (!this.level.isClientSide() && (flags & 512) == 0) { +- if (!this.level.isClientSide() && (flags & Block.UPDATE_SKIP_ON_PLACE) == 0) { + if (!this.level.isClientSide() && (flags & 512) == 0 && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. state.onPlace(this.level, pos, blockState, flag1); } -@@ -376,7 +_,12 @@ +@@ -378,7 +_,12 @@ @Nullable public BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType) { @@ -154,7 +154,7 @@ if (blockEntity == null) { CompoundTag compoundTag = this.pendingBlockEntities.remove(pos); if (compoundTag != null) { -@@ -431,7 +_,13 @@ +@@ -433,7 +_,13 @@ BlockPos blockPos = blockEntity.getBlockPos(); BlockState blockState = this.getBlockState(blockPos); if (!blockState.hasBlockEntity()) { @@ -169,7 +169,7 @@ } else { BlockState blockState1 = blockEntity.getBlockState(); if (blockState != blockState1) { -@@ -479,6 +_,11 @@ +@@ -481,6 +_,11 @@ public void removeBlockEntity(BlockPos pos) { if (this.isInLevel()) { BlockEntity blockEntity = this.blockEntities.remove(pos); @@ -181,7 +181,7 @@ if (blockEntity != null) { if (this.level instanceof ServerLevel serverLevel) { this.removeGameEventListener(blockEntity, serverLevel); -@@ -522,6 +_,65 @@ +@@ -524,6 +_,65 @@ } } @@ -247,7 +247,7 @@ public boolean isEmpty() { return false; } -@@ -760,23 +_,24 @@ +@@ -762,23 +_,24 @@ if (this.blockEntity.getType().isValid(blockState)) { this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity); this.loggedInvalidBlockState = false; diff --git a/paper-server/patches/sources/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java.patch b/paper-server/patches/sources/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java.patch index 495ef0300d1c..a5dfcd6e9ec4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java +++ b/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java -@@ -90,7 +_,7 @@ +@@ -91,7 +_,7 @@ for (EndCrystal endCrystal : crystals) { endCrystal.setBeamTarget(null); level.explode(endCrystal, endCrystal.getX(), endCrystal.getY(), endCrystal.getZ(), 6.0F, Level.ExplosionInteraction.NONE); @@ -8,4 +8,4 @@ + endCrystal.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause } } else if (ticks >= 80) { - level.levelEvent(3001, new BlockPos(0, 128, 0), 0); + level.levelEvent(LevelEvent.ANIMATION_DRAGON_SUMMON_ROAR, new BlockPos(0, 128, 0), 0); diff --git a/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch b/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch index 56f78232043c..201c35f63b13 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/dimension/end/EndDragonFight.java +++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java -@@ -69,8 +_,9 @@ +@@ -70,8 +_,9 @@ private static final int GATEWAY_DISTANCE = 96; public static final int DRAGON_SPAWN_Y = 128; private final Predicate validPlayer; @@ -11,7 +11,7 @@ ) .setPlayBossMusic(true) .setCreateWorldFog(true); -@@ -111,7 +_,12 @@ +@@ -112,7 +_,12 @@ if (data.isRespawning) { this.respawnStage = DragonRespawnAnimation.START; } @@ -25,7 +25,7 @@ this.portalLocation = data.exitPortalLocation.orElse(null); this.gateways.addAll(data.gateways.orElseGet(() -> { ObjectArrayList list = new ObjectArrayList<>(ContiguousSet.create(Range.closedOpen(0, 20), DiscreteDomain.integers())); -@@ -208,9 +_,9 @@ +@@ -209,9 +_,9 @@ this.dragonUUID = enderDragon.getUUID(); LOGGER.info("Found that there's a dragon still alive ({})", enderDragon); this.dragonKilled = false; @@ -37,7 +37,7 @@ this.dragonUUID = null; } } -@@ -365,12 +_,22 @@ +@@ -366,12 +_,22 @@ this.dragonEvent.setVisible(false); this.spawnExitPortal(true); this.spawnNewGateway(); @@ -66,7 +66,7 @@ } this.previouslyKilled = true; -@@ -384,6 +_,24 @@ +@@ -385,6 +_,24 @@ this.gateways.clear(); } @@ -91,7 +91,7 @@ private void spawnNewGateway() { if (!this.gateways.isEmpty()) { int i = this.gateways.remove(this.gateways.size() - 1); -@@ -414,6 +_,11 @@ +@@ -415,6 +_,11 @@ this.portalLocation = this.portalLocation.atY(Math.max(this.level.getMinY() + 1, this.portalLocation.getY())); } @@ -103,7 +103,7 @@ if (endPodiumFeature.place( FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), this.portalLocation )) { -@@ -433,6 +_,7 @@ +@@ -434,6 +_,7 @@ enderDragon.snapTo(this.origin.getX(), 128 + this.origin.getY(), this.origin.getZ(), this.level.random.nextFloat() * 360.0F, 0.0F); this.level.addFreshEntity(enderDragon); this.dragonUUID = enderDragon.getUUID(); @@ -111,7 +111,7 @@ } return enderDragon; -@@ -444,6 +_,10 @@ +@@ -445,6 +_,10 @@ this.ticksSinceDragonSeen = 0; if (dragon.hasCustomName()) { this.dragonEvent.setName(dragon.getDisplayName()); @@ -122,7 +122,7 @@ } } } -@@ -471,7 +_,13 @@ +@@ -472,7 +_,13 @@ return this.previouslyKilled; } @@ -137,7 +137,7 @@ if (this.dragonKilled && this.respawnStage == null) { BlockPos blockPos = this.portalLocation; if (blockPos == null) { -@@ -486,6 +_,22 @@ +@@ -487,6 +_,22 @@ blockPos = this.portalLocation; } @@ -160,7 +160,7 @@ List list = Lists.newArrayList(); BlockPos blockPos1 = blockPos.above(1); -@@ -493,18 +_,19 @@ +@@ -494,18 +_,19 @@ for (Direction direction : Direction.Plane.HORIZONTAL) { List entitiesOfClass = this.level.getEntitiesOfClass(EndCrystal.class, new AABB(blockPos1.relative(direction, 2))); if (entitiesOfClass.isEmpty()) { @@ -183,7 +183,7 @@ if (this.dragonKilled && this.respawnStage == null) { for (BlockPattern.BlockPatternMatch blockPatternMatch = this.findExitPortal(); blockPatternMatch != null; blockPatternMatch = this.findExitPortal()) { for (int i = 0; i < this.exitPortalPattern.getWidth(); i++) { -@@ -523,7 +_,9 @@ +@@ -524,7 +_,9 @@ this.respawnTime = 0; this.spawnExitPortal(false); this.respawnCrystals = crystals; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java.patch index 185e07f40d8e..45f466d14d47 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java.patch @@ -25,7 +25,7 @@ + blockList.destroyBlock(blockPos, true, null); // CraftBukkit } -- level.setBlock(blockPos, block.defaultBlockState(), 3); +- level.setBlock(blockPos, block.defaultBlockState(), Block.UPDATE_ALL); + blockList.setBlock(blockPos, block.defaultBlockState(), 3); // CraftBukkit } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch index 89e7988f1e7a..c08d93948b83 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch @@ -3,7 +3,7 @@ @@ -181,6 +_,11 @@ } - level.setBlock(worldPos, state, 2); + level.setBlock(worldPos, state, Block.UPDATE_CLIENTS); + // CraftBukkit start - fluid handling is already done if we have a transformer generator access + if (level instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess && transformerAccess.canTransformBlocks()) { + return; @@ -65,7 +65,7 @@ state = reorient(level, pos, Blocks.CHEST.defaultBlockState()); } -- level.setBlock(pos, state, 2); +- level.setBlock(pos, state, Block.UPDATE_CLIENTS); - BlockEntity blockEntity = level.getBlockEntity(pos); - if (blockEntity instanceof ChestBlockEntity) { - ((ChestBlockEntity)blockEntity).setLootTable(lootTable, random.nextLong()); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java.patch index 6288b74444bb..6758feff4c50 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java +++ b/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java -@@ -65,6 +_,16 @@ +@@ -66,6 +_,16 @@ private static void placeSuspiciousSand(BoundingBox boundingBox, WorldGenLevel worldGenLevel, BlockPos pos) { if (boundingBox.isInside(pos)) { @@ -14,6 +14,6 @@ + return; + } + // CraftBukkit end - worldGenLevel.setBlock(pos, Blocks.SUSPICIOUS_SAND.defaultBlockState(), 2); + worldGenLevel.setBlock(pos, Blocks.SUSPICIOUS_SAND.defaultBlockState(), Block.UPDATE_CLIENTS); worldGenLevel.getBlockEntity(pos, BlockEntityType.BRUSHABLE_BLOCK) .ifPresent(brushableBlockEntity -> brushableBlockEntity.setLootTable(BuiltInLootTables.DESERT_PYRAMID_ARCHAEOLOGY, pos.asLong())); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java.patch index 55007e0dc7aa..70a17df4e57a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java -@@ -102,10 +_,13 @@ +@@ -103,10 +_,13 @@ protected void handleDataMarker(String name, BlockPos pos, ServerLevelAccessor level, RandomSource random, BoundingBox box) { if ("chest".equals(name)) { - level.setBlock(pos, Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL); - BlockEntity blockEntity = level.getBlockEntity(pos.below()); - if (blockEntity instanceof ChestBlockEntity) { - ((ChestBlockEntity)blockEntity).setLootTable(BuiltInLootTables.IGLOO_CHEST, random.nextLong()); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch index 8a635d5f1123..1794d24018d5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch @@ -4,7 +4,7 @@ BlockPos worldPos = this.getWorldPos(1, 0, i8); if (box.isInside(worldPos) && this.isInterior(level, 1, 0, i8, box)) { this.hasPlacedSpider = true; -- level.setBlock(worldPos, Blocks.SPAWNER.defaultBlockState(), 2); +- level.setBlock(worldPos, Blocks.SPAWNER.defaultBlockState(), Block.UPDATE_CLIENTS); - if (level.getBlockEntity(worldPos) instanceof SpawnerBlockEntity spawnerBlockEntity) { - spawnerBlockEntity.setEntityId(EntityType.CAVE_SPIDER, random); - } diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch index a8fc4d333a97..abb610b37793 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java -@@ -1076,10 +_,13 @@ +@@ -1077,10 +_,13 @@ BlockPos worldPos = this.getWorldPos(3, 5, 5); if (box.isInside(worldPos)) { this.hasPlacedSpawner = true; -- level.setBlock(worldPos, Blocks.SPAWNER.defaultBlockState(), 2); +- level.setBlock(worldPos, Blocks.SPAWNER.defaultBlockState(), Block.UPDATE_CLIENTS); - if (level.getBlockEntity(worldPos) instanceof SpawnerBlockEntity spawnerBlockEntity) { - spawnerBlockEntity.setEntityId(EntityType.BLAZE, random); - } diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch index 51c57cca9635..b1642fdef4c5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch @@ -1,17 +1,21 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java -@@ -314,12 +_,18 @@ +@@ -314,14 +_,20 @@ @Override protected void handleDataMarker(String name, BlockPos pos, ServerLevelAccessor level, RandomSource random, BoundingBox box) { if ("chest".equals(name)) { -- level.setBlock(pos, Blocks.CHEST.defaultBlockState().setValue(ChestBlock.WATERLOGGED, level.getFluidState(pos).is(FluidTags.WATER)), 2); +- level.setBlock( +- pos, Blocks.CHEST.defaultBlockState().setValue(ChestBlock.WATERLOGGED, level.getFluidState(pos).is(FluidTags.WATER)), Block.UPDATE_CLIENTS +- ); - BlockEntity blockEntity = level.getBlockEntity(pos); - if (blockEntity instanceof ChestBlockEntity) { - ((ChestBlockEntity)blockEntity) - .setLootTable(this.isLarge ? BuiltInLootTables.UNDERWATER_RUIN_BIG : BuiltInLootTables.UNDERWATER_RUIN_SMALL, random.nextLong()); - } + // CraftBukkit start - transform block to ensure loot table is accessible -+ // level.setBlock(pos, Blocks.CHEST.defaultBlockState().setValue(ChestBlock.WATERLOGGED, level.getFluidState(pos).is(FluidTags.WATER)), 2); ++ // level.setBlock( ++ // pos, Blocks.CHEST.defaultBlockState().setValue(ChestBlock.WATERLOGGED, level.getFluidState(pos).is(FluidTags.WATER)), Block.UPDATE_CLIENTS ++ // ); + // BlockEntity blockEntity = level.getBlockEntity(pos); + // if (blockEntity instanceof ChestBlockEntity) { + // ((ChestBlockEntity)blockEntity) @@ -20,7 +24,7 @@ + org.bukkit.craftbukkit.block.CraftChest craftChest = (org.bukkit.craftbukkit.block.CraftChest) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(level, pos, Blocks.CHEST.defaultBlockState().setValue(ChestBlock.WATERLOGGED, level.getFluidState(pos).is(FluidTags.WATER)), null); + craftChest.setSeed(random.nextLong()); + craftChest.setLootTable(org.bukkit.craftbukkit.CraftLootTable.minecraftToBukkit(this.isLarge ? BuiltInLootTables.UNDERWATER_RUIN_BIG : BuiltInLootTables.UNDERWATER_RUIN_SMALL)); -+ this.placeCraftBlockEntity(level, pos, craftChest, 2); ++ this.placeCraftBlockEntity(level, pos, craftChest, Block.UPDATE_CLIENTS); + // CraftBukkit end } else if ("drowned".equals(name)) { Drowned drowned = EntityType.DROWNED.create(level.getLevel(), EntitySpawnReason.STRUCTURE); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch index fd336c1c4951..bb00d122c1b7 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java -@@ -831,10 +_,13 @@ +@@ -832,10 +_,13 @@ BlockPos worldPos = this.getWorldPos(5, 3, 6); if (box.isInside(worldPos)) { this.hasPlacedSpawner = true; -- level.setBlock(worldPos, Blocks.SPAWNER.defaultBlockState(), 2); +- level.setBlock(worldPos, Blocks.SPAWNER.defaultBlockState(), Block.UPDATE_CLIENTS); - if (level.getBlockEntity(worldPos) instanceof SpawnerBlockEntity spawnerBlockEntity) { - spawnerBlockEntity.setEntityId(EntityType.SILVERFISH, random); - } diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch index 719e8cbc54a4..28472f9cc4d1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -32,7 +32,7 @@ if ((!list.isEmpty() || !settings.isIgnoreEntities() && !this.entityInfoList.isEmpty()) && this.size.getX() >= 1 @@ -285,6 +_,21 @@ - level.setBlock(blockPos, Blocks.BARRIER.defaultBlockState(), 820); + level.setBlock(blockPos, Blocks.BARRIER.defaultBlockState(), Block.UPDATE_SKIP_ALL_SIDEEFFECTS | Block.UPDATE_NONE); } + // CraftBukkit start diff --git a/paper-server/patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch b/paper-server/patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch index e2c491ef2c08..f0d1dd9dafcb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -54,7 +54,7 @@ + this.beforeDestroyingBlock(level, pos, state, pos.relative(direction.getOpposite())); // Paper - Add BlockBreakBlockEvent } - level.setBlock(pos, fluidState.createLegacyBlock(), 3); + level.setBlock(pos, fluidState.createLegacyBlock(), Block.UPDATE_ALL); } } @@ -94,7 +94,7 @@ + } + state = ((org.bukkit.craftbukkit.block.data.CraftBlockData) event.getNewData()).getState(); + // CraftBukkit end - level.setBlock(pos, state, 3); + level.setBlock(pos, state, Block.UPDATE_ALL); } else if (newLiquid != fluidState) { fluidState = newLiquid; state = newLiquid.createLegacyBlock(); @@ -105,7 +105,7 @@ + } + state = ((org.bukkit.craftbukkit.block.data.CraftBlockData) event.getNewData()).getState(); + // CraftBukkit end - level.setBlock(pos, state, 3); + level.setBlock(pos, state, Block.UPDATE_ALL); level.scheduleTick(pos, newLiquid.getType(), spreadDelay); } @@ -481,9 +_,27 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch b/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch index ed6198164489..227361c33bcf 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java -@@ -93,6 +_,13 @@ +@@ -95,6 +_,13 @@ BlockState blockState = level.getBlockState(blockPos); if (blockState.isAir()) { if (this.hasFlammableNeighbours(level, blockPos)) { @@ -14,7 +14,7 @@ level.setBlockAndUpdate(blockPos, BaseFireBlock.getState(level, blockPos)); return; } -@@ -108,6 +_,14 @@ +@@ -110,6 +_,14 @@ } if (level.isEmptyBlock(blockPos1.above()) && this.isFlammable(level, blockPos1)) { @@ -29,7 +29,7 @@ level.setBlockAndUpdate(blockPos1.above(), BaseFireBlock.getState(level, blockPos1)); } } -@@ -118,9 +_,10 @@ +@@ -120,9 +_,10 @@ @Override protected void entityInside(Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { @@ -41,11 +41,11 @@ } private boolean hasFlammableNeighbours(LevelReader level, BlockPos pos) { -@@ -208,7 +_,11 @@ +@@ -210,7 +_,11 @@ FluidState fluidState1 = level.getFluidState(pos); if (this.is(FluidTags.LAVA) && fluidState1.is(FluidTags.WATER)) { if (state.getBlock() instanceof LiquidBlock) { -- level.setBlock(pos, Blocks.STONE.defaultBlockState(), 3); +- level.setBlock(pos, Blocks.STONE.defaultBlockState(), Block.UPDATE_ALL); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level.getMinecraftWorld(), pos, Blocks.STONE.defaultBlockState(), 3)) { + return; @@ -54,7 +54,7 @@ } this.fizz(level, pos); -@@ -226,7 +_,7 @@ +@@ -228,7 +_,7 @@ @Override protected float getExplosionResistance() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch index a4ab7b978805..8b702e021f2d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/portal/PortalForcer.java +++ b/net/minecraft/world/level/portal/PortalForcer.java -@@ -38,18 +_,32 @@ +@@ -39,18 +_,32 @@ this.level = level; } @@ -34,7 +34,7 @@ Direction direction = Direction.get(Direction.AxisDirection.POSITIVE, axis); double d = -1.0; BlockPos blockPos = null; -@@ -57,10 +_,15 @@ +@@ -58,10 +_,15 @@ BlockPos blockPos1 = null; WorldBorder worldBorder = this.level.getWorldBorder(); int min = Math.min(this.level.getMaxY(), this.level.getMinY() + this.level.getLogicalHeight() - 1); @@ -51,7 +51,7 @@ int min1 = Math.min(min, this.level.getHeight(Heightmap.Types.MOTION_BLOCKING, mutableBlockPos1.getX(), mutableBlockPos1.getZ())); if (worldBorder.isWithinBounds(mutableBlockPos1) && worldBorder.isWithinBounds(mutableBlockPos1.move(direction, 1))) { mutableBlockPos1.move(direction.getOpposite(), 1); -@@ -104,6 +_,7 @@ +@@ -105,6 +_,7 @@ d = d1; } @@ -59,7 +59,7 @@ if (d == -1.0) { int max = Math.max(this.level.getMinY() - -1, 70); int i4 = min - 9; -@@ -122,7 +_,7 @@ +@@ -123,7 +_,7 @@ mutableBlockPos.setWithOffset( blockPos, i2 * direction.getStepX() + i1x * clockWise.getStepX(), i3, i2 * direction.getStepZ() + i1x * clockWise.getStepZ() ); @@ -68,20 +68,20 @@ } } } -@@ -132,7 +_,7 @@ +@@ -133,7 +_,7 @@ for (int i4 = -1; i4 < 4; i4++) { if (max == -1 || max == 2 || i4 == -1 || i4 == 3) { mutableBlockPos.setWithOffset(blockPos, max * direction.getStepX(), i4, max * direction.getStepZ()); -- this.level.setBlock(mutableBlockPos, Blocks.OBSIDIAN.defaultBlockState(), 3); +- this.level.setBlock(mutableBlockPos, Blocks.OBSIDIAN.defaultBlockState(), Block.UPDATE_ALL); + blockList.setBlock(mutableBlockPos, Blocks.OBSIDIAN.defaultBlockState(), 3); // CraftBukkit } } } -@@ -142,10 +_,20 @@ +@@ -143,10 +_,20 @@ for (int i4x = 0; i4x < 2; i4x++) { for (int min1 = 0; min1 < 3; min1++) { mutableBlockPos.setWithOffset(blockPos, i4x * direction.getStepX(), min1, i4x * direction.getStepZ()); -- this.level.setBlock(mutableBlockPos, blockState1, 18); +- this.level.setBlock(mutableBlockPos, blockState1, Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE); + blockList.setBlock(mutableBlockPos, blockState1, 18); // CraftBukkit } } @@ -99,7 +99,7 @@ return Optional.of(new BlockUtil.FoundRectangle(blockPos.immutable(), 2, 3)); } -@@ -165,6 +_,13 @@ +@@ -166,6 +_,13 @@ i1, direction.getStepZ() * i + clockWise.getStepZ() * offsetScale ); diff --git a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch index 85e23ecea404..6d690ba52d9a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/portal/PortalShape.java +++ b/net/minecraft/world/level/portal/PortalShape.java -@@ -37,8 +_,12 @@ +@@ -38,8 +_,12 @@ private final BlockPos bottomLeft; private final int height; private final int width; @@ -14,7 +14,7 @@ this.axis = axis; this.numPortalBlocks = numPortalBlocks; this.rightDir = rightDir; -@@ -62,24 +_,25 @@ +@@ -63,24 +_,25 @@ } public static PortalShape findAnyShape(BlockGetter level, BlockPos bottomLeft, Direction.Axis axis) { @@ -47,7 +47,7 @@ int max = Math.max(level.getMinY(), pos.getY() - 21); while (pos.getY() > max && isEmpty(level.getBlockState(pos.below()))) { -@@ -87,16 +_,16 @@ +@@ -88,16 +_,16 @@ } Direction opposite = direction.getOpposite(); @@ -68,7 +68,7 @@ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); for (int i = 0; i <= 21; i++) { -@@ -104,6 +_,7 @@ +@@ -105,6 +_,7 @@ BlockState blockState = level.getBlockState(mutableBlockPos); if (!isEmpty(blockState)) { if (FRAME.test(blockState, level, mutableBlockPos)) { @@ -76,7 +76,7 @@ return i; } break; -@@ -113,32 +_,34 @@ +@@ -114,32 +_,34 @@ if (!FRAME.test(blockState1, level, mutableBlockPos)) { break; } @@ -116,7 +116,7 @@ ) { for (int i = 0; i < 21; i++) { checkPos.set(pos).move(Direction.UP, i).move(direction, -1); -@@ -162,6 +_,10 @@ +@@ -163,6 +_,10 @@ portalBlocks.increment(); } } @@ -127,7 +127,7 @@ } return 21; -@@ -175,10 +_,23 @@ +@@ -176,10 +_,23 @@ return this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } @@ -147,7 +147,7 @@ + } + // CraftBukkit end + BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)) - .forEach(pos -> level.setBlock(pos, blockState, 18)); + .forEach(pos -> level.setBlock(pos, blockState, Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE)); + return true; // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/level/portal/TeleportTransition.java.patch b/paper-server/patches/sources/net/minecraft/world/level/portal/TeleportTransition.java.patch index c1db4c688d4d..e497a2065335 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/portal/TeleportTransition.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/portal/TeleportTransition.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/portal/TeleportTransition.java +++ b/net/minecraft/world/level/portal/TeleportTransition.java -@@ -20,11 +_,18 @@ +@@ -21,11 +_,18 @@ boolean asPassenger, Set relatives, TeleportTransition.PostTeleportTransition postTeleportTransition @@ -19,7 +19,7 @@ public TeleportTransition( ServerLevel newLevel, Vec3 position, Vec3 deltaMovement, float yRot, float xRot, TeleportTransition.PostTeleportTransition postTeleportTransition ) { -@@ -40,7 +_,21 @@ +@@ -41,7 +_,21 @@ Set relatives, TeleportTransition.PostTeleportTransition postTeleportTransition ) { @@ -42,7 +42,7 @@ } private static void playPortalSound(Entity entity) { -@@ -99,7 +_,8 @@ +@@ -100,7 +_,8 @@ this.missingRespawnBlock(), this.asPassenger(), this.relatives(), @@ -52,7 +52,7 @@ ); } -@@ -113,7 +_,8 @@ +@@ -114,7 +_,8 @@ this.missingRespawnBlock(), this.asPassenger(), this.relatives(), @@ -62,7 +62,7 @@ ); } -@@ -127,7 +_,8 @@ +@@ -128,7 +_,8 @@ this.missingRespawnBlock(), true, this.relatives(), diff --git a/paper-server/patches/sources/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java.patch index 29135915123f..772d6eb81bc4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java +++ b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java -@@ -17,7 +_,16 @@ +@@ -18,7 +_,16 @@ @Override public void updatePowerStrength(Level level, BlockPos pos, BlockState state, @Nullable Orientation orientation, boolean updateShape) { int i = this.calculateTargetStrength(level, pos); @@ -16,5 +16,5 @@ + if (oldPower != i) { + // CraftBukkit end if (level.getBlockState(pos) == state) { - level.setBlock(pos, state.setValue(RedStoneWireBlock.POWER, i), 2); + level.setBlock(pos, state.setValue(RedStoneWireBlock.POWER, i), Block.UPDATE_CLIENTS); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java.patch index 271f636860a3..15f6e44d7221 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java +++ b/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java -@@ -38,7 +_,16 @@ +@@ -39,7 +_,16 @@ int intValue = entry.getIntValue(); int i = unpackPower(intValue); BlockState blockState = level.getBlockState(blockPos); @@ -15,6 +15,6 @@ + } + if (blockState.is(this.wireBlock) && oldPower != i) { + // CraftBukkit end - int i1 = 2; + int i1 = Block.UPDATE_CLIENTS; if (!updateShape || !flag) { - i1 |= 128; + i1 |= Block.UPDATE_SKIP_SHAPE_UPDATE_ON_WIRE; From 3bec17f6ced6825605c6f8df04961b5e9d0a03dc Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sun, 26 Oct 2025 21:54:10 +0100 Subject: [PATCH 032/112] add missing Block.UpdateFlag annotations only on non patched files for now --- .../paper/antixray/ChunkPacketBlockController.java | 3 ++- .../ChunkPacketBlockControllerAntiXray.java | 2 +- .../craftbukkit/block/CapturedBlockState.java | 6 +++--- .../org/bukkit/craftbukkit/block/CraftBlock.java | 2 +- .../craftbukkit/block/CraftBlockEntityState.java | 2 +- .../bukkit/craftbukkit/block/CraftBlockState.java | 9 +++++---- .../craftbukkit/event/CraftEventFactory.java | 14 +++++++------- .../craftbukkit/util/BlockStateListPopulator.java | 3 ++- .../org/bukkit/craftbukkit/util/CapturedBlock.java | 3 ++- .../craftbukkit/util/DelegatedGeneratorAccess.java | 6 +++--- .../craftbukkit/util/DummyGeneratorAccess.java | 2 +- .../util/TransformerGeneratorAccess.java | 8 ++++---- 12 files changed, 32 insertions(+), 28 deletions(-) diff --git a/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockController.java b/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockController.java index 69b553747b33..568d12d00699 100644 --- a/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockController.java +++ b/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockController.java @@ -8,6 +8,7 @@ import net.minecraft.server.level.ServerPlayerGameMode; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.LevelChunk; @@ -35,7 +36,7 @@ public void modifyBlocks(ClientboundLevelChunkWithLightPacket chunkPacket, Chunk chunkPacket.setReady(true); } - public void onBlockChange(Level level, BlockPos blockPos, BlockState newBlockState, BlockState oldBlockState, int flags, int maxUpdateDepth) { + public void onBlockChange(Level level, BlockPos blockPos, BlockState newBlockState, BlockState oldBlockState, @Block.UpdateFlags int flags, int maxUpdateDepth) { } diff --git a/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockControllerAntiXray.java index 3f21d3f49098..b03b2d098c20 100644 --- a/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockControllerAntiXray.java +++ b/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockControllerAntiXray.java @@ -608,7 +608,7 @@ private boolean[] readPalette(Palette palette, boolean[] temp, boole } @Override - public void onBlockChange(Level level, BlockPos blockPos, BlockState newBlockState, BlockState oldBlockState, int flags, int maxUpdateDepth) { + public void onBlockChange(Level level, BlockPos blockPos, BlockState newBlockState, BlockState oldBlockState, @Block.UpdateFlags int flags, int maxUpdateDepth) { if (oldBlockState != null && solidGlobal[GLOBAL_BLOCKSTATE_PALETTE.idFor(oldBlockState, PaletteResize.noResizeExpected())] && !solidGlobal[GLOBAL_BLOCKSTATE_PALETTE.idFor(newBlockState, PaletteResize.noResizeExpected())] && blockPos.getY() <= maxBlockHeightUpdatePosition) { updateNearbyBlocks(level, blockPos); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java index c00a267eaa5c..00912f0e5f11 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java @@ -38,7 +38,7 @@ public boolean update(boolean force, boolean applyPhysics) { } @Override - public boolean place(int flags) { + public boolean place(@net.minecraft.world.level.block.Block.UpdateFlags int flags) { boolean result = super.place(flags); this.addBees(); @@ -74,7 +74,7 @@ public CapturedBlockState copy(Location location) { return new CapturedBlockState(this, location); } - public static CapturedBlockState getTreeBlockState(Level world, BlockPos pos, int flag) { - return new CapturedBlockState(CraftBlock.at(world, pos), flag, true); + public static CapturedBlockState getTreeBlockState(Level world, BlockPos pos, @net.minecraft.world.level.block.Block.UpdateFlags int flags) { + return new CapturedBlockState(CraftBlock.at(world, pos), flags, true); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 73365f4b90e8..f3a5c5d610a4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -154,7 +154,7 @@ public void setData(final byte data, boolean applyPhysics) { } } - private void setData(final byte data, int flags) { + private void setData(final byte data, @net.minecraft.world.level.block.Block.UpdateFlags int flags) { this.world.setBlock(this.position, CraftMagicNumbers.getBlock(this.getType(), data), flags); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java index 5d4faad9df48..26feb76c5263 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java @@ -201,7 +201,7 @@ public boolean update(boolean force, boolean applyPhysics) { } @Override - public boolean place(int flags) { + public boolean place(@net.minecraft.world.level.block.Block.UpdateFlags int flags) { boolean result = super.place(flags); this.getWorldHandle().getBlockEntity(this.getPosition(), this.blockEntity.getType()).ifPresent(blockEntity -> { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index 196835bdf95b..3036f3fa8b58 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -28,6 +28,7 @@ public class CraftBlockState implements BlockState { protected final CraftWorld world; private final BlockPos position; protected net.minecraft.world.level.block.state.BlockState data; + @net.minecraft.world.level.block.Block.UpdateFlags protected int capturedFlags; // todo move out of this class private WeakReference weakWorld; @@ -39,7 +40,7 @@ protected CraftBlockState(final Block block) { } @Deprecated - protected CraftBlockState(final Block block, int capturedFlags) { + protected CraftBlockState(final Block block, @net.minecraft.world.level.block.Block.UpdateFlags int capturedFlags) { this(block); this.capturedFlags = capturedFlags; } @@ -181,11 +182,11 @@ public Material getType() { return this.data.getBukkitMaterial(); } - public void setFlags(int flags) { + public void setFlags(@net.minecraft.world.level.block.Block.UpdateFlags int flags) { this.capturedFlags = flags; } - public int getFlags() { + public @net.minecraft.world.level.block.Block.UpdateFlags int getFlags() { return this.capturedFlags; } @@ -244,7 +245,7 @@ public boolean update(boolean force, boolean applyPhysics) { } // used when the flags matter for non API usage - public boolean place(int flags) { + public boolean place(@net.minecraft.world.level.block.Block.UpdateFlags int flags) { if (!this.isPlaced()) { return false; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 0893b0d26214..7e909fa6537d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -834,7 +834,7 @@ public static BlockFadeEvent callBlockFadeEvent(LevelAccessor world, BlockPos po return event; } - public static boolean handleMoistureChangeEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags) { + public static boolean handleMoistureChangeEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @net.minecraft.world.level.block.Block.UpdateFlags int flags) { CraftBlockState snapshot = CraftBlockStates.getBlockState(world, pos); snapshot.setData(state); @@ -848,11 +848,11 @@ public static boolean handleMoistureChangeEvent(Level world, BlockPos pos, net.m public static BlockPos sourceBlockOverride = null; // SPIGOT-7068: Add source block override, not the most elegant way but better than passing down a BlockPos up to five methods deep. - public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState state, int flags) { + public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState state, @net.minecraft.world.level.block.Block.UpdateFlags int flags) { return handleBlockSpreadEvent(world, source, target, state, flags, false); } - public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState state, int flags, boolean checkSetResult) { + public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState state, @net.minecraft.world.level.block.Block.UpdateFlags int flags, boolean checkSetResult) { // Suppress during worldgen if (!(world instanceof Level)) { boolean result = world.setBlock(target, state, flags); @@ -1201,7 +1201,7 @@ public static PlayerExpChangeEvent callPlayerExpChangeEvent(net.minecraft.world. return event; } - public static boolean handleBlockGrowEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags) { + public static boolean handleBlockGrowEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @net.minecraft.world.level.block.Block.UpdateFlags int flags) { CraftBlockState snapshot = CraftBlockStates.getBlockState(world, pos); snapshot.setData(state); @@ -1819,15 +1819,15 @@ public static EntityPotionEffectEvent callEntityPotionEffectChangeEvent(net.mine return event; } - public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags) { + public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @net.minecraft.world.level.block.Block.UpdateFlags int flags) { return CraftEventFactory.handleBlockFormEvent(world, pos, state, flags, null); } - public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags, @Nullable Entity entity) { + public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @net.minecraft.world.level.block.Block.UpdateFlags int flags, @Nullable Entity entity) { return CraftEventFactory.handleBlockFormEvent(world, pos, state, flags, entity, false); } - public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags, @Nullable Entity entity, boolean checkSetResult) { + public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @net.minecraft.world.level.block.Block.UpdateFlags int flags, @Nullable Entity entity, boolean checkSetResult) { CraftBlockState snapshot = CraftBlockStates.getBlockState(world, pos); snapshot.setData(state); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java index cb9488fbad9d..7cfb0b878c1b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java @@ -12,6 +12,7 @@ import net.minecraft.util.RandomSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.dimension.DimensionType; @@ -51,7 +52,7 @@ public BlockEntity getBlockEntity(BlockPos pos) { } @Override - public boolean setBlock(BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags, int recursionLeft) { + public boolean setBlock(BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @Block.UpdateFlags int flags, int recursionLeft) { pos = pos.immutable(); // remove first to keep last updated order this.blocks.remove(pos); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CapturedBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CapturedBlock.java index d1e0c0610baa..0e2f27db42c7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CapturedBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CapturedBlock.java @@ -1,10 +1,11 @@ package org.bukkit.craftbukkit.util; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @NullMarked -public record CapturedBlock(BlockState state, int flags, @Nullable BlockEntity blockEntity) { +public record CapturedBlock(BlockState state, @Block.UpdateFlags int flags, @Nullable BlockEntity blockEntity) { } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java index 15367aa8300d..d3053d0939cd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java @@ -178,7 +178,7 @@ public void updateNeighborsAt(BlockPos pos, Block block) { } @Override - public void neighborShapeChanged(Direction direction, BlockPos pos, BlockPos neighborPos, BlockState neighborState, int flags, int recursionLeft) { + public void neighborShapeChanged(Direction direction, BlockPos pos, BlockPos neighborPos, BlockState neighborState, @Block.UpdateFlags int flags, int recursionLeft) { this.delegate.neighborShapeChanged(direction, pos, neighborPos, neighborState, flags, recursionLeft); } @@ -683,12 +683,12 @@ public Player getPlayerByUUID(UUID uuid) { } @Override - public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) { + public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags, int recursionLeft) { return this.delegate.setBlock(pos, state, flags, recursionLeft); } @Override - public boolean setBlock(BlockPos pos, BlockState state, int flags) { + public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags) { return this.delegate.setBlock(pos, state, flags); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java index f64bcc041a2e..3693c069f911 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -250,7 +250,7 @@ public boolean isFluidAtPosition(BlockPos pos, Predicate state) { } @Override - public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) { + public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags, int recursionLeft) { return false; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerGeneratorAccess.java index aed42b21137f..c698c8438052 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerGeneratorAccess.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerGeneratorAccess.java @@ -51,7 +51,7 @@ public boolean addFreshEntity(Entity entity, @Nullable SpawnReason reason) { return super.addFreshEntity(entity, reason); } - public boolean setCraftBlock(BlockPos position, CraftBlockState craftBlockState, int flags, int recursionLeft) { + public boolean setCraftBlock(BlockPos position, CraftBlockState craftBlockState, @Block.UpdateFlags int flags, int recursionLeft) { craftBlockState = this.structureTransformer.transformCraftState(craftBlockState); // This code is based on the method 'net.minecraft.world.level.levelgen.structure.StructurePiece#placeBlock' // It ensures that any kind of block is updated correctly upon placing it @@ -77,12 +77,12 @@ public boolean setCraftBlock(BlockPos position, CraftBlockState craftBlockState, return result; } - public boolean setCraftBlock(BlockPos pos, CraftBlockState craftBlockState, int flags) { + public boolean setCraftBlock(BlockPos pos, CraftBlockState craftBlockState, @Block.UpdateFlags int flags) { return this.setCraftBlock(pos, craftBlockState, flags, Block.UPDATE_LIMIT); } @Override - public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) { + public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags, int recursionLeft) { if (this.canTransformBlocks()) { return this.setCraftBlock(pos, (CraftBlockState) CraftBlockStates.getBlockState(this, pos, state, null), flags, recursionLeft); } @@ -90,7 +90,7 @@ public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursion } @Override - public boolean setBlock(BlockPos pos, BlockState state, int flags) { + public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags) { return this.setBlock(pos, state, flags, Block.UPDATE_LIMIT); } } From 983be46604c0d742c7366a04e5db57973aaaca39 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sun, 26 Oct 2025 22:15:32 +0100 Subject: [PATCH 033/112] uninline some constants --- .../java/org/bukkit/craftbukkit/block/CapturedBlockState.java | 2 +- .../src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java | 2 +- .../java/org/bukkit/craftbukkit/block/CraftStructureBlock.java | 3 ++- .../java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java | 2 +- .../java/org/bukkit/craftbukkit/structure/CraftStructure.java | 3 ++- .../org/bukkit/craftbukkit/util/BlockStateListPopulator.java | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java index 00912f0e5f11..6b5853ced761 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java @@ -15,7 +15,7 @@ public final class CapturedBlockState extends CraftBlockState { private final boolean treeBlock; - public CapturedBlockState(Block block, int capturedFlags, boolean treeBlock) { + public CapturedBlockState(Block block, @net.minecraft.world.level.block.Block.UpdateFlags int capturedFlags, boolean treeBlock) { super(block, capturedFlags); this.treeBlock = treeBlock; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index f3a5c5d610a4..31e665388bc6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -210,7 +210,7 @@ public static boolean setBlockState(LevelAccessor world, BlockPos pos, net.minec return world.setBlock(pos, newState, net.minecraft.world.level.block.Block.UPDATE_ALL); } else { boolean success = world.setBlock(pos, newState, - net.minecraft.world.level.block.Block.UPDATE_CLIENTS | + net.minecraft.world.level.block.Block.UPDATE_CLIENTS | net.minecraft.world.level.block.Block.UPDATE_KNOWN_SHAPE | net.minecraft.world.level.block.Block.UPDATE_SKIP_ON_PLACE); if (success && world instanceof net.minecraft.world.level.Level) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java index 1d87f637d262..b7f08dc4133b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.block; import com.google.common.base.Preconditions; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.entity.StructureBlockEntity; import net.minecraft.world.level.block.state.properties.StructureMode; @@ -192,7 +193,7 @@ protected void applyTo(StructureBlockEntity blockEntity) { // From StructureBlockEntity#setMode(BlockPropertyStructureMode) net.minecraft.world.level.block.state.BlockState state = access.getBlockState(this.getPosition()); if (state.is(net.minecraft.world.level.block.Blocks.STRUCTURE_BLOCK)) { - access.setBlock(this.getPosition(), state.setValue(net.minecraft.world.level.block.StructureBlock.MODE, blockEntity.getMode()), 2); + access.setBlock(this.getPosition(), state.setValue(net.minecraft.world.level.block.StructureBlock.MODE, blockEntity.getMode()), Block.UPDATE_CLIENTS); } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 939cdd623253..73b55c2de10d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -203,7 +203,7 @@ public boolean sleep(Location location, boolean force) { // From BlockBed state = state.setValue(BedBlock.OCCUPIED, true); - this.getHandle().level().setBlock(pos, state, 4); + this.getHandle().level().setBlock(pos, state, net.minecraft.world.level.block.Block.UPDATE_INVISIBLE); return true; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructure.java b/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructure.java index f4fca4614a5d..8065aedbee7f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructure.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructure.java @@ -16,6 +16,7 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.levelgen.structure.templatesystem.BlockRotProcessor; @@ -103,7 +104,7 @@ public void place(RegionAccessor regionAccessor, BlockVector location, boolean i access.setDelegate(handle); access.setStructureTransformer(new CraftStructureTransformer(handle, new ChunkPos(pos), blockTransformers, entityTransformers)); - this.structure.placeInWorld(access, pos, pos, definedstructureinfo, randomSource, 2); + this.structure.placeInWorld(access, pos, pos, definedstructureinfo, randomSource, Block.UPDATE_CLIENTS); access.getStructureTransformer().discard(); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java index 7cfb0b878c1b..989b2f751a59 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java @@ -82,7 +82,7 @@ public boolean destroyBlock(BlockPos pos, boolean dropBlock, Entity entity, int return false; } - this.setBlock(pos, blockState.getFluidState().createLegacyBlock(), 3, recursionLeft); // capture block without the event + this.setBlock(pos, blockState.getFluidState().createLegacyBlock(), Block.UPDATE_ALL, recursionLeft); // capture block without the event return true; } From 9a3462f26c7d1307115533ee78f433a2ec3cb133 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 27 Oct 2025 09:42:44 -0700 Subject: [PATCH 034/112] Update mache --- paper-server/build.gradle.kts | 2 +- .../server/level/ServerLevel.java.patch | 58 +++++++------- .../server/level/ServerPlayer.java.patch | 76 +++++++++--------- .../server/players/PlayerList.java.patch | 39 +++++---- .../world/entity/animal/Pufferfish.java.patch | 4 +- .../entity/monster/ElderGuardian.java.patch | 2 +- .../projectile/AbstractArrow.java.patch | 10 +-- .../minecraft/world/item/AxeItem.java.patch | 2 +- .../world/level/GameRules.java.patch | 80 +++++++++---------- 9 files changed, 136 insertions(+), 137 deletions(-) diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index a4aefc863e16..a1fe51814259 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:25w43a+build.5") + mache("io.papermc:mache:25w43a+build.6") paperclip("io.papermc:paperclip:3.0.3") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch index 0fcaf074de05..ddcca2e71b07 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -409,7 +409,7 @@ if (this.oRainLevel != this.rainLevel) { this.server .getPlayerList() -@@ -769,14 +_,47 @@ +@@ -765,14 +_,47 @@ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -461,7 +461,7 @@ } public void resetEmptyTime() { -@@ -798,18 +_,46 @@ +@@ -794,18 +_,46 @@ } } @@ -508,7 +508,7 @@ } private void tickPassenger(Entity ridingEntity, Entity passengerEntity) { -@@ -818,10 +_,12 @@ +@@ -814,10 +_,12 @@ } else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) { passengerEntity.setOldPosAndRot(); passengerEntity.tickCount++; @@ -521,7 +521,7 @@ profilerFiller.pop(); for (Entity entity : passengerEntity.getPassengers()) { -@@ -852,6 +_,7 @@ +@@ -848,6 +_,7 @@ public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) { ServerChunkCache chunkSource = this.getChunkSource(); if (!skipSave) { @@ -529,7 +529,7 @@ if (progress != null) { progress.progressStartNoAbort(Component.translatable("menu.savingLevel")); } -@@ -868,11 +_,18 @@ +@@ -864,11 +_,18 @@ this.entityManager.autoSave(); } } @@ -549,7 +549,7 @@ } DimensionDataStorage dataStorage = this.getChunkSource().getDataStorage(); -@@ -937,18 +_,40 @@ +@@ -933,18 +_,40 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -593,7 +593,7 @@ } } -@@ -971,41 +_,120 @@ +@@ -967,41 +_,120 @@ this.entityManager.addNewEntity(player); } @@ -719,7 +719,7 @@ if (d * d + d1 * d1 + d2 * d2 < 1024.0) { serverPlayer.connection.send(new ClientboundBlockDestructionPacket(breakerId, pos, progress)); } -@@ -1080,7 +_,7 @@ +@@ -1076,7 +_,7 @@ pos.getX(), pos.getY(), pos.getZ(), @@ -728,7 +728,7 @@ this.dimension(), new ClientboundLevelEventPacket(type, pos, data, false) ); -@@ -1092,6 +_,11 @@ +@@ -1088,6 +_,11 @@ @Override public void gameEvent(Holder gameEvent, Vec3 pos, GameEvent.Context context) { @@ -740,7 +740,7 @@ this.gameEventDispatcher.post(gameEvent, pos, context); } -@@ -1104,17 +_,28 @@ +@@ -1100,17 +_,28 @@ this.getChunkSource().blockChanged(pos); this.pathTypesByPosCache.invalidate(pos); @@ -769,7 +769,7 @@ try { this.isUpdatingNavigations = true; -@@ -1126,15 +_,23 @@ +@@ -1122,15 +_,23 @@ this.isUpdatingNavigations = false; } } @@ -793,7 +793,7 @@ this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, block, null, orientation); } -@@ -1184,6 +_,44 @@ +@@ -1180,6 +_,44 @@ WeightedList blockParticles, Holder explosionSound ) { @@ -838,7 +838,7 @@ Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) { case NONE -> Explosion.BlockInteraction.KEEP; case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); -@@ -1192,10 +_,17 @@ +@@ -1188,10 +_,17 @@ : Explosion.BlockInteraction.KEEP; case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY); case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; @@ -856,7 +856,7 @@ ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles; for (ServerPlayer serverPlayer : this.players) { -@@ -1204,6 +_,8 @@ +@@ -1200,6 +_,8 @@ serverPlayer.connection.send(new ClientboundExplodePacket(vec3, radius, i, optional, particleOptions, explosionSound, blockParticles)); } } @@ -865,7 +865,7 @@ } private Explosion.BlockInteraction getDestroyType(GameRules.Key decayGameRule) { -@@ -1274,19 +_,55 @@ +@@ -1270,19 +_,55 @@ public int sendParticles( T options, double x, double y, double z, int count, double xDist, double yDist, double zDist, double speed ) { @@ -924,7 +924,7 @@ if (this.sendParticles(serverPlayer, overrideLimiter, x, y, z, clientboundLevelParticlesPacket)) { i++; } -@@ -1375,7 +_,7 @@ +@@ -1371,7 +_,7 @@ @Nullable public BlockPos findNearestMapStructure(TagKey structureTag, BlockPos pos, int radius, boolean skipKnownStructures) { @@ -933,7 +933,7 @@ return null; } else { Optional> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag); -@@ -1429,10 +_,36 @@ +@@ -1425,10 +_,36 @@ @Nullable @Override public MapItemSavedData getMapData(MapId mapId) { @@ -971,7 +971,7 @@ this.getServer().overworld().getDataStorage().set(MapItemSavedData.type(mapId), data); } -@@ -1442,7 +_,19 @@ +@@ -1438,7 +_,19 @@ @Override public void setRespawnData(LevelData.RespawnData respawnData) { @@ -992,7 +992,7 @@ } @Override -@@ -1479,6 +_,11 @@ +@@ -1475,6 +_,11 @@ this.debugSynchronizers.dropPoi(blockPos); })); optional1.ifPresent(holder -> this.getServer().execute(() -> { @@ -1004,7 +1004,7 @@ PoiRecord poiRecord = this.getPoiManager().add(blockPos, (Holder)holder); if (poiRecord != null) { this.debugSynchronizers.registerPoi(poiRecord); -@@ -1633,12 +_,12 @@ +@@ -1629,12 +_,12 @@ } public boolean isFlat() { @@ -1019,7 +1019,7 @@ } @Nullable -@@ -1689,6 +_,7 @@ +@@ -1685,6 +_,7 @@ @Override public LevelEntityGetter getEntities() { @@ -1027,7 +1027,7 @@ return this.entityManager.getEntityGetter(); } -@@ -1799,6 +_,28 @@ +@@ -1795,6 +_,28 @@ return this.serverLevelData.getGameRules(); } @@ -1056,7 +1056,7 @@ @Override public CrashReportCategory fillReportDetails(CrashReport report) { CrashReportCategory crashReportCategory = super.fillReportDetails(report); -@@ -1843,6 +_,7 @@ +@@ -1839,6 +_,7 @@ if (entity instanceof WaypointTransmitter waypointTransmitter && waypointTransmitter.isTransmittingWaypoint()) { ServerLevel.this.getWaypointManager().trackWaypoint(waypointTransmitter); } @@ -1064,7 +1064,7 @@ } @Override -@@ -1856,17 +_,24 @@ +@@ -1852,17 +_,24 @@ @Override public void onTickingStart(Entity entity) { @@ -1090,7 +1090,7 @@ if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.add(serverPlayer); if (serverPlayer.isReceivingWaypoints()) { -@@ -1881,7 +_,7 @@ +@@ -1877,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1099,7 +1099,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1898,10 +_,52 @@ +@@ -1894,10 +_,52 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -1152,7 +1152,7 @@ ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); -@@ -1910,7 +_,7 @@ +@@ -1906,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1161,7 +1161,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1928,6 +_,15 @@ +@@ -1924,6 +_,15 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); ServerLevel.this.debugSynchronizers.dropEntity(entity); @@ -1177,7 +1177,7 @@ } @Override -@@ -1935,4 +_,24 @@ +@@ -1931,4 +_,24 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::move); } } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index cbe6cd1e9946..db28efcd82db 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -750,7 +750,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1098,13 +_,48 @@ +@@ -1097,13 +_,48 @@ ServerLevel level = teleportTransition.newLevel(); ServerLevel serverLevel = this.level(); @@ -802,7 +802,7 @@ this.connection.resetPosition(); teleportTransition.postTeleportTransition().onTransition(this); return this; -@@ -1115,18 +_,19 @@ +@@ -1114,18 +_,19 @@ this.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); PlayerList playerList = this.server.getPlayerList(); playerList.sendPlayerPermissionLevel(this); @@ -824,7 +824,7 @@ this.connection.resetPosition(); level.addDuringTeleport(this); profilerFiller.pop(); -@@ -1141,6 +_,15 @@ +@@ -1140,6 +_,15 @@ this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(teleportTransition, serverLevel); @@ -840,7 +840,7 @@ return this; } } -@@ -1155,12 +_,26 @@ +@@ -1154,12 +_,26 @@ public void triggerDimensionChangeTriggers(ServerLevel level) { ResourceKey resourceKey = level.dimension(); ResourceKey resourceKey1 = this.level().dimension(); @@ -870,7 +870,7 @@ this.enteredNetherPosition = null; } } -@@ -1176,9 +_,8 @@ +@@ -1175,9 +_,8 @@ this.containerMenu.broadcastChanges(); } @@ -882,7 +882,7 @@ if (!this.isSleeping() && this.isAlive()) { BedRule bedRule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, bedPos); boolean canSleep = bedRule.canSleep(this.level()); -@@ -1192,7 +_,7 @@ +@@ -1191,7 +_,7 @@ } else { if (canSetSpawn) { this.setRespawnPosition( @@ -891,7 +891,7 @@ ); } -@@ -1214,7 +_,37 @@ +@@ -1213,7 +_,37 @@ } } @@ -930,7 +930,7 @@ this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1224,10 +_,7 @@ +@@ -1223,10 +_,7 @@ this.level().updateSleepingPlayerList(); return either; @@ -941,7 +941,7 @@ } } -@@ -1253,21 +_,29 @@ +@@ -1252,21 +_,29 @@ @Override public void stopSleepInBed(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) { @@ -974,7 +974,7 @@ } @Override -@@ -1315,8 +_,9 @@ +@@ -1314,8 +_,9 @@ this.connection.send(new ClientboundShowDialogPacket(dialog)); } @@ -985,7 +985,7 @@ } @Override -@@ -1324,12 +_,39 @@ +@@ -1323,12 +_,39 @@ if (menu == null) { return OptionalInt.empty(); } else { @@ -1026,7 +1026,7 @@ if (abstractContainerMenu == null) { if (this.isSpectator()) { this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true); -@@ -1337,10 +_,14 @@ +@@ -1336,10 +_,14 @@ return OptionalInt.empty(); } else { @@ -1043,7 +1043,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1353,14 +_,25 @@ +@@ -1352,14 +_,25 @@ @Override public void openHorseInventory(AbstractHorse horse, Container inventory) { @@ -1072,7 +1072,7 @@ this.initMenu(this.containerMenu); } -@@ -1382,10 +_,30 @@ +@@ -1381,10 +_,30 @@ @Override public void closeContainer() { @@ -1103,7 +1103,7 @@ @Override public void doCloseContainer() { this.containerMenu.removed(this); -@@ -1408,19 +_,19 @@ +@@ -1407,19 +_,19 @@ int rounded = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); if (rounded > 0) { this.awardStat(Stats.SWIM_ONE_CM, rounded); @@ -1126,7 +1126,7 @@ } } else if (this.onClimbable()) { if (dy > 0.0) { -@@ -1431,13 +_,13 @@ +@@ -1430,13 +_,13 @@ if (rounded > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, rounded); @@ -1143,7 +1143,7 @@ } } } else if (this.isFallFlying()) { -@@ -1479,13 +_,13 @@ +@@ -1478,13 +_,13 @@ @Override public void awardStat(Stat stat, int amount) { this.stats.increment(this, stat, amount); @@ -1159,7 +1159,7 @@ } @Override -@@ -1516,9 +_,9 @@ +@@ -1515,9 +_,9 @@ super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1171,7 +1171,7 @@ } } -@@ -1533,6 +_,13 @@ +@@ -1532,6 +_,13 @@ public void disconnect() { this.disconnected = true; this.ejectPassengers(); @@ -1185,7 +1185,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, false); } -@@ -1544,6 +_,7 @@ +@@ -1543,6 +_,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1193,7 +1193,7 @@ } @Override -@@ -1578,12 +_,12 @@ +@@ -1577,12 +_,12 @@ this.onUpdateAbilities(); if (keepEverything) { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1208,7 +1208,7 @@ } this.getInventory().replaceWith(that.getInventory()); -@@ -1594,7 +_,7 @@ +@@ -1593,7 +_,7 @@ this.portalProcess = that.portalProcess; } else { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1217,7 +1217,7 @@ if (this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || that.isSpectator()) { this.getInventory().replaceWith(that.getInventory()); this.experienceLevel = that.experienceLevel; -@@ -1610,7 +_,7 @@ +@@ -1609,7 +_,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1226,7 +1226,7 @@ this.seenCredits = that.seenCredits; this.enteredNetherPosition = that.enteredNetherPosition; this.chunkTrackingView = that.chunkTrackingView; -@@ -1653,9 +_,22 @@ +@@ -1652,9 +_,22 @@ CriteriaTriggers.EFFECTS_CHANGED.trigger(this, null); } @@ -1250,7 +1250,7 @@ } @Override -@@ -1664,7 +_,7 @@ +@@ -1663,7 +_,7 @@ } @Override @@ -1259,7 +1259,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, true); } -@@ -1673,7 +_,7 @@ +@@ -1672,7 +_,7 @@ this.setCamera(this); } @@ -1268,7 +1268,7 @@ if (flag) { this.setYHeadRot(relativeMovements.contains(Relative.Y_ROT) ? this.getYHeadRot() + yaw : yaw); this.connection.resetFlyingTicks(); -@@ -1712,9 +_,19 @@ +@@ -1711,9 +_,19 @@ } public boolean setGameMode(GameType gameMode) { @@ -1290,7 +1290,7 @@ } else { this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, gameMode.getId())); if (gameMode == GameType.SPECTATOR) { -@@ -1730,7 +_,7 @@ +@@ -1729,7 +_,7 @@ this.onUpdateAbilities(); this.updateEffectVisibility(); @@ -1299,7 +1299,7 @@ } } -@@ -1786,8 +_,13 @@ +@@ -1785,8 +_,13 @@ } public void sendChatMessage(OutgoingChatMessage message, boolean filtered, ChatType.Bound boundChatType) { @@ -1314,7 +1314,7 @@ } } -@@ -1798,7 +_,42 @@ +@@ -1797,7 +_,42 @@ } public void updateOptions(ClientInformation clientInformation) { @@ -1357,7 +1357,7 @@ this.requestedViewDistance = clientInformation.viewDistance(); this.chatVisibility = clientInformation.chatVisibility(); this.canChatColor = clientInformation.chatColors(); -@@ -1884,8 +_,23 @@ +@@ -1883,8 +_,23 @@ Entity camera = this.getCamera(); this.camera = (Entity)(entityToSpectate == null ? this : entityToSpectate); if (camera != this.camera) { @@ -1382,7 +1382,7 @@ } if (entityToSpectate != null) { -@@ -1919,11 +_,11 @@ +@@ -1918,11 +_,11 @@ @Nullable public Component getTabListDisplayName() { @@ -1396,7 +1396,7 @@ } @Override -@@ -1954,11 +_,62 @@ +@@ -1953,11 +_,62 @@ } public void setRespawnPosition(@Nullable ServerPlayer.RespawnConfig respawnConfig, boolean displayInChat) { @@ -1461,7 +1461,7 @@ } public SectionPos getLastSectionPos() { -@@ -1988,16 +_,23 @@ +@@ -1987,16 +_,23 @@ } @Override @@ -1490,7 +1490,7 @@ return itemEntity; } -@@ -2120,9 +_,9 @@ +@@ -2119,9 +_,9 @@ } @Override @@ -1502,7 +1502,7 @@ if (vehicle instanceof LivingEntity livingEntity) { for (MobEffectInstance mobEffectInstance : livingEntity.getActiveEffects()) { this.connection.send(new ClientboundRemoveMobEffectPacket(vehicle.getId(), mobEffectInstance.getEffect())); -@@ -2239,7 +_,7 @@ +@@ -2238,7 +_,7 @@ } public static long placeEnderPearlTicket(ServerLevel level, ChunkPos pos) { @@ -1511,7 +1511,7 @@ return TicketType.ENDER_PEARL.timeout(); } -@@ -2269,9 +_,11 @@ +@@ -2268,9 +_,11 @@ } } @@ -1526,7 +1526,7 @@ } private static float calculateLookAtYaw(Vec3 position, BlockPos towardsPos) { -@@ -2291,4 +_,135 @@ +@@ -2290,4 +_,135 @@ ); public static final ServerPlayer.SavedPosition EMPTY = new ServerPlayer.SavedPosition(Optional.empty(), Optional.empty(), Optional.empty()); } diff --git a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch index ae9a5339b899..92c43bf075bd 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch @@ -495,7 +495,7 @@ serverPlayer.copyRespawnPosition(player); } -@@ -405,18 +_,27 @@ +@@ -405,17 +_,26 @@ serverPlayer.addTag(string); } @@ -510,8 +510,7 @@ + serverPlayer.connection.resetPosition(); // Paper - Fix SPIGOT-1903, MC-98153 + level.getChunkSource().addTicketWithRadius(net.minecraft.server.level.TicketType.POST_TELEPORT, new net.minecraft.world.level.ChunkPos(net.minecraft.util.Mth.floor(vec3.x()) >> 4, net.minecraft.util.Mth.floor(vec3.z()) >> 4), 1); // Paper - post teleport ticket type if (teleportTransition.missingRespawnBlock()) { - serverPlayer.connection - .send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, ClientboundGameEventPacket.DEMO_PARAM_INTRO)); + serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); + serverPlayer.setRespawnPosition(null, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed } @@ -524,7 +523,7 @@ serverPlayer.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); serverPlayer.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); serverPlayer.connection -@@ -426,9 +_,15 @@ +@@ -425,9 +_,15 @@ this.sendPlayerPermissionLevel(serverPlayer); level.addRespawnedPlayer(serverPlayer); this.players.add(serverPlayer); @@ -540,7 +539,7 @@ ServerPlayer.RespawnConfig respawnConfig = serverPlayer.getRespawnConfig(); if (!keepInventory && respawnConfig != null) { LevelData.RespawnData respawnData = respawnConfig.respawnData(); -@@ -454,6 +_,29 @@ +@@ -453,6 +_,29 @@ } } @@ -570,7 +569,7 @@ return serverPlayer; } -@@ -462,23 +_,58 @@ +@@ -461,23 +_,58 @@ } public void sendActiveEffects(LivingEntity entity, ServerGamePacketListenerImpl connection) { @@ -632,7 +631,7 @@ public void broadcastAll(Packet packet) { for (ServerPlayer serverPlayer : this.players) { serverPlayer.connection.send(packet); -@@ -564,6 +_,12 @@ +@@ -563,6 +_,12 @@ } private void sendPlayerPermissionLevel(ServerPlayer player, LevelBasedPermissionSet permissions) { @@ -645,7 +644,7 @@ if (player.connection != null) { byte b = switch (permissions.level()) { case ALL -> EntityEvent.PERMISSION_LEVEL_ALL; -@@ -575,9 +_,48 @@ +@@ -574,9 +_,48 @@ player.connection.send(new ClientboundEntityEventPacket(player, b)); } @@ -696,7 +695,7 @@ public boolean isWhiteListed(NameAndId nameAndId) { return !this.isUsingWhitelist() || this.ops.contains(nameAndId) || this.whitelist.contains(nameAndId); } -@@ -590,21 +_,17 @@ +@@ -589,21 +_,17 @@ @Nullable public ServerPlayer getPlayerByName(String username) { @@ -724,7 +723,7 @@ if (serverPlayer != except && serverPlayer.level().dimension() == dimension) { double d = x - serverPlayer.getX(); double d1 = y - serverPlayer.getY(); -@@ -617,9 +_,11 @@ +@@ -616,9 +_,11 @@ } public void saveAll() { @@ -736,7 +735,7 @@ } public UserWhiteList getWhiteList() { -@@ -646,10 +_,18 @@ +@@ -645,10 +_,18 @@ player.connection.send(new ClientboundInitializeBorderPacket(worldBorder)); player.connection.send(new ClientboundSetTimePacket(level.getGameTime(), level.getDayTime(), level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); @@ -745,7 +744,7 @@ + player.connection.send(new ClientboundSetSimulationDistancePacket(level.spigotConfig.simulationDistance)); + // Paper end if (level.isRaining()) { -- player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, ClientboundGameEventPacket.DEMO_PARAM_INTRO)); +- player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0.0F)); - player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, level.getRainLevel(1.0F))); - player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, level.getThunderLevel(1.0F))); + // CraftBukkit start - handle player weather @@ -757,8 +756,8 @@ + // CraftBukkit end } - player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, ClientboundGameEventPacket.DEMO_PARAM_INTRO)); -@@ -658,8 +_,21 @@ + player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F)); +@@ -657,8 +_,21 @@ public void sendAllPlayerInfo(ServerPlayer player) { player.inventoryMenu.sendAllDataToRemote(); @@ -781,7 +780,7 @@ } public int getPlayerCount() { -@@ -708,9 +_,26 @@ +@@ -707,9 +_,26 @@ } public void removeAll() { @@ -811,7 +810,7 @@ } public void broadcastSystemMessage(Component message, boolean overlay) { -@@ -733,20 +_,39 @@ +@@ -732,20 +_,39 @@ } public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound boundChatType) { @@ -854,7 +853,7 @@ flag1 |= flag2 && message.isFullyFiltered(); } -@@ -759,15 +_,21 @@ +@@ -758,15 +_,21 @@ return message.hasSignature() && !message.hasExpiredServer(Instant.now()); } @@ -881,7 +880,7 @@ Path path = file2.toPath(); if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { file2.renameTo(file1); -@@ -775,7 +_,7 @@ +@@ -774,7 +_,7 @@ } serverStatsCounter = new ServerStatsCounter(this.server, file1); @@ -890,7 +889,7 @@ } return serverStatsCounter; -@@ -783,11 +_,11 @@ +@@ -782,11 +_,11 @@ public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) { UUID uuid = player.getUUID(); @@ -904,7 +903,7 @@ } playerAdvancements.setPlayer(player); -@@ -841,11 +_,34 @@ +@@ -840,11 +_,34 @@ } public void reloadResources() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch index 542f5ff8e889..8372769dbe9a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch @@ -46,8 +46,8 @@ this.playSound(SoundEvents.PUFFER_FISH_STING, 1.0F, 1.0F); } } -@@ -154,7 +_,7 @@ - .send(new ClientboundGameEventPacket(ClientboundGameEventPacket.PUFFER_FISH_STING, ClientboundGameEventPacket.DEMO_PARAM_INTRO)); +@@ -153,7 +_,7 @@ + serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.PUFFER_FISH_STING, 0.0F)); } - entity.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * puffState, 0), this); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch index b98d049e03a7..c3d2fb4778d2 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch @@ -8,4 +8,4 @@ + List list = MobEffectUtil.addEffectToPlayersAround(level, this, this.position(), 50.0, mobEffectInstance, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK, (player) -> new io.papermc.paper.event.entity.ElderGuardianAppearanceEvent((org.bukkit.entity.ElderGuardian) this.getBukkitEntity(), player.getBukkitEntity()).callEvent()); // CraftBukkit // Paper - Add ElderGuardianAppearanceEvent list.forEach( serverPlayer -> serverPlayer.connection - .send( + .send(new ClientboundGameEventPacket(ClientboundGameEventPacket.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F)) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch index a707ad40d3d2..8c4c1b262292 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -130,7 +130,7 @@ } if (entity.hurtOrSimulate(damageSource, ceil)) { -@@ -487,7 +_,7 @@ +@@ -486,7 +_,7 @@ this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); if (this.getPierceLevel() <= 0) { @@ -139,7 +139,7 @@ } } else { entity.setRemainingFireTicks(remainingFireTicks); -@@ -498,7 +_,7 @@ +@@ -497,7 +_,7 @@ this.spawnAtLocation(serverLevel2, this.getPickupItem(), 0.1F); } @@ -148,7 +148,7 @@ } } } -@@ -511,7 +_,7 @@ +@@ -510,7 +_,7 @@ double max = Math.max(0.0, 1.0 - entity.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); Vec3 vec3 = this.getDeltaMovement().multiply(1.0, 0.0, 1.0).normalize().scale(d * 0.6 * max); if (vec3.lengthSqr() > 0.0) { @@ -157,7 +157,7 @@ } } } -@@ -624,7 +_,14 @@ +@@ -623,7 +_,14 @@ @Override public void setOwner(@Nullable Entity entity) { @@ -172,7 +172,7 @@ this.pickup = switch (entity) { case Player player when this.pickup == AbstractArrow.Pickup.DISALLOWED -> AbstractArrow.Pickup.ALLOWED; -@@ -636,9 +_,22 @@ +@@ -635,9 +_,22 @@ @Override public void playerTouch(Player entity) { if (!this.level().isClientSide() && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/AxeItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/AxeItem.java.patch index 14a2832b5458..cb0c66dc7f0f 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/AxeItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/AxeItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/AxeItem.java +++ b/net/minecraft/world/item/AxeItem.java -@@ -69,6 +_,11 @@ +@@ -70,6 +_,11 @@ return InteractionResult.PASS; } else { ItemStack itemInHand = context.getItemInHand(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch b/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch index 116f0da8b9f0..919f1b35d85d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch @@ -28,29 +28,29 @@ serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, b)); } }) -@@ -119,8 +_,8 @@ - GameRules.Category.PLAYER, - GameRules.BooleanValue.create( - false, -- (server, value) -> { -- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { -+ (level, value) -> { // Paper - rename param to match changes -+ for (ServerPlayer serverPlayer : level.players()) { // Paper - per world gamerules - serverPlayer.connection - .send( - new ClientboundGameEventPacket( -@@ -154,8 +_,8 @@ - GameRules.Category.PLAYER, - GameRules.BooleanValue.create( - false, -- (server, value) -> { -- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { -+ (level, value) -> { // Paper - rename param to match changes -+ for (ServerPlayer serverPlayer : level.players()) { // Paper - per world gamerules - serverPlayer.connection - .send( - new ClientboundGameEventPacket( -@@ -232,13 +_,13 @@ +@@ -115,8 +_,8 @@ + "doWeatherCycle", GameRules.Category.UPDATES, GameRules.BooleanValue.create(!SharedConstants.DEBUG_WORLD_RECREATE) + ); + public static final GameRules.Key RULE_LIMITED_CRAFTING = register( +- "doLimitedCrafting", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (server, value) -> { +- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { ++ "doLimitedCrafting", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (level, value) -> { // Paper - rename param to match changes ++ for (ServerPlayer serverPlayer : level.players()) { // Paper - per world gamerules + serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LIMITED_CRAFTING, value.get() ? 1.0F : 0.0F)); + } + }) +@@ -140,8 +_,8 @@ + "doInsomnia", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true) + ); + public static final GameRules.Key RULE_DO_IMMEDIATE_RESPAWN = register( +- "doImmediateRespawn", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (server, value) -> { +- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { ++ "doImmediateRespawn", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (level, value) -> { // Paper - rename param to match changes ++ for (ServerPlayer serverPlayer : level.players()) { // Paper - per world gamerules + serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.IMMEDIATE_RESPAWN, value.get() ? 1.0F : 0.0F)); + } + }) +@@ -212,13 +_,13 @@ public static final GameRules.Key RULE_MINECART_MAX_SPEED = register( "minecartMaxSpeed", GameRules.Category.MISC, @@ -66,7 +66,7 @@ ServerWaypointManager waypointManager = level.getWaypointManager(); if (value.get()) { level.players().forEach(waypointManager::updatePlayer); -@@ -252,7 +_,11 @@ +@@ -232,7 +_,11 @@ "allowEnteringNetherUsingPortals", GameRules.Category.MISC, GameRules.BooleanValue.create(true) ); public static final GameRules.Key RULE_SPAWN_MONSTERS = register( @@ -79,7 +79,7 @@ ); public static final GameRules.Key RULE_COMMAND_BLOCKS_ENABLED = register( "commandBlocksEnabled", GameRules.Category.MISC, GameRules.BooleanValue.create(true) -@@ -262,6 +_,7 @@ +@@ -242,6 +_,7 @@ ); private final Map, GameRules.Value> rules; private final FeatureFlagSet enabledFeatures; @@ -87,7 +87,7 @@ public static > GameRules.Type getType(GameRules.Key key) { return (GameRules.Type)GAME_RULE_TYPES.get(key); -@@ -309,10 +_,21 @@ +@@ -289,10 +_,21 @@ private GameRules(Map, GameRules.Value> rules, FeatureFlagSet enabledFeatures) { this.rules = rules; this.enabledFeatures = enabledFeatures; @@ -110,7 +110,7 @@ if (value == null) { throw new IllegalArgumentException("Tried to access invalid game rule"); } else { -@@ -353,13 +_,13 @@ +@@ -333,13 +_,13 @@ } } @@ -128,7 +128,7 @@ } public boolean getBoolean(GameRules.Key key) { -@@ -374,7 +_,7 @@ +@@ -354,7 +_,7 @@ private boolean value; private static GameRules.Type create( @@ -137,7 +137,7 @@ ) { return new GameRules.Type<>( BoolArgumentType::bool, -@@ -386,7 +_,7 @@ +@@ -366,7 +_,7 @@ ); } @@ -146,7 +146,7 @@ return new GameRules.Type<>( BoolArgumentType::bool, type -> new GameRules.BooleanValue(type, defaultValue), -@@ -407,17 +_,21 @@ +@@ -387,17 +_,21 @@ } @Override @@ -172,7 +172,7 @@ } @Override -@@ -446,9 +_,9 @@ +@@ -426,9 +_,9 @@ } @Override @@ -184,7 +184,7 @@ } } -@@ -486,7 +_,7 @@ +@@ -466,7 +_,7 @@ public static class IntegerValue extends GameRules.Value { private int value; @@ -193,7 +193,7 @@ return new GameRules.Type<>( IntegerArgumentType::integer, type -> new GameRules.IntegerValue(type, defaultValue), -@@ -498,7 +_,7 @@ +@@ -478,7 +_,7 @@ } static GameRules.Type create( @@ -202,7 +202,7 @@ ) { return new GameRules.Type<>( () -> IntegerArgumentType.integer(min, max), -@@ -520,17 +_,21 @@ +@@ -500,17 +_,21 @@ } @Override @@ -228,7 +228,7 @@ } @Override -@@ -581,13 +_,17 @@ +@@ -561,13 +_,17 @@ } @Override @@ -248,7 +248,7 @@ final String id; private final GameRules.Category category; -@@ -627,7 +_,7 @@ +@@ -607,7 +_,7 @@ public static class Type> { final Supplier> argument; private final Function, T> constructor; @@ -257,7 +257,7 @@ private final GameRules.VisitorCaller visitorCaller; final Class valueClass; final FeatureFlagSet requiredFeatures; -@@ -635,7 +_,7 @@ +@@ -615,7 +_,7 @@ Type( Supplier> argument, Function, T> constructor, @@ -266,7 +266,7 @@ GameRules.VisitorCaller visitorCaller, Class valueClass, FeatureFlagSet requiredFeatures -@@ -663,6 +_,12 @@ +@@ -643,6 +_,12 @@ public FeatureFlagSet requiredFeatures() { return this.requiredFeatures; } @@ -279,7 +279,7 @@ } public abstract static class Value> { -@@ -672,16 +_,16 @@ +@@ -652,16 +_,16 @@ this.type = type; } @@ -303,7 +303,7 @@ } } -@@ -700,7 +_,7 @@ +@@ -680,7 +_,7 @@ protected abstract T copy(); From 1eb13b0290e7617407e6bde0e59570ebde61d2ed Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 30 Oct 2025 09:40:10 -0700 Subject: [PATCH 035/112] Update Gradle wrapper --- gradle/wrapper/gradle-wrapper.jar | Bin 45457 -> 45633 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- paper-server/build.gradle.kts | 11 ++++------- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8bdaf60c75ab801e22807dde59e12a8735a34077..f8e1ee3125fe0768e9a76ee977ac089eb657005e 100644 GIT binary patch delta 36466 zcmXVXQ)4CEwrnG|ZQHhO+qRvo*j}-1c5K_WZL@>Z-@f-{{(%~(8dWpl;8)+_uR3dZ zfZQ)egq&Z$i11kM_Up+}Q({I9MU9QZb2tR|yWGN*EITsYQsXf^5qA245#ac}VN7sh zh0J3lJ2M}?KHXivdw;lL^3<*X4-B$3ia;m37Kqtw&i zS44bg*-wcSL! z3SdD4tBX;ArwHhPVinq?S0M$-NDOHL41GA}u(Mv5lJs<>n1t_H{9Dx+iP^!|OZQjg z?r?7~D`^kTzf9h>O*8A}exIMuzXc$pU~b^ya#D9FHgvX-Q%Yzk&SMjmRXXNaWUeur zlkHbC@;ZrS`g8^HFE*ztUGuNoszWPjE*%z7Ig86rushQM?7yOw$~9=Fm8+HQUTzv? zfJk=PC+3tWDRvq{9HGU^Zu%T_j*8tp%>TiVuoXOEUm?=ke1bF@YIBp42=^no_&WYdKw$ss1@Y-se*rkpi&K6u}~U$255Np z?7GN0p@Jp>xLr#KDJ@^^k}45a;HG1THPWPxvaJ=yARI7bHIW%7`oU5K?Zzz`nW5_D zr@AaO1KtwBXLQ3AdtS+tV8RsHYw?WXA}~magC2%dki?8d@kw)G7AS~1Mi{5@cB`Re zhFOH2-A^`}!>EIWtoSO%}~`k7X@ z@Qd#Q?2$C1GC6$WnOnF6&3iLUKO?&*=wT=QJA;RTu^aiHh9T1=UUCc}c#wz@jeYns zvk<0}xrpSWOn(w+ngAey!wL-gr}+QXrU%HlghdPxfNTZ$C0<*Mf_SUTBlzydqQ-|} zB@;h5SoD)PGJxL9yM-6-`Z=S^IvL}Q@C%IJA~4ZnAO2Pxvy>hrm@LM9Z2EHYVRCYM z`s?fA0Nvm85Q7gFw~GeAV71AGFwdq2TWN;^Lw$=~GeXQBUxL3Hcq!!(7#5i2&BId7 zYls^x%g+K(yV!&l?X%!0nZYjEh^X(>p-NVRs2nf-@LG5nMYwi+AhZo}(V+}>Di&T& zQ6M}b^7cHNQ(9{jop|K{8_u%_l{JkpuOY{n6yOvUcicc0op6r22)J>!RHvMWt`W*V zUO7)t$c%B@%MUdS?H7=G8Z8DQ@60bBMWS zjK>B9@LWwT`0;-9+`>2qK`lE(5t43;N7ho7oqWH$L4in9EWoHQ03@#V=2&?;3QW|*ThDm+^W_8PLz=_P?p z7PHSz5MvfwXE@_RYBaN8kHQF*AamlbM=mnH---W3jWF;?Q)W zT?E3Ih|JH}0OS_q`et(vywK<3Y-o&4lySM=>7Bx(T$#uizd|^`c)8!He?5*a1iA-5 za!4*i@&~W#|5sz8{LcJZzkd8^1_2^s;Q&tvNr6#lWB^>XPN7WTZK@5 z8ojIux!<+(H17=O3EubL9sSy$G6!G-3*_?GXnu;+Iy)$Cs@cjafZTlN@%m>du}^ zD4bg?P7|@FjvehnIoA#=$k(Tds}4Fw9Xa||Y5=VZBqW$rV_S9XfbAjM>*n~x8DGNu zp!|Va?Cn!gFjvxP*@V@HP}^5%n3ds!GkhkY*7i8{EDhz^h#EQ{FwuZ$J4_@mOfQ^F zB9~7JyU?e* zHb(HP_@|SQp?06V-{H?Zo3c<$qi%}emH?RjGN>W1aQnQ^YUCw$a$;C6{`9yFy7s0L zQk(B_`F4w9hMC!KLrfAG=IBPJM4R#z8K?N@cB1t5-C{CsM(5sFU467ukNNOAjwRn` zh&T9H`w%qgKAcDwHj7V2Io1eisR&TJ%U%5yxf}bCnQ{n*_(k!ywLHM-^;gfUTzL_f58`f7`3{e;7jHS zS-!BrUgGH%7EF#6z0gy0ZVW53^gTlCC)hWd=68=Cb6@Sy`8(GJlt#7Y{$TFwdg6(> z$6QM`b`8n27K;!=+cQQ7qex-G{?sY8j((iIh-z%iPgQ|Q?1M;9Lb1&$V{UAh!$G66 z5&rxAU&9UP-?1tIVX$lg7y39$n0{a>Ff>4sQP@NawoGiA4g(0)Uo5B$Rwe-~2&cm; zxNh(ahHmD}%+P|?M)vC!U2D|K%X$UnthR+miKDgEx$pTq8-TpeRsP;(D&Of#IvWFJ zp`OXChn$!D&K2jc`?0?Okl8>{&|2MYpOUAw-Eh2IgmRHOS`2&uY-o@pbvm2O7HgFX zi6tq>Su;b(H3VMlg&YYV-9EA$*%`=&nCk-Ko`Dxl;^G40z{1@8{N|=lR;Qb_o*#>G z1_{T3*C9m<5vy5Ia9zwIMmezG%_8b?dDu9nIw3d>hEE+%Gyu>$zUp`vZU_Ymul204 zkXB7DGl#++Q(_08PG3}xpkU2jwiRCm_f}d~soZHQzuRu}9@nNkJ>swCbr4tb=tkr~)d!U2G(jN>q^N6a<5W0DM zNl>jM`Mhz2Nix9+)n&<)*y6mrzC;J&oINA9*NahEal~uUSq;2&LB>lpV9!q3J}4H}MDBui-h@YN0*Dm+l?*gvBH5EC58CVimf z@T8=3Vm$AhDx_gS-GbucQvR7B)3FfX1MyqA9a#dfv0RjZ5Yby^3huOp&REVJZ@bx> zAUvHg?3869Gn%-Vesdst|0$B-Uv)HpOMwSW;Ax@?eXF<||1%OtCxVJ|(fvC|pdU$& zz_jhBdM?6G-lj|BglERPKgg~dSIDV4!x8~j9OT6}dVJ}nGyBn#3;u!N%Tv;|dmMu) zv_e*Z3D}W_tWkGfbUS<1vx7Q(;a8meSjZQ~EltZ3i`*xG2?c{`>p?)U!+!Ig;s%cs zXO2RhwQE`jQ)oIubL7n5I}$hNOEd_oGP;zO()@`UEJMuGGZuSk(1Ze80JyPAf`9z8 z7-w3fN)(ivcANE4ZN`z8MSZd7` zXQkbz+t(QLa&8&ulu+&;BnelNVH4VPLghCuaZ5-s5)}%_-IF2R?wvUkj|^T)?#Noy->*3IRu&vevo)O` zxYU4M`Q!Mplrev2^k&V!oj@_J$-n(MjIve23po1(>v=jb{D`e@5uML4;n+!bpX2tJ zsr(@+^>_kg&y+pQ;yKYhx;UmzjyUv*l&>=Ze?olQ-K4sxqzB?4Hj4|Q(vtv^?N69$ zUKMsLr1+3K`SBsQbLBy9X2?TE#vqKad)V8oOI$F&!-VS}PNdQ6oDo^;b3iX4r}nl( zIWM7S3;`x^;8woQ9FKInmR!-qoNuWVy8Yj6voy~$ME7_ZJ0j8pJX+=osF71jV?11; zCwH?kqAo+DO|>I0;5;}{DWL$c3Vh4fh!OPJzokUxpKr`o^nJ8`?D>Z~5Z8Twb<_vM zL86goRFdY!@g1{=BXDX6=TW}kQTNx!rn(+5vI3gJ^EE7f)?*Vw+OC0w{L1;tew5Zy z@T?0t?Ap9~De!?acVgr6AhWfhZp?qL=~MUe)hwhEROc=7(E21fZc+n`y@;qOOA=FN z{vcH=vvk0`Iv^Y-*YfRdkr6AE2dj82|EbTNj(%rSHPzx@YK9osl>CXA+|<4P$1@t1 zeXu`a^;&C(C-HZiM5vL>XaL2Kxnq6myf17+8q~}|8@$62S$DsE6}!m#3Q>c{8(Oz= zpdtLg3zylQ@7FWWRYxRX7-#exzdJ;BrLI=u+U&k7HYjK=}gBZa1LT_&?FEsD8b%+OIO{}KDC*c zQOqyArw=~kROVy%KV2m+Z9YpQXaV%T=Jm}v$;xrQp3&a{{3shRc&+RCF1VAkc63%B zZEh||$E_|%&)I0e#aqu|(W#{!y@3|L6__2NgNJFLp4`g20b7>}18@hFS@2Fcc+S)r z$9Q$ARc;Yi?O@z<`;HKb&mIlaazR zcH2jiHxpxAdvvQd`E0w1EV*2sx1Y4@G-nn)X8jGgMbBLm6iCeMqIeSTZbH3RpujLM z!x`gcfFz!Ze>Or51$aG3TnqLJLsbs;*h_Q!^g5{XM+i7(8tMSFHq{bBGC~3=QGuf- z3;~v*ofA9FAcCI`%wx`K_T78lo#zggsxAFx&6PvAV4?sFl$fJ?5;^1>{qR7|z*e53 z95AY5h0%SQX+{~(d-}I*#CzgjIaL}>2Ms7XMQ^txg5I$Z082i*^KZmY2OZSZ`uHJI z9Ysex^a3Jl7*2UR52x1+>%t1JP6o#emKb04QH3E_8c{}j1?K(Bu*s1>Q}Oc$!?g?5 zhH0^z*uE{KAE}*35R(cIsO=rmZYzDY2O$Zsur?9(|R^k;-51>qsU8@GwA!@I<)FwtTEAaH_&4uF=D;zY^* zQ_&IB)-u&ed0bS2)Iy>TfgtfcOr~YvPhAITgLd%06I^Z|zEvwp#_JEhq&pkv@nT7L z;9B;L&k1)b=fmHbIQ<`F^}V-mhbFwAic`+M`W&FHVoUCeMHT2*zZdp%G+kIaG!TNN z4I!_gn691F7u-X-Z&Ga3vjJ;+Db$JQ0r_hm0?ZRwK;Xf_!NOqj8TEH|qAB9;wUcdh zb3dbuID{n^SbmsLJ4)2;}VMx+)t4j!u4)3k=w9oE6(%Nk+ISL47B5St22MYts**7K3IbfVNfT_zt)+{Bz zZ-aHKZ;tAcd(Y=N>nv@XXCPC<*6Zr_&K)s$4n>Gp3nQ@J6hAzV76x<<0t@k878k~r zjei=NO2sQVl+k5K?fI2ZUUQRC2|EWs*Kqd&BW2SUV@(_(wn^NxfdbkkQr{;2uq)<( zzh(HCpR1+r@<;SU3h<%IdY6H!&kt|4EKvQ93d7JCPAq>P%_7z8z>^A98BFI{k~}Uk z7N;(=k{Kf~1Vq3yj?XWI66{kB{Xvgn=W52w7r5IntP-&ex zQMqrKl`3F9c@>X{P{SIiNp0)ZuF4`As|3QGA-m&=hU_$$wPNFL5LToHKco=9{l5{YH3W0}7Fot_Y6`aEj&W$nDbqSLm30heN<=az}u~ z0s@7td{-3*3F?HJ_l3F9v7cZ&p!+t3{%&&xi{@e0)nGt1l}g@t z-s;CZmU{l-_LE9NT=VbFdVH73-LkcF{~hA^KcC0i8NQD$Ti7A#(lhZbJ3-z$RaErF=hM9 z-~2_+o};ZfaRhMI)?3TppNYLJ?dVq~4RaOqpeQyZq1xH>Jw4FWg7W_Y)F89Ko z3V_>`R)FN<*41Ct7L{r(OTSDBiQreU@NM>$ZDUwjUyVXdHJZ0-C+U0{p8==;j@rN! zvW(Z?AByK&A;a(tK$+>RwwFzA^XnIU{qCO@1;e*{hlipU)ysRs2@W0WC1#I}6=oi> z_G>(iJnHV9H3WK4+W&T(X)bvC9Qv>#gTpV|2EfRbfC}r*BJTBtTGgBl8&*sh3bi)+ zTUUTBGU8*KUv6waE3G<&WgA)jh!B`c)T`Q+V0E$kQ2jF<>~Q?r3)nn@JgqjvX%5Rp z$)T?HBJ4(my?5-u)-@a@?+FuvlkH5L*ET${E+{k1L)b^!itTmAQ`dApgAgcXC`l@r zFu?ER<%q&GituO%2?S5G29?iDgI;!6mg(qsB5g9fijElDZ%}oWB1Y~g=`{5O%zPeU zu17IU80g~rMmVJQoZ+P&tsakARwfdNHkcrFwN-PCta+`srbtp6a|c{@jL7e8eoPHF zbqUaxFCbpet{WJ2t1y|vPH7v#MQMnf0>Jo=7PV3%isZUNqt_^S855(ca+0Az7P&8e z3*PcH$MKu=MkJRT-S^3(7 zEr$89!koefY#*h9AC84V7{WqTE@1*ato02~TEBk2rgIE^CO^A?VX%u(3SSXtfjXK0 zOy2Q~>PnMD4NxEuPI=fMM<6<1m>fNj*z=DJfkPZ~lwc73+g)bA|91wAq7ej4$sI5t zjEp2TD^MieAg5Zu(^`c$ZwLpVf+I*spc1t2_fAQcl=szBlUD~L@Icu2L0ZD|{D2R^ z2)id$B~s$S|Gu-oynC4VCjVj4j}`Q{qoZLt=HOu$O7+x+TX3bEJ0SM2(7lSq(J+_D zICjz~GD-aiGW)5aLo&?%;Mz67DcxY}Ox$krZ_Oyilv&~2YJt{**Uk>Egk(g~$kq-@ zL1eHHi;!p%Zh>SO`jK`ffKA&jT=>Kd3L{8K9A3shOo%9`oh<cCXmlAJttBvb%DEYlq*hNFxDFEJmN_%PuLU8Ft&3`mSETTBB{igdMa$X6 zE<=uX{m;khOxxco2l~4hqFCljh!p6j7|!&X~B!0N^^)&?HS9iMCTy zm%e6)9w-p39obfe)Nr&wrguNSd0~siw zr`<~2bP2ZOXzo7mpnI95V(i-e*Wu4iEjMpBT~A&lpCrwQ_X_ll*fGjdom0#T1391zQ{(bnp+_& z{?wh4x*Nn|n3cgW2hxlYA3DICpqWox%_1%$6zD?QxWdo{!11+e{Qyq6%^^SC&R9mc zIHe4AOkNrs#+bYqJOApGTIoJcl^Y@zb#mX0-);|XKq3s<@~{9f$P$sK`{89PkFn?E zr!Dx?8S_xF$h2yn+Xy34q>6PjBfi#S3UPFvV*W7$`EZVIbVAHKlGZlD2C4`{_>p$b zGIUzkeZJ`;4^cA241tgo0NJCxdKAK}ZP% zBwzolw?sVS5n5D*YQe*7Q=5@5mpe;*Ywu>u|tqpGWpERNwf48lIB zL0ZOwW|}Dl84wTENc4(ItOi9Qp@2O%Z|E+e#@6BJJ|JGL=i#;G+_^Zh?XjT--JG+o z_fo=N&{J4^bA7K0k#n4NIo?81qAHb2Q*%yKeX7M}twyz}FcNMVsNGyg0)h#E+c|*dsdg?*nx5H4jwCkZ z7k2hDvLeaN95WpbGbdwGRvrLyhOVZ8*KlU!G>b^m6qC0eKulm1;Fh+^X4ODEqfQ++ zv@2k)+J*|7Ej8%r(Q#bELUhEOV6{vfbe=Og=(3~RV?2bmSsZ@y!u*}F3_aE{fFR+r z7ju9J8;A$Y4$d}42@5%6h|i)3f`DVs`5VLJJG;2%?#?dDHgIuL6AnAbpf;O9vNr7b z^zF$_J;!$7_IX>t9&pHsAPoOZ{S%YV>Ugrh;$8vI)UH^`leLXgY<5k?E$oq-ZwjAI z;?qm;b|&;wigdVH=e`N^d{cQJV*Sn#qjVNg5F!Rp!<R+~wS>p60@z zmlis}I)H~d0VCeRePliuUnv5`ThnS8X-O5l@GXh+%>wD06wo|CJJMaud4#KjO^3KL z@=78D>KZy&<`7mfV05|>JC)L=itu9HuONaeIs7S0GNuXBo(Quv=YvbK_i@bV27X`+Z%<)bsWg?-6lAR&h0+b9MiI@lQo5FK^{7pc%|WP9fH;wf`Y`6u7Oy$unp=&D z+@<1kCGBbsJJmb#K@&qOgbDh75ThH0F6{(J?74iBg^ggY-*2#4HcGaDsHd8$PAck^ zgN!S)u1JbQuI#L*++S3nv;CQXHXr`;%A|S$n;5xaoFS{!ME;C6ym8nsk)r*|6P-zs z$RCki*-f!vD6#>m>3ae}#h{ZVNn5E!yeg3W z%g-ChR%t8jXqm$jVRGI*e2>6Y*fdA$B57l$JfvN5e2J=||DML8fR1Etg)uyBBgub& zu|+wtc+9r{(ad8c6Wl^%Dl>;QBl{6>EWo0vBl^f1iz2S>$nu7)<>&twdT&eC2K(7_ z_1IznN)8Oa#~&xAM`#~3k?$3F;1d=*qM5iNA!UG=d;h%%*rTQP>&E*ESOQBkPF8f6mca0dFJyP%yvEAREN0HWN1~W&=+0a&@rcqEwSyh6{@=>K-cG*w zXs4c#^E(y>Hn6_iAri-adBvu%w5#O#g8d|Qp=KbR5oC%^^PMrlA?(9Mp96!>w2}{l z3kUaNFKzFk>VWU~O?|t79{_R}uUeK^F8KkUCN=6u` z_w(gM%gopFG(Eugo7mqH1tW*Y&xicW)Iogg(wP@K3);-7PlCZ1C9VN2ShKJ4*MhRH+Me<`ix4Akmlv&jH|j(D7W{3z1K> zt0>Zfp_%BQs4;o_&td61RnKHADq(pbe`2PFh||9ZZ=r(4Svf1$!zvTtS^N7ml;pk` zVXTOhAc6rd+#!u&km}8XYDUYiyU`6ryby$v`l`9l8=h8SV+uzZJ4r9ev@&;QpRJHd zWEge+(nl`Z?xZjh(*e|{A6B}q?WyXvk?Hr-k}dU)Ge%X95`sZ1$~6j*_6w^~8?Dw; zJaKO#L%TyH1d*PB@(p z{$)}VUHV!76u6Bs6Hrqn?N9}wE`eg#AqHn)ab4bHOBSWZODvdKZK{KEPnrmheVETg2hAyQzeF5O)=$qkeG8yPlT0)52svXin;$dobPo1p zS`Al&rRoVOV2v8$d?5s*Yb6%fSohL;`{Xn+}Gk8I!8r50Vsm&JXAzi z`WMD)^8v&@kCz}5r~yOZsllqp{^bU;99@_cc(O<8Abuda_a*I z1W5c*<3MFkx=$y&}%5Bp@45bE*w^;_cu1MzpoBUS>r z*;5}foXw9f{(d40z*GOCKe$u9J=`9<4VWM0br=ZfxC+%wq^5;VF4jvF9c(9*okz+P zw(N3{*bAaXzQBViYHqwbu1_7^R9*nY>eX&sT{|y>08YS*muXh>AKlWGuqu;A%UH}@ zMTYO`mV>gpvU{T}4*ApxLC#k+Erqz0GeDM^k^j~wB#`khj`t)DE4gHlM#vQMz33kH zsJk&x&vvE~pIN65e+_N%hJ*xp2D~LKl4=GleJ#>M7k?rf9~$eg?Z^KXr&84(suwUd zekcjxLOXYuML7Kcy4R_UFk!)}C{`N6(FUw3`_XI3;CvbPg?CXR_1N-oPcADMf;6_+ zk!yVP-e0|eOjWZt>IYc1_dA0n|1Yss!0_^<@GnhR^}jS>9x^--qLLBds%-7NAcn$= zohiY1T%7WlAQVDCf>^JTsE`F-+n&!exzLD9q0e@&g?4J_wgQP6`VsdI|7aZs9~zMV zIUQ%@MH&hjr^1|~ezNU--PU2g)9L#L?+>bDjA3KDRm1PN>~X75WNSVK$u(VtY$8b? z*%te!F~!7Iuob0#S4sg;H=#;<8o8T)PCl-Aeyb6oS&F`lv|T9*I?~_2xw%PnH2(hg zU5-B%QbAXbTQZjjwonBEvzRddLWt^I)MG32<-Dm`!#yX%047;&IW?daV<<2`Wo#Cn z)PAHtPKnlJ+_*=W@SAL9i#zdzhsW-4KbS?qZ1vl})|vm<@^lBF;Z5+%)*var!bAL! zb;VPtbEGtL!;&^TN-O6L=RN!i*DSB!K*Wmm>`XRv{&BL4s$x~S&+gLHpgZD|C3s%P z>dE_`CrL%9x^oJDhNfawQa8Fz2 z5N0PK_OIuaVMQ@OnD$-Gu;+kZNO7hRPTX?u#1aT9Bvo4Wlo)}TL7}WCrER=FI3oNn z*M#(&HFPU~mfdt2S;<~)&$#LrJb&lR^##Rqre?3Pp+T(KThovMD}M~F`dCQmFhd-E zgrfPBjqoVgn$2GszRB%9nTj%F#$4+N6?+j&?hOSpHH<94)#8LBjS!xGydghgxt=dh zxSpNuZ*$Dfa!FQG@o_n3TW4)Z%CQYm8JXF%1RHY)m^H0X&#ME+*p#$a7(@mas#K^M0VZ4buZ z443qp7a%Ku5IQ)z2O8`?%n*j`6QgE!g}Gn+6fl8nwDTjt8W&@K_s5IQMWvDBL{m5B z{_KxJfZ=#kH-0~+!BA5y>TahsExbE2nS2 z5NG#^TEk7-l+6^^y+P|z}0Tv$#*eBo!=(Af8K=9olaRm-H<||zDH7V*=5(?#uN|Xg6qXrf@ZQGDd zvt2YbS&OTL`$6#cwvmH?$Kt$F7}%gX8o)Pj-*kC0XMDb0Y`Fh0=0SLM@%=QrC(Mv) zBH@mTC1#C-BT6<8Vf(Y#7SrG(7R}8>!pqne&!+~hB&~1C$CV=uI5;Dqn&$wDR$<58 zd9YydnpJ0hROkLn>FuI3@$DzsRL~|Yu$j7uPCL^NlZU~>lix+F&5gi91Z;ciaf;G6 z5(WS_izUwwClv~8C8wo;lj%}2H7Pd9Jb+r6qo)c=j}jD509m!n7^nrbjsAGDOti^S zd1g3uNG8Ri+!>Np!ac>_e~qKevj`vOdgp0?!nxg z-DlTI${yhmuKfUXhu#o0(66Ggkt*WTZ=P@%)-n00B}#y{`Hv?d?X-otP#_6d>%gn?5_p zCciPbXh6C-mD+QgK=}v!XE!wZgXpB8;I5HK^O*Bh!`#vR`i={FRBINnHcRz=EhEU3 z?pAtRhEhcr^;*JMw@QXZ9rXHpXSOx}LNv)i*kGN^Cg?;|?$P(JL3gxg z@koGLPQiudVyi*+#Lok>Ci)yia8>lG5V5kz7fsD6+%x>${Q{ zfZgg_uD$y=sd0+Ly0V|maeS&ED?&|fk^k$%`OEs**nc45{SPEwabrO6I$11XQQzRK zkZ=NyjPel0s1hmH8g4DS=1u$GJp$FEd2Dbwo!uWJISCmEO-dWe39sZIzvUWlXcXq5 z5IW{NZ+IRiJMm{G7tnjY;0*AjVP5RFw5q=hs+^sbJyPl|(rk@~89wc196b+T_1Z49 z18)Ud|3$>nxOr$YaSZ`>p^oeJFs5w_2LLjl`$m{5W67>+Z(>XcSDYSF!emEfieu4Pmr0xGXfC|mPUq$8KO`)dJ z{(18xqR@6|?^!cbZJa8SIb!$d^(DKz5dbj|iY(TT91zJO>=p!g@fYMDQW1@SHJ*tjqyG(1NQ4K$>O-E;uI>WJ4uUPT^cJ1BO_R`MpFB+r3b*&2jg!` z$A3J&f@3=GxeYrinT=Gj3?2LXWYGmhVeyty3MOn@vmp}mJXVB9>aU6645y0BEXvME zKeMQ*KnB!uv*`;xp{sC z8kJSE+Ta&zXk>4aE)d%w-v z7GYQjGhQc!!dq~zHUlERoML$au$3obvQT}vge92!Q zN07SGw7PubZR3lBjQys_?y`S% z$VJWB-bD*~oL41+JwX|-Kxv%vFzzHtH*2-8{PHpIo_w6s6#QX@a(4!!{T{obdfs^P zYgB%#D~wQb2awacVp_MH+!IfERO)s+L|oyFG$K0JABaL)Z|=ZZKcOLO0~E7-*&`z5 z4S3v%e@QFX@Cb;8BF)D0l@_@JMWk}hSj9eExRUise*d3QszvFXAPwA=vIB@h zQ9moHR(!d zN#=_>m`{98vTm~8%mANX@36fDWSHAFHj^cKXHlCvh;nN9%TuIX`s`ambAQ_G+vGZT z%|O?R>p)*XI3G5nGCd7zJc{ttm%TMyT*mt39n4GJv^G(@H9Dw%GK=JDAd?19_~Y z4l@pi3gX8)t}~1~cs96+w^A>RN%`qNX~A#f)_m4to*u?>jCGk!0c|L$yu{$T*0ZT6D`_Vx|VF!d2w?fjm_&lq_Ql zI50BZ9ai1Uy;Z%sscapmY4{`|$mv4$kXUG#?56FzL{oFn>`PKqFs;+WUm+Ztp{@1& zOJA2AcPb>I-2|fiWAutJCQZALm|}s1mmS;&u&KYvz-ky8RmOz+Q~`;gPeR63Roq>z zG%`IE*ENy@tUC53e?5ZC)F!0*5C#%(vAm@qgBAsqI;LhH@G&V{g@I37E;$p7ly6+Z zU5LIZ%M788r~?uUB=8tB4Ue%kH{}>ZzOc3y@Nn0JA*E+R$_vhXzRYDip4}GE_w4c5 z28{*W0+n1^l@=u@#(;I#+3whFE1HG~V&7cEH~-xgG?VS2PElT=$CP>|F24OmZkiz` z(=1vb9zWq9P~wFbALKcv{VPeYB*t6NaxR|{2eWhVP@|?iZPvVqTniig^woZgP^rx; z^39-^dRZQ?o++QeoUO9IK_?KDEE&6T{1!iz%Q}7_u3u9>qQm{SUj`wj^1*)p_#p`T zKQGu>P5}C+R&IWPOJX{uZ6B~(j)tx=5}K-vf{N<;Z(t;7#K|^0P%g3ldBN}PxZC-f z_aw)A8Zgb<64&MO9rQzu8Hgb-25_y?>vB38XKh@zqnv<8`=e>ZA?)>NL)4beC^Kz4 zFp1!vwgGn~`jN6)p&`vO6?Rdp*oW~8veKaRRg8E7Q?B7shR68gj3zE_)r)WD>eb77 za8k=lD#W43hpT@Owmp!SRiM*$CZK%t=I|*zPGVysTv!L#Qf3ePo<0mLM(jI-*d~7X5gy zk5NH#Z#ZfdB;nmY!mC~R!`qlJ#qAK1=4omv<{lR40Z4AqdO>io4A=n4Pa2V7o+LgN z)1EmzB@l%1^66LZc4W(n4O_VDiSX=ZA3W|TgHU@XVKi%hKMkEjnSo}f9%ah%Qt37$qc{g4bM4GONOpDYWv~5Jg>i2=zUC9JavY-HHm4qTZ<7bEYBS}?G=lGMU1KLoyOJL@1DTTfIdZiNxWufy z=ol$8y}qPNOLpmGZT@J9TukfSCRHvHGe6nm?*V5YdRvaCNK%y^+`4?s1Fba%CJRJU zJD9yO`x#}ZLS%wGTBOGfQKphP{Z7c+v?`l2Z`-SWmmxQZ(DtbOCm!V_Ha865)dbrY z#q)nLKA2jmt_d<8Ahyu)2eW@R?g_)J*lKqamlm1>mv3fE){ncp^<=%Y zG6C0CQw7`_3$jxTxH$#$Ma3nZ)VH~Ggkr>mwm_G%l#&b!?BAgEWF=4IHIm_+V7M~W zGPY^q<*yLJul&n0p!md#$~R00BB+|5j+>~xdOih6J_`hSyLM7!juaDYHHqd*ca-}}(Br64mu;i%tv|Dr@x1_B<*T)A0`_Gbzz<4Z9W@6^41RVm!Dw^L$ec?1=* zvT@kn+j|a`MgkD5z-YNkJD3%eK@U_Fn3qPrki|uA_4D}JvwNjMiTCEc(e}YhrFj3HLyq?J(pqM+ z3&jM`z-XmO+^jdovCf3c>w5daCS#!dr@;~jT^ugYdhF*TisPAIIKa6cG$QeFN(8b+ zha=#tXjWm+G`p%Y{Ax?|vNJC{KusU9b4hT{+*5KD{W;8fq~2Tq1frvVA(>qdaX`VyB!Y5PZjbS~JH_=Z#-R=ojNI1=}5ppvv`Wk1XBeK<0&>9iY z5;7**_D_6j1g=6O~;>eb|QAzP@Mx)Fer3!9)1 zPX?^+o)tmNh4-yL{)t1e?@-DAXetO85_kDS_Sgi%IN&F?AcZK8pe`w9J^d8ctvmRF z_U1nSh-^Y=+he7@ivFG-?^~jjk}LwCi${_k|K&}NZy(Dd%6kyy;nssbpX*JS9aZVb zyG1MyEVWBGsBRUGb>Fw+ye97nzf-K(aklVDtf;}r9cFg&L7N$yixS0O{67GzKvcgM zu;E1k=r+RpA^}?k_efMv;&RkTh~G#o0RqB)4g6Cq`SF05c=`z9lQLrkAtSq(l3V=O zP=7D&WRuwQ@G%mmDE|VhOE9_>0SVF@1jslVuDiO zp$5}h6Q7#P?sU6!zjAlCh8X!F{tIJ*MiYO4Kgu{=G)D2kmwRW<%$Yee_kR2S`73}1 zRs`N1A9tE>^aE*)D6sVn-5TiYx)u77>&e6o1H%t(VqB3&GA0fVWo%eOvPN<0$NI)V zdNHl*kz@EWGJo8xMx#-$*B^4OYX0I6QqN-`9!ldryA(KXK&0HjVRTF?=3b09YY%Eo z!=|zRR)Y{IcEeOzwBvdtuo^1IbdoJf;Qa59L^z zo(vpw|KO0UB#&8vrR~}Hl*#yOOVn8SI2Ldw!=L)NC@!XK)-M{z=a9v1~l z4kgc3$nzve0xQ+CO4iOoWn9ALA{Ma7jVH?pYysoHxIZ;>i7U7|5xUHinzhr_YPil` z5}u|CEL2qg+59GMO_;aK&`>B~26qIepYmh#?q`ta4<@)e$1+Pp5hcFwvA2pTwt(d? zn0xgR^OedcES=z5(NwV;+CHkS-D`c_ zm)B>l-R!2M|8wq4l1U~=e~(}E-h0mXedpVkGhe^($YVsbO1Ylt?i+91x%PDx?MCE? zndqnpRzx~0sw*N^yeEGeGtyBj5r|tICf1W?%rsIaHoJ{fAku9{j-)d2R7J4Uh^5Tx zik_}O+~^5JC5=_9R<2yR4zS6!dHl{yEQW;td)xlip@!k`Z%LG-fg_vXWi3T}h)OX4W1{8a;nKX0mp({M>7QwHVQa zN=~M!*BeKT+L)2(s@>jxy%|ZXF}fLc zX%98gCY^ukXtQmT9Y)ejq&?Iu2-MM5n`o;MH$4=x*IGdIK+W|=a*;;c;XO4yNehvc zj+!ZrUIV_8W>3rz5t&RurE80vTZEHh9?(X+gxPj8Ex9xzQk=bl$!qOsvBePz^3Xn7 zCwBHT`A21mNGytYh{ugYM+o@_2q_c#JqVAewCR5x(&;)n3}YFwn00J-;z+_eme}4S zq6IF;aIbcXlmMm!UtJn?!ss^fKnAn|-BujV+YPN*J$8t#DVknF6LV#s28~=#M+7&q zi^^a_tAvw0MzSjthYEJ}_P`mZg~sGBknEuwO30!ln7=_I7|eA;CTgZNI*OG>jgG^_ zsosB7+KdN;p*4Cf(_~2|la9t}L(vpc=j$OAbm(qU;I!0+!rME+QBNVn6scwj?(mPNRY^$c~ zdu>+XD4{~g7NZBpy_4Q0oaEi(2w_{L|AGKgA#kZ#m7}?BuwpU05`f4Z^j@7#(w$7c z%HlA#&)%ie?Q}{Mvd}oLb0F{6={CBDY4xiG!=ie#(@NUm+?Hw2?W^=brp=WXaaw;H zd;M65amvl{^I@GnL?6j#RB5~Bw3#&8MRNNnlNJ?UX)7tD8m*w_+&a|rar#6leT@2; zs$W$q`_Yy*(xCsT{J8}bRr)mYAG(=V^LSb&1O)qM=z&tYpB_Y6O33BH@|E*94}Fdv z5^$e~zs8N;b`vKh)7x_%UNjkl_!)o7>U1CVGbw?9Mh`OuUR98~POzKHM=A}90Jv10 zKdRFg=rPC`2<*RZ!@(+z9>+)ANTV{RJoF{OO%;6^r6HARPvzXZyt27yw*D%e6VOi} z^IC}lY4=@X33ydeZGxjLhhx7+Ul%I-Z>E+1IlfBYKsL*2pKPGL60sl|~aC=JD;Q3{EJo*+bu@?+IOfU-)wKMC$yZ0QnI* zTq{wROXE!S#XRRf<@U$)oZ$9hhSmF6DnWI{j9Z&eDjLNTZ8QZ8Lj4^gGdwouvO`nmJaK`b;#| zA?ok%QG5^pf6(a#(VDnL^PWI~4HOlB0y2>FPxNO&;xEV_Y0KX9&`Y9`d4c{0W1&Yt zTFk50L;s)$gl7IJwGK7*#LP5$hnH>hz5-5S7);XLG8@257_6{yD;psdh-*p!Ps60z&pUBnIi^-<) z9Js&+jpt2}EkzXZ0-=9=3>c&_h6+bdW^BWmOUDy71O+*p7cm^;BxB@ogH&A%eU^80 z1r?PXnUgDdsm^m5qsQc)q?v-}4EKX$i@zwi9P%nTo#F^e|=#v9M-b-W@J9D|wxOz&NpBROx?2L(pZ!WWYBakC-`Y zVYHZIv+74#^T#u>bQCV`w_A@IjW_DNK?K}_98`y8ru+#j4e+C;-$?Y@pn$AHS3cpi zy&HL83;N!WWgW@%sEk2mR%6qqy4|5&hc@r5YYa6V+TGT)^U#*` zt`UuMjclBGi#>m!<~*Ypu6ao*07~D=+eB=HKz8hz8n?p6AZsR$dU%Hoh}mUY?)*_B z4Yx5ZtSp@2CKx?zhKOnOUL-3hxhS* zox^+p&0vx9LRMFoIN&-_boSZ&9oG2}8)9HSjtGPcMnr$Qt79bAiXtR(cP358%}7SH zL);0k7infmQGJZfPWG8moxAvYoC(M8jH0?0?#(;m!N*>u2jhmK88r7~|Bzi!yu>V-(#i;3ap`TXepO--;HbBPv?U_Ke*uP9AfO z#Bbxb3$xq?Bh_krJJJCr*L1VpQF-`Xb`ii_#mIk3n4{E`(P{2ZMw#YMaGNts`VM}t zP%y@+NolLDt)aO&*COy;@&bi1LOEI*uhjVc@W8@Lv=%d!GP=yhXqPF9*$3=2C5@60 zmvbv7PE*BcfS(WXhjsoSV+wNZ-nA*PR%0>vfNXtlT6o`#Vl?;Hd-&u0384fOQ+KAP z137;m6e{=Ei(2(5zE9BnbiU4_yYH^8k9IXD(xyxhp8-;bD7lnYy zgb}lE=3-Xl2-H>EG$A_l{{%l-0;l{M)7*&zZqW*rF>NF-8cc`exw6qyobMM=Y7l{rBQ!$ z`AKvVRub*U5AAgf9kWL$?#v|8$djYmh#zA{YOpe~4%r$+k|sRP-y`qZ{2h5}{!T0D z7i#wl1Nb$@xG@D>*R`jtSSD@Smi?)`ROFxO{G8}Jw1kncL{^p!_Er!7l7A&?^RHbb z{!OXB#zFj@$MaJM)V&jx)Qa1dlsA8&jKN~w@U?8D+ejqLSW23u!TwPB_jv)wfrP-Y z%74HBo;;@UA9a3S6m(r^+XiF0ta8+~a54JO{$Kd70`(<0aXQ&6h>CPH5uVrw(%<HLa91@nK%u5OsM zLsb-{l2ptzdqj5F3UI}#xOBy#xbuB|9^5)6FKZMHkP*1HN73maxT{hME#!V3@+gxq z{P2s)WEeOWZP%2k=m?60K)q$9ku8iK@r#Wd&oRZWP!+GPl!>%c5<@Z(vLgVN7KUQN zhzqTxMWxw4=JH)BS7yN9l$n3|;WPJJhK!mJ$`|yf_{2T2Klj^4$fL{^zke)L#3V8% z&hi)wkX?tnxKTUeo^D)l+FRh|GNnRS{K`TPHQR5Cg)I9Ee}0(&TV?}giLT66Dp9^r zP(<|EMjLx4Wv}AEWlEK>Tr~tqiJy|-S;x}_?9Q&7_&lXXsTJtU;mUuoSWT{1jv1Lm zq#OOZ-TDiAY064rAzg!tS*2Vl^srjPKqr5XXfe~>76iJc2!Z|M2#h9~ zG&{weXst~FwAU#?ol2GU1veIjP^z*4Niv!^Y8^oWT32L{ocLO(TD)GbVm^Gvyt*tv!EUoBpkJJN?l_etC51^eVj72V|M%}I`t>^-j?M$_PxET2E z@EMSIRp-jCe`NZzOPA31$RsRhCme*q zYGVVEIF>pvNG9Xagz1k6KkPwelk(@1nSZO1^mit$xIbcbnC%ccZ^Fa*wldc#wDl&^ z#_>_|wu{@Ji|~KmA$W(cI>m3g$OFifks}x&b_p2NTX9v>nu)iYNx6a)?;=%}Qp6W& z_>Yw?qDhDGR!XFmdtF(YlBM!2&B@Yb;ZT;Ac$a3W_LTZ;)c{@jFd=?IedOIcNOj?s zsw_43)0XPcva0;|HvHG>-QnGtr9J%=&e8$Ggv()R`=#tda?34u@d&a0f62&o}o7l(Ax&-ws6onNVkUrr|CUe zdS5@?-A^AFqz{FIu7JoX;iRPcuCZ(m^##1E=`oKGpk( z5R;}2(ieY#D^Sn&4V}mO7qj%0Q{)4h3gtZMQx9e7e3qUGy84Fh$NqQZevR0lx*BTJCZlmTymH=_dl|7?6G@k^BP5IRffa-6LQ-9-?2~O|t;}YYFV`qtZe8 zZMdKQ_iO-YfDCGo+NWjd`BOAq&=T)?-lhg}w1a;o0;)tpy~*bqq!+@zl0)7X`{|Ea z`fHZ{F80nt=q&x~6qV%#wb{7vH6K1M1YNGxTDj&^v#i{E;f&8!t~n12Ny{}UYEYA8 zwF0s>GZ%sY@o7O2=o>l=N&*eNHgN+5k^(9i)@syq~9d zd$S|#J*YZ-rpp4hwhG}nrS zm8Yo92M4SRy1ZRj4+q_nhbx`82%oS&);d2*GlkpX%aP^vUpA^yw^rTV~;Ki-?m0x$u$lwMr7- z9md9XxHZc^xSLi4ggt2z9?!~@;veMa!UDJYP#OP3gdYDqkN1nS+{!`c0RLt>|2AI6 zzdK>9adA-fsZY@E-0BS19rw_dL4H0g1ObmxG=_?t#g zo)}PIPkozDZSCW7q^MTdcj&X*`WVr7j=o=&RXlJXXhE3*3~{`|k5gU97PYEOnI;4h zLM*M8LR3@_DrMo8er0-fR+$xUIY(2gA9H?~^lHb-mOgTEOZ7Qw8&qb84}<_QC#%eF zaXw1(!j6CHwgF{PR=K=iSvsHuaPo>W<%+Db2D_!q<*TruVqsYuyozC)GNnb@=66|TN13uy7`dcChXG0^0N5rV%9MS}`jvxcM{$2#4UP}xIUXa4kzbd{!0bFr)6pV4Qm%ClIM2!FdFPMB(>>ii$9%%`D}N0%jeDR6KWlvC*1Fr@F(4OilG)Psh#o}Rc{tg zQWSq+J4{+N1ojk_HmJ0aSf#6nXmaiwWQXV@q}m_y?>d!kQ|UgH?k9SgR;yICVAbVA z<|C@jDP_#!-qXj2iOr}98UXsb#lqQPRnf%J*??LPrDa{?g9Zv*%*#_13` zJNNK5*_$@jC|&Sexp7jGeT9|_2LDd;hiHF~P=-E4I=RL`6J0j%Wh%w@5cLgnz&EL! zg7zh(5b~d-zf99v=%P4`*)^7AUc;8gj={BAuuWdX}Ci2pqgzfwwu$X$T*qK$v^ zd>%(5mqZb?atMz6>G@?Eb;h0%FMU}!E_B*PN`7~y z^-5{@->}!{^6c z!SQ=w@_TUz8dv%hDBcg#K8SdHnx=oyGc=WTn#Nx8DxaY;7^ykN~&~L(^BUuTIO6sRn9u9c3w*X=RvA*MyS?#f|ff!Mk}0sw9@$?UEyo|5v_8* zL{~chMXOy*Yg~(Htt&w5T+1owYNqwB?R1qZP8(cDX``!`u6Er;*SH>}I`?#{cdwxa z_np+}zMGodKcr3SCfcmNgSMzoQ?vRkZB_paU9oUO=*sbLP)i30w>@zreii@#T`iLl z8XS|uaY=u%l@VYtItJBJVBIKTgL;?Tws$1CCAry#4^+hA3+3T!h!5~FR8+t&tyG4H z+XNLvK?PCqfiFZ6Q4x{)KVOnH?bfdHUDFnLQY&vFda1yq{LO0#l(wDa43A<%y+8P+J(=F|(jAtbh zi&uXbC{vid-P&QbB&<|l%lX^3+cD2Tg~BmW+e%4!zQTX&cQT8Y)A-2_6|5J!)0~v!tyM@jjMsZI ztf<~}EMK>dOD_sy4yr3rj@lpssFJUFK?L((p&({prhFY8#4OB~uVWPa4RWpq#|B`a zPN9shr~i&>SlTf$hO{nNYJ`Es3N!j_?*dB#nUB`&;=!V&L7adS16YCvg?VEvyF7o% zxwEoPB5tP*GzPFt#2aMSX(jE68sy2zER1Gh)n7=d^CclWalyDU(RF3Uvy%ok z(sOp2_qz75+80nukGk4ck{WEn=1O$oBHr;{%SmL@_IdP!)yI^no-AQ5MpS>KUBXH+ z2}1*0nRElPkYGiqoh+3YN-!x(1)_Grbnd>CU)9)__kVP!HDF)nHKB2}=_ zE4Qm}a;HspnGHBprnIVc^;;`fw{~TdL0m2tZAYSb9Sc>&Kx({4wfY7I=>A?;inr~> z`W23yG_8xJNUTjGBSH3Pt-XJXI%I;_k+*gywHhnpZEhmLbfr_|nsyG5I?GoiDoH#-9zGAB%x(1*?7!F|Zd!6BB_v4D|53x|xe zcg5_1{GIzozW?M)@kri|Z*r|Uqc5L{{Y26>3-%6HoBFBSPVs*-1@SH1FI>J&ZxppU zE8E*^r|tMg+tRJ?JB(U!uRS%8EmWrB_Q7J?EErTmV&J=zgiZIPhXQyI-%}{xylF#t zjfo#9G>#FL@R+izJrckn{7_2T;bVD~3j03_-~fKi3qvmP4i1q)JT5LffS*uoEa7Ij z@-vw$4&aI6jn#i*N<9AaaT}ZZ)9%jvDEJFHrOnMI;&mz4tLv4@RmVHkU&l(uoc|Rs z%_Ny#Of>_)W~4G!ue~|VLb|A7LXDdkrQhOr0sIEfOqeB#MPu4o;tz83{-~guP5hbe zpp!CgDncdyB7M*H3hgO~zlwW)iN8@bH`AQrlw;!W92{Z_imz9MUuhA2v^;-Lj6Xi07VGJJNoGmPR41@`^y*!O z(m@fz;P^hb&dE@p zI=(EOcpck`-fK41dIqYE&uuEvZkG~{zlLq6{S_()%aqxdY}K&+AHD+qrVHAc5?4VCS~+-3VPziA&9g!f@# zsC*w54dJ-EAb)dEkK^;_%%zk`?*8i=N3bN?(Kv|tIV>H)vS?$^5Slc)Jcm`)t^Ak6 zDML7I5DRiRa}QQ8%b{%#nt5g}e+!~HY#2sI^t?e_80|cWioO0>%kD-unQY0y$|2s} z7>$2!B{eDLcMf7RTR<%3uhjZ`${(BD0XWW?~dniZ{;Va?sFHTNLU6b_Z;kPVgR zuuXExU#k=jfTp5qW&5c>?*5KGrP)LD{^X1ZADMlkUA=- z<}+<_YSA8K#1Wn1hKLd3QhoKqJ@nb5A%l(>QHx18q?XW~KPACIG=wT@)QJ(Z>|Pkr zNTokybkW_FIkk+ze5!LVX7jf|7%k_=-0-k!%_$oHJTWsYFnkclh02O_ z;pu9lhDkM`p2kz^3iTch-=}}B)9`xr2@P*i!y0~5J*wfO>M`{UpnjsB(D*azS%JRm zd>`@8R4p0?RM>Zm?=u<~DEO_u&ud(u;J5qsXXx)1lNC%IDG0HmfdSn z_di@@V2Odwmoamcb6>zfxn4L||9AEO?FNS%1&p$aPf5TUjtavVWsRSb#=teCdKI$` z>{e>wD0@ZK)ci;!GX2x>GqhUfbR;)vl2fMF{1OBAjN;lUiChvj1~O8M^0r_$jKMZNjiJ3UQwV37GgxS7JF~=7} zwXY8~zN>JQzYDeg%P`j;$2`A-`Thh#{sAq=ug4Dm{{c`-2MAY7nUlqnzkXeR%Sr<= z6o&s;wOU7Oy=~l$g13%?wTpVejUWn&pdh%6)6;1*b0L}5h1du2EnF1Ag%99EiD#-J zA_sEL`SYDWA$k9JeFIR(g1}R+chPuoZ)9*sans#(gO*!$gCt6omYGUoFG`xkx*<){ z5^uJp^@279ceWE*cef?ArK+2MhF&C7PYpck^;)gA!>noi%(psPvtZlO+v1kuP{l+> z#UZO*GM3L`y|KBy+3=dwbsxtd1WK1l#{_hwGzqLECiFuio0|N4Bh!?Oe-hhFYQ6lO z5A%x^F)T2BE4$LyG7kOon_CL9B1YNoYy3Eg*l+4|z^KH}{r6aCNu@h~hR(=Z88R_* z`s;F;<+o*ObYI0PI}lh}{cG?aUb_+~tgc--a4=Ou5oHHs7$3(7Dh^7R$g5d_;X{5U zRJbYf&kS+J6jzm;;Vd{DO!7L<-69GcKzaT8`UTS)eauw*n0p2WXklPc_ykZ(2MBcE zwK8e}008F!002-+0|XS4nSe)s)p`F;^th6&JZ#5FL;|_7V`58|odgmGg_rFFaI8GA z^FSmeTuayXC6cbty^3RAgEi~{+d5jdHt7nCj+w2jYc`NWQwVGwP&V3i?{184quryW zYsc1Yuz~jf&b_i_$A)gpFF&38o%5aVeCPZA-{bhz_rLf&5nV3s5_I~1o_hwj-Pt^> zrH|?POmm_+J<{CKoHla>BdghlnUCkpjE?!Dp4Bx=$Kse~#nWSY`j}P9SDdY0XH*em21$c|ws{2Pu*(@fkF)h9cq@Eu&^15C$@}rnNt`{wwh52or zmvwH7XY}LEcLzua3JsZmrD9sY&dBP5E;5UwU86-UlhwP%i&~+e7rXlNmaS#83V8)B zyG=W;b!D~uXxHB1+w`=pkYA8LYmScUMM0~R^XyN`#qELu8FM_JHMNYOi|1q9;Vy&q zBK<@wLTDPp-T3(Z1F8a;gtg zm=*`gM=Qb6YN+ZVIe89hbWl7* zG3o?s7Bj2@&aH22KRnwSVcJNWSc}bqmd;sI5ZKf>Bf6)5Sk&a13T+KhH+#CyuyzV{TpgPJjQOU;|Mnl|&cX5>{ZKLIvJCquV7)tx5_AoPrCo9c*> zwdEp2CiC)7>Td=s4k+6n)Rn8ln1lU~twAxaL6s9u9c84fQdjxqc;|^USsXt8n=tefwAVPgXL%H^`UxLA4eht*th-d z7g{7t2k8*2aufKn#&CdcW<)^W_IZraYnnFH)C#+Qq1ceE6_F~|Z&K(ZA-aXp)jr!M zc`e8J!se_q4~%c+lQcoQJ{&82yjJ9^PNPPhXBY097PJC2#Tc2W=EOd?UeH3ys@WBuYWY)Fj zTk|ROSM&1ZvW13QLt`2u zWvG%_g0H?mDuW%DskaScvW-r!Lfl3~y1jB2;tZ7zUHa zx!cu|qM1V)u!|*&)1W20#ZJE1j@ru{C}tCCtA$xtj+!(b6FJkQtCS>ku&G)2j zIHYD;br%jAmSL-7wq39iU2cl(xMZe9kd>R>Jo^^%FVfq4{ z386PUi`-Gl-(eI4t(~`~&g8d$SuGZJblq$eoM!DyA$pFpo}%Y%u8)Euv%0LE`BF|V zO1DF~^YjAqzc@=?4U0m*i%`RBXSZ3@cV_h*q#`nZkK3Cs(@V%hdHsa#F3gSX>B{;F zeTCUyMMb(m>zz<@LZLr^#)#-WD3oFPDo65b^fhFh1^aQ1`Ta$WUrm~S(~NLt{5qOf zOB<0Hfn^E0^he5BQ1XxIPeSxZ^rw6>`apl~7`g}C^)H;1^9|(5suOxkBO{y$_Ll6L zO7d5NR@J&`_Ud1U=neKuWX7|#3@+yWCPc5(-=e#erE_{!P*+=We$!PiGrO+gK5x>u z*tOq=SLQoVp??6}#!+^EVeo(As`iic9sc?s3MjE-3-eEMYKhiw9V0G zHW?Q6q9G)fiN-kvcfr=Zrr?Sum|Uz7w0=l0A~w{bZkLLAB=sBi@81W?Dj>BY|C$*c z<`k={k3IKvMc{#d>a)!QgUK3`IEzWBwnkhW605}}v$rJ`fmh=a6fv%edFQ!@)H`SY z%o-#$iRnF4Y)f&flxB<0z&ONSmdZj_v^?mSsSoER`6g{Gko4I@` z6~Y-ecqqPq&5^x!`s5)K8MvzcOlA;xAg*j%Fh_~qd<8tRmW@gi*lIh&}!=(QA3DeJQ_HDovFFS$C(At4v2#xv0og*2E*bOx>zg~(B_0i3Yi@%H~WbH zEhEB7XdXrpB^JNw_51~Y%bFY7>v!lQS}AK+>3ws5w&VO;#8Gzht+W5Q^uHCPh+)*| zY6plHr(Lr8#&A(xzFc#BrcV zj05X`3`+P1*GeDTtrhk&4`7=#^7@`qZdfnM8LCGKQs62Nz5*1)S3Un-O^#t&j8TCP zm(WrYVgl3#@Ov??j;4-GQNuY}o*I~bc*&) z(kH3ODdI&HXNR!BT)7fwZ-K5>tg5V7FO^m=;2g< z@+Ddtd*1sP1!JDgljIdI*B+6%;E2VNhzby~FTg~L#2xs(lNMKCY7bkwou~p!dGOid zQg!4}XiIf%G5J6#)D0Sinj#hWgW0=X2Epu#!`^yng?gB7ap-ID^$xAAz&DF9lY~d^ zgaT1G+>ed>Fgpfe$KkDyLF^-#odn;1n*he!*i!*tkaQYxy~^thov(JhOx`mMV`nM9 z=NuJM32$tQtomj2r9i?L@v_VAOl|c)LJjeV&(q{D(~nKU-Smkj|Ds3P?{CB--ZGsm z(@$al1K2-B4|=xxntbu+AE(ZElkc*6s@!vy9!e#!`C%BmF5+Fbu}q&j1o4=E`t+fb zJ|N=j9W3Y3)SfauehMnZQe}DqXnQiLuvbz?5?)Vq$Qv8-bqx9ALk+(k@j5PgDg_7q z=6R{bd03!{E`rGk2yT&MJASuJJM7~W^1V+h6uM2Jf=UIQmq2qL{P+-#e-+MCC%tvPqfFmB!$0Sd%|f_JuQb|nIj$sCj?L66 z$2Qt3$1CV+Iqsxga!k^HUO5iZ5jh^AqcAv;hOppqj7&L}=s`L1Z?6Q+r{w5BD9bol z!lC(P>DK4irDkv68V7`k-lbI)+{!BjU|!02m;5`b z;0Qrp2HUXqYeLmHbp-~_#nU<{sTW9 z?)N+RL7bK8eU~+U6pc0W3eWV?c^pQ7gde%X!47iFbqc6@;T1mTc<;l~5hUK}h^A!L z9f*}h&^aDipe#ZV*eJq|Sc#M;4!Ngx;M65J^{iN47Ava?t=_}lMv)OgMpL7RB)lTw z6A8cMTboKKjI2a|fT0DDev?rpT2p`-FvR~;9l(`nFN=;w(Rs8iE`M5VD~l`T?=>%q zo>R0d;(I~#l*NwJRrU1BW1P&o&(Yf{)@sdBMk`EleWU1y+7ZQ3Zc6MrKM(maR$8vEb7kv0L6kbu+xuvJWYs|@3MsMy6)g) z0GAp);t~TL!AvgmW6j?bZ7=3Jafc zX(HUa0bIC zXdb@}`Xqf$(mXQ#c`8eqN2Xt-S0v3N(_g_a(>yZ$Lp*_*=8@_5#3D)a2wHfApJ_QV zy+kaRG>=TL7V9L=T*Bt|5E%_Gydi@PMvBhyccZ^(Pf+#n2E zR)Okh#e^c3Ib~p65$iarkpNm`lZF)z^>M1kdIev#3+@JpNXjLdFH&&=|zLTAHq2}0Wb+NLR7P%|3-%;G{PC|3<<3Za|I}N$+ zbR2>5dZ+wAd?Xq9Fu5~K?cIIP#aUJldq8@f0?!j(N=b{o7s2H^PV#~Gv9uF z`3j(fHHPD(qi5weYMmSV!fmJgPzS?c` z6$bqx;q+F6IZ&BlOn?0Rp{;YK|C`f~4>gpz)LWa>= ze?$lU5%-@LO?<$WV_JFbvb1kxi$2GC=bbM(L~3-!%GY0LjA3&lsQk zgo*c%PX?37c4C$~G3mlbOdKQm0hgCga8(8}thOzGV2qeWTo!i^4k+ z`%bB!NJFRTAW>454mUdvcaWd~Otu|HFQvo$!U=MJd3-18%%i{Mk?&o_+zD3xTLoPp za*@mZzX4E72M7foSXo;F003G9lMxymlh8H~lka{AlQ5JZe*-ZP#wYf#wTgWLC8t)p zU93Hd6xD)kEXPvKWM8U0E40B<=Qhaln3y{1DQ8{uH$Ph%!@#E)9J3{xXiMa@O_;98d47v|G&mVVK};+8+yo(@ z^^h-}qHAqPz+vu^FmV_g3LhO71-bAJ%k6}#AfVzPC zxwg8z5OC1F`3dMe+-yDj?|Ksfm2Pj+h9`;gjkB2LNB&R1sk9e zET&%YWO9-WOlHQpKv`;6eeg%L5Bk{GK83cdWgmR=-QVDE@Wr^#a7lo;G;2*}&c1y6 za=yKP|NG^y04A`(@Z{mcrObD+0@v1sS&U7_v{Eb?)2ynk8{E?^GgY;Ug5-`c1a}1~ zE8Ifje=>f*X#Q6C56|!|Q`~D^0Fi7B5cI8zp0Zp-yVwc*KdA)XDabt^4l zrbc#;zNZ`Md2UZJM4I&qREAF7-A$`KK5{>T2)a~+agw30;X7>^21TaYTm{_>AyKux zEka~C9X}c*f*zbvaT>i0y$w|(PX%Ww>{Z>=z3V~Pdl8(&fQo*cXXtOvaL%-SFXuUe zR~5W}A)_5BFmQcS#UL&)bQl&dGMsA|HTeg&7ZH8Jy;(-^z2j~jpePpOwlLXX%;(gR6iV)@`rlj3f%D}Uz1H{myw!2cY zy^b3y6nw}Kb`Ll;7Q(GV?AtY0@Db73^|<4?E4o)9p2Ux1N+#XL$0}wp%kY}(7u>xR z`r>mfbNB>zq;-~hZO~LnU}DBx1PfS{io0|!%NrPuA1}9M2bPeN*Ro8GL;{9P3&;O| z33U%Ek_ewOobpZD1bRv51w#Y_5RD(<|M7Xak1ymrd`V+_K+MIN2b!?uNGbSwUlBxI zt~l1Fgjetl!}*3{$u~W{Dw-S%`{UBo%Uix~6y@%qNf?@O9LtGrR)iUqvq9>peK3d7 z5{=Nc5K8}Yhrw)BR0!yFD{@bngqiw(kNzLZf{I^rj~JF{5h>fE_`UG93Ju>9 z*{5m$(tzbWTJhA?Wobj#k)`#!;8zR62_&>HPY{#kk7$PwJq#`##?VO`;Fm-Vr=CE0 zj=pC*=+Eb~+jxBkgZcTKN15Sqa^)|6gA{mp4NX$JjYkhvQH6868fth zX!#w8d}6hyyp6RQ%o?oGZ8)ze$zCGu_gKXMqQN_gAv~hghcFzRAK|Cq-3E`OH_;ic z(+X-=FruJep_#{DxKT$3m_my%oc>npXqWmhb!JcsxYV|hfOG`m({qwc$e2R3;Ya$W zp&@A-+W!GiO9u#Kvf8dOlMtF+f9p;YK@`W&K%u2BrCUIds>mYt0;N(4mWvl|DhY~d z1p^@=Lp$9rYi3vrX zu`5Dc&oU^cFqY9w>1Bc{yhq30tg@vc4e2Xkc3J?>A3+(QkN5csrmo zi{PbXd!IzpqXsXnY#Ukw-n*gipjzDG2*gtNI9Ttqu%V31ZX1=?H*5fFTSqf#3i7ot z3UJV+q+R-gcd-p@uIPJ#RWwQ9y zO7ab?x!PovZ(n-Xzy~(UPZu-2ZRm%y{4C@V^n4^GOws+##KRIqFlgl#5PgO?*=HX~VUXGPYG|^p4tWVft zj#GiPMQ5o6_qHo(>&kFKGQ927+q6%(GKFd}g zTQ{cO&~ea$)LDR)ZK^x04x&eowO8DOlcxu4m8sGQDi2-ydys2$UI}X#omgic^#&`tsS!|Ywo?&C!|o7@uZ8(ddXr{1eeXUHckc4ZKLrd zk{C2DLwR>Pg$Ot%{?G@+Y|;@*n#;>}qWLeO1 zV6Paiz&+^s)s0La~v zAOt%&sD#Q|bv#|hi&d(t+EG5u%{iOZ8rs8eA1y=UvRm-s64$|WSfLN`q$#hE3@e4%5jP|M$Iv24-qU zuE3|~0i&r{v`x)Jbk5B7|bIGkisJN<7f+KPrrBcxfg--!@xBuewf|aF`*I0>;j(& zVSvJ4sh+I6+1=K-y;`Fo;nh0fNB1_RI*j{p=oM)2aHv_`3~zLIES?Bch|CQjJP_&T zL-E+S^w>0WibmH&+{eqb_{MbSY;t(cV7UG$ta(Uzq)QkOfVqk^%~$I|GWUtLQ+B-` zB~E?D+~bluCV)kdngcO<_O?AdMv0z*dcY8VI_3O1vXp@2H+|N539B@|67dq3z(j$T z#99M#O7(uAjnbOpr?uajMP`dI(_|W7gStoS;Pa&n9SE-5SFR7UvyRR|PvL^%!>g0d zMpOBTUcOaS(hSnn_>nVYG$=6hY~t3J{+2)zO4zv-OpYx%sNZx-#-YH?^>x_ zd!$tH_n8c?o~F*j(SYA%S6=^6h}sL`AS)hp+z}PQ1-r#lpCtB=6<7r%W#T=A?s`AC z@HJ4dv2O2T`lHJNi+J(6jY5-pOnxBUh9v5}e#ysN&G1i|Q1I>ThihxBH(RKErw-Or zwA|fy8|r&jwZ}{c-LxbP5H9pV%bKXMvWpqE5{I3_yQDdq_&zkki<`I;_=@gg=H>|`Dwpz#Y}0uC^Np2TBu0*x!`@cI{CcMc)Hg96QmP`|PS}S5f$` z)ooqNs#DZW*t=7X&pp@25Nw@vs)|glv&Fl}p3w@aPmgROyDsp$C>;+>$ODihF~Sph z@z^94G2emUu#5fD2TRt*Vl9a|Vq6;ejpJ(CsDSHh`f3d|GsQT^m5Nz_bHrek9MrHf z`AL2{p?d6@sBwY=DXSpi@k|`{j1K)ofMFP>Pb%u#Q|GUZTvYbVCbI{GhejiJXkHhP zg=StSi@vt^x@!fla3Z3I2_g&Xqy zjR)ba%QaB$mnOb9`=t6k;!M=Txs$FvHO`S&nv?L4GRO)LA9{HxDP>|cJNdF-UOjfA zQ|7K(Qq>0_#YdSvBws((Z9A6wMG@COQuS{4#Gl0OwKPLE=RJ7AqVY;g7{+ez_`AD}>9VN!`hGFOoWSm*rCfO~; zPf|C^i`4&4F=!~G3S;aP3rm#a&VR2IwMe=O^Jw{B<<(z}4RNN|Ito#A_4f`=wPY=zhb1)7Nq5ilDbf zgOz52O~cHOgeAA)hr6Y$rl|vv-p21)CCg`w>k5J2?v_F~EhW9h0f8b9#FZ{%uVnDw zX9OgRL_t8lq@5oTxLKr&G|;}J?Ficc1a)wZG1+7H0ck}@;PF0jpx_=KwB-z4#R||V zhOrnQ_-WV!TrE~c{!_DAi>U=}p&j5tu?q5+_AUgX$pjn~+W~TkANk%L;=6w7FzA;l z6aryx^)^5&ae)5N&EzG+SUyTJD)UH5ey@o9rIPsXfWAuq1abq9$r4D08XvfC?E!mH zVsa;5cE=s6tPmr5hLjp`suaeOEw^J#Dpf=NUqfgB6joy%-zdeOK(_QU5yW>vj~H-_ zt^R}S05r;Up$t_DAgT<;LdF1?GI5}`Oaj3m-UlbH`ahH71bi*CK<==;gCXcJh42y! zY?dK_$Z{RT4qrG3I>7{*1>TlBB6g^%LAyMYT?05(VFvv{yjxfSW05lg`0v30Duo?z zHj-zI_Aee%2t=8wGTn3sENaHMgpmKF>=I)FyPy0CmP9i6p1^6j54v-d36y@C0jfKF zm@y@cuW$ftC5)xVkzw$yRDk|SXe$H@DS=?2Ffddpiuh-?6?2o_0N*_m*lFo2}kOpG_cg{q>K$x$J2N?{YLI#onWbA*y+4TfP z&*hj}JeJ7-W>A%pzgCd{9+FNX1LQ*6lTMR`{1-ocl`eV0~V3w delta 36287 zcmXV%b7Nio^R?3$C$?=njcuc`Z5yZ2iETHw8r!z*G-zxmPrvu?`Ded@^_e|ut~Jwl z2%c~NUT2F8lpPR8$+frDwH2W8x@o0uQV{!~&5tCJP!ed`_3y|ivGwFO=7tMeg}Gtm zha>U>BbLqnS-{S6{V}<7yz&MEmOa1}oHk{FC2$iOZ`;U9?Amtd&!m<_%jlA_-dn_q zcBNc+Exj-MEL@{p<8RDQ%pCf-daR9xlK@qbS&tI~1l`^TbuztP7-H$5?`e|ZpowSE zM4congfq^0uS@uG@ZgJ!L{kDCAWUa7N<)*pN;%k0ikaZhsZCR^Hk|!$>U%o$=RBxAS*jiQ+f& z%?2T{1P_ON{uEdx(}F6bNU=$q6l0B~4hD8YytS148yJ|= zx1{=H`lMP0W*p?erV4RSON zR>3#I&k*MQ+`x4-gX!+cZQF~6#|%SY&j(oDPjk={49rZFV=|uRQ%Er_rNowsOQa2V zCTL7xp!pV27d_cCgtnFb#5AYFyNPL0pk>J^WgdxJKS3?ir@Jr98#pjh#>hBT;TolW zhOzO%$GA`wqI>+J4If&JpNbM|e44z49V@4o%sf3ggK?L+s=56b$U0czF`+Uerku*MYCaeN(+g=Gg^-1-}^v=w77+jfXPP~5XgdnoU*0W^bx zQZ3U%sW+=NLp3epfo+8?c>T9r2HX*JDyP4y(l_19DQe&}-J`+6NY^w}9^RvrWz;>- zf4ELu{{?hSfXuy+!&$b5v{?0Ov)9aEi`lc-pcBGHL=$nC{H z!g+;_S&C@(5bowYfn;Z>8ycpAis;4ggBoyulWR z;k-rLhP8eQbvsAXg2wMzZvj^zTCkZGC z()jOvkTJ@GAME>(+LBy}#gB2qvpDca2p-!F88mz+u@G-+V0=o7mI4%u_B?_0+Vqs<$}U%E;1po2|Q1luKvVh-OjV z8Vu34c~V=kvUrz-uGVLxdaLyUV?P3L)7h5b_TPh`GdO5=WyL;~%}4RR+s%HT-8a2; z%En$1AV{%s-e49SU~vr?W2-;YB%RoP1pU?t z?SNgg5P!=6%8cO5MNvL^wb+0Yo|rThYd9)MC6D+AWJ+Pd<98gY-^KphyHIg*rFDdy zzRj5%<~T@)LakdwtwfWTXw1z;gx7keC(&_lzYQiJa66N*NAaj|#B0}IA1i?6$5D1I zZn7g3HM0WHKo|D-(k}1i%CIl&T;q1bK0F5&v%xp%8_qwA{-lNRm$f6x+tzK;KYZHkFKn!_&X%8i zN88!XZnsE@xfEkMdoU<(2>*L!E3XH=dPyQ!c0gOTjUOli*m{tWu(k10SyYlxfaXvL zir7ADJd#=@NM7gu=u>(2mD`~ovjgN~vx=oJ#8b!bKh3BZGiHlEmNP!fO6bSry`XN2 zAEle81v)%uF1MG2zPkO9cj>y#y*|&^2Kr}gLeKE~YbqKlx@#;nw(9XfWBvp6oD=2n z{Xl(V_)9pQDp#e2Gtr&v%+%898rKDM?Ix84hV9wtUMb4Fyv5QQ)D_0_^;&L)B(U1) zCK(?LkEyy)C&UiPlM*L^^{DIq!FzF$%1DKWG({HZwnGkm{Y_5!zIe|~otmTD3R;(T z>q9JpiG2_E2!8(&eWlicJCiNvhzp;9a-g<#wVX7IUR;yDHKfmRbL)nvtl(2<2oeaX z$H8kr6KAoQhg-sAhsAE7XUxfwAvYi%wSP&VbN{&_NYTxGkDUhIEIW~Ok3+1*R4t^2 zcxbAQtNA|J@iu$xLZ{{srks&Ta@bVNhSEd{Njk|xw9*P2?gLPsG}M4+#Y=7q1`Gy_ zwc1l;o1QrLcXhtxkx>I65)Min)7#!QD}{Dr3W5-xI}wg=pu~3a&EX8$8dpMQSlYQ~ zQ^wWu-;ztj;)5on$6G`4O%I}PN%rU?BeO~x9#*&Oav1sg1)!Ttj35g|%xFOwtAm#f zJ1ZFnfYST8ck=Z+CvMtNk_`z$U=eG0AsxmUX?Ngbv!eP=b~MMyyP2Rp-|=#0YTXB) z(BFcTep=9Wuz9>wig8&=l9^nWMPjhoBIej)cv|L(ctGBbgCW+5*L-*#&yxQU?8^@E z4m@LOkT!<-?&0^r7gSiKSeYMJ!xyLi<^6&F11lk+@`@ZS>@Wy$(g3GpN zzaVa9oOAgYkUrn%r`3c%!0^WZ+996j!=Yh@scNX5`@q9)=n?xs82AGNH031}HSH+? z!kn@RD469IwXnXpz${q&8RXNWXKuDF{yaP7e)hp{`P}UD8`YWrjk~|)jVtLHcPZ28 zFD$sJT96Qm%o7!YA&ZOjZL`!i`F{2+sc`R6hSlG-RJlX6QbfjK{HbqOqSyA8E)v`S=1sYmnI>=f(HMP03A zznKP>*pGv=lC)ae@tq@0gskOUOfrNlQ!Uvn>clP4-PkP*id9>O4rR(+PzyclfBiK0 z1go7ms|bsH;_E=bUzNU|nB<#zVBD7IB+wI7{qW-n$-`>Dn$eP2sPKhK_(mqLbNACs1y z5C@!^z7Ix_-xMM%uUyisE14-Ifm^CZ5$u)bD&kq|x5T(5&RcJJcwzk^v>#dLC4=+l zeHKLw`3YPdUw8gc8CZlOYCJdd1gem?8>O!1m9~G${o=h6CV3W;zvEi0iK>O2NcWPW zkOf$){*kT&w?7l3hf^fWTAr-Bgtdz@m@R2~tg=nN5NNKRl0+Oyf!~r`2RbRi>)CD_ zt)7Lo2bkd_l$xveuK2Z^t4lyMzvdfd^`^2p)2@;#uVri6-4>$qX>3Nl>ZlvHMB*)u zFZt8GmnBvHgvWdu)leRyvP-RmsFJ7OGNo>y6}W)E=Q_saXmb1AB`h)_xqzw_#||}B zB~|V8chn9fQ_K9lb!L&E6euSFTis+OqGhx&epF^ofzg;yl(3qiMt7Med%;8IbY*h_ zAIthg<-3@3U&dR#|1JC4)r^1Ckukw&ELoDDBS0jsL!a?joj*iT#yU+3g?u!tQ-|2qU{4X9a=aVG~P*C^JYf@G{p;Sjl{I4Je$@-y3}d$=1wi zPjN49)c+eI^fD^_o^X`g;h)n!cG5*uOhB(F;y8NCXL||w4Is5`Qs)PaP$rdXI%`$o z)iS(&oJgqeYV8nSL!zZ#Le8h+J2lY?{3=c}C7TzaGVmy{=m>t5NF#uw0lCT!U;at* zeubSL=SM`y*5YP{0D=xsbh}|st62zy#v}YzT=yP-q_D=mutvtA+NgRGuVklKL?Y>Y zNrAxGL43HY)Cq=iy@+Ro0xmi7CHv_%oH127671C;doRr=fb6tTI*`i$~qTrV6v% z3u)$!HA-pLOdxw`%`2ifx!yfYBMJMvZ6DIv{7ckx5#$@KhXg4b(JZ9Y2|YPK}O88DkGDrr!$ss z>Wl43B{((A?-E-lNha)0^z=FVkD9Rg$|{_JCHtwS^y-VD$Q#A)`tj`hj=P+2f3g@Z zn%>}#Mj?S`hjq#~_Sw|~8h&BUMYLM_VH32kMBU5}zyK2Etj20Pi|CKieJO7uLqj!K zqBO^6XZ?aQV@|IYOf|Qxr+v)Ff5jdrb*<*&ct&fR>DEo_n0og7J!3KoO>F4!gDh`0 z%O#IHt~Tx~Tb`m+!7mburyyoxXJqQP4s=7g^VTCp+3`ccwNh&&y}_H_(uCZO@7?&* zcIR~$kQ<1?ufP`0==YguC}pib^pvlB{{Av9Vb>Ento23a5sFn;>i*4l0AUqdyZ4i7 z2OOyz(JL2e&#CXzTu1ZTpNS*R|1P{UxX^Le%NB{ywG4Ua=#(PtvYvpb+Z&;a)#l>j z=>s}$uplLW4<@Y){qt6HOdD zH9JXiKON%g%FZbJaqm|8xvmwGiL3}Q@Ye>wM;V;`*%8@RlVGP@`iaBz!0|i!F#_cU z7{QfIT$XqakS(CgBYJdKdBMt!bbrOVx#!=npRU*`tQlKTPZ4ve;>3y_^x%4Nkw(N$ z2Mndhf2d^69ISoQL2jNlrOF;axY~2EBN?nsBfD$8Wilx5P4|3F>o~r_?Dh~i=m0f? zcYw#Sh#$z5ID$p4!Iy5$V>GngyvQ^43lY+ekJj%@?S5h^G(yfB^rW5V?~k-o(bt zh1PggH3Q^s%VU0ml4CR-E{XouY)>=4nH$c>(^k_o%Us>1UmP^IveP^e$svYXKIl;Z0aRpz`($f|7*9eq#D2+00!#L zEc|*`GTgpiuT_YZ30q%y-)Kw6qbl9S#k>c_@F?;P_p=CkP6YA$w@;b_>r+4`C9J*6 zOjqg5UG{?O^vBED8#0(23yvTGL8n#s!usYW`uuzj(@b;*@GL7G%7GvZ7Ox9_ACgzdB>Vv4gcNnlEzs#C&If{LZtzMlRMV4IjY` zW8R|(C6L_y_A-j3NbAsXdMCpXFLiZgJ1&Uzko&{ID3Uss9tSVLXyxLkZcSNMjhf+| zK%88qgzStrN~F;>b9cr=_Sgj;w$)r3qcSTje`tWp&m_JtT4*QyTAgdtDTcaISfN>W5|g?wK>D zG!K9FNZSt8Z42f5FypoK+Sq-Do6k_1bc*m1^1s$)Ch+Lq*&|S(0_Ly89U>ATlHJqD zCNG!Npa~A*ZVIarOd#sii2a990dY*_KApvFYmhA+)4r;nSxo-!guCG*(AQmALkWvY zCaI+U3=X%vHKL8@h|xwe(Le7+O9y}}VEvA_g$Jr%?b?1=C-WNHsOjb5G|caqu###J z?m%5XR{7N=TS{xjBHpa*o$~@>U#g|?mwb<2;7bUyfJF;VR{1;FMpPn1<-@7dV5VK5 zFeKf#P?S!pTjeKG9(J~*gUl^hoY{~rXPi`S!35IqoqdaEqXUxEd%%+xYldaiiwD4F z?EKHkErhDH$%BJ|r6tuR6aF)DYCv!~xwho2pJlB<&5d$xYD}VZB4RRc@}uUJ9wezJOTR&((J0=txHoku!$7glEHQtvrRwzv`ge(6GD%Zn{W_3b1fw z5nGkiCgfz|Esan`(5q>Fz9gEX?qaoa$?ERml#qvT5C+eRk?KcEc-eUQ@f80V%zrKa z7ERiy%^;)S$;H^mqMs}|AJ1RX z1{X~u$I)w%o#XEpE#U88AY&k#fTw~*Z2mTV`epB^z&YQZ-(%-#`ZoALmX*8D!*#u< zamXx=IAJEPO(DG?ili+pJee^E$w}5au8w^`Hl}*nJssk|LA>VjMl83n)s%u;;7jkw zbbb#n39MD1w?-Op~8h6x(ctF}NdLlvGRC8h$Ii2zhtb7}+{NeY(U#9)B z^jC9sW|kqAe{5l%X0885kFE->{V?MP8zZHV0jItr69982$Sd+2=+PGzK9?QRi^;Q+ z-F8hN-*+*Cr64@?8eGhiy+bV`2r^V#cSlEi;@o21G0k&jL05MI9~YEsdn#ibPF^u_ z7ve@UWK0n}%i>Z9yh#CIM6+_>^y~g^mD6aJGF|!25KO@mIEFIJI`m7!-h)?3g&yXJ zPMQ_4oiX-C%@nR4@h<*zCw8iXT3D5qZ!fSo_8>Z{c5iDt0}kp z6Ti=tOk?zn;%^cR$U||?IkNBh`~F6$)l2N$g{!>d*WlzdN(K|l*F&Bvv-Q#(Fy1dq zIzKq^jH;-IfLxi0`WpLx@4RRxAt7mx+8GFoa)O=RTIC~+GJ&;T0E>b~LP{s`Q+g;c zYlUwOr*k{yB8HCine+oYo9>|(`6Ny>T8z#|?4fVwZhP`>^4Gg(sNEZ4|ct^}o#NT~DtCX~$Hz@Oz8mxle4t#SzpnU1Lp9 z2rLF%-@W}1u7;nt?~*n0ec|bp{-@GFr-9C|fArcP{J%z*i%yxeO#z)GL`MXK#lWVW zjcm4Y*JV`3QWe6R$0N4eS8I}#N9;~F#!a<X?20 zW|26S!Tyx%dp!B^c`(5Z_M~F@?Bw@e@bcrr=|h@F-(7df*G6GUe}kQoD7~g|%|R1| zIh3-M`Q-PEzrq#5$0+e?cl#FbAeGss!qSTCiGzLd#LnLSuP3o`m0j-f6LhLX$j4PO99UQoVHq*xCsCLGaeWeHEI#xPYGo`Ikg9VglRTh)*Fws=?py}+QwEH zoL*Aw{8GC-L+lm`xPf4T_)5XO$HlU2{NY_~1UG@JH^d2=?|F)YDOti~3&sDEi8F9w z560XiLvKBv(~Ey-5G@6kMLfp_X;g)xwO}$Bv5KDoqPI1SrO)TZS9N^4*{xAcs&dqm@6y=R+uKK4pNBvMW|IWX-SW z5~2(eg0_%}6aoe}Gz_2rnIumiN}Hqr22-G%9JvU}NM(!+M31J(x za)3(*$1kp$uJ|bW#e|lFh~|IkhfKTbjXd53HI?YNuKK7NMg4%9p_{T^aTmpd$2w52 zSnH|1KJU7QnUH*Q+W`GcSKSuh@oht(m?puawMUZlua=ECy}SIH;Cix;N_TyG{rWZe zxi2?*FHW*fi6s<~Oeo;*@UV!TcM%JUEHn(2OlxeW`0Iduq{pA7Mz&mI)L~q8Cht6$ z$TJ=uL}nE;2^tofa~Z}4f9N)w3qK$pmCb2%Dpd9isUK94hJ*< zR>c&u0ljP3PPIM@4gN>*rHS}fc+Qk#?H&BPTe&{8nq(f%$MWB&GID?9&&VpAkMcuh zDUJvTA1-KiCg*uM(MC&tb!qacg|baeup=s|GjNFpGu*ZJTA1{9PoJT&1u+iqjPq4x zCcccm{df^U6<{v_Kol)K{Tb3Gvh?m7c1uzM6sG2uI>R~q{4WUS7Zv|e#rh3nygmSe&9f302skThk)RE^e)g|DLe9fk$I*{vbr}+Kp5IcNE_l( zq%h~74_+a0qq?VD8p__YZ!9Ix|aJC315pvl62ouc1}*`lYypQr(et*9!Yy;nxjF6+OyFgT zIE!Xiq98#WR;?)B~k7n4sTO;i?PNmWK^%=7knsd1V^}UK`6eg*=^eM9$ zzR_gnQ`sfV{8^TW2n>x*;5r~r-PdneeOlkDVgV;c(c3 z>AiOj#**{f7HKrMd$bf7$V5#vdOd$S!oCbHQX=U8M+9aM#NBTHEbj;;*gu#F0f_+y z3kwVO4`%lKbHKF>m`QaN$iNs4T}^aNoUIW^>On2aUmRHGnKp2N@pJ|#okQU%;BaV* zl8yH)uF{fJ?9LYb#XpGk{4aF`|C$>5*;hj8Xxit!%@fb<%*{Jmv|=t}5D9pLnx zbZ1R6HfW0(lC?X2)E|7X>$OODcIwD#cySiD5iD5FBSQsAi5^|!nO>m2-Iw}96`Wdb-~+{`;ubg`FBbtZOR9?sN^bR2>i z)rr>VL7MoL)|Qh{MYDXn3!3!Z8FeK(1^T5GPn<Bnp&)UBOC(=15y~(exj8}a{*g1~T#7O46`GO#LaDbo?Do_a_0b1sOm53T7 z>bavh1QL4))9jLe5JVRD)ZfFZ5S#&Hjnz!b#mV+Ns4zax4ZceUNaA0N(d0aMA~q!LA9zol3#+6UpjZFBj9~%=WxG)28a4Q^6ak7R1!v7|Y{lZ2t7Zf_ zPhi{tPi!o#DA39+=aja3!ZfUP>kt0EK|p~E?@{f;AZLoj^ z2PNUPFWoxMlJN&*%*&>!v4*XC$z$v}x|!Nm@1U}opU*sQt23@woBG`xYN?8h-i@$E z8NOvG@F(2Hg3<4u#M_W+?1Lw=^t03*uPrywnqgwj z#+}%YQm<~2rgMn1;*xPEtM6dhroxu|z1eqcyeXORE@Nl-Advwu1%INEn0$zB=;Ff+ znYf24!GnAG6FV$6fmTw!V1;3HnVvimhOVoR3)E>qkAO!71>u5DrrqJx+0gu%T}=8S zcE7DZiVQG_&5}Tf$rZRB=a856IyqA{RoTQC`MbkEZ^<-@JfNiN9u$eN$nB7VJ{A#E zv~8-<9fV4;{z}qnR>~txH2jKaj~6!_Au(}K14kO(RFp}jYJpqG+7oaj`i08r=(B9) z0i4W&m@{+6o#VEmMPfcszNK#b1bf2nf5Tt(IKQczngdZ1APD+HeaABt*~d&2e8z2` zy$IHhCa@vda9P=i3Y3%D=pN7NQoS_?XO{2O8Ek&fPsS`bG=I6uZ*E&k>^M|K_CAsdJ$-NU)>N&e!g4vY+^m57TGL9}W^jM{F8&(GB@Uh&p4=Rm-kBI}~M=9FuUE*F8?zu8$8xzra#+>GNAuP29- zW*pgnd_QaTi~uh4G#R)7a!WkHGc0!ro#kenL}OMqhczZT{2g`}@R7MOYWzSrMNkso zcrMx;h5+%J^wo7VV}96PhziCZEjgvc=FxE{Is;CIwF)e4jjD?f)oe=~n#|4p_AV86 zM{YS6-Smu3qw|~d`ZX}1UDkL(1~cYp7Dli_KvYRNe?(>K^?5{jyUmUf5BoOh?H~m7 z$nzisw_-23SWsHu0!Xdj8W$LR-M%O4$lUJSJQW!v!$W=0S(i9RUA65ppr5o|($3qP zw43Ct;&pE-ysB^FRL;eXxxoUpA3-(Ra`x)YE$J*_hG%-+3`}F`BSE!YK8>tc5^y6A zS0)CBW#@UQcy%N9P&=S;fxLq4D1SWSZt7ZwgkuM2enycYZrHL}3<3X)dw-U!1T#W$ z`Rq$#te9t}wPCp|c~Ou`a$?G!hktZ>QChRXldrmo?K?&z<|thH1;L~qWYJdSO$5w z2fj=RnubKw$w3}QGE$0uND@wDQ@f6TvD^h~tzvw&ytDV*MS*I0Ae(YO)57I+C2l*z z)MHp-kNMDS5>J@>C5Z;cV6kEqy%PPY*}TTntDno0{(T5uW%y_xhCDI_?qZ2j49R~_ zYw{YIDzF+YofC6A?jM6X+fUzlaioizW1T9Z`_$iIErWK9%cAc@yM=F^lK54JB}m_7 zy8Xg$ysj~+aDm-J;BX6oTIZ(dHT8YiD(o5?P{Hri>qAgDohkMQcA&XFjq4G5lFCK_+iSB28o4Cfc8TRQyywy zi5m`K=}Cx1e8-yUuh-EjTaKF~P2V?=p^57SSlVegu~A5@_zZHqs_t2=@I0=(M_A&v z`ZJ~AS}oR5U+HrdkyQ$~``mZbU$$iN87ppuwnBw`b%xMN-zCyHrC3g`VOrLG`0$|*w>lJ>5`j&2Z0M(J zp9MiSv*Cx;rzGSn;}ROkozd{lB#M`)WWCjZ4(NT;v9wMn5&$vs2iFw~)G5B{nCXNv zYVqi+R!Z+=D^&aqKLi__CgQ$36{s2Hh%;~&K_(R` z{{`K$C@pyW^3$HM)&3RM(V;l%miZO<1!jmV*b2z$_Y6=k)ig;5L(Hu2A?ZvA6qM+ z1W@@^gT=p3=o8ViUfmDq^uIOH99uCnGD4QlDA!c=R9+$Nr-LmWG(o*$SmP9nj?y5) z>0_&^F!!Hr7iiYH54PWx!VN21n?vA+%c(Hn*kk}cly4Oo-f5OZOZXos#( zrw0xsnG~fV%t0T>FT78txgg-@)T0=x6~qBRW2l3ywyh6+U*P-3rlRes-s1S?S3dIU zwh1&HK(c5#v3uK$W@>t?wjfdf^L*F<`Y3BvNsMNy_(zXq`-qcOsfD`vo{_-=u7&^$ z>ln+CH&wS0OEAL{zbxj!;#*S;Q5xgTn{ZJe4NiBz`m|HJ8~>-k9kQCO;eXA+zU0ix78HBT4taBPMZJA40Kh~@Kdc`J-@Dr4^UUl{$yeg?sd{8uXKl2x z+A#$iG&0%Are=9iT?lFqO>>7dpZS7r9H`K1aHlVvQhPXsnm4E0fx_e~ALMh@lGa5t zz<#_Qb!Rvs4X1BuxZ{ZJ3IJc7Or~@9?VgE^m!Z{_q6s(Ccwl2F0}9(G6V50x2rm8J zv{lw{29CJ!i_tU0UktLw-6%v%Y}2!PCThrj<<%vGTr65>DB9LvAc%di!ZwGdS7L=% zo215e3Tu>gg{*>HiN$)Vr?=lVo6vaZwI=++CGR5!;c5JbZ*m5j?PExM5FAYwA`ZIPJq2rIpR1DNgY9IJ@xxmfF?s>j;tN9ZP- ziKM6DV;OGwnF*O4bnbm~>OefH4v~bAat2X--@(GUZeAX7#WY04(Jma-+mX(QVQJ|MKkCnQw)VH?KN2{0fq^Z;iwm<-_?n?0xB zv_x89kOcxo=xR-PS=$PqQcC9a;Oy*s?B(5vI76Zl39qsno`qHi$OB_576g~)^oQ`E z!Lzv@(QZm$9$m-l>P;?iT>(ZqQ z6z8Rc|5GXho%qp=sDh}x%Wrlj_@Rd5`%(}C(i1bN2rt`Gr zy&r#%>Vd+gDk@#|FS^@q5<4+}Sd-(UJem!;Am4>dksSBlYkmwdoY+v8?>n>3 zVrdg)yOF&`a%<2t)js28aki}n@eZ)bT+cpG7J6B+hO?=Y+oR2-M2{5w7{qV=9L#~b z1Oj4k=$$Z9>DEonmxTM9un2~AP9d^q4)!5(VXeIVQ^D(f^^aU%$0Xei>E=XlG_zy_ zxbpA+ZKY9)tA%X*6M5wSL{^s&1Wq`hi=b4I#<@q6I*X#UG7+4Qo~3w;|3GsFi%>&B zOXVS9x^VUtn7%x>u{b9nyCwC5z-AKP?}fQmp|OX7l-4U*TGCkJWETnucthHyC8F_b z@ATW~2@flpS&iK<)QUS$tePlb`wpeHUPL3s(0Y(P)&QVBL>DmjKe7ys1I7&}`(6%e zq++O3TI{j%^PiuN%!Hi1_BqqM^8cKG~E4`yAF7gX~~QBA_7*4 z&@RIKnY0ctcllwJ#w5osRroKom(mzw@>faigRwS9st*=ss`Fips;j8uEdE~neT~7N zJ^MEj>N4hIY8mZ9Xlb#@9*{8;mNWDL-BiJ=rf%M*$M#q3hP$}c=+DL@IvRevoX=_@ z!H))06s(r-4n3NyJ#ZO^91XYXOs7PCCyHZBbq`8a_%b2(p=G~F)NAWDUh}LWp6YZ* zkRCC97>;KZL~z2D){z3ea)o=f3@EX#y5lPTECvd~n-yx@!s-54X zQ1fmh&=H0Vkfn$Nrvyni4_E^#2p(dl`FfaFH_%Q>55W$EpKUb5;#g!k!p_QLodF85 zntG2=DP3L^2EVf42;IFa^IgchUP%!N&4L_>SBajzr{(8YD_I-5Y8wt2~0*61FG z1xBI=b%H`={{TZ({1_84DWWSIp4jgZe7Uht29rwfg+tZS=@H#8UQq5j9ptRixLSO_y14EaUBTAP!D7I2!byG^io9f*PKvKU z)Ym}fy9}wF-G%ulo_qXtZARNEfk~nJQr3`V8jBmE+7b$I1HHJ#ycA23DttRczC83qD-~F6T_6WnTLx2D|8kn;btQ z_iUodFCf@_*XGpJD)l~dJ(eRWxxz9;H zH>iOJi}j}JNBs5NW2GBe_jC{caho&)*(mvc8@Xsu{~34$IRzjimO4r&bJ>Qdu1cSa zN*|d)uP|6l46?;4(#5z(%d~^Y{|+p63umkv#TBBJGXL3;20eLQ`9>K}%juWt?>pb` zraqrvP7!|6r<;2{gA%x{Z8o~KtjuS1S?=~@yv5?A$lUOrZdYgD`m!Ol@sgB0R`KN}j zdBWBIZr;C}Rr?X4|AsN?tww!zboM2=_9mJ9T|K8ZgB1AJ-m9BNmBRd%agUWCbE_}S ze?oEVxR@1m=psL0OaRA2XnyjR2MeVSP`E>I zjr$Ea{sOj0bNlEx0Y+>`=Q9MgNbDsl#}Y%Ysh#Oa+%rWgA8B|dX7K>>?cKKRTmuOo zMp=9>iv`3qp=kF7N};i?0R4yUEc1zJINmh`I)M1eA$TaycTk8k%TnLD?~OV|>?g?( z*ch`myxBu9I$Jb_*s7;zA0895JOIEZZey0e3uGG$^2ulYv67=3Kquc*a+xbLfCADz z6*MT$SZYvZ>7Q+uGc}|&j^~xOS;0~K5|e~?m^Jg~R@-$^mF@1EwHhR{wR*#?D(Sv6q2kyTzuB){OS1{NQ)+ACTNuV2`%D`XIW~i-k*@1Qf z8SA&U36Gf1Jpox;2CMwE{lFxOXZi-xg~WU6>bRC1$5hx^tx6vbI9#Ps>9ZvH1a7L9 z2UTwUgInr|l$}7{v4>w5r-=olKy~j(ol%-#)ks5oMuZ_-T~w(aR1=^{n?7leYs^za zWtNh9Lz>4?7l@n1rYqaVf+d`e#-m*Mw)o`MvBLq;FG9-2GQ(4ej*;LIsxfR%ZL-{sb0=&o1 zELbr^Mk$YROZE(Ul^0t5Y*DC6>?nqv;=0txGS()kXm&!P22Hper1-}PB@WLk$yEztTOmIsrE(`wPHN52JdspO z=HJO;x?F;+^24}FS##v`gDHMF#ihlBbFj2e=Y)Vkt+}rid6wrcJnP-~eDoy})D4i% zvFVa@cOJY2PLwt-!y;X3GNw6qY)&Ky=l(gQ)bGHKhY-2+0Em9)=NLZase)Q{FJm(4 z_ArN7NSll8@FU)w=bN?hqU+AMh= z$iR$i24fTmzy40TGBt8bcJhJLq5;GxSwhkNElC59tKu_VmB^#9U=C{GorSI(5rhGj6-;KUNWT z$g#HR0;V5SWmdP1k#s~lSLBMHSf9p?61&#q^2%I6Xh z;l8b8`F-V7dp*jTqJ6bP`m08|M>xnG%ItUC@#Mm+MoTyp_{-vZiWw5QiYO$y%!2F2 zjXIOaf**rkU@%UGr;kw)>Jf7Weh+j>^J+3cB2ymoqqbB9`!`A#tTb`Ma(Cq$o`LL( zGYr2b3T=g+pjtI?fa~hIg2H7c-N{x!w!{_wvjv#au5L2+hd+KHBVF!oO^Lf{%?Tm4 z=G~cx4McbFRpg>q`zF~K6sGyt8z3_sCno0Tcm1~k`H|(bn# zwC(~kRqXOxL~1wW6{6~2&B_5TBaBTcrT|OA6;2wbPt$jbpT5^>Ao_6$og$T#XxB#6 z0YY9$N&Hxgf7fLgx8CiWr+DPsI9;rbQ7s;7lAqCb3a4x8fd)c)7}-s@XeF=Y1A_9L zGX=q)zZZ1|Ws$Kldzj3X?07trUv&QhF&U^W{(i67e}YscE1~*2QTXd&BR!NSp-HO5 zUa((#56PoDv~yBo<+P6&yS%#FIM(wAGmq|5qzt$5Jo|E5SOGIyQ)Eh=_)UobwGSBh zdg1}jj2RswcO}xk_d4j#xXp0?o7b7GVSzw)0+dS5ln#V}cGS?Svb8he9;H&?sNjUdWz61x0g~ zOQ!jmpGoB&hJXs|;i$S3r+>AoZ-wXD7Ah@;7DSDLt%ettryI!;#eem$K=i@y6 zUDclPDBB~XpHF7z+ddYo8Cxku?&Li6^eCmg)~ z`$C1?VKcX5o^6dmMg*NGU@N1%V0&@+hVP@OJ>C9?z?|6iMQQDXDDkTHV3?y+yjxS4 zpw1w*Sl%VZt$zN;!LwcXyAMl--9so<L02GYRGP&cNU;Rm-kezDwkiP)BXr0?4i9e-N$-pPig$^&NdZ)hvpP5hu| z#&5p!GfOdJ`70atg0P`}ZNOedLE2$%lB)9N11l z{iaNH3F>!cs#{QhC{sOx`qNQB2=Xseq<}*5&!^`vy>W>tXN8a zRCHA+3EK^RkOqkfN`Z$OOlwViYHoL@+ok)JySp{S$Pe*f7!x#__yhb=#@V7ViVwcr zJ9B2v%$d3O+xO330X)F6z`Nt)R{f3Mlh%*|Ti?{JzP_egp&z-POx!Rq{Lm)G6?r6M z;^08WhBY8-7^i-$Z}z1Z)0!SRhA$(3!_8{+Ha6C+dk;BR)qnB(spl~e52UfqE(MMo z5Ggls7#)#{xfkR0+WlJHuxX^f)gT0l?J!jq?YbTbtc1!j9VKm#%-2dr5h-(T>~>;O z`=L+GFdU{)9+LvIhjJuMPX>;8&^sh6$zxhzVW+XX-D$q)?zOgenvHI!-Dq`x_Ya;m z1S-wnjCPVKdnBN3S)LoX$zy?Bb@ipd{NG7WQrELdtyDf?;RM$zH~2V#{sDL117li_&k5vy08mQ@2&=dq z+S&mC0I~v;v6LK>=vqjB1`x&o5=bTi!~lb!*?_<#P{QJ{2se|PWMpP;oCQc1tG2YZ z)-DgbVC`m?wAN~CVG>OhyP@r)+S3lBd^M5~n>nC`mirk!hFQ_*2Wj+lwgieN>gtD?FhV#RxZqcI~LwGx52)oEfq zX~s+=Wn#0(NChH2X5>gJ6HiqHyNp=Mtgh(o4#bV#KvdA^sHuo9nUqC1)}&15vujn$)OGKI6SzP9GdnzeyW^JvBEG-4*b-O3~*=B8-OWLj(` zyKB3XMrX{dJ(e_odV9@e?PmG8*ZyiXq6w9pOw(^LjvBQwBhg*Ez2gQml2*yhsz@8brWilV#JWs9a{#NSTpLGMetI z9S^hKLmrxl?t-{~m&$aSK{J`=Oa`UWET&SB z4OtOsOeiK#G-0M|ckc{=&>ZsVG@Ir!dB*OjG@r?pws!AqnSj;;v<0+Kr_0D+h}NP~ z1yc#mY=@7;A;!!+>R4@iXfZ9(X%Srkt8~G*8dVlp&4yEHIg{JGF#{iCDz6NUH|zRk z`#e-l0iCLUs0OyOIf+`ef@bXwBi#cdu3&P2A^1;ap%8hQ#=?WORdl6JD`_>8cjCTE zbzmuN*&aEf7l4QrV6UZhrL=~E;HHS1sdRPT8{~4EB|WXl?Al~y5}nP-q?J@@V_vB_ zvMOE6qzXp_2Oes$b=L?+u8t<6>5b!bGvd-7YNkzpI@Qx=+a^1Vq?t&2s6`N{r>!>8 zHY09&C}gj-g6M&o8;s;)jkd#kYI>6vA}bv=QyRSrd?n4^m?0uEnSx5!7CE;FC&fIV zopuSc?PgkfX+)$rdj*r%+0kN)BNXJJeY8&O>}T?i$r6!R6!8#`8;Q;k@(mDDCiHs{ z9#Lt3(>tWo^>i4Yb zOE;E~MM*G!qed{8>&8sfOlx!$D@__5hlx{veW|n=4+ukR^lGN5l1wHYjn#&tDWuNV zLa25#?Y9B_IgjY`TV4KikLlmKr`2C+)^ykS15NQhvAZGOchrbw%w;ti-Gmc5%~T{A z&FRNm%o%Q`TLhoC=97Rty*`;V`Vhcxgm#UT;Du>Pfp+s*AXLaQ2)>EltkVg)ZK5uJ zr4w|H(Wpvqh4MxzY%x+j5LczQp(NN=O*Qn{tin-3g^;aAFOGXVy+b(3J0}prwo3m6 z0i;6UQgbTDa@%OdVs<3}kvr+#I-R8VF!?Hr!`MFiKArBMQ=*WCCUBhtdB0A#)7?yU zuM`Z68_X^%X@_%rrX#nn(g&F~S6;+_X>IKF;~^#}H^yT?f?9IxP|wHd6Q%Sq>SwBcMXBsZd)i2Y{-^Ti7En~_)5w45X4=f- zX_*iZ?4P0gOX)s(0A(p5mkY~R&fh%rIeJjQeIEWAH~KnEoRmy&&v|&!WDMeeXDF-F zy)?k21Ogg8#1wc%LF&7}ZZ03GG$aDxQg!}_PG6u$A!8u0|N0FFt2BBHA8{j%%AE4h zmjpLe^ktNWRHh@9bMNxXmZI7Et8`94KaR|6B?_e7cZnt76-BiPjR(`ZiP=O>~;a zx1%yRp}ZCkeV4u`boG7V%Po_s^M?ZDN9b^^M13xeGc^?Rod1;DAJemf+y6m++gr{_g$;ug(&0tGfuRQyTE zK+-?ap9P7(Ab+GSd(%TNibm#n`WuXe9sy}FuU-%RgYFla`KQ!6)Yuy{)94*uvd#N4 zIEi5}N%zQX07DJ~kg6Deb4aO`XtQ#CfrlMJ!}qcnG$ft8Ihqrl9(IeK;$Bt@`&n5! zRW8YOE+b9V_<}IHv);p{?9o~0DMF!8^wpQ*9TT#_XnVoaQ5ARw(-oJ7qjDJ%LTFq; z&K1}@xx9pD@~nKSO4$ykjeLd3xxyi(+cRCByH-RI#e;eYI7Ocu^m^wp+^F-wSrH52mg zNTFH9>jVVGiG^c-N+%kEZX+fGzWI2>%vlSg#XOr;Kgyavo{6QSaB;ugdemsVQRfXJ z;1=efIxREhPgrSyA2t0(qR$2eWIej_NvG}I$OBu@_l7L%NTye13?g%ynm5(&4(&R$ zd1rl7sQJ+D_U4_3wrp>0_HZ*=J8t4lBaL&7Xq;;X0B8GUfgOG*Jy`c~d1 zVj~2y5BeLCOBn3z^o7L(ex(fT5|Ew=Jr zE6`uZG`9$HOCpuVNUHMd3n!QnhcnVWq9DgRq@&$3(WS;Ym^|?fI^W6|rw(3};folf z=w<;gxs%?c^UeHbv>=^P(OPz7>}GN5xN9VS3%^yE<#rgUR^vO64lucnw{r3{Rh$O+`4E3t=MOTbAlL3)n*wV! z7K0DSHuR;1_suFsbAN+}KhB>JNt-k@G>Ja({!URiEN}1nytap4x_J zcS|B|$^`KlAazO(M5d7B9^lUkoX=sWvPF`Cy*{t={d`(etIx)t3_Y-(SH2UUdPZeca-AJOd^duIi`*H zF=nJjD--LKtwAJd!sGnC@~+L_nWyIOvXXwGcE2!yUt^3L)4+9oN6Lz2(xz?MpUO)` z{+Z6tioQcj7zs;cW!YeF_3$tGSE4rm+C}2uw1#UP#NT-=KXpLeJ5fokxNS*)c@xSQ zEG`?lmW}iniG&$TNwYNCA1ePoFW>}_5ExeZ4;a9c$29(<&d-U0t_yA3U`&@+j=2^t zMjzV$3;$K1z6d8yC;J3Zk&Y(A6Z=5=JO4xH=NZGt`u~R?tNaog8F}Z>7_(C5tHgC) ztZy`X;B>hmMmyQgUf^M!UskApU>@1k1G9Fjih@*u&gw)h0!a1 zv616Brr4FL;?P>g8merxF`1Ke%lCnl=qr+jW=Gu9O$bhV3%p#eROpId zS>&M>`)!GkWq;w%FOy))Y@jUFmAOhK$`=ZXh(6nB&N zm8*mv>NE^=^7n{VGu>lBplgc|*gt{5SdvMzOWcXp+7v*0of6ckR9RneV^IjDDjSd_ zqlu%|5hS2>MFz>qua*mjGUXcOT3y+wU`TRBM67v~M)*C9)x^|)JeoRV;%7Hg-jUnd z^XIkc-&()ZA5G+!$Cgh2(j}>-HJXBX$&DO~fDlnFMi)RlB#k+ zgemG-1yfXYuI&0pr$4)N34M=F!g6-PK^UwyHX?~*sS|@_G9FEs{)q6yUQ{+Ie=eE% zw;D-*SJI06BUY!`0ip9IJe+SUbDctaUm|TBA0uyvxc#|*2=ASOclfGP{HBXMfJ_-V zf&pTefI+<#S2b;!c!!ykD@gG!Qe`Pce36F#Sm`F3au{!=L|VDmm8EG}D$mlqEL|QB zWofB*S(a)~sn1jm(p3);;wRKk-n~OqA8xJ6Qqur!sSYi#%71Uee{J3!-kn+6GeF@i z9kBmGLv($A_`rd-0WzFt$aFnIRpGG1+uiQ;M%%L#_g0;uRDLys)nj6HZ+@i@E3XkN zVejhz=zaYedcz>SWr%JM2c1K7M>uer-j${I4$xf#^noGzP&nuc_?!cD&qMS{rl8yB zeuzHHbc)aUT;lyS(_k z&J#ZMP?pYT>FJ=WfA~J^e@E`ui2dmsvh;&G0ay;uXKc`Nm-DcEdm>9e5lF{?^fQU% z7f8-gP@n1^1>5l;{qioF1K?jvV0S;24$*JJ1N6UV13&|0P=nMyElbaxqM3r0c+c}T zJ&>b+9V`)0B@*flKGzUEANG|T^1d)Yf6UTfv-EedcOF7#>0hU)EH9|d#)Yr>@NpsN za@A?&norHLa?gb`K3BQsJS-$F*QBUHO_J3L$lAitsI{r3z}98FAj_AB>$JOR zhM-r*i?Y0QZ~ySqJ}HV%b(CvD8r69?XKK0qd7m>J5Jy&dyM>;#)z|RW-nWCjtX}8{orjr}=GyJ~e^iGJboO-xaP??-q_d z)#om^buMgI#wYW8I%HD&X^PM7C|9Lr0%4FDOTW%3(hHtL8pRR$!Y#_IH>2TmH1pCA*G%tc15+X zq-qSIbA^O*ukI0=r}^tcd_ElVK~kTy8Y+D%%ioq+INU1YuQ-nu5nOGNt&3_}Q?3z^y)1#y=6E$3M^G{o*XQanL!)znRIujhFH7P8e%k z98`Vk+Oev&pIqEpeU93Pl)2#pAwbN_DhpbjkI-dd zM|Jz4vN)?;F`z6PR0248WtnniR#}7H(s0P(-Oyg9ti|%xSWvOByq)pYus5qTe@>`P zE^l*G0c`W~L1mlJ*aY5xx$SIT#js78(kgB9yR5RKOxY=nTvDL%<$=7iM$mlvp)zHc zofXTJJ)^KA040+EY!eV=%D&|T%E7Z^IIafAhw>bclf=lcOJrbnou!#*7^Z5aN`&Uo zVydKToDVq9s81@_IR~BR7M64PUK$hUMZhz+(G$&-00pUpPSq*?jAft z?(Ooq%YD6kcDQ@w^A`6BwI0tC?srP~lkWG3r&_Ou=_91tAM)>dm2Ow*UX|`6dWq^(s#>`Eied7K25A_L zl2#NJU;=zGp2M_%sR+=Md7xpmRV9BE_lA&I4Q}#Oe+L~f2Re*v_~jIA10k#@tDJ)NC8QAY zpQOJ;Gg;`OIE>`-WlCty7o|$4jEFk{PJ&27ZWIR>08w6lXZ4z^Nz(kM;QKam2t7%p z`8H)fFTcgV+(x-=Cb^;Vb1FaYRQZMcZUZ`H0n5*e|2+r4Qc8x&U4Zj~jq_X{M4D-NjNTa+D=M-cednUESgQS3}zW!9}%Ytwo*z)H-z;{Y2@FC z*XR?MNKn2C?gDuvF>$hBVv&=Ma2kID#_PfHyI}Hra0nV#`V=VM2h%=)czlYc(bF`Y zb(+Cm@+zO9GUZ{Kshp*9s%`+=xU+$uI+TS zD^43+M`@$0kFIgOkFIq+K=tmK)Zku2jqdkQllv}ecK?tzsheoC`Zn64K1D6+GqhFx zGjzqm4WTQ?zX4E72ME***tQ0M761TUEt9d79Fxa!Nq@o02rw8OlS(PDZj`V=y-jZ0 zJCfXz+-$=KDk30?;sbTO1Qdpf3fQHE@(^{KprR=FM8yZb5Jf~qMC$*1N!GNqh5ml& zx##=Nci!JQ=X>n6`yT>utZG-d{?bb~t$jy*uNAwLYztB4anz5B7(X)?nBX9=)xtt75CykT$)x zc)l;2NN^!DV1-u^wNw30%C^%^s-LSn>~w~*xW2aenC7+NxV@wPT_%)5pv%psWA;WT zVJj?l)BP>|X)B(vTXv?c!9hFS(w@qARwA)&*{&mwMP|}cT8bOcOJHtlJb0o zH-F${mae4nQynT;FLWn5DaTuy_s0PX&slJ8^kIy8tmm@8k0Dfk=YTn!Enz(Acs8C_5R9n!G8V{!~>U9i*$14|WV_1oUr zmIN{%t+~a6MN5M?3P%U93=Ikk##wfGl7DljW}QUbP8(xCF62zjUg?92&d6H{&Lt) z$NMZNkxkoY(hpWYQ>J>VggFmUk$-kRE5#HH4Qyl54a!1-6`^*jRAP`XL{9)0;B5?J zoCVmU6}|Z|#+W<|V_U+?WGG@n(&|O3V53iNSO3&bo9Z$faHvdaRqGnCR?n?^>0?9p0#7k_og1hFG; z?M`YnUc}qnM1tu~?J@?K@|AXS(7U9ACm4&OCp4w3(Gl;!I|Fz--bK;`S42FWHm_m% z*2y*F-FT14doM4^q&)-gD~3|DUY|}|TBd>b2XKWH5x*6WPl{!sg2|P<3Lg-I( z6*TZ62Gj9u#=vC;&YxgHdw*e_%6%9gslqk5mR7!g-@wP1QEbkg_AW1oPhedYK91{H zSyOu9Q#euf)1VP0(R(4O1mC6R5BVj(&`P8dkkt_yjW-IOx!Frs7Gqn zEefG&IT^T(o}tJfJ}2a##qA73KAUwToi`~j#8-Q8r)0wCnQEoU7=OeUrIl>QU2FiJ zyS}Tfy}ejJzbqxp#aHM*juTGbB^%tGsf26A+X}Oa!kQ^=*_$b~_uyX9=BrHTZ0haK zV28{J(a&mB(WpzAYWYEGP@KecLHsrhg#5hDU_U*XfO-R;OnB`s}nF-(*|5^?j33EAF+Y2D63ARNUTQ zY?}pxN=OWRYl^Vxp7dA%kK)@3!w7XMPm? z1)b97W)tzcl?N#&~Jof@cPC1cM2ikD`JOfROIfnPIH8LQ9Ul4c=Y(lDvUO^(uU z@w)(igJ&nr62+o1<1Fz9xp{w7P|YU(On1;p88;Q7l7ErDXM2VA6vSV}J-@`?sG6H; zPI1aH@pq05l7Dh(m->6Gp+~)`VTO|bftLd8ga0hn{CpXc8$tK|Tfw)b>tIJL+2hIo z;FU_ejQ>)!=XSU|*?ah+7#CeiJ*DXX;k5uR#uyFR>7?TB&Wx$}Mld;EdzO=8Nk6pI zinakO-DO{#wNo)&Rg_q+IRjryY zlnZ##Ubk(ikhs8dyp7T?IPtXy)uC!}KrK=nt!GoUlAFeRTrwM%UcsO`T-C{;BPMh< zGEG{ZCvL_c8Bk00biORJEM=;r*gX35uEL2^B+S-nlXxOyN^Vfg$y+t@mW-ciPjNGy z9rWz@_+?d1B_mY(StT3IqTSjF!w0W2%Yva+u|X6bdikZvgMEILiX5Yk4XD+M!+51r z6dzQ_v4C)u%p1qclW}<^f2b!IbyBehXz81>DbGpTCAOR#P^U;EJ*-$u?08*i>#OS{ zH%j36KEKY%P@g)!ES-2A+lk(5Hq{0Os*TTWD$(WfMSrF>xLGviFe8PsGn?$S(|Uyu zwsKB}v>D}d=gFfDAPg2DA8Z=(xuzkXcL02(ufZXFmTx51$nzD1e@hyp+qQ+u_G12u zy;#_^7mLDsu{cz|7fXh5#66I|d8o&c`E%xS$|QIHwT+`#7VT&p!onPuk77l%v1b@f z8eN&gvDK~om&5VHIB^JzayVr-)~v{(Z8w^EWeSq{y8h| zMK_sj&B4kc-rX3De{Lf+DHe7PVR594$0FrJSQ3p?H03bRJ%nV$@VA;3t(9TT-K;ft zBhVBMmF18PmFKYQdQ^?z(ulbS?SfwxjhF{0YwY=uIf^Tyk-#vne5kd`-x{n9)>hqy z!$W3maCI~?ODkO!3WWIe!S2h0YR}j+p+Lk8nfKwN3i*#ue=6+8G4i!rv28CSKk9#z zI3yJ4ss79`Zl#%dU*vGd2)@w0XY5hxS22Vy<#2a6WQ<@)6dR!#d+^)t+RBPs@x737 z0FO0ks%XT}>m4iAcVA1-qIM#LP|QbT4a5H5rwoTpq_LdiJLA*0wA-6kgvL`U%` zH5|rwsvjT5e-p!aGKU{W%p86eG9$(wbc(|&L$dI2Q?zK2(Np~lEgHe^bNEyBa|g{T z?wdW;&ufccIJl)EMp>&_Tj_gSw6*ePbwaIq{cGLD6yR^MW_EW;BB(0ajz-EPz|}8~ z;9vLR)f|&o`EsgaH)DsVw9Vz=8fDTj)j6sH(TWFge{nP#D({K(Jzc}Ld?_riI&A2)IG7I+uOX@Nr=Q3ZY-2Q+*Pk8Aid4nzWFgc0~h4jBSpVOu6-!wqOS zi+xO>bQ*#6>Ua%LQkyhPszLP(o>mvDt2De?e_f;Dwdw{9Z&V{1KA@h^@Co&#dKOSW zQa{!Bv+6m4zH5Bf`Dd#Z4Ff9dyU}-x#svy~tM7J=3l#iL-(HOi6nw-ts&RpWKjeEv z;{pZ$hHt;d1q%MC?-v>uDEKqJKWJQ_;LrPB)VM&wU-G@Iae;#W*I%J=fyDjQ{sn?- ze@GlY^%j=hD^d49oNHj2fzDSjdyI2mz(BcPI9>mD_5bY#hZ_Zqv5HSiz#5JU!x&?Y zpO(hJ<)nHIa}8Xf)Z#JrimK`Pkw|3vXX0mQwal4FKCVfQpIP(s4ctG5E2kxLNkoO7 z9z)smGzRu*s$Ys>Gf+LPH9C1_jmFqCf8QV)r^#-fpfgV}O4(K5bKR=OcB&u_epBgWXF%h;z2gd8d5yEC6k z2R9V;=G%Lb_!wt!9Ox$9R_J^)Bl7 zZbJsQ6gS;nH)y#vH%OvXX_=`c_M)UotQ*oKE%9bsS}$l*aBDk}b$44*TdIG#Y3M~V z^;GWB*x6YRHny2H^`H4xM{5>rTYBrW#l(buXk=59e`jQxlJQSsn@Oz~zVl&zu_6WqCU0a{`dY@Jf8MyEAS+^+ z{l3PJlZgE$PWy~X{M>(!g_eI*x?|{!td$`X)ze>>%PhYwQ^WfzR@s5T{L){8|M2pa zKw)Y5%7KH45{f807{TZ$hEQ=(!dPBS2@D?cE1|+ok$+}@E2g-r%7KKkxO9u$1r-P4b0RRB!0RR9{O9PXffJuMnRX?94 z`N}uS!*=Y%c{I0n+{lt;=dswS(wFU|tz+fsJfgBf1?)j2Ma2b}nT%Mu+sIZL~IKh9fCG6ERuFKu5=>#OAG7o84C0Ka@)* zF<_7Akxl3t>0vW%7+EttjL|bj*2Y;F-`2LJZChl}IMet6KM6rCX74Hq#f`kHr03aTWQfK0tn|;;)qfQfU!?t%5ssxoiE# zjT;3G&wIh5L$}AIGfk_V4=eVhYx^BW&Gwe-Y+he%dl;td+hKph=}GD~0ACwyDU&4! zw+HA3TE|w<1O>{ERj3gTG0vH`V@rb_4bXaOR;h_@ngKUgCxwE7>f~t7F_Y~*Rx$|` z0@=1gAwg9}D&vgCAWcwBNe{V_$Dl?lMN|q?8R`*UnbruJ3l^qSx&F+PwxS&1=^w$Mrv*TzxU;Gxj zmG=XgOJ*vr&>eyl)85Iq3s5&TFQP8$5p?fe(mUE97G=$W99u%$&}?te1}($Z(w3to zthA$>X-!X$VwtOxY1nPr&T|=bj6uz@v>`J+s2S(M^FAM29lfS-;sBA{=}JjUp@ zEC*`pncaU-tl!bIpo;aI6uL*H6O68wnKnu5Ddr1@S!W&?-^(ZIf_A+(R`_^5%U7L3 zjW*9N+&3Yp9y!Gv8ZB{RPcdN$+By$P-rI=)c>mp9k{4|VIBA3`kB9}Ft(e~Zo zG|=DsH7q@d4J%*nS3p#1~@T7d+O@kUU4DDxIbK5mmX&pzc6-1yjAf zEcQp}1FX@5C2{gL2S>8jS$%-H@}IfL>-I0-D)9iWHl$5_aZ zm#%+RW|HolnH=O?@{=k(!bqx~UeSw$B=gKq!M2Wdw{gzhGY8UB5&bjt5tV+LewGUW zR2$AnfIde1ImkbbA;wY~7he{lLp>FsrpAv2rOoDto@kD+ZS-`qc!Zs?or#an~aNv-#VXZiE*tAVY8*!YB9c?dCWE-<(u~42a zk=vQETsD%bPff6QtReWy#0ll*1F?Vi4!PDEU_fa(8|Klq1TKl|mM?A9Y{QUF(M-o? zYo9RzKycu%piZ5}+JRi!F;fOAI3vUR6#BJUnSMsT`ix4?(eo%nT=1b`cn6eI0$eiYO&qsrQu&ZUg3bUT!rq%ZLL-Y>7g@gHXe3XSbC#b|#G! zq#`nZm&=v~kWUPRx$&sm%H%`aNF$3Nq3ht#?ArQH8z?jS8oIz1?zE+`GZ-VUroAOj4*#QehtN|tq(~?U|E80`k^=rO8yc3u}XhPf5IoD4y;U_ zM)iQZ{<%vze*vB>IiWi@G{i)(H|LaPlD`tPvfNEGXa8EI*V!)()1EC~P{iEdsPr2B zEvieII;Um@wFhJKo33=3nRyNOd4s;muKhcBWxfLy`g_3bEYdCv{*Qm0)&7CL%|9RJ zT}WE0gd$T!GC-fBD~!;8DbJ#N%L3_N@e=5Q1PKJ? zf58X~KI#;DhwCqEI6(iy5%}NqePoXVU=yY(KNX-DY*Q>00(cz*Di4VY45I|bBiV2g zBMZe(+Hl$r9q5(uvlxF;_JLK?j{B}&7HpYSn2AcE!1Kb-?gtiqZ5h;gez6D`+fhcv zez6$E&~@ITidYJCGb|5fQ5M}0oTbgoZa`Fv8dWS4wX+iLf~9*|!WDHexu`Ea;fgX9 zu@dS#)}aHjvWvQtF&wx`tX4&XSTl25Oc6H#iAYVH>C)~a4upR?Yyb2dBx&MCRjdi`xeXzJ9Ahx?xx1cr* zE*RS4HePc(oH;DdaB%OKTi}T<6nL2Ip7AzEg=#PmcL4aPwHfyA&}`0jN8!mk#a*h{ zDelGw)8@)Eo6TiV9R$QK5F%#!e8m5j5#c1{+~F)@lAnLVMtaVlfM!R;`W?oQo=ZBV z{=Qk;asFPhkL|dB=HF!gw}KSWkJMHwobXU{a(2%ME^5evf7dSd#vyT76$ix;(8d&O z`Yj}slHaC@PQ*c8Q}xqX-PX)$)3o`;F_qq;=b<a&fg1oZw`FGF?2%YnMlNbOt z$_Yf)Z+?FPjcSTjX;gFEleM5<3~_}%Pkmn=_9Gnj;1*BHZt;uLfU*viPO9F%t2m*3Ls{tjXk;4fRU9WRE=by!22G2`KbzD)%+JO*#>Aa zS_QCJLQ6@A40;=|-ivm1D1LmLYOc`oc;7hHgb#rdQD2_6Um!KyfREdcocD^c!W-ef(2ImPxImisDkbp`mQ z0wXbaBnt&XaCjv)?!)K^gq?x6J_4~%U~~-Y-T*M(!kz-wRgpnMMX&NaL+2~4FO&CD z&Bz3$_gtY&Jn9XPlU==xKJSnE8ocbX2jU%-Pf$&y!RM)~%+m+Q;BNYOU1i0S?Dv1y zBMsg>ozK%xVE-f7KTeN&I(&7$$hD`bEmG&(QcZ;iC+MT`C^kO^gD-0EF58%=Pac7I z3_X72ybp-@S}V(WGQKBIPhWsa;dq{&0otC8DeRT_@u=4m>i35GeXaeKk^Y)rZScA- zdM*wJ{raTTViFdpqg60D0l`hOZNY!<)+vX5j8xydRIkt}g)$1|3bc|Wg`!JBp@#}= zURd09;?z30>uvHEAic6|GN&Nm2{jUTiw-VMLf|9p(!}gGb2~kH#0y%=_1;+1s&#i01u<{y)d?>tTGY~&PFJ2^{=ed9L6|m_y zvGSScuv5spFDB3TsYao3vGQ$*tm1mI2#05jO!D*9;vXU*;G+kB{FM z2(MS;d-yP*B$B5;n4mwELH1`CXerzOFOQ5BzB)$7S|eBJHD398oIx~BUvKb@(>L<; zt*E!!I}2Km)6x>OzB5+%b|imZ#M7JjKUVlqUkE3?IoX=0f4am!lVCFySLv2UTQ1ub zq{+6Cnq?cL4%yyJx5;)V?UHSb_R97E9hdEKIthal=?DvMN63=uee1Eugg1&nxz9$sFObr}{;gdE0K2G05_#nV) z{u4i~#qYQAgE-66yTzrElPGa{t?*1uP2w;DBr3rjE_T2%cPi*r3$O6G$9oNJJnL)&cya?5b){}X$`LgK9i>Um)H81Xn z`l^G#-tN5U>F`!{`l~wC24AZLVE|m_Oo-mRh+U+6>(zRHUEqJ=eP>fqJ#h`|x8IX+@--2aQhuWpMyQ^=e+czd>pB)Zx0{VF{gTr+=*QR9}M<^^TEU zY@=7`t$3|CJ}&N=3^ynZzQ|>9qE_6C>z7cEl;sbzsX{Pk;>aZ=+O2)OjqL`z)(Qg_ z1$BxQwPF~b5qW>bQ?(-LS~@f?tjTi8FOi?4?RC>{$E%%?L&&WQv+<%@f$v(H-e~~6-pIh#~L|>MDZn^&r z`j+f-%YD2tWuII0g$Hji^kvKaR#fcV=a%~k@tD-p4a(nR&OQ{7OL_2E=Vm2~MJX9`-SZSXeEFD}Wr5B5U8nD2AgzO2JB1RsOKwrp| zQ9+&`08kA}2MBjW_x58D003kkld+T>lN^#k2GZ>UB5A0TW0E6(8Cry3D?8cE>^tXq z&zYQ=@4vr(1F(uEhNHv7=jFF*of~_?ZK&(2v7;7M!*hJg=8@&On&UMD>4C5X4+SkY zd8ippVeEym6RPVw+zv%i^-ay;zGg{}`r6vEv2u@MgYqfA6WcZkVUugi^ebG`a)k&i z*Ch2o1R>=jy5S7#iH!}QhYZxTH; zfMns-7mUt)#@GkQCxdZh+c696m~`P2#*UEuh^vdoxGn=3N-fKu7$IgJH`>f0jOW@)apC{$*=G>ee9MUBECT_(bLGC{d=W$O5BA+*CG&toqYxu>cf;eT{G zmd6vy+Td?~QEE-VCBhq%MH4H7XqAbHuF*Pri+C_P83kU1YyR8@#-Q_%l~&@l(#YU2 zv#}pr5oz=vt;ln<{+%e2OXn~RHQE-`8SF2`TKHO+*uM>zD2o;}88pw8QN;y=gZ|A= zKxKZl_3XbJ%o)`BgLxO)(CI)6b}JavujmWVg9h2E7@an3Q{N@mBdw7(j^3dA`WvXg z7Sz50P)i30wv8}qB$F(bZhyw07(zm%7mU!0EmFY-s053t7o1E^l7Y$0cxDF5QoGs* ze?FeAo#wKHWDVB`scGWRV%`6ka_CpAaLCx8|(D`k{^O%VU6paf`3kiGiC1Owp@=_o1P38;@QC3u+tJ|YGmi=dxn{w*PJPaNUL6f z%Ft=JJ88AYNA5=uL6?d!PBQd0eWz{Hq{vj8tDu`9#H)_CMTiWir-a~Dn2w_fQO4?ne3_P1UKny)>yCWsr>$ssp!G{cCcb`*ZA>2B^ zz8!M~9}%5hPZOTIVt5teN&G0LWYTSXtYQYU46nIzU;&F#ahJ|zc>}}oqvamkfhFYRwJeh(k$@p{jDO?*gt~_nNrcZCPWcvX0;6PT z1(OE@5RD(=|IvB4k1ymrd`V-wPt3)c2Re7;NGbSwPZ302t_XWm!YlZO;e1oEhdy>V&jEgp`*RpA(Fk1&q4Y0z7|d2h1&2Ym zBKMRLH%sQ7i55~3>qh+&CiB4v*$emA_MLdUm6_G#L`G+;T8Ry=ieS=!Kb zWNG~__|*azfrR$u31YJR5$zD7hry-87&=J<{G6!a)Ke%g(D!^B{rP;hj@P#_n4cd_ z<`Z>9Yk0eccegQ;zf%VpkG;fYhWX@6e8BJolYjJajUm5K!_A)Q8s?rf{!Gz#cesZ6 z{A5QBpZ?VNBQel1O483rQA2*^S>w0F3w-rF`wXEZp}*ROp5F$~CsupPb*$B3)nJd- zAzo3Ey+qpYv5EmigLf1|ctoiWVK_KH!jHkb4IW8vqBGo}71XX^L_xnoGmpP;qk#@E zg*FyB{jE08F7;vR%%Bu#QrkuX(h-DD&q*>NV+zrR$Mj7@L((?1{{v7<2MCx5wahXE z003qOld+T>ldM=5lMS*5ld!QIe|?i}PZL29$7i9?QjgLW5Tq({h<$)kd8!o<5I&`4U3olI-5(y4J=w=LBgVc<)|asxl1yaZleds8BT=y%)$ks6ExxR&N2B4jp6jbc(_sh9 z4rZj?Pbg;RNJ?t!IJR!jbB3g2DKPhz{;QPuS`beW#_|@H;RoIToPvs!37HnTuc7*bbF?p8Ej z|DSGYSHxWG$)+u@Kn%I-j%U|_d)rIV4%5#e2;3xkP5tu1jUKlh!LqBbVBmM$8sQ1ciJR)>>b3)iFiRH#9V0Z;H)Ho-HKqic&RFLetz44{Td1k9%9!Rl~;JEI_ zJfFWZg+JoVTYXvyUY2GKhz>JxGt6nW9|i7eWDFrc7 z(0z2dO3qF2_P!(7HiVqCty7<5J;&!cUkf9iyK(~BSYKyWO~HWqOCfRT`BIEhbDBr` z%Y7PAb4{6XxtvFR)e0{u5@rO(!o3rV$4Rn6>@nb4YZC8b01i@Kx4FJDPUL;@9w$Zk*f0FD*UDM~^&^&f%%VUH zjzXfIyyum~rCq{X38Q7D5?o^4bi!qd=*S!TP!=SSicI9@ccBlZpP!(d`?s!<=`Y=Qz*Zg5QgZHT zX24A(6YHHZ_XhHV4kzQ6F%Al<4k25sww8-w1jT8=^B0^ZpY_@ATGl)cTexKXQxvO< zpWD$&oD%P;A~xt(%tL^ z<5u8BJ{;SD7^Qx1m@I#@MxWGBC6S353xMkVP7_JAWje!B3D z{`iB>Bu6#%#6gH!@u}SpK8?{(Wlxf%LN$6(7K1&U)NM0_jmBHP3x$?n(>Sxr#?baAQ<2DWM=?GB3t_!o?Y*u&!nPDJ8Y8ddl=|H;;w_ z)Juc?UYF%HhaiQIyN6DdP7UR<=?dQ?9;`+;hirfg`P$E662#}bL%m_d2LoFIrrFkA zaBnOko@Zc7Y!{zwh`8r67?jh=$dbUVYo8G7|#9wDElc=yiyK|$y}cVkf@ z?T+TomsgVI6&2nL%W$JM!i~IB-ufI}$6nDntDC4?$^EDu{ejN!2IsDtp&s(68rddq zM#eR6!i?eK1syI{6P|?S#5_V#!KC4sSeaFb`TSBn3kEtVZNSs8Iw^s=ocVc4YQ(0R zebf8t*x98@o9cvU|KKW)v?_)asBg2yAPIG$VEAffo^SG3%#x6h*W8_4Q}L|h7V;wg z^f76pw)W2NSlp$f+=~l(koj1^aUfh4*$cB5diRa0HtM!D5|$6}7CvO?GifLm2c8ys zL7944-4iK)KjRd&MJW(Ph3L;O3os}$f{ko{Ai7fUddkX7l?KQ00ER^{AcBtx=-`0@ zR#lt~so71ew!m5u1bl+;Hz>ac!1k?>K_Fe4EIdMgvg8)4!~PiCQZ9#}A-;hBA&Q7e z>}7@Sxq}W<+IF1bzggn}&k`pFsxKwbRssPJOaBSpbEf=RA_vER-5CP`w`j6#@jDt^+KViUH>dl2EF+J*A+A z{~Ij}pp_K5&TuRx2RjXU@L?QR+ZZ&yNAtl@RblGzAa_X3?B` z0QBFdnP^jY1H?*m*#5R62qa2#>C^~HA{by;B?8;qIC7!P7iY?Nh|rKw$<$`3ru>>* z)GZUr%)44G9ENqRAGKMkSe4tHJiylmG1!{!A+A*GrWG!>^~o TbTtHgKIb=}#OPPBcmMwnM9LS( diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e1113280ef1..bad7c2462f5a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index a1fe51814259..eec79f920458 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -54,30 +54,27 @@ tasks.generateDevelopmentBundle { } abstract class Services { - @get:Inject - abstract val softwareComponentFactory: SoftwareComponentFactory - @get:Inject abstract val archiveOperations: ArchiveOperations } val services = objects.newInstance() if (project.providers.gradleProperty("publishDevBundle").isPresent) { - val devBundleComponent = services.softwareComponentFactory.adhoc("devBundle") + val devBundleComponent = publishing.softwareComponentFactory.adhoc("devBundle") components.add(devBundleComponent) val devBundle = configurations.consumable("devBundle") { attributes.attribute(DevBundleOutput.ATTRIBUTE, objects.named(DevBundleOutput.ZIP)) outgoing.artifact(tasks.generateDevelopmentBundle.flatMap { it.devBundleFile }) } - devBundleComponent.addVariantsFromConfiguration(devBundle.get()) {} + devBundleComponent.addVariantsFromConfiguration(devBundle) {} val runtime = configurations.consumable("serverRuntimeClasspath") { attributes.attribute(DevBundleOutput.ATTRIBUTE, objects.named(DevBundleOutput.SERVER_DEPENDENCIES)) attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME)) extendsFrom(configurations.runtimeClasspath.get()) } - devBundleComponent.addVariantsFromConfiguration(runtime.get()) { + devBundleComponent.addVariantsFromConfiguration(runtime) { mapToMavenScope("runtime") } @@ -86,7 +83,7 @@ if (project.providers.gradleProperty("publishDevBundle").isPresent) { attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_API)) extendsFrom(configurations.compileClasspath.get()) } - devBundleComponent.addVariantsFromConfiguration(compile.get()) { + devBundleComponent.addVariantsFromConfiguration(compile) { mapToMavenScope("compile") } From 77007167c21d8fd67c50937d0eca5acb42964d3f Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 3 Nov 2025 10:51:23 -0700 Subject: [PATCH 036/112] 25w44a init server/notifications world/entity server/level level/block GameRules MinecraftGameRuleServiceImpl DispenseItemBehavior GameRuleCommand EnderDragon ServerStatsCounter PlayerList DedicatedServer Connection Llama HopperBlockEntity TestEnvironmentDefinition EatBlockGoal MinecraftServer JsonRpcNotificationService PathNavigation LargeFireball AbstractNautilus, ServerGamePacketListenerImpl Start fixing type annotation issues Misc compile fixes --- gradle.properties | 4 +- paper-server/build.gradle.kts | 4 +- .../mojang/math/OctahedralGroup.java.patch | 6 +- .../net/minecraft/ChatFormatting.java.patch | 6 +- .../net/minecraft/CrashReport.java.patch | 4 +- .../sources/net/minecraft/Util.java.patch | 98 +++++- .../advancements/AdvancementTree.java.patch | 4 +- .../commands/CommandSourceStack.java.patch | 20 +- .../minecraft/commands/Commands.java.patch | 25 +- .../blocks/BlockStateParser.java.patch | 2 +- .../selector/EntitySelector.java.patch | 2 +- .../selector/EntitySelectorParser.java.patch | 8 +- .../net/minecraft/core/Holder.java.patch | 2 +- .../minecraft/core/MappedRegistry.java.patch | 11 +- .../component/DataComponentPatch.java.patch | 2 +- .../dispenser/DispenseItemBehavior.java.patch | 98 +++--- .../registries/BuiltInRegistries.java.patch | 10 +- .../framework/GameTestInfo.java.patch | 2 +- .../framework/GameTestMainUtil.java.patch | 2 +- .../framework/GameTestServer.java.patch | 8 +- .../TestEnvironmentDefinition.java.patch | 34 +- .../net/minecraft/nbt/CompoundTag.java.patch | 4 +- .../net/minecraft/nbt/NbtIo.java.patch | 2 +- .../net/minecraft/nbt/SnbtGrammar.java.patch | 4 +- .../minecraft/network/Connection.java.patch | 46 +-- .../network/FriendlyByteBuf.java.patch | 4 +- .../network/Varint21FrameDecoder.java.patch | 2 +- .../network/chat/ChatDecorator.java.patch | 2 +- .../network/chat/Component.java.patch | 2 +- .../network/chat/MessageSignature.java.patch | 2 +- .../network/chat/MutableComponent.java.patch | 2 +- .../network/chat/PlayerChatMessage.java.patch | 2 +- .../chat/SignedMessageChain.java.patch | 4 +- .../network/chat/TextColor.java.patch | 5 +- .../chat/contents/NbtContents.java.patch | 4 +- .../contents/TranslatableContents.java.patch | 4 +- ...ClientboundLevelChunkPacketData.java.patch | 2 +- ...ientboundPlayerInfoUpdatePacket.java.patch | 2 +- .../ClientboundSetPlayerTeamPacket.java.patch | 2 +- .../game/ServerboundInteractPacket.java.patch | 2 +- .../syncher/SynchedEntityData.java.patch | 2 +- .../resources/ResourceLocation.java.patch | 4 +- .../net/minecraft/server/Main.java.patch | 22 +- .../server/MinecraftServer.java.patch | 171 ++++++---- .../server/PlayerAdvancements.java.patch | 16 +- .../net/minecraft/server/Services.java.patch | 2 +- .../commands/GameRuleCommand.java.patch | 27 +- .../dedicated/DedicatedServer.java.patch | 47 ++- .../DedicatedServerProperties.java.patch | 8 +- .../server/dedicated/Settings.java.patch | 20 +- .../server/gui/StatsComponent.java.patch | 4 +- .../JsonRpcNotificationService.java.patch | 6 +- .../MinecraftGameRuleServiceImpl.java.patch | 29 +- .../server/level/ChunkHolder.java.patch | 14 +- .../server/level/ChunkLevel.java.patch | 2 +- .../server/level/ChunkMap.java.patch | 50 +-- .../server/level/DistanceManager.java.patch | 4 +- .../server/level/PlayerSpawnFinder.java.patch | 2 +- .../server/level/ServerChunkCache.java.patch | 44 +-- .../server/level/ServerEntity.java.patch | 19 +- .../server/level/ServerLevel.java.patch | 142 ++++---- .../server/level/ServerPlayer.java.patch | 183 +++++----- .../level/ServerPlayerGameMode.java.patch | 33 +- .../server/level/TicketType.java.patch | 2 +- .../server/level/WorldGenRegion.java.patch | 16 +- .../network/EventLoopGroupHolder.java.patch | 11 +- ...ConfigurationPacketListenerImpl.java.patch | 20 +- .../ServerGamePacketListenerImpl.java.patch | 167 +++++----- .../ServerLoginPacketListenerImpl.java.patch | 40 +-- .../config/PrepareSpawnTask.java.patch | 17 +- .../EmptyNotificationService.java.patch | 4 +- .../NotificationManager.java.patch | 8 +- .../NotificationService.java.patch | 4 +- .../server/packs/PathPackResources.java.patch | 2 +- .../repository/ServerPacksSource.java.patch | 6 +- .../server/players/BanListEntry.java.patch | 4 +- .../server/players/NameAndId.java.patch | 2 +- .../players/OldUsersConverter.java.patch | 2 +- .../server/players/PlayerList.java.patch | 112 +++---- .../server/players/StoredUserList.java.patch | 14 +- .../rcon/thread/QueryThreadGs4.java.patch | 4 +- .../server/rcon/thread/RconThread.java.patch | 8 +- .../stats/ServerStatsCounter.java.patch | 12 +- .../net/minecraft/tags/TagLoader.java.patch | 10 +- .../util/datafix/DataFixers.java.patch | 2 +- .../util/parsing/packrat/Scope.java.patch | 2 +- .../util/random/WeightedList.java.patch | 29 +- .../util/worldupdate/WorldUpgrader.java.patch | 2 +- .../net/minecraft/world/Container.java.patch | 4 +- .../world/InteractionResult.java.patch | 2 +- .../world/RandomizableContainer.java.patch | 11 +- .../world/SimpleContainer.java.patch | 16 +- .../damagesource/CombatTracker.java.patch | 2 +- .../damagesource/DamageSource.java.patch | 28 +- .../world/effect/MobEffect.java.patch | 2 +- .../world/effect/MobEffectInstance.java.patch | 6 +- .../world/effect/MobEffectUtil.java.patch | 2 +- .../world/effect/WeavingMobEffect.java.patch | 2 +- .../world/entity/AgeableMob.java.patch | 8 +- .../world/entity/AreaEffectCloud.java.patch | 12 +- .../minecraft/world/entity/Entity.java.patch | 234 +++++++------ .../world/entity/EntityReference.java.patch | 2 +- .../world/entity/EntityType.java.patch | 22 +- .../world/entity/ExperienceOrb.java.patch | 34 +- .../world/entity/Interaction.java.patch | 2 +- .../world/entity/Leashable.java.patch | 20 +- .../world/entity/LightningBolt.java.patch | 77 +++-- .../world/entity/LivingEntity.java.patch | 162 +++++---- .../net/minecraft/world/entity/Mob.java.patch | 69 ++-- .../world/entity/NeutralMob.java.patch | 11 +- .../world/entity/TamableAnimal.java.patch | 6 +- .../attributes/AttributeInstance.java.patch | 2 +- .../ai/attributes/AttributeMap.java.patch | 2 +- .../ai/behavior/HarvestFarmland.java.patch | 4 +- ...TransportItemsBetweenContainers.java.patch | 2 +- .../entity/ai/goal/EatBlockGoal.java.patch | 8 +- .../entity/ai/goal/FollowOwnerGoal.java.patch | 2 +- .../entity/ai/goal/RemoveBlockGoal.java.patch | 8 +- .../world/entity/ai/goal/SwellGoal.java.patch | 2 +- .../world/entity/ai/goal/TemptGoal.java.patch | 14 +- .../target/DefendVillageTargetGoal.java.patch | 2 +- .../goal/target/HurtByTargetGoal.java.patch | 4 +- .../NearestAttackableTargetGoal.java.patch | 2 +- .../ai/goal/target/TargetGoal.java.patch | 4 +- .../ai/navigation/PathNavigation.java.patch | 37 +-- .../WallClimberNavigation.java.patch | 2 +- .../ai/sensing/TemptingSensor.java.patch | 2 +- .../world/entity/ambient/Bat.java.patch | 8 +- .../animal/AbstractSchoolingFish.java.patch | 2 +- .../world/entity/animal/Animal.java.patch | 18 +- .../world/entity/animal/Bee.java.patch | 20 +- .../world/entity/animal/Cat.java.patch | 16 +- .../world/entity/animal/Dolphin.java.patch | 12 +- .../world/entity/animal/Fox.java.patch | 26 +- .../world/entity/animal/HappyGhast.java.patch | 4 +- .../world/entity/animal/IronGolem.java.patch | 4 +- .../entity/animal/MushroomCow.java.patch | 4 +- .../world/entity/animal/Ocelot.java.patch | 4 +- .../world/entity/animal/Panda.java.patch | 12 +- .../world/entity/animal/Parrot.java.patch | 4 +- .../world/entity/animal/Pig.java.patch | 2 +- .../world/entity/animal/Rabbit.java.patch | 2 +- .../world/entity/animal/SnowGolem.java.patch | 2 +- .../world/entity/animal/Turtle.java.patch | 16 +- .../entity/animal/allay/Allay.java.patch | 14 +- .../animal/armadillo/Armadillo.java.patch | 8 +- .../entity/animal/axolotl/Axolotl.java.patch | 4 +- .../entity/animal/camel/Camel.java.patch | 14 +- .../animal/coppergolem/CopperGolem.java.patch | 20 +- .../world/entity/animal/frog/Frog.java.patch | 2 +- .../entity/animal/frog/Tadpole.java.patch | 8 +- .../world/entity/animal/goat/Goat.java.patch | 6 +- .../horse/AbstractChestedHorse.java.patch | 2 +- .../animal/horse/AbstractHorse.java.patch | 26 +- .../entity/animal/horse/Llama.java.patch | 16 +- .../animal/horse/TraderLlama.java.patch | 4 +- .../nautilus/AbstractNautilus.java.patch | 6 +- .../animal/nautilus/Nautilus.java.patch | 4 +- .../entity/animal/sheep/Sheep.java.patch | 2 +- .../world/entity/animal/wolf/Wolf.java.patch | 14 +- .../boss/enderdragon/EnderDragon.java.patch | 42 +-- .../phases/DragonDeathPhase.java.patch | 2 +- .../DragonHoldingPatternPhase.java.patch | 2 +- .../DragonLandingApproachPhase.java.patch | 2 +- .../phases/DragonLandingPhase.java.patch | 2 +- .../DragonSittingFlamingPhase.java.patch | 4 +- .../phases/DragonStrafePlayerPhase.java.patch | 2 +- .../phases/DragonTakeoffPhase.java.patch | 2 +- .../entity/boss/wither/WitherBoss.java.patch | 2 +- .../entity/decoration/ArmorStand.java.patch | 4 +- .../entity/decoration/ItemFrame.java.patch | 17 +- .../LeashFenceKnotEntity.java.patch | 2 +- .../entity/decoration/Painting.java.patch | 2 +- .../entity/item/FallingBlockEntity.java.patch | 28 +- .../world/entity/item/ItemEntity.java.patch | 34 +- .../world/entity/item/PrimedTnt.java.patch | 18 +- .../monster/AbstractSkeleton.java.patch | 12 +- .../world/entity/monster/Bogged.java.patch | 4 +- .../world/entity/monster/Creeper.java.patch | 2 +- .../world/entity/monster/Drowned.java.patch | 2 +- .../world/entity/monster/EnderMan.java.patch | 22 +- .../world/entity/monster/Evoker.java.patch | 2 +- .../world/entity/monster/Guardian.java.patch | 8 +- .../world/entity/monster/Husk.java.patch | 2 +- .../entity/monster/Illusioner.java.patch | 2 +- .../world/entity/monster/Phantom.java.patch | 17 +- .../world/entity/monster/Pillager.java.patch | 2 +- .../world/entity/monster/Ravager.java.patch | 4 +- .../world/entity/monster/Shulker.java.patch | 6 +- .../entity/monster/Silverfish.java.patch | 10 +- .../world/entity/monster/Slime.java.patch | 18 +- .../world/entity/monster/Spider.java.patch | 2 +- .../world/entity/monster/Strider.java.patch | 2 +- .../world/entity/monster/Vex.java.patch | 4 +- .../entity/monster/Vindicator.java.patch | 2 +- .../entity/monster/WitherSkeleton.java.patch | 4 +- .../world/entity/monster/Zombie.java.patch | 4 +- .../entity/monster/ZombieVillager.java.patch | 6 +- .../entity/monster/ZombifiedPiglin.java.patch | 10 +- .../monster/creaking/Creaking.java.patch | 2 +- .../entity/monster/hoglin/Hoglin.java.patch | 2 +- .../entity/monster/piglin/Piglin.java.patch | 6 +- .../entity/monster/piglin/PiglinAi.java.patch | 2 +- .../entity/monster/warden/Warden.java.patch | 4 +- .../entity/npc/AbstractVillager.java.patch | 16 +- .../world/entity/npc/Villager.java.patch | 26 +- .../entity/npc/VillagerTrades.java.patch | 6 +- .../entity/npc/WanderingTrader.java.patch | 14 +- .../npc/WanderingTraderSpawner.java.patch | 2 +- .../world/entity/player/Player.java.patch | 66 ++-- .../projectile/AbstractArrow.java.patch | 30 +- .../entity/projectile/EvokerFangs.java.patch | 4 +- .../entity/projectile/EyeOfEnder.java.patch | 6 +- .../FireworkRocketEntity.java.patch | 20 +- .../entity/projectile/FishingHook.java.patch | 30 +- .../projectile/LargeFireball.java.patch | 13 +- .../entity/projectile/Projectile.java.patch | 28 +- .../projectile/ShulkerBullet.java.patch | 14 +- .../projectile/SmallFireball.java.patch | 4 +- .../projectile/ThrownEnderpearl.java.patch | 16 +- .../projectile/ThrownTrident.java.patch | 12 +- .../windcharge/AbstractWindCharge.java.patch | 2 +- .../world/entity/raid/Raid.java.patch | 4 +- .../world/entity/raid/Raider.java.patch | 10 +- .../world/entity/raid/Raids.java.patch | 2 +- .../entity/vehicle/AbstractBoat.java.patch | 16 +- .../vehicle/AbstractChestBoat.java.patch | 16 +- .../vehicle/AbstractMinecart.java.patch | 14 +- .../AbstractMinecartContainer.java.patch | 15 +- .../entity/vehicle/ContainerEntity.java.patch | 8 +- .../entity/vehicle/MinecartTNT.java.patch | 10 +- .../vehicle/NewMinecartBehavior.java.patch | 12 +- .../vehicle/OldMinecartBehavior.java.patch | 6 +- .../minecraft/world/food/FoodData.java.patch | 6 +- .../AbstractContainerMenu.java.patch | 35 +- .../world/inventory/AnvilMenu.java.patch | 24 +- .../world/inventory/BeaconMenu.java.patch | 10 +- .../world/inventory/CraftingMenu.java.patch | 2 +- .../inventory/MerchantContainer.java.patch | 4 +- .../PlayerEnderChestContainer.java.patch | 8 +- .../inventory/ResultContainer.java.patch | 14 +- .../minecraft/world/item/BlockItem.java.patch | 4 +- .../world/item/BucketItem.java.patch | 2 +- .../world/item/EnderEyeItem.java.patch | 2 +- .../minecraft/world/item/ItemStack.java.patch | 24 +- .../minecraft/world/item/MapItem.java.patch | 4 +- .../minecraft/world/item/SignItem.java.patch | 2 +- .../world/item/SpawnEggItem.java.patch | 2 +- .../item/StandingAndWallBlockItem.java.patch | 2 +- .../component/WrittenBookContent.java.patch | 2 +- .../item/crafting/RecipeManager.java.patch | 2 +- .../item/crafting/ShapedRecipe.java.patch | 2 +- .../item/crafting/ShapelessRecipe.java.patch | 2 +- .../SmithingTransformRecipe.java.patch | 10 +- .../crafting/SmithingTrimRecipe.java.patch | 12 +- .../item/crafting/TransmuteRecipe.java.patch | 2 +- .../enchantment/ItemEnchantments.java.patch | 2 +- .../world/item/trading/Merchant.java.patch | 6 +- .../world/level/BaseCommandBlock.java.patch | 14 +- .../world/level/BaseSpawner.java.patch | 14 +- .../world/level/BlockGetter.java.patch | 12 +- .../world/level/ClipContext.java.patch | 2 +- .../level/EmptyBlockAndTintGetter.java.patch | 2 +- .../world/level/EmptyBlockGetter.java.patch | 2 +- .../world/level/EntityGetter.java.patch | 14 +- .../world/level/GameRules.java.patch | 314 ------------------ .../minecraft/world/level/Level.java.patch | 36 +- .../world/level/LevelAccessor.java.patch | 2 +- .../world/level/LevelReader.java.patch | 6 +- .../world/level/LevelWriter.java.patch | 2 +- .../world/level/NaturalSpawner.java.patch | 10 +- .../world/level/ServerExplosion.java.patch | 8 +- .../world/level/StructureManager.java.patch | 2 +- .../world/level/TicketStorage.java.patch | 6 +- .../level/biome/MobSpawnSettings.java.patch | 2 +- .../level/block/BambooStalkBlock.java.patch | 10 +- .../world/level/block/BeaconBlock.java.patch | 2 +- .../world/level/block/BedBlock.java.patch | 6 +- .../level/block/BigDripleafBlock.java.patch | 10 +- .../level/block/BlastFurnaceBlock.java.patch | 2 +- .../world/level/block/Block.java.patch | 22 +- .../level/block/BrewingStandBlock.java.patch | 2 +- .../level/block/CampfireBlock.java.patch | 2 +- .../level/block/CarvedPumpkinBlock.java.patch | 4 +- .../block/CeilingHangingSignBlock.java.patch | 6 +- .../world/level/block/ChestBlock.java.patch | 18 +- .../world/level/block/CocoaBlock.java.patch | 2 +- .../level/block/ComparatorBlock.java.patch | 2 +- .../world/level/block/CrafterBlock.java.patch | 6 +- .../world/level/block/CropBlock.java.patch | 4 +- .../level/block/DecoratedPotBlock.java.patch | 2 +- .../world/level/block/DoorBlock.java.patch | 2 +- .../level/block/DoublePlantBlock.java.patch | 2 +- .../level/block/EndGatewayBlock.java.patch | 4 +- .../level/block/EndPortalBlock.java.patch | 8 +- .../world/level/block/FarmBlock.java.patch | 2 +- .../world/level/block/FireBlock.java.patch | 125 ++++--- .../world/level/block/FurnaceBlock.java.patch | 2 +- .../world/level/block/HopperBlock.java.patch | 4 +- .../block/LayeredCauldronBlock.java.patch | 2 +- .../world/level/block/LecternBlock.java.patch | 2 +- .../world/level/block/LeverBlock.java.patch | 2 +- .../block/MangrovePropaguleBlock.java.patch | 2 +- .../level/block/MultifaceSpreader.java.patch | 4 +- .../level/block/NetherPortalBlock.java.patch | 17 +- .../level/block/PitcherCropBlock.java.patch | 8 +- .../block/PointedDripstoneBlock.java.patch | 4 +- .../level/block/PowderSnowBlock.java.patch | 4 +- .../world/level/block/RailState.java.patch | 6 +- .../level/block/RedstoneLampBlock.java.patch | 4 +- .../level/block/SculkCatalystBlock.java.patch | 2 +- .../level/block/SculkSensorBlock.java.patch | 8 +- .../level/block/SculkShriekerBlock.java.patch | 4 +- .../world/level/block/ShelfBlock.java.patch | 2 +- .../level/block/ShulkerBoxBlock.java.patch | 34 +- .../world/level/block/SignBlock.java.patch | 6 +- .../world/level/block/SmokerBlock.java.patch | 2 +- .../world/level/block/SpawnerBlock.java.patch | 2 +- .../world/level/block/TntBlock.java.patch | 4 +- .../level/block/TripWireHookBlock.java.patch | 6 +- .../world/level/block/VineBlock.java.patch | 2 +- .../block/WallHangingSignBlock.java.patch | 6 +- .../level/block/WitherSkullBlock.java.patch | 6 +- .../AbstractFurnaceBlockEntity.java.patch | 4 +- .../block/entity/BannerBlockEntity.java.patch | 10 +- .../BaseContainerBlockEntity.java.patch | 6 +- .../block/entity/BeaconBlockEntity.java.patch | 32 +- .../entity/BeehiveBlockEntity.java.patch | 8 +- .../level/block/entity/BlockEntity.java.patch | 22 +- .../entity/BrushableBlockEntity.java.patch | 10 +- .../entity/ConduitBlockEntity.java.patch | 4 +- .../entity/DecoratedPotBlockEntity.java.patch | 8 +- .../block/entity/HopperBlockEntity.java.patch | 17 +- .../entity/LecternBlockEntity.java.patch | 2 +- ...andomizableContainerBlockEntity.java.patch | 2 +- .../SculkShriekerBlockEntity.java.patch | 8 +- .../entity/ShulkerBoxBlockEntity.java.patch | 10 +- .../block/entity/SignBlockEntity.java.patch | 16 +- .../TheEndGatewayBlockEntity.java.patch | 6 +- .../trialspawner/TrialSpawner.java.patch | 6 +- .../TrialSpawnerStateData.java.patch | 2 +- .../entity/vault/VaultBlockEntity.java.patch | 8 +- .../level/block/grower/TreeGrower.java.patch | 6 +- .../block/state/BlockBehaviour.java.patch | 23 +- .../state/properties/Property.java.patch | 2 +- .../world/level/chunk/ChunkAccess.java.patch | 22 +- .../level/chunk/ChunkGenerator.java.patch | 16 +- .../ChunkGeneratorStructureState.java.patch | 2 +- .../level/chunk/EmptyLevelChunk.java.patch | 4 +- .../level/chunk/ImposterProtoChunk.java.patch | 2 +- .../world/level/chunk/LevelChunk.java.patch | 37 +-- .../world/level/chunk/ProtoChunk.java.patch | 2 +- .../level/chunk/storage/RegionFile.java.patch | 6 +- .../storage/RegionFileStorage.java.patch | 10 +- .../storage/RegionFileVersion.java.patch | 2 +- .../storage/SerializableChunkData.java.patch | 27 +- .../storage/SimpleRegionStorage.java.patch | 2 +- .../dimension/end/EndDragonFight.java.patch | 22 +- .../DynamicGameEventListener.java.patch | 2 +- .../vibrations/VibrationSystem.java.patch | 2 +- .../level/gamerules/GameRules.java.patch | 69 ++++ .../level/levelgen/PatrolSpawner.java.patch | 2 +- .../level/levelgen/PhantomSpawner.java.patch | 2 +- .../LegacyStructureDataHandler.java.patch | 14 +- .../structure/StructurePiece.java.patch | 8 +- .../structure/StructureStart.java.patch | 10 +- .../structures/MineshaftPieces.java.patch | 2 +- .../NetherFortressPieces.java.patch | 2 +- .../StructurePlaceSettings.java.patch | 8 +- .../StructureTemplate.java.patch | 4 +- .../world/level/material/LavaFluid.java.patch | 52 +-- .../level/material/WaterFluid.java.patch | 6 +- .../pathfinder/WalkNodeEvaluator.java.patch | 2 +- .../world/level/portal/PortalShape.java.patch | 21 +- .../CollectingNeighborUpdater.java.patch | 2 +- .../maps/MapItemSavedData.java.patch | 18 +- .../storage/DimensionDataStorage.java.patch | 4 +- .../storage/LevelStorageSource.java.patch | 6 +- .../level/storage/PrimaryLevelData.java.patch | 20 +- .../world/scores/Scoreboard.java.patch | 2 +- .../paper/adventure/PaperAdventure.java | 4 +- .../paper/configuration/Configurations.java | 2 +- .../configuration/PaperConfigurations.java | 2 +- .../flag/PaperFeatureFlagProviderImpl.java | 2 +- .../craftbukkit/CraftOfflinePlayer.java | 2 +- .../org/bukkit/craftbukkit/CraftServer.java | 4 +- .../org/bukkit/craftbukkit/CraftWorld.java | 8 +- .../craftbukkit/entity/CraftEntity.java | 2 +- .../craftbukkit/event/CraftEventFactory.java | 2 +- .../craftbukkit/inventory/CraftMetaSkull.java | 2 +- .../util/DelegatedGeneratorAccess.java | 2 +- todo-snapshot.txt | 3 + 392 files changed, 2581 insertions(+), 2786 deletions(-) delete mode 100644 paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/gamerules/GameRules.java.patch diff --git a/gradle.properties b/gradle.properties index ece9e4f6128c..b16462300185 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group=io.papermc.paper -version=25w43a-R0.1-SNAPSHOT -mcVersion=25w43a +version=25w44a-R0.1-SNAPSHOT +mcVersion=25w44a # This is the current API version for use in (paper-)plugin.yml files # During snapshot cycles this should be the anticipated version of the release target apiVersion=1.21.11 diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index eec79f920458..bb47232fb24d 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:25w43a+build.6") + mache("io.papermc:mache:25w44a+build.2") paperclip("io.papermc:paperclip:3.0.3") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } @@ -42,7 +42,7 @@ paperweight { ) updatingMinecraft { - //oldPaperCommit = "474d54da728306598f93b4a779578eee5cf54423" + // oldPaperCommit = "1eb13b0290e7617407e6bde0e59570ebde61d2ed" } } diff --git a/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch b/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch index 59bb0cf429e6..d88e9f4da8a0 100644 --- a/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch +++ b/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/math/OctahedralGroup.java +++ b/com/mojang/math/OctahedralGroup.java -@@ -116,6 +_,12 @@ +@@ -115,6 +_,12 @@ } ); @@ -13,7 +13,7 @@ private OctahedralGroup(final String name, final SymmetricGroup3 permutation, final boolean invertX, final boolean invertY, final boolean invertZ) { this.name = name; this.invertX = invertX; -@@ -156,7 +_,7 @@ +@@ -155,7 +_,7 @@ return this.name; } @@ -22,7 +22,7 @@ if (this.rotatedDirections == null) { this.rotatedDirections = Util.makeEnumMap(Direction.class, direction1 -> { Direction.Axis axis = direction1.getAxis(); -@@ -167,6 +_,11 @@ +@@ -166,6 +_,11 @@ }); } diff --git a/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch b/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch index a2a9d43baa0f..eb3d87a70583 100644 --- a/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch +++ b/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/ChatFormatting.java +++ b/net/minecraft/ChatFormatting.java -@@ -118,6 +_,19 @@ +@@ -114,6 +_,19 @@ return friendlyName == null ? null : FORMATTING_BY_NAME.get(cleanName(friendlyName)); } @@ -17,6 +17,6 @@ + } + // Paper end - add method to get by hex value + - @Nullable - public static ChatFormatting getById(int index) { + public static @Nullable ChatFormatting getById(int index) { if (index < 0) { + return RESET; diff --git a/paper-server/patches/sources/net/minecraft/CrashReport.java.patch b/paper-server/patches/sources/net/minecraft/CrashReport.java.patch index d9c00ba98178..9ac4c79d30ac 100644 --- a/paper-server/patches/sources/net/minecraft/CrashReport.java.patch +++ b/paper-server/patches/sources/net/minecraft/CrashReport.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/CrashReport.java +++ b/net/minecraft/CrashReport.java -@@ -32,8 +_,10 @@ +@@ -31,8 +_,10 @@ private final SystemReport systemReport = new SystemReport(); public CrashReport(String title, Throwable exception) { @@ -11,7 +11,7 @@ } public String getTitle() { -@@ -218,7 +_,7 @@ +@@ -216,7 +_,7 @@ } public static void preload() { diff --git a/paper-server/patches/sources/net/minecraft/Util.java.patch b/paper-server/patches/sources/net/minecraft/Util.java.patch index 32f814b74c27..3c2c1f2231d0 100644 --- a/paper-server/patches/sources/net/minecraft/Util.java.patch +++ b/paper-server/patches/sources/net/minecraft/Util.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/Util.java +++ b/net/minecraft/Util.java -@@ -89,9 +_,25 @@ +@@ -90,9 +_,25 @@ private static final int DEFAULT_MAX_THREADS = 255; private static final int DEFAULT_SAFE_FILE_OPERATION_RETRIES = 10; private static final String MAX_THREADS_SYSTEM_PROPERTY = "max.bg.threads"; @@ -28,7 +28,7 @@ private static final DateTimeFormatter FILENAME_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss", Locale.ROOT); public static final int LINEAR_LOOKUP_THRESHOLD = 8; private static final Set ALLOWED_UNTRUSTED_LINK_PROTOCOLS = Set.of("http", "https"); -@@ -110,6 +_,7 @@ +@@ -111,6 +_,7 @@ .findFirst() .orElseThrow(() -> new IllegalStateException("No jar file system provider found")); private static Consumer thePauser = string -> {}; @@ -36,7 +36,7 @@ public static Collector, ?, Map> toMap() { return Collectors.toMap(Entry::getKey, Entry::getValue); -@@ -132,7 +_,7 @@ +@@ -133,7 +_,7 @@ } public static long getNanos() { @@ -45,7 +45,7 @@ } public static long getEpochMillis() { -@@ -143,9 +_,10 @@ +@@ -144,9 +_,10 @@ return FILENAME_DATE_TIME_FORMATTER.format(ZonedDateTime.now()); } @@ -58,7 +58,7 @@ if (i <= 0) { directExecutorService = MoreExecutors.newDirectExecutorService(); } else { -@@ -170,16 +_,30 @@ +@@ -171,16 +_,30 @@ super.onTermination(throwOnTermination); } }; @@ -91,11 +91,10 @@ } private static int getMaxThreads() { -@@ -229,6 +_,21 @@ - return thread; +@@ -231,6 +_,21 @@ })); } -+ + + // Paper start - Separate dimension data IO pool + private static TracingExecutor makeExtraIoExecutor(String namePrefix) { + AtomicInteger atomicInteger = new AtomicInteger(1); @@ -110,6 +109,87 @@ + })); + } + // Paper end - Separate dimension data IO pool - ++ public static void throwAsRuntime(Throwable throwable) { throw throwable instanceof RuntimeException ? (RuntimeException)throwable : new RuntimeException(throwable); + } +@@ -297,6 +_,19 @@ + return input -> true; + } + ++ @SafeVarargs ++ public static Predicate allOf(Predicate... predicates) { ++ return input -> { ++ for (Predicate predicate : predicates) { ++ if (!predicate.test(input)) { ++ return false; ++ } ++ } ++ ++ return true; ++ }; ++ } ++ + public static Predicate allOf(Predicate predicate) { + return (Predicate)predicate; + } +@@ -325,19 +_,6 @@ + return input -> predicate1.test(input) && predicate2.test(input) && predicate3.test(input) && predicate4.test(input) && predicate5.test(input); + } + +- @SafeVarargs +- public static Predicate allOf(Predicate... predicates) { +- return input -> { +- for (Predicate predicate : predicates) { +- if (!predicate.test(input)) { +- return false; +- } +- } +- +- return true; +- }; +- } +- + public static Predicate allOf(List> predicates) { + return switch (predicates.size()) { + case 0 -> allOf(); +@@ -368,6 +_,19 @@ + return input -> false; + } + ++ @SafeVarargs ++ public static Predicate anyOf(Predicate... predicates) { ++ return input -> { ++ for (Predicate predicate : predicates) { ++ if (predicate.test(input)) { ++ return true; ++ } ++ } ++ ++ return false; ++ }; ++ } ++ + public static Predicate anyOf(Predicate predicate) { + return (Predicate)predicate; + } +@@ -394,19 +_,6 @@ + Predicate predicate5 + ) { + return input -> predicate1.test(input) || predicate2.test(input) || predicate3.test(input) || predicate4.test(input) || predicate5.test(input); +- } +- +- @SafeVarargs +- public static Predicate anyOf(Predicate... predicates) { +- return input -> { +- for (Predicate predicate : predicates) { +- if (predicate.test(input)) { +- return true; +- } +- } +- +- return false; +- }; + } + + public static Predicate anyOf(List> predicates) { diff --git a/paper-server/patches/sources/net/minecraft/advancements/AdvancementTree.java.patch b/paper-server/patches/sources/net/minecraft/advancements/AdvancementTree.java.patch index aeb440896784..6c17a3351155 100644 --- a/paper-server/patches/sources/net/minecraft/advancements/AdvancementTree.java.patch +++ b/paper-server/patches/sources/net/minecraft/advancements/AdvancementTree.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/AdvancementTree.java +++ b/net/minecraft/advancements/AdvancementTree.java -@@ -26,7 +_,7 @@ +@@ -25,7 +_,7 @@ this.remove(advancementNode); } @@ -9,7 +9,7 @@ this.nodes.remove(node.holder().id()); if (node.parent() == null) { this.roots.remove(node); -@@ -62,7 +_,7 @@ +@@ -61,7 +_,7 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch b/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch index 1fbab0cbda5c..4266c14e397a 100644 --- a/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/commands/CommandSourceStack.java +++ b/net/minecraft/commands/CommandSourceStack.java @@ -48,7 +_,7 @@ - import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; -public class CommandSourceStack implements ExecutionCommandSource, SharedSuggestionProvider { +public class CommandSourceStack implements ExecutionCommandSource, SharedSuggestionProvider, io.papermc.paper.command.brigadier.PaperCommandSourceStack { // Paper - Brigadier API public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(Component.translatable("permissions.requires.player")); public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(Component.translatable("permissions.requires.entity")); public final CommandSource source; -@@ -66,6 +_,7 @@ +@@ -65,6 +_,7 @@ private final Vec2 rotation; private final CommandSigningContext signingContext; private final TaskChainer chatMessageChainer; @@ -17,7 +17,7 @@ public CommandSourceStack( CommandSource source, -@@ -191,6 +_,30 @@ +@@ -190,6 +_,30 @@ ); } @@ -48,7 +48,7 @@ public CommandSourceStack withRotation(Vec2 rotation) { return this.rotation.equals(rotation) ? this -@@ -380,6 +_,32 @@ +@@ -379,6 +_,32 @@ return this.permissions; } @@ -81,9 +81,9 @@ public Vec3 getPosition() { return this.worldPosition; } -@@ -485,20 +_,25 @@ +@@ -482,20 +_,25 @@ GameRules gameRules = this.level.getGameRules(); - if (gameRules.getBoolean(GameRules.RULE_SENDCOMMANDFEEDBACK)) { + if (gameRules.get(GameRules.SEND_COMMAND_FEEDBACK)) { for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) { - if (serverPlayer.commandSource() != this.source && this.server.getPlayerList().isOp(serverPlayer.nameAndId())) { + if (serverPlayer.commandSource() != this.source && serverPlayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit @@ -92,8 +92,8 @@ } } -- if (this.source != this.server && gameRules.getBoolean(GameRules.RULE_LOGADMINCOMMANDS)) { -+ if (this.source != this.server && gameRules.getBoolean(GameRules.RULE_LOGADMINCOMMANDS) && !org.spigotmc.SpigotConfig.silentCommandBlocks) { // Spigot +- if (this.source != this.server && gameRules.get(GameRules.LOG_ADMIN_COMMANDS)) { ++ if (this.source != this.server && gameRules.get(GameRules.LOG_ADMIN_COMMANDS) && !org.spigotmc.SpigotConfig.silentCommandBlocks) { // Spigot this.server.sendSystemMessage(component); } } @@ -110,7 +110,7 @@ } } -@@ -509,7 +_,7 @@ +@@ -506,7 +_,7 @@ @Override public Collection getOnlinePlayerNames() { @@ -119,7 +119,7 @@ } @Override -@@ -589,4 +_,16 @@ +@@ -586,4 +_,16 @@ public boolean isSilent() { return this.silent; } diff --git a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch index dcf528ef8c15..fd41340e2755 100644 --- a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch @@ -6,9 +6,9 @@ public class Commands { + public interface RestrictedMarker { } // Paper - restricted api public static final String COMMAND_PREFIX = "/"; - private static final ThreadLocal> CURRENT_EXECUTION_CONTEXT = new ThreadLocal<>(); + private static final ThreadLocal<@Nullable ExecutionContext> CURRENT_EXECUTION_CONTEXT = new ThreadLocal<>(); private static final Logger LOGGER = LogUtils.getLogger(); -@@ -180,6 +_,7 @@ +@@ -179,6 +_,7 @@ @Override public boolean isRestricted(CommandNode node) { @@ -16,7 +16,7 @@ Predicate requirement = node.getRequirement(); return !requirement.test(this.noPermissionSource); } -@@ -187,6 +_,11 @@ +@@ -186,6 +_,11 @@ private final CommandDispatcher dispatcher = new CommandDispatcher<>(); public Commands(Commands.CommandSelection selection, CommandBuildContext context) { @@ -28,7 +28,7 @@ AdvancementCommands.register(this.dispatcher); AttributeCommand.register(this.dispatcher, context); ExecuteCommand.register(this.dispatcher, context); -@@ -297,6 +_,42 @@ +@@ -296,6 +_,42 @@ PublishCommand.register(this.dispatcher); } @@ -71,7 +71,7 @@ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -316,6 +_,13 @@ +@@ -315,6 +_,13 @@ } public void performCommand(ParseResults parseResults, String command) { @@ -85,7 +85,7 @@ CommandSourceStack commandSourceStack = parseResults.getContext().getSource(); Profiler.get().push(() -> "/" + command); ContextChain contextChain = finishParsing(parseResults, command, commandSourceStack); -@@ -329,10 +_,13 @@ +@@ -328,10 +_,13 @@ ) ); } @@ -102,14 +102,17 @@ StackTraceElement[] stackTrace = var12.getStackTrace(); for (int i = 0; i < Math.min(stackTrace.length, 3); i++) { -@@ -358,13 +_,17 @@ +@@ -356,7 +_,8 @@ + } } - @Nullable -- private static ContextChain finishParsing(ParseResults parseResults, String command, CommandSourceStack source) { -+ private ContextChain finishParsing(ParseResults parseResults, String command, CommandSourceStack source) { +- private static @Nullable ContextChain finishParsing( ++ ++ private ContextChain finishParsing( + ParseResults parseResults, String command, CommandSourceStack source + ) { try { - validateParseResults(parseResults); +@@ -364,7 +_,11 @@ return ContextChain.tryFlatten(parseResults.getContext().build(command)) .orElseThrow(() -> CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().createWithContext(parseResults.getReader())); } catch (CommandSyntaxException var7) { diff --git a/paper-server/patches/sources/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch b/paper-server/patches/sources/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch index 5d7a0a0c8b7a..6b9c60c09010 100644 --- a/paper-server/patches/sources/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch @@ -8,4 +8,4 @@ + private final Map, Comparable> properties = Maps.newLinkedHashMap(); // CraftBukkit - stable private final Map vagueProperties = Maps.newHashMap(); private ResourceLocation id = ResourceLocation.withDefaultNamespace(""); - @Nullable + private @Nullable StateDefinition definition; diff --git a/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelector.java.patch b/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelector.java.patch index c85828a3f37a..936c7f5ec845 100644 --- a/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelector.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelector.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java -@@ -107,7 +_,7 @@ +@@ -103,7 +_,7 @@ } private void checkPermissions(CommandSourceStack source) throws CommandSyntaxException { diff --git a/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch b/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch index c34391be4ca2..f7a84f01766c 100644 --- a/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelectorParser.java +++ b/net/minecraft/commands/arguments/selector/EntitySelectorParser.java -@@ -126,6 +_,11 @@ +@@ -113,6 +_,11 @@ } public static boolean allowSelectors(S suggestionProvider) { @@ -12,7 +12,7 @@ return suggestionProvider instanceof PermissionSetSupplier permissionSetSupplier && permissionSetSupplier.permissions().hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS); } -@@ -208,8 +_,10 @@ +@@ -195,8 +_,10 @@ }; } @@ -25,7 +25,7 @@ this.suggestions = this::suggestSelector; if (!this.reader.canRead()) { throw ERROR_MISSING_SELECTOR_TYPE.createWithContext(this.reader); -@@ -481,6 +_,12 @@ +@@ -458,6 +_,12 @@ } public EntitySelector parse() throws CommandSyntaxException { @@ -38,7 +38,7 @@ this.startPosition = this.reader.getCursor(); this.suggestions = this::suggestNameOrSelector; if (this.reader.canRead() && this.reader.peek() == '@') { -@@ -489,7 +_,7 @@ +@@ -466,7 +_,7 @@ } this.reader.skip(); diff --git a/paper-server/patches/sources/net/minecraft/core/Holder.java.patch b/paper-server/patches/sources/net/minecraft/core/Holder.java.patch index c1d6d57ceb0c..34c31f6e8258 100644 --- a/paper-server/patches/sources/net/minecraft/core/Holder.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/Holder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/Holder.java +++ b/net/minecraft/core/Holder.java -@@ -230,7 +_,7 @@ +@@ -227,7 +_,7 @@ } void bindTags(Collection> tags) { diff --git a/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch b/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch index 941381d50bd2..37e67005c52c 100644 --- a/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java -@@ -32,17 +_,25 @@ +@@ -32,16 +_,24 @@ public class MappedRegistry implements WritableRegistry { private final ResourceKey> key; private final ObjectList> byId = new ObjectArrayList<>(256); @@ -18,8 +18,7 @@ private final Map, HolderSet.Named> frozenTags = new IdentityHashMap<>(); MappedRegistry.TagSet allTags = MappedRegistry.TagSet.unbound(); private boolean frozen; - @Nullable - private Map> unregisteredIntrusiveHolders; + private @Nullable Map> unregisteredIntrusiveHolders; + // Paper start - support pre-filling in registry mod API + private final Map temporaryUnfrozenMap = new HashMap<>(); + @@ -31,7 +30,7 @@ @Override public Stream> listTags() { -@@ -113,6 +_,7 @@ +@@ -112,6 +_,7 @@ this.toId.put(value, size); this.registrationInfos.put(key, registrationInfo); this.registryLifecycle = this.registryLifecycle.add(registrationInfo.lifecycle()); @@ -39,7 +38,7 @@ return reference; } } -@@ -274,6 +_,7 @@ +@@ -268,6 +_,7 @@ return this; } else { this.frozen = true; @@ -47,7 +46,7 @@ this.byValue.forEach((object, reference) -> reference.bindValue((T)object)); List list = this.byKey .entrySet() -@@ -508,4 +_,13 @@ +@@ -502,4 +_,13 @@ Stream> getTags(); } diff --git a/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch b/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch index 855a46776605..52040ac041fe 100644 --- a/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch @@ -44,7 +44,7 @@ } }; } -@@ -249,6 +_,42 @@ +@@ -248,6 +_,42 @@ Builder() { } diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index b104f6654b05..ba660f85657e 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -87,10 +_,38 @@ +@@ -88,10 +_,38 @@ if (type == null) { return item; } else { @@ -40,7 +40,7 @@ null, blockSource.pos().relative(direction), EntitySpawnReason.DISPENSER, -@@ -102,7 +_,8 @@ +@@ -103,7 +_,8 @@ return ItemStack.EMPTY; } @@ -50,7 +50,7 @@ blockSource.level().gameEvent(null, GameEvent.ENTITY_PLACE, blockSource.pos()); return item; } -@@ -121,12 +_,38 @@ +@@ -122,12 +_,38 @@ Direction direction = blockSource.state().getValue(DispenserBlock.FACING); BlockPos blockPos = blockSource.pos().relative(direction); ServerLevel serverLevel = blockSource.level(); @@ -91,45 +91,45 @@ } return item; -@@ -146,8 +_,35 @@ - new AABB(blockPos), - abstractChestedHorse1 -> abstractChestedHorse1.isAlive() && !abstractChestedHorse1.hasChest() +@@ -149,8 +_,35 @@ )) { -- if (abstractChestedHorse.isTamed() && abstractChestedHorse.getSlot(499).set(item)) { -- item.shrink(1); -+ if (abstractChestedHorse.isTamed()/* && abstractChestedHorse.getSlot(499).set(item)*/) { + if (abstractChestedHorse.isTamed()) { + SlotAccess slot = abstractChestedHorse.getSlot(499); +- if (slot != null && slot.set(item)) { +- item.shrink(1); + // CraftBukkit start -+ ItemStack singleCopy = item.copyWithCount(1); -+ ServerLevel world = blockSource.level(); -+ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(world, blockSource.pos()); -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(singleCopy); -+ org.bukkit.event.block.BlockDispenseArmorEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), abstractChestedHorse.getBukkitLivingEntity()); -+ world.getCraftServer().getPluginManager().callEvent(event); ++ if (slot != null/* && slot.set(item)*/) { ++ ItemStack singleCopy = item.copyWithCount(1); ++ ServerLevel world = blockSource.level(); ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(world, blockSource.pos()); ++ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(singleCopy); ++ org.bukkit.event.block.BlockDispenseArmorEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), abstractChestedHorse.getBukkitLivingEntity()); ++ world.getCraftServer().getPluginManager().callEvent(event); + -+ if (event.isCancelled()) { -+ this.setSuccess(false); -+ return item; -+ } -+ -+ boolean shrink = true; -+ if (!event.getItem().equals(craftItem)) { -+ shrink = false; -+ // Chain to handler for new item -+ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); -+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { -+ dispenseBehavior.dispense(blockSource, eventStack); ++ if (event.isCancelled()) { ++ this.setSuccess(false); + return item; + } -+ } -+ abstractChestedHorse.getSlot(499).set(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem())); -+ // CraftBukkit end + -+ if (shrink) item.shrink(1); // Paper - actually handle here - this.setSuccess(true); - return item; - } -@@ -185,8 +_,45 @@ ++ boolean shrink = true; ++ if (!event.getItem().equals(craftItem)) { ++ shrink = false; ++ // Chain to handler for new item ++ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); ++ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); ++ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { ++ dispenseBehavior.dispense(blockSource, eventStack); ++ return item; ++ } ++ } ++ slot.set(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem())); ++ // CraftBukkit end ++ ++ if (shrink) item.shrink(1); // Paper - actually handle here + this.setSuccess(true); + return item; + } +@@ -189,8 +_,45 @@ DispensibleContainerItem dispensibleContainerItem = (DispensibleContainerItem)item.getItem(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); Level level = blockSource.level(); @@ -176,7 +176,7 @@ return this.consumeWithRemainder(blockSource, item, new ItemStack(Items.BUCKET)); } else { return this.defaultDispenseItemBehavior.dispense(blockSource, item); -@@ -209,12 +_,19 @@ +@@ -213,12 +_,19 @@ BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); BlockState blockState = levelAccessor.getBlockState(blockPos); if (blockState.getBlock() instanceof BucketPickup bucketPickup) { @@ -197,7 +197,7 @@ return this.consumeWithRemainder(blockSource, item, new ItemStack(item1)); } } else { -@@ -229,15 +_,26 @@ +@@ -233,15 +_,26 @@ this.setSuccess(true); Direction direction = blockSource.state().getValue(DispenserBlock.FACING); BlockPos blockPos = blockSource.pos().relative(direction); @@ -227,7 +227,7 @@ serverLevel.removeBlock(blockPos, false); } else { this.setSuccess(false); -@@ -259,11 +_,46 @@ +@@ -263,11 +_,46 @@ this.setSuccess(true); Level level = blockSource.level(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); @@ -274,7 +274,7 @@ return item; } -@@ -277,11 +_,36 @@ +@@ -281,11 +_,36 @@ return item; } else { BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); @@ -314,7 +314,7 @@ this.setSuccess(true); return item; } -@@ -295,6 +_,13 @@ +@@ -299,6 +_,13 @@ Level level = blockSource.level(); Direction direction = blockSource.state().getValue(DispenserBlock.FACING); BlockPos blockPos = blockSource.pos().relative(direction); @@ -328,7 +328,7 @@ if (level.isEmptyBlock(blockPos) && WitherSkullBlock.canSpawnMob(level, blockPos, item)) { level.setBlock( blockPos, -@@ -310,7 +_,7 @@ +@@ -314,7 +_,7 @@ item.shrink(1); this.setSuccess(true); } else { @@ -337,7 +337,7 @@ } return item; -@@ -323,6 +_,13 @@ +@@ -327,6 +_,13 @@ Level level = blockSource.level(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); CarvedPumpkinBlock carvedPumpkinBlock = (CarvedPumpkinBlock)Blocks.CARVED_PUMPKIN; @@ -351,7 +351,7 @@ if (level.isEmptyBlock(blockPos) && carvedPumpkinBlock.canSpawnGolem(level, blockPos)) { if (!level.isClientSide()) { level.setBlock(blockPos, carvedPumpkinBlock.defaultBlockState(), Block.UPDATE_ALL); -@@ -332,7 +_,7 @@ +@@ -336,7 +_,7 @@ item.shrink(1); this.setSuccess(true); } else { @@ -360,7 +360,7 @@ } return item; -@@ -358,6 +_,12 @@ +@@ -362,6 +_,12 @@ ServerLevel serverLevel = blockSource.level(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); BlockState blockState = serverLevel.getBlockState(blockPos); @@ -373,7 +373,7 @@ if (blockState.is( BlockTags.BEEHIVES, blockStateBase -> blockStateBase.hasProperty(BeehiveBlock.HONEY_LEVEL) && blockStateBase.getBlock() instanceof BeehiveBlock -@@ -386,6 +_,13 @@ +@@ -390,6 +_,13 @@ this.setSuccess(true); if (blockState.is(Blocks.RESPAWN_ANCHOR)) { if (blockState.getValue(RespawnAnchorBlock.CHARGE) != 4) { @@ -387,7 +387,7 @@ RespawnAnchorBlock.charge(null, level, blockPos, blockState); item.shrink(1); } else { -@@ -409,6 +_,28 @@ +@@ -413,6 +_,28 @@ this.setSuccess(false); return item; } else { @@ -416,7 +416,7 @@ for (Armadillo armadillo : entitiesOfClass) { if (armadillo.brushOffScute(null, item)) { item.hurtAndBreak(16, serverLevel, null, item1 -> {}); -@@ -429,6 +_,13 @@ +@@ -433,6 +_,13 @@ BlockState blockState = level.getBlockState(blockPos); Optional waxed = HoneycombItem.getWaxed(blockState); if (waxed.isPresent()) { @@ -430,7 +430,7 @@ level.setBlockAndUpdate(blockPos, waxed.get()); level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_WAX_ON, blockPos, 0); item.shrink(1); -@@ -456,6 +_,12 @@ +@@ -460,6 +_,12 @@ if (!serverLevel.getBlockState(blockPos1).is(BlockTags.CONVERTABLE_TO_MUD)) { return this.defaultDispenseItemBehavior.dispense(blockSource, item); } else { diff --git a/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch b/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch index 93178427d8bf..253ebe5b2fdf 100644 --- a/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/core/registries/BuiltInRegistries.java +++ b/net/minecraft/core/registries/BuiltInRegistries.java -@@ -352,6 +_,11 @@ - public static final Registry> ATTRIBUTE_TYPE = registerSimple(Registries.ATTRIBUTE_TYPE, AttributeTypes::bootstrap); +@@ -358,6 +_,11 @@ + public static final Registry> SLOT_SOURCE_TYPE = registerSimple(Registries.SLOT_SOURCE_TYPE, SlotSources::bootstrap); public static final Registry> TEST_FUNCTION = registerSimple(Registries.TEST_FUNCTION, BuiltinTestFunctions::bootstrap); public static final Registry> REGISTRY = WRITABLE_REGISTRY; + // Paper start - add built-in registry conversions @@ -12,7 +12,7 @@ private static Registry registerSimple(ResourceKey> registryKey, BuiltInRegistries.RegistryBootstrap bootstrap) { return internalRegister(registryKey, new MappedRegistry<>(registryKey, Lifecycle.stable(), false), bootstrap); -@@ -379,6 +_,7 @@ +@@ -385,6 +_,7 @@ ResourceKey> registryKey, R registry, BuiltInRegistries.RegistryBootstrap bootstrap ) { Bootstrap.checkBootstrapCalled(() -> "registry " + registryKey.location()); @@ -20,7 +20,7 @@ ResourceLocation resourceLocation = registryKey.location(); LOADERS.put(resourceLocation, () -> bootstrap.run(registry)); WRITABLE_REGISTRY.register((ResourceKey)registryKey, registry, RegistrationInfo.BUILT_IN); -@@ -386,16 +_,34 @@ +@@ -392,16 +_,34 @@ } public static void bootStrap() { @@ -55,7 +55,7 @@ }); } -@@ -404,6 +_,7 @@ +@@ -410,6 +_,7 @@ for (Registry registry : REGISTRY) { bindBootstrappedTagsToEmpty(registry); diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch index 405db6d114b8..35ce20da5340 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestInfo.java +++ b/net/minecraft/gametest/framework/GameTestInfo.java -@@ -247,7 +_,7 @@ +@@ -243,7 +_,7 @@ AABB structureBounds = this.getStructureBounds(); List entitiesOfClass = this.getLevel() .getEntitiesOfClass(Entity.class, structureBounds.inflate(1.0), entity -> !(entity instanceof Player)); diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestMainUtil.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestMainUtil.java.patch index 9026c81bf78b..c7d9012b3e1e 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestMainUtil.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestMainUtil.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestMainUtil.java +++ b/net/minecraft/gametest/framework/GameTestMainUtil.java -@@ -77,7 +_,7 @@ +@@ -75,7 +_,7 @@ copyPacks(string, string1); } diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch index f176aa3352b0..1ab2a5ca3a50 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java -@@ -147,6 +_,8 @@ +@@ -146,6 +_,8 @@ boolean verify ) { super( @@ -9,7 +9,7 @@ serverThread, storageSource, packRepository, -@@ -162,9 +_,17 @@ +@@ -161,9 +_,17 @@ @Override public boolean initServer() { @@ -29,7 +29,7 @@ ServerLevel serverLevel = this.overworld(); this.testBatches = this.evaluateTestsToRun(serverLevel); LOGGER.info("Started game test server"); -@@ -349,6 +_,13 @@ +@@ -348,6 +_,13 @@ return false; } @@ -43,7 +43,7 @@ @Override public boolean isSingleplayerOwner(NameAndId nameAndId) { return false; -@@ -396,5 +_,16 @@ +@@ -395,5 +_,16 @@ @Override public void save() { } diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch index bc812f397e89..f705c709f77c 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch @@ -1,30 +1,20 @@ --- a/net/minecraft/gametest/framework/TestEnvironmentDefinition.java +++ b/net/minecraft/gametest/framework/TestEnvironmentDefinition.java -@@ -136,11 +_,11 @@ +@@ -124,7 +_,7 @@ + public void setup(ServerLevel level) { + GameRules gameRules = level.getGameRules(); MinecraftServer server = level.getServer(); - - for (TestEnvironmentDefinition.SetGameRules.Entry entry : this.boolRules) { -- gameRules.getRule(entry.key()).set(entry.value(), server); -+ gameRules.getRule(entry.key()).set(entry.value(), level); // Paper - per-world - } - - for (TestEnvironmentDefinition.SetGameRules.Entry entry : this.intRules) { -- gameRules.getRule(entry.key()).set(entry.value(), server); -+ gameRules.getRule(entry.key()).set(entry.value(), level); // Paper - per-world - } +- gameRules.setAll(this.gameRulesMap, server); ++ gameRules.setAll(this.gameRulesMap, level); // Paper - per-world game rules } -@@ -150,11 +_,11 @@ - MinecraftServer server = level.getServer(); - - for (TestEnvironmentDefinition.SetGameRules.Entry entry : this.boolRules) { -- gameRules.getRule(entry.key()).setFrom(GameRules.getType(entry.key()).createRule(), server); -+ gameRules.getRule(entry.key()).setFrom(GameRules.getType(entry.key()).createRule(), level); // Paper - per-world - } + @Override +@@ -133,7 +_,7 @@ + } - for (TestEnvironmentDefinition.SetGameRules.Entry entry : this.intRules) { -- gameRules.getRule(entry.key()).setFrom(GameRules.getType(entry.key()).createRule(), server); -+ gameRules.getRule(entry.key()).setFrom(GameRules.getType(entry.key()).createRule(), level); // Paper - per-world - } + private void resetRule(ServerLevel level, GameRule rule) { +- level.getGameRules().set(rule, rule.defaultValue(), level.getServer()); ++ level.getGameRules().set(rule, rule.defaultValue(), level); // Paper - per-world game rules } + @Override diff --git a/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch b/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch index 644f58a4e09e..c07e64d19e6c 100644 --- a/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch +++ b/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch @@ -18,7 +18,7 @@ } @Override -@@ -402,9 +_,16 @@ +@@ -400,9 +_,16 @@ @Override public CompoundTag copy() { @@ -38,7 +38,7 @@ } @Override -@@ -525,22 +_,47 @@ +@@ -523,22 +_,47 @@ this.merge((CompoundTag)mapCodec.encoder().encodeStart(ops, data).getOrThrow()); } diff --git a/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch b/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch index 926de43667ff..5cd314e969fc 100644 --- a/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch +++ b/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/nbt/NbtIo.java +++ b/net/minecraft/nbt/NbtIo.java -@@ -119,6 +_,11 @@ +@@ -118,6 +_,11 @@ } public static CompoundTag read(DataInput input, NbtAccounter accounter) throws IOException { diff --git a/paper-server/patches/sources/net/minecraft/nbt/SnbtGrammar.java.patch b/paper-server/patches/sources/net/minecraft/nbt/SnbtGrammar.java.patch index 6bf901555d4e..f32f5b684f24 100644 --- a/paper-server/patches/sources/net/minecraft/nbt/SnbtGrammar.java.patch +++ b/paper-server/patches/sources/net/minecraft/nbt/SnbtGrammar.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/nbt/SnbtGrammar.java +++ b/net/minecraft/nbt/SnbtGrammar.java -@@ -591,7 +_,7 @@ +@@ -587,7 +_,7 @@ Atom>> atom30 = Atom.of("map_entries"); dictionary.put(atom30, Term.repeatedWithTrailingSeparator(namedRule3, atom30, StringReaderTerms.character(',')), scope -> scope.getOrThrow(atom30)); Atom atom31 = Atom.of("map_literal"); @@ -9,7 +9,7 @@ List> list = scope.getOrThrow(atom30); if (list.isEmpty()) { return object2; -@@ -626,7 +_,9 @@ +@@ -622,7 +_,9 @@ atom35, Term.sequence( StringReaderTerms.character('['), diff --git a/paper-server/patches/sources/net/minecraft/network/Connection.java.patch b/paper-server/patches/sources/net/minecraft/network/Connection.java.patch index dac3dc2e57ce..9e277b37beeb 100644 --- a/paper-server/patches/sources/net/minecraft/network/Connection.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/Connection.java.patch @@ -9,13 +9,13 @@ + public com.mojang.authlib.properties.Property[] spoofedProfile; + public boolean preparing = true; + // Spigot end - @Nullable - private volatile PacketListener disconnectListener; - @Nullable -@@ -86,6 +_,43 @@ - private volatile DisconnectionDetails delayedDisconnect; - @Nullable - BandwidthDebugMonitor bandwidthDebugMonitor; + private volatile @Nullable PacketListener disconnectListener; + private volatile @Nullable PacketListener packetListener; + private @Nullable DisconnectionDetails disconnectionDetails; +@@ -81,6 +_,43 @@ + private boolean handlingFault; + private volatile @Nullable DisconnectionDetails delayedDisconnect; + @Nullable BandwidthDebugMonitor bandwidthDebugMonitor; + public String hostname = ""; // CraftBukkit - add field + // Paper start - NetworkClient implementation + public int protocolVersion; @@ -34,7 +34,7 @@ + // Paper end - add utility methods + // Paper start - packet limiter + protected final Object PACKET_LIMIT_LOCK = new Object(); -+ protected final @Nullable io.papermc.paper.util.IntervalledCounter allPacketCounts = io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.allPackets.isEnabled() ? new io.papermc.paper.util.IntervalledCounter( ++ protected final io.papermc.paper.util.@Nullable IntervalledCounter allPacketCounts = io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.allPackets.isEnabled() ? new io.papermc.paper.util.IntervalledCounter( + (long)(io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.allPackets.interval() * 1.0e9) + ) : null; + protected final java.util.Map>, io.papermc.paper.util.IntervalledCounter> packetSpecificLimits = new java.util.HashMap<>(); @@ -49,14 +49,14 @@ + } + // Paper end - packet limiter + @Nullable public SocketAddress haProxyAddress; // Paper - Add API to get player's proxy address -+ public @Nullable java.util.Optional legacySavedLoginEventResultOverride; // Paper - playerloginevent ++ public java.util.@Nullable Optional legacySavedLoginEventResultOverride; // Paper - playerloginevent + public boolean handledLegacyLoginEvent; // Paper - playerloginevent -+ public @Nullable net.minecraft.server.level.ServerPlayer savedPlayerForLegacyEvents; // Paper - playerloginevent & PlayerSpawnLocationEvent -+ public @Nullable org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus; // Paper ++ public net.minecraft.server.level.@Nullable ServerPlayer savedPlayerForLegacyEvents; // Paper - playerloginevent & PlayerSpawnLocationEvent ++ public org.bukkit.event.player.PlayerResourcePackStatusEvent.@Nullable Status resourcePackStatus; // Paper public Connection(PacketFlow receiving) { this.receiving = receiving; -@@ -96,6 +_,7 @@ +@@ -91,6 +_,7 @@ super.channelActive(ctx); this.channel = ctx.channel(); this.address = this.channel.remoteAddress(); @@ -64,7 +64,7 @@ if (this.delayedDisconnect != null) { this.disconnect(this.delayedDisconnect); } -@@ -108,14 +_,31 @@ +@@ -103,14 +_,31 @@ @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable exception) { @@ -96,7 +96,7 @@ this.disconnect(Component.translatable("disconnect.timeout")); } else { Component component = Component.translatable("disconnect.genericReason", "Internal Exception: " + exception); -@@ -127,9 +_,11 @@ +@@ -122,9 +_,11 @@ disconnectionDetails = new DisconnectionDetails(component); } @@ -109,7 +109,7 @@ Packet packet = (Packet)(this.sendLoginDisconnect ? new ClientboundLoginDisconnectPacket(component) : new ClientboundDisconnectPacket(component)); -@@ -146,6 +_,7 @@ +@@ -141,6 +_,7 @@ } } } @@ -117,7 +117,7 @@ } @Override -@@ -155,10 +_,60 @@ +@@ -150,10 +_,60 @@ if (packetListener == null) { throw new IllegalStateException("Received a packet before the packet listener was initialized"); } else { @@ -178,7 +178,7 @@ } catch (RejectedExecutionException var6) { this.disconnect(Component.translatable("multiplayer.disconnect.server_shutdown")); } catch (ClassCastException var7) { -@@ -351,10 +_,30 @@ +@@ -346,10 +_,30 @@ } } @@ -209,7 +209,7 @@ } if (!this.isConnected() && !this.disconnectionHandled) { -@@ -362,7 +_,7 @@ +@@ -357,7 +_,7 @@ } if (this.channel != null) { @@ -218,7 +218,7 @@ } if (this.tickCount++ % 20 == 0) { -@@ -398,12 +_,13 @@ +@@ -393,12 +_,13 @@ } public void disconnect(DisconnectionDetails disconnectionDetails) { @@ -233,7 +233,7 @@ this.disconnectionDetails = disconnectionDetails; } } -@@ -540,6 +_,13 @@ +@@ -533,6 +_,13 @@ } } @@ -247,7 +247,7 @@ public void setupCompression(int threshold, boolean validateDecompressed) { if (threshold >= 0) { if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder compressionDecoder) { -@@ -553,6 +_,7 @@ +@@ -546,6 +_,7 @@ } else { this.channel.pipeline().addAfter("prepender", "compress", new CompressionEncoder(threshold)); } @@ -255,7 +255,7 @@ } else { if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder) { this.channel.pipeline().remove("decompress"); -@@ -561,6 +_,7 @@ +@@ -554,6 +_,7 @@ if (this.channel.pipeline().get("compress") instanceof CompressionEncoder) { this.channel.pipeline().remove("compress"); } @@ -263,7 +263,7 @@ } } -@@ -578,6 +_,26 @@ +@@ -571,6 +_,26 @@ ); packetListener1.onDisconnect(disconnectionDetails); } diff --git a/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch b/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch index c4a3ada187dc..136c3096ffe6 100644 --- a/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch @@ -4,7 +4,7 @@ public class FriendlyByteBuf extends ByteBuf { public static final int DEFAULT_NBT_QUOTA = 2097152; private final ByteBuf source; -+ @Nullable public final java.util.Locale adventure$locale; // Paper - track player's locale for server-side translations ++ public final java.util.@Nullable Locale adventure$locale; // Paper - track player's locale for server-side translations public static final short MAX_STRING_LENGTH = 32767; public static final int MAX_COMPONENT_STRING_LENGTH = 262144; private static final int PUBLIC_KEY_SIZE = 256; @@ -36,7 +36,7 @@ } public static IntFunction limitValue(IntFunction function, int limit) { -@@ -555,7 +_,7 @@ +@@ -553,7 +_,7 @@ try { NbtIo.writeAnyTag(tag, new ByteBufOutputStream(buffer)); diff --git a/paper-server/patches/sources/net/minecraft/network/Varint21FrameDecoder.java.patch b/paper-server/patches/sources/net/minecraft/network/Varint21FrameDecoder.java.patch index d0035abf78e1..46628723821a 100644 --- a/paper-server/patches/sources/net/minecraft/network/Varint21FrameDecoder.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/Varint21FrameDecoder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/Varint21FrameDecoder.java +++ b/net/minecraft/network/Varint21FrameDecoder.java -@@ -41,6 +_,12 @@ +@@ -40,6 +_,12 @@ @Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) { diff --git a/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch index f0ee199b6887..b340bb0c3041 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch @@ -13,7 +13,7 @@ + java.util.concurrent.CompletableFuture decorate(@Nullable ServerPlayer player, Component message); // Paper - adventure; support async chat decoration events + + // Paper start - adventure; support async chat decoration events -+ default java.util.concurrent.CompletableFuture decorate(@Nullable ServerPlayer sender, @Nullable net.minecraft.commands.CommandSourceStack commandSourceStack, Component message) { ++ default java.util.concurrent.CompletableFuture decorate(@Nullable ServerPlayer sender, net.minecraft.commands.@Nullable CommandSourceStack commandSourceStack, Component message) { + throw new UnsupportedOperationException("Must override this implementation"); + } + // Paper end - adventure; support async chat decoration events diff --git a/paper-server/patches/sources/net/minecraft/network/chat/Component.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/Component.java.patch index d9578e5969d4..6159dbd6c797 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/Component.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/Component.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/network/chat/Component.java +++ b/net/minecraft/network/chat/Component.java @@ -25,7 +_,19 @@ - import net.minecraft.util.FormattedCharSequence; import net.minecraft.world.level.ChunkPos; + import org.jspecify.annotations.Nullable; -public interface Component extends Message, FormattedText { +public interface Component extends Message, FormattedText, Iterable { // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/network/chat/MessageSignature.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/MessageSignature.java.patch index af25ad25c9bd..18e60d87993d 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/MessageSignature.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/MessageSignature.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/network/chat/MessageSignature.java +++ b/net/minecraft/network/chat/MessageSignature.java @@ -13,6 +_,7 @@ - import net.minecraft.util.SignatureValidator; + import org.jspecify.annotations.Nullable; public record MessageSignature(byte[] bytes) { + public net.kyori.adventure.chat.SignedMessage.Signature adventure() { return () -> this.bytes; } // Paper - adventure; support signed messages diff --git a/paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch index 9a37c4f26d6c..677316ab3cbe 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/MutableComponent.java +++ b/net/minecraft/network/chat/MutableComponent.java -@@ -98,6 +_,11 @@ +@@ -97,6 +_,11 @@ @Override public boolean equals(Object other) { diff --git a/paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch index 8b60666cfb41..f6d43730715a 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch @@ -21,7 +21,7 @@ + return PlayerChatMessage.this.signature == null ? null : PlayerChatMessage.this.signature.adventure(); + } + @Override -+ public @Nullable net.kyori.adventure.text.Component unsignedContent() { ++ public net.kyori.adventure.text.@Nullable Component unsignedContent() { + return PlayerChatMessage.this.unsignedContent() == null ? null : io.papermc.paper.adventure.PaperAdventure.asAdventure(PlayerChatMessage.this.unsignedContent()); + } + @Override diff --git a/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch index 440e3748c579..72366c94cd99 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/SignedMessageChain.java +++ b/net/minecraft/network/chat/SignedMessageChain.java -@@ -40,14 +_,14 @@ +@@ -39,14 +_,14 @@ if (signature == null) { throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.MISSING_PROFILE_KEY); } else if (publicKey.data().hasExpired()) { @@ -17,7 +17,7 @@ } else { SignedMessageChain.this.lastTimeStamp = body.timeStamp(); PlayerChatMessage playerChatMessage = new PlayerChatMessage(signedMessageLink, signature, body, null, FilterMask.PASS_THROUGH); -@@ -80,8 +_,15 @@ +@@ -79,8 +_,15 @@ static final Component INVALID_SIGNATURE = Component.translatable("chat.disabled.invalid_signature"); static final Component OUT_OF_ORDER_CHAT = Component.translatable("chat.disabled.out_of_order_chat"); diff --git a/paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch index b9e08a06cfbc..40288d32b2e2 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/TextColor.java +++ b/net/minecraft/network/chat/TextColor.java -@@ -17,23 +_,29 @@ +@@ -17,22 +_,28 @@ public static final Codec CODEC = Codec.STRING.comapFlatMap(TextColor::parseColor, TextColor::serialize); private static final Map LEGACY_FORMAT_TO_COLOR = Stream.of(ChatFormatting.values()) .filter(ChatFormatting::isColor) @@ -10,8 +10,7 @@ .stream() .collect(ImmutableMap.toImmutableMap(textColor -> textColor.name, Function.identity())); private final int value; - @Nullable - public final String name; + public final @Nullable String name; + // CraftBukkit start + @Nullable + public final ChatFormatting format; diff --git a/paper-server/patches/sources/net/minecraft/network/chat/contents/NbtContents.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/contents/NbtContents.java.patch index 90795a01c010..ca177c9cdd7f 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/contents/NbtContents.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/contents/NbtContents.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/contents/NbtContents.java +++ b/net/minecraft/network/chat/contents/NbtContents.java -@@ -120,7 +_,7 @@ +@@ -118,7 +_,7 @@ if (this.interpreting) { RegistryOps registryOps = source.registryAccess().createSerializationContext(NbtOps.INSTANCE); Component component = DataFixUtils.orElse( @@ -9,7 +9,7 @@ ); return stream.flatMap(tag -> { try { -@@ -133,7 +_,7 @@ +@@ -131,7 +_,7 @@ }).reduce((mutableComponent, component1) -> mutableComponent.append(component).append(component1)).orElseGet(Component::empty); } else { Stream stream1 = stream.map(NbtContents::asString); diff --git a/paper-server/patches/sources/net/minecraft/network/chat/contents/TranslatableContents.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/contents/TranslatableContents.java.patch index 607754e3e550..bdbfe1fcb029 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/contents/TranslatableContents.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/contents/TranslatableContents.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/contents/TranslatableContents.java +++ b/net/minecraft/network/chat/contents/TranslatableContents.java -@@ -180,6 +_,16 @@ +@@ -178,6 +_,16 @@ @Override public Optional visit(FormattedText.ContentConsumer contentConsumer) { @@ -17,7 +17,7 @@ this.decompose(); for (FormattedText formattedText : this.decomposedParts) { -@@ -191,6 +_,27 @@ +@@ -189,6 +_,27 @@ return Optional.empty(); } diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch index ef54b04ade6a..03d18f0dc288 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch @@ -9,7 +9,7 @@ throw new RuntimeException("Chunk Packet trying to allocate too much memory on read."); } else { this.buffer = new byte[varInt]; -@@ -155,6 +_,7 @@ +@@ -154,6 +_,7 @@ CompoundTag updateTag = blockEntity.getUpdateTag(blockEntity.getLevel().registryAccess()); BlockPos blockPos = blockEntity.getBlockPos(); int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ()); diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch index a04c1424dd9e..bed45c045c4a 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch @@ -83,7 +83,7 @@ UPDATE_GAME_MODE( (entryBuilder, buffer) -> entryBuilder.gameMode = GameType.byId(buffer.readVarInt()), @@ -161,10 +_,15 @@ - @Nullable RemoteChatSession.Data chatSession + RemoteChatSession.@Nullable Data chatSession ) { Entry(ServerPlayer player) { + // Paper start - Add Listing API for Player diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch index cfe10e0294d2..8623dbc40ee0 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch @@ -12,7 +12,7 @@ private ClientboundSetPlayerTeamPacket(String name, int method, Optional parameters, Collection players) { this.name = name; this.method = method; -@@ -199,7 +_,7 @@ +@@ -197,7 +_,7 @@ ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buffer, this.displayName); buffer.writeByte(this.options); Team.Visibility.STREAM_CODEC.encode(buffer, this.nametagVisibility); diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch index d7bf58f0ce54..aa80d580bf29 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/game/ServerboundInteractPacket.java +++ b/net/minecraft/network/protocol/game/ServerboundInteractPacket.java -@@ -145,6 +_,15 @@ +@@ -144,6 +_,15 @@ buffer.writeEnum(this.hand); } } diff --git a/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch b/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch index 9a5fc7c227a3..d94f74eb7226 100644 --- a/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch @@ -14,7 +14,7 @@ public boolean isDirty() { return this.isDirty; } -@@ -169,6 +_,19 @@ +@@ -167,6 +_,19 @@ return new SynchedEntityData(this.entity, this.itemsById); } } diff --git a/paper-server/patches/sources/net/minecraft/resources/ResourceLocation.java.patch b/paper-server/patches/sources/net/minecraft/resources/ResourceLocation.java.patch index 8aeb195136e7..5340cbd25c30 100644 --- a/paper-server/patches/sources/net/minecraft/resources/ResourceLocation.java.patch +++ b/paper-server/patches/sources/net/minecraft/resources/ResourceLocation.java.patch @@ -22,7 +22,7 @@ this.namespace = namespace; this.path = path; } -@@ -243,7 +_,7 @@ +@@ -244,7 +_,7 @@ private static String assertValidNamespace(String namespace, String path) { if (!isValidNamespace(namespace)) { @@ -31,7 +31,7 @@ } else { return namespace; } -@@ -268,7 +_,7 @@ +@@ -269,7 +_,7 @@ private static String assertValidPath(String namespace, String path) { if (!isValidPath(path)) { diff --git a/paper-server/patches/sources/net/minecraft/server/Main.java.patch b/paper-server/patches/sources/net/minecraft/server/Main.java.patch index c7a44529abe9..bcb9b55ffc1f 100644 --- a/paper-server/patches/sources/net/minecraft/server/Main.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/Main.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -66,8 +_,10 @@ - reason = "System.out needed before bootstrap" - ) +@@ -64,8 +_,10 @@ + + @SuppressForbidden(reason = "System.out needed before bootstrap") @DontObfuscate - public static void main(String[] args) { + public static void main(final OptionSet optionSet) { // CraftBukkit - replaces main(String[] args) @@ -12,7 +12,7 @@ OptionParser optionParser = new OptionParser(); OptionSpec optionSpec = optionParser.accepts("nogui"); OptionSpec optionSpec1 = optionParser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); -@@ -92,41 +_,94 @@ +@@ -90,41 +_,94 @@ optionParser.printHelpOn(System.err); return; } @@ -116,7 +116,7 @@ Dynamic dataTag; if (levelStorageAccess.hasWorldData()) { LevelSummary summary; -@@ -168,12 +_,36 @@ +@@ -166,12 +_,36 @@ } Dynamic dynamic = dataTag; @@ -154,7 +154,7 @@ WorldStem worldStem; try { -@@ -182,6 +_,7 @@ +@@ -180,6 +_,7 @@ executor -> WorldLoader.load( initConfig, context -> { @@ -162,7 +162,7 @@ Registry registry = context.datapackDimensions().lookupOrThrow(Registries.LEVEL_STEM); if (dynamic != null) { LevelDataAndDimensions levelDataAndDimensions = LevelStorageSource.getLevelDataAndDimensions( -@@ -193,7 +_,7 @@ +@@ -191,7 +_,7 @@ } else { LOGGER.info("No existing world data, creating new world"); return createNewWorldData( @@ -171,7 +171,7 @@ ); } }, -@@ -211,6 +_,7 @@ +@@ -209,6 +_,7 @@ return; } @@ -179,7 +179,7 @@ RegistryAccess.Frozen frozen = worldStem.registries().compositeAccess(); WorldData worldData = worldStem.worldData(); boolean hasOptionSpec1 = optionSet.has(optionSpec6); -@@ -219,22 +_,50 @@ +@@ -217,22 +_,50 @@ } levelStorageAccess.saveDataTag(frozen, worldData); @@ -233,7 +233,7 @@ Thread thread = new Thread("Server Shutdown Thread") { @Override public void run() { -@@ -243,12 +_,13 @@ +@@ -241,12 +_,13 @@ }; thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); Runtime.getRuntime().addShutdownHook(thread); @@ -248,7 +248,7 @@ DedicatedServerSettings settings, WorldLoader.DataLoadContext context, Registry stemRegistry, boolean demo, boolean generateBonusChest ) { LevelSettings levelSettings; -@@ -316,7 +_,7 @@ +@@ -314,7 +_,7 @@ RegistryAccess registryAccess, boolean recreateRegionFiles ) { diff --git a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch index b25e192d9c9e..8e74bbbe7d1c 100644 --- a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -183,11 +_,13 @@ +@@ -188,11 +_,13 @@ import org.slf4j.Logger; public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ServerInfo, CommandSource, ChunkIOErrorReporter { @@ -15,16 +15,16 @@ private static final int OVERLOADED_TICKS_THRESHOLD = 20; private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeUtil.NANOSECONDS_PER_SECOND; private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100; -@@ -215,7 +_,7 @@ - private MinecraftServer.TimeProfiler debugCommandProfiler; +@@ -219,7 +_,7 @@ + private MinecraftServer.@Nullable TimeProfiler debugCommandProfiler; private boolean debugCommandProfilerDelayStart; private ServerConnectionListener connection; - private final LevelLoadListener levelLoadListener; + // Paper - per world load listener - moved LevelLoadListener to ServerLevel - @Nullable - private ServerStatus status; - @Nullable -@@ -228,14 +_,14 @@ + private @Nullable ServerStatus status; + private ServerStatus.@Nullable Favicon statusIcon; + private final RandomSource random = RandomSource.create(); +@@ -230,13 +_,14 @@ private Map, ServerLevel> levels = Maps.newLinkedHashMap(); private PlayerList playerList; private volatile boolean running = true; @@ -35,13 +35,12 @@ protected final Proxy proxy; private boolean onlineMode; private boolean preventProxyConnections; -- @Nullable -- private String motd; +- private @Nullable String motd; + private net.kyori.adventure.text.Component motd; // Paper - Adventure private int playerIdleTimeout; private final long[] tickTimesNanos = new long[100]; private long aggregatedTickTimesNanos = 0L; -@@ -287,10 +_,108 @@ +@@ -283,10 +_,108 @@ private final DiscontinuousFrame tickFrame; private final PacketProcessor packetProcessor; @@ -83,7 +82,7 @@ + private long scheduledTickStart; + private final Object statsLock = new Object(); + private @Nullable double[] tps; -+ private @Nullable ca.spottedleaf.moonrise.common.time.TickData.MSPTData msptData5s; ++ private ca.spottedleaf.moonrise.common.time.TickData.@Nullable MSPTData msptData5s; + + private void addTickTime(final ca.spottedleaf.moonrise.common.time.TickTime time) { + synchronized (this.statsLock) { @@ -123,7 +122,7 @@ + } + } + -+ public @Nullable ca.spottedleaf.moonrise.common.time.TickData.MSPTData getMSPTData5s() { ++ public ca.spottedleaf.moonrise.common.time.TickData.@Nullable MSPTData getMSPTData5s() { + synchronized (this.statsLock) { + if (this.msptData5s == null) { + this.msptData5s = this.tickTimes5s.getMSPTData(null, this.tickRateManager().nanosecondsPerTick()); @@ -151,7 +150,7 @@ if (Runtime.getRuntime().availableProcessors() > 4) { thread.setPriority(8); } -@@ -302,6 +_,10 @@ +@@ -298,6 +_,10 @@ } public MinecraftServer( @@ -162,7 +161,7 @@ Thread serverThread, LevelStorageSource.LevelStorageAccess storageSource, PackRepository packRepository, -@@ -312,18 +_,19 @@ +@@ -308,18 +_,19 @@ LevelLoadListener levelLoadListener ) { super("Server"); @@ -185,7 +184,7 @@ this.storageSource = storageSource; this.playerDataStorage = storageSource.createPlayerStorage(); this.fixerUpper = fixerUpper; -@@ -343,6 +_,38 @@ +@@ -339,6 +_,38 @@ this.serverActivityMonitor = new ServerActivityMonitor(this.notificationManager, 30); this.packetProcessor = new PacketProcessor(serverThread); } @@ -224,7 +223,7 @@ } protected abstract boolean initServer() throws IOException; -@@ -377,15 +_,15 @@ +@@ -371,15 +_,15 @@ }; } @@ -245,7 +244,7 @@ if (profiledDuration != null) { profiledDuration.finish(true); } -@@ -399,31 +_,127 @@ +@@ -393,31 +_,127 @@ } } @@ -383,7 +382,7 @@ serverLevelData.setInitialized(true); if (isDebugWorld) { this.setupDebugLevel(this.worldData); -@@ -443,38 +_,16 @@ +@@ -437,38 +_,16 @@ } GlobalPos globalPos = this.selectLevelLoadFocusPos(); @@ -430,7 +429,7 @@ Optional legacyWorldBorderSettings = serverLevelData.getLegacyWorldBorderSettings(); if (legacyWorldBorderSettings.isPresent()) { WorldBorder.Settings settings = legacyWorldBorderSettings.get(); -@@ -497,16 +_,14 @@ +@@ -491,16 +_,14 @@ dataStorage1.set(WorldBorder.TYPE, worldBorder); } @@ -453,7 +452,7 @@ } private static void setInitialSpawn( -@@ -518,6 +_,30 @@ +@@ -512,6 +_,30 @@ levelData.setSpawn(LevelData.RespawnData.of(level.dimension(), BlockPos.ZERO.above(80), 0.0F, 0.0F)); } else { ServerChunkCache chunkSource = level.getChunkSource(); @@ -484,7 +483,7 @@ ChunkPos chunkPos = new ChunkPos(chunkSource.randomState().sampler().findSpawnPosition()); levelLoadListener.start(LevelLoadListener.Stage.PREPARE_GLOBAL_SPAWN, 0); levelLoadListener.updateFocus(level.dimension(), chunkPos); -@@ -574,10 +_,13 @@ +@@ -568,10 +_,13 @@ serverLevelData.setGameType(GameType.SPECTATOR); } @@ -500,7 +499,7 @@ chunkLoadCounter.track(serverLevel, () -> { TicketStorage ticketStorage = serverLevel.getDataStorage().get(TicketStorage.TYPE); if (ticketStorage != null) { -@@ -586,17 +_,19 @@ +@@ -580,17 +_,19 @@ }); } @@ -518,7 +517,7 @@ - this.levelLoadListener.finish(LevelLoadListener.Stage.LOAD_INITIAL_CHUNKS); - this.updateMobSpawningFlags(); + serverLevel.levelLoadListener.finish(LevelLoadListener.Stage.LOAD_INITIAL_CHUNKS); // Paper - per world load listener -+ serverLevel.setSpawnSettings(serverLevel.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && serverLevel.getGameRules().getBoolean(GameRules.RULE_SPAWN_MONSTERS)); // Paper - per level difficulty (from setDifficulty(ServerLevel, Difficulty, boolean)) ++ serverLevel.setSpawnSettings(serverLevel.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && serverLevel.getGameRules().get(GameRules.SPAWN_MONSTERS)); // Paper - per level difficulty (from setDifficulty(ServerLevel, Difficulty, boolean)) this.updateEffectiveRespawnData(); + this.forceTicks = false; // CraftBukkit + serverLevel.entityManager.tick(); // SPIGOT-6526: Load pending entities so they are available to the API @@ -526,7 +525,7 @@ } protected GlobalPos selectLevelLoadFocusPos() { -@@ -630,8 +_,10 @@ +@@ -624,8 +_,10 @@ flag = true; } @@ -539,7 +538,7 @@ if (flush) { for (ServerLevel serverLevel : this.getAllLevels()) { LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", serverLevel.getChunkSource().chunkMap.getStorageName()); -@@ -661,19 +_,49 @@ +@@ -655,19 +_,49 @@ this.stopServer(); } @@ -590,7 +589,7 @@ } LOGGER.info("Saving worlds"); -@@ -715,6 +_,25 @@ +@@ -709,6 +_,25 @@ } catch (IOException var4) { LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), var4); } @@ -616,7 +615,7 @@ } public String getLocalIp() { -@@ -730,6 +_,14 @@ +@@ -724,6 +_,14 @@ } public void halt(boolean waitForShutdown) { @@ -631,7 +630,7 @@ this.running = false; if (waitForShutdown) { try { -@@ -740,6 +_,124 @@ +@@ -734,6 +_,124 @@ } } @@ -756,7 +755,7 @@ protected void runServer() { try { if (!this.initServer()) { -@@ -747,26 +_,68 @@ +@@ -741,26 +_,68 @@ } this.nextTickTimeNanos = Util.getNanos(); @@ -835,7 +834,7 @@ boolean flag = l == 0L; if (this.debugCommandProfilerDelayStart) { -@@ -774,22 +_,22 @@ +@@ -768,22 +_,22 @@ this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount); } @@ -863,7 +862,7 @@ this.finishMeasuringTaskExecutionTime(); if (flag) { this.tickRateManager.endTickWork(); -@@ -823,7 +_,7 @@ +@@ -817,7 +_,7 @@ } catch (Throwable var64) { LOGGER.error("Exception stopping the server", var64); } finally { @@ -872,7 +871,7 @@ } } } -@@ -875,7 +_,14 @@ +@@ -869,7 +_,14 @@ } private boolean haveTime() { @@ -888,7 +887,7 @@ } public static boolean throwIfFatalException() { -@@ -901,11 +_,11 @@ +@@ -895,11 +_,11 @@ } protected void waitUntilNextTick() { @@ -902,7 +901,7 @@ } finally { this.waitingForNextTick = false; } -@@ -924,17 +_,23 @@ +@@ -918,17 +_,23 @@ @Override public TickTask wrapRunnable(Runnable runnable) { @@ -928,7 +927,7 @@ this.mayHaveDelayedTasks = flag; return flag; } -@@ -943,15 +_,16 @@ +@@ -937,15 +_,16 @@ if (super.pollTask()) { return true; } else { @@ -947,7 +946,7 @@ } } -@@ -1003,26 +_,44 @@ +@@ -997,26 +_,44 @@ } public void tickServer(BooleanSupplier hasTimeLeft) { @@ -993,7 +992,7 @@ this.tickCount++; this.tickRateManager.tick(); this.tickChildren(hasTimeLeft); -@@ -1032,11 +_,18 @@ +@@ -1026,11 +_,18 @@ } this.ticksUntilAutosave--; @@ -1013,7 +1012,7 @@ profilerFiller.push("tallying"); long l = Util.getNanos() - nanos; int i1 = this.tickCount % 100; -@@ -1049,7 +_,7 @@ +@@ -1043,7 +_,7 @@ } private void autoSave() { @@ -1022,7 +1021,7 @@ LOGGER.debug("Autosave started"); ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("save"); -@@ -1091,7 +_,7 @@ +@@ -1085,7 +_,7 @@ private ServerStatus buildServerStatus() { ServerStatus.Players players = this.buildPlayerStatus(); return new ServerStatus( @@ -1031,7 +1030,7 @@ Optional.of(players), Optional.of(ServerStatus.Version.current()), Optional.ofNullable(this.statusIcon), -@@ -1105,7 +_,7 @@ +@@ -1099,7 +_,7 @@ if (this.hidesOnlinePlayers()) { return new ServerStatus.Players(maxPlayers, players.size(), List.of()); } else { @@ -1040,7 +1039,7 @@ ObjectArrayList list = new ObjectArrayList<>(min); int randomInt = Mth.nextInt(this.random, 0, players.size() - min); -@@ -1122,18 +_,77 @@ +@@ -1116,18 +_,77 @@ protected void tickChildren(BooleanSupplier hasTimeLeft) { ProfilerFiller profilerFiller = Profiler.get(); this.getPlayerList().getPlayers().forEach(serverPlayer1 -> serverPlayer1.connection.suspendFlushing()); @@ -1084,7 +1083,7 @@ + // Send time updates to everyone, it will get the right time from the world the player is in. + // Paper start - Perf: Optimize time updates + for (final ServerLevel level : this.getAllLevels()) { -+ final boolean doDaylight = level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT); ++ final boolean doDaylight = level.getGameRules().get(GameRules.ADVANCE_TIME); + final long dayTime = level.getDayTime(); + long worldTime = level.getGameTime(); + final ClientboundSetTimePacket worldPacket = new ClientboundSetTimePacket(worldTime, dayTime, doDaylight); @@ -1118,7 +1117,7 @@ profilerFiller.push("tick"); -@@ -1147,7 +_,9 @@ +@@ -1141,7 +_,9 @@ profilerFiller.pop(); profilerFiller.pop(); @@ -1128,7 +1127,7 @@ profilerFiller.popPush("connection"); this.tickConnection(); -@@ -1177,9 +_,12 @@ +@@ -1171,9 +_,12 @@ this.serverActivityMonitor.tick(); } @@ -1143,7 +1142,7 @@ this.effectiveRespawnData = serverLevel.getWorldBorderAdjustedRespawnData(respawnData); } -@@ -1231,6 +_,22 @@ +@@ -1223,6 +_,22 @@ return this.levels.get(dimension); } @@ -1166,7 +1165,7 @@ public Set> levelKeys() { return this.levels.keySet(); } -@@ -1255,7 +_,7 @@ +@@ -1247,7 +_,7 @@ @DontObfuscate public String getServerModName() { @@ -1175,7 +1174,7 @@ } public SystemReport fillSystemReport(SystemReport systemReport) { -@@ -1290,7 +_,7 @@ +@@ -1282,7 +_,7 @@ @Override public void sendSystemMessage(Component message) { @@ -1184,7 +1183,7 @@ } public KeyPair getKeyPair() { -@@ -1328,11 +_,17 @@ +@@ -1319,11 +_,17 @@ } } @@ -1201,13 +1200,13 @@ + level.getWorld(), source, org.bukkit.craftbukkit.util.CraftDifficulty.toBukkit(difficulty) + ).callEvent(); + worldData.setDifficulty(worldData.isHardcore() ? Difficulty.HARD : difficulty); -+ level.setSpawnSettings(worldData.getDifficulty() != Difficulty.PEACEFUL && level.getGameRules().getBoolean(GameRules.RULE_SPAWN_MONSTERS)); ++ level.setSpawnSettings(worldData.getDifficulty() != Difficulty.PEACEFUL && level.getGameRules().get(GameRules.SPAWN_MONSTERS)); + // this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate); + // Paper end - per level difficulty } } -@@ -1404,10 +_,20 @@ +@@ -1395,10 +_,20 @@ @Override public String getMotd() { @@ -1229,7 +1228,7 @@ this.motd = motd; } -@@ -1436,9 +_,13 @@ +@@ -1427,9 +_,13 @@ int i = 0; for (ServerPlayer serverPlayer : this.getPlayerList().getPlayers()) { @@ -1245,7 +1244,7 @@ } return i; -@@ -1446,7 +_,7 @@ +@@ -1437,7 +_,7 @@ } public ServerConnectionListener getConnection() { @@ -1254,7 +1253,7 @@ } public boolean isReady() { -@@ -1514,7 +_,7 @@ +@@ -1504,7 +_,7 @@ @Override public void executeIfPossible(Runnable task) { if (this.isStopped()) { @@ -1263,7 +1262,7 @@ } else { super.executeIfPossible(task); } -@@ -1549,7 +_,14 @@ +@@ -1539,7 +_,14 @@ return this.functionManager; } @@ -1278,7 +1277,7 @@ CompletableFuture completableFuture = CompletableFuture.supplyAsync( () -> selectedIds.stream().map(this.packRepository::getPack).filter(Objects::nonNull).map(Pack::open).collect(ImmutableList.toImmutableList()), this -@@ -1557,7 +_,7 @@ +@@ -1547,7 +_,7 @@ .thenCompose( list -> { CloseableResourceManager closeableResourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, list); @@ -1287,7 +1286,7 @@ return ReloadableServerResources.loadResources( closeableResourceManager, this.registries, -@@ -1578,20 +_,39 @@ +@@ -1568,20 +_,39 @@ ) .thenAcceptAsync( reloadableResources -> { @@ -1329,7 +1328,7 @@ }, this ); -@@ -1608,7 +_,7 @@ +@@ -1598,7 +_,7 @@ DataPackConfig dataPackConfig = initialDataConfig.dataPacks(); FeatureFlagSet featureFlagSet = initMode ? FeatureFlagSet.of() : initialDataConfig.enabledFeatures(); FeatureFlagSet featureFlagSet1 = initMode ? FeatureFlags.REGISTRY.allFlags() : initialDataConfig.enabledFeatures(); @@ -1338,7 +1337,7 @@ if (safeMode) { return configureRepositoryWithSelection(packRepository, List.of("vanilla"), featureFlagSet, false); } else { -@@ -1663,7 +_,7 @@ +@@ -1653,7 +_,7 @@ private static WorldDataConfiguration configureRepositoryWithSelection( PackRepository packRepository, Collection selectedPacks, FeatureFlagSet enabledFeatures, boolean safeMode ) { @@ -1347,7 +1346,7 @@ enableForcedFeaturePacks(packRepository, enabledFeatures); DataPackConfig selectedPacks1 = getSelectedPacks(packRepository, safeMode); FeatureFlagSet featureFlagSet = packRepository.getRequestedFeatureFlags().join(enabledFeatures); -@@ -1695,7 +_,7 @@ +@@ -1685,7 +_,7 @@ } } @@ -1356,7 +1355,7 @@ } } -@@ -1712,8 +_,8 @@ +@@ -1702,8 +_,8 @@ UserWhiteList whiteList = playerList.getWhiteList(); for (ServerPlayer serverPlayer : Lists.newArrayList(playerList.getPlayers())) { @@ -1367,7 +1366,7 @@ } } } -@@ -1743,12 +_,12 @@ +@@ -1733,12 +_,12 @@ } public ServerLevel findRespawnDimension() { @@ -1382,7 +1381,7 @@ public void setRespawnData(LevelData.RespawnData respawnData) { ServerLevelData serverLevelData = this.worldData.overworldData(); LevelData.RespawnData respawnData1 = serverLevelData.getRespawnData(); -@@ -1950,6 +_,17 @@ +@@ -1940,6 +_,17 @@ } } @@ -1400,7 +1399,7 @@ private ProfilerFiller createProfiler() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted( -@@ -2071,16 +_,22 @@ +@@ -2060,16 +_,22 @@ } public void logChatMessage(Component content, ChatType.Bound boundChatType, @Nullable String header) { @@ -1427,7 +1426,7 @@ } public boolean logIPs() { -@@ -2091,8 +_,9 @@ +@@ -2080,8 +_,9 @@ LOGGER.debug("Received custom click action {} with payload {}", id, payload.orElse(null)); } @@ -1438,18 +1437,48 @@ } public boolean setAutoSave(boolean autoSave) { -@@ -2118,8 +_,9 @@ +@@ -2107,12 +_,14 @@ return false; } -+ @io.papermc.paper.annotation.DoNotUse @Deprecated(forRemoval = true) // Paper - per level gamerules - replace all calls - public void onGameRuleChanged(String key, GameRules.Value value) { -- this.notificationManager().onGameRuleChanged(key, value); -+ throw new UnsupportedOperationException(); // Paper - per level gamerules - replace callers +- public void onGameRuleChanged(GameRule rule, T value) { +- this.notificationManager().onGameRuleChanged(rule, value); ++ // Paper start - per-world game rules ++ public void onGameRuleChanged(ServerLevel serverLevel, GameRule rule, T value) { ++ this.notificationManager().onGameRuleChanged(serverLevel, rule, value); ++ // Paper end - per-world game rules + if (rule == GameRules.REDUCED_DEBUG_INFO) { + byte b = (byte)((Boolean)value ? 22 : 23); + +- for (ServerPlayer serverPlayer : this.getPlayerList().getPlayers()) { ++ for (ServerPlayer serverPlayer : serverLevel.players()) { // Paper - per-world game rules + serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, b)); + } + } else if (rule == GameRules.LIMITED_CRAFTING || rule == GameRules.IMMEDIATE_RESPAWN) { +@@ -2120,18 +_,18 @@ + ? ClientboundGameEventPacket.LIMITED_CRAFTING + : ClientboundGameEventPacket.IMMEDIATE_RESPAWN; + ClientboundGameEventPacket clientboundGameEventPacket = new ClientboundGameEventPacket(type, (Boolean)value ? 1.0F : 0.0F); +- this.getPlayerList().getPlayers().forEach(serverPlayer1 -> serverPlayer1.connection.send(clientboundGameEventPacket)); ++ serverLevel.players().forEach(serverPlayer1 -> serverPlayer1.connection.send(clientboundGameEventPacket)); // Paper - per-world game rules + } else if (rule == GameRules.LOCATOR_BAR) { +- this.getAllLevels().forEach(serverLevel -> { ++ // this.getAllLevels().forEach(serverLevel -> { // Paper - per-world game rules + ServerWaypointManager waypointManager = serverLevel.getWaypointManager(); + if ((Boolean)value) { + serverLevel.players().forEach(waypointManager::updatePlayer); + } else { + waypointManager.breakAllConnections(); + } +- }); ++ // }); // Paper - per-world game rules + } else if (rule == GameRules.SPAWN_MONSTERS) { +- this.updateMobSpawningFlags(); ++ serverLevel.setSpawnSettings(serverLevel.serverLevelData.getDifficulty() != net.minecraft.world.Difficulty.PEACEFUL && serverLevel.getGameRules().get(GameRules.SPAWN_MONSTERS)); // Paper - per-world game rules + } } - public boolean acceptsTransfers() { -@@ -2253,4 +_,53 @@ +@@ -2266,4 +_,53 @@ }; } } diff --git a/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch b/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch index 42f13731adeb..dd0559c5bd82 100644 --- a/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch @@ -9,15 +9,15 @@ private final PlayerList playerList; private final Path playerSavePath; private AdvancementTree tree; -@@ -60,6 +_,7 @@ - private AdvancementHolder lastSelectedTab; +@@ -59,6 +_,7 @@ + private @Nullable AdvancementHolder lastSelectedTab; private boolean isFirstPacket = true; private final Codec codec; + public final Map, Set>> criterionData = new java.util.IdentityHashMap<>(); // Paper - fix advancement data player leakage public PlayerAdvancements(DataFixer dataFixer, PlayerList playerList, ServerAdvancementManager manager, Path playerSavePath, ServerPlayer player) { this.playerList = playerList; -@@ -127,6 +_,7 @@ +@@ -126,6 +_,7 @@ } public void save() { @@ -25,7 +25,7 @@ JsonElement jsonElement = this.codec.encodeStart(JsonOps.INSTANCE, this.asData()).getOrThrow(); try { -@@ -144,6 +_,7 @@ +@@ -143,6 +_,7 @@ data.forEach((path, progress) -> { AdvancementHolder advancementHolder = advancementManager.get(path); if (advancementHolder == null) { @@ -33,7 +33,7 @@ LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", path, this.playerSavePath); } else { this.startProgress(advancementHolder, progress); -@@ -168,14 +_,31 @@ +@@ -167,14 +_,31 @@ AdvancementProgress orStartProgress = this.getOrStartProgress(advancement); boolean isDone = orStartProgress.isDone(); if (orStartProgress.grantProgress(criterionKey)) { @@ -58,16 +58,16 @@ + // Paper end advancement.value().rewards().grant(this.player); advancement.value().display().ifPresent(displayInfo -> { -- if (displayInfo.shouldAnnounceChat() && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { +- if (displayInfo.shouldAnnounceChat() && this.player.level().getGameRules().get(GameRules.SHOW_ADVANCEMENT_MESSAGES)) { - this.playerList.broadcastSystemMessage(displayInfo.getType().createAnnouncement(advancement, this.player), false); + // Paper start - Add Adventure message to PlayerAdvancementDoneEvent -+ if (event.message() != null && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { ++ if (event.message() != null && this.player.level().getGameRules().get(GameRules.SHOW_ADVANCEMENT_MESSAGES)) { + this.playerList.broadcastSystemMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.message()), false); + // Paper end } }); } -@@ -246,7 +_,7 @@ +@@ -245,7 +_,7 @@ public void flushDirty(ServerPlayer player, boolean showAdvancements) { if (this.isFirstPacket || !this.rootsToUpdate.isEmpty() || !this.progressChanged.isEmpty()) { Map map = new HashMap<>(); diff --git a/paper-server/patches/sources/net/minecraft/server/Services.java.patch b/paper-server/patches/sources/net/minecraft/server/Services.java.patch index a4cc21df362d..7c8740bb9afa 100644 --- a/paper-server/patches/sources/net/minecraft/server/Services.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/Services.java.patch @@ -45,4 +45,4 @@ + // Paper end - load paper config files from cli options } - @Nullable + public @Nullable SignatureValidator profileKeySignatureValidator() { diff --git a/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch index 23c44096b8f3..95d7b3d5f300 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch @@ -1,13 +1,22 @@ --- a/net/minecraft/server/commands/GameRuleCommand.java +++ b/net/minecraft/server/commands/GameRuleCommand.java -@@ -32,8 +_,8 @@ - static > int setRule(CommandContext context, GameRules.Key gameRule) { +@@ -34,7 +_,18 @@ + static int setRule(CommandContext context, GameRule rule) { CommandSourceStack commandSourceStack = context.getSource(); - T rule = commandSourceStack.getLevel().getGameRules().getRule(gameRule); -- rule.setFromArgument(context, "value"); -- commandSourceStack.getServer().onGameRuleChanged(gameRule.getId(), rule); -+ rule.setFromArgument(context, "value", gameRule); // Paper - Add WorldGameRuleChangeEvent -+ commandSourceStack.getServer().notificationManager().onGameRuleChanged(commandSourceStack.getLevel(), gameRule.getId(), rule); // Paper - per-world game rules - commandSourceStack.sendSuccess(() -> Component.translatable("commands.gamerule.set", gameRule.getId(), rule.toString()), true); - return rule.getCommandResult(); + T argument = context.getArgument("value", rule.valueClass()); +- commandSourceStack.getLevel().getGameRules().set(rule, argument, context.getSource().getServer()); ++ // Paper start - Add WorldGameRuleChangeEvent ++ final var event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent( ++ context.getSource().getBukkitWorld(), ++ context.getSource().getBukkitSender(), ++ org.bukkit.GameRule.getByName(gameRuleKey.toString()), ++ String.valueOf(argument) ++ ); ++ if (!event.callEvent()) { ++ return 0; ++ } ++ // Paper end - Add WorldGameRuleChangeEvent ++ commandSourceStack.getLevel().getGameRules().set(rule, argument, context.getSource().getLevel()); // Paper - per-world game rules + commandSourceStack.sendSuccess(() -> Component.translatable("commands.gamerule.set", rule.id(), rule.serialize(argument)), true); + return rule.getCommandResult(argument); } diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch index f0fc6ae608cc..f26eae182477 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,19 +1,18 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -80,10 +_,10 @@ +@@ -80,9 +_,9 @@ static final Logger LOGGER = LogUtils.getLogger(); private static final int CONVERSION_RETRY_DELAY_MS = 5000; private static final int CONVERSION_RETRIES = 2; - private final List consoleInput = Collections.synchronizedList(Lists.newArrayList()); + private final java.util.Queue serverCommandQueue = new java.util.concurrent.ConcurrentLinkedQueue<>(); // Paper - Perf: use a proper queue - @Nullable - private QueryThreadGs4 queryThreadGs4; + private @Nullable QueryThreadGs4 queryThreadGs4; - private final RconConsoleSource rconConsoleSource; + // private final RconConsoleSource rconConsoleSource; // CraftBukkit - remove field - @Nullable - private RconThread rconThread; + private @Nullable RconThread rconThread; public DedicatedServerSettings settings; -@@ -101,6 +_,7 @@ + private @Nullable MinecraftServerGui gui; +@@ -95,6 +_,7 @@ private long lastHeartbeat; public DedicatedServer( @@ -21,7 +20,7 @@ Thread serverThread, LevelStorageSource.LevelStorageAccess storageSource, PackRepository packRepository, -@@ -109,9 +_,10 @@ +@@ -103,9 +_,10 @@ DataFixer fixerUpper, Services services ) { @@ -34,7 +33,7 @@ this.serverTextFilter = ServerTextFilter.createFromConfig(settings.getProperties()); this.serverLinks = createServerLinks(settings); if (settings.getProperties().codeOfConduct) { -@@ -197,6 +_,10 @@ +@@ -191,6 +_,10 @@ Thread thread = new Thread("Server console handler") { @Override public void run() { @@ -45,7 +44,7 @@ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); String string4; -@@ -206,17 +_,41 @@ +@@ -200,17 +_,41 @@ } } catch (IOException var4) { DedicatedServer.LOGGER.error("Exception handling console input", (Throwable)var4); @@ -89,7 +88,7 @@ LOGGER.info("Loading properties"); DedicatedServerProperties properties = this.settings.getProperties(); if (this.isSingleplayer()) { -@@ -227,8 +_,46 @@ +@@ -221,8 +_,46 @@ this.setLocalIp(properties.serverIp); } @@ -137,7 +136,7 @@ InetAddress inetAddress = null; if (!this.getLocalIp().isEmpty()) { inetAddress = InetAddress.getByName(this.getLocalIp()); -@@ -237,46 +_,72 @@ +@@ -231,46 +_,72 @@ if (this.getPort() < 0) { this.setPort(properties.serverPort); } @@ -213,12 +212,12 @@ + LOGGER.info("Done preparing level \"{}\" ({})", this.getLevelIdName(), string3); // Paper - Improve startup message, add total time + this.initPostWorld(); // Paper - don't include plugins in world preparation time if (properties.announcePlayerAchievements != null) { -- this.worldData.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS).set(properties.announcePlayerAchievements, this); -+ this.worldData.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS).set(properties.announcePlayerAchievements, this.overworld()); // CraftBukkit - per-world +- this.worldData.getGameRules().set(GameRules.SHOW_ADVANCEMENT_MESSAGES, properties.announcePlayerAchievements, this); ++ this.worldData.getGameRules().set(GameRules.SHOW_ADVANCEMENT_MESSAGES, properties.announcePlayerAchievements, this.overworld()); // Paper - per-world game rules } if (properties.enableQuery) { -@@ -289,7 +_,7 @@ +@@ -283,7 +_,7 @@ this.rconThread = RconThread.create(this); } @@ -227,7 +226,7 @@ Thread thread1 = new Thread(new ServerWatchdog(this)); thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(LOGGER)); thread1.setName("Server Watchdog"); -@@ -307,6 +_,12 @@ +@@ -301,6 +_,12 @@ } } @@ -240,7 +239,7 @@ @Override public boolean isEnforceWhitelist() { return this.settings.getProperties().enforceWhitelist.get(); -@@ -324,6 +_,7 @@ +@@ -318,6 +_,7 @@ @Override public void setUsingWhitelist(boolean usingWhitelist) { @@ -248,7 +247,7 @@ this.settings.update(dedicatedServerProperties -> dedicatedServerProperties.whiteList.update(this.registryAccess(), usingWhitelist)); } -@@ -374,7 +_,7 @@ +@@ -368,7 +_,7 @@ @Override public void forceDifficulty() { @@ -257,7 +256,7 @@ } public int viewDistance() { -@@ -430,11 +_,11 @@ +@@ -424,11 +_,11 @@ } if (this.rconThread != null) { @@ -271,7 +270,7 @@ } if (this.jsonRpcServer != null) { -@@ -444,6 +_,9 @@ +@@ -438,6 +_,9 @@ LOGGER.error("Interrupted while stopping the management server", (Throwable)var2); } } @@ -281,7 +280,7 @@ } @Override -@@ -453,12 +_,20 @@ +@@ -447,12 +_,20 @@ } public void handleConsoleInput(String msg, CommandSourceStack source) { @@ -305,7 +304,7 @@ this.getCommands().performPrefixedCommand(consoleInput.source, consoleInput.msg); } } -@@ -603,12 +_,15 @@ +@@ -597,12 +_,15 @@ @Override public String getMotd() { @@ -323,7 +322,7 @@ } @Override -@@ -634,7 +_,11 @@ +@@ -628,7 +_,11 @@ @Override public boolean enforceSecureProfile() { DedicatedServerProperties properties = this.getProperties(); @@ -336,7 +335,7 @@ } @Override -@@ -719,21 +_,60 @@ +@@ -713,21 +_,60 @@ @Override public String getPluginNames() { @@ -402,7 +401,7 @@ } @Override -@@ -865,4 +_,15 @@ +@@ -858,4 +_,15 @@ public Map getCodeOfConducts() { return this.codeOfConductTexts; } diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch index a96aa62f6148..4525693454fd 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch @@ -8,7 +8,7 @@ public static final String MANAGEMENT_SERVER_TLS_ENABLED_KEY = "management-server-tls-enabled"; public static final String MANAGEMENT_SERVER_TLS_KEYSTORE_KEY = "management-server-tls-keystore"; public static final String MANAGEMENT_SERVER_TLS_KEYSTORE_PASSWORD_KEY = "management-server-tls-keystore-password"; -@@ -107,7 +_,7 @@ +@@ -106,7 +_,7 @@ public final boolean broadcastRconToOps = this.get("broadcast-rcon-to-ops", true); public final boolean broadcastConsoleToOps = this.get("broadcast-console-to-ops", true); public final int maxWorldSize = this.get("max-world-size", property -> Mth.clamp(property, 1, 29999984), 29999984); @@ -17,7 +17,7 @@ public final String regionFileComression = this.get("region-file-compression", "deflate"); public final boolean enableJmxMonitoring = this.get("enable-jmx-monitoring", false); public final Settings.MutableValue enableStatus = this.getMutable("enable-status", true); -@@ -124,13 +_,16 @@ +@@ -123,13 +_,16 @@ public final Settings.MutableValue whiteList = this.getMutable("white-list", false); public final boolean enforceSecureProfile = this.get("enforce-secure-profile", true); public final boolean logIPs = this.get("log-ips", true); @@ -37,7 +37,7 @@ String string = this.get("level-seed", ""); boolean flag = this.get("generate-structures", true); long l = WorldOptions.parseSeed(string).orElse(WorldOptions.randomSeed()); -@@ -151,15 +_,21 @@ +@@ -150,15 +_,21 @@ this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())), this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled())) ); @@ -62,4 +62,4 @@ + // CraftBukkit end } - @Nullable + private static @Nullable Component parseResourcePackPrompt(String json) { diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch index 7c8135855ecc..1c8c31a9719b 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch @@ -83,19 +83,21 @@ this.properties.store(bufferedWriter, "Minecraft server properties"); } catch (IOException var7) { LOGGER.error("Failed to store properties to file: {}", filePath); -@@ -94,7 +_,7 @@ +@@ -93,7 +_,7 @@ + } - @Nullable - public String getStringRaw(String key) { + public @Nullable String getStringRaw(String key) { - return (String)this.properties.get(key); + return (String)this.getOverride(key, this.properties.getProperty(key)); // CraftBukkit } - @Nullable -@@ -109,6 +_,15 @@ + protected @Nullable V getLegacy(String key, Function serializer) { +@@ -106,7 +_,16 @@ + } } - protected V get(String key, Function serializer, Function deserializer, V defaultValue) { +- protected V get(String key, Function serializer, Function deserializer, V defaultValue) { ++ protected V get(String key, Function serializer, Function deserializer, V defaultValue) { + // CraftBukkit start + try { + return this.get0(key, serializer, deserializer, defaultValue); @@ -103,12 +105,12 @@ + throw new RuntimeException("Could not load invalidly configured property '" + key + "'", ex); + } + } -+ private V get0(String key, Function serializer, Function deserializer, V defaultValue) { ++ private V get0(String key, Function serializer, Function deserializer, V defaultValue) { + // CraftBukkit end String stringRaw = this.getStringRaw(key); V object = MoreObjects.firstNonNull(stringRaw != null ? serializer.apply(stringRaw) : null, defaultValue); this.properties.put(key, deserializer.apply(object)); -@@ -185,7 +_,7 @@ +@@ -181,7 +_,7 @@ return map; } @@ -117,7 +119,7 @@ public class MutableValue implements Supplier { private final String key; -@@ -206,7 +_,7 @@ +@@ -202,7 +_,7 @@ public T update(RegistryAccess registryAccess, V newValue) { Properties map = Settings.this.cloneProperties(); map.put(this.key, this.serializer.apply(newValue)); diff --git a/paper-server/patches/sources/net/minecraft/server/gui/StatsComponent.java.patch b/paper-server/patches/sources/net/minecraft/server/gui/StatsComponent.java.patch index d1bc8cfa66c7..40640f3fda1f 100644 --- a/paper-server/patches/sources/net/minecraft/server/gui/StatsComponent.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/gui/StatsComponent.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/gui/StatsComponent.java +++ b/net/minecraft/server/gui/StatsComponent.java -@@ -31,8 +_,17 @@ +@@ -32,8 +_,17 @@ private void tick() { long l = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); @@ -18,7 +18,7 @@ this.values[this.vp++ & 0xFF] = (int)(l * 100L / Runtime.getRuntime().maxMemory()); this.repaint(); } -@@ -61,4 +_,10 @@ +@@ -62,4 +_,10 @@ public void close() { this.timer.stop(); } diff --git a/paper-server/patches/sources/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java.patch b/paper-server/patches/sources/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java.patch index 263d75bcc248..e8fa089602cf 100644 --- a/paper-server/patches/sources/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java.patch @@ -4,9 +4,9 @@ } @Override -- public void onGameRuleChanged(String key, GameRules.Value value) { -+ public void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, String key, GameRules.Value value) { // Paper - per-world game rules (add level param) +- public void onGameRuleChanged(GameRule rule, T value) { ++ public void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, GameRule rule, T value) { // Paper - per-world game rules (add level param) + if (level != level.getServer().overworld()) return; // Paper - per-world game rules - use overworld for vanilla protocol - this.broadcastNotification(OutgoingRpcMethods.GAMERULE_CHANGED, GameRulesService.getTypedRule(this.minecraftApi, key, value)); + this.broadcastNotification(OutgoingRpcMethods.GAMERULE_CHANGED, GameRulesService.getTypedRule(this.minecraftApi, rule, value)); } diff --git a/paper-server/patches/sources/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java.patch index 94e422dcfaf8..92b7b4e23401 100644 --- a/paper-server/patches/sources/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java.patch @@ -1,24 +1,11 @@ --- a/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java +++ b/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java -@@ -25,18 +_,18 @@ - net.minecraft.world.level.GameRules.Value ruleValue = this.getRuleValue(rule.key()); - String string = ruleValue.serialize(); - if (ruleValue instanceof net.minecraft.world.level.GameRules.BooleanValue booleanValue) { -- booleanValue.set(Boolean.parseBoolean(rule.value()), this.server); -+ booleanValue.set(Boolean.parseBoolean(rule.value()), this.server.overworld()); // Paper - per-world game rules - use overworld for vanilla protocol - } else { - if (!(ruleValue instanceof net.minecraft.world.level.GameRules.IntegerValue integerValue)) { - throw new InvalidParameterJsonRpcException("Unknown rule type for key: " + rule.key()); - } - -- integerValue.set(Integer.parseInt(rule.value()), this.server); -+ integerValue.set(Integer.parseInt(rule.value()), this.server.overworld()); // Paper - per-world game rules - use overworld for vanilla protocol - } - - GameRulesService.TypedRule typedRule = this.getTypedRule(rule.key(), ruleValue); - this.jsonrpcLogger.log(client, "Game rule '{}' updated from '{}' to '{}'", typedRule.key(), string, typedRule.value()); -- this.server.onGameRuleChanged(rule.key(), ruleValue); -+ this.server.notificationManager().onGameRuleChanged(this.server.overworld(), rule.key(), ruleValue); // Paper - per-world game rules - use overworld for vanilla protocol - return typedRule; +@@ -24,7 +_,7 @@ + GameRule gameRule = update.gameRule(); + T object = this.gameRules.get(gameRule); + T object1 = update.value(); +- this.gameRules.set(gameRule, object1, this.server); ++ this.gameRules.set(gameRule, object1, this.server.overworld()); // Paper - per-world game rules - use overworld for vanilla protocol + this.jsonrpcLogger.log(client, "Game rule '{}' updated from '{}' to '{}'", gameRule.id(), gameRule.serialize(object), gameRule.serialize(object1)); + return update; } - diff --git a/paper-server/patches/sources/net/minecraft/server/level/ChunkHolder.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ChunkHolder.java.patch index b3f729b8b573..dbd31018891f 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ChunkHolder.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ChunkHolder.java.patch @@ -32,23 +32,23 @@ public CompletableFuture> getTickingChunkFuture() { return this.tickingChunkFuture; } -@@ -84,7 +_,7 @@ +@@ -83,7 +_,7 @@ + return this.fullChunkFuture; } - @Nullable -- public LevelChunk getTickingChunk() { -+ public final LevelChunk getTickingChunk() { // Paper - final for inline +- public @Nullable LevelChunk getTickingChunk() { ++ public final @Nullable LevelChunk getTickingChunk() { // Paper - final for inline return this.getTickingChunkFuture().getNow(UNLOADED_LEVEL_CHUNK).orElse(null); } -@@ -129,6 +_,7 @@ +@@ -127,6 +_,7 @@ } else { boolean flag = this.hasChangedSections; int sectionIndex = this.levelHeightAccessor.getSectionIndex(pos.getY()); + if (sectionIndex < 0 || sectionIndex >= this.changedBlocksPerSection.length) return false; // CraftBukkit - SPIGOT-6086, SPIGOT-6296 - if (this.changedBlocksPerSection[sectionIndex] == null) { + ShortSet set = this.changedBlocksPerSection[sectionIndex]; + if (set == null) { this.hasChangedSections = true; - this.changedBlocksPerSection[sectionIndex] = new ShortOpenHashSet(); @@ -274,6 +_,38 @@ chunkMap.onFullChunkStatusChange(this.pos, fullChunkStatus); } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ChunkLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ChunkLevel.java.patch index dd7a296972b8..a6ccc990f4f3 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ChunkLevel.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ChunkLevel.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/level/ChunkLevel.java +++ b/net/minecraft/server/level/ChunkLevel.java @@ -7,7 +_,7 @@ - import org.jetbrains.annotations.Contract; + import org.jspecify.annotations.Nullable; public class ChunkLevel { - private static final int FULL_CHUNK_LEVEL = 33; diff --git a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch index 8f4c256a0a51..622c09a01cec 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -151,6 +_,33 @@ +@@ -152,6 +_,33 @@ public int serverViewDistance; private final WorldGenContext worldGenContext; @@ -34,7 +34,7 @@ public ChunkMap( ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorageAccess, -@@ -179,13 +_,19 @@ +@@ -180,13 +_,19 @@ this.level = level; RegistryAccess registryAccess = level.registryAccess(); long seed = level.getSeed(); @@ -56,7 +56,7 @@ this.mainThreadExecutor = mainThreadExecutor; ConsecutiveExecutor consecutiveExecutor = new ConsecutiveExecutor(dispatcher, "worldgen"); this.chunkStatusListener = chunkStatusListener; -@@ -214,6 +_,12 @@ +@@ -215,6 +_,12 @@ this.chunksToEagerlySave.add(chunkPos.toLong()); } @@ -69,7 +69,7 @@ protected ChunkGenerator generator() { return this.worldGenContext.generator(); } -@@ -359,9 +_,9 @@ +@@ -357,9 +_,9 @@ } ); stringBuilder.append("Updating:").append(System.lineSeparator()); @@ -81,7 +81,7 @@ CrashReport crashReport = CrashReport.forThrowable(exception, "Chunk loading"); CrashReportCategory crashReportCategory = crashReport.addCategory("Chunk loading"); crashReportCategory.setDetail("Details", details); -@@ -397,6 +_,7 @@ +@@ -394,6 +_,7 @@ holder.setTicketLevel(newLevel); } else { holder = new ChunkHolder(new ChunkPos(chunkPos), newLevel, this.level, this.lightEngine, this::onLevelChange, this); @@ -89,7 +89,7 @@ } this.updatingChunkMap.put(chunkPos, holder); -@@ -425,8 +_,8 @@ +@@ -422,8 +_,8 @@ protected void saveAllChunks(boolean flush) { if (flush) { @@ -100,7 +100,7 @@ .stream() .filter(ChunkHolder::wasAccessibleSinceLastSave) .peek(ChunkHolder::refreshAccessibility) -@@ -452,7 +_,7 @@ +@@ -449,7 +_,7 @@ this.nextChunkSaveTime.clear(); long millis = Util.getMillis(); @@ -109,7 +109,7 @@ this.saveChunkIfNeeded(chunkHolder, millis); } } -@@ -473,6 +_,7 @@ +@@ -470,6 +_,7 @@ public boolean hasWork() { return this.lightEngine.hasLightWork() || !this.pendingUnloads.isEmpty() @@ -117,7 +117,7 @@ || !this.updatingChunkMap.isEmpty() || this.poiManager.hasWork() || !this.toDrop.isEmpty() -@@ -531,7 +_,11 @@ +@@ -528,7 +_,11 @@ this.scheduleUnload(chunkPos, chunkHolder); } else { ChunkAccess latestChunk = chunkHolder.getLatestChunk(); @@ -130,7 +130,7 @@ if (latestChunk instanceof LevelChunk levelChunk) { levelChunk.setLoaded(false); } -@@ -544,7 +_,9 @@ +@@ -541,7 +_,9 @@ this.lightEngine.updateChunkStatus(latestChunk.getPos()); this.lightEngine.tryScheduleUpdate(); this.nextChunkSaveTime.remove(latestChunk.getPos().toLong()); @@ -141,7 +141,7 @@ } }, this.unloadQueue::add).whenComplete((_void, error) -> { if (error != null) { -@@ -852,7 +_,7 @@ +@@ -848,7 +_,7 @@ } public int size() { @@ -150,7 +150,7 @@ } public net.minecraft.server.level.DistanceManager getDistanceManager() { -@@ -879,10 +_,10 @@ +@@ -875,10 +_,10 @@ .addColumn("fluid_ticks") .build(writer); @@ -164,7 +164,7 @@ Optional optional = Optional.ofNullable(chunkHolder.getLatestChunk()); Optional optional1 = optional.flatMap(chunk -> chunk instanceof LevelChunk ? Optional.of((LevelChunk)chunk) : Optional.empty()); csvOutput.writeRow( -@@ -926,12 +_,12 @@ +@@ -922,12 +_,12 @@ } private CompoundTag upgradeChunkTag(CompoundTag tag) { @@ -180,7 +180,7 @@ generator.ifPresent(resourceKey -> compoundTag.putString("generator", resourceKey.location().toString())); return compoundTag; } -@@ -943,7 +_,7 @@ +@@ -939,7 +_,7 @@ ChunkHolder chunkHolder = this.visibleChunkMap.get(spawnCandidateChunks.nextLong()); if (chunkHolder != null) { LevelChunk tickingChunk = chunkHolder.getTickingChunk(); @@ -189,7 +189,7 @@ output.add(tickingChunk); } } -@@ -963,13 +_,35 @@ +@@ -959,8 +_,14 @@ } public boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkPos) { @@ -204,6 +204,10 @@ + // Spigot end } + boolean anyPlayerCloseEnoughTo(BlockPos pos, int radius) { +@@ -976,8 +_,24 @@ + } + private boolean anyPlayerCloseEnoughForSpawningInternal(ChunkPos chunkPos) { + // Spigot start + return this.anyPlayerCloseEnoughForSpawningInternal(chunkPos, false); @@ -227,7 +231,7 @@ return true; } } -@@ -985,7 +_,7 @@ +@@ -993,7 +_,7 @@ Builder builder = ImmutableList.builder(); for (ServerPlayer serverPlayer : this.playerMap.getAllPlayers()) { @@ -236,7 +240,7 @@ builder.add(serverPlayer); } } -@@ -994,12 +_,12 @@ +@@ -1002,12 +_,12 @@ } } @@ -251,7 +255,7 @@ } } -@@ -1121,9 +_,19 @@ +@@ -1138,9 +_,19 @@ } public void addEntity(Entity entity) { @@ -271,7 +275,7 @@ if (i != 0) { int updateInterval = type.updateInterval(); if (this.entityMap.containsKey(entity.getId())) { -@@ -1147,6 +_,7 @@ +@@ -1164,6 +_,7 @@ } protected void removeEntity(Entity entity) { @@ -279,7 +283,7 @@ if (entity instanceof ServerPlayer serverPlayer) { this.updatePlayerStatus(serverPlayer, false); -@@ -1308,10 +_,10 @@ +@@ -1323,10 +_,10 @@ final Entity entity; private final int range; SectionPos lastSectionPos; @@ -292,7 +296,7 @@ this.entity = entity; this.range = range; this.lastSectionPos = SectionPos.of(entity); -@@ -1358,6 +_,7 @@ +@@ -1373,6 +_,7 @@ } public void removePlayer(ServerPlayer player) { @@ -300,7 +304,7 @@ if (this.seenBy.remove(player.connection)) { this.serverEntity.removePairing(player); if (this.seenBy.isEmpty()) { -@@ -1367,23 +_,45 @@ +@@ -1382,23 +_,45 @@ } public void updatePlayer(ServerPlayer player) { @@ -351,7 +355,7 @@ } } else { this.removePlayer(player); -@@ -1400,6 +_,7 @@ +@@ -1415,6 +_,7 @@ for (Entity entity : this.entity.getIndirectPassengers()) { int i1 = entity.getType().clientTrackingRange() * 16; diff --git a/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch b/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch index 8c9d908d0583..0ef527512714 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -74,6 +_,12 @@ +@@ -72,6 +_,12 @@ } if (!this.chunksToUpdateFutures.isEmpty()) { @@ -13,7 +13,7 @@ for (ChunkHolder chunkHolder : this.chunksToUpdateFutures) { chunkHolder.updateHighestAllowedStatus(chunkMap); } -@@ -123,8 +_,10 @@ +@@ -121,8 +_,10 @@ ChunkPos chunkPos = sectionPos.chunk(); long packedChunkPos = chunkPos.toLong(); ObjectSet set = this.playersPerChunk.get(packedChunkPos); diff --git a/paper-server/patches/sources/net/minecraft/server/level/PlayerSpawnFinder.java.patch b/paper-server/patches/sources/net/minecraft/server/level/PlayerSpawnFinder.java.patch index fe2eeb0f53b5..ba090aa9250e 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/PlayerSpawnFinder.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/PlayerSpawnFinder.java.patch @@ -6,6 +6,6 @@ public static CompletableFuture findSpawn(ServerLevel level, BlockPos pos) { - if (level.dimensionType().hasSkyLight() && level.getServer().getWorldData().getGameType() != GameType.ADVENTURE) { + if (level.dimensionType().hasSkyLight() && level.serverLevelData.getGameType() != GameType.ADVENTURE) { // CraftBukkit - int max = Math.max(0, level.getGameRules().getInt(GameRules.RULE_SPAWN_RADIUS)); + int max = Math.max(0, level.getGameRules().get(GameRules.RESPAWN_RADIUS)); int floor = Mth.floor(level.getWorldBorder().getDistanceToBorder(pos.getX(), pos.getZ())); if (floor < max) { diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch index 186c46ecd7cd..90afddb38210 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch @@ -7,11 +7,11 @@ + public boolean spawnFriendlies = true; // Paper - add back spawnFriendlies field private static final int CACHE_SIZE = 4; private final long[] lastChunkPos = new long[4]; - private final ChunkStatus[] lastChunkStatus = new ChunkStatus[4]; -@@ -76,6 +_,13 @@ - @Nullable + private final @Nullable ChunkStatus[] lastChunkStatus = new ChunkStatus[4]; +@@ -75,6 +_,13 @@ + private final Set chunkHoldersToBroadcast = new ReferenceOpenHashSet<>(); @VisibleForDebug - private NaturalSpawner.SpawnState lastSpawnState; + private NaturalSpawner.@Nullable SpawnState lastSpawnState; + // Paper start + public final ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable fullChunks = new ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<>(); + public int getFullChunksCount() { @@ -22,7 +22,7 @@ public ServerChunkCache( ServerLevel level, -@@ -124,6 +_,64 @@ +@@ -123,6 +_,64 @@ this.clearCache(); } @@ -87,7 +87,7 @@ @Override public ThreadedLevelLightEngine getLightEngine() { return this.lightEngine; -@@ -159,7 +_,7 @@ +@@ -156,7 +_,7 @@ for (int i = 0; i < 4; i++) { if (packedChunkPos == this.lastChunkPos[i] && chunkStatus == this.lastChunkStatus[i]) { ChunkAccess chunkAccess = this.lastChunk[i]; @@ -96,7 +96,7 @@ return chunkAccess; } } -@@ -168,6 +_,7 @@ +@@ -165,6 +_,7 @@ profilerFiller.incrementCounter("getChunkCacheMiss"); CompletableFuture> chunkFutureMainThread = this.getChunkFutureMainThread(x, z, chunkStatus, requireChunk); this.mainThreadProcessor.managedBlock(chunkFutureMainThread::isDone); @@ -104,7 +104,7 @@ ChunkResult chunkResult = chunkFutureMainThread.join(); ChunkAccess chunkAccess1 = chunkResult.orElse(null); if (chunkAccess1 == null && requireChunk) { -@@ -239,7 +_,15 @@ +@@ -235,7 +_,15 @@ long packedChunkPos = chunkPos.toLong(); int i = ChunkLevel.byStatus(chunkStatus); ChunkHolder visibleChunkIfPresent = this.getVisibleChunkIfPresent(packedChunkPos); @@ -121,7 +121,7 @@ this.addTicket(new Ticket(TicketType.UNKNOWN, i), chunkPos); if (this.chunkAbsent(visibleChunkIfPresent, i)) { ProfilerFiller profilerFiller = Profiler.get(); -@@ -259,7 +_,7 @@ +@@ -255,7 +_,7 @@ } private boolean chunkAbsent(@Nullable ChunkHolder chunkHolder, int status) { @@ -130,7 +130,7 @@ } @Override -@@ -314,17 +_,39 @@ +@@ -309,17 +_,39 @@ @Override public void close() throws IOException { @@ -172,18 +172,18 @@ this.ticketStorage.purgeStaleTickets(this.chunkMap); } -@@ -380,12 +_,20 @@ +@@ -375,12 +_,20 @@ naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, new LocalMobCapCalculator(this.chunkMap) ); this.lastSpawnState = spawnState; -- boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING); -+ boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit - int _int = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); +- boolean flag = this.level.getGameRules().get(GameRules.SPAWN_MOBS); ++ boolean flag = this.level.getGameRules().get(GameRules.SPAWN_MOBS) && !this.level.players().isEmpty(); // CraftBukkit + int i = this.level.getGameRules().get(GameRules.RANDOM_TICK_SPEED); List filteredSpawningCategories; -- if (_boolean) { -- boolean flag = this.level.getGameTime() % 400L == 0L; -- filteredSpawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnState, true, this.spawnEnemies, flag); -+ if (_boolean && (this.spawnEnemies || this.spawnFriendlies)) { // Paper +- if (flag) { +- boolean flag1 = this.level.getGameTime() % 400L == 0L; +- filteredSpawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnState, true, this.spawnEnemies, flag1); ++ if (flag && (this.spawnEnemies || this.spawnFriendlies)) { // Paper + // Paper start - PlayerNaturallySpawnCreaturesEvent + for (ServerPlayer entityPlayer : this.level.players()) { + int chunkRange = Math.min(level.spigotConfig.mobSpawnRange, entityPlayer.getBukkitEntity().getViewDistance()); @@ -192,12 +192,12 @@ + entityPlayer.playerNaturallySpawnedEvent.callEvent(); + } + // Paper end - PlayerNaturallySpawnCreaturesEvent -+ boolean flag = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit -+ filteredSpawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnState, this.spawnFriendlies, this.spawnEnemies, flag, this.level); // CraftBukkit ++ boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit ++ filteredSpawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnState, this.spawnFriendlies, this.spawnEnemies, flag1, this.level); // CraftBukkit } else { filteredSpawningCategories = List.of(); } -@@ -558,7 +_,13 @@ +@@ -553,7 +_,13 @@ @Override public void setSpawnSettings(boolean spawnSettings) { @@ -211,7 +211,7 @@ } public String getChunkDebugData(ChunkPos chunkPos) { -@@ -631,12 +_,18 @@ +@@ -625,12 +_,18 @@ @Override public boolean pollTask() { diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch index 035b390e4150..d0eb6ed42506 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -65,13 +_,15 @@ +@@ -65,12 +_,14 @@ private Vec3 lastSentMovement; private int tickCount; private int teleportDelay; @@ -8,8 +8,7 @@ + private List lastPassengers = com.google.common.collect.ImmutableList.of(); // Paper - optimize passenger checks private boolean wasRiding; private boolean wasOnGround; - @Nullable - private List> trackedDataValues; + private @Nullable List> trackedDataValues; + private final Set trackedPlayers; // Paper - public ServerEntity(ServerLevel level, Entity entity, int updateInterval, boolean trackDelta, ServerEntity.Synchronizer synchronizer) { @@ -18,7 +17,7 @@ this.level = level; this.synchronizer = synchronizer; this.entity = entity; -@@ -95,16 +_,22 @@ +@@ -94,16 +_,22 @@ new ClientboundSetPassengersPacket(this.entity), serverPlayer1 -> passengers.contains(serverPlayer1) == this.lastPassengers.contains(serverPlayer1) ); @@ -45,7 +44,7 @@ savedData.tickCarriedBy(serverPlayer, item); Packet updatePacket = savedData.getUpdatePacket(mapId, serverPlayer); if (updatePacket != null) { -@@ -137,7 +_,13 @@ +@@ -136,7 +_,13 @@ } else { this.teleportDelay++; Vec3 vec3 = this.entity.trackingPosition(); @@ -60,7 +59,7 @@ Packet packet = null; boolean flag2 = flag1 || this.tickCount % 60 == 0; boolean flag3 = false; -@@ -219,6 +_,25 @@ +@@ -218,6 +_,25 @@ this.tickCount++; if (this.entity.hurtMarked) { @@ -86,7 +85,7 @@ this.entity.hurtMarked = false; this.synchronizer.sendToTrackingPlayersAndSelf(new ClientboundSetEntityMotionPacket(this.entity)); } -@@ -270,7 +_,10 @@ +@@ -269,7 +_,10 @@ public void sendPairingData(ServerPlayer player, Consumer> consumer) { this.entity.updateDataBeforeSync(); if (this.entity.isRemoved()) { @@ -98,7 +97,7 @@ } Packet addEntityPacket = this.entity.getAddEntityPacket(this); -@@ -281,6 +_,11 @@ +@@ -280,6 +_,11 @@ if (this.entity instanceof LivingEntity livingEntity) { Collection syncableAttributes = livingEntity.getAttributes().getSyncableAttributes(); @@ -110,7 +109,7 @@ if (!syncableAttributes.isEmpty()) { consumer.accept(new ClientboundUpdateAttributesPacket(this.entity.getId(), syncableAttributes)); } -@@ -297,8 +_,9 @@ +@@ -296,8 +_,9 @@ } if (!list.isEmpty()) { @@ -121,7 +120,7 @@ } if (!this.entity.getPassengers().isEmpty()) { -@@ -345,6 +_,11 @@ +@@ -344,6 +_,11 @@ if (this.entity instanceof LivingEntity) { Set attributesToSync = ((LivingEntity)this.entity).getAttributes().getAttributesToSync(); if (!attributesToSync.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch index ddcca2e71b07..49697c615f3d 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -9,7 +9,7 @@ final EntityTickList entityTickList = new EntityTickList(); private final ServerWaypointManager waypointManager; public final PersistentEntitySectionManager entityManager; -@@ -217,25 +_,170 @@ +@@ -216,25 +_,170 @@ private final RandomSequences randomSequences; final LevelDebugSynchronizers debugSynchronizers = new LevelDebugSynchronizers(this); @@ -183,7 +183,7 @@ boolean flag = server.forceSynchronousWrites(); DataFixer fixerUpper = server.getFixerUpper(); EntityPersistentStorage entityPersistentStorage = new EntityStorage( -@@ -257,8 +_,8 @@ +@@ -256,8 +_,8 @@ server.getStructureManager(), dispatcher, chunkGenerator, @@ -194,7 +194,7 @@ flag, this.entityManager::updateChunkStatus, () -> server.overworld().getDataStorage() -@@ -277,7 +_,7 @@ +@@ -276,7 +_,7 @@ this.chunkSource.chunkScanner(), this.registryAccess(), server.getStructureManager(), @@ -203,7 +203,7 @@ chunkGenerator, this.chunkSource.randomState(), this, -@@ -285,9 +_,9 @@ +@@ -284,9 +_,9 @@ seed, fixerUpper ); @@ -216,7 +216,7 @@ } else { this.dragonFight = null; } -@@ -296,7 +_,15 @@ +@@ -295,7 +_,15 @@ this.gameEventDispatcher = new GameEventDispatcher(this); this.randomSequences = Objects.requireNonNullElseGet(randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE)); this.waypointManager = new ServerWaypointManager(); @@ -233,7 +233,7 @@ @Deprecated @VisibleForTesting -@@ -308,8 +_,8 @@ +@@ -307,8 +_,8 @@ this.serverLevelData.setClearWeatherTime(clearTime); this.serverLevelData.setRainTime(weatherTime); this.serverLevelData.setThunderTime(weatherTime); @@ -244,10 +244,10 @@ } @Override -@@ -336,12 +_,25 @@ +@@ -335,12 +_,25 @@ - int _int = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); - if (this.sleepStatus.areEnoughSleeping(_int) && this.sleepStatus.areEnoughDeepSleeping(_int, this.players)) { + int i = this.getGameRules().get(GameRules.PLAYERS_SLEEPING_PERCENTAGE); + if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { + // Paper start - create time skip event - move up calculations + final long newDayTime = this.levelData.getDayTime() + 24000L; + org.bukkit.event.world.TimeSkipEvent event = new org.bukkit.event.world.TimeSkipEvent( @@ -256,7 +256,7 @@ + (newDayTime - newDayTime % 24000L) - this.getDayTime() + ); + // Paper end - create time skip event - move up calculations - if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { + if (this.getGameRules().get(GameRules.ADVANCE_TIME)) { - long l = this.levelData.getDayTime() + 24000L; - this.setDayTime(l - l % 24000L); + // Paper start - call time skip event if gamerule is enabled @@ -270,10 +270,10 @@ - this.wakeUpAllPlayers(); + if (!event.isCancelled()) this.wakeUpAllPlayers(); // Paper - only wake up players if time skip event is not cancelled - if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { + if (this.getGameRules().get(GameRules.ADVANCE_WEATHER) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -356,9 +_,9 @@ +@@ -355,9 +_,9 @@ if (!this.isDebug() && runsNormally) { long l = this.getGameTime(); profilerFiller.push("blockTicks"); @@ -285,7 +285,7 @@ profilerFiller.pop(); } -@@ -376,7 +_,7 @@ +@@ -375,7 +_,7 @@ this.handlingTick = false; profilerFiller.pop(); @@ -294,7 +294,7 @@ if (hasActiveTickets) { this.resetEmptyTime(); } -@@ -484,11 +_,13 @@ +@@ -483,11 +_,13 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("iceandsnow"); @@ -308,7 +308,7 @@ profilerFiller.popPush("tickBlocks"); if (randomTickSpeed > 0) { -@@ -531,12 +_,12 @@ +@@ -530,12 +_,12 @@ int minBlockZ = pos.getMinBlockZ(); ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("thunder"); @@ -317,13 +317,13 @@ BlockPos blockPos = this.findLightningTargetAround(this.getBlockRandomPos(minBlockX, 0, minBlockZ, 15)); if (this.isRainingAt(blockPos)) { DifficultyInstance currentDifficultyAt = this.getCurrentDifficultyAt(blockPos); - boolean flag = this.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) + boolean flag = this.getGameRules().get(GameRules.SPAWN_MOBS) - && this.random.nextDouble() < currentDifficultyAt.getEffectiveDifficulty() * 0.01 + && this.random.nextDouble() < currentDifficultyAt.getEffectiveDifficulty() * this.paperConfig().entities.spawning.skeletonHorseThunderSpawnChance.or(0.01) // Paper - Configurable spawn chances for skeleton horses && !this.getBlockState(blockPos.below()).is(BlockTags.LIGHTNING_RODS); if (flag) { SkeletonHorse skeletonHorse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT); -@@ -544,7 +_,7 @@ +@@ -543,7 +_,7 @@ skeletonHorse.setTrap(true); skeletonHorse.setAge(0); skeletonHorse.setPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()); @@ -332,7 +332,7 @@ } } -@@ -552,7 +_,7 @@ +@@ -551,7 +_,7 @@ if (lightningBolt != null) { lightningBolt.snapTo(Vec3.atBottomCenterOf(blockPos)); lightningBolt.setVisualOnly(flag); @@ -341,7 +341,7 @@ } } } -@@ -566,7 +_,7 @@ +@@ -565,7 +_,7 @@ BlockPos blockPos = heightmapPos.below(); Biome biome = this.getBiome(heightmapPos).value(); if (biome.shouldFreeze(this, blockPos)) { @@ -350,8 +350,8 @@ } if (this.isRaining()) { -@@ -578,10 +_,10 @@ - if (layersValue < Math.min(_int, 8)) { +@@ -577,10 +_,10 @@ + if (layersValue < Math.min(i, 8)) { BlockState blockState1 = blockState.setValue(SnowLayerBlock.LAYERS, layersValue + 1); Block.pushEntitiesUp(blockState, blockState1, this, heightmapPos); - this.setBlockAndUpdate(heightmapPos, blockState1); @@ -363,7 +363,7 @@ } } -@@ -606,6 +_,12 @@ +@@ -605,6 +_,12 @@ } protected BlockPos findLightningTargetAround(BlockPos pos) { @@ -376,12 +376,12 @@ BlockPos heightmapPos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos); Optional optional = this.findLightningRod(heightmapPos); if (optional.isPresent()) { -@@ -613,11 +_,12 @@ +@@ -612,11 +_,12 @@ } else { AABB aabb = AABB.encapsulatingFullBlocks(heightmapPos, heightmapPos.atY(this.getMaxY() + 1)).inflate(3.0); List entitiesOfClass = this.getEntitiesOfClass( -- LivingEntity.class, aabb, entity -> entity != null && entity.isAlive() && this.canSeeSky(entity.blockPosition()) -+ LivingEntity.class, aabb, entity -> entity != null && entity.isAlive() && this.canSeeSky(entity.blockPosition()) && !entity.isSpectator() // Paper - Fix lightning being able to hit spectators (MC-262422) +- LivingEntity.class, aabb, entity -> entity.isAlive() && this.canSeeSky(entity.blockPosition()) ++ LivingEntity.class, aabb, entity -> entity.isAlive() && this.canSeeSky(entity.blockPosition()) && !entity.isSpectator() // Paper - Fix lightning being able to hit spectators (MC-262422) ); if (!entitiesOfClass.isEmpty()) { return entitiesOfClass.get(this.random.nextInt(entitiesOfClass.size())).blockPosition(); @@ -390,7 +390,7 @@ if (heightmapPos.getY() == this.getMinY() - 1) { heightmapPos = heightmapPos.above(2); } -@@ -721,8 +_,8 @@ +@@ -720,8 +_,8 @@ this.serverLevelData.setThunderTime(thunderTime); this.serverLevelData.setRainTime(rainTime); this.serverLevelData.setClearWeatherTime(clearWeatherTime); @@ -401,7 +401,7 @@ } this.oThunderLevel = this.thunderLevel; -@@ -743,6 +_,7 @@ +@@ -742,6 +_,7 @@ this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -409,7 +409,7 @@ if (this.oRainLevel != this.rainLevel) { this.server .getPlayerList() -@@ -765,14 +_,47 @@ +@@ -764,14 +_,47 @@ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -461,7 +461,7 @@ } public void resetEmptyTime() { -@@ -794,18 +_,46 @@ +@@ -793,18 +_,46 @@ } } @@ -508,7 +508,7 @@ } private void tickPassenger(Entity ridingEntity, Entity passengerEntity) { -@@ -814,10 +_,12 @@ +@@ -813,10 +_,12 @@ } else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) { passengerEntity.setOldPosAndRot(); passengerEntity.tickCount++; @@ -521,7 +521,7 @@ profilerFiller.pop(); for (Entity entity : passengerEntity.getPassengers()) { -@@ -848,6 +_,7 @@ +@@ -847,6 +_,7 @@ public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) { ServerChunkCache chunkSource = this.getChunkSource(); if (!skipSave) { @@ -529,7 +529,7 @@ if (progress != null) { progress.progressStartNoAbort(Component.translatable("menu.savingLevel")); } -@@ -864,11 +_,18 @@ +@@ -863,11 +_,18 @@ this.entityManager.autoSave(); } } @@ -549,7 +549,7 @@ } DimensionDataStorage dataStorage = this.getChunkSource().getDataStorage(); -@@ -933,18 +_,40 @@ +@@ -931,18 +_,40 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -559,7 +559,7 @@ + } + + @Override -+ public boolean addFreshEntity(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ public boolean addFreshEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason reason) { + return this.addEntity(entity, reason); + // CraftBukkit end } @@ -570,7 +570,7 @@ + return this.addWithUUID(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + -+ public boolean addWithUUID(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ public boolean addWithUUID(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason reason) { + return this.addEntity(entity, reason); + // CraftBukkit end } @@ -583,7 +583,7 @@ + this.addDuringTeleport(entity, null); + } + -+ public void addDuringTeleport(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ public void addDuringTeleport(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason reason) { + // CraftBukkit end if (entity instanceof ServerPlayer serverPlayer) { this.addPlayer(serverPlayer); @@ -593,13 +593,13 @@ } } -@@ -967,41 +_,120 @@ +@@ -965,41 +_,120 @@ this.entityManager.addNewEntity(player); } - private boolean addEntity(Entity entity) { + // CraftBukkit start -+ private boolean addEntity(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { ++ private boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason spawnReason) { + org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot + entity.generation = false; // Paper - Don't fire sync event during generation; Reset flag if it was added during a ServerLevel generation process + // Paper start - extra debug info @@ -707,7 +707,7 @@ + } + // Paper end - Add BlockBreakProgressUpdateEvent for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) { - if (serverPlayer != null && serverPlayer.level() == this && serverPlayer.getId() != breakerId) { + if (serverPlayer.level() == this && serverPlayer.getId() != breakerId) { double d = pos.getX() - serverPlayer.getX(); double d1 = pos.getY() - serverPlayer.getY(); double d2 = pos.getZ() - serverPlayer.getZ(); @@ -719,7 +719,7 @@ if (d * d + d1 * d1 + d2 * d2 < 1024.0) { serverPlayer.connection.send(new ClientboundBlockDestructionPacket(breakerId, pos, progress)); } -@@ -1076,7 +_,7 @@ +@@ -1074,7 +_,7 @@ pos.getX(), pos.getY(), pos.getZ(), @@ -728,7 +728,7 @@ this.dimension(), new ClientboundLevelEventPacket(type, pos, data, false) ); -@@ -1088,6 +_,11 @@ +@@ -1086,6 +_,11 @@ @Override public void gameEvent(Holder gameEvent, Vec3 pos, GameEvent.Context context) { @@ -740,7 +740,7 @@ this.gameEventDispatcher.post(gameEvent, pos, context); } -@@ -1100,17 +_,28 @@ +@@ -1098,17 +_,28 @@ this.getChunkSource().blockChanged(pos); this.pathTypesByPosCache.invalidate(pos); @@ -769,7 +769,7 @@ try { this.isUpdatingNavigations = true; -@@ -1122,15 +_,23 @@ +@@ -1120,15 +_,23 @@ this.isUpdatingNavigations = false; } } @@ -793,7 +793,7 @@ this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, block, null, orientation); } -@@ -1180,6 +_,44 @@ +@@ -1178,6 +_,44 @@ WeightedList blockParticles, Holder explosionSound ) { @@ -832,15 +832,15 @@ + ParticleOptions largeExplosionParticles, + WeightedList blockParticles, + Holder explosionSound, -+ @Nullable java.util.function.Consumer configurator ++ java.util.function.@Nullable Consumer configurator + ) { + // CraftBukkit end Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) { case NONE -> Explosion.BlockInteraction.KEEP; - case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); -@@ -1188,10 +_,17 @@ + case BLOCK -> this.getDestroyType(GameRules.BLOCK_EXPLOSION_DROP_DECAY); +@@ -1186,10 +_,17 @@ : Explosion.BlockInteraction.KEEP; - case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY); + case TNT -> this.getDestroyType(GameRules.TNT_EXPLOSION_DROP_DECAY); case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; + case STANDARD -> Explosion.BlockInteraction.DESTROY; // CraftBukkit - handle custom explosion type }; @@ -856,7 +856,7 @@ ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles; for (ServerPlayer serverPlayer : this.players) { -@@ -1200,6 +_,8 @@ +@@ -1198,6 +_,8 @@ serverPlayer.connection.send(new ClientboundExplodePacket(vec3, radius, i, optional, particleOptions, explosionSound, blockParticles)); } } @@ -864,8 +864,8 @@ + return serverExplosion; // CraftBukkit } - private Explosion.BlockInteraction getDestroyType(GameRules.Key decayGameRule) { -@@ -1270,19 +_,55 @@ + private Explosion.BlockInteraction getDestroyType(GameRule decayGameRule) { +@@ -1267,19 +_,55 @@ public int sendParticles( T options, double x, double y, double z, int count, double xDist, double yDist, double zDist, double speed ) { @@ -924,19 +924,19 @@ if (this.sendParticles(serverPlayer, overrideLimiter, x, y, z, clientboundLevelParticlesPacket)) { i++; } -@@ -1371,7 +_,7 @@ +@@ -1363,7 +_,7 @@ + } - @Nullable - public BlockPos findNearestMapStructure(TagKey structureTag, BlockPos pos, int radius, boolean skipKnownStructures) { + public @Nullable BlockPos findNearestMapStructure(TagKey structureTag, BlockPos pos, int radius, boolean skipKnownStructures) { - if (!this.server.getWorldData().worldGenOptions().generateStructures()) { + if (!this.serverLevelData.worldGenOptions().generateStructures()) { // CraftBukkit return null; } else { Optional> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag); -@@ -1425,10 +_,36 @@ - @Nullable +@@ -1415,10 +_,36 @@ + @Override - public MapItemSavedData getMapData(MapId mapId) { + public @Nullable MapItemSavedData getMapData(MapId mapId) { - return this.getServer().overworld().getDataStorage().get(MapItemSavedData.type(mapId)); + // Paper start - Call missing map initialize event and set id + final DimensionDataStorage storage = this.getServer().overworld().getDataStorage(); @@ -971,7 +971,7 @@ this.getServer().overworld().getDataStorage().set(MapItemSavedData.type(mapId), data); } -@@ -1438,7 +_,19 @@ +@@ -1428,7 +_,19 @@ @Override public void setRespawnData(LevelData.RespawnData respawnData) { @@ -992,7 +992,7 @@ } @Override -@@ -1475,6 +_,11 @@ +@@ -1465,6 +_,11 @@ this.debugSynchronizers.dropPoi(blockPos); })); optional1.ifPresent(holder -> this.getServer().execute(() -> { @@ -1004,7 +1004,7 @@ PoiRecord poiRecord = this.getPoiManager().add(blockPos, (Holder)holder); if (poiRecord != null) { this.debugSynchronizers.registerPoi(poiRecord); -@@ -1629,12 +_,12 @@ +@@ -1618,12 +_,12 @@ } public boolean isFlat() { @@ -1018,8 +1018,8 @@ + return this.serverLevelData.worldGenOptions().seed(); // CraftBukkit } - @Nullable -@@ -1685,6 +_,7 @@ + public @Nullable EndDragonFight getDragonFight() { +@@ -1673,6 +_,7 @@ @Override public LevelEntityGetter getEntities() { @@ -1027,13 +1027,13 @@ return this.entityManager.getEntityGetter(); } -@@ -1795,6 +_,28 @@ +@@ -1788,6 +_,28 @@ return this.serverLevelData.getGameRules(); } + // Paper start - respect global sound events gamerule + public List getPlayersForGlobalSoundGamerule() { -+ return this.getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) ? ((ServerLevel) this).getServer().getPlayerList().players : ((ServerLevel) this).players(); ++ return this.getGameRules().get(GameRules.GLOBAL_SOUND_EVENTS) ? ((ServerLevel) this).getServer().getPlayerList().players : ((ServerLevel) this).players(); + } + + public double getGlobalSoundRangeSquared(java.util.function.Function rangeFunction) { @@ -1056,7 +1056,7 @@ @Override public CrashReportCategory fillReportDetails(CrashReport report) { CrashReportCategory crashReportCategory = super.fillReportDetails(report); -@@ -1839,6 +_,7 @@ +@@ -1832,6 +_,7 @@ if (entity instanceof WaypointTransmitter waypointTransmitter && waypointTransmitter.isTransmittingWaypoint()) { ServerLevel.this.getWaypointManager().trackWaypoint(waypointTransmitter); } @@ -1064,7 +1064,7 @@ } @Override -@@ -1852,17 +_,24 @@ +@@ -1845,17 +_,24 @@ @Override public void onTickingStart(Entity entity) { @@ -1090,7 +1090,7 @@ if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.add(serverPlayer); if (serverPlayer.isReceivingWaypoints()) { -@@ -1877,7 +_,7 @@ +@@ -1870,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1099,7 +1099,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1894,10 +_,52 @@ +@@ -1887,10 +_,52 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -1152,7 +1152,7 @@ ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); -@@ -1906,7 +_,7 @@ +@@ -1899,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1161,7 +1161,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1924,6 +_,15 @@ +@@ -1917,6 +_,15 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); ServerLevel.this.debugSynchronizers.dropEntity(entity); @@ -1177,7 +1177,7 @@ } @Override -@@ -1931,4 +_,24 @@ +@@ -1924,4 +_,24 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::move); } } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index dfbf4b288b5d..c1715ea0d357 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -257,7 +_,8 @@ +@@ -255,7 +_,8 @@ private int levitationStartTime; private boolean disconnected; private int requestedViewDistance = 2; - public String language = "en_us"; + public String language = null; // Paper - default to null + public java.util.Locale adventure$locale = java.util.Locale.US; // Paper - @Nullable - private Vec3 startingToFallPosition; - @Nullable -@@ -306,6 +_,13 @@ + private @Nullable Vec3 startingToFallPosition; + private @Nullable Vec3 enteredNetherPosition; + private @Nullable Vec3 enteredLavaOnVehiclePosition; +@@ -299,6 +_,13 @@ } } @@ -24,7 +24,7 @@ @Override public void sendSlotChange(AbstractContainerMenu container, int slot, ItemStack stack) { ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(container.containerId, container.incrementStateId(), slot, stack)); -@@ -341,6 +_,32 @@ +@@ -334,6 +_,32 @@ } } @@ -57,7 +57,7 @@ @Override public void dataChanged(AbstractContainerMenu containerMenu, int dataSlotIndex, int value) { } -@@ -369,10 +_,43 @@ +@@ -360,10 +_,43 @@ public void sendSystemMessage(Component message) { ServerPlayer.this.sendSystemMessage(message); } @@ -77,7 +77,7 @@ + public int patrolSpawnDelay; // Paper - Pillager patrol spawn settings and per player options + // Paper start - cancellable death event + public boolean queueHealthUpdatePacket; -+ public @Nullable net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; ++ public net.minecraft.network.protocol.game.@Nullable ClientboundSetHealthPacket queuedHealthUpdatePacket; + // Paper end - cancellable death event + // CraftBukkit start + public @Nullable String lastKnownName; // Better rename detection @@ -96,12 +96,12 @@ + public boolean suppressTrackerForLogin = false; // Paper - Fire PlayerJoinEvent when Player is actually ready + // CraftBukkit end + public boolean isRealPlayer; // Paper -+ public @Nullable com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent -+ public @Nullable 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 ++ public com.destroystokyo.paper.event.entity.@Nullable PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent ++ public org.bukkit.event.player.PlayerQuitEvent.@Nullable 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 public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) { super(level, gameProfile); -@@ -383,8 +_,14 @@ +@@ -374,8 +_,14 @@ this.recipeBook = new ServerRecipeBook((recipe, output) -> server.getRecipeManager().listDisplaysForRecipe(recipe, output)); this.stats = server.getPlayerList().getPlayerStats(this); this.advancements = server.getPlayerList().getPlayerAdvancements(this); @@ -117,7 +117,7 @@ } @Override -@@ -402,6 +_,7 @@ +@@ -393,6 +_,7 @@ this.seenCredits = input.getBooleanOr("seenCredits", false); input.read("recipeBook", ServerRecipeBook.Packed.CODEC) .ifPresent(packed -> this.recipeBook.loadUntrusted(packed, key -> this.server.getRecipeManager().byKey(key).isPresent())); @@ -125,7 +125,7 @@ if (this.isSleeping()) { this.stopSleeping(); } -@@ -409,6 +_,19 @@ +@@ -400,6 +_,19 @@ this.respawnConfig = input.read("respawn", ServerPlayer.RespawnConfig.CODEC).orElse(null); this.spawnExtraParticlesOnFall = input.getBooleanOr("spawn_extra_particles_on_fall", false); this.raidOmenPosition = input.read("raid_omen_position", BlockPos.CODEC).orElse(null); @@ -145,7 +145,7 @@ this.gameMode .setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(input, "playerGameType")), readPlayerMode(input, "previousPlayerGameType")); this.setShoulderEntityLeft(input.read("ShoulderEntityLeft", CompoundTag.CODEC).orElseGet(CompoundTag::new)); -@@ -436,12 +_,24 @@ +@@ -427,12 +_,24 @@ if (!this.getShoulderEntityRight().isEmpty()) { output.store("ShoulderEntityRight", CompoundTag.CODEC, this.getShoulderEntityRight()); } @@ -171,7 +171,7 @@ ValueOutput valueOutput = output.child("RootVehicle"); valueOutput.store("Attach", UUIDUtil.CODEC, vehicle.getUUID()); rootVehicle.save(valueOutput.child("Entity")); -@@ -453,7 +_,7 @@ +@@ -444,7 +_,7 @@ if (!optional.isEmpty()) { ServerLevel serverLevel = this.level(); Entity entity = EntityType.loadEntityRecursive( @@ -180,7 +180,7 @@ ); if (entity != null) { UUID uuid = optional.get().read("Attach", UUIDUtil.CODEC).orElse(null); -@@ -470,10 +_,10 @@ +@@ -461,10 +_,10 @@ if (!this.isPassenger()) { LOGGER.warn("Couldn't reattach entity to player"); @@ -193,7 +193,7 @@ } } } -@@ -485,6 +_,7 @@ +@@ -476,6 +_,7 @@ ValueOutput.ValueOutputList valueOutputList = output.childrenList("ender_pearls"); for (ThrownEnderpearl thrownEnderpearl : this.enderPearls) { @@ -201,7 +201,7 @@ if (thrownEnderpearl.isRemoved()) { LOGGER.warn("Trying to save removed ender pearl, skipping"); } else { -@@ -517,6 +_,16 @@ +@@ -508,6 +_,16 @@ } } @@ -218,7 +218,7 @@ public void setExperiencePoints(int experiencePoints) { float f = this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -581,6 +_,11 @@ +@@ -572,6 +_,11 @@ @Override public void tick() { @@ -230,7 +230,7 @@ this.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); -@@ -588,9 +_,18 @@ +@@ -579,9 +_,18 @@ this.invulnerableTime--; } @@ -252,7 +252,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -649,10 +_,10 @@ +@@ -640,10 +_,10 @@ public void doTick() { try { @@ -265,7 +265,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -682,7 +_,7 @@ +@@ -673,7 +_,7 @@ if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -274,7 +274,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -713,6 +_,12 @@ +@@ -704,6 +_,12 @@ this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float)this.lastRecordedExperience)); } @@ -287,7 +287,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float)this.lastRecordedLevel)); -@@ -726,6 +_,21 @@ +@@ -717,6 +_,21 @@ if (this.tickCount % 20 == 0) { CriteriaTriggers.LOCATION.trigger(this); } @@ -309,8 +309,8 @@ } catch (Throwable var4) { CrashReport crashReport = CrashReport.forThrowable(var4, "Ticking player"); CrashReportCategory crashReportCategory = crashReport.addCategory("Player being ticked"); -@@ -750,7 +_,7 @@ - if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { +@@ -741,7 +_,7 @@ + if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.level().getGameRules().get(GameRules.NATURAL_HEALTH_REGENERATION)) { if (this.tickCount % 20 == 0) { if (this.getHealth() < this.getMaxHealth()) { - this.heal(1.0F); @@ -318,7 +318,7 @@ } float saturationLevel = this.foodData.getSaturationLevel(); -@@ -770,6 +_,7 @@ +@@ -761,6 +_,7 @@ this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft()); this.playShoulderEntityAmbientSound(this.getShoulderEntityRight()); if (this.fallDistance > 0.5 || this.isInWater() || this.getAbilities().flying || this.isSleeping() || this.isInPowderSnow) { @@ -326,7 +326,7 @@ this.removeEntitiesOnShoulder(); } } -@@ -814,35 +_,64 @@ +@@ -805,35 +_,64 @@ @Override public void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { @@ -398,7 +398,7 @@ } @Override -@@ -879,15 +_,36 @@ +@@ -870,15 +_,36 @@ } private void updateScoreForCriteria(ObjectiveCriteria criteria, int points) { @@ -408,8 +408,8 @@ - @Override - public void die(DamageSource damageSource) { - this.gameEvent(GameEvent.ENTITY_DIE); -- boolean _boolean = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); -- if (_boolean) { +- boolean flag = this.level().getGameRules().get(GameRules.SHOW_DEATH_MESSAGES); +- if (flag) { - Component deathMessage = this.getCombatTracker().getDeathMessage(); + this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteria, this, scoreAccess -> scoreAccess.set(points)); // CraftBukkit - Use our scores instead + } @@ -444,7 +444,7 @@ this.connection .send( new ClientboundPlayerCombatKillPacket(this.getId(), deathMessage), -@@ -904,6 +_,65 @@ +@@ -895,6 +_,65 @@ } ) ); @@ -456,13 +456,13 @@ + @Override + public void die(DamageSource damageSource) { + // this.gameEvent(GameEvent.ENTITY_DIE); // Paper - move below event cancellation check -+ boolean _boolean = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); final boolean showDeathMessage = _boolean; // Paper - OBFHELPER ++ boolean flag = this.level().getGameRules().get(GameRules.SHOW_DEATH_MESSAGES); final boolean showDeathMessage = flag; // Paper - OBFHELPER + // CraftBukkit start - fire PlayerDeathEvent + if (this.isRemoved()) { + return; + } + List loot = new java.util.ArrayList<>(this.getInventory().getContainerSize()); // Paper - Restore vanilla drops behavior -+ boolean keepInventory = this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator(); ++ boolean keepInventory = this.level().getGameRules().get(GameRules.KEEP_INVENTORY) || this.isSpectator(); + if (!keepInventory) { + for (ItemStack item : this.getInventory().getContents()) { + if (!item.isEmpty() && !EnchantmentHelper.has(item, net.minecraft.world.item.enchantment.EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) { @@ -510,7 +510,7 @@ Team team = this.getTeam(); if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) { this.server.getPlayerList().broadcastSystemMessage(deathMessage, false); -@@ -913,7 +_,7 @@ +@@ -904,7 +_,7 @@ this.server.getPlayerList().broadcastSystemToAllExceptTeam(this, deathMessage); } } else { @@ -519,7 +519,7 @@ } this.removeEntitiesOnShoulder(); -@@ -921,11 +_,35 @@ +@@ -912,11 +_,35 @@ this.tellNeutralMobsThatIDied(); } @@ -558,7 +558,7 @@ LivingEntity killCredit = this.getKillCredit(); if (killCredit != null) { this.awardStat(Stats.ENTITY_KILLED_BY.get(killCredit.getType())); -@@ -959,10 +_,10 @@ +@@ -950,10 +_,10 @@ if (entity != this) { super.awardKillScore(entity, damageSource); Scoreboard scoreboard = this.level().getScoreboard(); @@ -571,7 +571,7 @@ } else { this.awardStat(Stats.MOB_KILLS); } -@@ -974,12 +_,11 @@ +@@ -965,12 +_,11 @@ } private void handleTeamKill(ScoreHolder scoreHolder, ScoreHolder teamMember, ObjectiveCriteria[] criteria) { @@ -586,7 +586,7 @@ } } } -@@ -990,9 +_,20 @@ +@@ -981,9 +_,20 @@ return false; } else { Entity entity = damageSource.getEntity(); @@ -609,7 +609,7 @@ } } -@@ -1002,25 +_,95 @@ +@@ -993,25 +_,95 @@ } private boolean isPvpAllowed() { @@ -713,7 +713,7 @@ } public boolean isReceivingWaypoints() { -@@ -1055,14 +_,16 @@ +@@ -1046,14 +_,16 @@ && (flag || blockState.getValue(RespawnAnchorBlock.CHARGE) > 0) && RespawnAnchorBlock.canSetSpawn(level, blockPos)) { Optional optional = RespawnAnchorBlock.findStandUpPosition(EntityType.PLAYER, level, blockPos); @@ -733,7 +733,7 @@ } else if (!flag) { return Optional.empty(); } else { -@@ -1070,7 +_,7 @@ +@@ -1061,7 +_,7 @@ BlockState blockState1 = level.getBlockState(blockPos.above()); boolean isPossibleToRespawnInThis1 = blockState1.getBlock().isPossibleToRespawnInThis(blockState1); return isPossibleToRespawnInThis && isPossibleToRespawnInThis1 @@ -742,15 +742,15 @@ : Optional.empty(); } } -@@ -1088,6 +_,7 @@ - @Nullable +@@ -1078,6 +_,7 @@ + @Override - public ServerPlayer teleport(TeleportTransition teleportTransition) { + public @Nullable ServerPlayer teleport(TeleportTransition teleportTransition) { + if (this.isSleeping()) return null; // CraftBukkit - SPIGOT-3154 if (this.isRemoved()) { return null; } else { -@@ -1097,13 +_,48 @@ +@@ -1087,13 +_,48 @@ ServerLevel level = teleportTransition.newLevel(); ServerLevel serverLevel = this.level(); @@ -802,7 +802,7 @@ this.connection.resetPosition(); teleportTransition.postTeleportTransition().onTransition(this); return this; -@@ -1114,18 +_,19 @@ +@@ -1104,18 +_,19 @@ this.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); PlayerList playerList = this.server.getPlayerList(); playerList.sendPlayerPermissionLevel(this); @@ -824,7 +824,7 @@ this.connection.resetPosition(); level.addDuringTeleport(this); profilerFiller.pop(); -@@ -1140,6 +_,15 @@ +@@ -1130,6 +_,15 @@ this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(teleportTransition, serverLevel); @@ -840,7 +840,7 @@ return this; } } -@@ -1154,12 +_,26 @@ +@@ -1144,12 +_,26 @@ public void triggerDimensionChangeTriggers(ServerLevel level) { ResourceKey resourceKey = level.dimension(); ResourceKey resourceKey1 = this.level().dimension(); @@ -870,7 +870,7 @@ this.enteredNetherPosition = null; } } -@@ -1175,9 +_,8 @@ +@@ -1165,9 +_,8 @@ this.containerMenu.broadcastChanges(); } @@ -882,7 +882,7 @@ if (!this.isSleeping() && this.isAlive()) { BedRule bedRule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, bedPos); boolean canSleep = bedRule.canSleep(this.level()); -@@ -1191,7 +_,7 @@ +@@ -1181,7 +_,7 @@ } else { if (canSetSpawn) { this.setRespawnPosition( @@ -891,7 +891,7 @@ ); } -@@ -1213,7 +_,37 @@ +@@ -1203,7 +_,37 @@ } } @@ -930,7 +930,7 @@ this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1223,10 +_,7 @@ +@@ -1213,10 +_,7 @@ this.level().updateSleepingPlayerList(); return either; @@ -941,7 +941,7 @@ } } -@@ -1252,21 +_,29 @@ +@@ -1242,21 +_,29 @@ @Override public void stopSleepInBed(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) { @@ -974,7 +974,7 @@ } @Override -@@ -1314,8 +_,9 @@ +@@ -1304,8 +_,9 @@ this.connection.send(new ClientboundShowDialogPacket(dialog)); } @@ -985,7 +985,7 @@ } @Override -@@ -1323,12 +_,39 @@ +@@ -1313,12 +_,39 @@ if (menu == null) { return OptionalInt.empty(); } else { @@ -1026,7 +1026,7 @@ if (abstractContainerMenu == null) { if (this.isSpectator()) { this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true); -@@ -1336,10 +_,14 @@ +@@ -1326,10 +_,14 @@ return OptionalInt.empty(); } else { @@ -1043,7 +1043,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1352,14 +_,25 @@ +@@ -1342,14 +_,25 @@ @Override public void openHorseInventory(AbstractHorse horse, Container inventory) { @@ -1072,7 +1072,7 @@ this.initMenu(this.containerMenu); } -@@ -1381,10 +_,30 @@ +@@ -1371,10 +_,30 @@ @Override public void closeContainer() { @@ -1103,7 +1103,7 @@ @Override public void doCloseContainer() { this.containerMenu.removed(this); -@@ -1407,19 +_,19 @@ +@@ -1397,19 +_,19 @@ int rounded = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); if (rounded > 0) { this.awardStat(Stats.SWIM_ONE_CM, rounded); @@ -1126,7 +1126,7 @@ } } else if (this.onClimbable()) { if (dy > 0.0) { -@@ -1430,13 +_,13 @@ +@@ -1420,13 +_,13 @@ if (rounded > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, rounded); @@ -1143,7 +1143,7 @@ } } } else if (this.isFallFlying()) { -@@ -1478,13 +_,13 @@ +@@ -1470,13 +_,13 @@ @Override public void awardStat(Stat stat, int amount) { this.stats.increment(this, stat, amount); @@ -1159,7 +1159,7 @@ } @Override -@@ -1515,9 +_,9 @@ +@@ -1507,9 +_,9 @@ super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1171,7 +1171,7 @@ } } -@@ -1532,6 +_,13 @@ +@@ -1524,6 +_,13 @@ public void disconnect() { this.disconnected = true; this.ejectPassengers(); @@ -1185,7 +1185,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, false); } -@@ -1543,6 +_,7 @@ +@@ -1535,6 +_,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1193,7 +1193,7 @@ } @Override -@@ -1577,12 +_,12 @@ +@@ -1569,12 +_,12 @@ this.onUpdateAbilities(); if (keepEverything) { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1208,16 +1208,16 @@ } this.getInventory().replaceWith(that.getInventory()); -@@ -1593,7 +_,7 @@ +@@ -1585,7 +_,7 @@ this.portalProcess = that.portalProcess; } else { this.getAttributes().assignBaseValues(that.getAttributes()); - this.setHealth(this.getMaxHealth()); + // this.setHealth(this.getMaxHealth()); // CraftBukkit - if (this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || that.isSpectator()) { + if (this.level().getGameRules().get(GameRules.KEEP_INVENTORY) || that.isSpectator()) { this.getInventory().replaceWith(that.getInventory()); this.experienceLevel = that.experienceLevel; -@@ -1609,7 +_,7 @@ +@@ -1601,7 +_,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1226,7 +1226,7 @@ this.seenCredits = that.seenCredits; this.enteredNetherPosition = that.enteredNetherPosition; this.chunkTrackingView = that.chunkTrackingView; -@@ -1652,9 +_,22 @@ +@@ -1644,9 +_,22 @@ CriteriaTriggers.EFFECTS_CHANGED.trigger(this, null); } @@ -1250,7 +1250,7 @@ } @Override -@@ -1663,7 +_,7 @@ +@@ -1655,7 +_,7 @@ } @Override @@ -1259,7 +1259,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, true); } -@@ -1672,7 +_,7 @@ +@@ -1664,7 +_,7 @@ this.setCamera(this); } @@ -1268,7 +1268,7 @@ if (flag) { this.setYHeadRot(relativeMovements.contains(Relative.Y_ROT) ? this.getYHeadRot() + yaw : yaw); this.connection.resetFlyingTicks(); -@@ -1711,9 +_,19 @@ +@@ -1703,9 +_,18 @@ } public boolean setGameMode(GameType gameMode) { @@ -1276,8 +1276,7 @@ + org.bukkit.event.player.PlayerGameModeChangeEvent event = this.setGameMode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.UNKNOWN, null); + return event != null && !event.isCancelled(); + } -+ @Nullable -+ public org.bukkit.event.player.PlayerGameModeChangeEvent setGameMode(GameType gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause cause, @Nullable net.kyori.adventure.text.Component message) { ++ public org.bukkit.event.player.@Nullable PlayerGameModeChangeEvent setGameMode(GameType gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause cause, net.kyori.adventure.text.@Nullable Component message) { boolean isSpectator = this.isSpectator(); - if (!this.gameMode.changeGameModeForPlayer(gameMode)) { - return false; @@ -1290,7 +1289,7 @@ } else { this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, gameMode.getId())); if (gameMode == GameType.SPECTATOR) { -@@ -1729,7 +_,7 @@ +@@ -1721,7 +_,7 @@ this.onUpdateAbilities(); this.updateEffectVisibility(); @@ -1299,7 +1298,7 @@ } } -@@ -1785,8 +_,13 @@ +@@ -1776,8 +_,13 @@ } public void sendChatMessage(OutgoingChatMessage message, boolean filtered, ChatType.Bound boundChatType) { @@ -1314,7 +1313,7 @@ } } -@@ -1797,7 +_,42 @@ +@@ -1788,7 +_,42 @@ } public void updateOptions(ClientInformation clientInformation) { @@ -1357,7 +1356,7 @@ this.requestedViewDistance = clientInformation.viewDistance(); this.chatVisibility = clientInformation.chatVisibility(); this.canChatColor = clientInformation.chatColors(); -@@ -1883,8 +_,23 @@ +@@ -1874,8 +_,23 @@ Entity camera = this.getCamera(); this.camera = (Entity)(entityToSpectate == null ? this : entityToSpectate); if (camera != this.camera) { @@ -1382,10 +1381,10 @@ } if (entityToSpectate != null) { -@@ -1918,11 +_,11 @@ +@@ -1908,11 +_,11 @@ + } - @Nullable - public Component getTabListDisplayName() { + public @Nullable Component getTabListDisplayName() { - return null; + return this.listName; // CraftBukkit } @@ -1396,17 +1395,17 @@ } @Override -@@ -1953,11 +_,62 @@ +@@ -1942,11 +_,62 @@ } - public void setRespawnPosition(@Nullable ServerPlayer.RespawnConfig respawnConfig, boolean displayInChat) { + public void setRespawnPosition(ServerPlayer.@Nullable RespawnConfig respawnConfig, boolean displayInChat) { - if (displayInChat && respawnConfig != null && !respawnConfig.isSamePosition(this.respawnConfig)) { - this.sendSystemMessage(SPAWN_SET_MESSAGE); + // Paper start - Add PlayerSetSpawnEvent + this.setRespawnPosition(respawnConfig, displayInChat, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.UNKNOWN); + } + -+ public boolean setRespawnPosition(@Nullable ServerPlayer.RespawnConfig respawnConfig, boolean displayInChat, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause cause) { ++ public boolean setRespawnPosition(ServerPlayer.@Nullable RespawnConfig respawnConfig, boolean displayInChat, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause cause) { + org.bukkit.Location spawnLoc = null; + boolean actuallyDisplayInChat = false; + if (respawnConfig != null) { @@ -1461,13 +1460,13 @@ } public SectionPos getLastSectionPos() { -@@ -1987,16 +_,23 @@ +@@ -1976,16 +_,23 @@ } @Override - public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean traceItem) { - ItemEntity itemEntity = super.drop(droppedItem, dropAround, traceItem); -+ public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean traceItem, boolean callEvent, @Nullable java.util.function.Consumer entityOperation) { // Paper - Extend dropItem API ++ public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean traceItem, boolean callEvent, java.util.function.@Nullable Consumer entityOperation) { // Paper - Extend dropItem API + ItemEntity itemEntity = super.drop(droppedItem, dropAround, traceItem, callEvent, entityOperation); // Paper - Extend dropItem API + ItemStack itemStack = itemEntity != null ? itemEntity.getItem() : ItemStack.EMPTY; // Paper - move up if (traceItem) { @@ -1490,7 +1489,7 @@ return itemEntity; } -@@ -2119,9 +_,9 @@ +@@ -2106,9 +_,9 @@ } @Override @@ -1502,7 +1501,7 @@ if (vehicle instanceof LivingEntity livingEntity) { for (MobEffectInstance mobEffectInstance : livingEntity.getActiveEffects()) { this.connection.send(new ClientboundRemoveMobEffectPacket(vehicle.getId(), mobEffectInstance.getEffect())); -@@ -2238,7 +_,7 @@ +@@ -2224,7 +_,7 @@ } public static long placeEnderPearlTicket(ServerLevel level, ChunkPos pos) { @@ -1511,7 +1510,7 @@ return TicketType.ENDER_PEARL.timeout(); } -@@ -2268,9 +_,11 @@ +@@ -2254,9 +_,11 @@ } } @@ -1526,7 +1525,7 @@ } private static float calculateLookAtYaw(Vec3 position, BlockPos towardsPos) { -@@ -2290,4 +_,135 @@ +@@ -2276,4 +_,135 @@ ); public static final ServerPlayer.SavedPosition EMPTY = new ServerPlayer.SavedPosition(Optional.empty(), Optional.empty(), Optional.empty()); } @@ -1545,7 +1544,7 @@ + } + } + -+ public @Nullable org.bukkit.WeatherType weatherType = null; ++ public org.bukkit.@Nullable WeatherType weatherType = null; + + public void setPlayerWeather(org.bukkit.WeatherType type, boolean plugin) { + if (!plugin && this.weatherType != null) { diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 2c7b90a2f63e..4f580de70e15 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -47,16 +_,38 @@ +@@ -46,16 +_,37 @@ private BlockPos delayedDestroyPos = BlockPos.ZERO; private int delayedTickStart; private int lastSentState = -1; @@ -19,8 +19,7 @@ + return event != null && !event.isCancelled(); + } + -+ @Nullable -+ public org.bukkit.event.player.PlayerGameModeChangeEvent changeGameModeForPlayer(GameType gameModeForPlayer, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause playerGameModeChangeCause, @Nullable net.kyori.adventure.text.Component cancelMessage) { ++ public org.bukkit.event.player.@Nullable PlayerGameModeChangeEvent changeGameModeForPlayer(GameType gameModeForPlayer, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause playerGameModeChangeCause, net.kyori.adventure.text.@Nullable Component cancelMessage) { + // Paper end - Expand PlayerGameModeChangeEvent if (gameModeForPlayer == this.gameModeForPlayer) { - return false; @@ -40,7 +39,7 @@ Abilities abilities = this.player.getAbilities(); this.setGameModeForPlayer(gameModeForPlayer, this.gameModeForPlayer); if (abilities.flying && gameModeForPlayer != GameType.SPECTATOR && this.isInRangeOfGround()) { -@@ -67,13 +_,13 @@ +@@ -66,13 +_,13 @@ this.level .getServer() .getPlayerList() @@ -56,7 +55,7 @@ } } -@@ -107,10 +_,11 @@ +@@ -105,10 +_,11 @@ } public void tick() { @@ -71,7 +70,7 @@ this.hasDelayedDestroy = false; } else { float f = this.incrementDestroyProgress(blockState, this.delayedDestroyPos, this.delayedTickStart); -@@ -120,7 +_,13 @@ +@@ -118,7 +_,13 @@ } } } else if (this.isDestroyingBlock) { @@ -86,7 +85,7 @@ if (blockState.isAir()) { this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1); this.lastSentState = -1; -@@ -151,6 +_,7 @@ +@@ -149,6 +_,7 @@ public void handleBlockBreakAction(BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction face, int maxBuildHeight, int sequence) { if (!this.player.canInteractWithBlock(pos, 1.0)) { @@ -94,7 +93,7 @@ this.debugLogging(pos, false, sequence, "too far"); } else if (pos.getY() > maxBuildHeight) { this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); -@@ -158,16 +_,35 @@ +@@ -156,16 +_,35 @@ } else { if (action == ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK) { if (!this.level.mayInteract(this.player, pos)) { @@ -132,7 +131,7 @@ if (this.player.blockActionRestricted(this.level, pos, this.gameModeForPlayer)) { this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); this.debugLogging(pos, false, sequence, "block action restricted"); -@@ -177,7 +_,7 @@ +@@ -175,7 +_,7 @@ this.destroyProgressStart = this.gameTicks; float f = 1.0F; BlockState blockState = this.level.getBlockState(pos); @@ -141,7 +140,7 @@ EnchantmentHelper.onHitBlock( this.level, this.player.getMainHandItem(), -@@ -192,6 +_,23 @@ +@@ -190,6 +_,23 @@ f = blockState.getDestroyProgress(this.player, this.player.level(), pos); } @@ -165,7 +164,7 @@ if (!blockState.isAir() && f >= 1.0F) { this.destroyAndAck(pos, sequence, "insta mine"); } else { -@@ -232,14 +_,22 @@ +@@ -230,14 +_,22 @@ this.debugLogging(pos, true, sequence, "stopped destroying"); } else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) { this.isDestroyingBlock = false; @@ -190,7 +189,7 @@ } } } -@@ -255,17 +_,64 @@ +@@ -253,17 +_,64 @@ public boolean destroyBlock(BlockPos pos) { BlockState blockState = this.level.getBlockState(pos); @@ -257,7 +256,7 @@ BlockState blockState1 = block.playerWillDestroy(this.level, pos, blockState, this.player); boolean flag = this.level.removeBlock(pos, false); if (SharedConstants.DEBUG_BLOCK_BREAK) { -@@ -276,19 +_,44 @@ +@@ -274,19 +_,44 @@ block.destroy(this.level, pos, blockState1); } @@ -309,7 +308,7 @@ } } } -@@ -323,7 +_,7 @@ +@@ -321,7 +_,7 @@ } if (!player.isUsingItem()) { @@ -318,7 +317,7 @@ } return interactionResult; -@@ -331,15 +_,47 @@ +@@ -329,15 +_,47 @@ } } @@ -368,7 +367,7 @@ return InteractionResult.CONSUME; } else { return InteractionResult.PASS; -@@ -364,7 +_,7 @@ +@@ -362,7 +_,7 @@ } } @@ -377,7 +376,7 @@ UseOnContext useOnContext = new UseOnContext(player, hand, hitResult); InteractionResult interactionResult1; if (player.hasInfiniteMaterials()) { -@@ -381,6 +_,11 @@ +@@ -379,6 +_,11 @@ return interactionResult1; } else { diff --git a/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch b/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch index c81767550de6..350485061772 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch @@ -32,7 +32,7 @@ private static TicketType register(String name, long timeout, @TicketType.Flags int flags) { return Registry.register(BuiltInRegistries.TICKET_TYPE, name, new TicketType(timeout, flags)); @@ -48,12 +_,20 @@ - return (this.flags & 16) != 0; + return (this.flags & FLAG_CAN_EXPIRE_IF_UNLOADED) != 0; } + // Paper start - chunk-gc config diff --git a/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch b/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch index bb40ae05343f..bf4502922504 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/WorldGenRegion.java +++ b/net/minecraft/server/level/WorldGenRegion.java -@@ -152,6 +_,28 @@ +@@ -150,6 +_,28 @@ return chessboardDistance < this.generatingStep.directDependencies().size(); } @@ -29,7 +29,7 @@ @Override public BlockState getBlockState(BlockPos pos) { return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos); -@@ -199,7 +_,8 @@ +@@ -196,7 +_,8 @@ if (blockState.isAir()) { return false; } else { @@ -39,7 +39,7 @@ BlockEntity blockEntity = blockState.hasBlockEntity() ? this.getBlockEntity(pos) : null; Block.dropResources(blockState, this.level, pos, blockEntity, entity, ItemStack.EMPTY); } -@@ -243,6 +_,7 @@ +@@ -239,6 +_,7 @@ } } @@ -47,7 +47,7 @@ @Override public boolean ensureCanWrite(BlockPos pos) { int sectionPosX = SectionPos.blockToSectionCoord(pos.getX()); -@@ -260,6 +_,8 @@ +@@ -256,6 +_,8 @@ return true; } else { @@ -56,7 +56,7 @@ Util.logAndPauseIfInIde( "Detected setBlock in a far chunk [" + sectionPosX -@@ -271,6 +_,12 @@ +@@ -267,6 +_,12 @@ + this.generatingStep.targetStatus() + (this.currentlyGenerating == null ? "" : ", currently generating: " + this.currentlyGenerating.get()) ); @@ -69,7 +69,7 @@ return false; } } -@@ -281,7 +_,7 @@ +@@ -277,7 +_,7 @@ return false; } else { ChunkAccess chunk = this.getChunk(pos); @@ -78,7 +78,7 @@ if (blockState != null) { this.level.updatePOIOnBlockStateChange(pos, blockState, state); } -@@ -295,6 +_,17 @@ +@@ -291,6 +_,17 @@ chunk.removeBlockEntity(pos); } } else { @@ -96,7 +96,7 @@ CompoundTag compoundTag = new CompoundTag(); compoundTag.putInt("x", pos.getX()); compoundTag.putInt("y", pos.getY()); -@@ -320,6 +_,13 @@ +@@ -316,6 +_,13 @@ @Override public boolean addFreshEntity(Entity entity) { diff --git a/paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch b/paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch index 4afd453e3754..72b4be725f8d 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/EventLoopGroupHolder.java +++ b/net/minecraft/server/network/EventLoopGroupHolder.java -@@ -38,15 +_,37 @@ +@@ -48,11 +_,20 @@ return LocalIoHandler.newFactory(); } }; @@ -15,12 +15,15 @@ private final String type; private final Class channelCls; private final Class serverChannelCls; - @Nullable - private volatile EventLoopGroup group; + private volatile @Nullable EventLoopGroup group; + @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - use variant with address param public static EventLoopGroupHolder remote(boolean tryNativeTransport) { - return tryNativeTransport && Epoll.isAvailable() ? EPOLL : NIO; + if (tryNativeTransport) { + if (KQueue.isAvailable()) { +@@ -66,6 +_,19 @@ + + return NIO; } + + // Paper start - Unix domain socket support diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch index 7eb2aa20a0ef..4f05492b68cd 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java -@@ -55,12 +_,26 @@ - private SynchronizeRegistriesTask synchronizeRegistriesTask; - @Nullable - private PrepareSpawnTask prepareSpawnTask; +@@ -52,12 +_,26 @@ + public ClientInformation clientInformation; + private @Nullable SynchronizeRegistriesTask synchronizeRegistriesTask; + private @Nullable PrepareSpawnTask prepareSpawnTask; + public io.papermc.paper.connection.PaperPlayerConfigurationConnection paperConnection; // Paper public ServerConfigurationPacketListenerImpl(MinecraftServer server, Connection connection, CommonListenerCookie cookie) { @@ -28,7 +28,7 @@ @Override protected GameProfile playerProfile() { -@@ -69,6 +_,11 @@ +@@ -66,6 +_,11 @@ @Override public void onDisconnect(DisconnectionDetails details) { @@ -40,7 +40,7 @@ LOGGER.info("{} ({}) lost connection: {}", this.gameProfile.name(), this.gameProfile.id(), details.reason().getString()); if (this.prepareSpawnTask != null) { this.prepareSpawnTask.close(); -@@ -84,10 +_,15 @@ +@@ -81,10 +_,15 @@ } public void startConfiguration() { @@ -57,7 +57,7 @@ } LayeredRegistryAccess layeredRegistryAccess = this.server.registries(); -@@ -100,11 +_,12 @@ +@@ -97,11 +_,12 @@ this.synchronizeRegistriesTask = new SynchronizeRegistriesTask(list, layeredRegistryAccess); this.configurationTasks.add(this.synchronizeRegistriesTask); this.addOptionalTasks(); @@ -71,7 +71,7 @@ this.configurationTasks.add(this.prepareSpawnTask); this.configurationTasks.add(new JoinWorldTask()); this.startNextTask(); -@@ -135,12 +_,14 @@ +@@ -132,12 +_,14 @@ @Override public void handleClientInformation(ServerboundClientInformationPacket packet) { this.clientInformation = packet.information(); @@ -87,7 +87,7 @@ this.finishCurrentTask(ServerResourcePackConfigurationTask.TYPE); } } -@@ -174,7 +_,7 @@ +@@ -171,7 +_,7 @@ return; } @@ -96,7 +96,7 @@ if (component != null) { this.disconnect(component); return; -@@ -234,4 +_,29 @@ +@@ -231,4 +_,29 @@ this.startNextTask(); } } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index dea22a407438..ff1d12a0da50 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -214,6 +_,38 @@ - import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; +// CraftBukkit start @@ -49,7 +49,7 @@ private double firstGoodX; private double firstGoodY; private double firstGoodZ; -@@ -259,14 +_,33 @@ +@@ -257,13 +_,32 @@ private int receivedMovePacketCount; private int knownMovePacketCount; private boolean receivedMovementThisTick; @@ -68,8 +68,7 @@ + private float lastYaw = Float.MAX_VALUE; + private boolean justTeleported = false; + // CraftBukkit end - @Nullable - private RemoteChatSession chatSession; + private @Nullable RemoteChatSession chatSession; + private boolean hasLoggedExpiry = false; // Paper - Prevent causing expired keys from impacting new joins private SignedMessageChain.Decoder signedMessageDecoder; private final LastSeenMessagesValidator lastSeenMessages = new LastSeenMessagesValidator(20); @@ -83,7 +82,7 @@ public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player, CommonListenerCookie cookie) { super(server, connection, cookie); -@@ -275,8 +_,22 @@ +@@ -272,8 +_,22 @@ player.connection = this; player.getTextFilter().join(); this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(player.getUUID(), server::enforceSecureProfile); @@ -108,7 +107,7 @@ @Override public void tick() { -@@ -289,11 +_,13 @@ +@@ -286,11 +_,13 @@ this.keepConnectionAlive(); this.chatSpamThrottler.tick(); this.dropSpamThrottler.tick(); @@ -123,7 +122,7 @@ } } } -@@ -309,8 +_,8 @@ +@@ -306,8 +_,8 @@ this.knownMovePacketCount = this.receivedMovePacketCount; if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger() && !this.player.isDeadOrDying()) { if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player)) { @@ -134,7 +133,7 @@ return true; } } else { -@@ -328,8 +_,8 @@ +@@ -325,8 +_,8 @@ this.vehicleLastGoodZ = this.lastVehicle.getZ(); if (this.clientVehicleIsFloating && this.lastVehicle.getControllingPassenger() == this.player) { if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle)) { @@ -145,7 +144,7 @@ return true; } } else { -@@ -342,6 +_,12 @@ +@@ -339,6 +_,12 @@ this.aboveGroundVehicleTickCount = 0; } @@ -158,7 +157,7 @@ return false; } -@@ -407,11 +_,37 @@ +@@ -404,11 +_,37 @@ @Override public void handlePlayerInput(ServerboundPlayerInputPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -198,7 +197,7 @@ } private static boolean containsInvalidValues(double x, double y, double z, float yRot, float xRot) { -@@ -430,17 +_,29 @@ +@@ -427,17 +_,29 @@ public void handleMoveVehicle(ServerboundMoveVehiclePacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (containsInvalidValues(packet.position().x(), packet.position().y(), packet.position().z(), packet.yRot(), packet.xRot())) { @@ -232,7 +231,7 @@ float f = Mth.wrapDegrees(packet.yRot()); float f1 = Mth.wrapDegrees(packet.xRot()); double d3 = d - this.vehicleFirstGoodX; -@@ -448,16 +_,61 @@ +@@ -445,16 +_,61 @@ double d5 = d2 - this.vehicleFirstGoodZ; double d6 = rootVehicle.getDeltaMovement().lengthSqr(); double d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -298,7 +297,7 @@ boolean flag = rootVehicle.verticalCollisionBelow; if (rootVehicle instanceof LivingEntity livingEntity && livingEntity.onClimbable()) { livingEntity.resetFallDistance(); -@@ -474,7 +_,7 @@ +@@ -471,7 +_,7 @@ d5 = d2 - rootVehicle.getZ(); d7 = d3 * d3 + d4 * d4 + d5 * d5; boolean flag1 = false; @@ -307,7 +306,7 @@ flag1 = true; LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", rootVehicle.getPlainTextName(), this.player.getPlainTextName(), Math.sqrt(d7)); } -@@ -488,6 +_,57 @@ +@@ -485,6 +_,57 @@ } rootVehicle.absSnapTo(d, d1, d2, f, f1); @@ -365,7 +364,7 @@ this.player.level().getChunkSource().move(this.player); Vec3 vec3 = new Vec3(rootVehicle.getX() - x, rootVehicle.getY() - y, rootVehicle.getZ() - z); this.handlePlayerKnownMovement(vec3); -@@ -518,7 +_,7 @@ +@@ -515,7 +_,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (packet.getId() == this.awaitingTeleport) { if (this.awaitingPositionFromClient == null) { @@ -374,7 +373,7 @@ return; } -@@ -535,12 +_,20 @@ +@@ -532,12 +_,20 @@ this.lastGoodZ = this.awaitingPositionFromClient.z; this.player.hasChangedDimension(); this.awaitingPositionFromClient = null; @@ -395,7 +394,7 @@ this.player.setClientLoaded(true); } -@@ -562,6 +_,7 @@ +@@ -559,6 +_,7 @@ @Override public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -403,7 +402,7 @@ this.player.getRecipeBook().setBookSetting(packet.getBookType(), packet.isOpen(), packet.isFiltering()); } -@@ -577,25 +_,110 @@ +@@ -574,25 +_,110 @@ } } @@ -519,7 +518,7 @@ } ); } -@@ -603,7 +_,7 @@ +@@ -600,7 +_,7 @@ @Override public void handleSetCommandBlock(ServerboundSetCommandBlockPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -528,7 +527,7 @@ this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock baseCommandBlock = null; -@@ -664,7 +_,7 @@ +@@ -661,7 +_,7 @@ @Override public void handleSetCommandMinecart(ServerboundSetCommandMinecartPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -537,7 +536,7 @@ this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock commandBlock = packet.getCommandBlock(this.player.level()); -@@ -702,11 +_,11 @@ +@@ -699,11 +_,11 @@ boolean flag = this.player.hasInfiniteMaterials() && packet.includeData(); ItemStack cloneItemStack = blockState.getCloneItemStack(serverLevel, blockPos, flag); if (!cloneItemStack.isEmpty()) { @@ -551,7 +550,7 @@ } } } -@@ -733,27 +_,40 @@ +@@ -730,27 +_,40 @@ if (entityOrPart != null && this.player.canInteractWithEntity(entityOrPart, 3.0)) { ItemStack pickResult = entityOrPart.getPickResult(); if (pickResult != null && !pickResult.isEmpty()) { @@ -598,7 +597,7 @@ } } -@@ -931,6 +_,13 @@ +@@ -928,6 +_,13 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); int item = packet.getItem(); if (this.player.containerMenu instanceof MerchantMenu merchantMenu) { @@ -612,7 +611,7 @@ if (!merchantMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, merchantMenu); return; -@@ -943,6 +_,51 @@ +@@ -940,6 +_,51 @@ @Override public void handleEditBook(ServerboundEditBookPacket packet) { @@ -664,7 +663,7 @@ int slot = packet.slot(); if (Inventory.isHotbarSlot(slot) || slot == 40) { List list = Lists.newArrayList(); -@@ -957,10 +_,14 @@ +@@ -954,10 +_,14 @@ } private void updateBookContents(List pages, int index) { @@ -680,7 +679,7 @@ } } -@@ -973,7 +_,8 @@ +@@ -970,7 +_,8 @@ itemStack.set( DataComponents.WRITTEN_BOOK_CONTENT, new WrittenBookContent(this.filterableFromOutgoing(title), this.player.getPlainTextName(), 0, list, true) ); @@ -690,7 +689,7 @@ } } -@@ -1021,27 +_,35 @@ +@@ -1018,27 +_,35 @@ public void handleMovePlayer(ServerboundMovePlayerPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (containsInvalidValues(packet.getX(0.0), packet.getY(0.0), packet.getZ(0.0), packet.getYRot(0.0F), packet.getXRot(0.0F))) { @@ -733,7 +732,7 @@ double x = this.player.getX(); double y = this.player.getY(); double z = this.player.getZ(); -@@ -1050,6 +_,16 @@ +@@ -1047,6 +_,16 @@ double d5 = d2 - this.firstGoodZ; double d6 = this.player.getDeltaMovement().lengthSqr(); double d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -750,7 +749,7 @@ if (this.player.isSleeping()) { if (d7 > 1.0) { this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); -@@ -1059,36 +_,108 @@ +@@ -1056,36 +_,108 @@ if (serverLevel.tickRateManager().runsNormally()) { this.receivedMovePacketCount++; int i = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -869,7 +868,7 @@ double verticalDelta = d4; d3 = d - this.player.getX(); d4 = d1 - this.player.getY(); -@@ -1098,20 +_,100 @@ +@@ -1095,20 +_,100 @@ d5 = d2 - this.player.getZ(); d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -979,7 +978,7 @@ this.player.absSnapTo(d, d1, d2, f, f1); boolean isAutoSpinAttack = this.player.isAutoSpinAttack(); this.clientIsFloating = verticalDelta >= -0.03125 -@@ -1146,7 +_,7 @@ +@@ -1143,7 +_,7 @@ this.lastGoodY = this.player.getY(); this.lastGoodZ = this.player.getZ(); } else { @@ -988,7 +987,7 @@ this.player.doCheckFallDamage(this.player.getX() - x, this.player.getY() - y, this.player.getZ() - z, packet.isOnGround()); this.player.removeLatestMovementRecording(); } -@@ -1182,6 +_,7 @@ +@@ -1178,6 +_,7 @@ this.player.getXRot() ); } @@ -996,7 +995,7 @@ return true; } else { -@@ -1205,10 +_,77 @@ +@@ -1201,10 +_,77 @@ } public void teleport(double x, double y, double z, float yRot, float xRot) { @@ -1075,7 +1074,7 @@ this.awaitingTeleportTime = this.tickCount; if (++this.awaitingTeleport == Integer.MAX_VALUE) { this.awaitingTeleport = 0; -@@ -1216,12 +_,20 @@ +@@ -1212,12 +_,20 @@ this.player.teleportSetPosition(posMoveRotation, relatives); this.awaitingPositionFromClient = this.player.position(); @@ -1096,7 +1095,7 @@ if (this.player.hasClientLoaded()) { BlockPos pos = packet.getPos(); this.player.resetLastActionTime(); -@@ -1246,32 +_,95 @@ +@@ -1242,32 +_,95 @@ case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { ItemStack itemInHand1 = this.player.getItemInHand(InteractionHand.OFF_HAND); @@ -1194,7 +1193,7 @@ return; default: throw new IllegalArgumentException("Invalid player action"); -@@ -1289,9 +_,31 @@ +@@ -1285,9 +_,31 @@ } } @@ -1226,7 +1225,7 @@ if (this.player.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel serverLevel = this.player.level(); -@@ -1300,6 +_,11 @@ +@@ -1296,6 +_,11 @@ if (itemInHand.isItemEnabled(serverLevel.enabledFeatures())) { BlockHitResult hitResult = packet.getHitResult(); Vec3 location = hitResult.getLocation(); @@ -1238,7 +1237,7 @@ BlockPos blockPos = hitResult.getBlockPos(); if (this.player.canInteractWithBlock(blockPos, 1.0)) { Vec3 vec3 = location.subtract(Vec3.atCenterOf(blockPos)); -@@ -1309,7 +_,8 @@ +@@ -1305,7 +_,8 @@ this.player.resetLastActionTime(); int maxY = this.player.level().getMaxY(); if (blockPos.getY() <= maxY) { @@ -1248,7 +1247,7 @@ InteractionResult interactionResult = this.player.gameMode.useItemOn(this.player, serverLevel, itemInHand, hand, hitResult); if (interactionResult.consumesAction()) { CriteriaTriggers.ANY_BLOCK_USE.trigger(this.player, hitResult.getBlockPos(), itemInHand.copy()); -@@ -1322,10 +_,10 @@ +@@ -1318,10 +_,10 @@ Component component = Component.translatable("build.tooHigh", maxY).withStyle(ChatFormatting.RED); this.player.sendSystemMessage(component, true); } else if (interactionResult instanceof InteractionResult.Success success @@ -1261,7 +1260,7 @@ } else { Component component1 = Component.translatable("build.tooHigh", maxY).withStyle(ChatFormatting.RED); this.player.sendSystemMessage(component1, true); -@@ -1333,13 +_,8 @@ +@@ -1329,13 +_,8 @@ this.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos)); this.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos.relative(direction))); @@ -1277,7 +1276,7 @@ } } } -@@ -1349,6 +_,8 @@ +@@ -1345,6 +_,8 @@ @Override public void handleUseItem(ServerboundUseItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1286,7 +1285,7 @@ if (this.player.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel serverLevel = this.player.level(); -@@ -1362,6 +_,48 @@ +@@ -1358,6 +_,48 @@ this.player.absSnapRotationTo(f, f1); } @@ -1335,7 +1334,7 @@ if (this.player.gameMode.useItem(this.player, serverLevel, itemInHand, hand) instanceof InteractionResult.Success success && success.swingSource() == InteractionResult.SwingSource.SERVER) { this.player.swing(hand, true); -@@ -1377,7 +_,7 @@ +@@ -1373,7 +_,7 @@ for (ServerLevel serverLevel : this.server.getAllLevels()) { Entity entity = packet.getEntity(serverLevel); if (entity != null) { @@ -1344,7 +1343,7 @@ return; } } -@@ -1394,24 +_,50 @@ +@@ -1390,24 +_,50 @@ @Override public void onDisconnect(DisconnectionDetails details) { @@ -1369,7 +1368,7 @@ + this.removePlayerFromWorld(null); + } + -+ private void removePlayerFromWorld(@Nullable net.kyori.adventure.text.Component quitMessage) { ++ private void removePlayerFromWorld(net.kyori.adventure.text.@Nullable Component quitMessage) { + // Paper end - Fix kick event leave message not being sent this.chatMessageChain.close(); + // CraftBukkit start - Replace vanilla quit message handling with our own. @@ -1397,7 +1396,7 @@ throw new IllegalArgumentException("Expected packet sequence nr >= 0"); } else { this.ackBlockChangesUpTo = Math.max(sequence, this.ackBlockChangesUpTo); -@@ -1421,20 +_,38 @@ +@@ -1417,20 +_,38 @@ @Override public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1436,7 +1435,7 @@ Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { this.tryHandleChat(packet.message(), false, () -> { -@@ -1446,25 +_,45 @@ +@@ -1442,25 +_,45 @@ return; } @@ -1489,7 +1488,7 @@ ParseResults parseResults = this.parseCommand(command); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseResults)) { LOGGER.error( -@@ -1481,28 +_,57 @@ +@@ -1477,28 +_,57 @@ Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { this.tryHandleChat(packet.command(), true, () -> { @@ -1550,7 +1549,7 @@ } private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) { -@@ -1566,14 +_,20 @@ +@@ -1562,14 +_,20 @@ return dispatcher.parse(command, this.player.createCommandSourceStack()); } @@ -1575,7 +1574,7 @@ } } -@@ -1585,7 +_,7 @@ +@@ -1581,7 +_,7 @@ var10000 = Optional.of(lastSeenMessages); } catch (LastSeenMessagesValidator.ValidationException var5) { LOGGER.error("Failed to validate message acknowledgements from {}: {}", this.player.getPlainTextName(), var5.getMessage()); @@ -1584,7 +1583,7 @@ return Optional.empty(); } -@@ -1603,22 +_,81 @@ +@@ -1599,22 +_,81 @@ return false; } @@ -1672,7 +1671,7 @@ } } -@@ -1629,7 +_,7 @@ +@@ -1625,7 +_,7 @@ this.lastSeenMessages.applyOffset(packet.offset()); } catch (LastSeenMessagesValidator.ValidationException var5) { LOGGER.error("Failed to validate message acknowledgement offset from {}: {}", this.player.getPlainTextName(), var5.getMessage()); @@ -1681,7 +1680,7 @@ } } } -@@ -1637,7 +_,40 @@ +@@ -1633,7 +_,40 @@ @Override public void handleAnimate(ServerboundSwingPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1722,7 +1721,7 @@ this.player.swing(packet.getHand()); } -@@ -1645,6 +_,22 @@ +@@ -1641,6 +_,22 @@ public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (this.player.hasClientLoaded()) { @@ -1745,7 +1744,7 @@ this.player.resetLastActionTime(); switch (packet.getAction()) { case START_SPRINTING: -@@ -1689,6 +_,14 @@ +@@ -1685,6 +_,14 @@ } public void sendPlayerChatMessage(PlayerChatMessage chatMessage, ChatType.Bound boundChatType) { @@ -1760,7 +1759,7 @@ this.send( new ClientboundPlayerChatPacket( this.nextChatIndex++, -@@ -1711,9 +_,11 @@ +@@ -1707,9 +_,11 @@ } if (i > 4096) { @@ -1773,7 +1772,7 @@ } public void sendDisguisedChatMessage(Component message, ChatType.Bound boundChatType) { -@@ -1724,6 +_,17 @@ +@@ -1720,6 +_,17 @@ return this.connection.getRemoteAddress(); } @@ -1791,7 +1790,7 @@ public void switchToConfig() { this.waitingForSwitchToConfig = true; this.removePlayerFromWorld(); -@@ -1739,9 +_,16 @@ +@@ -1735,9 +_,16 @@ @Override public void handleInteract(ServerboundInteractPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1808,7 +1807,7 @@ this.player.resetLastActionTime(); this.player.setShiftKeyDown(packet.isUsingSecondaryAction()); if (target != null) { -@@ -1750,16 +_,54 @@ +@@ -1746,16 +_,54 @@ } AABB boundingBox = target.getBoundingBox(); @@ -1868,7 +1867,7 @@ ItemStack itemStack1 = success.wasItemInteraction() ? itemStack : ItemStack.EMPTY; CriteriaTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(ServerGamePacketListenerImpl.this.player, itemStack1, target); if (success.swingSource() == InteractionResult.SwingSource.SERVER) { -@@ -1771,13 +_,13 @@ +@@ -1767,13 +_,13 @@ @Override public void onInteraction(InteractionHand hand) { @@ -1884,7 +1883,7 @@ ); } -@@ -1785,7 +_,7 @@ +@@ -1781,7 +_,7 @@ public void onAttack() { if (!(target instanceof ItemEntity) && !(target instanceof ExperienceOrb) @@ -1893,7 +1892,7 @@ && !(target instanceof AbstractArrow abstractArrow && !abstractArrow.isAttackable())) { ItemStack itemInHand = ServerGamePacketListenerImpl.this.player.getItemInHand(InteractionHand.MAIN_HAND); if (itemInHand.isItemEnabled(serverLevel.enabledFeatures())) { -@@ -1794,7 +_,7 @@ +@@ -1790,7 +_,7 @@ } } } else { @@ -1902,7 +1901,7 @@ ServerGamePacketListenerImpl.LOGGER .warn("Player {} tried to attack an invalid entity", ServerGamePacketListenerImpl.this.player.getPlainTextName()); } -@@ -1803,6 +_,27 @@ +@@ -1799,6 +_,27 @@ ); } } @@ -1930,7 +1929,7 @@ } } -@@ -1815,7 +_,7 @@ +@@ -1811,7 +_,7 @@ case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; @@ -1939,7 +1938,7 @@ this.resetPosition(); CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); } else { -@@ -1823,11 +_,11 @@ +@@ -1819,11 +_,11 @@ return; } @@ -1948,13 +1947,13 @@ this.resetPosition(); if (this.server.isHardcore()) { - this.player.setGameMode(GameType.SPECTATOR); -- this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS).set(false, this.server); +- this.player.level().getGameRules().set(GameRules.SPECTATORS_GENERATE_CHUNKS, false, this.server); + this.player.setGameMode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper - Expand PlayerGameModeChangeEvent -+ this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS).set(false, this.player.level()); // CraftBukkit - per-world ++ this.player.level().getGameRules().set(GameRules.SPECTATORS_GENERATE_CHUNKS, false, this.player.level()); // CraftBukkit - per-world } } break; -@@ -1838,16 +_,27 @@ +@@ -1834,16 +_,27 @@ @Override public void handleContainerClose(ServerboundContainerClosePacket packet) { @@ -1984,7 +1983,7 @@ this.player.containerMenu.sendAllDataToRemote(); } else if (!this.player.containerMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); -@@ -1863,7 +_,298 @@ +@@ -1859,7 +_,298 @@ } else { boolean flag = packet.stateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -2284,7 +2283,7 @@ for (Entry entry : Int2ObjectMaps.fastIterable(packet.changedSlots())) { this.player.containerMenu.setRemoteSlotUnsafe(entry.getIntKey(), entry.getValue()); -@@ -1876,6 +_,8 @@ +@@ -1872,6 +_,8 @@ } else { this.player.containerMenu.broadcastChanges(); } @@ -2293,7 +2292,7 @@ } } } -@@ -1883,6 +_,14 @@ +@@ -1879,6 +_,14 @@ @Override public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) { @@ -2308,7 +2307,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); this.player.resetLastActionTime(); if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) { -@@ -1899,9 +_,44 @@ +@@ -1895,9 +_,44 @@ return; } @@ -2354,7 +2353,7 @@ if (postPlaceAction == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) { this.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, recipeFromDisplay.display().display())); } -@@ -1915,6 +_,7 @@ +@@ -1911,6 +_,7 @@ @Override public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2362,7 +2361,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -1924,6 +_,7 @@ +@@ -1920,6 +_,7 @@ if (flag) { this.player.containerMenu.broadcastChanges(); } @@ -2370,7 +2369,7 @@ } } } -@@ -1940,10 +_,48 @@ +@@ -1936,10 +_,48 @@ boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45; boolean flag2 = itemStack.isEmpty() || itemStack.getCount() <= itemStack.getMaxStackSize(); @@ -2419,7 +2418,7 @@ } else if (flag && flag2) { if (this.dropSpamThrottler.isUnderThreshold()) { this.dropSpamThrottler.increment(); -@@ -1957,15 +_,38 @@ +@@ -1953,15 +_,38 @@ @Override public void handleSignUpdate(ServerboundSignUpdatePacket packet) { @@ -2459,7 +2458,7 @@ if (!(serverLevel.getBlockEntity(pos) instanceof SignBlockEntity signBlockEntity)) { return; } -@@ -1977,14 +_,32 @@ +@@ -1973,14 +_,32 @@ @Override public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2493,7 +2492,7 @@ if (this.player.isModelPartShown(PlayerModelPart.HAT) != isModelPartShown) { this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player)); } -@@ -2000,7 +_,7 @@ +@@ -1996,7 +_,7 @@ packet.difficulty().getDisplayName() ); } else { @@ -2502,7 +2501,7 @@ } } -@@ -2014,7 +_,7 @@ +@@ -2010,7 +_,7 @@ packet.mode().getShortDisplayName().getString() ); } else { @@ -2511,7 +2510,7 @@ } } -@@ -2034,7 +_,7 @@ +@@ -2030,7 +_,7 @@ ProfilePublicKey.Data data2 = data.profilePublicKey(); if (!Objects.equals(data1, data2)) { if (data1 != null && data2.expiresAt().isBefore(data1.expiresAt())) { @@ -2520,7 +2519,7 @@ } else { try { SignatureValidator signatureValidator = this.server.services().profileKeySignatureValidator(); -@@ -2045,8 +_,8 @@ +@@ -2041,8 +_,8 @@ this.resetPlayerChatState(data.validate(this.player.getGameProfile(), signatureValidator)); } catch (ProfilePublicKey.ValidationException var6) { @@ -2531,7 +2530,7 @@ } } } -@@ -2057,11 +_,13 @@ +@@ -2053,11 +_,13 @@ if (!this.waitingForSwitchToConfig) { throw new IllegalStateException("Client acknowledged config, but none was requested"); } else { @@ -2546,7 +2545,7 @@ } } -@@ -2079,27 +_,32 @@ +@@ -2075,27 +_,32 @@ private void resetPlayerChatState(RemoteChatSession chatSession) { this.chatSession = chatSession; @@ -2580,7 +2579,7 @@ if (!this.receivedMovementThisTick) { this.player.setKnownMovement(Vec3.ZERO); } -@@ -2130,4 +_,80 @@ +@@ -2126,4 +_,80 @@ interface EntityInteraction { InteractionResult run(ServerPlayer player, Entity entity, InteractionHand hand); } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch index b97c3ae2a6cc..92f8260e5ab5 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -46,9 +_,16 @@ - import org.apache.commons.lang3.Validate; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; +// CraftBukkit start @@ -17,26 +17,26 @@ private static final int MAX_TICKS_BEFORE_LOGIN = 600; private final byte[] challenge; final MinecraftServer server; -@@ -57,11 +_,16 @@ +@@ -56,10 +_,16 @@ + final ServerActivityMonitor serverActivityMonitor; public volatile ServerLoginPacketListenerImpl.State state = ServerLoginPacketListenerImpl.State.HELLO; private int tick; - @Nullable -- String requestedUsername; +- @Nullable String requestedUsername; ++ @Nullable + public String requestedUsername; // Paper - @Nullable - public GameProfile authenticatedProfile; + public @Nullable GameProfile authenticatedProfile; private final String serverId = ""; - private final boolean transferred; + public final boolean transferred; // Paper + public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding + private int velocityLoginMessageId = -1; // Paper - Add Velocity IP Forwarding Support -+ public @Nullable java.util.UUID requestedUuid; // Paper ++ public java.util.@Nullable UUID requestedUuid; // Paper + private final io.papermc.paper.connection.PaperPlayerLoginConnection paperLoginConnection; // Paper - Config API + private volatile boolean disconnecting = false; // Paper - Fix disconnect still ticking login public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection, boolean transferred) { this.server = server; -@@ -69,10 +_,20 @@ +@@ -67,10 +_,20 @@ this.serverActivityMonitor = this.server.getServerActivityMonitor(); this.challenge = Ints.toByteArray(RandomSource.create().nextInt()); this.transferred = transferred; @@ -57,7 +57,7 @@ if (this.state == ServerLoginPacketListenerImpl.State.VERIFYING) { this.verifyLoginAndFinishConnectionSetup(Objects.requireNonNull(this.authenticatedProfile)); } -@@ -82,11 +_,23 @@ +@@ -80,11 +_,23 @@ this.finishLoginAndWaitForClient(this.authenticatedProfile); } @@ -81,7 +81,7 @@ @Override public boolean isAcceptingMessages() { return this.connection.isConnected(); -@@ -97,6 +_,7 @@ +@@ -95,6 +_,7 @@ LOGGER.info("Disconnecting {}: {}", this.getUserName(), reason.getString()); this.connection.send(new ClientboundLoginDisconnectPacket(reason)); this.connection.disconnect(reason); @@ -89,7 +89,7 @@ } catch (Exception var3) { LOGGER.error("Error whilst disconnecting player", (Throwable)var3); } -@@ -119,7 +_,14 @@ +@@ -117,7 +_,14 @@ @Override public void handleHello(ServerboundHelloPacket packet) { Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet"); @@ -105,7 +105,7 @@ this.requestedUsername = packet.name(); GameProfile singleplayerProfile = this.server.getSingleplayerProfile(); if (singleplayerProfile != null && this.requestedUsername.equalsIgnoreCase(singleplayerProfile.name())) { -@@ -129,7 +_,32 @@ +@@ -127,7 +_,32 @@ this.state = ServerLoginPacketListenerImpl.State.KEY; this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge, true)); } else { @@ -139,7 +139,7 @@ } } } -@@ -141,7 +_,7 @@ +@@ -139,7 +_,7 @@ private void verifyLoginAndFinishConnectionSetup(GameProfile profile) { PlayerList playerList = this.server.getPlayerList(); @@ -148,7 +148,7 @@ if (component != null) { this.disconnect(component); } else { -@@ -153,7 +_,7 @@ +@@ -151,7 +_,7 @@ ); } @@ -157,7 +157,7 @@ if (flag) { this.state = ServerLoginPacketListenerImpl.State.WAITING_FOR_DUPE_DISCONNECT; } else { -@@ -165,6 +_,7 @@ +@@ -163,6 +_,7 @@ private void finishLoginAndWaitForClient(GameProfile profile) { this.state = ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING; this.connection.send(new ClientboundLoginFinishedPacket(profile)); @@ -165,7 +165,7 @@ } @Override -@@ -188,7 +_,8 @@ +@@ -186,7 +_,8 @@ throw new IllegalStateException("Protocol error", var7); } @@ -175,7 +175,7 @@ @Override public void run() { String string1 = Objects.requireNonNull(ServerLoginPacketListenerImpl.this.requestedUsername, "Player name not initialized"); -@@ -200,12 +_,18 @@ +@@ -198,12 +_,18 @@ .hasJoinedServer(string1, string, this.getAddress()); if (profileResult != null) { GameProfile gameProfile = profileResult.profile(); @@ -195,7 +195,7 @@ } else { ServerLoginPacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.unverified_username")); ServerLoginPacketListenerImpl.LOGGER.error("Username '{}' tried to join with an invalid session", string1); -@@ -213,11 +_,16 @@ +@@ -211,11 +_,16 @@ } catch (AuthenticationUnavailableException var4) { if (ServerLoginPacketListenerImpl.this.server.isSingleplayer()) { ServerLoginPacketListenerImpl.LOGGER.warn("Authentication servers are down but will let them in anyway!"); @@ -214,7 +214,7 @@ } } -@@ -228,18 +_,113 @@ +@@ -225,18 +_,113 @@ ? ((InetSocketAddress)remoteAddress).getAddress() : null; } @@ -332,7 +332,7 @@ Validate.validState(this.state == ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet"); this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND); CommonListenerCookie commonListenerCookie = CommonListenerCookie.createInitial(Objects.requireNonNull(this.authenticatedProfile), this.transferred); -@@ -258,8 +_,31 @@ +@@ -255,8 +_,31 @@ @Override public void handleCookieResponse(ServerboundCookieResponsePacket packet) { diff --git a/paper-server/patches/sources/net/minecraft/server/network/config/PrepareSpawnTask.java.patch b/paper-server/patches/sources/net/minecraft/server/network/config/PrepareSpawnTask.java.patch index 55476434f5a2..616349a9566f 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/config/PrepareSpawnTask.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/config/PrepareSpawnTask.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/network/config/PrepareSpawnTask.java +++ b/net/minecraft/server/network/config/PrepareSpawnTask.java -@@ -37,10 +_,17 @@ - @Nullable - private PrepareSpawnTask.State state; +@@ -36,10 +_,17 @@ + final LevelLoadListener loadListener; + private PrepareSpawnTask.@Nullable State state; - public PrepareSpawnTask(MinecraftServer server, NameAndId nameAndId) { + // Paper start - passthrough profile and packet listener @@ -21,7 +21,7 @@ } @Override -@@ -50,15 +_,57 @@ +@@ -49,15 +_,57 @@ .getPlayerList() .loadPlayerData(this.nameAndId) .map(compoundTag -> TagValueInput.create(scopedCollector, this.server.registryAccess(), compoundTag)); @@ -83,7 +83,7 @@ CompletableFuture completableFuture = savedPosition.position() .map(CompletableFuture::completedFuture) .orElseGet(() -> PlayerSpawnFinder.findSpawn(serverLevel, respawnData.pos())); -@@ -113,11 +_,12 @@ +@@ -112,10 +_,11 @@ } final class Preparing implements PrepareSpawnTask.State { @@ -93,13 +93,12 @@ + private ServerLevel spawnLevel; // Paper - remove final + private CompletableFuture spawnPosition; // Paper - remove final + private Vec2 spawnAngle; // Paper - remove final - @Nullable - private CompletableFuture chunkLoadFuture; + private @Nullable CompletableFuture chunkLoadFuture; + private @Nullable CompletableFuture eventFuture; // Paper private final ChunkLoadCounter chunkLoadCounter = new ChunkLoadCounter(); Preparing(final ServerLevel spawnLevel, final CompletableFuture spawnPosition, final Vec2 spawnAngle) { -@@ -137,6 +_,50 @@ +@@ -134,6 +_,50 @@ } else { Vec3 vec3 = this.spawnPosition.join(); if (this.chunkLoadFuture == null) { @@ -150,7 +149,7 @@ ChunkPos chunkPos = new ChunkPos(BlockPos.containing(vec3)); this.chunkLoadCounter .track( -@@ -177,15 +_,48 @@ +@@ -174,15 +_,48 @@ public ServerPlayer spawn(Connection connection, CommonListenerCookie cookie) { ChunkPos chunkPos = new ChunkPos(BlockPos.containing(this.spawnPosition)); this.spawnLevel.waitForEntities(chunkPos, 3); diff --git a/paper-server/patches/sources/net/minecraft/server/notifications/EmptyNotificationService.java.patch b/paper-server/patches/sources/net/minecraft/server/notifications/EmptyNotificationService.java.patch index 03e9ee786948..83ebfe93a472 100644 --- a/paper-server/patches/sources/net/minecraft/server/notifications/EmptyNotificationService.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/notifications/EmptyNotificationService.java.patch @@ -4,8 +4,8 @@ } @Override -- public void onGameRuleChanged(String key, GameRules.Value value) { -+ public void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, String key, GameRules.Value value) { // Paper - per-world game rules (add level param) +- public void onGameRuleChanged(GameRule rule, T value) { ++ public void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, GameRule rule, T value) { // Paper - per-world game rules (add level param) } @Override diff --git a/paper-server/patches/sources/net/minecraft/server/notifications/NotificationManager.java.patch b/paper-server/patches/sources/net/minecraft/server/notifications/NotificationManager.java.patch index 2a3768c26a69..9caace376939 100644 --- a/paper-server/patches/sources/net/minecraft/server/notifications/NotificationManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/notifications/NotificationManager.java.patch @@ -4,10 +4,10 @@ } @Override -- public void onGameRuleChanged(String key, GameRules.Value value) { -- this.notificationServices.forEach(notificationService -> notificationService.onGameRuleChanged(key, value)); -+ public void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, String key, GameRules.Value value) { // Paper - per-world game rules (add level param) -+ this.notificationServices.forEach(notificationService -> notificationService.onGameRuleChanged(level, key, value)); // Paper - per-world game rules (add level param) +- public void onGameRuleChanged(GameRule rule, T value) { +- this.notificationServices.forEach(notificationService -> notificationService.onGameRuleChanged(rule, value)); ++ public void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, GameRule rule, T value) { // Paper - per-world game rules (add level param) ++ this.notificationServices.forEach(notificationService -> notificationService.onGameRuleChanged(level, rule, value)); // Paper - per-world game rules (add level param) } @Override diff --git a/paper-server/patches/sources/net/minecraft/server/notifications/NotificationService.java.patch b/paper-server/patches/sources/net/minecraft/server/notifications/NotificationService.java.patch index fb34055d0f72..735ae3988d81 100644 --- a/paper-server/patches/sources/net/minecraft/server/notifications/NotificationService.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/notifications/NotificationService.java.patch @@ -4,8 +4,8 @@ void playerUnbanned(NameAndId nameAndId); -- void onGameRuleChanged(String key, GameRules.Value value); -+ void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, String key, GameRules.Value value); // Paper - per-world game rules (add level param) +- void onGameRuleChanged(GameRule rule, T value); ++ void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, GameRule rule, T value); // Paper - per-world game rules (add level param) void statusHeartbeat(); } diff --git a/paper-server/patches/sources/net/minecraft/server/packs/PathPackResources.java.patch b/paper-server/patches/sources/net/minecraft/server/packs/PathPackResources.java.patch index 344f5284c4a9..f6f98c34221e 100644 --- a/paper-server/patches/sources/net/minecraft/server/packs/PathPackResources.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/packs/PathPackResources.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/packs/PathPackResources.java +++ b/net/minecraft/server/packs/PathPackResources.java -@@ -124,6 +_,12 @@ +@@ -120,6 +_,12 @@ try (DirectoryStream directoryStream = Files.newDirectoryStream(path)) { for (Path path1 : directoryStream) { String string = path1.getFileName().toString(); diff --git a/paper-server/patches/sources/net/minecraft/server/packs/repository/ServerPacksSource.java.patch b/paper-server/patches/sources/net/minecraft/server/packs/repository/ServerPacksSource.java.patch index ee3142e9b547..599949c60b3e 100644 --- a/paper-server/patches/sources/net/minecraft/server/packs/repository/ServerPacksSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/packs/repository/ServerPacksSource.java.patch @@ -9,10 +9,10 @@ .applyDevelopmentConfig() .pushJarResources() .build(VANILLA_PACK_INFO); -@@ -68,15 +_,26 @@ - @Nullable +@@ -66,15 +_,26 @@ + @Override - protected Pack createBuiltinPack(String id, Pack.ResourcesSupplier resources, Component title) { + protected @Nullable Pack createBuiltinPack(String id, Pack.ResourcesSupplier resources, Component title) { - return Pack.readMetaAndCreate(createBuiltInPackLocation(id, title), resources, PackType.SERVER_DATA, FEATURE_SELECTION_CONFIG); + // Paper start - custom built-in pack + final PackLocationInfo info; diff --git a/paper-server/patches/sources/net/minecraft/server/players/BanListEntry.java.patch b/paper-server/patches/sources/net/minecraft/server/players/BanListEntry.java.patch index ae8148986ac3..adebe9c189b2 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/BanListEntry.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/BanListEntry.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/BanListEntry.java +++ b/net/minecraft/server/players/BanListEntry.java -@@ -28,7 +_,7 @@ +@@ -26,7 +_,7 @@ } protected BanListEntry(@Nullable T user, JsonObject entryData) { @@ -9,7 +9,7 @@ Date date; try { -@@ -103,4 +_,22 @@ +@@ -99,4 +_,22 @@ return false; } } diff --git a/paper-server/patches/sources/net/minecraft/server/players/NameAndId.java.patch b/paper-server/patches/sources/net/minecraft/server/players/NameAndId.java.patch index a4ff1aa54164..d8dcdd205edc 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/NameAndId.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/NameAndId.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/NameAndId.java +++ b/net/minecraft/server/players/NameAndId.java -@@ -49,4 +_,10 @@ +@@ -48,4 +_,10 @@ UUID uuid = UUIDUtil.createOfflinePlayerUUID(name); return new NameAndId(uuid, name); } diff --git a/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch b/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch index b19ec1420d2b..c7f7b5f5feb2 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch @@ -46,7 +46,7 @@ } } -@@ -318,6 +_,37 @@ +@@ -317,6 +_,37 @@ private void movePlayerFile(File file3, String oldFileName, String newFileName) { File file4 = new File(worldPlayersDirectory, oldFileName + ".dat"); File file5 = new File(file3, newFileName + ".dat"); diff --git a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch index 3308ebefbebb..bd413b2ec3e1 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -112,14 +_,16 @@ +@@ -114,14 +_,16 @@ private static final int SEND_PLAYER_INFO_INTERVAL = 600; private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z", Locale.ROOT); private final MinecraftServer server; @@ -20,7 +20,7 @@ public final PlayerDataStorage playerIo; private final LayeredRegistryAccess registries; private int viewDistance; -@@ -127,9 +_,17 @@ +@@ -129,9 +_,17 @@ private boolean allowCommandsForAllPlayers; private int sendAllPlayerInfoIn; @@ -38,7 +38,7 @@ this.server = server; this.registries = registries; this.playerIo = playerIo; -@@ -139,23 +_,19 @@ +@@ -141,23 +_,19 @@ this.ipBans = new IpBanList(IPBANLIST_FILE, notificationService); } @@ -67,7 +67,7 @@ LevelData levelData = serverLevel.getLevelData(); ServerGamePacketListenerImpl serverGamePacketListenerImpl = new ServerGamePacketListenerImpl(this.server, connection, player, cookie); connection.setupInboundProtocol( -@@ -173,8 +_,8 @@ +@@ -175,8 +_,8 @@ levelData.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), @@ -75,10 +75,10 @@ - this.getSimulationDistance(), + serverLevel.spigotConfig.viewDistance, // Spigot - view distance + serverLevel.spigotConfig.simulationDistance, // Spigot - simulation distance - _boolean1, - !_boolean, - _boolean2, -@@ -182,6 +_,7 @@ + flag1, + !flag, + flag2, +@@ -184,6 +_,7 @@ this.server.enforceSecureProfile() ) ); @@ -86,7 +86,7 @@ serverGamePacketListenerImpl.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); serverGamePacketListenerImpl.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities())); serverGamePacketListenerImpl.send(new ClientboundSetHeldSlotPacket(player.getInventory().getSelectedSlot())); -@@ -201,24 +_,129 @@ +@@ -203,24 +_,129 @@ mutableComponent = Component.translatable("multiplayer.player.joined.renamed", player.getDisplayName(), string); } @@ -220,7 +220,7 @@ } public void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) { -@@ -240,31 +_,40 @@ +@@ -242,31 +_,40 @@ } } @@ -266,7 +266,7 @@ } @Override -@@ -288,57 +_,137 @@ +@@ -290,56 +_,137 @@ } protected void save(ServerPlayer player) { @@ -286,11 +286,11 @@ } - public void remove(ServerPlayer player) { -+ public @Nullable net.kyori.adventure.text.Component remove(ServerPlayer player) { // CraftBukkit - return string // Paper - return Component ++ public net.kyori.adventure.text.@Nullable Component remove(ServerPlayer player) { // CraftBukkit - return string // Paper - return Component + // Paper start - Fix kick event leave message not being sent + return this.remove(player, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? player.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName()))); + } -+ public @Nullable net.kyori.adventure.text.Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) { ++ public net.kyori.adventure.text.@Nullable Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) { + // Paper end - Fix kick event leave message not being sent ServerLevel serverLevel = player.level(); player.awardStat(Stats.LEAVE_GAME); @@ -378,8 +378,7 @@ - this.broadcastAll(new ClientboundPlayerInfoRemovePacket(List.of(player.getUUID()))); - } - -- @Nullable -- public Component canPlayerLogin(SocketAddress socketAddress, NameAndId nameAndId) { +- public @Nullable Component canPlayerLogin(SocketAddress socketAddress, NameAndId nameAndId) { - if (this.bans.isBanned(nameAndId)) { - UserBanListEntry userBanListEntry = this.bans.get(nameAndId); + // CraftBukkit start @@ -401,7 +400,7 @@ + } + + // Paper start - PlayerLoginEvent -+ public record LoginResult(@Nullable Component message, @org.jetbrains.annotations.NotNull org.bukkit.event.player.PlayerLoginEvent.Result result) { ++ public record LoginResult(@Nullable Component message, org.bukkit.event.player.PlayerLoginEvent.Result result) { + public static LoginResult ALLOW = new net.minecraft.server.players.PlayerList.LoginResult(null, org.bukkit.event.player.PlayerLoginEvent.Result.ALLOWED); + + public boolean isAllowed() { @@ -418,7 +417,7 @@ MutableComponent mutableComponent = Component.translatable("multiplayer.disconnect.banned.reason", userBanListEntry.getReasonMessage()); if (userBanListEntry.getExpires() != null) { mutableComponent.append( -@@ -346,9 +_,11 @@ +@@ -347,9 +_,11 @@ ); } @@ -433,7 +432,7 @@ } else if (this.ipBans.isBanned(socketAddress)) { IpBanListEntry ipBanListEntry = this.ipBans.get(socketAddress); MutableComponent mutableComponent = Component.translatable("multiplayer.disconnect.banned_ip.reason", ipBanListEntry.getReasonMessage()); -@@ -358,19 +_,18 @@ +@@ -359,19 +_,18 @@ ); } @@ -458,7 +457,7 @@ set.add(serverPlayer); } } -@@ -381,23 +_,31 @@ +@@ -382,23 +_,31 @@ } for (ServerPlayer serverPlayer2 : set) { @@ -495,7 +494,7 @@ serverPlayer.copyRespawnPosition(player); } -@@ -405,17 +_,26 @@ +@@ -406,17 +_,26 @@ serverPlayer.addTag(string); } @@ -523,7 +522,7 @@ serverPlayer.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); serverPlayer.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); serverPlayer.connection -@@ -425,9 +_,15 @@ +@@ -426,9 +_,15 @@ this.sendPlayerPermissionLevel(serverPlayer); level.addRespawnedPlayer(serverPlayer); this.players.add(serverPlayer); @@ -539,7 +538,7 @@ ServerPlayer.RespawnConfig respawnConfig = serverPlayer.getRespawnConfig(); if (!keepInventory && respawnConfig != null) { LevelData.RespawnData respawnData = respawnConfig.respawnData(); -@@ -453,6 +_,29 @@ +@@ -454,6 +_,29 @@ } } @@ -569,7 +568,7 @@ return serverPlayer; } -@@ -461,23 +_,58 @@ +@@ -462,23 +_,58 @@ } public void sendActiveEffects(LivingEntity entity, ServerGamePacketListenerImpl connection) { @@ -631,7 +630,7 @@ public void broadcastAll(Packet packet) { for (ServerPlayer serverPlayer : this.players) { serverPlayer.connection.send(packet); -@@ -563,6 +_,12 @@ +@@ -564,6 +_,12 @@ } private void sendPlayerPermissionLevel(ServerPlayer player, LevelBasedPermissionSet permissions) { @@ -644,7 +643,7 @@ if (player.connection != null) { byte b = switch (permissions.level()) { case ALL -> EntityEvent.PERMISSION_LEVEL_ALL; -@@ -574,9 +_,48 @@ +@@ -575,9 +_,48 @@ player.connection.send(new ClientboundEntityEventPacket(player, b)); } @@ -696,9 +695,9 @@ return !this.isUsingWhitelist() || this.ops.contains(nameAndId) || this.whitelist.contains(nameAndId); } @@ -589,21 +_,17 @@ + } - @Nullable - public ServerPlayer getPlayerByName(String username) { + public @Nullable ServerPlayer getPlayerByName(String username) { - int size = this.players.size(); - - for (int i = 0; i < size; i++) { @@ -737,7 +736,7 @@ public UserWhiteList getWhiteList() { @@ -645,10 +_,18 @@ player.connection.send(new ClientboundInitializeBorderPacket(worldBorder)); - player.connection.send(new ClientboundSetTimePacket(level.getGameTime(), level.getDayTime(), level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); + player.connection.send(new ClientboundSetTimePacket(level.getGameTime(), level.getDayTime(), level.getGameRules().get(GameRules.ADVANCE_TIME))); player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); + // Paper start + player.connection.send(new ClientboundSetChunkCacheRadiusPacket(level.spigotConfig.viewDistance)); @@ -772,15 +771,15 @@ + player.refreshEntityData(player); // CraftBukkit - SPIGOT-7218: sync metadata player.connection.send(new ClientboundSetHeldSlotPacket(player.getInventory().getSelectedSlot())); + // CraftBukkit start - from GameRules -+ int i = player.level().getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23; ++ int i = player.level().getGameRules().get(GameRules.REDUCED_DEBUG_INFO) ? 22 : 23; + player.connection.send(new ClientboundEntityEventPacket(player, (byte) i)); -+ float immediateRespawn = player.level().getGameRules().getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F; ++ float immediateRespawn = player.level().getGameRules().get(GameRules.IMMEDIATE_RESPAWN) ? 1.0F: 0.0F; + player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.IMMEDIATE_RESPAWN, immediateRespawn)); + // CraftBukkit end } public int getPlayerCount() { -@@ -707,9 +_,26 @@ +@@ -706,9 +_,26 @@ } public void removeAll() { @@ -810,7 +809,7 @@ } public void broadcastSystemMessage(Component message, boolean overlay) { -@@ -732,20 +_,39 @@ +@@ -731,20 +_,39 @@ } public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound boundChatType) { @@ -853,43 +852,32 @@ flag1 |= flag2 && message.isFullyFiltered(); } -@@ -758,15 +_,21 @@ +@@ -757,13 +_,21 @@ return message.hasSignature() && !message.hasExpiredServer(Instant.now()); } - public ServerStatsCounter getPlayerStats(Player player) { -- GameProfile gameProfile = player.getGameProfile(); -- UUID uuid = gameProfile.id(); -- ServerStatsCounter serverStatsCounter = this.stats.get(uuid); + // CraftBukkit start + public ServerStatsCounter getPlayerStats(ServerPlayer player) { -+ ServerStatsCounter serverstatisticmanager = player.getStats(); -+ return serverstatisticmanager == null ? this.getPlayerStats(player.getUUID(), player.getGameProfile().name()) : serverstatisticmanager; // Paper - use username and not display name + GameProfile gameProfile = player.getGameProfile(); +- return this.stats.computeIfAbsent(gameProfile.id(), uuid -> { ++ ServerStatsCounter playerStatsCounter = player.getStats(); ++ if (playerStatsCounter == null) { ++ return this.getPlayerStats(gameProfile); ++ } else { ++ return playerStatsCounter; ++ } + } -+ -+ public ServerStatsCounter getPlayerStats(UUID uuid, String displayName) { -+ ServerPlayer player = this.getPlayer(uuid); -+ ServerStatsCounter serverStatsCounter = player == null ? null : player.getStats(); -+ // CraftBukkit end - if (serverStatsCounter == null) { - File file = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR).toFile(); - File file1 = new File(file, uuid + ".json"); - if (!file1.exists()) { -- File file2 = new File(file, gameProfile.name() + ".json"); -+ File file2 = new File(file, displayName + ".json"); // CraftBukkit - Path path = file2.toPath(); - if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { - file2.renameTo(file1); -@@ -774,7 +_,7 @@ - } - - serverStatsCounter = new ServerStatsCounter(this.server, file1); -- this.stats.put(uuid, serverStatsCounter); -+ // this.stats.put(uuid, serverStatsCounter); // CraftBukkit - } ++ public ServerStatsCounter getPlayerStats(GameProfile gameProfile) { + Path path = this.locateStatsFile(gameProfile); + return new ServerStatsCounter(this.server, path); +- }); + } ++ // CraftBukkit end - return serverStatsCounter; -@@ -782,11 +_,11 @@ + private Path locateStatsFile(GameProfile profile) { + Path worldPath = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR); +@@ -790,11 +_,11 @@ public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) { UUID uuid = player.getUUID(); @@ -903,7 +891,7 @@ } playerAdvancements.setPlayer(player); -@@ -840,11 +_,34 @@ +@@ -842,11 +_,34 @@ } public void reloadResources() { diff --git a/paper-server/patches/sources/net/minecraft/server/players/StoredUserList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/StoredUserList.java.patch index efea418a123a..939fcbdb3ad3 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/StoredUserList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/StoredUserList.java.patch @@ -9,10 +9,10 @@ protected final NotificationService notificationService; public StoredUserList(File file, NotificationService notificationService) { -@@ -60,8 +_,11 @@ +@@ -59,8 +_,11 @@ + } - @Nullable - public V get(K user) { + public @Nullable V get(K user) { - this.removeExpired(); - return this.map.get(this.getKeyForUser(user)); + // Paper start - Use ConcurrentHashMap in StoredUserList @@ -23,7 +23,7 @@ } public boolean remove(K user) { -@@ -98,7 +_,7 @@ +@@ -97,7 +_,7 @@ } public boolean isEmpty() { @@ -32,7 +32,7 @@ } protected String getKeyForUser(K user) { -@@ -106,21 +_,12 @@ +@@ -105,21 +_,12 @@ } protected boolean contains(K entry) { @@ -56,7 +56,7 @@ } protected abstract StoredUserEntry createEntry(JsonObject entryData); -@@ -130,6 +_,7 @@ +@@ -129,6 +_,7 @@ } public void save() throws IOException { @@ -64,7 +64,7 @@ JsonArray jsonArray = new JsonArray(); this.map.values().stream().map(storedEntry -> Util.make(new JsonObject(), storedEntry::serialize)).forEach(jsonArray::add); -@@ -154,7 +_,14 @@ +@@ -153,7 +_,14 @@ this.map.put(this.getKeyForUser(storedUserEntry.getUser()), (V)storedUserEntry); } } diff --git a/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch b/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch index d1a66ee01a94..a2323578dd66 100644 --- a/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/rcon/thread/QueryThreadGs4.java +++ b/net/minecraft/server/rcon/thread/QueryThreadGs4.java -@@ -106,13 +_,32 @@ +@@ -105,13 +_,32 @@ NetworkDataOutputStream networkDataOutputStream = new NetworkDataOutputStream(1460); networkDataOutputStream.write(0); networkDataOutputStream.writeBytes(this.getIdentBytes(requestPacket.getSocketAddress())); @@ -39,7 +39,7 @@ this.sendTo(networkDataOutputStream.toByteArray(), requestPacket); LOGGER.debug("Status [{}]", socketAddress); } -@@ -147,31 +_,75 @@ +@@ -146,31 +_,75 @@ this.rulesResponse.writeString("splitnum"); this.rulesResponse.write(128); this.rulesResponse.write(0); diff --git a/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconThread.java.patch b/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconThread.java.patch index 62a462ca730b..bd7388039ad4 100644 --- a/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconThread.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconThread.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/rcon/thread/RconThread.java +++ b/net/minecraft/server/rcon/thread/RconThread.java -@@ -57,7 +_,7 @@ - @Nullable - public static RconThread create(ServerInterface serverInterface) { +@@ -56,7 +_,7 @@ + + public static @Nullable RconThread create(ServerInterface serverInterface) { DedicatedServerProperties properties = serverInterface.getProperties(); - String serverIp = serverInterface.getServerIp(); + String serverIp = properties.rconIp; // Paper - Configurable rcon ip if (serverIp.isEmpty()) { serverIp = "0.0.0.0"; } -@@ -104,6 +_,14 @@ +@@ -103,6 +_,14 @@ this.clients.clear(); } diff --git a/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch b/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch index 0ba528b7a58f..71d760f9fd73 100644 --- a/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch +++ b/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/stats/ServerStatsCounter.java +++ b/net/minecraft/stats/ServerStatsCounter.java -@@ -68,9 +_,21 @@ - LOGGER.error("Couldn't parse statistics file {}", file, var5); +@@ -74,9 +_,21 @@ + LOGGER.error("Couldn't parse statistics file {}", file, var9); } } + // Paper start - Moved after stat fetching for player state file @@ -19,10 +19,10 @@ public void save() { + if (org.spigotmc.SpigotConfig.disableStatSaving) return; // Spigot - try { - FileUtils.writeStringToFile(this.file, this.toJson()); - } catch (IOException var2) { -@@ -80,6 +_,8 @@ + try (Writer bufferedWriter = Files.newBufferedWriter(this.file, StandardCharsets.UTF_8)) { + GSON.toJson(this.toJson(), GSON.newJsonWriter(bufferedWriter)); + } catch (JsonIOException | IOException var6) { +@@ -86,6 +_,8 @@ @Override public void setValue(Player player, Stat stat, int value) { diff --git a/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch b/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch index fc75f3c8b79a..560d7e591da7 100644 --- a/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch +++ b/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch @@ -6,13 +6,13 @@ - public Map> build(Map> builders) { + // Paper start - fire tag registrar events -+ public Map> build(Map> builders, @Nullable io.papermc.paper.tag.TagEventConfig eventConfig) { ++ public Map> build(Map> builders, io.papermc.paper.tag.@Nullable TagEventConfig eventConfig) { + builders = io.papermc.paper.tag.PaperTagListenerManager.INSTANCE.firePreFlattenEvent(builders, eventConfig); + // Paper end final Map> map = new HashMap<>(); TagEntry.Lookup lookup = new TagEntry.Lookup() { - @Nullable -@@ -114,7 +_,7 @@ + @Override +@@ -112,7 +_,7 @@ ) .ifRight(list -> map.put(path, (List)list)) ); @@ -21,7 +21,7 @@ } public static void loadTagsFromNetwork(TagNetworkSerialization.NetworkPayload payload, WritableRegistry registry) { -@@ -122,16 +_,27 @@ +@@ -120,16 +_,27 @@ } public static List> loadTagsForExistingRegistries(ResourceManager resourceManager, RegistryAccess registryAccess) { @@ -51,7 +51,7 @@ .forEach((resourceLocation, list) -> registry.bindTag(TagKey.create(resourceKey, resourceLocation), (List>)list)); } -@@ -139,12 +_,12 @@ +@@ -137,12 +_,12 @@ return tags.entrySet().stream().collect(Collectors.toUnmodifiableMap(entry -> TagKey.create(registryKey, entry.getKey()), Entry::getValue)); } diff --git a/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch b/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch index 3f96af7cf973..f49aaf7f2381 100644 --- a/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/datafix/DataFixers.java +++ b/net/minecraft/util/datafix/DataFixers.java -@@ -530,6 +_,24 @@ +@@ -533,6 +_,24 @@ Schema schema44 = builder.addSchema(1456, SAME_NAMESPACED); builder.addFixer(new EntityItemFrameDirectionFix(schema44, false)); Schema schema45 = builder.addSchema(1458, V1458::new); diff --git a/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch b/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch index f2f1d5f3aa93..92a4a56bc7e7 100644 --- a/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/parsing/packrat/Scope.java +++ b/net/minecraft/util/parsing/packrat/Scope.java -@@ -281,4 +_,36 @@ +@@ -279,4 +_,36 @@ return true; } diff --git a/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch b/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch index 686f5748058b..80963a1ae0db 100644 --- a/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch @@ -1,23 +1,42 @@ --- a/net/minecraft/util/random/WeightedList.java +++ b/net/minecraft/util/random/WeightedList.java -@@ -16,14 +_,14 @@ - import net.minecraft.util.ExtraCodecs; +@@ -16,13 +_,13 @@ import net.minecraft.util.RandomSource; + import org.jspecify.annotations.Nullable; -public final class WeightedList { +public class WeightedList { // Paper - non-final private static final int FLAT_THRESHOLD = 64; private final int totalWeight; private final List> items; - @Nullable - private final WeightedList.Selector selector; + private final WeightedList.@Nullable Selector selector; - WeightedList(List> items) { + protected WeightedList(List> items) { // Paper - protected this.items = List.copyOf(items); this.totalWeight = WeightedRandom.getTotalWeight(items, Weighted::weight); if (this.totalWeight == 0) { -@@ -129,7 +_,7 @@ +@@ -38,15 +_,15 @@ + return new WeightedList<>(List.of()); + } + +- public static WeightedList of(E element) { +- return new WeightedList<>(List.of(new Weighted<>(element, 1))); +- } +- + @SafeVarargs + public static WeightedList of(Weighted... items) { + return new WeightedList<>(List.of(items)); + } + ++ public static WeightedList of(E element) { ++ return new WeightedList<>(List.of(new Weighted<>(element, 1))); ++ } ++ + public static WeightedList of(List> items) { + return new WeightedList<>(items); + } +@@ -128,7 +_,7 @@ } public static class Builder { diff --git a/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch b/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch index bc8cee0c23f9..fe6961f40b5f 100644 --- a/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch @@ -9,7 +9,7 @@ this.eraseCache = eraseCache; this.dataFixer = dataFixer; this.levelStorage = levelStorage; -@@ -368,7 +_,7 @@ +@@ -367,7 +_,7 @@ int dataVersion = NbtUtils.getDataVersion(compoundTag); ChunkGenerator chunkGenerator = WorldUpgrader.this.dimensions.getValueOrThrow(Registries.levelToLevelStem(dimension)).generator(); CompoundTag compoundTag1 = regionStorage.upgradeChunkTag( diff --git a/paper-server/patches/sources/net/minecraft/world/Container.java.patch b/paper-server/patches/sources/net/minecraft/world/Container.java.patch index 55c66d111110..b5e9379ac384 100644 --- a/paper-server/patches/sources/net/minecraft/world/Container.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/Container.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/Container.java +++ b/net/minecraft/world/Container.java -@@ -28,9 +_,7 @@ +@@ -31,9 +_,7 @@ void setItem(int slot, ItemStack stack); @@ -11,7 +11,7 @@ default int getMaxStackSize(ItemStack stack) { return Math.min(this.getMaxStackSize(), stack.getMaxStackSize()); -@@ -123,4 +_,22 @@ +@@ -142,4 +_,22 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/InteractionResult.java.patch b/paper-server/patches/sources/net/minecraft/world/InteractionResult.java.patch index 71c9cd34dcb2..2b132d669a06 100644 --- a/paper-server/patches/sources/net/minecraft/world/InteractionResult.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/InteractionResult.java.patch @@ -6,7 +6,7 @@ - public record Success(InteractionResult.SwingSource swingSource, InteractionResult.ItemContext itemContext) implements InteractionResult { + // Paper start - track more context in interaction result -+ public record PaperSuccessContext(@Nullable net.minecraft.core.BlockPos placedBlockPosition) { ++ public record PaperSuccessContext(net.minecraft.core.@Nullable BlockPos placedBlockPosition) { + static PaperSuccessContext DEFAULT = new PaperSuccessContext(null); + + public PaperSuccessContext placedBlockAt(final net.minecraft.core.BlockPos blockPos) { diff --git a/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch index 169adf2ef107..cf20d20fe90d 100644 --- a/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/RandomizableContainer.java +++ b/net/minecraft/world/RandomizableContainer.java -@@ -27,7 +_,7 @@ +@@ -26,7 +_,7 @@ void setLootTable(@Nullable ResourceKey lootTable); @@ -9,7 +9,7 @@ this.setLootTable(lootTable); this.setLootTableSeed(seed); } -@@ -50,8 +_,9 @@ +@@ -48,8 +_,9 @@ default boolean tryLoadLootTable(ValueInput input) { ResourceKey resourceKey = input.read("LootTable", LootTable.KEY_CODEC).orElse(null); this.setLootTable(resourceKey); @@ -20,7 +20,7 @@ } default boolean trySaveLootTable(ValueOutput output) { -@@ -60,26 +_,42 @@ +@@ -58,26 +_,42 @@ return false; } else { output.store("LootTable", LootTable.KEY_CODEC, lootTable); @@ -65,15 +65,14 @@ LootParams.Builder builder = new LootParams.Builder((ServerLevel)level).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockPos)); if (player != null) { builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player); -@@ -88,4 +_,17 @@ +@@ -86,4 +_,16 @@ lootTable1.fill(this, builder.create(LootContextParamSets.CHEST), this.getLootTableSeed()); } } + + // Paper start - LootTable API -+ @Nullable + @org.jetbrains.annotations.Contract(pure = true) -+ default com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData() { ++ default com.destroystokyo.paper.loottable.@Nullable PaperLootableInventoryData lootableData() { + return null; // some containers don't really have a "replenish" ability like decorated pots + } + diff --git a/paper-server/patches/sources/net/minecraft/world/SimpleContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/SimpleContainer.java.patch index 893e6c97415d..5eeeade6049f 100644 --- a/paper-server/patches/sources/net/minecraft/world/SimpleContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/SimpleContainer.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/SimpleContainer.java +++ b/net/minecraft/world/SimpleContainer.java -@@ -19,7 +_,90 @@ - @Nullable - private List listeners; +@@ -18,7 +_,90 @@ + public final NonNullList items; + private @Nullable List listeners; + // Paper start - add fields and methods + public List transaction = new java.util.ArrayList<>(); + private int maxStack = MAX_STACK; -+ protected @Nullable org.bukkit.inventory.InventoryHolder bukkitOwner; // Paper - annotation ++ protected org.bukkit.inventory.@Nullable InventoryHolder bukkitOwner; // Paper - annotation + + @Override + public List getContents() { @@ -40,7 +40,7 @@ + } + + @Override -+ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { ++ public org.bukkit.inventory.@Nullable InventoryHolder getOwner() { + // Paper start - Add missing InventoryHolders + if (this.bukkitOwner == null && this.bukkitOwnerCreator != null) { + this.bukkitOwner = this.bukkitOwnerCreator.get(); @@ -50,7 +50,7 @@ + } + + @Override -+ public @Nullable org.bukkit.Location getLocation() { ++ public org.bukkit.@Nullable Location getLocation() { + // Paper start - Fix inventories returning null Locations + // When the block inventory does not have a tile state that implements getLocation, e. g. composters + if (this.bukkitOwner instanceof org.bukkit.inventory.BlockInventoryHolder blockInventoryHolder) { @@ -77,7 +77,7 @@ + } + + // Paper start - Add missing InventoryHolders -+ private @Nullable java.util.function.Supplier bukkitOwnerCreator; ++ private java.util.function.@Nullable Supplier bukkitOwnerCreator; + + public SimpleContainer(java.util.function.Supplier bukkitOwnerCreator, int size) { + this(size); @@ -85,7 +85,7 @@ + } + // Paper end - Add missing InventoryHolders + -+ public SimpleContainer(int size, @Nullable org.bukkit.inventory.InventoryHolder owner) { ++ public SimpleContainer(int size, org.bukkit.inventory.@Nullable InventoryHolder owner) { + this.bukkitOwner = owner; + // Paper end this.size = size; diff --git a/paper-server/patches/sources/net/minecraft/world/damagesource/CombatTracker.java.patch b/paper-server/patches/sources/net/minecraft/world/damagesource/CombatTracker.java.patch index 11b79f9cfbfb..9f7b4e9b5d5c 100644 --- a/paper-server/patches/sources/net/minecraft/world/damagesource/CombatTracker.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/damagesource/CombatTracker.java.patch @@ -25,7 +25,7 @@ this.entries.add(combatEntry); this.lastDamageTime = this.mob.tickCount; this.takingDamage = true; -@@ -147,6 +_,13 @@ +@@ -145,6 +_,13 @@ public void recheckStatus() { int i = this.inCombat ? 300 : 100; if (this.takingDamage && (!this.mob.isAlive() || this.mob.tickCount - this.lastDamageTime > i)) { diff --git a/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch b/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch index dc1afa4718ed..f546b59ffca7 100644 --- a/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch @@ -1,18 +1,15 @@ --- a/net/minecraft/world/damagesource/DamageSource.java +++ b/net/minecraft/world/damagesource/DamageSource.java -@@ -20,6 +_,92 @@ - private final Entity directEntity; - @Nullable - private final Vec3 damageSourcePosition; +@@ -17,6 +_,86 @@ + private final @Nullable Entity causingEntity; + private final @Nullable Entity directEntity; + private final @Nullable Vec3 damageSourcePosition; + // CraftBukkit start -+ @Nullable -+ private org.bukkit.event.entity.EntityDamageEvent.DamageCause knownCause; // When the damage event cause is known by the context of the call rather than the damage source data ++ private org.bukkit.event.entity.EntityDamageEvent.@Nullable DamageCause knownCause; // When the damage event cause is known by the context of the call rather than the damage source data + @Nullable + private Entity eventEntityDamager = null; // Relevant entity set when the game doesn't normally set a causingEntity/directEntity -+ @Nullable -+ private org.bukkit.block.Block eventBlockDamager; // Relevant block set. damageSourcePosition is only used for bad respawn point explosion or custom damage -+ @Nullable -+ private org.bukkit.block.BlockState fromBlockSnapshot; // Captured block snapshot when the eventBlockDamager is not relevant (e.g. for bad respawn point explosions the block is already removed) ++ private org.bukkit.block.@Nullable Block eventBlockDamager; // Relevant block set. damageSourcePosition is only used for bad respawn point explosion or custom damage ++ private org.bukkit.block.@Nullable BlockState fromBlockSnapshot; // Captured block snapshot when the eventBlockDamager is not relevant (e.g. for bad respawn point explosions the block is already removed) + private boolean critical; // Supports arrows and sweeping damage + + public DamageSource knownCause(final org.bukkit.event.entity.EntityDamageEvent.DamageCause cause) { @@ -21,8 +18,7 @@ + return damageSource; + } + -+ @Nullable -+ public org.bukkit.event.entity.EntityDamageEvent.DamageCause knownCause() { ++ public org.bukkit.event.entity.EntityDamageEvent.@Nullable DamageCause knownCause() { + return this.knownCause; + } + @@ -40,12 +36,11 @@ + return damageSource; + } + -+ @Nullable -+ public org.bukkit.block.Block eventBlockDamager() { ++ public org.bukkit.block.@Nullable Block eventBlockDamager() { + return this.eventBlockDamager; + } + -+ public DamageSource eventBlockDamager(final net.minecraft.world.level.LevelAccessor level, final @Nullable net.minecraft.core.BlockPos pos) { ++ public DamageSource eventBlockDamager(final net.minecraft.world.level.LevelAccessor level, final net.minecraft.core.@Nullable BlockPos pos) { + if (pos == null) { + return this; + } @@ -55,8 +50,7 @@ + return damageSource; + } + -+ @Nullable -+ public org.bukkit.block.BlockState causingBlockSnapshot() { ++ public org.bukkit.block.@Nullable BlockState causingBlockSnapshot() { + return this.fromBlockSnapshot; + } + diff --git a/paper-server/patches/sources/net/minecraft/world/effect/MobEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/MobEffect.java.patch index b131cd898a81..1d9da101bd4a 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/MobEffect.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/MobEffect.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffect.java +++ b/net/minecraft/world/effect/MobEffect.java -@@ -86,6 +_,7 @@ +@@ -85,6 +_,7 @@ public void applyInstantenousEffect( ServerLevel level, @Nullable Entity source, @Nullable Entity indirectSource, LivingEntity entity, int amplifier, double health ) { diff --git a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch index 7743e56b9ef7..4a5dad6b1167 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffectInstance.java +++ b/net/minecraft/world/effect/MobEffectInstance.java -@@ -219,7 +_,7 @@ +@@ -218,7 +_,7 @@ return false; } else { int i = this.isInfiniteDuration() ? entity.tickCount : this.duration; @@ -9,7 +9,7 @@ return false; } else { this.tickDownDuration(); -@@ -415,7 +_,7 @@ +@@ -414,7 +_,7 @@ .apply(instance, MobEffectInstance.Details::create) ) ); @@ -18,7 +18,7 @@ codec -> StreamCodec.composite( ByteBufCodecs.VAR_INT, MobEffectInstance.Details::amplifier, -@@ -427,7 +_,7 @@ +@@ -426,7 +_,7 @@ MobEffectInstance.Details::showParticles, ByteBufCodecs.BOOL, MobEffectInstance.Details::showIcon, diff --git a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch index a28b1c75be6b..c0642b162e3d 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch @@ -13,7 +13,7 @@ + return addEffectToPlayersAround(level, source, pos, radius, effect, duration, cause, null); + } + -+ public static List addEffectToPlayersAround(ServerLevel level, @Nullable Entity source, Vec3 pos, double radius, MobEffectInstance effect, int duration, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause, @Nullable java.util.function.Predicate playerPredicate) { ++ public static List addEffectToPlayersAround(ServerLevel level, @Nullable Entity source, Vec3 pos, double radius, MobEffectInstance effect, int duration, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause, java.util.function.@Nullable Predicate playerPredicate) { + // Paper end - Add ElderGuardianAppearanceEvent + // CraftBukkit end Holder effect1 = effect.getEffect(); diff --git a/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch index dedc162cba80..3e0ba111f71b 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch @@ -3,7 +3,7 @@ @@ -27,11 +_,11 @@ @Override public void onMobRemoved(ServerLevel level, LivingEntity entity, int amplifier, Entity.RemovalReason reason) { - if (reason == Entity.RemovalReason.KILLED && (entity instanceof Player || level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { + if (reason == Entity.RemovalReason.KILLED && (entity instanceof Player || level.getGameRules().get(GameRules.MOB_GRIEFING))) { - this.spawnCobwebsRandomlyAround(level, entity.getRandom(), entity.blockPosition()); + this.spawnCobwebsRandomlyAround(level, entity.getRandom(), entity.blockPosition(), entity); // Paper - Fire EntityChangeBlockEvent in more places } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch index 455f0c3cfdc4..b7db5c0cfc47 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch @@ -8,7 +8,7 @@ protected AgeableMob(EntityType type, Level level) { super(type, level); -@@ -70,6 +_,7 @@ +@@ -68,6 +_,7 @@ } public void ageUp(int amount, boolean forced) { @@ -16,7 +16,7 @@ int age = this.getAge(); int previousAge = age; age += amount * 20; -@@ -109,6 +_,7 @@ +@@ -107,6 +_,7 @@ super.addAdditionalSaveData(output); output.putInt("Age", this.getAge()); output.putInt("ForcedAge", this.forcedAge); @@ -24,7 +24,7 @@ } @Override -@@ -116,6 +_,7 @@ +@@ -114,6 +_,7 @@ super.readAdditionalSaveData(input); this.setAge(input.getIntOr("Age", 0)); this.forcedAge = input.getIntOr("ForcedAge", 0); @@ -32,7 +32,7 @@ } @Override -@@ -130,7 +_,7 @@ +@@ -128,7 +_,7 @@ @Override public void aiStep() { super.aiStep(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch index dff1e208fb69..0acae96c2e8e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/AreaEffectCloud.java +++ b/net/minecraft/world/entity/AreaEffectCloud.java -@@ -191,7 +_,7 @@ +@@ -189,7 +_,7 @@ private void serverTick(ServerLevel level) { if (this.duration != -1 && this.tickCount - this.waitTime >= this.duration) { @@ -9,7 +9,7 @@ } else { boolean isWaiting = this.isWaiting(); boolean flag = this.tickCount < this.waitTime; -@@ -204,7 +_,7 @@ +@@ -202,7 +_,7 @@ if (this.radiusPerTick != 0.0F) { radius += this.radiusPerTick; if (radius < 0.5F) { @@ -18,7 +18,7 @@ return; } -@@ -220,6 +_,7 @@ +@@ -218,6 +_,7 @@ this.potionContents.forEachEffect(list::add, this.potionDurationScale); List entitiesOfClass = this.level().getEntitiesOfClass(LivingEntity.class, this.getBoundingBox()); if (!entitiesOfClass.isEmpty()) { @@ -26,7 +26,7 @@ for (LivingEntity livingEntity : entitiesOfClass) { if (!this.victims.containsKey(livingEntity) && livingEntity.isAffectedByPotions() -@@ -228,6 +_,17 @@ +@@ -226,6 +_,17 @@ double d1 = livingEntity.getZ() - this.getZ(); double d2 = d * d + d1 * d1; if (d2 <= radius * radius) { @@ -44,7 +44,7 @@ this.victims.put(livingEntity, this.tickCount + this.reapplicationDelay); for (MobEffectInstance mobEffectInstance : list) { -@@ -236,14 +_,14 @@ +@@ -234,14 +_,14 @@ .value() .applyInstantenousEffect(level, this, this.getOwner(), livingEntity, mobEffectInstance.getAmplifier(), 0.5); } else { @@ -61,7 +61,7 @@ return; } -@@ -253,7 +_,7 @@ +@@ -251,7 +_,7 @@ if (this.durationOnUse != 0 && this.duration != -1) { this.duration = this.duration + this.durationOnUse; if (this.duration <= 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch index 58918ddb5edf..b59473d204dc 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -152,6 +_,105 @@ +@@ -153,6 +_,105 @@ import org.slf4j.Logger; - public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, EntityAccess, ScoreHolder, DataComponentGetter { + public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, SlotProvider, EntityAccess, ScoreHolder, DataComponentGetter { + // CraftBukkit start + private static final int CURRENT_LEVEL = 2; + static boolean isLevelAtLeast(ValueInput input, int level) { @@ -82,9 +82,9 @@ + } + } + // Paper end - Share random for entities to make them more random -+ public @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason ++ public org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason + -+ private volatile @Nullable org.bukkit.craftbukkit.entity.CraftEntity bukkitEntity; // Paper - Folia schedulers - volatile ++ private volatile org.bukkit.craftbukkit.entity.@Nullable CraftEntity bukkitEntity; // Paper - Folia schedulers - volatile + + public org.bukkit.craftbukkit.entity.CraftEntity getBukkitEntity() { + if (this.bukkitEntity == null) { @@ -99,14 +99,14 @@ + return this.bukkitEntity; + } + // Paper start -+ public @Nullable org.bukkit.craftbukkit.entity.CraftEntity getBukkitEntityRaw() { ++ public org.bukkit.craftbukkit.entity.@Nullable CraftEntity getBukkitEntityRaw() { + return this.bukkitEntity; + } + // Paper end private static final Logger LOGGER = LogUtils.getLogger(); public static final String TAG_ID = "id"; public static final String TAG_UUID = "UUID"; -@@ -229,7 +_,7 @@ +@@ -228,7 +_,7 @@ public double yOld; public double zOld; public boolean noPhysics; @@ -115,7 +115,7 @@ public int tickCount; private int remainingFireTicks; public boolean wasTouchingWater; -@@ -266,7 +_,7 @@ +@@ -264,7 +_,7 @@ protected UUID uuid = Mth.createInsecureUUID(this.random); protected String stringUUID = this.uuid.toString(); private boolean hasGlowingTag; @@ -124,15 +124,15 @@ private final double[] pistonDeltas = new double[]{0.0, 0.0, 0.0}; private long pistonDeltasGameTime; private EntityDimensions dimensions; -@@ -281,6 +_,7 @@ +@@ -278,6 +_,7 @@ + public boolean hasVisualFire; private Vec3 lastKnownMovement = Vec3.ZERO; - @Nullable - private Vec3 lastKnownPosition; + private @Nullable Vec3 lastKnownPosition; + public net.kyori.adventure.util.TriState visualFire = net.kyori.adventure.util.TriState.NOT_SET; // Paper - improve visual fire API - @Nullable - private BlockState inBlockState = null; + private @Nullable BlockState inBlockState = null; public static final int MAX_MOVEMENTS_HANDELED_PER_TICK = 100; -@@ -289,6 +_,41 @@ + private final ArrayDeque movementThisTick = new ArrayDeque<>(100); +@@ -285,6 +_,40 @@ private final LongSet visitedBlocks = new LongOpenHashSet(); private final InsideBlockEffectApplier.StepBasedCollector insideEffectCollector = new InsideBlockEffectApplier.StepBasedCollector(); private CustomData customData = CustomData.EMPTY; @@ -144,8 +144,7 @@ + public boolean inWorld = false; + public boolean generation; + public int maxAirTicks = this.getDefaultMaxAirSupply(); // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() -+ @Nullable // Paper - Refresh ProjectileSource for projectiles -+ public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only ++ public org.bukkit.projectiles.@Nullable ProjectileSource projectileSource; // For projectiles only // Paper - Refresh ProjectileSource for projectiles + public boolean lastDamageCancelled; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled + public boolean persistentInvisibility = false; + public @Nullable BlockPos lastLavaContact; @@ -174,7 +173,7 @@ public Entity(EntityType type, Level level) { this.type = type; -@@ -310,6 +_,7 @@ +@@ -306,6 +_,7 @@ this.entityData = builder.build(); this.setPos(0.0, 0.0, 0.0); this.eyeHeight = this.dimensions.eyeHeight(); @@ -182,7 +181,7 @@ } public boolean isColliding(BlockPos pos, BlockState state) { -@@ -322,6 +_,12 @@ +@@ -318,6 +_,12 @@ return team != null && team.getColor().getColor() != null ? team.getColor().getColor() : 16777215; } @@ -195,7 +194,7 @@ public boolean isSpectator() { return false; } -@@ -374,7 +_,7 @@ +@@ -370,7 +_,7 @@ } public boolean addTag(String tag) { @@ -204,7 +203,7 @@ } public boolean removeTag(String tag) { -@@ -382,12 +_,18 @@ +@@ -378,12 +_,18 @@ } public void kill(ServerLevel level) { @@ -219,13 +218,13 @@ + this.discard(null); + } + -+ public final void discard(@Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { ++ public final void discard(org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { + this.remove(Entity.RemovalReason.DISCARDED, cause); + // CraftBukkit end } protected abstract void defineSynchedData(SynchedEntityData.Builder builder); -@@ -396,6 +_,48 @@ +@@ -392,6 +_,48 @@ return this.entityData; } @@ -274,7 +273,7 @@ @Override public boolean equals(Object other) { return other instanceof Entity && ((Entity)other).id == this.id; -@@ -407,7 +_,13 @@ +@@ -403,7 +_,13 @@ } public void remove(Entity.RemovalReason reason) { @@ -283,13 +282,13 @@ + this.remove(reason, null); + } + -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause eventCause) { + this.setRemoved(reason, eventCause); + // CraftBukkit end } public void onClientRemoval() { -@@ -417,6 +_,15 @@ +@@ -413,6 +_,15 @@ } public void setPose(Pose pose) { @@ -305,7 +304,7 @@ this.entityData.set(DATA_POSE, pose); } -@@ -440,6 +_,32 @@ +@@ -436,6 +_,32 @@ } public void setRot(float yRot, float xRot) { @@ -338,7 +337,7 @@ this.setYRot(yRot % 360.0F); this.setXRot(xRot % 360.0F); } -@@ -449,8 +_,8 @@ +@@ -445,8 +_,8 @@ } public void setPos(double x, double y, double z) { @@ -349,7 +348,7 @@ } protected final AABB makeBoundingBox() { -@@ -483,12 +_,28 @@ +@@ -479,12 +_,28 @@ } public void tick() { @@ -378,7 +377,7 @@ if (this.lastKnownPosition == null) { this.lastKnownPosition = this.position(); } -@@ -505,7 +_,7 @@ +@@ -501,7 +_,7 @@ this.boardingCooldown--; } @@ -387,7 +386,7 @@ if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -533,6 +_,10 @@ +@@ -529,6 +_,10 @@ if (this.isInLava()) { this.fallDistance *= 0.5; @@ -398,7 +397,7 @@ } this.checkBelowWorld(); -@@ -549,11 +_,16 @@ +@@ -545,11 +_,16 @@ } public void setSharedFlagOnFire(boolean isOnFire) { @@ -417,7 +416,7 @@ this.onBelowWorld(); } } -@@ -581,15 +_,41 @@ +@@ -577,15 +_,41 @@ } public void lavaIgnite() { @@ -461,7 +460,7 @@ && this.shouldPlayLavaHurtSound() && !this.isSilent()) { serverLevel.playSound( -@@ -604,6 +_,20 @@ +@@ -600,6 +_,20 @@ } public final void igniteForSeconds(float seconds) { @@ -482,7 +481,7 @@ this.igniteForTicks(Mth.floor(seconds * 20.0F)); } -@@ -628,7 +_,7 @@ +@@ -624,7 +_,7 @@ } protected void onBelowWorld() { @@ -491,7 +490,7 @@ } public boolean isFree(double x, double y, double z) { -@@ -684,7 +_,28 @@ +@@ -680,7 +_,28 @@ return this.onGround; } @@ -520,7 +519,7 @@ if (this.noPhysics) { this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); this.horizontalCollision = false; -@@ -767,6 +_,27 @@ +@@ -763,6 +_,27 @@ block.updateEntityMovementAfterFallOn(this.level(), this); } } @@ -548,7 +547,7 @@ if (!this.level().isClientSide() || this.isLocalInstanceAuthoritative()) { Entity.MovementEmission movementEmission = this.getMovementEmission(); -@@ -780,6 +_,13 @@ +@@ -776,6 +_,13 @@ profilerFiller.pop(); } } @@ -562,7 +561,7 @@ } private void applyMovementEmissionAndPlaySound(Entity.MovementEmission movementEmission, Vec3 movement, BlockPos pos, BlockState state) { -@@ -961,7 +_,7 @@ +@@ -957,7 +_,7 @@ } protected BlockPos getOnPos(float yOffset) { @@ -571,7 +570,7 @@ BlockPos blockPos = this.mainSupportingBlockPos.get(); if (!(yOffset > 1.0E-5F)) { return blockPos; -@@ -1216,7 +_,7 @@ +@@ -1212,7 +_,7 @@ if (flag2) { try { boolean flag4 = flag || aabb.intersects(pos); @@ -580,7 +579,7 @@ blockState.entityInside(this.level(), pos, this, stepBasedCollector, flag4); this.onInsideBlock(blockState); } catch (Throwable var20) { -@@ -1230,7 +_,7 @@ +@@ -1226,7 +_,7 @@ } if (flag3) { @@ -589,7 +588,7 @@ blockState.getFluidState().entityInside(this.level(), pos, this, stepBasedCollector); } -@@ -1667,6 +_,7 @@ +@@ -1662,6 +_,7 @@ this.setXRot(Mth.clamp(xRot, -90.0F, 90.0F) % 360.0F); this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); @@ -597,7 +596,7 @@ } public void absSnapTo(double x, double y, double z) { -@@ -1676,6 +_,7 @@ +@@ -1671,6 +_,7 @@ this.yo = y; this.zo = d1; this.setPos(d, y, d1); @@ -605,7 +604,7 @@ } public void snapTo(Vec3 pos) { -@@ -1700,6 +_,7 @@ +@@ -1695,6 +_,7 @@ this.setXRot(xRot); this.setOldPosAndRot(); this.reapplyPosition(); @@ -613,7 +612,7 @@ } public final void setOldPosAndRot() { -@@ -1766,6 +_,7 @@ +@@ -1761,6 +_,7 @@ public void push(Entity entity) { if (!this.isPassengerOfSameVehicle(entity)) { if (!entity.noPhysics && !this.noPhysics) { @@ -621,7 +620,7 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double max = Mth.absMax(d, d1); -@@ -1799,7 +_,21 @@ +@@ -1794,7 +_,21 @@ } public void push(double x, double y, double z) { @@ -644,7 +643,7 @@ this.hasImpulse = true; } -@@ -1906,8 +_,20 @@ +@@ -1901,8 +_,20 @@ } public boolean isPushable() { @@ -665,7 +664,7 @@ public void awardKillScore(Entity entity, DamageSource damageSource) { if (entity instanceof ServerPlayer) { -@@ -1934,15 +_,23 @@ +@@ -1929,15 +_,23 @@ } public boolean saveAsPassenger(ValueOutput output) { @@ -693,7 +692,7 @@ return true; } } -@@ -1953,14 +_,35 @@ +@@ -1948,14 +_,35 @@ } public void saveWithoutId(ValueOutput output) { @@ -729,7 +728,7 @@ output.store("Rotation", Vec2.CODEC, new Vec2(this.getYRot(), this.getXRot())); output.putDouble("fall_distance", this.fallDistance); output.putShort("Fire", (short)this.remainingFireTicks); -@@ -1968,7 +_,29 @@ +@@ -1963,7 +_,29 @@ output.putBoolean("OnGround", this.onGround()); output.putBoolean("Invulnerable", this.invulnerable); output.putInt("PortalCooldown", this.portalCooldown); @@ -759,7 +758,7 @@ output.storeNullable("CustomName", ComponentSerialization.CODEC, this.getCustomName()); if (this.isCustomNameVisible()) { output.putBoolean("CustomNameVisible", this.isCustomNameVisible()); -@@ -1991,9 +_,12 @@ +@@ -1986,9 +_,12 @@ output.putInt("TicksFrozen", this.getTicksFrozen()); } @@ -774,7 +773,7 @@ if (!this.tags.isEmpty()) { output.store("Tags", TAG_LIST_CODEC, List.copyOf(this.tags)); -@@ -2003,13 +_,13 @@ +@@ -1998,13 +_,13 @@ output.store("data", CustomData.CODEC, this.customData); } @@ -790,7 +789,7 @@ valueOutputList.discardLast(); } } -@@ -2018,6 +_,34 @@ +@@ -2013,6 +_,34 @@ output.discard("Passengers"); } } @@ -825,7 +824,7 @@ } catch (Throwable var7) { CrashReport crashReport = CrashReport.forThrowable(var7, "Saving entity NBT"); CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being saved"); -@@ -2029,7 +_,7 @@ +@@ -2024,7 +_,7 @@ public void load(ValueInput input) { try { Vec3 vec3 = input.read("Pos", Vec3.CODEC).orElse(Vec3.ZERO); @@ -834,7 +833,7 @@ Vec2 vec2 = input.read("Rotation", Vec2.CODEC).orElse(Vec2.ZERO); this.setDeltaMovement(Math.abs(vec31.x) > 10.0 ? 0.0 : vec31.x, Math.abs(vec31.y) > 10.0 ? 0.0 : vec31.y, Math.abs(vec31.z) > 10.0 ? 0.0 : vec31.z); this.hasImpulse = true; -@@ -2061,7 +_,20 @@ +@@ -2056,7 +_,20 @@ this.setNoGravity(input.getBooleanOr("NoGravity", false)); this.setGlowingTag(input.getBooleanOr("Glowing", false)); this.setTicksFrozen(input.getIntOr("TicksFrozen", 0)); @@ -856,7 +855,7 @@ this.customData = input.read("data", CustomData.CODEC).orElse(CustomData.EMPTY); this.tags.clear(); input.read("Tags", TAG_LIST_CODEC).ifPresent(this.tags::addAll); -@@ -2072,6 +_,59 @@ +@@ -2067,6 +_,59 @@ } else { throw new IllegalStateException("Entity has invalid rotation"); } @@ -916,10 +915,10 @@ } catch (Throwable var7) { CrashReport crashReport = CrashReport.forThrowable(var7, "Loading entity NBT"); CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being loaded"); -@@ -2086,13 +_,24 @@ +@@ -2080,13 +_,24 @@ + } - @Nullable - public final String getEncodeId() { + public final @Nullable String getEncodeId() { + // Paper start - Raw entity serialization API + return getEncodeId(false); + } @@ -941,16 +940,16 @@ + protected abstract void addAdditionalSaveData(ValueOutput output); - @Nullable -@@ -2107,11 +_,62 @@ + public @Nullable ItemEntity spawnAtLocation(ServerLevel level, ItemLike item) { +@@ -2098,11 +_,60 @@ + } - @Nullable - public ItemEntity spawnAtLocation(ServerLevel level, ItemStack stack, Vec3 offset) { + public @Nullable ItemEntity spawnAtLocation(ServerLevel level, ItemStack stack, Vec3 offset) { + // Paper start - Restore vanilla drops behavior + return this.spawnAtLocation(level, stack, offset, null); + } + -+ public record DefaultDrop(Item item, org.bukkit.inventory.ItemStack stack, @Nullable java.util.function.Consumer dropConsumer) { ++ public record DefaultDrop(Item item, org.bukkit.inventory.ItemStack stack, java.util.function.@Nullable Consumer dropConsumer) { + public DefaultDrop(final ItemStack stack, final java.util.function.Consumer dropConsumer) { + this(stack.getItem(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack), dropConsumer); + } @@ -964,8 +963,7 @@ + } + } + -+ @Nullable -+ public ItemEntity spawnAtLocation(ServerLevel level, ItemStack stack, Vec3 offset, @Nullable java.util.function.Consumer delayedAddConsumer) { ++ public @Nullable ItemEntity spawnAtLocation(ServerLevel level, ItemStack stack, Vec3 offset, java.util.function.@Nullable Consumer delayedAddConsumer) { + // Paper end - Restore vanilla drops behavior if (stack.isEmpty()) { return null; @@ -993,8 +991,7 @@ + return this.spawnAtLocation(level, itemEntity); + } + } -+ @Nullable -+ public ItemEntity spawnAtLocation(ServerLevel level, ItemEntity itemEntity) { ++ public @Nullable ItemEntity spawnAtLocation(ServerLevel level, ItemEntity itemEntity) { + { + // Paper end - Call EntityDropItemEvent + // CraftBukkit start @@ -1007,7 +1004,7 @@ level.addFreshEntity(itemEntity); return itemEntity; } -@@ -2157,6 +_,15 @@ +@@ -2147,6 +_,15 @@ for (Leashable leashable1 : list) { if (leashable1.canHaveALeashAttachedTo(this)) { @@ -1023,7 +1020,7 @@ leashable1.setLeashedTo(this, true); flag = true; } -@@ -2171,7 +_,7 @@ +@@ -2161,7 +_,7 @@ } ItemStack itemInHand = player.getItemInHand(hand); @@ -1032,7 +1029,7 @@ itemInHand.hurtAndBreak(1, player, hand); return InteractionResult.SUCCESS; } else if (this instanceof Mob mob -@@ -2184,11 +_,13 @@ +@@ -2174,11 +_,13 @@ if (this.isAlive() && this instanceof Leashable leashable2) { if (leashable2.getLeashHolder() == player) { if (!this.level().isClientSide()) { @@ -1050,7 +1047,7 @@ this.gameEvent(GameEvent.ENTITY_INTERACT, player); this.playSound(SoundEvents.LEAD_UNTIED); -@@ -2201,9 +_,22 @@ +@@ -2191,9 +_,22 @@ if (itemInHand1.is(Items.LEAD) && !(leashable2.getLeashHolder() instanceof Player)) { if (!this.level().isClientSide() && leashable2.canHaveALeashAttachedTo(player)) { if (leashable2.isLeashed()) { @@ -1074,7 +1071,7 @@ leashable2.setLeashedTo(player, true); this.playSound(SoundEvents.LEAD_TIED); itemInHand1.shrink(1); -@@ -2218,7 +_,12 @@ +@@ -2208,7 +_,12 @@ } public boolean shearOffAllLeashConnections(@Nullable Player player) { @@ -1088,7 +1085,7 @@ if (flag && this.level() instanceof ServerLevel serverLevel) { serverLevel.playSound(null, this.blockPosition(), SoundEvents.SHEARS_SNIP, player != null ? player.getSoundSource() : this.getSoundSource()); } -@@ -2227,15 +_,38 @@ +@@ -2217,15 +_,38 @@ } public boolean dropAllLeashConnections(@Nullable Player player) { @@ -1131,7 +1128,7 @@ } if (flag) { -@@ -2259,7 +_,9 @@ +@@ -2249,7 +_,9 @@ this.gameEvent(GameEvent.SHEAR, player); this.playSound(equippable.shearingSound().value()); if (this.level() instanceof ServerLevel serverLevel) { @@ -1141,7 +1138,7 @@ CriteriaTriggers.PLAYER_SHEARED_EQUIPMENT.trigger((ServerPlayer)player, itemBySlot, mob); } -@@ -2332,11 +_,11 @@ +@@ -2322,11 +_,11 @@ } public boolean startRiding(Entity entity, boolean force, boolean triggerEvents) { @@ -1155,7 +1152,7 @@ return false; } else { for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) { -@@ -2346,6 +_,27 @@ +@@ -2336,6 +_,27 @@ } if (force || this.canRide(entity) && entity.canAddPassenger(this)) { @@ -1183,7 +1180,7 @@ if (this.isPassenger()) { this.stopRiding(); } -@@ -2378,10 +_,16 @@ +@@ -2368,10 +_,16 @@ } public void removeVehicle() { @@ -1201,7 +1198,7 @@ Entity.RemovalReason removalReason = this.getRemovalReason(); if (removalReason == null || removalReason.shouldDestroy()) { this.level().gameEvent(this, GameEvent.ENTITY_DISMOUNT, entity.position); -@@ -2390,7 +_,13 @@ +@@ -2380,7 +_,13 @@ } public void stopRiding() { @@ -1216,7 +1213,7 @@ } protected void addPassenger(Entity passenger) { -@@ -2412,10 +_,43 @@ +@@ -2402,10 +_,43 @@ } } @@ -1261,7 +1258,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == passenger) { this.passengers = ImmutableList.of(); } else { -@@ -2424,6 +_,7 @@ +@@ -2414,6 +_,7 @@ passenger.boardingCooldown = 60; } @@ -1269,7 +1266,7 @@ } protected boolean canAddPassenger(Entity passenger) { -@@ -2524,7 +_,8 @@ +@@ -2513,7 +_,8 @@ TeleportTransition portalDestination = this.portalProcess.getPortalDestination(serverLevel, this); if (portalDestination != null) { ServerLevel level = portalDestination.newLevel(); @@ -1279,7 +1276,7 @@ ) { this.teleport(portalDestination); -@@ -2607,7 +_,7 @@ +@@ -2596,7 +_,7 @@ } public boolean isCrouching() { @@ -1288,7 +1285,7 @@ } public boolean isSprinting() { -@@ -2623,7 +_,7 @@ +@@ -2612,7 +_,7 @@ } public boolean isVisuallySwimming() { @@ -1297,7 +1294,7 @@ } public boolean isVisuallyCrawling() { -@@ -2631,6 +_,13 @@ +@@ -2620,6 +_,13 @@ } public void setSwimming(boolean swimming) { @@ -1311,15 +1308,15 @@ this.setSharedFlag(FLAG_SWIMMING, swimming); } -@@ -2669,6 +_,7 @@ +@@ -2657,6 +_,7 @@ + } - @Nullable - public PlayerTeam getTeam() { + public @Nullable PlayerTeam getTeam() { + if (!this.level().paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof Player)) { return null; } // Paper - Perf: Disable Scoreboards for non players by default return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -2685,7 +_,11 @@ +@@ -2673,7 +_,11 @@ } public void setInvisible(boolean invisible) { @@ -1332,7 +1329,7 @@ } public boolean getSharedFlag(int flag) { -@@ -2702,7 +_,7 @@ +@@ -2690,7 +_,7 @@ } public int getMaxAirSupply() { @@ -1341,7 +1338,7 @@ } public int getAirSupply() { -@@ -2710,10 +_,22 @@ +@@ -2698,10 +_,22 @@ } public void setAirSupply(int airSupply) { @@ -1365,7 +1362,7 @@ this.setTicksFrozen(0); } -@@ -2740,11 +_,43 @@ +@@ -2728,11 +_,43 @@ public void thunderHit(ServerLevel level, LightningBolt lightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -1413,7 +1410,7 @@ } public void onAboveBubbleColumn(boolean downwards, BlockPos pos) { -@@ -2900,26 +_,30 @@ +@@ -2888,26 +_,30 @@ return this.removalReason != null ? String.format( Locale.ROOT, @@ -1447,7 +1444,7 @@ ); } -@@ -2943,6 +_,13 @@ +@@ -2931,6 +_,13 @@ } public void restoreFrom(Entity entity) { @@ -1461,10 +1458,10 @@ try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) { TagValueOutput tagValueOutput = TagValueOutput.createWithContext(scopedCollector, entity.registryAccess()); entity.saveWithoutId(tagValueOutput); -@@ -2955,7 +_,65 @@ +@@ -2942,7 +_,65 @@ + } - @Nullable - public Entity teleport(TeleportTransition teleportTransition) { + public @Nullable Entity teleport(TeleportTransition teleportTransition) { + // Paper start - Fix item duplication and teleport issues + if ((!this.isAlive() || !this.valid) && (teleportTransition.newLevel() != this.level)) { + LOGGER.warn("Illegal Entity Teleport {} to {}:{}", this, teleportTransition.newLevel(), teleportTransition.position(), new Throwable()); @@ -1527,7 +1524,7 @@ ServerLevel level = teleportTransition.newLevel(); boolean flag = level.dimension() != serverLevel.dimension(); if (!teleportTransition.asPassenger()) { -@@ -3005,10 +_,15 @@ +@@ -2991,10 +_,15 @@ profilerFiller.pop(); return null; } else { @@ -1544,7 +1541,7 @@ for (Entity entity2 : list) { entity2.startRiding(entityx, true, false); -@@ -3098,9 +_,17 @@ +@@ -3084,9 +_,17 @@ } protected void removeAfterChangingDimensions() { @@ -1565,7 +1562,7 @@ } if (this instanceof WaypointTransmitter waypointTransmitter && this.level instanceof ServerLevel serverLevel) { -@@ -3117,6 +_,7 @@ +@@ -3103,6 +_,7 @@ } public boolean canTeleport(Level fromLevel, Level toLevel) { @@ -1573,7 +1570,7 @@ if (fromLevel.dimension() == Level.END && toLevel.dimension() == Level.OVERWORLD) { for (Entity entity : this.getPassengers()) { if (entity instanceof ServerPlayer serverPlayer && !serverPlayer.seenCredits) { -@@ -3224,13 +_,19 @@ +@@ -3209,13 +_,19 @@ return this.entityData.get(DATA_CUSTOM_NAME_VISIBLE); } @@ -1596,7 +1593,7 @@ } public void teleportTo(double x, double y, double z) { -@@ -3339,7 +_,26 @@ +@@ -3324,7 +_,26 @@ } public final void setBoundingBox(AABB bb) { @@ -1624,7 +1621,7 @@ } public final float getEyeHeight(Pose pose) { -@@ -3366,6 +_,12 @@ +@@ -3352,6 +_,12 @@ } public void stopSeenByPlayer(ServerPlayer player) { @@ -1637,16 +1634,7 @@ } public float rotate(Rotation transformRotation) { -@@ -3394,7 +_,7 @@ - } - - @Nullable -- public LivingEntity getControllingPassenger() { -+ public net.minecraft.world.entity.LivingEntity getControllingPassenger() { - return null; - } - -@@ -3426,21 +_,32 @@ +@@ -3410,21 +_,32 @@ } private Stream getIndirectPassengersStream() { @@ -1680,7 +1668,7 @@ } public int countPlayerPassengers() { -@@ -3448,6 +_,7 @@ +@@ -3432,6 +_,7 @@ } public boolean hasExactlyOnePlayerPassenger() { @@ -1688,7 +1676,7 @@ return this.countPlayerPassengers() == 1; } -@@ -3530,9 +_,38 @@ +@@ -3512,9 +_,38 @@ return 0; } @@ -1706,7 +1694,7 @@ + + @Override + public boolean acceptsSuccess() { -+ return ((ServerLevel) Entity.this.level()).getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_SENDCOMMANDFEEDBACK); ++ return ((ServerLevel) Entity.this.level()).getGameRules().get(net.minecraft.world.level.gamerules.GameRules.COMMAND_BLOCK_OUTPUT); + } + + @Override @@ -1728,7 +1716,7 @@ this.position(), this.getRotationVector(), level, -@@ -3598,6 +_,11 @@ +@@ -3580,6 +_,11 @@ vec3 = vec3.add(flow); i++; } @@ -1740,7 +1728,7 @@ } } } -@@ -3696,7 +_,9 @@ +@@ -3678,7 +_,9 @@ } public void setDeltaMovement(Vec3 deltaMovement) { @@ -1750,7 +1738,7 @@ } public void addDeltaMovement(Vec3 addend) { -@@ -3759,9 +_,35 @@ +@@ -3741,9 +_,35 @@ return this.getZ((2.0 * this.random.nextDouble() - 1.0) * scale); } @@ -1786,7 +1774,7 @@ int floor = Mth.floor(x); int floor1 = Mth.floor(y); int floor2 = Mth.floor(z); -@@ -3783,7 +_,18 @@ +@@ -3765,7 +_,18 @@ serverLevel.getWaypointManager().updatePlayer(serverPlayer); } } @@ -1806,7 +1794,7 @@ } public void checkDespawn() { -@@ -3836,6 +_,12 @@ +@@ -3817,6 +_,12 @@ return this.getTicksFrozen() > 0; } @@ -1819,18 +1807,18 @@ public float getYRot() { return this.yRot; } -@@ -3887,7 +_,9 @@ +@@ -3867,7 +_,9 @@ } @Override - public final void setRemoved(Entity.RemovalReason removalReason) { -+ public final void setRemoved(Entity.RemovalReason removalReason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause ++ public final void setRemoved(Entity.RemovalReason removalReason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { // CraftBukkit - add Bukkit remove cause + org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); // CraftBukkit + final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers if (this.removalReason == null) { this.removalReason = removalReason; } -@@ -3899,12 +_,28 @@ +@@ -3879,12 +_,28 @@ this.getPassengers().forEach(Entity::stopRiding); this.levelCallback.onRemove(removalReason); this.onRemoval(removalReason); @@ -1859,7 +1847,7 @@ @Override public void setLevelCallback(EntityInLevelCallback levelCallback) { this.levelCallback = levelCallback; -@@ -4101,4 +_,14 @@ +@@ -4078,4 +_,14 @@ return this.save; } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntityReference.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntityReference.java.patch index 52e052d9b0fa..0a2cd6195a45 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/EntityReference.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntityReference.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityReference.java +++ b/net/minecraft/world/entity/EntityReference.java -@@ -150,4 +_,15 @@ +@@ -140,4 +_,15 @@ public int hashCode() { return this.getUUID().hashCode(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch index 9717149ae655..018611242bd6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -1283,6 +_,22 @@ +@@ -1289,6 +_,22 @@ boolean shouldOffsetY, boolean shouldOffsetYMore ) { @@ -23,7 +23,7 @@ Consumer consumer; if (spawnedFrom != null) { consumer = createDefaultStackConfig(level, spawnedFrom, owner); -@@ -1290,7 +_,7 @@ +@@ -1296,7 +_,7 @@ consumer = entity -> {}; } @@ -32,7 +32,7 @@ } public static Consumer createDefaultStackConfig(Level level, ItemStack stack, @Nullable LivingEntity owner) { -@@ -1307,21 +_,58 @@ +@@ -1313,19 +_,54 @@ public static Consumer appendCustomEntityStackConfig(Consumer consumer, Level level, ItemStack stack, @Nullable LivingEntity owner) { TypedEntityData> typedEntityData = stack.get(DataComponents.ENTITY_DATA); @@ -48,21 +48,17 @@ + // CraftBukkit end } - @Nullable - public T spawn(ServerLevel level, BlockPos pos, EntitySpawnReason spawnReason) { + public @Nullable T spawn(ServerLevel level, BlockPos pos, EntitySpawnReason spawnReason) { - return this.spawn(level, null, pos, spawnReason, false, false); + // CraftBukkit start + return this.spawn(level, pos, spawnReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } -+ -+ @Nullable -+ public T spawn(ServerLevel level, BlockPos pos, EntitySpawnReason spawnReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) { ++ public @Nullable T spawn(ServerLevel level, BlockPos pos, EntitySpawnReason spawnReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) { + return this.spawn(level, null, pos, spawnReason, false, false, creatureSpawnReason); + // CraftBukkit End } - @Nullable - public T spawn( + public @Nullable T spawn( ServerLevel level, @Nullable Consumer consumer, BlockPos pos, EntitySpawnReason spawnReason, boolean shouldOffsetY, boolean shouldOffsetYMore ) { + // CraftBukkit start @@ -94,7 +90,7 @@ if (entity instanceof Mob mob) { mob.playAmbientSound(); } -@@ -1376,6 +_,13 @@ +@@ -1381,6 +_,13 @@ if (level.isClientSide() || !entity.getType().onlyOpCanSetNbt() || owner instanceof Player player && server.getPlayerList().isOp(player.nameAndId())) { @@ -108,7 +104,7 @@ entityData.loadInto(entity); } } -@@ -1447,9 +_,20 @@ +@@ -1451,9 +_,20 @@ } public static Optional create(ValueInput input, Level level, EntitySpawnReason spawnReason) { @@ -130,7 +126,7 @@ () -> LOGGER.warn("Skipping Entity with id {}", input.getStringOr("id", "[invalid]")) ); } -@@ -1606,8 +_,23 @@ +@@ -1605,8 +_,23 @@ return this.builtInRegistryHolder; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch index 744ae96e3aca..77020cd48c6a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch @@ -1,14 +1,12 @@ --- a/net/minecraft/world/entity/ExperienceOrb.java +++ b/net/minecraft/world/entity/ExperienceOrb.java -@@ -44,13 +_,59 @@ - @Nullable - private Player followingPlayer; +@@ -43,13 +_,57 @@ + public int count = 1; + private @Nullable Player followingPlayer; private final InterpolationHandler interpolation = new InterpolationHandler(this); + // Paper start -+ @Nullable -+ public java.util.UUID sourceEntityId; -+ @Nullable -+ public java.util.UUID triggerEntityId; ++ public java.util.@Nullable UUID sourceEntityId; ++ public java.util.@Nullable UUID triggerEntityId; + public org.bukkit.entity.ExperienceOrb.SpawnReason spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.UNKNOWN; + private void loadPaperNBT(ValueInput input) { @@ -40,7 +38,7 @@ + // Paper start - add reasons for orbs + this(level, x, y, z, value, null, null, null); + } -+ public ExperienceOrb(Level level, double x, double y, double z, int value, @Nullable org.bukkit.entity.ExperienceOrb.SpawnReason reason, @Nullable Entity triggerId, @Nullable Entity sourceId) { ++ public ExperienceOrb(Level level, double x, double y, double z, int value, org.bukkit.entity.ExperienceOrb.@Nullable SpawnReason reason, @Nullable Entity triggerId, @Nullable Entity sourceId) { + this(level, new Vec3(x, y, z), Vec3.ZERO, value, reason, triggerId, sourceId); + // Paper end - add reasons for orbs } @@ -50,7 +48,7 @@ + // Paper start - add reasons for orbs + this(level, pos, direction, value, null, null, null); + } -+ public ExperienceOrb(Level level, Vec3 pos, Vec3 direction, int value, @Nullable org.bukkit.entity.ExperienceOrb.SpawnReason reason, @Nullable Entity triggerId, @Nullable Entity sourceId) { ++ public ExperienceOrb(Level level, Vec3 pos, Vec3 direction, int value, org.bukkit.entity.ExperienceOrb.@Nullable SpawnReason reason, @Nullable Entity triggerId, @Nullable Entity sourceId) { + // Paper end - add reasons for orbs this(EntityType.EXPERIENCE_ORB, level); + // Paper start - add reasons for orbs @@ -61,7 +59,7 @@ this.setPos(pos); if (!level.isClientSide()) { this.setYRot(this.random.nextFloat() * 360.0F); -@@ -147,12 +_,13 @@ +@@ -146,12 +_,13 @@ this.age++; if (this.age >= 6000) { @@ -76,7 +74,7 @@ if (this.followingPlayer == null || this.followingPlayer.isSpectator() || this.followingPlayer.distanceToSqr(this) > 64.0) { Player nearestPlayer = this.level().getNearestPlayer(this, 8.0); if (nearestPlayer != null && !nearestPlayer.isSpectator() && !nearestPlayer.isDeadOrDying()) { -@@ -162,7 +_,24 @@ +@@ -161,7 +_,24 @@ } } @@ -102,14 +100,14 @@ Vec3 vec3 = new Vec3( this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + this.followingPlayer.getEyeHeight() / 2.0 - this.getY(), -@@ -193,18 +_,24 @@ +@@ -192,18 +_,24 @@ } public static void awardWithDirection(ServerLevel level, Vec3 pos, Vec3 direction, int amount) { + // Paper start - add reason to orbs + awardWithDirection(level, pos, direction, amount, null, null, null); + } -+ public static void awardWithDirection(ServerLevel level, Vec3 pos, Vec3 direction, int amount, @Nullable org.bukkit.entity.ExperienceOrb.SpawnReason reason, @Nullable Entity triggerId, @Nullable Entity sourceId) { ++ public static void awardWithDirection(ServerLevel level, Vec3 pos, Vec3 direction, int amount, org.bukkit.entity.ExperienceOrb.@Nullable SpawnReason reason, @Nullable Entity triggerId, @Nullable Entity sourceId) { + // Paper end - add reason to orbs while (amount > 0) { int experienceValue = getExperienceValue(amount); @@ -129,7 +127,7 @@ List entities = level.getEntities( EntityTypeTest.forClass(ExperienceOrb.class), aabb, experienceOrb1 -> canMerge(experienceOrb1, randomInt, amount) ); -@@ -223,13 +_,18 @@ +@@ -222,13 +_,18 @@ } private static boolean canMerge(ExperienceOrb orb, int amount, int other) { @@ -150,7 +148,7 @@ } private void setUnderwaterMovement() { -@@ -254,7 +_,7 @@ +@@ -253,7 +_,7 @@ this.markHurt(); this.health = (int)(this.health - amount); if (this.health <= 0) { @@ -159,7 +157,7 @@ } return true; -@@ -265,32 +_,34 @@ +@@ -264,32 +_,34 @@ protected void addAdditionalSaveData(ValueOutput output) { output.putShort("Health", (short)this.health); output.putShort("Age", (short)this.age); @@ -200,7 +198,7 @@ } } } -@@ -304,9 +_,19 @@ +@@ -303,9 +_,19 @@ ItemStack itemStack = randomItemWith.get().itemStack(); int i = EnchantmentHelper.modifyDurabilityToRepairFromXp(player.level(), itemStack, value); int min = Math.min(i, itemStack.getDamageValue()); @@ -221,7 +219,7 @@ if (i1 > 0) { return this.repairPlayerItems(player, i1); } -@@ -352,6 +_,24 @@ +@@ -351,6 +_,24 @@ } public static int getExperienceValue(int expValue) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch index a047e73e5938..64ff18b39efb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Interaction.java +++ b/net/minecraft/world/entity/Interaction.java -@@ -101,9 +_,16 @@ +@@ -99,9 +_,16 @@ @Override public boolean skipAttackInteraction(Entity entity) { if (entity instanceof Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Leashable.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Leashable.java.patch index abff20c395c0..568f7284c189 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Leashable.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Leashable.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/Leashable.java +++ b/net/minecraft/world/entity/Leashable.java -@@ -80,6 +_,11 @@ +@@ -79,6 +_,11 @@ } - default void writeLeashData(ValueOutput output, @Nullable Leashable.LeashData leashData) { + default void writeLeashData(ValueOutput output, Leashable.@Nullable LeashData leashData) { + // CraftBukkit start - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin + if (leashData != null && leashData.leashHolder != null && leashData.leashHolder.pluginRemoved) { + return; @@ -12,7 +12,7 @@ output.storeNullable("leash", Leashable.LeashData.CODEC, leashData); } -@@ -99,7 +_,9 @@ +@@ -98,7 +_,9 @@ } if (entity.tickCount > 100) { @@ -22,7 +22,7 @@ entity.setLeashData(null); } } -@@ -123,7 +_,9 @@ +@@ -122,7 +_,9 @@ entity.onLeashRemoved(); if (entity.level() instanceof ServerLevel serverLevel) { if (dropItem) { @@ -32,16 +32,16 @@ } if (broadcastPacket) { -@@ -143,7 +_,15 @@ +@@ -142,7 +_,15 @@ if (leashData != null && leashData.leashHolder != null) { if (!entity.canInteractWithLevel() || !leashData.leashHolder.canInteractWithLevel()) { -- if (level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { +- if (level.getGameRules().get(GameRules.ENTITY_DROPS)) { + // Paper start - Expand EntityUnleashEvent + final org.bukkit.event.entity.EntityUnleashEvent event = new org.bukkit.event.entity.EntityUnleashEvent( + entity.getBukkitEntity(), + !entity.isAlive() ? org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.PLAYER_UNLEASH : org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.HOLDER_GONE, -+ level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !entity.pluginRemoved ++ level.getGameRules().get(GameRules.ENTITY_DROPS) && !entity.pluginRemoved + ); + event.callEvent(); + if (event.isDropLeash()) { // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin @@ -49,7 +49,7 @@ entity.dropLeash(); } else { entity.removeLeash(); -@@ -154,8 +_,7 @@ +@@ -153,8 +_,7 @@ if (leashHolder != null && leashHolder.level() == entity.level()) { double d = entity.leashDistanceTo(leashHolder); entity.whenLeashedTo(leashHolder); @@ -59,7 +59,7 @@ entity.leashTooFarBehaviour(); } else if (d > entity.leashElasticDistance() - leashHolder.getBbWidth() - entity.getBbWidth() && entity.checkElasticInteractions(leashHolder, leashData)) { -@@ -175,6 +_,12 @@ +@@ -174,6 +_,12 @@ entity.checkFallDistanceAccumulation(); } @@ -72,7 +72,7 @@ default double leashSnapDistance() { return 12.0; } -@@ -196,7 +_,25 @@ +@@ -195,7 +_,25 @@ } default void leashTooFarBehaviour() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch index 2e1221d33669..e83be8e541c0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/LightningBolt.java +++ b/net/minecraft/world/entity/LightningBolt.java -@@ -41,6 +_,7 @@ - private ServerPlayer cause; +@@ -39,6 +_,7 @@ + private @Nullable ServerPlayer cause; private final Set hitEntities = Sets.newHashSet(); private int blocksSetOnFire; + public boolean isEffect; // Paper - Properly handle lightning effects api public LightningBolt(EntityType type, Level level) { super(type, level); -@@ -78,7 +_,7 @@ +@@ -75,7 +_,7 @@ @Override public void tick() { super.tick(); @@ -17,7 +17,7 @@ if (this.level().isClientSide()) { this.level() .playLocalSound( -@@ -109,7 +_,7 @@ +@@ -106,7 +_,7 @@ } this.powerLightningRod(); @@ -26,7 +26,7 @@ this.gameEvent(GameEvent.LIGHTNING_STRIKE); } } -@@ -132,7 +_,7 @@ +@@ -129,7 +_,7 @@ } } @@ -35,7 +35,7 @@ } else if (this.life < -this.random.nextInt(10)) { this.flashes--; this.life = 1; -@@ -141,10 +_,10 @@ +@@ -138,10 +_,10 @@ } } @@ -48,38 +48,47 @@ List entities = this.level() .getEntities( this, -@@ -170,32 +_,45 @@ +@@ -167,34 +_,47 @@ } private void spawnFire(int extraIgnitions) { -- if (!this.visualOnly && this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { -+ if (!this.visualOnly && !this.isEffect && this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { // Paper - prevent any fire if only effect - BlockPos blockPos = this.blockPosition(); - BlockState state = BaseFireBlock.getState(this.level(), blockPos); - if (this.level().getBlockState(blockPos).isAir() && state.canSurvive(this.level(), blockPos)) { -- this.level().setBlockAndUpdate(blockPos, state); -- this.blocksSetOnFire++; -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), blockPos, this).isCancelled()) { -+ this.level().setBlockAndUpdate(blockPos, state); -+ this.blocksSetOnFire++; -+ } -+ // CraftBukkit end - } - - for (int i = 0; i < extraIgnitions; i++) { - BlockPos blockPos1 = blockPos.offset(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); - state = BaseFireBlock.getState(this.level(), blockPos1); - if (this.level().getBlockState(blockPos1).isAir() && state.canSurvive(this.level(), blockPos1)) { -- this.level().setBlockAndUpdate(blockPos1, state); +- if (!this.visualOnly && this.level() instanceof ServerLevel serverLevel) { ++ if (!this.visualOnly && !this.isEffect && this.level() instanceof ServerLevel serverLevel) { // Paper - prevent any fire if only effect + BlockPos var7 = this.blockPosition(); + if (serverLevel.canSpreadFireAround(var7)) { +- BlockState state = BaseFireBlock.getState(serverLevel, var7); +- if (serverLevel.getBlockState(var7).isAir() && state.canSurvive(serverLevel, var7)) { +- serverLevel.setBlockAndUpdate(var7, state); - this.blocksSetOnFire++; -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), blockPos1, this).isCancelled()) { -+ this.level().setBlockAndUpdate(blockPos1, state); -+ this.blocksSetOnFire++; +- } +- +- for (int i = 0; i < extraIgnitions; i++) { +- BlockPos blockPos1 = var7.offset(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); +- state = BaseFireBlock.getState(serverLevel, blockPos1); +- if (serverLevel.getBlockState(blockPos1).isAir() && state.canSurvive(serverLevel, blockPos1)) { +- serverLevel.setBlockAndUpdate(blockPos1, state); ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), var7, this).isCancelled()) { ++ BlockState state = BaseFireBlock.getState(serverLevel, var7); ++ if (serverLevel.getBlockState(var7).isAir() && state.canSurvive(serverLevel, var7)) { ++ serverLevel.setBlockAndUpdate(var7, state); + this.blocksSetOnFire++; + } ++ ++ for (int i = 0; i < extraIgnitions; i++) { ++ BlockPos blockPos1 = var7.offset(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); ++ state = BaseFireBlock.getState(serverLevel, blockPos1); ++ if (serverLevel.getBlockState(blockPos1).isAir() && state.canSurvive(serverLevel, blockPos1)) { ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), blockPos1, this).isCancelled()) { ++ serverLevel.setBlockAndUpdate(blockPos1, state); ++ this.blocksSetOnFire++; ++ } ++ // CraftBukkit end ++ } + } -+ // CraftBukkit end } ++ // CraftBukkit end } } } @@ -101,7 +110,7 @@ } BlockPos.MutableBlockPos mutableBlockPos = pos.mutable(); -@@ -203,16 +_,16 @@ +@@ -202,16 +_,16 @@ for (int i1 = 0; i1 < i; i1++) { int i2 = level.random.nextInt(8) + 1; @@ -121,7 +130,7 @@ if (optional.isEmpty()) { break; } -@@ -221,11 +_,17 @@ +@@ -220,11 +_,17 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index 61427a84a015..71ae2b9750b1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -142,6 +_,17 @@ - import org.jetbrains.annotations.Contract; +@@ -141,6 +_,17 @@ + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; +// CraftBukkit start @@ -18,7 +18,7 @@ public abstract class LivingEntity extends Entity implements Attackable, WaypointTransmitter { private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; -@@ -272,11 +_,25 @@ +@@ -266,11 +_,25 @@ ); protected final EntityEquipment equipment; private Waypoint.Icon locatorBarIcon = new Waypoint.Icon(); @@ -45,7 +45,7 @@ this.equipment = this.createEquipment(); this.blocksBuilding = true; this.reapplyPosition(); -@@ -378,7 +_,13 @@ +@@ -369,7 +_,13 @@ double d1 = Math.min(0.2F + d / 15.0, 2.5); int i = (int)(150.0 * d1); @@ -60,7 +60,7 @@ } } -@@ -563,7 +_,7 @@ +@@ -554,7 +_,7 @@ this.deathTime++; if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { this.level().broadcastEntityEvent(this, EntityEvent.POOF); @@ -69,7 +69,7 @@ } } -@@ -668,7 +_,7 @@ +@@ -656,7 +_,7 @@ } public boolean shouldDiscardFriction() { @@ -78,7 +78,7 @@ } public void setDiscardFriction(boolean discardFriction) { -@@ -680,10 +_,15 @@ +@@ -668,10 +_,15 @@ } public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem) { @@ -95,12 +95,12 @@ this.level() .playSeededSound( null, -@@ -710,12 +_,12 @@ +@@ -698,12 +_,12 @@ } @Override - public void remove(Entity.RemovalReason reason) { -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { // CraftBukkit - add Bukkit remove cause ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause eventCause) { // CraftBukkit - add Bukkit remove cause if ((reason == Entity.RemovalReason.KILLED || reason == Entity.RemovalReason.DISCARDED) && this.level() instanceof ServerLevel serverLevel) { this.triggerOnDeathMobEffects(serverLevel, reason); } @@ -110,7 +110,7 @@ this.brain.clearMemories(); } -@@ -732,11 +_,17 @@ +@@ -720,11 +_,17 @@ mobEffectInstance.onMobRemoved(level, this, removalReason); } @@ -128,25 +128,21 @@ output.putFloat("Health", this.getHealth()); output.putShort("HurtTime", (short)this.hurtTime); output.putInt("HurtByTimestamp", this.lastHurtByMobTimestamp); -@@ -770,8 +_,15 @@ +@@ -758,7 +_,12 @@ } } -- @Nullable -- public ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower) { +- public @Nullable ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower) { + // Paper start - Extend dropItem API -+ @Nullable -+ public final ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower) { ++ public final @Nullable ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower) { + return this.drop(stack, randomizeMotion, includeThrower, true, null); + } -+ -+ @Nullable -+ public ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower, boolean callEvent, @Nullable java.util.function.Consumer entityOperation) { ++ public @Nullable ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower, boolean callEvent, java.util.function.@Nullable Consumer entityOperation) { + // Paper end - Extend dropItem API if (stack.isEmpty()) { return null; } else if (this.level().isClientSide()) { -@@ -780,6 +_,31 @@ +@@ -767,6 +_,31 @@ } else { ItemEntity itemEntity = this.createItemStackToDrop(stack, randomizeMotion, includeThrower); if (itemEntity != null) { @@ -178,7 +174,7 @@ this.level().addFreshEntity(itemEntity); } -@@ -789,7 +_,22 @@ +@@ -776,7 +_,22 @@ @Override protected void readAdditionalSaveData(ValueInput input) { @@ -202,7 +198,7 @@ if (this.level() != null && !this.level().isClientSide()) { input.read("attributes", AttributeInstance.Packed.LIST_CODEC).ifPresent(this.getAttributes()::apply); } -@@ -802,6 +_,11 @@ +@@ -789,6 +_,11 @@ this.effectsDirty = true; } @@ -214,7 +210,7 @@ this.setHealth(input.getFloatOr("Health", this.getMaxHealth())); this.hurtTime = input.getShortOr("HurtTime", (short)0); this.deathTime = input.getShortOr("DeathTime", (short)0); -@@ -809,6 +_,7 @@ +@@ -796,6 +_,7 @@ input.getString("Team").ifPresent(string -> { Scoreboard scoreboard = this.level().getScoreboard(); PlayerTeam playerTeam = scoreboard.getPlayerTeam(string); @@ -222,7 +218,7 @@ boolean flag = playerTeam != null && scoreboard.addPlayerToTeam(this.getStringUUID(), playerTeam); if (!flag) { LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", string); -@@ -816,11 +_,13 @@ +@@ -803,11 +_,13 @@ }); this.setSharedFlag(Entity.FLAG_FALL_FLYING, input.getBooleanOr("FallFlying", false)); input.read("sleeping_pos", BlockPos.CODEC).ifPresentOrElse(blockPos -> { @@ -236,7 +232,7 @@ }, this::clearSleepingPos); input.read("Brain", Codec.PASSTHROUGH).ifPresent(dynamic -> this.brain = this.makeBrain((Dynamic)dynamic)); this.lastHurtByPlayer = EntityReference.read(input, "last_hurt_by_player"); -@@ -837,15 +_,44 @@ +@@ -824,15 +_,44 @@ this.updateDirtyEffects(); } @@ -281,7 +277,7 @@ iterator.remove(); this.onEffectsRemoved(List.of(mobEffectInstance)); } else if (mobEffectInstance.getDuration() % 600 == 0) { -@@ -854,6 +_,18 @@ +@@ -841,6 +_,18 @@ } } catch (ConcurrentModificationException var6) { } @@ -300,7 +296,7 @@ } else { for (MobEffectInstance mobEffectInstance1 : this.activeEffects.values()) { mobEffectInstance1.tickClient(); -@@ -964,15 +_,33 @@ +@@ -951,15 +_,33 @@ } public boolean removeAllEffects() { @@ -338,7 +334,7 @@ } } -@@ -999,21 +_,57 @@ +@@ -985,21 +_,57 @@ } public final boolean addEffect(MobEffectInstance effectInstance) { @@ -398,16 +394,14 @@ this.onEffectUpdated(mobEffectInstance, true, entity); flag = true; } -@@ -1052,11 +_,37 @@ +@@ -1037,11 +_,35 @@ + } - @Nullable - public final MobEffectInstance removeEffectNoUpdate(Holder effect) { -+// CraftBukkit start + public final @Nullable MobEffectInstance removeEffectNoUpdate(Holder effect) { ++ // CraftBukkit start + return this.removeEffectNoUpdate(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); + } -+ -+ @Nullable -+ public MobEffectInstance removeEffectNoUpdate(Holder effect, EntityPotionEffectEvent.Cause cause) { ++ public @Nullable MobEffectInstance removeEffectNoUpdate(Holder effect, EntityPotionEffectEvent.Cause cause) { + if (this.isTickingEffects) { + this.effectsToProcess.add(new ProcessableEffect(effect, cause)); + return null; @@ -422,7 +416,7 @@ + if (event.isCancelled()) { + return null; + } -+// CraftBukkit end ++ // CraftBukkit end return this.activeEffects.remove(effect); } @@ -437,7 +431,7 @@ if (mobEffectInstance != null) { this.onEffectsRemoved(List.of(mobEffectInstance)); return true; -@@ -1147,17 +_,62 @@ +@@ -1132,17 +_,62 @@ } public void heal(float amount) { @@ -501,7 +495,7 @@ this.entityData.set(DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth())); } -@@ -1169,7 +_,7 @@ +@@ -1154,7 +_,7 @@ public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { if (this.isInvulnerableTo(level, damageSource)) { return false; @@ -510,7 +504,7 @@ return false; } else if (damageSource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1185,35 +_,58 @@ +@@ -1170,35 +_,58 @@ ItemStack useItem = this.getUseItem(); float originAmount = amount; @@ -577,7 +571,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1228,7 +_,7 @@ +@@ -1213,7 +_,7 @@ level.broadcastDamageEvent(this, damageSource); } @@ -586,7 +580,7 @@ this.markHurt(); } -@@ -1243,8 +_,16 @@ +@@ -1228,8 +_,16 @@ d = damageSource.getSourcePosition().x() - this.getX(); d1 = damageSource.getSourcePosition().z() - this.getZ(); } @@ -604,7 +598,7 @@ if (!flag) { this.indicateDamage(d, d1); } -@@ -1253,19 +_,19 @@ +@@ -1238,19 +_,19 @@ if (this.isDeadOrDying()) { if (!this.checkTotemDeathProtection(damageSource)) { @@ -629,7 +623,7 @@ if (flag2) { this.lastDamageSource = damageSource; this.lastDamageStamp = this.level().getGameTime(); -@@ -1291,6 +_,12 @@ +@@ -1276,6 +_,12 @@ } public float applyItemBlocking(ServerLevel level, DamageSource damageSource, float damageAmount) { @@ -642,7 +636,7 @@ if (damageAmount <= 0.0F) { return 0.0F; } else { -@@ -1315,10 +_,12 @@ +@@ -1300,10 +_,12 @@ } float f = blocksAttacks.resolveBlockedDamage(damageSource, damageAmount, acos); @@ -656,7 +650,7 @@ return f; } -@@ -1329,6 +_,59 @@ +@@ -1314,6 +_,59 @@ } } @@ -716,7 +710,7 @@ public void playSecondaryHurtSound(DamageSource damageSource) { if (damageSource.is(DamageTypes.THORNS)) { SoundSource soundSource = this instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE; -@@ -1361,12 +_,24 @@ +@@ -1345,12 +_,24 @@ return EntityReference.getPlayer(this.lastHurtByPlayer, this.level()); } @@ -742,7 +736,7 @@ } private boolean checkTotemDeathProtection(DamageSource damageSource) { -@@ -1376,18 +_,39 @@ +@@ -1360,18 +_,39 @@ ItemStack itemStack = null; DeathProtection deathProtection = null; @@ -789,7 +783,7 @@ serverPlayer.awardStat(Stats.ITEM_USED.get(itemStack.getItem())); CriteriaTriggers.USED_TOTEM.trigger(serverPlayer, itemStack); this.gameEvent(GameEvent.ITEM_INTERACT_FINISH); -@@ -1446,6 +_,7 @@ +@@ -1429,6 +_,7 @@ if (!this.isRemoved() && !this.dead) { Entity entity = damageSource.getEntity(); LivingEntity killCredit = this.getKillCredit(); @@ -797,7 +791,7 @@ if (killCredit != null) { killCredit.awardKillScore(this, damageSource); } -@@ -1455,68 +_,147 @@ +@@ -1438,68 +_,147 @@ } if (!this.level().isClientSide() && this.hasCustomName()) { @@ -871,7 +865,7 @@ boolean var6 = false; - if (entitySource instanceof WitherBoss) { + if (this.dead && entitySource instanceof WitherBoss) { // Paper - if (serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (serverLevel.getGameRules().get(GameRules.MOB_GRIEFING)) { BlockPos blockPos = this.blockPosition(); BlockState blockState = Blocks.WITHER_ROSE.defaultBlockState(); if (this.level().getBlockState(blockPos).isAir() && blockState.canSurvive(this.level(), blockPos)) { @@ -939,7 +933,7 @@ if (!this.wasExperienceConsumed() && ( this.isAlwaysExperienceDropper() - || this.lastHurtByPlayerMemoryTime > 0 && this.shouldDropExperience() && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT) + || this.lastHurtByPlayerMemoryTime > 0 && this.shouldDropExperience() && level.getGameRules().get(GameRules.MOB_DROPS) )) { - ExperienceOrb.award(level, this.position(), this.getExperienceReward(level, entity)); - } @@ -958,7 +952,7 @@ } protected void dropCustomDeathLoot(ServerLevel level, DamageSource damageSource, boolean recentlyHit) { -@@ -1620,9 +_,14 @@ +@@ -1603,9 +_,14 @@ } public void knockback(double strength, double x, double z) { @@ -975,7 +969,7 @@ Vec3 deltaMovement = this.getDeltaMovement(); while (x * x + z * z < 1.0E-5F) { -@@ -1631,11 +_,22 @@ +@@ -1614,11 +_,22 @@ } Vec3 vec3 = new Vec3(x, 0.0, z).normalize().scale(strength); @@ -999,7 +993,7 @@ } } -@@ -1728,7 +_,7 @@ +@@ -1709,7 +_,7 @@ @Override public boolean isAlive() { @@ -1008,7 +1002,7 @@ } public boolean isLookingAtMe(LivingEntity entity, double tolerance, boolean scaleByDistance, boolean visual, double... yValues) { -@@ -1762,9 +_,14 @@ +@@ -1743,9 +_,14 @@ boolean flag = super.causeFallDamage(fallDistance, damageMultiplier, damageSource); int i = this.calculateFallDamage(fallDistance, damageMultiplier); if (i > 0) { @@ -1024,7 +1018,7 @@ return true; } else { return flag; -@@ -1829,7 +_,7 @@ +@@ -1810,7 +_,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damageSource, float damageAmount) { if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -1033,7 +1027,7 @@ damageAmount = CombatRules.getDamageAfterAbsorb( this, damageAmount, damageSource, this.getArmorValue(), (float)this.getAttributeValue(Attributes.ARMOR_TOUGHNESS) ); -@@ -1842,7 +_,8 @@ +@@ -1823,7 +_,8 @@ if (damageSource.is(DamageTypeTags.BYPASSES_EFFECTS)) { return damageAmount; } else { @@ -1043,7 +1037,7 @@ int i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int i1 = 25 - i; float f = damageAmount * i1; -@@ -1879,24 +_,201 @@ +@@ -1860,24 +_,201 @@ } } @@ -1255,7 +1249,7 @@ } public CombatTracker getCombatTracker() { -@@ -1925,7 +_,17 @@ +@@ -1905,7 +_,17 @@ } public final void setArrowCount(int count) { @@ -1274,7 +1268,7 @@ } public final int getStingerCount() { -@@ -1972,7 +_,7 @@ +@@ -1952,7 +_,7 @@ @Override public void handleDamageEvent(DamageSource damageSource) { this.walkAnimation.setSpeed(1.5F); @@ -1283,7 +1277,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; SoundEvent hurtSound = this.getHurtSound(damageSource); -@@ -2091,7 +_,7 @@ +@@ -2071,7 +_,7 @@ @Override protected void onBelowWorld() { @@ -1292,7 +1286,7 @@ } protected void updateSwingTime() { -@@ -2187,8 +_,15 @@ +@@ -2165,8 +_,15 @@ } public void setItemSlot(EquipmentSlot slot, ItemStack stack) { @@ -1310,7 +1304,7 @@ public float getArmorCoverPercentage() { int i = 0; -@@ -2280,14 +_,27 @@ +@@ -2258,14 +_,27 @@ return this.hasEffect(MobEffects.JUMP_BOOST) ? 0.1F * (this.getEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1.0F) : 0.0F; } @@ -1338,7 +1332,7 @@ this.addDeltaMovement(new Vec3(-Mth.sin(f) * 0.2, 0.0, Mth.cos(f) * 0.2)); } -@@ -2447,8 +_,10 @@ +@@ -2448,8 +_,10 @@ } public void stopFallFlying() { @@ -1349,7 +1343,7 @@ } private Vec3 updateFallFlyingMovement(Vec3 deltaMovement) { -@@ -2592,7 +_,7 @@ +@@ -2593,7 +_,7 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F && target instanceof LivingEntity livingEntity) { @@ -1358,7 +1352,7 @@ this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); } } -@@ -2668,37 +_,15 @@ +@@ -2669,37 +_,15 @@ profilerFiller.pop(); profilerFiller.push("rangeChecks"); @@ -1406,8 +1400,8 @@ profilerFiller.pop(); if (this.isFallFlying()) { @@ -2780,16 +_,39 @@ - @Nullable - private Map collectEquipmentChanges() { + + private @Nullable Map collectEquipmentChanges() { Map map = null; + // Paper start - EntityEquipmentChangedEvent + record EquipmentChangeImpl(org.bukkit.inventory.ItemStack oldItem, org.bukkit.inventory.ItemStack newItem) implements io.papermc.paper.event.entity.EntityEquipmentChangedEvent.EquipmentChange { @@ -1526,18 +1520,18 @@ + return; + } + -+ int _int = ((ServerLevel) this.level()).getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING); -+ if (_int <= 0 && this.level().paperConfig().collisions.maxEntityCollisions <= 0) { ++ int i = ((ServerLevel) this.level()).getGameRules().get(GameRules.MAX_ENTITY_CRAMMING); ++ if (i <= 0 && this.level().paperConfig().collisions.maxEntityCollisions <= 0) { + return; + } + // Paper end - don't run getEntities if we're not going to use its result List pushableEntities = this.level().getPushableEntities(this, this.getBoundingBox()); if (!pushableEntities.isEmpty()) { if (this.level() instanceof ServerLevel serverLevel) { -- int _int = serverLevel.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING); +- int i = serverLevel.getGameRules().get(GameRules.MAX_ENTITY_CRAMMING); + // Paper - don't run getEntities if we're not going to use its result; moved up - if (_int > 0 && pushableEntities.size() > _int - 1 && this.random.nextInt(4) == 0) { - int i = 0; + if (i > 0 && pushableEntities.size() > i - 1 && this.random.nextInt(4) == 0) { + int i1 = 0; @@ -3074,7 +_,16 @@ } @@ -1688,7 +1682,7 @@ private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { -@@ -3272,6 +_,11 @@ +@@ -3271,6 +_,11 @@ return null; } else { double d = this.getEyeY() - 0.3F; @@ -1700,7 +1694,7 @@ ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), d, this.getZ(), stack); itemEntity.setPickUpDelay(40); if (includeThrower) { -@@ -3303,7 +_,12 @@ +@@ -3302,7 +_,12 @@ protected void updateUsingItem(ItemStack usingItem) { usingItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); @@ -1714,7 +1708,7 @@ this.completeUsingItem(); } } -@@ -3329,10 +_,19 @@ +@@ -3328,10 +_,19 @@ } public void startUsingItem(InteractionHand hand) { @@ -1736,7 +1730,7 @@ if (!this.level().isClientSide()) { this.setLivingEntityFlag(LIVING_ENTITY_FLAG_IS_USING, true); this.setLivingEntityFlag(LIVING_ENTITY_FLAG_OFF_HAND, hand == InteractionHand.OFF_HAND); -@@ -3359,7 +_,10 @@ +@@ -3358,7 +_,10 @@ } } else if (!this.isUsingItem() && !this.useItem.isEmpty()) { this.useItem = ItemStack.EMPTY; @@ -1748,7 +1742,7 @@ } } } -@@ -3398,7 +_,38 @@ +@@ -3397,7 +_,38 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1788,7 +1782,7 @@ if (itemStack != this.useItem) { this.setItemInHand(usedItemHand, itemStack); } -@@ -3432,6 +_,7 @@ +@@ -3431,6 +_,7 @@ ItemStack itemInHand = this.getItemInHand(this.getUsedItemHand()); if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemInHand, this.useItem)) { this.useItem = itemInHand; @@ -1796,7 +1790,7 @@ this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); if (this.useItem.useOnRelease()) { this.updatingUsingItem(); -@@ -3452,7 +_,10 @@ +@@ -3451,7 +_,10 @@ } this.useItem = ItemStack.EMPTY; @@ -1808,7 +1802,7 @@ } public boolean isBlocking() { -@@ -3476,6 +_,60 @@ +@@ -3474,6 +_,60 @@ } } @@ -1833,7 +1827,7 @@ + return this.level().clip(raytrace); + } + -+ public @Nullable net.minecraft.world.phys.EntityHitResult getTargetEntity(int maxDistance) { ++ public net.minecraft.world.phys.@Nullable EntityHitResult getTargetEntity(int maxDistance) { + if (maxDistance < 1 || maxDistance > 120) { + throw new IllegalArgumentException("maxDistance must be between 1-120"); + } @@ -1869,7 +1863,7 @@ public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); } -@@ -3494,6 +_,12 @@ +@@ -3492,6 +_,12 @@ } public boolean randomTeleport(double x, double y, double z, boolean broadcastTeleport) { @@ -1882,7 +1876,7 @@ double x1 = this.getX(); double y1 = this.getY(); double z1 = this.getZ(); -@@ -3516,16 +_,39 @@ +@@ -3514,16 +_,39 @@ } if (flag1) { @@ -1925,7 +1919,7 @@ } else { if (broadcastTeleport) { level.broadcastEntityEvent(this, EntityEvent.TELEPORT); -@@ -3535,7 +_,7 @@ +@@ -3533,7 +_,7 @@ pathfinderMob.getNavigation().stop(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch index 22481cc35513..e457d625dc5b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java @@ -91,6 +_,14 @@ - import net.minecraft.world.phys.Vec3; import net.minecraft.world.ticks.ContainerSingleItem; + import org.jspecify.annotations.Nullable; +// CraftBukkit start +import org.bukkit.event.entity.CreatureSpawnEvent; @@ -19,12 +19,12 @@ private final BodyRotationControl bodyRotationControl; protected PathNavigation navigation; public GoalSelector goalSelector; -+ public @Nullable net.minecraft.world.entity.ai.goal.FloatGoal goalFloat; // Paper - Allow nerfed mobs to jump and float ++ public net.minecraft.world.entity.ai.goal.@Nullable FloatGoal goalFloat; // Paper - Allow nerfed mobs to jump and float public GoalSelector targetSelector; - @Nullable - private LivingEntity target; -@@ -140,6 +_,8 @@ - private Leashable.LeashData leashData; + private @Nullable LivingEntity target; + private final Sensing sensing; +@@ -138,6 +_,8 @@ + private Leashable.@Nullable LeashData leashData; private BlockPos homePosition = BlockPos.ZERO; private int homeRadius = -1; + public boolean aware = true; // CraftBukkit @@ -32,7 +32,7 @@ protected Mob(EntityType type, Level level) { super(type, level); -@@ -156,6 +_,12 @@ +@@ -154,6 +_,12 @@ } } @@ -45,7 +45,7 @@ protected void registerGoals() { } -@@ -236,7 +_,39 @@ +@@ -231,7 +_,39 @@ } public void setTarget(@Nullable LivingEntity target) { @@ -53,7 +53,7 @@ + this.setTarget(target, EntityTargetEvent.TargetReason.UNKNOWN); + } + -+ public boolean setTarget(@Nullable LivingEntity target, @Nullable EntityTargetEvent.TargetReason reason) { ++ public boolean setTarget(@Nullable LivingEntity target, EntityTargetEvent.@Nullable TargetReason reason) { + if (this.getTarget() == target) { + return false; + } @@ -85,7 +85,7 @@ } @Override -@@ -376,13 +_,27 @@ +@@ -370,13 +_,27 @@ if (this.isNoAi()) { output.putBoolean("NoAI", this.isNoAi()); } @@ -115,7 +115,7 @@ this.dropChances = input.read("drop_chances", DropChances.CODEC).orElse(DropChances.DEFAULT); this.readLeashData(input); this.homeRadius = input.getIntOr("home_radius", -1); -@@ -394,6 +_,13 @@ +@@ -388,6 +_,13 @@ this.lootTable = input.read("DeathLootTable", LootTable.KEY_CODEC); this.lootTableSeed = input.getLongOr("DeathLootTableSeed", 0L); this.setNoAi(input.getBooleanOr("NoAI", false)); @@ -129,7 +129,7 @@ } @Override -@@ -461,6 +_,11 @@ +@@ -455,6 +_,11 @@ && !itemEntity.getItem().isEmpty() && !itemEntity.hasPickUpDelay() && this.wantsToPickUp(serverLevel, itemEntity.getItem())) { @@ -141,7 +141,7 @@ this.pickUpItem(serverLevel, itemEntity); } } -@@ -514,18 +_,24 @@ +@@ -508,18 +_,24 @@ protected void pickUpItem(ServerLevel level, ItemEntity entity) { ItemStack item = entity.getItem(); @@ -168,7 +168,7 @@ EquipmentSlot equipmentSlotForItem = this.getEquipmentSlotForItem(stack); if (!this.isEquippableInSlot(stack, equipmentSlotForItem)) { return ItemStack.EMPTY; -@@ -538,10 +_,18 @@ +@@ -532,10 +_,18 @@ canReplaceCurrentItem = itemBySlot.isEmpty(); } @@ -188,7 +188,7 @@ } ItemStack itemStack = equipmentSlotForItem.limit(stack); -@@ -655,25 +_,38 @@ +@@ -648,25 +_,38 @@ return this.isPassenger(); } @@ -241,7 +241,7 @@ this.noActionTime = 0; } } -@@ -685,6 +_,15 @@ +@@ -678,6 +_,15 @@ @Override protected final void serverAiStep() { this.noActionTime++; @@ -257,7 +257,7 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("sensing"); this.sensing.tick(); -@@ -859,14 +_,69 @@ +@@ -852,14 +_,69 @@ public boolean stillValid(Player player) { return player.getVehicle() == Mob.this || player.canInteractWithEntity(Mob.this, 4.0); } @@ -292,7 +292,7 @@ + } + + @Override -+ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { ++ public org.bukkit.inventory.@Nullable InventoryHolder getOwner() { + if (Mob.this.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder inventoryHolder) { + return inventoryHolder; + } @@ -327,7 +327,7 @@ ItemStack itemBySlot = this.getItemBySlot(equipmentSlot); float f = this.dropChances.byEquipment(equipmentSlot); if (f != 0.0F) { -@@ -886,7 +_,13 @@ +@@ -879,7 +_,13 @@ } this.spawnAtLocation(level, itemBySlot); @@ -341,7 +341,7 @@ } } } -@@ -910,7 +_,9 @@ +@@ -903,7 +_,9 @@ set.add(equipmentSlot); } else if (this.dropChances.isPreserved(equipmentSlot)) { this.setItemSlot(equipmentSlot, ItemStack.EMPTY); @@ -351,8 +351,8 @@ } } } -@@ -1205,6 +_,21 @@ - public T convertTo( +@@ -1194,6 +_,21 @@ + public @Nullable T convertTo( EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.AfterConversion afterConversion ) { + // Paper start - entity zap event - allow cancellation of conversion post creation @@ -361,19 +361,19 @@ + + @Nullable + public T convertTo( -+ EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.AfterConversion afterConversion, @Nullable EntityTransformEvent.TransformReason transformReason, @Nullable CreatureSpawnEvent.SpawnReason creatureSpawnReason ++ EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.AfterConversion afterConversion, EntityTransformEvent.@Nullable TransformReason transformReason, CreatureSpawnEvent.@Nullable SpawnReason creatureSpawnReason + ) { + return this.convertTo(entityType, conversionParams, spawnReason, e -> { afterConversion.finalizeConversion(e); return true; }, transformReason, creatureSpawnReason); + } + @Nullable + public T convertTo( -+ EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.CancellingAfterConversion afterConversion, @Nullable EntityTransformEvent.TransformReason transformReason, @Nullable CreatureSpawnEvent.SpawnReason creatureSpawnReason ++ EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.CancellingAfterConversion afterConversion, EntityTransformEvent.@Nullable TransformReason transformReason, CreatureSpawnEvent.@Nullable SpawnReason creatureSpawnReason + ) { + // Paper end - entity zap event - allow cancellation of conversion post creation if (this.isRemoved()) { return null; } else { -@@ -1213,13 +_,23 @@ +@@ -1202,13 +_,23 @@ return null; } else { conversionParams.type().convert(this, mob, conversionParams); @@ -400,27 +400,26 @@ } return mob; -@@ -1229,7 +_,18 @@ - - @Nullable - public T convertTo(EntityType entityType, ConversionParams conversionParams, ConversionParams.AfterConversion afterConversion) { +@@ -1219,7 +_,17 @@ + public @Nullable T convertTo( + EntityType entityType, ConversionParams conversionParams, ConversionParams.AfterConversion afterConversion + ) { - return this.convertTo(entityType, conversionParams, EntitySpawnReason.CONVERSION, afterConversion); + // Paper start - entity zap event - allow cancellation of conversion post creation + return this.convertTo(entityType, conversionParams, afterConversion, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); + } + -+ @Nullable -+ public T convertTo(EntityType entityType, ConversionParams conversionParams, ConversionParams.AfterConversion afterConversion, @Nullable EntityTransformEvent.TransformReason transformReason, @Nullable CreatureSpawnEvent.SpawnReason creatureSpawnReason) { ++ public @Nullable T convertTo(EntityType entityType, ConversionParams conversionParams, ConversionParams.AfterConversion afterConversion, EntityTransformEvent.@Nullable TransformReason transformReason, CreatureSpawnEvent.@Nullable SpawnReason creatureSpawnReason) { + return this.convertTo(entityType, conversionParams, e -> { afterConversion.finalizeConversion(e); return true; }, transformReason, creatureSpawnReason); + } -+ @Nullable -+ public T convertTo(EntityType entityType, ConversionParams conversionParams, ConversionParams.CancellingAfterConversion afterConversion, @Nullable EntityTransformEvent.TransformReason transformReason, @Nullable CreatureSpawnEvent.SpawnReason creatureSpawnReason) { ++ ++ public @Nullable T convertTo(EntityType entityType, ConversionParams conversionParams, ConversionParams.CancellingAfterConversion afterConversion, EntityTransformEvent.@Nullable TransformReason transformReason, CreatureSpawnEvent.@Nullable SpawnReason creatureSpawnReason) { + return this.convertTo(entityType, conversionParams, EntitySpawnReason.CONVERSION, afterConversion, transformReason, creatureSpawnReason); + // Paper end - entity zap event - allow cancellation of conversion post creation } - @Nullable -@@ -1271,7 +_,17 @@ + @Override +@@ -1260,7 +_,17 @@ public boolean startRiding(Entity entity, boolean force, boolean triggerEvents) { boolean flag = super.startRiding(entity, force, triggerEvents); if (flag && this.isLeashed()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch index d3a4fd531dc6..1b8348e43ee4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/NeutralMob.java +++ b/net/minecraft/world/entity/NeutralMob.java -@@ -51,7 +_,11 @@ +@@ -50,7 +_,11 @@ if (level instanceof ServerLevel) { this.setPersistentAngerTarget(EntityReference.read(input, "angry_at")); @@ -13,7 +13,7 @@ } } -@@ -118,7 +_,7 @@ +@@ -117,7 +_,7 @@ default void stopBeingAngry() { this.setLastHurtByMob(null); this.setPersistentAngerTarget(null); @@ -22,16 +22,15 @@ this.setPersistentAngerEndTime(-1L); } -@@ -129,8 +_,20 @@ +@@ -127,7 +_,19 @@ void setTarget(@Nullable LivingEntity target); -+ boolean setTarget(@Nullable LivingEntity target, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason); // CraftBukkit ++ boolean setTarget(@Nullable LivingEntity target, org.bukkit.event.entity.EntityTargetEvent.@Nullable TargetReason reason); // CraftBukkit + boolean canAttack(LivingEntity entity); - @Nullable - LivingEntity getTarget(); + @Nullable LivingEntity getTarget(); + + // Paper start - Prevent entity loading causing async lookups + // Update last hurt when ticking diff --git a/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch index 03644b2736f1..cc8c0bbb2921 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch @@ -23,9 +23,9 @@ byte b = this.entityData.get(DATA_FLAGS_ID); if (sitting) { this.entityData.set(DATA_FLAGS_ID, (byte)(b | 1)); -@@ -215,7 +_,12 @@ +@@ -213,7 +_,12 @@ if (this.level() instanceof ServerLevel serverLevel - && serverLevel.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES) + && serverLevel.getGameRules().get(GameRules.SHOW_DEATH_MESSAGES) && this.getOwner() instanceof ServerPlayer serverPlayer) { - serverPlayer.sendSystemMessage(this.getCombatTracker().getDeathMessage()); + // Paper start - Add TameableDeathMessageEvent @@ -37,7 +37,7 @@ } super.die(damageSource); -@@ -258,7 +_,14 @@ +@@ -256,7 +_,14 @@ if (!this.canTeleportTo(new BlockPos(x, y, z))) { return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch index e0094dde9c77..f800fedeb545 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/attributes/AttributeInstance.java +++ b/net/minecraft/world/entity/ai/attributes/AttributeInstance.java -@@ -151,20 +_,20 @@ +@@ -150,20 +_,20 @@ double baseValue = this.getBaseValue(); for (AttributeModifier attributeModifier : this.getModifiersOrEmpty(AttributeModifier.Operation.ADD_VALUE)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch index 0963597315bb..b2374f012ca5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/attributes/AttributeMap.java +++ b/net/minecraft/world/entity/ai/attributes/AttributeMap.java -@@ -148,4 +_,12 @@ +@@ -147,4 +_,12 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch index 32e15ef453ba..4f07a53c89a7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java +++ b/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java -@@ -110,7 +_,9 @@ +@@ -108,7 +_,9 @@ Block block = blockState.getBlock(); Block block1 = level.getBlockState(this.aboveFarmlandPos.below()).getBlock(); if (block instanceof CropBlock && ((CropBlock)block).isMaxAge(blockState)) { @@ -10,7 +10,7 @@ } if (blockState.isAir() && block1 instanceof FarmBlock && owner.hasFarmSeeds()) { -@@ -121,9 +_,11 @@ +@@ -119,9 +_,11 @@ boolean flag = false; if (!item.isEmpty() && item.is(ItemTags.VILLAGER_PLANTABLE_SEEDS) && item.getItem() instanceof BlockItem blockItem) { BlockState blockState1 = blockItem.getBlock().defaultBlockState(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch index 851e1cc6a9f9..6d62fb17905f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java +++ b/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java -@@ -323,7 +_,10 @@ +@@ -320,7 +_,10 @@ } else { boolean flag1 = this.isWantedBlock(mob, transportItemTarget.state) && !this.isPositionAlreadyVisited(visitedPositions, unreachablePositions, transportItemTarget, level) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch index e92a3969ffe1..4ecb07b24c57 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch @@ -5,10 +5,10 @@ if (this.eatAnimationTick == this.adjustedTickDelay(4)) { BlockPos blockPos = this.mob.blockPosition(); - if (IS_EDIBLE.test(this.level.getBlockState(blockPos))) { -- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (getServerLevel(this.level).getGameRules().get(GameRules.MOB_GRIEFING)) { + final BlockState blockState = this.level.getBlockState(blockPos); // Paper - fix wrong block state + if (IS_EDIBLE.test(blockState)) { // Paper - fix wrong block state -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockPos, blockState.getFluidState().createLegacyBlock(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit // Paper - fix wrong block state ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockPos, blockState.getFluidState().createLegacyBlock(), !getServerLevel(this.level).getGameRules().get(GameRules.MOB_GRIEFING))) { // CraftBukkit // Paper - fix wrong block state this.level.destroyBlock(blockPos, false); } @@ -16,8 +16,8 @@ } else { BlockPos blockPos1 = blockPos.below(); if (this.level.getBlockState(blockPos1).is(Blocks.GRASS_BLOCK)) { -- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockPos1, Blocks.DIRT.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit // Paper - Fix wrong block state +- if (getServerLevel(this.level).getGameRules().get(GameRules.MOB_GRIEFING)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockPos1, Blocks.DIRT.defaultBlockState(), !getServerLevel(this.level).getGameRules().get(GameRules.MOB_GRIEFING))) { // CraftBukkit // Paper - Fix wrong block state this.level.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, blockPos1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); this.level.setBlock(blockPos1, Blocks.DIRT.defaultBlockState(), Block.UPDATE_CLIENTS); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch index 32807a319e00..29d8247ac576 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java +++ b/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java -@@ -72,7 +_,7 @@ +@@ -71,7 +_,7 @@ public void tick() { boolean shouldTryTeleportToOwner = this.tamable.shouldTryTeleportToOwner(); if (!shouldTryTeleportToOwner) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch index 776d692c9ace..a42f7a01a855 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch @@ -12,10 +12,10 @@ level.removeBlock(posWithBlock, false); if (!level.isClientSide()) { for (int i = 0; i < 20; i++) { -@@ -124,13 +_,16 @@ +@@ -123,13 +_,16 @@ + } - @Nullable - private BlockPos getPosWithBlock(BlockPos pos, BlockGetter level) { + private @Nullable BlockPos getPosWithBlock(BlockPos pos, BlockGetter level) { - if (level.getBlockState(pos).is(this.blockToRemove)) { + net.minecraft.world.level.block.state.BlockState block = level.getBlockStateIfLoaded(pos); // Paper - Prevent AI rules from loading chunks + if (block == null) return null; // Paper - Prevent AI rules from loading chunks @@ -31,7 +31,7 @@ return blockPos; } } -@@ -141,7 +_,7 @@ +@@ -140,7 +_,7 @@ @Override protected boolean isValidTarget(LevelReader level, BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch index acde7d31dd3c..84ac8fe4b87e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/SwellGoal.java +++ b/net/minecraft/world/entity/ai/goal/SwellGoal.java -@@ -21,6 +_,14 @@ +@@ -20,6 +_,14 @@ return this.creeper.getSwellDir() > 0 || target != null && this.creeper.distanceToSqr(target) < 9.0; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch index cd8fcb07995b..1a838aa9c160 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/ai/goal/TemptGoal.java +++ b/net/minecraft/world/entity/ai/goal/TemptGoal.java -@@ -24,7 +_,7 @@ +@@ -23,7 +_,7 @@ + private double pz; private double pRotX; private double pRotY; - @Nullable -- protected Player player; -+ protected LivingEntity player; // CraftBukkit +- protected @Nullable Player player; ++ protected @Nullable LivingEntity player; // CraftBukkit private int calmDown; private boolean isRunning; private final Predicate items; -@@ -57,6 +_,15 @@ +@@ -56,6 +_,15 @@ } else { this.player = getServerLevel(this.mob) .getNearestPlayer(this.targetingConditions.range(this.mob.getAttributeValue(Attributes.TEMPT_RANGE)), this.mob); @@ -25,7 +25,7 @@ return this.player != null; } } -@@ -123,7 +_,7 @@ +@@ -122,7 +_,7 @@ this.mob.getNavigation().stop(); } @@ -34,7 +34,7 @@ this.mob.getNavigation().moveTo(player, this.speedModifier); } -@@ -142,7 +_,7 @@ +@@ -141,7 +_,7 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch index 2635d672a76a..66d7c33c3395 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java +++ b/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java -@@ -47,7 +_,7 @@ +@@ -46,7 +_,7 @@ @Override public void start() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch index 6c395ee1f3e7..b1cd473fdd52 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java +++ b/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java -@@ -59,7 +_,7 @@ +@@ -58,7 +_,7 @@ @Override public void start() { @@ -9,7 +9,7 @@ this.targetMob = this.mob.getTarget(); this.timestamp = this.mob.getLastHurtByMobTimestamp(); this.unseenMemoryTicks = 300; -@@ -114,6 +_,6 @@ +@@ -113,6 +_,6 @@ } protected void alertOther(Mob mob, LivingEntity target) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch index 3a53b1a47b8a..d2987e4f20d7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java +++ b/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java -@@ -73,7 +_,7 @@ +@@ -72,7 +_,7 @@ @Override public void start() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch index a452b371fec3..0c6f02b444d1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/target/TargetGoal.java +++ b/net/minecraft/world/entity/ai/goal/target/TargetGoal.java -@@ -63,7 +_,7 @@ +@@ -62,7 +_,7 @@ } } @@ -9,7 +9,7 @@ return true; } } -@@ -83,7 +_,7 @@ +@@ -82,7 +_,7 @@ @Override public void stop() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch index ac04f3da30b0..788c01d186c7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch @@ -1,49 +1,46 @@ --- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java -@@ -131,7 +_,13 @@ +@@ -124,7 +_,12 @@ + } - @Nullable - public Path createPath(BlockPos pos, int reachRange) { + public @Nullable Path createPath(BlockPos pos, int reachRange) { - return this.createPath(ImmutableSet.of(pos), 8, false, reachRange); + // Paper start - EntityPathfindEvent + return this.createPath(pos, null, reachRange); + } -+ @Nullable -+ public Path createPath(BlockPos target, @Nullable Entity entity, int reachRange) { ++ public @Nullable Path createPath(BlockPos target, @Nullable Entity entity, int reachRange) { + return this.createPath(ImmutableSet.of(target), entity, 8, false, reachRange); + // Paper end - EntityPathfindEvent } - @Nullable -@@ -141,7 +_,7 @@ + public @Nullable Path createPath(BlockPos pos, int reachRange, int followRange) { +@@ -132,7 +_,7 @@ + } - @Nullable - public Path createPath(Entity entity, int reachRange) { + public @Nullable Path createPath(Entity entity, int reachRange) { - return this.createPath(ImmutableSet.of(entity.blockPosition()), 16, true, reachRange); + return this.createPath(ImmutableSet.of(entity.blockPosition()), entity, 16, true, reachRange); // Paper - EntityPathfindEvent } - @Nullable -@@ -151,6 +_,18 @@ + protected @Nullable Path createPath(Set targets, int regionOffset, boolean offsetUpward, int reachRange) { +@@ -140,6 +_,16 @@ + } - @Nullable - protected Path createPath(Set targets, int regionOffset, boolean offsetUpward, int reachRange, float followRange) { + protected @Nullable Path createPath(Set targets, int regionOffset, boolean offsetUpward, int reachRange, float followRange) { + // Paper start - EntityPathfindEvent + return this.createPath(targets, null, regionOffset, offsetUpward, reachRange, followRange); + } + -+ @Nullable -+ protected Path createPath(Set targets, @Nullable Entity target, int regionOffset, boolean offsetUpward, int reachRange) { ++ protected @Nullable Path createPath(Set targets, @Nullable Entity target, int regionOffset, boolean offsetUpward, int reachRange) { + return this.createPath(targets, target, regionOffset, offsetUpward, reachRange, this.getMaxPathLength()); + } + -+ @Nullable -+ protected Path createPath(Set targets, @Nullable Entity target, int regionOffset, boolean offsetUpward, int reachRange, float followRange) { ++ protected @Nullable Path createPath(Set targets, @Nullable Entity target, int regionOffset, boolean offsetUpward, int reachRange, float followRange) { + // Paper end - EntityPathfindEvent if (targets.isEmpty()) { return null; } else if (this.mob.getY() < this.level.getMinY()) { -@@ -160,6 +_,23 @@ +@@ -149,6 +_,23 @@ } else if (this.path != null && !this.path.isDone() && targets.contains(this.targetPos)) { return this.path; } else { @@ -67,7 +64,7 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("pathfind"); BlockPos blockPos = offsetUpward ? this.mob.blockPosition().above() : this.mob.blockPosition(); -@@ -177,6 +_,11 @@ +@@ -166,6 +_,11 @@ } } @@ -79,7 +76,7 @@ public boolean moveTo(double x, double y, double z, double speedModifier) { return this.moveTo(this.createPath(x, y, z, 1), speedModifier); } -@@ -186,8 +_,23 @@ +@@ -175,8 +_,23 @@ } public boolean moveTo(Entity entity, double speedModifier) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch index e5e2bb810f52..470cc35f4485 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java -@@ -16,9 +_,9 @@ +@@ -15,9 +_,9 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/sensing/TemptingSensor.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/sensing/TemptingSensor.java.patch index 0a3a0a535061..ac8b07e679f5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/sensing/TemptingSensor.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/sensing/TemptingSensor.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/sensing/TemptingSensor.java +++ b/net/minecraft/world/entity/ai/sensing/TemptingSensor.java -@@ -38,7 +_,19 @@ +@@ -48,7 +_,19 @@ .collect(Collectors.toList()); if (!list.isEmpty()) { Player player = list.get(0); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch index a4af5a390093..43f464a614ba 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ambient/Bat.java +++ b/net/minecraft/world/entity/ambient/Bat.java -@@ -87,7 +_,7 @@ +@@ -84,7 +_,7 @@ } @Override @@ -9,7 +9,7 @@ return false; } -@@ -141,13 +_,13 @@ +@@ -138,13 +_,13 @@ this.yHeadRot = this.random.nextInt(360); } @@ -25,7 +25,7 @@ this.setResting(false); if (!isSilent) { level.levelEvent(null, LevelEvent.SOUND_BAT_LIFTOFF, blockPos, 0); -@@ -180,7 +_,7 @@ +@@ -177,7 +_,7 @@ float f1 = Mth.wrapDegrees(f - this.getYRot()); this.zza = 0.5F; this.setYRot(this.getYRot() + f1); @@ -34,7 +34,7 @@ this.setResting(true); } } -@@ -205,7 +_,7 @@ +@@ -202,7 +_,7 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractSchoolingFish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractSchoolingFish.java.patch index 94cfc94803e6..79bdc07a66e0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractSchoolingFish.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractSchoolingFish.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/AbstractSchoolingFish.java +++ b/net/minecraft/world/entity/animal/AbstractSchoolingFish.java -@@ -51,6 +_,7 @@ +@@ -50,6 +_,7 @@ } public void stopFollowing() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch index a0e5270649be..a39cced042b7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/animal/Animal.java +++ b/net/minecraft/world/entity/animal/Animal.java -@@ -41,6 +_,7 @@ +@@ -39,6 +_,7 @@ + private static final int DEFAULT_IN_LOVE_TIME = 0; public int inLove = 0; - @Nullable - public EntityReference loveCause; + public @Nullable EntityReference loveCause; + public @Nullable ItemStack breedItem; // CraftBukkit - Add breedItem variable protected Animal(EntityType type, Level level) { super(type, level); -@@ -80,9 +_,13 @@ +@@ -78,9 +_,13 @@ } @Override @@ -24,7 +24,7 @@ } @Override -@@ -138,8 +_,9 @@ +@@ -136,8 +_,9 @@ if (this.isFood(itemInHand)) { int age = this.getAge(); if (player instanceof ServerPlayer serverPlayer && age == 0 && this.canFallInLove()) { @@ -35,7 +35,7 @@ this.playEatingSound(); return InteractionResult.SUCCESS_SERVER; } -@@ -166,8 +_,23 @@ +@@ -164,8 +_,23 @@ return this.inLove <= 0; } @@ -60,7 +60,7 @@ if (player instanceof ServerPlayer serverPlayer) { this.loveCause = EntityReference.of(serverPlayer); } -@@ -205,23 +_,45 @@ +@@ -202,23 +_,45 @@ if (breedOffspring != null) { breedOffspring.setBaby(true); breedOffspring.snapTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); @@ -105,9 +105,9 @@ this.resetLove(); animal.resetLove(); level.broadcastEntityEvent(this, EntityEvent.IN_LOVE_HEARTS); -- if (level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- if (level.getGameRules().get(GameRules.MOB_DROPS)) { - level.addFreshEntity(new ExperienceOrb(level, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1)); -+ if (experience > 0 && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - Call EntityBreedEvent ++ if (experience > 0 && level.getGameRules().get(GameRules.MOB_DROPS)) { // Paper - Call EntityBreedEvent + level.addFreshEntity(new ExperienceOrb(level, this.position(), net.minecraft.world.phys.Vec3.ZERO, experience, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, player, baby)); // Paper - Call EntityBreedEvent, add spawn context } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch index aaf4047d34b9..fa1468aff6d1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Bee.java +++ b/net/minecraft/world/entity/animal/Bee.java -@@ -149,10 +_,26 @@ +@@ -146,10 +_,26 @@ Bee.BeeGoToHiveGoal goToHiveGoal; private Bee.BeeGoToKnownFlowerGoal goToKnownFlowerGoal; private int underWaterTicks; @@ -28,7 +28,7 @@ this.lookControl = new Bee.BeeLookControl(this); this.setPathfindingMalus(PathType.DANGER_FIRE, -1.0F); this.setPathfindingMalus(PathType.WATER, -1.0F); -@@ -199,9 +_,18 @@ +@@ -196,9 +_,18 @@ @Override protected void addAdditionalSaveData(ValueOutput output) { @@ -47,7 +47,7 @@ output.putBoolean("HasNectar", this.hasNectar()); output.putBoolean("HasStung", this.hasStung()); output.putInt("TicksSincePollination", this.ticksWithoutNectarSinceExitingHive); -@@ -239,7 +_,7 @@ +@@ -236,7 +_,7 @@ } if (i > 0) { @@ -56,7 +56,7 @@ } } -@@ -486,7 +_,11 @@ +@@ -479,7 +_,11 @@ if (this.hivePos == null) { return null; } else { @@ -69,7 +69,7 @@ } } -@@ -519,6 +_,7 @@ +@@ -512,6 +_,7 @@ } public void setRolling(boolean isRolling) { @@ -77,7 +77,7 @@ this.setFlag(FLAG_ROLL, isRolling); } -@@ -575,7 +_,7 @@ +@@ -568,7 +_,7 @@ if (beeInteractionEffect != null) { this.usePlayerItem(player, hand, itemInHand); if (!this.level().isClientSide()) { @@ -86,7 +86,7 @@ } return InteractionResult.SUCCESS; -@@ -644,8 +_,9 @@ +@@ -636,8 +_,9 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { @@ -97,7 +97,7 @@ } } -@@ -987,7 +_,7 @@ +@@ -978,7 +_,7 @@ } } @@ -106,7 +106,7 @@ Bee.this.level().levelEvent(LevelEvent.PARTICLES_BEE_GROWTH, blockPos, 15); Bee.this.level().setBlockAndUpdate(blockPos, blockState1); Bee.this.incrementNumCropsGrownSincePollination(); -@@ -1011,7 +_,7 @@ +@@ -1002,7 +_,7 @@ @Override protected void alertOther(Mob mob, LivingEntity target) { if (mob instanceof Bee && this.mob.hasLineOfSight(target)) { @@ -115,7 +115,7 @@ } } } -@@ -1169,7 +_,7 @@ +@@ -1159,7 +_,7 @@ Bee.this.dropFlower(); this.pollinating = false; Bee.this.remainingCooldownBeforeLocatingNewFlower = 200; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch index 097c820fb681..a4e3f5c26948 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Cat.java +++ b/net/minecraft/world/entity/animal/Cat.java -@@ -374,6 +_,11 @@ +@@ -368,6 +_,11 @@ if (item instanceof DyeItem dyeItem) { DyeColor dyeColor = dyeItem.getDyeColor(); if (dyeColor != this.getCollarColor()) { @@ -12,7 +12,7 @@ if (!this.level().isClientSide()) { this.setCollarColor(dyeColor); itemInHand.consume(1, player); -@@ -386,7 +_,7 @@ +@@ -380,7 +_,7 @@ if (!this.level().isClientSide()) { this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); @@ -21,7 +21,7 @@ this.playEatingSound(); } -@@ -448,7 +_,7 @@ +@@ -442,7 +_,7 @@ } private void tryToTame(Player player) { @@ -30,7 +30,7 @@ this.tame(player); this.setOrderedToSit(true); this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); -@@ -586,15 +_,20 @@ +@@ -578,15 +_,20 @@ .dropFromGiftLootTable( getServerLevel(this.cat), BuiltInLootTables.CAT_MORNING_GIFT, @@ -55,12 +55,12 @@ ); } -@@ -621,7 +_,7 @@ +@@ -612,7 +_,7 @@ + } static class CatTemptGoal extends TemptGoal { - @Nullable -- private Player selectedPlayer; -+ private LivingEntity selectedPlayer; // CraftBukkit +- private @Nullable Player selectedPlayer; ++ private @Nullable LivingEntity selectedPlayer; // CraftBukkit private final Cat cat; public CatTemptGoal(Cat cat, double speedModifier, Predicate items, boolean canScare) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch index b3a85bb49fb2..7cef37cbdf38 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Dolphin.java +++ b/net/minecraft/world/entity/animal/Dolphin.java -@@ -100,6 +_,13 @@ +@@ -97,6 +_,13 @@ return EntityType.DOLPHIN.create(level, EntitySpawnReason.BREEDING); } @@ -14,7 +14,7 @@ @Override public float getAgeScale() { return this.isBaby() ? 0.65F : 1.0F; -@@ -184,7 +_,7 @@ +@@ -181,7 +_,7 @@ @Override public int getMaxAirSupply() { @@ -23,7 +23,7 @@ } @Override -@@ -217,11 +_,15 @@ +@@ -214,11 +_,15 @@ if (this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) { ItemStack item = entity.getItem(); if (this.canHoldItem(item)) { @@ -40,7 +40,7 @@ } } } -@@ -488,7 +_,7 @@ +@@ -478,7 +_,7 @@ @Override public void start() { @@ -49,7 +49,7 @@ } @Override -@@ -507,7 +_,7 @@ +@@ -497,7 +_,7 @@ } if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) { @@ -58,7 +58,7 @@ } } } -@@ -577,7 +_,7 @@ +@@ -567,7 +_,7 @@ 0.3F * Mth.cos(Dolphin.this.getYRot() * (float) (Math.PI / 180.0)) * Mth.cos(Dolphin.this.getXRot() * (float) (Math.PI / 180.0)) + Mth.sin(f1) * f2 ); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch index a7adf614b850..2e1bf961290c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Fox.java +++ b/net/minecraft/world/entity/animal/Fox.java -@@ -432,7 +_,7 @@ +@@ -429,7 +_,7 @@ input.read("Trusted", TRUSTED_LIST_CODEC).orElse(List.of()).forEach(this::addTrustedEntity); this.setSleeping(input.getBooleanOr("Sleeping", false)); this.setVariant(input.read("Type", Fox.Variant.CODEC).orElse(Fox.Variant.DEFAULT)); @@ -9,7 +9,7 @@ this.setIsCrouching(input.getBooleanOr("Crouching", false)); if (this.level() instanceof ServerLevel) { this.setTargetGoals(); -@@ -449,6 +_,12 @@ +@@ -446,6 +_,12 @@ } public void setSitting(boolean sitting) { @@ -22,7 +22,7 @@ this.setFlag(FLAG_SITTING, sitting); } -@@ -508,19 +_,20 @@ +@@ -505,19 +_,20 @@ itemEntity.setPickUpDelay(40); itemEntity.setThrower(this); this.playSound(SoundEvents.FOX_SPIT, 1.0F, 1.0F); @@ -46,7 +46,7 @@ int count = item.getCount(); if (count > 1) { this.dropItemStack(item.split(count - 1)); -@@ -531,7 +_,7 @@ +@@ -528,7 +_,7 @@ this.setItemSlot(EquipmentSlot.MAINHAND, item.split(1)); this.setGuaranteedDrop(EquipmentSlot.MAINHAND); this.take(entity, item.getCount()); @@ -55,12 +55,12 @@ this.ticksSinceEaten = 0; } } -@@ -622,12 +_,12 @@ +@@ -619,12 +_,12 @@ } @Override - public void setTarget(@Nullable LivingEntity target) { -+ public boolean setTarget(@Nullable LivingEntity target, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { // CraftBukkit ++ public boolean setTarget(@Nullable LivingEntity target, org.bukkit.event.entity.EntityTargetEvent.@Nullable TargetReason reason) { // CraftBukkit if (this.isDefending() && target == null) { this.setDefending(false); } @@ -70,7 +70,7 @@ } void wakeUp() { -@@ -691,15 +_,33 @@ +@@ -685,15 +_,33 @@ return this.getTrustedEntities().anyMatch(entityReference -> entityReference.matches(entity)); } @@ -89,7 +89,7 @@ ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.MAINHAND); - if (!itemBySlot.isEmpty()) { + boolean releaseMouth = false; -+ if (!itemBySlot.isEmpty() && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Fix MC-153010 ++ if (!itemBySlot.isEmpty() && level.getGameRules().get(GameRules.MOB_DROPS)) { // Fix MC-153010 this.spawnAtLocation(level, itemBySlot); + releaseMouth = true; + } @@ -108,7 +108,7 @@ } public static boolean isPathClear(Fox fox, LivingEntity livingEntity) { -@@ -874,6 +_,19 @@ +@@ -866,6 +_,19 @@ fox.addTrustedEntity(loveCause1); } @@ -128,7 +128,7 @@ if (serverPlayer != null) { serverPlayer.awardStat(Stats.ANIMALS_BRED); CriteriaTriggers.BRED_ANIMALS.trigger(serverPlayer, this.animal, this.partner, fox); -@@ -883,14 +_,12 @@ +@@ -875,14 +_,12 @@ this.partner.setAge(6000); this.animal.resetLove(); this.partner.resetLove(); @@ -137,8 +137,8 @@ - this.level.addFreshEntityWithPassengers(fox); + this.level.addFreshEntityWithPassengers(fox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason this.level.broadcastEntityEvent(this.animal, EntityEvent.IN_LOVE_HEARTS); -- if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { -+ if (experience > 0 && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - call EntityBreedEvent +- if (this.level.getGameRules().get(GameRules.MOB_DROPS)) { ++ if (experience > 0 && this.level.getGameRules().get(GameRules.MOB_DROPS)) { // Paper - call EntityBreedEvent this.level .addFreshEntity( - new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), this.animal.getRandom().nextInt(7) + 1) @@ -146,7 +146,7 @@ ); } } -@@ -954,6 +_,7 @@ +@@ -946,6 +_,7 @@ private void pickSweetBerries(BlockState state) { int ageValue = state.getValue(SweetBerryBushBlock.AGE); state.setValue(SweetBerryBushBlock.AGE, 1); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/HappyGhast.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/HappyGhast.java.patch index b405dfdb247f..9f267abaf223 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/HappyGhast.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/HappyGhast.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/HappyGhast.java +++ b/net/minecraft/world/entity/animal/HappyGhast.java -@@ -306,8 +_,12 @@ +@@ -305,8 +_,12 @@ } @Override @@ -15,7 +15,7 @@ if (!this.level().isClientSide()) { this.setServerStillTimeout(10); } -@@ -316,6 +_,7 @@ +@@ -315,6 +_,7 @@ this.clearHome(); this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.HARNESS_GOGGLES_UP, this.getSoundSource(), 1.0F, 1.0F); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch index de8e39c3864c..7d4e5af15e11 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/IronGolem.java +++ b/net/minecraft/world/entity/animal/IronGolem.java -@@ -107,7 +_,7 @@ +@@ -106,7 +_,7 @@ @Override protected void doPush(Entity entity) { if (entity instanceof Enemy && !(entity instanceof Creeper) && this.getRandom().nextInt(20) == 0) { @@ -9,7 +9,7 @@ } super.doPush(entity); -@@ -306,7 +_,7 @@ +@@ -304,7 +_,7 @@ BlockPos blockPos = this.blockPosition(); BlockPos blockPos1 = blockPos.below(); BlockState blockState = level.getBlockState(blockPos1); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/MushroomCow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/MushroomCow.java.patch index 3b17e1eada52..507e7fd362e4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/MushroomCow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/MushroomCow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/MushroomCow.java +++ b/net/minecraft/world/entity/animal/MushroomCow.java -@@ -118,7 +_,17 @@ +@@ -116,7 +_,17 @@ return InteractionResult.SUCCESS; } else if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { if (this.level() instanceof ServerLevel serverLevel) { @@ -19,7 +19,7 @@ this.gameEvent(GameEvent.SHEAR, player); itemInHand.hurtAndBreak(1, player, hand.asEquipmentSlot()); } -@@ -172,15 +_,31 @@ +@@ -170,15 +_,31 @@ @Override public void shear(ServerLevel level, SoundSource source, ItemStack shears) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch index e9414924cb20..039ed17d0233 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Ocelot.java +++ b/net/minecraft/world/entity/animal/Ocelot.java -@@ -128,7 +_,7 @@ +@@ -126,7 +_,7 @@ @Override public boolean removeWhenFarAway(double distanceToClosestPlayer) { @@ -9,7 +9,7 @@ } public static AttributeSupplier.Builder createAttributes() { -@@ -162,7 +_,7 @@ +@@ -159,7 +_,7 @@ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemInHand) && player.distanceToSqr(this) < 9.0) { this.usePlayerItem(player, hand, itemInHand); if (!this.level().isClientSide()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch index 3dd7c3341de6..3e1e4eeea684 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch @@ -8,7 +8,7 @@ this.setFlag(FLAG_SIT, sitting); } -@@ -518,24 +_,28 @@ +@@ -517,24 +_,28 @@ for (Panda panda : level.getEntitiesOfClass(Panda.class, this.getBoundingBox().inflate(10.0))) { if (!panda.isBaby() && panda.onGround() && !panda.isInWater() && panda.canPerformAction()) { @@ -18,7 +18,7 @@ } } - if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.MOB_DROPS)) { + this.forceDrops = true; // Paper - Add missing forceDrop toggles this.dropFromGiftLootTable(serverLevel, BuiltInLootTables.PANDA_SNEEZE, this::spawnAtLocation); + this.forceDrops = false; // Paper - Add missing forceDrop toggles @@ -39,7 +39,7 @@ } } -@@ -626,8 +_,9 @@ +@@ -624,8 +_,9 @@ this.usePlayerItem(player, hand, itemInHand); this.ageUp((int)(-this.getAge() / 20 * 0.1F), true); } else if (!this.level().isClientSide() && this.getAge() == 0 && this.canFallInLove()) { @@ -50,7 +50,7 @@ } else { if (!(this.level() instanceof ServerLevel serverLevel) || this.isSitting() || this.isInWater()) { return InteractionResult.PASS; -@@ -637,7 +_,9 @@ +@@ -635,7 +_,9 @@ this.eat(true); ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.MAINHAND); if (!itemBySlot.isEmpty() && !player.hasInfiniteMaterials()) { @@ -60,7 +60,7 @@ } this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(itemInHand.getItem(), 1)); -@@ -859,7 +_,7 @@ +@@ -854,7 +_,7 @@ @Override protected void alertOther(Mob mob, LivingEntity target) { if (mob instanceof Panda && mob.isAggressive()) { @@ -69,7 +69,7 @@ } } } -@@ -1088,7 +_,9 @@ +@@ -1083,7 +_,9 @@ public void stop() { ItemStack itemBySlot = Panda.this.getItemBySlot(EquipmentSlot.MAINHAND); if (!itemBySlot.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch index bd95bd002b39..35c882dfdb55 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Parrot.java +++ b/net/minecraft/world/entity/animal/Parrot.java -@@ -265,7 +_,7 @@ +@@ -267,7 +_,7 @@ } if (!this.level().isClientSide()) { @@ -9,7 +9,7 @@ this.tame(player); this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); } else { -@@ -286,7 +_,7 @@ +@@ -288,7 +_,7 @@ } } else { this.usePlayerItem(player, hand, itemInHand); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch index 472c9720c0fd..31833a858436 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Pig.java +++ b/net/minecraft/world/entity/animal/Pig.java -@@ -215,7 +_,14 @@ +@@ -214,7 +_,14 @@ } mob.setPersistenceRequired(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch index 4cbf9b68f433..37c997cffb94 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch @@ -9,7 +9,7 @@ } @Override -@@ -591,9 +_,11 @@ +@@ -588,9 +_,11 @@ if (this.canRaid && block instanceof CarrotBlock) { int ageValue = blockState.getValue(CarrotBlock.AGE); if (ageValue == 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch index 44e765ab9cf5..0478047fca15 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch @@ -8,7 +8,7 @@ + this.hurtServer(serverLevel, this.damageSources().onFire().knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.MELTING), 1.0F); // CraftBukkit } - if (!serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (!serverLevel.getGameRules().get(GameRules.MOB_GRIEFING)) { @@ -107,7 +_,7 @@ int floor2 = Mth.floor(this.getZ() + (i / 2 % 2 * 2 - 1) * 0.25F); BlockPos blockPos = new BlockPos(floor, floor1, floor2); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch index df21684efb8e..8b82dacb92db 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/entity/animal/Turtle.java +++ b/net/minecraft/world/entity/animal/Turtle.java -@@ -261,7 +_,9 @@ +@@ -255,7 +_,9 @@ protected void ageBoundaryReached() { super.ageBoundaryReached(); - if (!this.isBaby() && this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (!this.isBaby() && this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.MOB_DROPS)) { + this.forceDrops = true; // CraftBukkit this.dropFromGiftLootTable(serverLevel, BuiltInLootTables.TURTLE_GROW, this::spawnAtLocation); + this.forceDrops = false; // CraftBukkit } } -@@ -286,7 +_,7 @@ +@@ -276,7 +_,7 @@ @Override public void thunderHit(ServerLevel level, LightningBolt lightning) { @@ -19,7 +19,7 @@ } @Override -@@ -313,6 +_,10 @@ +@@ -303,6 +_,10 @@ if (loveCause == null && this.partner.getLoveCause() != null) { loveCause = this.partner.getLoveCause(); } @@ -30,16 +30,16 @@ if (loveCause != null) { loveCause.awardStat(Stats.ANIMALS_BRED); -@@ -326,7 +_,7 @@ +@@ -316,7 +_,7 @@ this.partner.resetLove(); RandomSource random = this.animal.getRandom(); - if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (getServerLevel(this.level).getGameRules().get(GameRules.MOB_DROPS)) { - this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), random.nextInt(7) + 1)); + if (event.getExperience() > 0) this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.position(), Vec3.ZERO, event.getExperience(), org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, loveCause, this.turtle)); // Paper - Add EntityFertilizeEggEvent event } } } -@@ -349,7 +_,7 @@ +@@ -339,7 +_,7 @@ && ( this.turtle.hasEgg() || this.turtle.getRandom().nextInt(reducedTickDelay(700)) == 0 && !this.turtle.homePos.closerToCenterThan(this.turtle.position(), 64.0) @@ -48,7 +48,7 @@ } @Override -@@ -457,14 +_,20 @@ +@@ -447,14 +_,20 @@ BlockPos blockPos = this.turtle.blockPosition(); if (!this.turtle.isInWater() && this.isReachedTarget()) { if (this.turtle.layEggCounter < 1) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch index ef8378b2a1cf..ec19e8dbe40e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/allay/Allay.java +++ b/net/minecraft/world/entity/animal/allay/Allay.java -@@ -113,6 +_,7 @@ +@@ -112,6 +_,7 @@ private float dancingAnimationTicks; private float spinningAnimationTicks; private float spinningAnimationTicks0; @@ -8,7 +8,7 @@ public Allay(EntityType type, Level level) { super(type, level); -@@ -126,6 +_,12 @@ +@@ -125,6 +_,12 @@ ); } @@ -21,7 +21,7 @@ @Override protected Brain.Provider brainProvider() { return Brain.provider(MEMORY_TYPES, SENSOR_TYPES); -@@ -233,7 +_,7 @@ +@@ -232,7 +_,7 @@ public void aiStep() { super.aiStep(); if (!this.level().isClientSide() && this.isAlive() && this.tickCount % 10 == 0) { @@ -30,7 +30,7 @@ } if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) { -@@ -301,7 +_,12 @@ +@@ -300,7 +_,12 @@ ItemStack itemInHand = player.getItemInHand(hand); ItemStack itemInHand1 = this.getItemInHand(InteractionHand.MAIN_HAND); if (this.isDancing() && itemInHand.is(ItemTags.DUPLICATES_ALLAYS) && this.canDuplicate()) { @@ -44,7 +44,7 @@ this.level().broadcastEntityEvent(this, EntityEvent.IN_LOVE_HEARTS); this.level().playSound(player, this, SoundEvents.AMETHYST_BLOCK_CHIME, SoundSource.NEUTRAL, 2.0F, 1.0F); this.removeInteractionItem(player, itemInHand); -@@ -400,6 +_,7 @@ +@@ -399,6 +_,7 @@ } private boolean shouldStopDancing() { @@ -52,7 +52,7 @@ return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), GameEvent.JUKEBOX_PLAY.value().notificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX); -@@ -452,7 +_,7 @@ +@@ -451,7 +_,7 @@ super.readAdditionalSaveData(input); this.readInventoryFromTag(input); this.vibrationData = input.read("listener", VibrationSystem.Data.CODEC).orElseGet(VibrationSystem.Data::new); @@ -61,7 +61,7 @@ } @Override -@@ -471,15 +_,17 @@ +@@ -470,15 +_,17 @@ this.entityData.set(DATA_CAN_DUPLICATE, duplicationCooldown == 0L); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch index 714cacd93e93..24fa5f2176eb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -138,10 +_,12 @@ +@@ -137,10 +_,12 @@ ArmadilloAi.updateActivity(this); profilerFiller.pop(); if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) { @@ -13,7 +13,7 @@ this.scuteTime = this.pickNextScuteDropTime(); } -@@ -278,8 +_,11 @@ +@@ -277,8 +_,11 @@ } @Override @@ -27,7 +27,7 @@ if (!this.isNoAi() && !this.isDeadOrDying()) { if (damageSource.getEntity() instanceof LivingEntity) { this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L); -@@ -290,6 +_,7 @@ +@@ -289,6 +_,7 @@ this.rollOut(); } } @@ -35,7 +35,7 @@ } @Override -@@ -308,7 +_,9 @@ +@@ -307,7 +_,9 @@ return false; } else { if (this.level() instanceof ServerLevel serverLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch index ebe3a364c64b..db1f768482cf 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch @@ -9,7 +9,7 @@ } public Axolotl.Variant getVariant() { -@@ -450,10 +_,10 @@ +@@ -448,10 +_,10 @@ if (effect == null || effect.endsWithin(2399)) { int i = effect != null ? effect.getDuration() : 0; int min = Math.min(2400, 100 + i); @@ -22,7 +22,7 @@ } @Override -@@ -539,6 +_,13 @@ +@@ -530,6 +_,13 @@ ) { return level.getBlockState(pos.below()).is(BlockTags.AXOLOTLS_SPAWNABLE_ON); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch index 08a4d7d4a009..39caee1ceda0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/camel/Camel.java +++ b/net/minecraft/world/entity/animal/camel/Camel.java -@@ -403,12 +_,12 @@ +@@ -411,12 +_,12 @@ } else { boolean flag = this.getHealth() < this.getMaxHealth(); if (flag) { @@ -15,7 +15,7 @@ } boolean isBaby = this.isBaby(); -@@ -468,9 +_,13 @@ +@@ -474,9 +_,13 @@ } @Override @@ -31,25 +31,25 @@ } @Override -@@ -565,7 +_,7 @@ +@@ -571,7 +_,7 @@ } public void sitDown() { - if (!this.isCamelSitting()) { + if (!this.isCamelSitting() && new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), true).callEvent()) { // Paper - Add EntityToggleSitEvent - this.makeSound(SoundEvents.CAMEL_SIT); + this.makeSound(this.getSitDownSound()); this.setPose(Pose.SITTING); this.gameEvent(GameEvent.ENTITY_ACTION); -@@ -574,7 +_,7 @@ +@@ -580,7 +_,7 @@ } public void standUp() { - if (this.isCamelSitting()) { + if (this.isCamelSitting() && new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), false).callEvent()) { // Paper - Add EntityToggleSitEvent - this.makeSound(SoundEvents.CAMEL_STAND); + this.makeSound(this.getStandUpSound()); this.setPose(Pose.STANDING); this.gameEvent(GameEvent.ENTITY_ACTION); -@@ -583,6 +_,7 @@ +@@ -597,6 +_,7 @@ } public void standUpInstantly() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch index 67806aa82794..f4186542dfdb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java +++ b/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java @@ -58,8 +_,8 @@ - import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; public class CopperGolem extends AbstractGolem implements ContainerUser, Shearable { - private static final long IGNORE_WEATHERING_TICK = -2L; @@ -11,16 +11,16 @@ private static final int WEATHERING_TICK_FROM = 504000; private static final int WEATHERING_TICK_TO = 552000; private static final int SPIN_ANIMATION_MIN_COOLDOWN = 200; -@@ -78,7 +_,7 @@ - private BlockPos openedChestPos; - @Nullable - private UUID lastLightningBoltUUID; +@@ -76,7 +_,7 @@ + ); + private @Nullable BlockPos openedChestPos; + private @Nullable UUID lastLightningBoltUUID; - private long nextWeatheringTick = -1L; + public long nextWeatheringTick = -1L; // Paper - public private int idleAnimationStartTick = 0; private final AnimationState idleAnimationState = new AnimationState(); private final AnimationState interactionGetItemAnimationState = new AnimationState(); -@@ -222,7 +_,15 @@ +@@ -220,7 +_,15 @@ Level level = this.level(); if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { if (level instanceof ServerLevel serverLevel) { @@ -37,7 +37,7 @@ this.gameEvent(GameEvent.SHEAR, player); itemInHand.hurtAndBreak(1, player, hand); } -@@ -285,20 +_,27 @@ +@@ -283,20 +_,27 @@ private void turnToStatue(ServerLevel level) { BlockPos blockPos = this.blockPosition(); @@ -70,8 +70,8 @@ + this.discard(null); // Paper - add Bukkit remove cause this.playSound(SoundEvents.COPPER_GOLEM_BECOME_STATUE); if (this.isLeashed()) { - if (level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { -@@ -429,12 +_,32 @@ + if (level.getGameRules().get(GameRules.ENTITY_DROPS)) { +@@ -426,12 +_,32 @@ } @Override @@ -108,7 +108,7 @@ @Override public boolean readyForShearing() { -@@ -448,9 +_,13 @@ +@@ -445,9 +_,13 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Frog.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Frog.java.patch index 86555d969696..ae9192ae64c2 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Frog.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Frog.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/frog/Frog.java +++ b/net/minecraft/world/entity/animal/frog/Frog.java -@@ -287,7 +_,12 @@ +@@ -285,7 +_,12 @@ @Override public void spawnChildFromBreeding(ServerLevel level, Animal partner) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch index b4ecf723acc2..2d3ea622dc8d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch @@ -31,8 +31,8 @@ + this.ageLocked = input.getBooleanOr("AgeLocked", false); // Paper } - @Nullable -@@ -173,13 +_,19 @@ + @Override +@@ -170,13 +_,19 @@ @Override public void saveToBucketTag(ItemStack stack) { Bucketable.saveDefaultDataToBucketTag(this, stack); @@ -53,7 +53,7 @@ } @Override -@@ -211,6 +_,7 @@ +@@ -208,6 +_,7 @@ } private void ageUp(int offset) { @@ -61,7 +61,7 @@ this.setAge(this.age + offset * 20); } -@@ -223,12 +_,17 @@ +@@ -220,12 +_,17 @@ private void ageUp() { if (this.level() instanceof ServerLevel serverLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch index 25ba8b853664..a05540f3cdf0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/goat/Goat.java +++ b/net/minecraft/world/entity/animal/goat/Goat.java -@@ -235,13 +_,22 @@ +@@ -234,13 +_,22 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.BUCKET) && !this.isBaby()) { @@ -25,7 +25,7 @@ this.playEatingSound(); } -@@ -347,8 +_,7 @@ +@@ -346,8 +_,7 @@ double d1 = Mth.randomBetween(this.random, 0.3F, 0.7F); double d2 = Mth.randomBetween(this.random, -0.2F, 0.2F); ItemEntity itemEntity = new ItemEntity(this.level(), vec3.x(), vec3.y(), vec3.z(), itemStack, d, d1, d2); @@ -35,7 +35,7 @@ } } -@@ -379,4 +_,15 @@ +@@ -378,4 +_,15 @@ ) { return level.getBlockState(pos.below()).is(BlockTags.GOATS_SPAWNABLE_ON) && isBrightEnoughToSpawn(level, pos); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch index afe3272470b2..c90ac1a05a3a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java -@@ -73,6 +_,12 @@ +@@ -74,6 +_,12 @@ super.dropEquipment(level); if (this.hasChest()) { this.spawnAtLocation(level, Blocks.CHEST); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch index 59ace8c45609..a2d2806b86d7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java -@@ -124,6 +_,7 @@ +@@ -123,6 +_,7 @@ + protected boolean canGallop = true; protected int gallopSoundCounter; - @Nullable - public EntityReference owner; + public @Nullable EntityReference owner; + public int maxDomestication = 100; // CraftBukkit - store max domestication value protected AbstractHorse(EntityType type, Level level) { super(type, level); -@@ -253,7 +_,7 @@ +@@ -251,7 +_,7 @@ } @Override @@ -17,7 +17,7 @@ return !this.isVehicle(); } -@@ -304,7 +_,7 @@ +@@ -302,7 +_,7 @@ public void createInventory() { SimpleContainer simpleContainer = this.inventory; @@ -26,7 +26,7 @@ if (simpleContainer != null) { int min = Math.min(simpleContainer.getContainerSize(), this.inventory.getContainerSize()); -@@ -398,7 +_,7 @@ +@@ -394,7 +_,7 @@ } public int getMaxTemper() { @@ -35,7 +35,7 @@ } @Override -@@ -461,7 +_,7 @@ +@@ -457,7 +_,7 @@ i1 = 5; if (!this.level().isClientSide() && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { flag = true; @@ -44,7 +44,7 @@ } } else if (stack.is(Items.GOLDEN_APPLE) || stack.is(Items.ENCHANTED_GOLDEN_APPLE)) { f = 10.0F; -@@ -469,12 +_,12 @@ +@@ -465,12 +_,12 @@ i1 = 10; if (!this.level().isClientSide() && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { flag = true; @@ -59,7 +59,7 @@ flag = true; } -@@ -545,7 +_,7 @@ +@@ -541,7 +_,7 @@ super.aiStep(); if (this.level() instanceof ServerLevel serverLevel && this.isAlive()) { if (this.random.nextInt(900) == 0 && this.deathTime == 0) { @@ -68,7 +68,7 @@ } if (this.canEatGrass()) { -@@ -647,6 +_,16 @@ +@@ -643,6 +_,16 @@ } } @@ -85,7 +85,7 @@ @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { if (this.isVehicle() || this.isBaby()) { -@@ -799,6 +_,7 @@ +@@ -794,6 +_,7 @@ output.putInt("Temper", this.getTemper()); output.putBoolean("Tame", this.isTamed()); EntityReference.store(this.owner, output, "Owner"); @@ -93,7 +93,7 @@ } @Override -@@ -809,6 +_,7 @@ +@@ -804,6 +_,7 @@ this.setTemper(input.getIntOr("Temper", 0)); this.setTamed(input.getBooleanOr("Tame", false)); this.owner = EntityReference.readWithOldOwnerConversion(input, "Owner", this.level()); @@ -101,7 +101,7 @@ } @Override -@@ -897,6 +_,17 @@ +@@ -891,6 +_,17 @@ @Override public void handleStartJump(int jumpPower) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch index 478d49854eec..471cee49f3bc 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/animal/horse/Llama.java +++ b/net/minecraft/world/entity/animal/horse/Llama.java -@@ -77,18 +_,19 @@ - @Nullable - private Llama caravanHead; - @Nullable -- private Llama caravanTail; -+ public Llama caravanTail; // Paper - public +@@ -75,18 +_,19 @@ + .scale(0.5F); + boolean didSpit; + private @Nullable Llama caravanHead; +- private @Nullable Llama caravanTail; ++ public @Nullable Llama caravanTail; // Paper - public public Llama(EntityType type, Level level) { super(type, level); @@ -22,7 +22,7 @@ this.entityData.set(DATA_STRENGTH_ID, Math.max(1, Math.min(5, strength))); } -@@ -194,12 +_,12 @@ +@@ -191,12 +_,12 @@ f = 10.0F; if (this.isTamed() && this.getAge() == 0 && this.canFallInLove()) { flag = true; @@ -37,7 +37,7 @@ flag = true; } -@@ -313,7 +_,7 @@ +@@ -308,7 +_,7 @@ @Override public int getMaxTemper() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch index a446a4d6fe3c..c7fe01d2930a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/TraderLlama.java +++ b/net/minecraft/world/entity/animal/horse/TraderLlama.java -@@ -89,7 +_,7 @@ +@@ -88,7 +_,7 @@ this.despawnDelay = this.isLeashedToWanderingTrader() ? ((WanderingTrader)this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1; if (this.despawnDelay <= 0) { this.removeLeash(); @@ -9,7 +9,7 @@ } } } -@@ -148,7 +_,7 @@ +@@ -146,7 +_,7 @@ @Override public void start() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch index 27e74cafe633..70da9d7b0e84 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java +++ b/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java -@@ -388,7 +_,7 @@ +@@ -381,7 +_,7 @@ if (this.isFood(itemInHand) && this.getHealth() < this.getMaxHealth()) { this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); - this.heal(foodProperties != null ? 2 * foodProperties.nutrition() : 1.0F); + this.heal(foodProperties != null ? 2 * foodProperties.nutrition() : 1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper - Add regain reason + this.playEatingSound(); return InteractionResult.SUCCESS; } - -@@ -408,7 +_,7 @@ +@@ -402,7 +_,7 @@ } private void tryToTame(Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch index 770f05b5920e..0d8ad115baec 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/nautilus/Nautilus.java +++ b/net/minecraft/world/entity/animal/nautilus/Nautilus.java -@@ -98,8 +_,14 @@ +@@ -97,8 +_,14 @@ @Override public int getMaxAirSupply() { @@ -17,7 +17,7 @@ protected void handleAirSupply(ServerLevel level, int airSupply) { if (this.isAlive() && !this.isInWater()) { -@@ -109,7 +_,7 @@ +@@ -108,7 +_,7 @@ this.hurtServer(level, this.damageSources().dryOut(), 2.0F); } } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch index b9fb8d4ec5e7..bb206b657c75 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch @@ -57,7 +57,7 @@ if (itemEntity != null) { itemEntity.setDeltaMovement( itemEntity.getDeltaMovement() -@@ -281,6 +_,7 @@ +@@ -279,6 +_,7 @@ @Override public void ate() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch index f93ff3c4f8ab..73a3cd945133 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/wolf/Wolf.java +++ b/net/minecraft/world/entity/animal/wolf/Wolf.java -@@ -400,16 +_,18 @@ +@@ -397,16 +_,18 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { @@ -22,7 +22,7 @@ ItemStack bodyArmorItem = this.getBodyArmorItem(); int damageValue = bodyArmorItem.getDamageValue(); int maxDamage = bodyArmorItem.getMaxDamage(); -@@ -429,6 +_,7 @@ +@@ -426,6 +_,7 @@ ); } } @@ -30,7 +30,7 @@ } private boolean canArmorAbsorb(DamageSource damageSource) { -@@ -439,7 +_,7 @@ +@@ -436,7 +_,7 @@ protected void applyTamingSideEffects() { if (this.isTame()) { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(40.0); @@ -39,7 +39,7 @@ } else { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(8.0); } -@@ -464,7 +_,7 @@ +@@ -461,7 +_,7 @@ this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); float f = foodProperties != null ? foodProperties.nutrition() : 1.0F; @@ -48,7 +48,7 @@ return InteractionResult.SUCCESS; } -@@ -493,7 +_,7 @@ +@@ -490,7 +_,7 @@ this.setOrderedToSit(!this.isOrderedToSit()); this.jumping = false; this.navigation.stop(); @@ -57,7 +57,7 @@ return InteractionResult.SUCCESS.withoutItem(); } -@@ -502,6 +_,13 @@ +@@ -499,6 +_,13 @@ DyeColor dyeColor = dyeItem.getDyeColor(); if (dyeColor != this.getCollarColor()) { @@ -71,7 +71,7 @@ this.setCollarColor(dyeColor); itemInHand.consume(1, player); return InteractionResult.SUCCESS; -@@ -516,7 +_,7 @@ +@@ -513,7 +_,7 @@ } private void tryToTame(Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch index f2476c893834..27e7b473a0dc 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -@@ -89,6 +_,10 @@ +@@ -87,6 +_,10 @@ private final Node[] nodes = new Node[24]; private final int[] nodeAdjacency = new int[24]; private final BinaryHeap openSet = new BinaryHeap(); @@ -11,7 +11,7 @@ public EnderDragon(EntityType type, Level level) { super(EntityType.ENDER_DRAGON, level); -@@ -104,6 +_,7 @@ +@@ -102,6 +_,7 @@ this.setHealth(this.getMaxHealth()); this.noPhysics = true; this.phaseManager = new EnderDragonPhaseManager(this); @@ -19,7 +19,7 @@ } public void setDragonFight(EndDragonFight dragonFight) { -@@ -122,6 +_,19 @@ +@@ -120,6 +_,19 @@ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 200.0).add(Attributes.CAMERA_DISTANCE, 16.0); } @@ -39,7 +39,7 @@ @Override public boolean isFlapping() { float cos = Mth.cos(this.flapTime * (float) (Math.PI * 2)); -@@ -213,7 +_,7 @@ +@@ -211,7 +_,7 @@ } Vec3 flyTargetLocation = currentPhase.getFlyTargetLocation(); @@ -48,7 +48,7 @@ double d = flyTargetLocation.x - this.getX(); double d1 = flyTargetLocation.y - this.getY(); double d2 = flyTargetLocation.z - this.getZ(); -@@ -368,7 +_,12 @@ +@@ -366,7 +_,12 @@ if (this.nearestCrystal.isRemoved()) { this.nearestCrystal = null; } else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -62,7 +62,7 @@ } } -@@ -398,7 +_,7 @@ +@@ -396,7 +_,7 @@ double d2 = entity.getX() - d; double d3 = entity.getZ() - d1; double max = Math.max(d2 * d2 + d3 * d3, 0.1); @@ -71,7 +71,7 @@ if (!this.phaseManager.getCurrentPhase().isSitting() && livingEntity.getLastHurtByMobTimestamp() < entity.tickCount - 2) { DamageSource damageSource = this.damageSources().mobAttack(this); entity.hurtServer(level, damageSource, 5.0F); -@@ -431,6 +_,7 @@ +@@ -429,6 +_,7 @@ int floor5 = Mth.floor(box.maxZ); boolean flag = false; boolean flag1 = false; @@ -79,10 +79,10 @@ for (int i = floor; i <= floor3; i++) { for (int i1 = floor1; i1 <= floor4; i1++) { -@@ -439,7 +_,11 @@ +@@ -437,7 +_,11 @@ BlockState blockState = level.getBlockState(blockPos); if (!blockState.isAir() && !blockState.is(BlockTags.DRAGON_TRANSPARENT)) { - if (level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !blockState.is(BlockTags.DRAGON_IMMUNE)) { + if (level.getGameRules().get(GameRules.MOB_GRIEFING) && !blockState.is(BlockTags.DRAGON_IMMUNE)) { - flag1 = level.removeBlock(blockPos, false) || flag1; + // CraftBukkit start - Add blocks to list rather than destroying them + //flag1 = level.removeBlock(blockPos, false) || flag1; @@ -92,7 +92,7 @@ } else { flag = true; } -@@ -448,6 +_,58 @@ +@@ -446,6 +_,58 @@ } } @@ -151,7 +151,7 @@ if (flag1) { BlockPos blockPos1 = new BlockPos( floor + this.random.nextInt(floor3 - floor + 1), -@@ -505,7 +_,15 @@ +@@ -503,7 +_,15 @@ @Override public void kill(ServerLevel level) { @@ -168,7 +168,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); if (this.dragonFight != null) { this.dragonFight.updateDragon(this); -@@ -527,18 +_,41 @@ +@@ -525,18 +_,41 @@ this.level().addParticle(ParticleTypes.EXPLOSION_EMITTER, this.getX() + f, this.getY() + 2.0 + f1, this.getZ() + f2, 0.0, 0.0, 0.0); } @@ -183,7 +183,7 @@ + // CraftBukkit end if (this.level() instanceof ServerLevel serverLevel) { -- if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && serverLevel.getGameRules().get(GameRules.MOB_DROPS)) { - ExperienceOrb.award(serverLevel, this.position(), Mth.floor(i * 0.08F)); + if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp + ExperienceOrb.awardWithDirection(serverLevel, this.position(), net.minecraft.world.phys.Vec3.ZERO, Mth.floor(i * 0.08F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, net.minecraft.world.entity.EntityReference.get(this.lastHurtByPlayer, this.level(), Player.class), this); // Paper @@ -199,7 +199,7 @@ + double deltaZ = this.getZ() - player.getZ(); + double distanceSquared = Mth.square(deltaX) + Mth.square(deltaZ); + final double soundRadiusSquared = serverLevel.getGlobalSoundRangeSquared(config -> config.dragonDeathSoundRadius); // Paper - respect global sound events gamerule -+ if (!serverLevel.getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Paper - respect global sound events gamerule ++ if (!serverLevel.getGameRules().get(GameRules.GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Paper - respect global sound events gamerule + if (distanceSquared > Mth.square(viewDistance)) { + double deltaLength = Math.sqrt(distanceSquared); + double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; @@ -213,11 +213,11 @@ } } -@@ -551,15 +_,15 @@ +@@ -549,15 +_,15 @@ } if (this.dragonDeathTime == 200 && this.level() instanceof ServerLevel serverLevel1) { -- if (serverLevel1.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- if (serverLevel1.getGameRules().get(GameRules.MOB_DROPS)) { - ExperienceOrb.award(serverLevel1, this.position(), Mth.floor(i * 0.2F)); + if (true) { // Paper - SPIGOT-2420: Already checked for the game rule when calculating the xp + ExperienceOrb.awardWithDirection(serverLevel1, this.position(), net.minecraft.world.phys.Vec3.ZERO, Mth.floor(i * 0.2F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, net.minecraft.world.entity.EntityReference.get(this.lastHurtByPlayer, this.level(), Player.class), this); // Paper @@ -232,7 +232,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); } } -@@ -741,6 +_,7 @@ +@@ -738,6 +_,7 @@ super.addAdditionalSaveData(output); output.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId()); output.putInt("DragonDeathTime", this.dragonDeathTime); @@ -240,7 +240,7 @@ } @Override -@@ -748,6 +_,7 @@ +@@ -745,6 +_,7 @@ super.readAdditionalSaveData(input); input.getInt("DragonPhase").ifPresent(integer -> this.phaseManager.setPhase(EnderDragonPhase.getById(integer))); this.dragonDeathTime = input.getIntOr("DragonDeathTime", 0); @@ -248,7 +248,7 @@ } @Override -@@ -788,7 +_,7 @@ +@@ -785,7 +_,7 @@ EnderDragonPhase phase = currentPhase.getPhase(); Vec3 viewVector; if (phase == EnderDragonPhase.LANDING || phase == EnderDragonPhase.TAKEOFF) { @@ -257,7 +257,7 @@ float max = Math.max((float)Math.sqrt(heightmapPos.distToCenterSqr(this.position())) / 4.0F, 1.0F); float f = 6.0F / max; float xRot = this.getXRot(); -@@ -876,4 +_,19 @@ +@@ -872,4 +_,19 @@ protected float sanitizeScale(float scale) { return 1.0F; } @@ -266,7 +266,7 @@ + @Override + public int getExpReward(ServerLevel level, Entity entity) { + // CraftBukkit - Moved from #tickDeath method -+ boolean flag = level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT); ++ boolean flag = level.getGameRules().get(GameRules.MOB_DROPS); + int i = 500; + + if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java.patch index 3c43f0ec62c7..50c8b1f6f662 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java -@@ -34,7 +_,7 @@ +@@ -33,7 +_,7 @@ public void doServerTick(ServerLevel level) { this.time++; if (this.targetLocation == null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java.patch index 9652e080af12..0ae3e07ca1ce 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java -@@ -53,7 +_,7 @@ +@@ -50,7 +_,7 @@ private void findNewTarget(ServerLevel level) { if (this.currentPath != null && this.currentPath.isDone()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java.patch index bfc7cb63f7a4..0abf0d51e715 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java -@@ -52,7 +_,7 @@ +@@ -49,7 +_,7 @@ private void findNewTarget(ServerLevel level) { if (this.currentPath == null || this.currentPath.isDone()) { int i = this.dragon.findClosestNode(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java.patch index 5b33dd00ad2f..dcadba51268e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java -@@ -51,7 +_,7 @@ +@@ -50,7 +_,7 @@ public void doServerTick(ServerLevel level) { if (this.targetLocation == null) { this.targetLocation = Vec3.atBottomCenterOf( diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch index b5f3bda70f50..42a7a0356203 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java -@@ -94,7 +_,13 @@ +@@ -93,7 +_,13 @@ this.flame.setCustomParticle(PowerParticleOption.create(ParticleTypes.DRAGON_BREATH, 1.0F)); this.flame.setPotionDurationScale(0.25F); this.flame.addEffect(new MobEffectInstance(MobEffects.INSTANT_DAMAGE)); @@ -14,7 +14,7 @@ } } -@@ -107,7 +_,7 @@ +@@ -106,7 +_,7 @@ @Override public void end() { if (this.flame != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch index afcef46ed1de..b61e3572c5ce 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java -@@ -73,13 +_,16 @@ +@@ -70,13 +_,16 @@ double d6 = this.attackTarget.getY(0.5) - d3; double d7 = this.attackTarget.getZ() - d4; Vec3 vec32 = new Vec3(d5, d6, d7); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java.patch index d81a699daa82..f58b95dd48cd 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java -@@ -24,7 +_,7 @@ +@@ -22,7 +_,7 @@ @Override public void doServerTick(ServerLevel level) { if (!this.firstTick && this.currentPath != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch index 980373b3f609..ff4d2ea48644 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -31,7 +31,7 @@ + double deltaZ = this.getZ() - player.getZ(); + double distanceSquared = Mth.square(deltaX) + Mth.square(deltaZ); + final double soundRadiusSquared = level.getGlobalSoundRangeSquared(config -> config.witherSpawnSoundRadius); // Paper - respect global sound events gamerule -+ if (!level.getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Spigot // Paper - respect global sound events gamerule ++ if (!level.getGameRules().get(GameRules.GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Spigot // Paper - respect global sound events gamerule + if (distanceSquared > Mth.square(viewDistance)) { + double deltaLength = Math.sqrt(distanceSquared); + double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch index 8c0e896aba23..8e6296c6ae5b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch @@ -116,7 +116,7 @@ @Override @@ -268,15 +_,32 @@ - } else if (!level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && damageSource.getEntity() instanceof Mob) { + } else if (!level.getGameRules().get(GameRules.MOB_GRIEFING) && damageSource.getEntity() instanceof Mob) { return false; } else if (damageSource.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { - this.kill(level); @@ -289,7 +289,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); } -@@ -685,4 +_,13 @@ +@@ -683,4 +_,13 @@ .apply(instance, ArmorStand.ArmorStandPose::new) ); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch index 7e31cac70397..040af54cf20e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch @@ -51,22 +51,21 @@ this.dropItem(level, damageSource.getEntity(), false); this.gameEvent(GameEvent.BLOCK_CHANGE, damageSource.getEntity()); this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F); -@@ -258,6 +_,14 @@ +@@ -258,6 +_,13 @@ return this.getEntityData().get(DATA_ITEM); } + // Paper start - Fix MC-123848 (spawn item frame drops above block) -+ @Nullable + @Override -+ public net.minecraft.world.entity.item.ItemEntity spawnAtLocation(ServerLevel serverLevel, ItemStack stack) { ++ public net.minecraft.world.entity.item.@Nullable ItemEntity spawnAtLocation(ServerLevel serverLevel, ItemStack stack) { + return this.spawnAtLocation(serverLevel, stack, this.getDirection() == Direction.DOWN ? -0.6F : 0.0F); + } + // Paper end + - @Nullable - public MapId getFramedMapId(ItemStack stack) { + public @Nullable MapId getFramedMapId(ItemStack stack) { return stack.get(DataComponents.MAP_ID); -@@ -272,13 +_,19 @@ + } +@@ -271,13 +_,19 @@ } public void setItem(ItemStack stack, boolean updateNeighbours) { @@ -87,7 +86,7 @@ this.playSound(this.getAddItemSound(), 1.0F, 1.0F); } -@@ -305,6 +_,7 @@ +@@ -304,6 +_,7 @@ } private void onItemChanged(ItemStack item) { @@ -95,7 +94,7 @@ if (!item.isEmpty() && item.getFrame() != this) { item.setEntityRepresentation(this); } -@@ -373,7 +_,13 @@ +@@ -372,7 +_,13 @@ if (savedData != null && savedData.isTrackedCountOverLimit(256)) { return InteractionResult.FAIL; } else { @@ -110,7 +109,7 @@ this.gameEvent(GameEvent.BLOCK_CHANGE, player); itemInHand.consume(1, player); return InteractionResult.SUCCESS; -@@ -382,6 +_,13 @@ +@@ -381,6 +_,13 @@ return InteractionResult.PASS; } } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch index 65331b4049ae..f89a67b2afb9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java.patch @@ -35,7 +35,7 @@ public static LeashFenceKnotEntity getOrCreateKnot(Level level, BlockPos pos) { + return getOrCreateKnot(level, pos, null); + } -+ public static LeashFenceKnotEntity getOrCreateKnot(Level level, BlockPos pos, @Nullable org.apache.commons.lang3.mutable.MutableBoolean created) { ++ public static LeashFenceKnotEntity getOrCreateKnot(Level level, BlockPos pos, org.apache.commons.lang3.mutable.@Nullable MutableBoolean created) { + // Paper end - Track if a knot was created int x = pos.getX(); int y = pos.getY(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/Painting.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/Painting.java.patch index e448f719b00d..b4fe3f726bf7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/Painting.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/Painting.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/Painting.java +++ b/net/minecraft/world/entity/decoration/Painting.java -@@ -149,21 +_,31 @@ +@@ -148,21 +_,31 @@ @Override protected AABB calculateBoundingBox(BlockPos pos, Direction direction) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch index b6351e4095a2..8c6c4c685462 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -72,6 +_,7 @@ - public CompoundTag blockData; +@@ -71,6 +_,7 @@ + public @Nullable CompoundTag blockData; public boolean forceTickAfterTeleportToDuplicate; protected static final EntityDataAccessor DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS); + public boolean autoExpire = true; // Paper - Expand FallingBlock API public FallingBlockEntity(EntityType type, Level level) { super(type, level); -@@ -97,6 +_,7 @@ +@@ -96,6 +_,7 @@ pos.getZ() + 0.5, state.hasProperty(BlockStateProperties.WATERLOGGED) ? state.setValue(BlockStateProperties.WATERLOGGED, false) : state ); @@ -16,7 +16,7 @@ level.setBlock(pos, state.getFluidState().createLegacyBlock(), Block.UPDATE_ALL); level.addFreshEntity(fallingBlockEntity); return fallingBlockEntity; -@@ -147,13 +_,22 @@ +@@ -146,13 +_,22 @@ @Override public void tick() { if (this.blockState.isAir()) { @@ -30,7 +30,7 @@ this.applyEffectsFromBlocks(); + // Paper start - Configurable falling blocks height nerf + if (this.level().paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) { -+ if (this.dropItem && this.level() instanceof final ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { ++ if (this.dropItem && this.level() instanceof final ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.ENTITY_DROPS)) { + this.spawnAtLocation(serverLevel, block); + } + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.OUT_OF_WORLD); @@ -40,13 +40,13 @@ this.handlePortal(); if (this.level() instanceof ServerLevel serverLevel && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) { BlockPos blockPos = this.blockPosition(); -@@ -174,12 +_,12 @@ +@@ -173,12 +_,12 @@ } if (!this.onGround() && !flag1) { - if (this.time > 100 && (blockPos.getY() <= this.level().getMinY() || blockPos.getY() > this.level().getMaxY()) || this.time > 600) { + if ((this.time > 100 && autoExpire) && (blockPos.getY() <= this.level().getMinY() || blockPos.getY() > this.level().getMaxY()) || (this.time > 600 && autoExpire)) { // Paper - Expand FallingBlock API - if (this.dropItem && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + if (this.dropItem && serverLevel.getGameRules().get(GameRules.ENTITY_DROPS)) { this.spawnAtLocation(serverLevel, block); } @@ -55,7 +55,7 @@ } } else { BlockState blockState = this.level().getBlockState(blockPos); -@@ -197,11 +_,17 @@ +@@ -196,11 +_,17 @@ this.blockState = this.blockState.setValue(BlockStateProperties.WATERLOGGED, true); } @@ -74,10 +74,10 @@ if (block instanceof Fallable fallable) { fallable.onLand(this.level(), blockPos, this.blockState, blockState, this); } -@@ -226,19 +_,19 @@ +@@ -225,19 +_,19 @@ } } - } else if (this.dropItem && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + } else if (this.dropItem && serverLevel.getGameRules().get(GameRules.ENTITY_DROPS)) { - this.discard(); + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause this.callOnBrokenAfterFall(block, blockPos); @@ -86,7 +86,7 @@ } else { - this.discard(); + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause - if (this.dropItem && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + if (this.dropItem && serverLevel.getGameRules().get(GameRules.ENTITY_DROPS)) { this.callOnBrokenAfterFall(block, blockPos); this.spawnAtLocation(serverLevel, block); } @@ -97,7 +97,7 @@ this.callOnBrokenAfterFall(block, blockPos); } } -@@ -298,6 +_,7 @@ +@@ -297,6 +_,7 @@ } output.putBoolean("CancelDrop", this.cancelDrop); @@ -105,7 +105,7 @@ } @Override -@@ -309,8 +_,9 @@ +@@ -308,8 +_,9 @@ this.fallDamagePerDistance = input.getFloatOr("FallHurtAmount", 0.0F); this.fallDamageMax = input.getIntOr("FallHurtMax", 40); this.dropItem = input.getBooleanOr("DropItem", true); @@ -116,7 +116,7 @@ } public void setHurtsEntities(float fallDamagePerDistance, int fallDamageMax) { -@@ -367,7 +_,7 @@ +@@ -365,7 +_,7 @@ ResourceKey resourceKey1 = this.level().dimension(); boolean flag = (resourceKey1 == Level.END || resourceKey == Level.END) && resourceKey1 != resourceKey; Entity entity = super.teleport(teleportTransition); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch index cf980acc7fa4..4fda90eca2b9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -53,6 +_,9 @@ - @Nullable - public UUID target; +@@ -51,6 +_,9 @@ + public @Nullable EntityReference thrower; + public @Nullable UUID target; public final float bobOffs = this.random.nextFloat() * (float) Math.PI * 2.0F; + public boolean canMobPickup = true; // Paper - Item#canEntityPickup + private int despawnRate = -1; // Paper - Alternative item-despawn-rate @@ -10,7 +10,7 @@ public ItemEntity(EntityType type, Level level) { super(type, level); -@@ -60,7 +_,12 @@ +@@ -58,7 +_,12 @@ } public ItemEntity(Level level, double posX, double posY, double posZ, ItemStack stack) { @@ -24,7 +24,7 @@ } public ItemEntity(Level level, double posX, double posY, double posZ, ItemStack stack, double deltaX, double deltaY, double deltaZ) { -@@ -70,6 +_,14 @@ +@@ -68,6 +_,14 @@ this.setItem(stack); } @@ -39,7 +39,7 @@ @Override public boolean dampensVibrations() { return this.getItem().is(ItemTags.DAMPENS_VIBRATIONS); -@@ -107,7 +_,7 @@ +@@ -104,7 +_,7 @@ @Override public void tick() { if (this.getItem().isEmpty()) { @@ -48,7 +48,7 @@ } else { super.tick(); if (this.pickupDelay > 0 && this.pickupDelay != 32767) { -@@ -135,11 +_,15 @@ +@@ -132,11 +_,15 @@ } } @@ -66,7 +66,7 @@ f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; } -@@ -172,8 +_,14 @@ +@@ -169,8 +_,14 @@ } } @@ -83,7 +83,7 @@ } } } -@@ -198,9 +_,18 @@ +@@ -195,9 +_,18 @@ private void mergeWithNeighbours() { if (this.isMergable()) { @@ -103,7 +103,7 @@ this.tryToMerge(itemEntity); if (this.isRemoved()) { break; -@@ -212,7 +_,7 @@ +@@ -209,7 +_,7 @@ private boolean isMergable() { ItemStack item = this.getItem(); @@ -112,7 +112,7 @@ } private void tryToMerge(ItemEntity itemEntity) { -@@ -245,11 +_,16 @@ +@@ -242,11 +_,16 @@ } private static void merge(ItemEntity destinationEntity, ItemStack destinationStack, ItemEntity originEntity, ItemStack originStack) { @@ -130,7 +130,7 @@ } } -@@ -277,12 +_,17 @@ +@@ -274,12 +_,17 @@ } else if (!this.getItem().canBeHurtBy(damageSource)) { return false; } else { @@ -149,7 +149,7 @@ } return true; -@@ -304,6 +_,11 @@ +@@ -301,6 +_,11 @@ if (!this.getItem().isEmpty()) { output.store("Item", ItemStack.CODEC, this.getItem()); } @@ -161,7 +161,7 @@ } @Override -@@ -314,8 +_,17 @@ +@@ -311,8 +_,17 @@ this.target = input.read("Owner", UUIDUtil.CODEC).orElse(null); this.thrower = EntityReference.read(input, "Thrower"); this.setItem(input.read("Item", ItemStack.CODEC).orElse(ItemStack.EMPTY)); @@ -180,7 +180,7 @@ } } -@@ -325,10 +_,73 @@ +@@ -322,10 +_,73 @@ ItemStack item = this.getItem(); Item item1 = item.getItem(); int count = item.getCount(); @@ -255,7 +255,7 @@ item.setCount(count); } -@@ -366,6 +_,7 @@ +@@ -362,6 +_,7 @@ public void setItem(ItemStack stack) { this.getEntityData().set(DATA_ITEM, stack); @@ -263,7 +263,7 @@ } @Override -@@ -418,7 +_,7 @@ +@@ -414,7 +_,7 @@ public void makeFakeItem() { this.setNeverPickUp(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch index f0625f340d7d..35574d47b784 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java @@ -28,6 +_,12 @@ - import net.minecraft.world.level.storage.ValueInput; import net.minecraft.world.level.storage.ValueOutput; + import org.jspecify.annotations.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -13,15 +13,15 @@ public class PrimedTnt extends Entity implements TraceableEntity { private static final EntityDataAccessor DATA_FUSE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.INT); private static final EntityDataAccessor DATA_BLOCK_STATE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.BLOCK_STATE); -@@ -52,6 +_,7 @@ - public EntityReference owner; +@@ -51,6 +_,7 @@ + public @Nullable EntityReference owner; private boolean usedPortal; public float explosionPower = 4.0F; + public boolean isIncendiary = false; // CraftBukkit public PrimedTnt(EntityType type, Level level) { super(type, level); -@@ -61,7 +_,7 @@ +@@ -60,7 +_,7 @@ public PrimedTnt(Level level, double x, double y, double z, @Nullable LivingEntity owner) { this(EntityType.TNT, level); this.setPos(x, y, z); @@ -30,7 +30,7 @@ this.setDeltaMovement(-Math.sin(d) * 0.02, 0.2F, -Math.cos(d) * 0.02); this.setFuse(80); this.xo = x; -@@ -93,10 +_,17 @@ +@@ -92,10 +_,17 @@ @Override public void tick() { @@ -48,7 +48,7 @@ this.setDeltaMovement(this.getDeltaMovement().scale(0.98)); if (this.onGround()) { this.setDeltaMovement(this.getDeltaMovement().multiply(0.7, -0.5, 0.7)); -@@ -105,20 +_,35 @@ +@@ -104,20 +_,35 @@ int i = this.getFuse() - 1; this.setFuse(i); if (i <= 0) { @@ -75,7 +75,7 @@ } private void explode() { - if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) { + if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.TNT_EXPLODES)) { + // CraftBukkit start + ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); + if (event.isCancelled()) { @@ -85,7 +85,7 @@ this.level() .explode( this, -@@ -127,8 +_,8 @@ +@@ -126,8 +_,8 @@ this.getX(), this.getY(0.0625), this.getZ(), @@ -96,7 +96,7 @@ Level.ExplosionInteraction.TNT ); } -@@ -202,4 +_,11 @@ +@@ -199,4 +_,11 @@ public final boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch index 53618c133cce..adc766a54f6a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/AbstractSkeleton.java +++ b/net/minecraft/world/entity/monster/AbstractSkeleton.java -@@ -63,6 +_,7 @@ +@@ -65,6 +_,7 @@ AbstractSkeleton.this.setAggressive(true); } }; @@ -8,7 +8,7 @@ protected AbstractSkeleton(EntityType type, Level level) { super(type, level); -@@ -87,6 +_,21 @@ +@@ -89,6 +_,21 @@ return Monster.createMonsterAttributes().add(Attributes.MOVEMENT_SPEED, 0.25); } @@ -30,7 +30,7 @@ @Override protected void playStepSound(BlockPos pos, BlockState block) { this.playSound(this.getStepSound(), 0.15F, 1.0F); -@@ -118,7 +_,7 @@ +@@ -119,7 +_,7 @@ this.populateDefaultEquipmentSlots(random, difficulty); this.populateDefaultEquipmentEnchantments(level, random, difficulty); this.reassessWeaponGoal(); @@ -39,7 +39,7 @@ if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty() && SpecialDates.isHalloween() && random.nextFloat() < 0.25F) { this.setItemSlot(EquipmentSlot.HEAD, new ItemStack(random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN)); this.setDropChance(EquipmentSlot.HEAD, 0.0F); -@@ -156,7 +_,8 @@ +@@ -157,7 +_,8 @@ @Override public void performRangedAttack(LivingEntity target, float distanceFactor) { @@ -49,7 +49,7 @@ ItemStack projectile = this.getProjectile(itemInHand); AbstractArrow arrow = this.getArrow(projectile, distanceFactor, itemInHand); double d = target.getX() - this.getX(); -@@ -164,9 +_,21 @@ +@@ -165,9 +_,21 @@ double d2 = target.getZ() - this.getZ(); double squareRoot = Math.sqrt(d * d + d2 * d2); if (this.level() instanceof ServerLevel serverLevel) { @@ -72,7 +72,7 @@ } this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); -@@ -190,11 +_,22 @@ +@@ -191,11 +_,22 @@ protected void readAdditionalSaveData(ValueInput input) { super.readAdditionalSaveData(input); this.reassessWeaponGoal(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Bogged.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Bogged.java.patch index 2661b9cf10e0..6d7d6d459cc8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Bogged.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Bogged.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Bogged.java +++ b/net/minecraft/world/entity/monster/Bogged.java -@@ -74,7 +_,19 @@ +@@ -72,7 +_,19 @@ ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { if (this.level() instanceof ServerLevel serverLevel) { @@ -21,7 +21,7 @@ this.gameEvent(GameEvent.SHEAR, player); itemInHand.hurtAndBreak(1, player, hand.asEquipmentSlot()); } -@@ -127,15 +_,33 @@ +@@ -125,15 +_,33 @@ @Override public void shear(ServerLevel level, SoundSource source, ItemStack shears) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch index 58cc6a6dfdec..65fc6a540624 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch @@ -22,7 +22,7 @@ @Override - public void setTarget(@Nullable LivingEntity target) { -+ public boolean setTarget(@Nullable LivingEntity target, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { // CraftBukkit ++ public boolean setTarget(@Nullable LivingEntity target, org.bukkit.event.entity.EntityTargetEvent.@Nullable TargetReason reason) { // CraftBukkit if (!(target instanceof Goat)) { - super.setTarget(target); + return super.setTarget(target, reason); // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch index 28b883945a16..75ed4eb61e6e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Drowned.java +++ b/net/minecraft/world/entity/monster/Drowned.java -@@ -88,7 +_,7 @@ +@@ -89,7 +_,7 @@ this.goalSelector.addGoal(7, new RandomStrollGoal(this, 1.0)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this, Drowned.class).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, (entity, level) -> this.okTarget(entity))); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch index 4b176b45835a..a7435e6abc0d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EnderMan.java +++ b/net/minecraft/world/entity/monster/EnderMan.java -@@ -120,9 +_,20 @@ +@@ -119,9 +_,20 @@ .add(Attributes.STEP_HEIGHT, 1.0); } @@ -14,7 +14,7 @@ - public void setTarget(@Nullable LivingEntity target) { - super.setTarget(target); + // CraftBukkit start - fire event -+ public boolean setTarget(@Nullable LivingEntity target, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { ++ public boolean setTarget(@Nullable LivingEntity target, org.bukkit.event.entity.EntityTargetEvent.@Nullable TargetReason reason) { + if (!super.setTarget(target, reason)) { + return false; + } @@ -23,7 +23,7 @@ AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED); if (target == null) { this.targetChangeTime = 0; -@@ -136,6 +_,7 @@ +@@ -135,6 +_,7 @@ attribute.addTransientModifier(SPEED_MODIFIER_ATTACKING); } } @@ -31,7 +31,7 @@ } @Override -@@ -209,6 +_,15 @@ +@@ -207,6 +_,15 @@ } boolean isBeingStaredBy(Player player) { @@ -44,10 +44,10 @@ + + boolean isBeingStaredBy0(Player player) { + // Paper end - EndermanAttackPlayerEvent - return LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM.test(player) && this.isLookingAtMe(player, 0.025, true, false, new double[]{this.getEyeY()}); + return LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM.test(player) && this.isLookingAtMe(player, 0.025, true, false, this.getEyeY()); } -@@ -248,7 +_,7 @@ +@@ -246,7 +_,7 @@ float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue(); if (lightLevelDependentMagicValue > 0.5F && level.canSeeSky(this.blockPosition()) @@ -56,7 +56,7 @@ this.setTarget(null); this.teleport(); } -@@ -361,21 +_,25 @@ +@@ -358,21 +_,25 @@ AbstractThrownPotion abstractThrownPotion1 = damageSource.getDirectEntity() instanceof AbstractThrownPotion abstractThrownPotion ? abstractThrownPotion : null; @@ -83,7 +83,7 @@ return flag; } -@@ -400,6 +_,16 @@ +@@ -397,6 +_,16 @@ this.entityData.set(DATA_STARED_AT, true); } @@ -100,7 +100,7 @@ @Override public boolean requiresCustomPersistence() { return super.requiresCustomPersistence() || this.getCarriedBlock() != null; -@@ -459,16 +_,19 @@ +@@ -455,16 +_,19 @@ int floor1 = Mth.floor(this.enderman.getY() + random.nextDouble() * 2.0); int floor2 = Mth.floor(this.enderman.getZ() - 1.0 + random.nextDouble() * 2.0); BlockPos blockPos = new BlockPos(floor, floor1, floor2); @@ -121,7 +121,7 @@ } } } -@@ -566,7 +_,7 @@ +@@ -561,7 +_,7 @@ } else { if (this.target != null && !this.enderman.isPassenger()) { if (this.enderman.isBeingStaredBy((Player)this.target)) { @@ -130,7 +130,7 @@ this.enderman.teleport(); } -@@ -605,15 +_,18 @@ +@@ -600,15 +_,18 @@ int floor1 = Mth.floor(this.enderman.getY() + random.nextDouble() * 3.0); int floor2 = Mth.floor(this.enderman.getZ() - 2.0 + random.nextDouble() * 4.0); BlockPos blockPos = new BlockPos(floor, floor1, floor2); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Evoker.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Evoker.java.patch index ebbd045b2016..9632f43aca78 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Evoker.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Evoker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Evoker.java +++ b/net/minecraft/world/entity/monster/Evoker.java -@@ -247,7 +_,7 @@ +@@ -245,7 +_,7 @@ serverLevel.getScoreboard().addPlayerToTeam(vex.getScoreboardName(), team); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Guardian.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Guardian.java.patch index b7602f075136..e15e6f685444 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Guardian.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Guardian.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/monster/Guardian.java +++ b/net/minecraft/world/entity/monster/Guardian.java -@@ -60,6 +_,7 @@ +@@ -58,6 +_,7 @@ + private int clientSideAttackTime; private boolean clientSideTouchedGround; - @Nullable - public RandomStrollGoal randomStrollGoal; + public @Nullable RandomStrollGoal randomStrollGoal; + public Guardian.GuardianAttackGoal guardianAttackGoal; // CraftBukkit - add field public Guardian(EntityType type, Level level) { super(type, level); -@@ -74,7 +_,7 @@ +@@ -72,7 +_,7 @@ protected void registerGoals() { MoveTowardsRestrictionGoal moveTowardsRestrictionGoal = new MoveTowardsRestrictionGoal(this, 1.0); this.randomStrollGoal = new RandomStrollGoal(this, 1.0, 80); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch index fdf5692e3319..14b5a8c69208 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Husk.java +++ b/net/minecraft/world/entity/monster/Husk.java -@@ -57,7 +_,7 @@ +@@ -58,7 +_,7 @@ boolean flag = super.doHurtTarget(level, target); if (flag && this.getMainHandItem().isEmpty() && target instanceof LivingEntity) { float effectiveDifficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Illusioner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Illusioner.java.patch index 59562e47c2b6..9108cd36f8fa 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Illusioner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Illusioner.java.patch @@ -50,4 +50,4 @@ + Illusioner.this.addEffect(new MobEffectInstance(MobEffects.INVISIBILITY, 1200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ILLUSION); // CraftBukkit } - @Nullable + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch index 2c3ddeef49ae..65f2c4e2f0cf 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch @@ -1,18 +1,17 @@ --- a/net/minecraft/world/entity/monster/Phantom.java +++ b/net/minecraft/world/entity/monster/Phantom.java -@@ -50,6 +_,11 @@ - @Nullable - public BlockPos anchorPoint; +@@ -49,6 +_,10 @@ + Vec3 moveTargetPoint = Vec3.ZERO; + @Nullable public BlockPos anchorPoint; Phantom.AttackPhase attackPhase = Phantom.AttackPhase.CIRCLE; + // Paper start -+ @Nullable -+ public java.util.UUID spawningEntity; ++ public java.util.@Nullable UUID spawningEntity; + public boolean shouldBurnInDay = true; + // Paper end public Phantom(EntityType type, Level level) { super(type, level); -@@ -137,6 +_,13 @@ +@@ -136,6 +_,13 @@ } } @@ -26,7 +25,7 @@ @Override protected void checkFallDamage(double y, boolean onGround, BlockState state, BlockPos pos) { } -@@ -165,6 +_,10 @@ +@@ -164,6 +_,10 @@ super.readAdditionalSaveData(input); this.anchorPoint = input.read("anchor_pos", BlockPos.CODEC).orElse(null); this.setPhantomSize(input.getIntOr("size", 0)); @@ -37,7 +36,7 @@ } @Override -@@ -172,6 +_,10 @@ +@@ -171,6 +_,10 @@ super.addAdditionalSaveData(output); output.storeNullable("anchor_pos", BlockPos.CODEC, this.anchorPoint); output.putInt("size", this.getPhantomSize()); @@ -48,7 +47,7 @@ } @Override -@@ -245,8 +_,10 @@ +@@ -244,8 +_,10 @@ for (Player player : nearbyPlayers) { if (Phantom.this.canAttack(serverLevel, player, TargetingConditions.DEFAULT)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Pillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Pillager.java.patch index 1df33fe9b19d..baac9f090b12 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Pillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Pillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Pillager.java +++ b/net/minecraft/world/entity/monster/Pillager.java -@@ -215,7 +_,7 @@ +@@ -214,7 +_,7 @@ this.onItemPickup(entity); ItemStack itemStack = this.inventory.addItem(item); if (itemStack.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch index 071ea14cdf53..752755c85ffa 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Ravager.java +++ b/net/minecraft/world/entity/monster/Ravager.java -@@ -156,12 +_,19 @@ +@@ -154,12 +_,19 @@ BlockState blockState = serverLevel.getBlockState(blockPos); Block block = blockState.getBlock(); if (block instanceof LeavesBlock) { @@ -20,7 +20,7 @@ } } -@@ -253,7 +_,7 @@ +@@ -249,7 +_,7 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double max = Math.max(d * d + d1 * d1, 0.001); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Shulker.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Shulker.java.patch index 437dc3fa63e9..a709e8da5f32 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Shulker.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Shulker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Shulker.java +++ b/net/minecraft/world/entity/monster/Shulker.java -@@ -277,8 +_,10 @@ +@@ -276,8 +_,10 @@ } @Override @@ -13,7 +13,7 @@ if (this.level().isClientSide()) { this.clientOldAttachPosition = this.blockPosition(); } -@@ -391,6 +_,14 @@ +@@ -388,6 +_,14 @@ && this.level().getWorldBorder().isWithinBounds(blockPos1) && this.level().noCollision(this, new AABB(blockPos1).deflate(1.0E-6))) { Direction direction = this.findAttachableSurface(blockPos1); @@ -28,7 +28,7 @@ if (direction != null) { this.unRide(); this.setAttachFace(direction); -@@ -455,7 +_,12 @@ +@@ -452,7 +_,12 @@ if (shulker != null) { shulker.setVariant(this.getVariant()); shulker.snapTo(vec3); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch index d3a8325d0377..69d673e3b825 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Silverfish.java +++ b/net/minecraft/world/entity/monster/Silverfish.java -@@ -119,7 +_,7 @@ +@@ -118,7 +_,7 @@ return true; } else { Player nearestPlayer = level.getNearestPlayer(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 5.0, true); @@ -9,7 +9,7 @@ } } -@@ -170,9 +_,14 @@ +@@ -168,9 +_,14 @@ BlockPos blockPos = BlockPos.containing(this.mob.getX(), this.mob.getY() + 0.5, this.mob.getZ()).relative(this.selectedDirection); BlockState blockState = levelAccessor.getBlockState(blockPos); if (InfestedBlock.isCompatibleHostBlock(blockState)) { @@ -25,16 +25,16 @@ } } } -@@ -212,6 +_,12 @@ +@@ -210,6 +_,12 @@ BlockState blockState = level.getBlockState(blockPos1); Block block = blockState.getBlock(); if (block instanceof InfestedBlock) { + // CraftBukkit start -+ BlockState afterState = getServerLevel(level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? blockState.getFluidState().createLegacyBlock() : ((InfestedBlock) block).hostStateByInfested(level.getBlockState(blockPos1)); // Paper - fix wrong block state ++ BlockState afterState = getServerLevel(level).getGameRules().get(GameRules.MOB_GRIEFING) ? blockState.getFluidState().createLegacyBlock() : ((InfestedBlock) block).hostStateByInfested(level.getBlockState(blockPos1)); // Paper - fix wrong block state + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockPos1, afterState)) { // Paper - fix wrong block state + continue; + } + // CraftBukkit end - if (getServerLevel(level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (getServerLevel(level).getGameRules().get(GameRules.MOB_GRIEFING)) { level.destroyBlock(blockPos1, true, this.silverfish); } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch index 79605ed9a1e1..1b6e77d4bcd8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch @@ -29,7 +29,7 @@ @Override - public void remove(Entity.RemovalReason reason) { -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { // CraftBukkit - add Bukkit remove cause ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause eventCause) { // CraftBukkit - add Bukkit remove cause int size = this.getSize(); if (!this.level().isClientSide() && size > 1 && this.isDeadOrDying()) { float width = this.getDimensions(this.getPose()).width(); @@ -108,7 +108,7 @@ return checkMobSpawnRules(entityType, level, spawnReason, pos, random); } } -@@ -350,6 +_,16 @@ +@@ -349,6 +_,16 @@ return super.getDefaultDimensions(pose).scale(this.getSize()); } @@ -125,7 +125,7 @@ static class SlimeAttackGoal extends Goal { private final Slime slime; private int growTiredTimer; -@@ -362,7 +_,16 @@ +@@ -361,7 +_,16 @@ @Override public boolean canUse() { LivingEntity target = this.slime.getTarget(); @@ -143,7 +143,7 @@ } @Override -@@ -374,7 +_,16 @@ +@@ -373,7 +_,16 @@ @Override public boolean canContinueToUse() { LivingEntity target = this.slime.getTarget(); @@ -161,7 +161,7 @@ } @Override -@@ -393,6 +_,13 @@ +@@ -392,6 +_,13 @@ slimeMoveControl.setDirection(this.slime.getYRot(), this.slime.isDealsDamage()); } } @@ -175,7 +175,7 @@ } static class SlimeFloatGoal extends Goal { -@@ -406,7 +_,7 @@ +@@ -405,7 +_,7 @@ @Override public boolean canUse() { @@ -184,7 +184,7 @@ } @Override -@@ -436,7 +_,7 @@ +@@ -435,7 +_,7 @@ @Override public boolean canUse() { @@ -193,7 +193,7 @@ } @Override -@@ -514,7 +_,7 @@ +@@ -513,7 +_,7 @@ @Override public boolean canUse() { @@ -202,7 +202,7 @@ && (this.slime.onGround() || this.slime.isInWater() || this.slime.isInLava() || this.slime.hasEffect(MobEffects.LEVITATION)) && this.slime.getMoveControl() instanceof Slime.SlimeMoveControl; } -@@ -524,6 +_,11 @@ +@@ -523,6 +_,11 @@ if (--this.nextRandomizeTime <= 0) { this.nextRandomizeTime = this.adjustedTickDelay(40 + this.slime.getRandom().nextInt(60)); this.chosenDegrees = this.slime.getRandom().nextInt(360); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch index d2183db1be92..fd73c021d9ec 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch @@ -18,7 +18,7 @@ } public boolean isClimbing() { -@@ -165,7 +_,7 @@ +@@ -164,7 +_,7 @@ if (spawnGroupData instanceof Spider.SpiderEffectsGroupData spiderEffectsGroupData) { Holder holder = spiderEffectsGroupData.effect; if (holder != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch index 146c0cc62788..c2026f351255 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Strider.java +++ b/net/minecraft/world/entity/monster/Strider.java -@@ -295,7 +_,14 @@ +@@ -293,7 +_,14 @@ || blockStateOnLegacy.is(BlockTags.STRIDER_WARM_BLOCKS) || this.getFluidHeight(FluidTags.LAVA) > 0.0; boolean flag1 = this.getVehicle() instanceof Strider strider && strider.isSuffocating(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vex.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Vex.java.patch index 0b1c9a9bdd8e..2c78ad8e6565 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vex.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Vex.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Vex.java +++ b/net/minecraft/world/entity/monster/Vex.java -@@ -293,7 +_,7 @@ +@@ -288,7 +_,7 @@ @Override public void start() { Mob owner = Vex.this.getOwner(); @@ -9,7 +9,7 @@ super.start(); } } -@@ -352,7 +_,10 @@ +@@ -347,7 +_,10 @@ for (int i = 0; i < 3; i++) { BlockPos blockPos = boundOrigin.offset(Vex.this.random.nextInt(15) - 7, Vex.this.random.nextInt(11) - 5, Vex.this.random.nextInt(15) - 7); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vindicator.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Vindicator.java.patch index 3d00b8fa853d..5aa541a68ac5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vindicator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Vindicator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Vindicator.java +++ b/net/minecraft/world/entity/monster/Vindicator.java -@@ -183,7 +_,7 @@ +@@ -182,7 +_,7 @@ static class VindicatorBreakDoorGoal extends BreakDoorGoal { public VindicatorBreakDoorGoal(Mob mob) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/WitherSkeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/WitherSkeleton.java.patch index b9f37bbe1c2f..0dcfd955d3ea 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/WitherSkeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/WitherSkeleton.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/WitherSkeleton.java +++ b/net/minecraft/world/entity/monster/WitherSkeleton.java -@@ -96,7 +_,7 @@ +@@ -95,7 +_,7 @@ return false; } else { if (target instanceof LivingEntity) { @@ -9,7 +9,7 @@ } return true; -@@ -112,6 +_,6 @@ +@@ -111,6 +_,6 @@ @Override public boolean canBeAffected(MobEffectInstance effectInstance) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch index 63939b3ebef4..6f4c34a8fb21 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch @@ -207,7 +207,7 @@ return flag; } -@@ -445,7 +_,7 @@ +@@ -444,7 +_,7 @@ spawnGroupData = super.finalizeSpawn(level, difficulty, spawnReason, spawnGroupData); float specialMultiplier = difficulty.getSpecialMultiplier(); if (spawnReason != EntitySpawnReason.CONVERSION) { @@ -216,7 +216,7 @@ } if (spawnGroupData == null) { -@@ -472,7 +_,7 @@ +@@ -471,7 +_,7 @@ chicken1.finalizeSpawn(level, difficulty, EntitySpawnReason.JOCKEY, null); chicken1.setChickenJockey(true); this.startRiding(chicken1, false, false); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch index e1e2648a7f26..948098620892 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/net/minecraft/world/entity/monster/ZombieVillager.java -@@ -170,12 +_,20 @@ +@@ -167,12 +_,20 @@ } public void startConverting(@Nullable UUID conversionStarter, int villagerConversionTime) { @@ -24,7 +24,7 @@ } @Override -@@ -200,7 +_,7 @@ +@@ -197,7 +_,7 @@ } private void finishConversion(ServerLevel level) { @@ -33,7 +33,7 @@ EntityType.VILLAGER, ConversionParams.single(this, false, false), mob -> { -@@ -224,19 +_,24 @@ +@@ -223,19 +_,24 @@ mob.finalizeSpawn(level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CONVERSION, null); mob.refreshBrain(level); if (this.conversionStarter != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch index 3ffae817d785..2b43c1a453ec 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/ZombifiedPiglin.java +++ b/net/minecraft/world/entity/monster/ZombifiedPiglin.java -@@ -58,6 +_,7 @@ +@@ -57,6 +_,7 @@ private static final int ALERT_RANGE_Y = 10; private static final UniformInt ALERT_INTERVAL = TimeUtil.rangeOfSeconds(4, 6); private int ticksUntilNextAlert; @@ -8,7 +8,7 @@ public ZombifiedPiglin(EntityType type, Level level) { super(type, level); -@@ -69,7 +_,7 @@ +@@ -68,7 +_,7 @@ this.goalSelector.addGoal(1, new SpearUseGoal<>(this, 1.0, 1.0, 10.0F, 2.0F)); this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0, false)); this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0)); @@ -17,7 +17,7 @@ this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt)); this.targetSelector.addGoal(3, new ResetUniversalAngerTargetGoal<>(this, true)); } -@@ -142,7 +_,7 @@ +@@ -141,7 +_,7 @@ .filter(zombifiedPiglin -> zombifiedPiglin != this) .filter(zombifiedPiglin -> zombifiedPiglin.getTarget() == null) .filter(zombifiedPiglin -> !zombifiedPiglin.isAlliedTo(this.getTarget())) @@ -26,12 +26,12 @@ } private void playAngerSound() { -@@ -150,18 +_,27 @@ +@@ -149,18 +_,27 @@ } @Override - public void setTarget(@Nullable LivingEntity target) { -+ public boolean setTarget(@Nullable LivingEntity target, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { // CraftBukkit - signature ++ public boolean setTarget(@Nullable LivingEntity target, org.bukkit.event.entity.EntityTargetEvent.@Nullable TargetReason reason) { // CraftBukkit - signature if (this.getTarget() == null && target != null) { this.playFirstAngerSoundIn = FIRST_ANGER_SOUND_DELAY.sample(this.random); this.ticksUntilNextAlert = ALERT_INTERVAL.sample(this.random); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch index 530599b19567..cebc12470b3a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch @@ -21,7 +21,7 @@ } public void creakingDeathEffects(DamageSource damageSource) { -@@ -449,9 +_,9 @@ +@@ -447,9 +_,9 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch index 527914ad088b..3d2981564dac 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -267,7 +_,12 @@ +@@ -266,7 +_,12 @@ } private void finishConversion() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch index 93e2f77079ee..c79bd690da28 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch @@ -35,7 +35,7 @@ } @VisibleForDebug -@@ -310,7 +_,9 @@ +@@ -309,7 +_,9 @@ @Override protected void finishConversion(ServerLevel level) { PiglinAi.cancelAdmiring(level, this); @@ -45,7 +45,7 @@ super.finishConversion(level); } -@@ -388,7 +_,7 @@ +@@ -386,7 +_,7 @@ } protected void holdInOffHand(ItemStack stack) { @@ -54,7 +54,7 @@ this.setItemSlot(EquipmentSlot.OFFHAND, stack); this.setGuaranteedDrop(EquipmentSlot.OFFHAND); } else { -@@ -413,15 +_,15 @@ +@@ -411,15 +_,15 @@ return false; } else { TagKey preferredWeaponType = this.getPreferredWeaponType(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch index eb8eb63220ab..72683033ecfc 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch @@ -127,7 +127,7 @@ + if (!player.level().paperConfig().entities.behavior.piglinsGuardChests) return; // Paper - Config option for Piglins guarding chests List entitiesOfClass = player.level().getEntitiesOfClass(Piglin.class, player.getBoundingBox().inflate(16.0)); entitiesOfClass.stream().filter(PiglinAi::isIdle).filter(piglin -> !requireLineOfSight || BehaviorUtils.canSee(piglin, player)).forEach(piglin -> { - if (level.getGameRules().getBoolean(GameRules.RULE_UNIVERSAL_ANGER)) { + if (level.getGameRules().get(GameRules.UNIVERSAL_ANGER)) { @@ -548,7 +_,7 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch index 14e482b4939e..0cc4dc341d9a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/warden/Warden.java +++ b/net/minecraft/world/entity/monster/warden/Warden.java -@@ -396,7 +_,7 @@ +@@ -395,7 +_,7 @@ public static void applyDarknessAround(ServerLevel level, Vec3 pos, @Nullable Entity source, int radius) { MobEffectInstance mobEffectInstance = new MobEffectInstance(MobEffects.DARKNESS, 260, 0, false, false); @@ -9,7 +9,7 @@ } @Override -@@ -440,6 +_,15 @@ +@@ -439,6 +_,15 @@ @VisibleForTesting public void increaseAngerAt(@Nullable Entity entity, int offset, boolean playListeningSound) { if (!this.isNoAi() && this.canTargetEntity(entity)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch index f201ac3c58ee..56eb11e321c0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/npc/AbstractVillager.java +++ b/net/minecraft/world/entity/npc/AbstractVillager.java -@@ -43,7 +_,7 @@ - private Player tradingPlayer; - @Nullable - protected MerchantOffers offers; +@@ -41,7 +_,7 @@ + private static final int VILLAGER_INVENTORY_SIZE = 8; + private @Nullable Player tradingPlayer; + protected @Nullable MerchantOffers offers; - private final SimpleContainer inventory = new SimpleContainer(8); + private final SimpleContainer inventory = new SimpleContainer(8, (org.bukkit.craftbukkit.entity.CraftAbstractVillager) this.getBukkitEntity()); // CraftBukkit - add argument public AbstractVillager(EntityType type, Level level) { super(type, level); -@@ -96,6 +_,20 @@ +@@ -93,6 +_,20 @@ return this.tradingPlayer != null; } @@ -30,13 +30,13 @@ @Override public MerchantOffers getOffers() { if (this.level() instanceof ServerLevel serverLevel) { -@@ -118,11 +_,24 @@ +@@ -115,11 +_,24 @@ public void overrideXp(int xp) { } + // Paper start - Add PlayerTradeEvent and PlayerPurchaseEvent + @Override -+ public void processTrade(MerchantOffer offer, @Nullable io.papermc.paper.event.player.PlayerPurchaseEvent event) { // The MerchantRecipe passed in here is the one set by the PlayerPurchaseEvent ++ public void processTrade(MerchantOffer offer, io.papermc.paper.event.player.@Nullable PlayerPurchaseEvent event) { // The MerchantRecipe passed in here is the one set by the PlayerPurchaseEvent + if (event == null || event.willIncreaseTradeUses()) { + offer.increaseUses(); + } @@ -57,7 +57,7 @@ if (this.tradingPlayer instanceof ServerPlayer) { CriteriaTriggers.TRADE.trigger((ServerPlayer)this.tradingPlayer, this, offer.getResult()); } -@@ -227,7 +_,20 @@ +@@ -223,7 +_,20 @@ while (i < maxNumbers && !list.isEmpty()) { MerchantOffer offer = list.remove(this.random.nextInt(list.size())).getOffer(level, this, this.random); if (offer != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch index ddf2db4bd4f0..4040534803d8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/Villager.java +++ b/net/minecraft/world/entity/npc/Villager.java -@@ -287,7 +_,7 @@ +@@ -286,7 +_,7 @@ this.increaseProfessionLevelOnUpdate = false; } @@ -9,7 +9,7 @@ } } -@@ -396,7 +_,12 @@ +@@ -395,7 +_,12 @@ this.updateDemand(); for (MerchantOffer merchantOffer : this.getOffers()) { @@ -23,7 +23,7 @@ } this.resendOffersToTradingPlayer(); -@@ -452,7 +_,12 @@ +@@ -451,7 +_,12 @@ int i = 2 - this.numberOfRestocksToday; if (i > 0) { for (MerchantOffer merchantOffer : this.getOffers()) { @@ -37,7 +37,7 @@ } } -@@ -473,6 +_,7 @@ +@@ -472,6 +_,7 @@ int playerReputation = this.getPlayerReputation(player); if (playerReputation != 0) { for (MerchantOffer merchantOffer : this.getOffers()) { @@ -45,7 +45,7 @@ merchantOffer.addToSpecialPriceDiff(-Mth.floor(playerReputation * merchantOffer.getPriceMultiplier())); } } -@@ -482,6 +_,7 @@ +@@ -481,6 +_,7 @@ int amplifier = effect.getAmplifier(); for (MerchantOffer merchantOffer1 : this.getOffers()) { @@ -53,7 +53,7 @@ double d = 0.3 + 0.0625 * amplifier; int i = (int)Math.floor(d * merchantOffer1.getBaseCostA().getCount()); merchantOffer1.addToSpecialPriceDiff(-Math.max(i, 1)); -@@ -590,7 +_,7 @@ +@@ -588,7 +_,7 @@ } if (offer.shouldRewardExp()) { @@ -62,7 +62,7 @@ } } -@@ -608,7 +_,7 @@ +@@ -606,7 +_,7 @@ @Override public void die(DamageSource damageSource) { @@ -71,7 +71,7 @@ Entity entity = damageSource.getEntity(); if (entity != null) { this.tellWitnessesThatIWasMurdered(entity); -@@ -707,7 +_,7 @@ +@@ -705,7 +_,7 @@ return VillagerData.canLevelUp(level) && this.villagerXp >= VillagerData.getMaxXpPerLevel(level); } @@ -80,7 +80,7 @@ this.setVillagerData(this.getVillagerData().withLevel(this.getVillagerData().level() + 1)); this.updateTrades(serverLevel); } -@@ -776,12 +_,19 @@ +@@ -772,12 +_,19 @@ @Override public void thunderHit(ServerLevel level, LightningBolt lightning) { if (level.getDifficulty() != Difficulty.PEACEFUL) { @@ -102,7 +102,7 @@ if (witch == null) { super.thunderHit(level, lightning); } -@@ -821,6 +_,12 @@ +@@ -817,6 +_,12 @@ @Override protected void updateTrades(ServerLevel level) { @@ -115,7 +115,7 @@ VillagerData villagerData = this.getVillagerData(); ResourceKey resourceKey = villagerData.profession().unwrapKey().orElse(null); if (resourceKey != null) { -@@ -836,13 +_,15 @@ +@@ -832,13 +_,15 @@ VillagerTrades.ItemListing[] itemListings = map1.get(villagerData.level()); if (itemListings != null) { MerchantOffers offers = this.getOffers(); @@ -133,7 +133,7 @@ } public void gossip(ServerLevel level, Villager target, long gameTime) { -@@ -871,7 +_,7 @@ +@@ -867,7 +_,7 @@ List entitiesOfClass = level.getEntitiesOfClass(Villager.class, aabb); List list = entitiesOfClass.stream().filter(villager -> villager.wantsToSpawnGolem(gameTime)).limit(5L).toList(); if (list.size() >= minVillagerAmount) { @@ -142,7 +142,7 @@ EntityType.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, level, -@@ -880,9 +_,11 @@ +@@ -876,9 +_,11 @@ 8, 6, SpawnUtil.Strategy.LEGACY_IRON_GOLEM, diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch index 96af2b92ea84..90dc6c5da082 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/npc/VillagerTrades.java +++ b/net/minecraft/world/entity/npc/VillagerTrades.java -@@ -1742,7 +_,8 @@ - @Nullable +@@ -1737,7 +_,8 @@ + @Override - public MerchantOffer getOffer(ServerLevel level, Entity trader, RandomSource random) { + public @Nullable MerchantOffer getOffer(ServerLevel level, Entity trader, RandomSource random) { - BlockPos blockPos = level.findNearestMapStructure(this.destination, trader.blockPosition(), 100, true); + if (!level.paperConfig().environment.treasureMaps.enabled) return null; // Paper - Configurable cartographer treasure maps + BlockPos blockPos = level.findNearestMapStructure(this.destination, trader.blockPosition(), 100, !level.paperConfig().environment.treasureMaps.findAlreadyDiscoveredVillager); // Paper - Configurable cartographer treasure maps diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch index 5bdfd4e0a61c..97413a49a27b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/npc/WanderingTrader.java +++ b/net/minecraft/world/entity/npc/WanderingTrader.java -@@ -51,6 +_,10 @@ - @Nullable - private BlockPos wanderTarget; +@@ -50,6 +_,10 @@ + private static final int DEFAULT_DESPAWN_DELAY = 0; + private @Nullable BlockPos wanderTarget; private int despawnDelay = 0; + // Paper start - Add more WanderingTrader API + public boolean canDrinkPotion = true; @@ -11,7 +11,7 @@ public WanderingTrader(EntityType type, Level level) { super(type, level); -@@ -66,7 +_,7 @@ +@@ -65,7 +_,7 @@ this, PotionContents.createItemStack(Items.POTION, Potions.INVISIBILITY), SoundEvents.WANDERING_TRADER_DISAPPEARED, @@ -20,7 +20,7 @@ ) ); this.goalSelector -@@ -76,7 +_,7 @@ +@@ -75,7 +_,7 @@ this, new ItemStack(Items.MILK_BUCKET), SoundEvents.WANDERING_TRADER_REAPPEARED, @@ -29,7 +29,7 @@ ) ); this.goalSelector.addGoal(1, new TradeWithPlayerGoal(this)); -@@ -164,7 +_,7 @@ +@@ -162,7 +_,7 @@ protected void rewardTradeXp(MerchantOffer offer) { if (offer.shouldRewardExp()) { int i = 3 + this.random.nextInt(4); @@ -38,7 +38,7 @@ } } -@@ -216,7 +_,7 @@ +@@ -214,7 +_,7 @@ private void maybeDespawn() { if (this.despawnDelay > 0 && !this.isTrading() && --this.despawnDelay == 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch index 346f7737d69c..9e346da1df25 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch @@ -34,7 +34,7 @@ + this.spawnDelay = level.paperConfig().entities.spawning.wanderingTrader.spawnDayLength; + this.spawnChance = level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin; + } - if (level.getGameRules().getBoolean(GameRules.RULE_DO_TRADER_SPAWNING)) { + if (level.getGameRules().get(GameRules.SPAWN_WANDERING_TRADERS)) { - if (--this.tickDelay <= 0) { - this.tickDelay = 1200; - this.spawnDelay -= 1200; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index 5c7d2845116a..213895cd1050 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -151,7 +_,7 @@ +@@ -150,7 +_,7 @@ private static final boolean DEFAULT_IGNORE_FALL_DAMAGE_FROM_CURRENT_IMPULSE = false; private static final int DEFAULT_CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME = 0; final Inventory inventory; @@ -9,8 +9,8 @@ public final InventoryMenu inventoryMenu; public AbstractContainerMenu containerMenu; protected FoodData foodData = new FoodData(); -@@ -182,6 +_,18 @@ - public Entity currentExplosionCause; +@@ -178,6 +_,18 @@ + public @Nullable Entity currentExplosionCause; private boolean ignoreFallDamageFromCurrentImpulse = false; private int currentImpulseContextResetGraceTime = 0; + public boolean affectsSpawning = true; // Paper - Affects Spawning API @@ -28,7 +28,7 @@ public Player(Level level, GameProfile gameProfile) { super(EntityType.PLAYER, level); -@@ -249,6 +_,13 @@ +@@ -245,6 +_,13 @@ if (this.isSleeping()) { this.sleepCounter++; @@ -42,7 +42,7 @@ if (this.sleepCounter > 100) { this.sleepCounter = 100; } -@@ -332,7 +_,7 @@ +@@ -328,7 +_,7 @@ } private void turtleHelmetTick() { @@ -51,7 +51,7 @@ } private boolean isEquipped(Item item) { -@@ -436,6 +_,18 @@ +@@ -432,6 +_,18 @@ } } @@ -70,7 +70,7 @@ public void closeContainer() { this.containerMenu = this.inventoryMenu; } -@@ -447,8 +_,14 @@ +@@ -443,8 +_,14 @@ public void rideTick() { if (!this.level().isClientSide() && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -87,7 +87,7 @@ super.rideTick(); } } -@@ -709,10 +_,10 @@ +@@ -703,10 +_,10 @@ if (this.isDeadOrDying()) { return false; } else { @@ -100,7 +100,7 @@ } if (level.getDifficulty() == Difficulty.EASY) { -@@ -724,7 +_,14 @@ +@@ -718,7 +_,14 @@ } } @@ -116,7 +116,7 @@ } } } -@@ -736,7 +_,7 @@ +@@ -730,7 +_,7 @@ BlocksAttacks blocksAttacks = itemBlockingWith != null ? itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS) : null; float secondsToDisableBlocking = entity.getSecondsToDisableBlocking(); if (secondsToDisableBlocking > 0.0F && blocksAttacks != null) { @@ -125,7 +125,7 @@ } } -@@ -746,9 +_,29 @@ +@@ -740,9 +_,29 @@ } public boolean canHarmPlayer(Player other) { @@ -158,7 +158,7 @@ } @Override -@@ -762,7 +_,12 @@ +@@ -756,7 +_,12 @@ } @Override @@ -172,7 +172,7 @@ if (!this.isInvulnerableTo(level, damageSource)) { amount = this.getDamageAfterArmorAbsorb(damageSource, amount); amount = this.getDamageAfterMagicAbsorb(damageSource, amount); -@@ -774,7 +_,7 @@ +@@ -768,7 +_,7 @@ } if (var8 != 0.0F) { @@ -181,7 +181,7 @@ this.getCombatTracker().recordDamage(damageSource, var8); this.setHealth(this.getHealth() - var8); if (var8 < 3.4028235E37F) { -@@ -784,6 +_,7 @@ +@@ -778,6 +_,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -189,7 +189,7 @@ } public boolean isTextFilteringEnabled() { -@@ -867,14 +_,16 @@ +@@ -861,14 +_,16 @@ } @Override @@ -209,7 +209,7 @@ } @Override -@@ -953,16 +_,26 @@ +@@ -947,16 +_,26 @@ } public void attack(Entity target) { @@ -239,7 +239,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = attackStrengthScale > 0.9F; boolean flag1; -@@ -975,7 +_,9 @@ +@@ -969,7 +_,9 @@ f += weaponItem.getItem().getAttackDamageBonus(target, f, damageSource); boolean flag2 = flag && this.canCriticalAttack(target); @@ -249,7 +249,7 @@ f *= 1.5F; } -@@ -1017,11 +_,12 @@ +@@ -1011,11 +_,12 @@ return !target.isAttackable() || target.skipAttackInteraction(this); } @@ -264,7 +264,7 @@ return true; } else { return false; -@@ -1114,21 +_,43 @@ +@@ -1108,21 +_,43 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F) { if (target instanceof LivingEntity livingEntity) { @@ -309,7 +309,7 @@ } } -@@ -1149,7 +_,10 @@ +@@ -1143,7 +_,10 @@ && !(livingEntity instanceof ArmorStand armorStand && armorStand.isMarker()) && this.distanceToSqr(livingEntity) < 9.0) { float f1 = this.getEnchantedDamage(livingEntity, var12, damageSource) * strengthScale; @@ -321,7 +321,7 @@ livingEntity.knockback(0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity, damageSource); } -@@ -1176,13 +_,22 @@ +@@ -1170,13 +_,22 @@ @Override public boolean stabAttack(EquipmentSlot slot, Entity target, float damageAmount, boolean damage, boolean knockback, boolean dismount) { @@ -346,7 +346,7 @@ return true; } else { float f1 = damage ? damageAmount + f : 0.0F; -@@ -1210,7 +_,7 @@ +@@ -1204,7 +_,7 @@ this.setLastHurtMob(target); this.itemAttackInteraction(target, itemBySlot, damageSource, flag); this.damageStatsAndHearts(target, f2); @@ -355,18 +355,18 @@ return true; } } -@@ -1221,8 +_,8 @@ +@@ -1215,8 +_,8 @@ } @Override - public void remove(Entity.RemovalReason reason) { - super.remove(reason); -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { // CraftBukkit - add Bukkit remove cause ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause eventCause) { // CraftBukkit - add Bukkit remove cause + super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause this.inventoryMenu.removed(this); if (this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1290,6 +_,12 @@ +@@ -1284,6 +_,12 @@ } public Either startSleepInBed(BlockPos bedPos) { @@ -379,7 +379,7 @@ this.startSleeping(bedPos); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1401,7 +_,7 @@ +@@ -1395,7 +_,7 @@ @Override public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) { @@ -388,7 +388,7 @@ return false; } else { if (fallDistance >= 2.0) { -@@ -1442,7 +_,15 @@ +@@ -1436,7 +_,15 @@ } public void startFallFlying() { @@ -405,7 +405,7 @@ } @Override -@@ -1540,7 +_,7 @@ +@@ -1534,7 +_,7 @@ if (levels > 0 && this.experienceLevel % 5 == 0 && this.lastLevelUpTime < this.tickCount - 100.0F) { float f = this.experienceLevel > 30 ? 1.0F : this.experienceLevel / 30.0F; @@ -414,7 +414,7 @@ this.lastLevelUpTime = this.tickCount; } } -@@ -1548,15 +_,35 @@ +@@ -1542,15 +_,35 @@ public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { return 112 + (this.experienceLevel - 30) * 9; @@ -452,7 +452,7 @@ } } } -@@ -1814,7 +_,7 @@ +@@ -1805,7 +_,7 @@ @Override public void onAttack() { @@ -461,7 +461,7 @@ super.onAttack(); } -@@ -1849,17 +_,32 @@ +@@ -1840,17 +_,32 @@ return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } @@ -496,7 +496,7 @@ for (int i = 0; i < this.inventory.getContainerSize(); i++) { ItemStack item = this.inventory.getItem(i); -@@ -1868,6 +_,7 @@ +@@ -1859,6 +_,7 @@ } } @@ -504,7 +504,7 @@ return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; } } -@@ -1954,12 +_,20 @@ +@@ -1945,12 +_,20 @@ } public boolean hasClientLoaded() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch index 8c4c1b262292..c18de65f21b3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/AbstractArrow.java +++ b/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -87,7 +_,14 @@ +@@ -83,7 +_,14 @@ protected AbstractArrow( EntityType type, double x, double y, double z, Level level, ItemStack pickupItemStack, @Nullable ItemStack firedFromWeapon ) { @@ -15,7 +15,7 @@ this.pickupItemStack = pickupItemStack.copy(); this.applyComponentsFromItemStack(pickupItemStack); Unit unit = pickupItemStack.remove(DataComponents.INTANGIBLE_PROJECTILE); -@@ -112,8 +_,8 @@ +@@ -108,8 +_,8 @@ protected AbstractArrow( EntityType type, LivingEntity owner, Level level, ItemStack pickupItemStack, @Nullable ItemStack firedFromWeapon ) { @@ -26,7 +26,7 @@ } public void setSoundEvent(SoundEvent soundEvent) { -@@ -208,6 +_,7 @@ +@@ -204,6 +_,7 @@ this.setSharedFlagOnFire(this.getRemainingFireTicks() > 0); } } else { @@ -34,7 +34,7 @@ this.inGroundTime = 0; Vec3 vec31 = this.position(); if (this.isInWater()) { -@@ -277,7 +_,7 @@ +@@ -273,7 +_,7 @@ if (list.isEmpty()) { if (this.isAlive() && hitResult.getType() != HitResult.Type.MISS) { @@ -43,7 +43,7 @@ this.hasImpulse = true; } break; -@@ -294,7 +_,7 @@ +@@ -290,7 +_,7 @@ private ProjectileDeflection hitTargetsOrDeflectSelf(Collection hitResults) { for (EntityHitResult entityHitResult : hitResults) { @@ -52,7 +52,7 @@ if (!this.isAlive() || projectileDeflection != ProjectileDeflection.NONE) { return projectileDeflection; } -@@ -326,13 +_,26 @@ +@@ -322,13 +_,26 @@ } } @@ -80,7 +80,7 @@ } private void startFalling() { -@@ -365,8 +_,8 @@ +@@ -361,8 +_,8 @@ protected void tickDespawn() { this.life++; @@ -91,7 +91,7 @@ } } -@@ -400,9 +_,9 @@ +@@ -396,9 +_,9 @@ } @Override @@ -103,7 +103,7 @@ } } -@@ -429,7 +_,7 @@ +@@ -425,7 +_,7 @@ } if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) { @@ -112,7 +112,7 @@ return; } -@@ -445,10 +_,16 @@ +@@ -441,10 +_,16 @@ livingEntity.setLastHurtMob(entity); } @@ -130,7 +130,7 @@ } if (entity.hurtOrSimulate(damageSource, ceil)) { -@@ -486,7 +_,7 @@ +@@ -482,7 +_,7 @@ this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); if (this.getPierceLevel() <= 0) { @@ -139,7 +139,7 @@ } } else { entity.setRemainingFireTicks(remainingFireTicks); -@@ -497,7 +_,7 @@ +@@ -493,7 +_,7 @@ this.spawnAtLocation(serverLevel2, this.getPickupItem(), 0.1F); } @@ -148,7 +148,7 @@ } } } -@@ -510,7 +_,7 @@ +@@ -506,7 +_,7 @@ double max = Math.max(0.0, 1.0 - entity.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); Vec3 vec3 = this.getDeltaMovement().multiply(1.0, 0.0, 1.0).normalize().scale(d * 0.6 * max); if (vec3.lengthSqr() > 0.0) { @@ -157,7 +157,7 @@ } } } -@@ -623,7 +_,14 @@ +@@ -617,7 +_,14 @@ @Override public void setOwner(@Nullable Entity entity) { @@ -172,7 +172,7 @@ this.pickup = switch (entity) { case Player player when this.pickup == AbstractArrow.Pickup.DISALLOWED -> AbstractArrow.Pickup.ALLOWED; -@@ -635,9 +_,22 @@ +@@ -629,9 +_,22 @@ @Override public void playerTouch(Player entity) { if (!this.level().isClientSide() && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch index e667ea089ee1..81c63120251b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EvokerFangs.java +++ b/net/minecraft/world/entity/projectile/EvokerFangs.java -@@ -98,7 +_,7 @@ +@@ -96,7 +_,7 @@ } if (--this.lifeTicks < 0) { @@ -9,7 +9,7 @@ } } } -@@ -107,7 +_,7 @@ +@@ -105,7 +_,7 @@ LivingEntity owner = this.getOwner(); if (target.isAlive() && !target.isInvulnerable() && target != owner) { if (owner == null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch index 69a8e815ddb3..060c0ec1b92e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EyeOfEnder.java +++ b/net/minecraft/world/entity/projectile/EyeOfEnder.java -@@ -73,6 +_,12 @@ +@@ -72,6 +_,12 @@ } public void signalTo(Vec3 pos) { @@ -13,7 +13,7 @@ Vec3 vec3 = pos.subtract(this.position()); double d = vec3.horizontalDistance(); if (d > 12.0) { -@@ -81,8 +_,10 @@ +@@ -80,8 +_,10 @@ this.target = pos; } @@ -24,7 +24,7 @@ } @Override -@@ -103,7 +_,7 @@ +@@ -102,7 +_,7 @@ this.life++; if (this.life > 80 && !this.level().isClientSide()) { this.playSound(SoundEvents.ENDER_EYE_DEATH, 1.0F, 1.0F); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch index 9a9d61c83368..655f97818f9d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -49,6 +_,7 @@ +@@ -48,6 +_,7 @@ + public int life = 0; public int lifetime = 0; - @Nullable - public LivingEntity attachedToEntity; -+ @Nullable public java.util.UUID spawningEntity; // Paper + public @Nullable LivingEntity attachedToEntity; ++ public java.util.@Nullable UUID spawningEntity; // Paper public FireworkRocketEntity(EntityType type, Level level) { super(type, level); -@@ -164,7 +_,7 @@ +@@ -163,7 +_,7 @@ } if (!this.noPhysics && this.isAlive() && hitResultOnMoveVector.getType() != HitResult.Type.MISS) { @@ -17,7 +17,7 @@ this.hasImpulse = true; } -@@ -188,7 +_,11 @@ +@@ -187,7 +_,11 @@ } if (this.life > this.lifetime && this.level() instanceof ServerLevel serverLevel) { @@ -30,7 +30,7 @@ } } -@@ -196,14 +_,18 @@ +@@ -195,14 +_,18 @@ level.broadcastEntityEvent(this, EntityEvent.FIREWORKS_EXPLODE); this.gameEvent(GameEvent.EXPLODE, this.getOwner()); this.dealExplosionDamage(level); @@ -51,7 +51,7 @@ } } -@@ -212,7 +_,11 @@ +@@ -211,7 +_,11 @@ BlockPos blockPos = new BlockPos(result.getBlockPos()); this.level().getBlockState(blockPos).entityInside(this.level(), blockPos, this, InsideBlockEffectApplier.NOOP, true); if (this.level() instanceof ServerLevel serverLevel && this.hasExplosion()) { @@ -64,7 +64,7 @@ } super.onHitBlock(result); -@@ -284,6 +_,7 @@ +@@ -283,6 +_,7 @@ output.putInt("LifeTime", this.lifetime); output.store("FireworksItem", ItemStack.CODEC, this.getItem()); output.putBoolean("ShotAtAngle", this.entityData.get(DATA_SHOT_AT_ANGLE)); @@ -72,7 +72,7 @@ } @Override -@@ -293,6 +_,7 @@ +@@ -292,6 +_,7 @@ this.lifetime = input.getIntOr("LifeTime", 0); this.entityData.set(DATA_ID_FIREWORKS_ITEM, input.read("FireworksItem", ItemStack.CODEC).orElse(getDefaultItem())); this.entityData.set(DATA_SHOT_AT_ANGLE, input.getBooleanOr("ShotAtAngle", false)); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch index 1e6738898fc7..ebdb125b7d61 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/FishingHook.java +++ b/net/minecraft/world/entity/projectile/FishingHook.java -@@ -71,10 +_,26 @@ +@@ -69,10 +_,26 @@ private final int lureSpeed; private final InterpolationHandler interpolationHandler = new InterpolationHandler(this); @@ -27,7 +27,7 @@ } public FishingHook(EntityType type, Level level) { -@@ -155,12 +_,12 @@ +@@ -152,12 +_,12 @@ super.tick(); Player playerOwner = this.getPlayerOwner(); if (playerOwner == null) { @@ -42,7 +42,7 @@ return; } } else { -@@ -178,12 +_,14 @@ +@@ -175,12 +_,14 @@ if (this.currentState == FishingHook.FishHookState.FLYING) { if (this.hookedIn != null) { this.setDeltaMovement(Vec3.ZERO); @@ -57,7 +57,7 @@ this.currentState = FishingHook.FishHookState.BOBBING; return; } -@@ -198,6 +_,7 @@ +@@ -195,6 +_,7 @@ this.setPos(this.hookedIn.getX(), this.hookedIn.getY(0.8), this.hookedIn.getZ()); } else { this.setHookedEntity(null); @@ -65,7 +65,7 @@ this.currentState = FishingHook.FishHookState.FLYING; } } -@@ -264,13 +_,13 @@ +@@ -261,13 +_,13 @@ } } @@ -81,7 +81,7 @@ } @Override -@@ -301,11 +_,11 @@ +@@ -298,11 +_,11 @@ ServerLevel serverLevel = (ServerLevel)this.level(); int i = 1; BlockPos blockPos = pos.above(); @@ -95,7 +95,7 @@ i--; } -@@ -315,6 +_,10 @@ +@@ -312,6 +_,10 @@ this.timeUntilLured = 0; this.timeUntilHooked = 0; this.getEntityData().set(DATA_BITING, false); @@ -106,7 +106,7 @@ } } else if (this.timeUntilHooked > 0) { this.timeUntilHooked -= i; -@@ -338,6 +_,12 @@ +@@ -335,6 +_,12 @@ serverLevel.sendParticles(ParticleTypes.FISHING, d, d1, d2, 0, -f2, 0.01, f1, 1.0); } } else { @@ -119,7 +119,7 @@ this.playSound(SoundEvents.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); double d3 = this.getY() + 0.5; serverLevel.sendParticles( -@@ -389,14 +_,31 @@ +@@ -386,14 +_,31 @@ } if (this.timeUntilLured <= 0) { @@ -155,7 +155,7 @@ public boolean calculateOpenWater(BlockPos pos) { FishingHook.OpenWaterType openWaterType = FishingHook.OpenWaterType.INVALID; -@@ -455,15 +_,31 @@ +@@ -452,15 +_,31 @@ protected void readAdditionalSaveData(ValueInput input) { } @@ -187,7 +187,7 @@ } else if (this.nibble > 0) { LootParams lootParams = new LootParams.Builder((ServerLevel)this.level()) .withParameter(LootContextParams.ORIGIN, this.position()) -@@ -477,18 +_,27 @@ +@@ -474,18 +_,27 @@ for (ItemStack itemStack : randomItems) { ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemStack); @@ -221,7 +221,7 @@ if (itemStack.is(ItemTags.FISHES)) { playerOwner.awardStat(Stats.FISH_CAUGHT, 1); } -@@ -498,10 +_,24 @@ +@@ -495,10 +_,24 @@ } if (this.onGround()) { @@ -247,19 +247,19 @@ return i; } else { return 0; -@@ -531,9 +_,9 @@ +@@ -528,9 +_,9 @@ } @Override - public void remove(Entity.RemovalReason reason) { -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { // CraftBukkit - add Bukkit remove cause this.updateOwnerInfo(null); - super.remove(reason); + super.remove(reason, cause); // CraftBukkit - add Bukkit remove cause } @Override -@@ -581,7 +_,7 @@ +@@ -576,7 +_,7 @@ if (this.getPlayerOwner() == null) { int data = packet.getData(); LOGGER.error("Failed to recreate fishing hook on client. {} (id: {}) is not a valid owner.", this.level().getEntity(data), data); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch index 18c1ce5d89af..2a386a6ddb5d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch @@ -1,25 +1,26 @@ --- a/net/minecraft/world/entity/projectile/LargeFireball.java +++ b/net/minecraft/world/entity/projectile/LargeFireball.java -@@ -20,11 +_,13 @@ +@@ -20,20 +_,27 @@ public LargeFireball(EntityType type, Level level) { super(type, level); -+ this.isIncendiary = (level instanceof ServerLevel serverLevel) && serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit ++ this.isIncendiary = (level instanceof ServerLevel serverLevel) && serverLevel.getGameRules().get(GameRules.MOB_GRIEFING); // CraftBukkit } public LargeFireball(Level level, LivingEntity owner, Vec3 movement, int explosionPower) { super(EntityType.FIREBALL, owner, movement, level); this.explosionPower = explosionPower; -+ this.isIncendiary = (level instanceof ServerLevel serverLevel) && serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit ++ this.isIncendiary = (level instanceof ServerLevel serverLevel) && serverLevel.getGameRules().get(GameRules.MOB_GRIEFING); // CraftBukkit } @Override -@@ -32,8 +_,13 @@ + protected void onHit(HitResult result) { super.onHit(result); if (this.level() instanceof ServerLevel serverLevel) { - boolean _boolean = serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); -- this.level().explode(this, this.getX(), this.getY(), this.getZ(), this.explosionPower, _boolean, Level.ExplosionInteraction.MOB); +- boolean flag = serverLevel.getGameRules().get(GameRules.MOB_GRIEFING); +- this.level().explode(this, this.getX(), this.getY(), this.getZ(), this.explosionPower, flag, Level.ExplosionInteraction.MOB); - this.discard(); ++ // boolean flag = serverLevel.getGameRules().get(GameRules.MOB_GRIEFING); // CraftBukkit - baked into fields (see constructor) + // CraftBukkit start - fire ExplosionPrimeEvent + org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); + if (event.callEvent()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch index 552cc853b5a7..4ccdf0bec601 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java -@@ -45,6 +_,7 @@ +@@ -43,6 +_,7 @@ + private boolean leftOwnerChecked; public boolean hasBeenShot = false; - @Nullable - private Entity lastDeflectedBy; + private @Nullable Entity lastDeflectedBy; + protected boolean hitCancelled = false; // CraftBukkit Projectile(EntityType type, Level level) { super(type, level); -@@ -52,12 +_,25 @@ +@@ -50,12 +_,25 @@ protected void setOwner(@Nullable EntityReference owner) { this.owner = owner; @@ -31,10 +31,10 @@ + } + // Paper end - Refresh ProjectileSource for projectiles + - @Nullable @Override - public Entity getOwner() { -@@ -85,6 +_,7 @@ + public @Nullable Entity getOwner() { + return EntityReference.getEntity(this.owner, this.level()); +@@ -82,6 +_,7 @@ @Override protected void readAdditionalSaveData(ValueInput input) { this.setOwner(EntityReference.read(input, "Owner")); @@ -42,7 +42,7 @@ this.leftOwner = input.getBooleanOr("LeftOwner", false); this.hasBeenShot = input.getBooleanOr("HasBeenShot", false); } -@@ -157,7 +_,14 @@ +@@ -154,7 +_,14 @@ float f2 = Mth.cos(y * (float) (Math.PI / 180.0)) * Mth.cos(x * (float) (Math.PI / 180.0)); this.shoot(f, f1, f2, velocity, inaccuracy); Vec3 knownMovement = shooter.getKnownMovement(); @@ -57,7 +57,7 @@ } @Override -@@ -177,7 +_,12 @@ +@@ -174,7 +_,12 @@ public static T spawnProjectileFromRotation( Projectile.ProjectileFactory factory, ServerLevel level, ItemStack spawnedFrom, LivingEntity owner, float z, float velocity, float inaccuracy ) { @@ -71,7 +71,7 @@ factory.create(level, owner, spawnedFrom), level, spawnedFrom, -@@ -202,7 +_,13 @@ +@@ -199,7 +_,13 @@ public static T spawnProjectileUsingShoot( T projectile, ServerLevel level, ItemStack spawnedFrom, double x, double y, double z, float velocity, float inaccuracy ) { @@ -86,7 +86,7 @@ } public static T spawnProjectile(T projectile, ServerLevel level, ItemStack spawnedFrom) { -@@ -210,11 +_,46 @@ +@@ -207,11 +_,46 @@ } public static T spawnProjectile(T projectile, ServerLevel level, ItemStack stack, Consumer adapter) { @@ -137,7 +137,7 @@ public void applyOnProjectileSpawned(ServerLevel level, ItemStack spawnedFrom) { EnchantmentHelper.onProjectileSpawned(level, spawnedFrom, this, item -> {}); -@@ -226,6 +_,17 @@ +@@ -223,6 +_,17 @@ } } @@ -155,7 +155,7 @@ protected ProjectileDeflection hitTargetOrDeflectSelf(HitResult hitResult) { if (hitResult.getType() == HitResult.Type.ENTITY) { EntityHitResult entityHitResult = (EntityHitResult)hitResult; -@@ -293,15 +_,35 @@ +@@ -290,15 +_,35 @@ } protected void onHitBlock(BlockHitResult result) { @@ -191,7 +191,7 @@ return owner == null || this.leftOwner || !owner.isPassengerOfSameVehicle(target); } } -@@ -314,13 +_,7 @@ +@@ -311,13 +_,7 @@ } protected static float lerpRotation(float currentRotation, float targetRotation) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch index e6c8b8c4023e..c7c063146a24 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ShulkerBullet.java +++ b/net/minecraft/world/entity/projectile/ShulkerBullet.java -@@ -57,7 +_,21 @@ +@@ -55,7 +_,21 @@ this.finalTarget = EntityReference.of(finalTarget); this.currentMoveDirection = Direction.UP; this.selectNextMoveDirection(axis, finalTarget); @@ -23,7 +23,7 @@ @Override public SoundSource getSoundSource() { -@@ -179,7 +_,7 @@ +@@ -176,7 +_,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == Difficulty.PEACEFUL) { @@ -32,7 +32,7 @@ } } -@@ -223,7 +_,7 @@ +@@ -220,7 +_,7 @@ } if (hitResult != null && this.isAlive() && hitResult.getType() != HitResult.Type.MISS) { @@ -41,7 +41,7 @@ } ProjectileUtil.rotateTowardsMovement(this, 0.5F); -@@ -296,7 +_,7 @@ +@@ -293,7 +_,7 @@ } if (entity instanceof LivingEntity livingEntity1) { @@ -50,7 +50,7 @@ } } } -@@ -309,14 +_,20 @@ +@@ -306,14 +_,20 @@ } private void destroy() { @@ -59,7 +59,7 @@ + this.destroy(null); + } + -+ private void destroy(@Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { ++ private void destroy(org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { + this.discard(cause); + // CraftBukkit end this.level().gameEvent(GameEvent.ENTITY_DAMAGE, this.position(), GameEvent.Context.of(this)); @@ -73,7 +73,7 @@ } @Override -@@ -331,9 +_,14 @@ +@@ -328,9 +_,14 @@ @Override public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/SmallFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/SmallFireball.java.patch index 31dd848e92b6..8990fd8cb5f1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/SmallFireball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/SmallFireball.java.patch @@ -6,7 +6,7 @@ super(EntityType.SMALL_FIREBALL, owner, movement, level); + // CraftBukkit start + if (this.getOwner() != null && this.getOwner() instanceof Mob) { -+ this.isIncendiary = (level instanceof ServerLevel serverLevel) && serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); ++ this.isIncendiary = (level instanceof ServerLevel serverLevel) && serverLevel.getGameRules().get(GameRules.MOB_GRIEFING); + } + // CraftBukkit end } @@ -32,7 +32,7 @@ super.onHitBlock(result); if (this.level() instanceof ServerLevel serverLevel) { Entity owner = this.getOwner(); -- if (!(owner instanceof Mob) || serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (!(owner instanceof Mob) || serverLevel.getGameRules().get(GameRules.MOB_GRIEFING)) { + if (this.isIncendiary) { // CraftBukkit BlockPos blockPos = result.getBlockPos().relative(result.getDirection()); - if (this.level().isEmptyBlock(blockPos)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch index be8ad6a68872..65ac961eb6e6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -104,11 +_,21 @@ +@@ -102,11 +_,21 @@ Vec3 vec3 = this.oldPosition(); if (owner instanceof ServerPlayer serverPlayer) { if (serverPlayer.connection.isAcceptingMessages()) { @@ -24,7 +24,7 @@ } } -@@ -116,15 +_,17 @@ +@@ -114,15 +_,17 @@ owner.setPortalCooldown(); } @@ -48,7 +48,7 @@ } this.playSound(serverLevel, vec3); -@@ -140,9 +_,9 @@ +@@ -138,9 +_,9 @@ this.playSound(serverLevel, vec3); } @@ -60,17 +60,17 @@ } } } -@@ -165,7 +_,7 @@ +@@ -163,7 +_,7 @@ && !entity.isAlive() && !serverPlayer.wonGame - && serverPlayer.level().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) { + && serverPlayer.level().getGameRules().get(GameRules.ENDER_PEARLS_VANISH_ON_DEATH)) { - this.discard(); + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } else { super.tick(); } -@@ -195,7 +_,7 @@ - public Entity teleport(TeleportTransition teleportTransition) { +@@ -192,7 +_,7 @@ + public @Nullable Entity teleport(TeleportTransition teleportTransition) { Entity entity = super.teleport(teleportTransition); if (entity != null) { - entity.placePortalTicket(BlockPos.containing(entity.position())); @@ -78,7 +78,7 @@ } return entity; -@@ -203,7 +_,7 @@ +@@ -200,7 +_,7 @@ @Override public boolean canTeleport(Level fromLevel, Level toLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch index 72a406d1af5c..ca1d733d00ac 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ThrownTrident.java +++ b/net/minecraft/world/entity/projectile/ThrownTrident.java -@@ -48,6 +_,12 @@ +@@ -50,6 +_,12 @@ this.entityData.set(ID_FOIL, pickupItemStack.hasFoil()); } @@ -13,7 +13,7 @@ @Override protected void defineSynchedData(SynchedEntityData.Builder builder) { super.defineSynchedData(builder); -@@ -69,10 +_,10 @@ +@@ -71,10 +_,10 @@ this.spawnAtLocation(serverLevel, this.getPickupItem(), 0.1F); } @@ -26,7 +26,7 @@ return; } -@@ -101,6 +_,20 @@ +@@ -103,6 +_,20 @@ return this.entityData.get(ID_FOIL); } @@ -44,10 +44,10 @@ + } + // Paper end + - @Nullable @Override - protected EntityHitResult findHitEntity(Vec3 startVec, Vec3 endVec) { -@@ -110,7 +_,7 @@ + protected @Nullable EntityHitResult findHitEntity(Vec3 startVec, Vec3 endVec) { + return this.dealtDamage ? null : super.findHitEntity(startVec, endVec); +@@ -117,7 +_,7 @@ @Override protected void onHitEntity(EntityHitResult result) { Entity entity = result.getEntity(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java.patch index 5c702b795c4b..1f826ae0660e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java.patch @@ -27,7 +27,7 @@ } } -@@ -140,7 +_,7 @@ +@@ -139,7 +_,7 @@ public void tick() { if (!this.level().isClientSide() && this.getBlockY() > this.level().getMaxY() + 30) { this.explode(this.position()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch index f0cdb389cdd5..b5e70b6efac7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java @@ -61,6 +_,12 @@ - import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; public class Raid { + // Paper start @@ -146,7 +146,7 @@ } } } -@@ -795,6 +_,12 @@ +@@ -793,6 +_,12 @@ public void addHeroOfTheVillage(Entity player) { this.heroesOfTheVillage.add(player.getUUID()); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch index 584017abc9a1..1d98a008dec0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/Raider.java +++ b/net/minecraft/world/entity/raid/Raider.java -@@ -214,17 +_,24 @@ +@@ -212,17 +_,24 @@ if (this.hasActiveRaid() && !flag && ItemStack.matches(item, Raid.getOminousBannerInstance(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)))) { @@ -26,7 +26,7 @@ this.getCurrentRaid().setLeader(this.getWave(), this); this.setPatrolLeader(true); } else { -@@ -298,7 +_,7 @@ +@@ -295,7 +_,7 @@ for (Raider raider : getServerLevel(this.mob) .getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0, 8.0, 8.0))) { @@ -35,7 +35,7 @@ } } -@@ -309,7 +_,7 @@ +@@ -306,7 +_,7 @@ if (target != null) { for (Raider raider : getServerLevel(this.mob) .getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0, 8.0, 8.0))) { @@ -44,11 +44,11 @@ raider.setAggressive(true); } -@@ -394,6 +_,7 @@ +@@ -389,6 +_,7 @@ } private boolean cannotPickUpBanner() { -+ if (!getServerLevel(this.mob).getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_MOBGRIEFING)) return true; // Paper - respect game and entity rules for picking up items ++ if (!getServerLevel(this.mob).getGameRules().get(net.minecraft.world.level.gamerules.GameRules.MOB_GRIEFING)) return true; // Paper - respect game and entity rules for picking up items if (!this.mob.hasActiveRaid()) { return true; } else if (this.mob.getCurrentRaid().isOver()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch index d2ff3f1e6120..0efe66607e7e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch @@ -8,7 +8,7 @@ } this.nextId = nextId; -@@ -139,11 +_,23 @@ +@@ -137,11 +_,23 @@ } Raid raid = this.getOrCreateRaid(serverLevel, blockPos); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch index 6339c7e7f016..b85056082a32 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/vehicle/AbstractBoat.java +++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java -@@ -78,6 +_,15 @@ - private Leashable.LeashData leashData; +@@ -77,6 +_,15 @@ + private Leashable.@Nullable LeashData leashData; private final Supplier dropItem; + // CraftBukkit start @@ -16,7 +16,7 @@ public AbstractBoat(EntityType type, Level level, Supplier dropItem) { super(type, level); this.dropItem = dropItem; -@@ -119,7 +_,7 @@ +@@ -118,7 +_,7 @@ } @Override @@ -25,7 +25,7 @@ return true; } -@@ -174,11 +_,30 @@ +@@ -173,11 +_,30 @@ @Override public void push(Entity entity) { @@ -56,7 +56,7 @@ super.push(entity); } } -@@ -245,6 +_,18 @@ +@@ -244,6 +_,18 @@ this.setDeltaMovement(Vec3.ZERO); } @@ -75,7 +75,7 @@ this.applyEffectsFromBlocks(); this.applyEffectsFromBlocks(); this.tickBubbleColumn(); -@@ -547,7 +_,7 @@ +@@ -543,7 +_,7 @@ this.waterLevel = this.getY(1.0); double d2 = this.getWaterLevelAbove() - this.getBbHeight() + 0.101; if (this.level().noCollision(this, this.getBoundingBox().move(0.0, d2 - this.getY(), 0.0))) { @@ -84,12 +84,12 @@ this.setDeltaMovement(this.getDeltaMovement().multiply(1.0, 0.0, 1.0)); this.lastYd = 0.0; } -@@ -710,12 +_,12 @@ +@@ -706,12 +_,12 @@ } @Override - public void remove(Entity.RemovalReason reason) { -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { // CraftBukkit - add Bukkit remove cause ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause eventCause) { // CraftBukkit - add Bukkit remove cause if (!this.level().isClientSide() && reason.shouldDestroy() && this.isLeashed()) { this.dropLeash(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch index c4e49c5976af..d8f0cc02f216 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/vehicle/AbstractChestBoat.java +++ b/net/minecraft/world/entity/vehicle/AbstractChestBoat.java -@@ -67,12 +_,12 @@ +@@ -66,12 +_,12 @@ } @Override - public void remove(Entity.RemovalReason reason) { -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { // CraftBukkit - add Bukkit remove cause if (!this.level().isClientSide() && reason.shouldDestroy()) { Containers.dropContents(this.level(), this, this); } @@ -15,7 +15,7 @@ } @Override -@@ -95,8 +_,8 @@ +@@ -94,8 +_,8 @@ @Override public void openCustomInventoryScreen(Player player) { @@ -26,16 +26,16 @@ this.gameEvent(GameEvent.CONTAINER_OPEN, player); PiglinAi.angerNearbyPiglins(serverLevel, player, true); } -@@ -149,7 +_,7 @@ - @Nullable +@@ -147,7 +_,7 @@ + @Override - public AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { + public @Nullable AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { - if (this.lootTable != null && player.isSpectator()) { + if (this.lootTable != null && player.isSpectator()) { // Paper - LootTable API (TODO spectators can open chests that aren't ready to be re-generated but this doesn't support that) return null; } else { this.unpackLootTable(playerInventory.player); -@@ -196,4 +_,58 @@ +@@ -193,4 +_,58 @@ public void stopOpen(ContainerUser user) { this.level().gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.Context.of(user.getLivingEntity())); } @@ -73,7 +73,7 @@ + } + + @Override -+ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { ++ public org.bukkit.inventory.@Nullable InventoryHolder getOwner() { + org.bukkit.entity.Entity entity = this.getBukkitEntity(); + return entity instanceof final org.bukkit.inventory.InventoryHolder inventoryHolder ? inventoryHolder : null; + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch index 23323b9b5ebe..d569a2acd33b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch @@ -18,7 +18,7 @@ protected AbstractMinecart(EntityType type, Level level) { super(type, level); -@@ -152,11 +_,19 @@ +@@ -151,11 +_,19 @@ @Override public boolean canCollideWith(Entity entity) { @@ -40,7 +40,7 @@ return true; } -@@ -257,6 +_,14 @@ +@@ -256,6 +_,14 @@ @Override public void tick() { @@ -55,7 +55,7 @@ if (this.getHurtTime() > 0) { this.setHurtTime(this.getHurtTime() - 1); } -@@ -266,8 +_,20 @@ +@@ -265,8 +_,20 @@ } this.checkBelowWorld(); @@ -77,7 +77,7 @@ this.updateInWaterStateAndDoFluidPushing(); if (this.isInLava()) { this.lavaIgnite(); -@@ -355,12 +_,16 @@ +@@ -354,12 +_,16 @@ Vec3 deltaMovement = this.getDeltaMovement(); this.setDeltaMovement(Mth.clamp(deltaMovement.x, -maxSpeed, maxSpeed), deltaMovement.y, Mth.clamp(deltaMovement.z, -maxSpeed, maxSpeed)); if (this.onGround()) { @@ -96,7 +96,7 @@ } } -@@ -462,6 +_,15 @@ +@@ -461,6 +_,15 @@ this.setDisplayOffset(input.getIntOr("DisplayOffset", this.getDefaultDisplayOffset())); this.flipped = input.getBooleanOr("FlippedRotation", false); this.firstTick = input.getBooleanOr("HasTicked", false); @@ -112,7 +112,7 @@ } @Override -@@ -474,13 +_,26 @@ +@@ -473,13 +_,26 @@ output.putBoolean("FlippedRotation", this.flipped); output.putBoolean("HasTicked", this.firstTick); @@ -139,7 +139,7 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double d2 = d * d + d1 * d1; -@@ -589,4 +_,26 @@ +@@ -588,4 +_,26 @@ public boolean isFurnace() { return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch index 2499cc67a92e..2c01132fdea0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch @@ -1,24 +1,23 @@ --- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -@@ -22,10 +_,11 @@ - import net.minecraft.world.phys.Vec3; +@@ -22,9 +_,10 @@ + import org.jspecify.annotations.Nullable; public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity { - private NonNullList itemStacks = NonNullList.withSize(36, ItemStack.EMPTY); + private NonNullList itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 - @Nullable - public ResourceKey lootTable; + public @Nullable ResourceKey lootTable; public long lootTableSeed; + private final com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData = new com.destroystokyo.paper.loottable.PaperLootableInventoryData(); // Paper - LootTable API protected AbstractMinecartContainer(EntityType type, Level level) { super(type, level); -@@ -72,12 +_,12 @@ +@@ -71,12 +_,12 @@ } @Override - public void remove(Entity.RemovalReason reason) { -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { // CraftBukkit - add Bukkit remove cause if (!this.level().isClientSide() && reason.shouldDestroy()) { Containers.dropContents(this.level(), this, this); } @@ -28,7 +27,7 @@ } @Override -@@ -165,4 +_,56 @@ +@@ -162,4 +_,56 @@ public void clearItemStacks() { this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); } @@ -65,7 +64,7 @@ + } + + @Override -+ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { ++ public org.bukkit.inventory.@Nullable InventoryHolder getOwner() { + return this.getBukkitEntity() instanceof final org.bukkit.inventory.InventoryHolder inventoryHolder ? inventoryHolder : null; + } + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch index 1c884027739d..bfc73e99d069 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java -@@ -60,12 +_,12 @@ +@@ -59,12 +_,12 @@ default void addChestVehicleSaveData(ValueOutput output) { if (this.getContainerLootTable() != null) { output.putString("LootTable", this.getContainerLootTable().location().toString()); @@ -15,7 +15,7 @@ } default void readChestVehicleSaveData(ValueInput input) { -@@ -73,7 +_,12 @@ +@@ -72,7 +_,12 @@ ResourceKey resourceKey = input.read("LootTable", LootTable.KEY_CODEC).orElse(null); this.setContainerLootTable(resourceKey); this.setContainerLootTableSeed(input.getLongOr("LootTableSeed", 0L)); @@ -29,7 +29,7 @@ ContainerHelper.loadAllItems(input, this.getItemStacks()); } } -@@ -89,19 +_,27 @@ +@@ -88,19 +_,27 @@ } default InteractionResult interactWithContainerVehicle(Player player) { @@ -60,7 +60,7 @@ LootParams.Builder builder = new LootParams.Builder((ServerLevel)this.level()).withParameter(LootContextParams.ORIGIN, this.position()); if (player != null) { builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player); -@@ -171,4 +_,14 @@ +@@ -170,4 +_,14 @@ default boolean isChestVehicleStillValid(Player player) { return !this.isRemoved() && player.canInteractWithEntity(this.getBoundingBox(), 4.0); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch index da13294e34b0..e0a9d385e70f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/MinecartTNT.java +++ b/net/minecraft/world/entity/vehicle/MinecartTNT.java -@@ -40,6 +_,7 @@ +@@ -39,6 +_,7 @@ public int fuse = -1; public float explosionPowerBase = 4.0F; public float explosionSpeedFactor = 1.0F; @@ -8,7 +8,7 @@ public MinecartTNT(EntityType type, Level level) { super(type, level); -@@ -54,6 +_,12 @@ +@@ -53,6 +_,12 @@ public void tick() { super.tick(); if (this.fuse > 0) { @@ -21,9 +21,9 @@ this.fuse--; this.level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5, this.getZ(), 0.0, 0.0, 0.0); } else if (this.fuse == 0) { -@@ -105,6 +_,17 @@ +@@ -104,6 +_,17 @@ if (this.level() instanceof ServerLevel serverLevel) { - if (serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) { + if (serverLevel.getGameRules().get(GameRules.TNT_EXPLODES)) { double min = Math.min(Math.sqrt(radiusModifier), 5.0); + // CraftBukkit start + org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent( @@ -39,7 +39,7 @@ serverLevel.explode( this, damageSource, -@@ -112,13 +_,13 @@ +@@ -111,13 +_,13 @@ this.getX(), this.getY(), this.getZ(), diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch index ef6420a14fa6..753b35e02c21 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java +++ b/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java -@@ -480,6 +_,12 @@ +@@ -479,6 +_,12 @@ @Override public double getMaxSpeed(ServerLevel level) { @@ -10,10 +10,10 @@ + return this.minecart.isInWater() ? maxSpeed / 2.0D : maxSpeed; + } + // CraftBukkit end - return level.getGameRules().getInt(GameRules.RULE_MINECART_MAX_SPEED) * (this.minecart.isInWater() ? 0.5 : 1.0) / 20.0; + return level.getGameRules().get(GameRules.MAX_MINECART_SPEED).intValue() * (this.minecart.isInWater() ? 0.5 : 1.0) / 20.0; } -@@ -495,7 +_,8 @@ +@@ -494,7 +_,8 @@ @Override public double getSlowdownFactor() { @@ -23,7 +23,7 @@ } @Override -@@ -519,6 +_,13 @@ +@@ -518,6 +_,13 @@ && !(entity instanceof AbstractMinecart) && !this.minecart.isVehicle() && !entity.isPassenger()) { @@ -37,7 +37,7 @@ boolean flag = entity.startRiding(this.minecart); if (flag) { return true; -@@ -542,6 +_,17 @@ +@@ -541,6 +_,17 @@ || entity instanceof AbstractMinecart || this.minecart.isVehicle() || entity.isPassenger()) { @@ -55,7 +55,7 @@ entity.push(this.minecart); flag = true; } -@@ -550,6 +_,15 @@ +@@ -549,6 +_,15 @@ } else { for (Entity entity1 : this.level().getEntities(this.minecart, box)) { if (!this.minecart.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof AbstractMinecart) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch index 71c314ca361f..38721192ef0f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java +++ b/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java -@@ -378,8 +_,22 @@ +@@ -376,8 +_,22 @@ && !(entity instanceof AbstractMinecart) && !this.minecart.isVehicle() && !entity.isPassenger()) { @@ -23,7 +23,7 @@ entity.push(this.minecart); } } -@@ -387,6 +_,12 @@ +@@ -385,6 +_,12 @@ } else { for (Entity entity1 : this.level().getEntities(this.minecart, aabb)) { if (!this.minecart.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof AbstractMinecart) { @@ -36,7 +36,7 @@ entity1.push(this.minecart); } } -@@ -409,11 +_,18 @@ +@@ -407,11 +_,18 @@ @Override public double getMaxSpeed(ServerLevel level) { diff --git a/paper-server/patches/sources/net/minecraft/world/food/FoodData.java.patch b/paper-server/patches/sources/net/minecraft/world/food/FoodData.java.patch index 04aec9b9faa4..4b595cfd1806 100644 --- a/paper-server/patches/sources/net/minecraft/world/food/FoodData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/food/FoodData.java.patch @@ -47,8 +47,8 @@ } } - boolean _boolean = serverLevel.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION); - if (_boolean && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20) { + boolean flag = serverLevel.getGameRules().get(GameRules.NATURAL_HEALTH_REGENERATION); + if (flag && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20) { this.tickTimer++; - if (this.tickTimer >= 10) { + if (this.tickTimer >= this.saturatedRegenRate) { // CraftBukkit @@ -60,7 +60,7 @@ + player.causeFoodExhaustion(min, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent this.tickTimer = 0; } - } else if (_boolean && this.foodLevel >= 18 && player.isHurt()) { + } else if (flag && this.foodLevel >= 18 && player.isHurt()) { this.tickTimer++; - if (this.tickTimer >= 80) { - player.heal(1.0F); diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch index 66bf34a8d618..dbc59efe855d 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -65,6 +_,36 @@ - @Nullable - private ContainerSynchronizer synchronizer; +@@ -63,6 +_,35 @@ + private final List containerListeners = Lists.newArrayList(); + private @Nullable ContainerSynchronizer synchronizer; private boolean suppressRemoteUpdates; + // CraftBukkit start + public boolean checkReachable = true; @@ -16,8 +16,7 @@ + ((org.bukkit.craftbukkit.inventory.CraftInventory) destination.getBottomInventory()).getInventory().onOpen(player); + } + -+ @Nullable -+ private net.minecraft.network.chat.Component title; ++ private net.minecraft.network.chat.@Nullable Component title; + public final net.minecraft.network.chat.Component getTitle() { + // Paper start - return chat component with empty text instead of throwing error + if (this.title == null) { @@ -37,7 +36,7 @@ protected AbstractContainerMenu(@Nullable MenuType menuType, int containerId) { this.menuType = menuType; -@@ -176,8 +_,43 @@ +@@ -174,8 +_,43 @@ if (this.synchronizer != null) { this.synchronizer.sendInitialData(this, list, carried.copy(), this.remoteDataSlots.toIntArray()); @@ -83,7 +82,7 @@ public void removeSlotListener(ContainerListener listener) { this.containerListeners.remove(listener); -@@ -243,7 +_,7 @@ +@@ -241,7 +_,7 @@ this.lastSlots.set(slotIndex, itemStack1); for (ContainerListener containerListener : this.containerListeners) { @@ -92,7 +91,7 @@ } } } -@@ -351,6 +_,7 @@ +@@ -349,6 +_,7 @@ this.resetQuickCraft(); } } else if (this.quickcraftStatus == 1) { @@ -100,7 +99,7 @@ Slot slot = this.slots.get(slotIndex); ItemStack carried = this.getCarried(); if (canItemQuickReplace(slot, carried, true) -@@ -375,6 +_,7 @@ +@@ -373,6 +_,7 @@ } int count = this.getCarried().getCount(); @@ -108,7 +107,7 @@ for (Slot slot1 : this.quickcraftSlots) { ItemStack carried1 = this.getCarried(); -@@ -387,12 +_,46 @@ +@@ -385,12 +_,46 @@ int min = Math.min(itemStack.getMaxStackSize(), slot1.getMaxStackSize(itemStack)); int min1 = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemStack) + i2, min); count -= min1 - i2; @@ -161,7 +160,7 @@ } this.resetQuickCraft(); -@@ -406,8 +_,11 @@ +@@ -404,8 +_,11 @@ if (slotIndex == SLOT_CLICKED_OUTSIDE) { if (!this.getCarried().isEmpty()) { if (clickAction == ClickAction.PRIMARY) { @@ -174,7 +173,7 @@ } else { player.drop(this.getCarried().split(1), true); } -@@ -469,8 +_,18 @@ +@@ -467,8 +_,18 @@ } slot.setChanged(); @@ -193,7 +192,7 @@ ItemStack item = inventory.getItem(button); Slot slot = this.slots.get(slotIndex); ItemStack carried = slot.getItem(); -@@ -590,8 +_,9 @@ +@@ -588,8 +_,9 @@ if (player instanceof ServerPlayer) { ItemStack carried = this.getCarried(); if (!carried.isEmpty()) { @@ -204,7 +203,7 @@ } } } -@@ -637,6 +_,14 @@ +@@ -635,6 +_,14 @@ public abstract boolean stillValid(Player player); protected boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection) { @@ -219,7 +218,7 @@ boolean flag = false; int i = startIndex; if (reverseDirection) { -@@ -647,18 +_,27 @@ +@@ -645,18 +_,27 @@ while (!stack.isEmpty() && (reverseDirection ? i >= startIndex : i < endIndex)) { Slot slot = this.slots.get(i); ItemStack item = slot.getItem(); @@ -247,7 +246,7 @@ flag = true; } } -@@ -681,10 +_,21 @@ +@@ -679,10 +_,21 @@ while (reverseDirection ? i >= startIndex : i < endIndex) { Slot slotx = this.slots.get(i); ItemStack itemx = slotx.getItem(); @@ -269,7 +268,7 @@ flag = true; break; } -@@ -768,6 +_,11 @@ +@@ -766,6 +_,11 @@ } public ItemStack getCarried() { @@ -281,7 +280,7 @@ return this.carried; } -@@ -820,4 +_,15 @@ +@@ -818,4 +_,15 @@ this.stateId = this.stateId + 1 & 32767; return this.stateId; } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch index 184b89d203bd..73337324a4bb 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/AnvilMenu.java +++ b/net/minecraft/world/inventory/AnvilMenu.java -@@ -46,6 +_,12 @@ +@@ -45,6 +_,12 @@ private static final int ADDITIONAL_SLOT_X_PLACEMENT = 76; private static final int RESULT_SLOT_X_PLACEMENT = 134; private static final int SLOT_Y_PLACEMENT = 47; @@ -13,7 +13,7 @@ public AnvilMenu(int containerId, Inventory playerInventory) { this(containerId, playerInventory, ContainerLevelAccess.NULL); -@@ -71,7 +_,7 @@ +@@ -70,7 +_,7 @@ @Override protected boolean mayPickup(Player player, boolean hasStack) { @@ -22,7 +22,7 @@ } @Override -@@ -92,7 +_,7 @@ +@@ -91,7 +_,7 @@ this.inputSlots.setItem(1, ItemStack.EMPTY); } @@ -31,7 +31,7 @@ if (player instanceof ServerPlayer serverPlayer && !StringUtil.isBlank(this.itemName) && !this.inputSlots.getItem(0).getHoverName().getString().equals(this.itemName)) { -@@ -104,6 +_,16 @@ +@@ -103,6 +_,16 @@ BlockState blockState = level.getBlockState(blockPos); if (!player.hasInfiniteMaterials() && blockState.is(BlockTags.ANVIL) && player.getRandom().nextFloat() < 0.12F) { BlockState blockState1 = AnvilBlock.damage(blockState); @@ -48,7 +48,7 @@ if (blockState1 == null) { level.removeBlock(blockPos, false); level.levelEvent(LevelEvent.SOUND_ANVIL_BROKEN, blockPos, 0); -@@ -136,8 +_,8 @@ +@@ -135,8 +_,8 @@ if (itemStack.isDamageableItem() && item.isValidRepairItem(item1)) { int min = Math.min(itemStack.getDamageValue(), itemStack.getMaxDamage() / 4); if (min <= 0) { @@ -59,7 +59,7 @@ return; } -@@ -152,8 +_,8 @@ +@@ -151,8 +_,8 @@ this.repairItemCountCost = i2; } else { if (!hasStoredEnchantments && (!itemStack.is(item1.getItem()) || !itemStack.isDamageableItem())) { @@ -70,7 +70,7 @@ return; } -@@ -199,7 +_,7 @@ +@@ -198,7 +_,7 @@ flag1 = true; } else { flag = true; @@ -79,7 +79,7 @@ intValue = enchantment.getMaxLevel(); } -@@ -217,8 +_,8 @@ +@@ -216,8 +_,8 @@ } if (flag1 && !flag) { @@ -90,7 +90,7 @@ return; } } -@@ -243,14 +_,16 @@ +@@ -242,14 +_,16 @@ } if (i1 == i && i1 > 0) { @@ -110,7 +110,7 @@ itemStack = ItemStack.EMPTY; } -@@ -268,12 +_,13 @@ +@@ -267,12 +_,13 @@ EnchantmentHelper.setEnchantments(itemStack, mutable.toImmutable()); } @@ -127,7 +127,7 @@ } public static int calculateIncreasedRepairCost(int oldRepairCost) { -@@ -294,6 +_,7 @@ +@@ -293,6 +_,7 @@ } this.createResult(); @@ -135,7 +135,7 @@ return true; } else { return false; -@@ -309,4 +_,19 @@ +@@ -307,4 +_,19 @@ public int getCost() { return this.cost.get(); } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch index 76af523d8930..65870483569e 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch @@ -21,7 +21,7 @@ private final ContainerLevelAccess access; private final ContainerData beaconData; + // CraftBukkit start -+ private @Nullable org.bukkit.craftbukkit.inventory.view.CraftBeaconView view = null; ++ private org.bukkit.craftbukkit.inventory.view.@Nullable CraftBeaconView view = null; + private final net.minecraft.world.entity.player.Inventory inventory; + // CraftBukkit end @@ -61,12 +61,12 @@ return stillValid(this.access, player, Blocks.BEACON); } -@@ -141,13 +_,30 @@ - public Holder getSecondaryEffect() { +@@ -138,13 +_,30 @@ + public @Nullable Holder getSecondaryEffect() { return decodeEffect(this.beaconData.get(2)); } + // Paper start - Add PlayerChangeBeaconEffectEvent -+ private static @Nullable org.bukkit.potion.PotionEffectType convert(Optional> optionalEffect) { ++ private static org.bukkit.potion.@Nullable PotionEffectType convert(Optional> optionalEffect) { + return optionalEffect.map(org.bukkit.craftbukkit.potion.CraftPotionEffectType::minecraftHolderToBukkit).orElse(null); + } + // Paper end - Add PlayerChangeBeaconEffectEvent @@ -94,7 +94,7 @@ } } -@@ -170,4 +_,17 @@ +@@ -167,4 +_,17 @@ return 1; } } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/CraftingMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/CraftingMenu.java.patch index 50d426ca17ba..c2af45981276 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/CraftingMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/CraftingMenu.java.patch @@ -4,7 +4,7 @@ public final ContainerLevelAccess access; private final Player player; private boolean placingRecipe; -+ private @Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view = null; // CraftBukkit ++ private org.bukkit.craftbukkit.inventory.@Nullable CraftInventoryView view = null; // CraftBukkit public CraftingMenu(int containerId, Inventory playerInventory) { this(containerId, playerInventory, ContainerLevelAccess.NULL); diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch index 31a0a81d1c5e..757e9e948ad6 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/inventory/MerchantContainer.java +++ b/net/minecraft/world/inventory/MerchantContainer.java -@@ -17,6 +_,45 @@ - private MerchantOffer activeOffer; +@@ -16,6 +_,45 @@ + private @Nullable MerchantOffer activeOffer; public int selectionHint; private int futureXp; + // CraftBukkit start - add fields and methods diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch index 9db2a512bf94..e41f6d341dc6 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/inventory/PlayerEnderChestContainer.java +++ b/net/minecraft/world/inventory/PlayerEnderChestContainer.java -@@ -13,9 +_,23 @@ +@@ -12,9 +_,23 @@ + public class PlayerEnderChestContainer extends SimpleContainer { - @Nullable - private EnderChestBlockEntity activeChest; + private @Nullable EnderChestBlockEntity activeChest; - - public PlayerEnderChestContainer() { + // CraftBukkit start @@ -15,7 +15,7 @@ + } + + @Override -+ public @Nullable org.bukkit.Location getLocation() { ++ public org.bukkit.@Nullable Location getLocation() { + return this.activeChest != null ? org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.activeChest.getBlockPos(), this.activeChest.getLevel()) : null; + } + diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/ResultContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/ResultContainer.java.patch index b3efe5e40d7e..36e9f3a8cff2 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/ResultContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/ResultContainer.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/inventory/ResultContainer.java +++ b/net/minecraft/world/inventory/ResultContainer.java -@@ -12,6 +_,55 @@ +@@ -11,6 +_,55 @@ + public class ResultContainer implements Container, RecipeCraftingHolder { private final NonNullList itemStacks = NonNullList.withSize(1, ItemStack.EMPTY); - @Nullable - private RecipeHolder recipeUsed; + private @Nullable RecipeHolder recipeUsed; + // CraftBukkit start + private int maxStack = MAX_STACK; + @@ -13,7 +13,7 @@ + } + + @Override -+ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { ++ public org.bukkit.inventory.@Nullable InventoryHolder getOwner() { + // Paper start - Add missing InventoryHolders + if (this.holder == null && this.holderCreator != null) { + this.holder = this.holderCreator.get(); @@ -39,13 +39,13 @@ + } + + @Override -+ public @Nullable org.bukkit.Location getLocation() { ++ public org.bukkit.@Nullable Location getLocation() { + return null; + } + // CraftBukkit end + // Paper start - Add missing InventoryHolders -+ private @Nullable java.util.function.Supplier holderCreator; -+ private @Nullable org.bukkit.inventory.InventoryHolder holder; ++ private java.util.function.@Nullable Supplier holderCreator; ++ private org.bukkit.inventory.@Nullable InventoryHolder holder; + public ResultContainer(java.util.function.Supplier holderCreator) { + this.holderCreator = holderCreator; + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch index 5f34e50bb287..52cf1527e917 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch @@ -64,7 +64,7 @@ } } } -@@ -137,8 +_,19 @@ +@@ -135,8 +_,19 @@ protected boolean canPlace(BlockPlaceContext context, BlockState state) { Player player = context.getPlayer(); @@ -86,7 +86,7 @@ } protected boolean mustSurvive() { -@@ -162,7 +_,7 @@ +@@ -160,7 +_,7 @@ return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch index 45110e1aa9e3..534428c9d894 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/BucketItem.java +++ b/net/minecraft/world/item/BucketItem.java @@ -31,6 +_,7 @@ - import net.minecraft.world.phys.HitResult; + import org.jspecify.annotations.Nullable; public class BucketItem extends Item implements DispensibleContainerItem { + private static @Nullable ItemStack itemLeftInHandAfterPlayerBucketEmptyEvent = null; // Paper - Fix PlayerBucketEmptyEvent result itemstack diff --git a/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch index b797b0751900..b36d81a0e594 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch @@ -27,7 +27,7 @@ + double deltaZ = soundPos.getZ() - player.getZ(); + double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; + final double soundRadiusSquared = serverLevel.getGlobalSoundRangeSquared(config -> config.endPortalSoundRadius); // Paper - respect global sound events gamerule -+ if (!serverLevel.getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Spigot // Paper - respect global sound events gamerule ++ if (!serverLevel.getGameRules().get(net.minecraft.world.level.gamerules.GameRules.GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Spigot // Paper - respect global sound events gamerule + if (distanceSquared > viewDistance * viewDistance) { + double deltaLength = Math.sqrt(distanceSquared); + double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; diff --git a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch index 7b169b409e4d..aa5f6cfa28cb 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -202,12 +_,20 @@ +@@ -200,12 +_,20 @@ @Override public void encode(RegistryFriendlyByteBuf buffer, ItemStack value) { @@ -23,7 +23,7 @@ } } }; -@@ -371,10 +_,166 @@ +@@ -369,10 +_,166 @@ return InteractionResult.PASS; } else { Item item = this.getItem(); @@ -192,7 +192,7 @@ return interactionResult; } -@@ -455,31 +_,67 @@ +@@ -453,31 +_,67 @@ return this.isDamageableItem() && this.getDamageValue() >= this.getMaxDamage() - 1; } @@ -268,7 +268,7 @@ this.shrink(1); onBreak.accept(item); } -@@ -492,7 +_,26 @@ +@@ -490,7 +_,26 @@ return; } @@ -296,7 +296,7 @@ this.applyDamage(min, serverPlayer, item -> {}); } } -@@ -502,9 +_,14 @@ +@@ -500,9 +_,14 @@ } public void hurtAndBreak(int amount, LivingEntity entity, EquipmentSlot slot) { @@ -312,7 +312,7 @@ ); } } -@@ -746,6 +_,12 @@ +@@ -744,6 +_,12 @@ return this.getItem().useOnRelease(this); } @@ -322,10 +322,10 @@ + } + // CraftBukkit end + - @Nullable - public T set(DataComponentType component, @Nullable T value) { + public @Nullable T set(DataComponentType component, @Nullable T value) { return this.components.set(component, value); -@@ -794,6 +_,28 @@ + } +@@ -787,6 +_,28 @@ this.components.setAll(components); } @@ -342,7 +342,7 @@ + return org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(itemstack); + } + -+ private @Nullable org.bukkit.craftbukkit.inventory.CraftItemStack bukkitStack; ++ private org.bukkit.craftbukkit.inventory.@Nullable CraftItemStack bukkitStack; + public org.bukkit.inventory.ItemStack getBukkitStack() { + if (this.bukkitStack == null || this.bukkitStack.handle != this) { + this.bukkitStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this); @@ -354,7 +354,7 @@ public Component getHoverName() { Component customName = this.getCustomName(); return customName != null ? customName : this.getItemName(); -@@ -1027,6 +_,19 @@ +@@ -1017,6 +_,19 @@ EnchantmentHelper.forEachModifier(this, slot, action); } @@ -374,7 +374,7 @@ public Component getDisplayName() { MutableComponent mutableComponent = Component.empty().append(this.getHoverName()); if (this.has(DataComponents.CUSTOM_NAME)) { -@@ -1086,7 +_,7 @@ +@@ -1076,7 +_,7 @@ } public void consume(int amount, @Nullable LivingEntity entity) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/MapItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/MapItem.java.patch index 0d250525f064..07a53be2f8aa 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/MapItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/MapItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/MapItem.java +++ b/net/minecraft/world/item/MapItem.java -@@ -97,8 +_,8 @@ +@@ -95,8 +_,8 @@ int i9 = (i1 / i + i6 - 64) * i; int i10 = (i2 / i + i7 - 64) * i; Multiset multiset = LinkedHashMultiset.create(); @@ -11,7 +11,7 @@ int i11 = 0; double d1 = 0.0; if (level.dimensionType().hasCeiling()) { -@@ -205,7 +_,7 @@ +@@ -203,7 +_,7 @@ for (int i5 = 0; i5 < 128; i5++) { for (int i6 = 0; i6 < 128; i6++) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/SignItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/SignItem.java.patch index fe3d4a6926e6..eb805f28709f 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/SignItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/SignItem.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/SignItem.java +++ b/net/minecraft/world/item/SignItem.java @@ -11,6 +_,7 @@ - import net.minecraft.world.level.block.state.BlockState; + import org.jspecify.annotations.Nullable; public class SignItem extends StandingAndWallBlockItem { + public static BlockPos openSign; // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch index 0ee6be7e5610..9ce8994289c2 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch @@ -17,7 +17,7 @@ return InteractionResult.FAIL; } else { if (type.spawn((ServerLevel)level, stack, owner, pos, EntitySpawnReason.SPAWN_ITEM_USE, shouldOffsetY, shouldOffsetYMore) != null) { -@@ -180,7 +_,7 @@ +@@ -178,7 +_,7 @@ } else { breedOffspring.snapTo(pos.x(), pos.y(), pos.z(), 0.0F, 0.0F); breedOffspring.applyComponentsFromItemStack(stack); diff --git a/paper-server/patches/sources/net/minecraft/world/item/StandingAndWallBlockItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/StandingAndWallBlockItem.java.patch index e99c04062a99..90f8211a9a80 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/StandingAndWallBlockItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/StandingAndWallBlockItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/StandingAndWallBlockItem.java +++ b/net/minecraft/world/item/StandingAndWallBlockItem.java -@@ -42,7 +_,20 @@ +@@ -41,7 +_,20 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/WrittenBookContent.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/WrittenBookContent.java.patch index 5b01096247ed..b8d4d0c85d0e 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/component/WrittenBookContent.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/component/WrittenBookContent.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/component/WrittenBookContent.java +++ b/net/minecraft/world/item/component/WrittenBookContent.java -@@ -94,7 +_,7 @@ +@@ -93,7 +_,7 @@ public static boolean resolveForItem(ItemStack stack, CommandSourceStack source, @Nullable Player player) { WrittenBookContent writtenBookContent = stack.get(DataComponents.WRITTEN_BOOK_CONTENT); diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch index 723d1f665ff5..31ec46f411c1 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch @@ -39,7 +39,7 @@ } public Optional> byKey(ResourceKey> key) { -@@ -200,6 +_,22 @@ +@@ -198,6 +_,22 @@ Recipe recipe1 = Recipe.CODEC.parse(registries.createSerializationContext(JsonOps.INSTANCE), json).getOrThrow(JsonParseException::new); return new RecipeHolder<>(recipe, recipe1); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapedRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapedRecipe.java.patch index 18e1fb071816..075f7f7cf2af 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapedRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapedRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/ShapedRecipe.java +++ b/net/minecraft/world/item/crafting/ShapedRecipe.java -@@ -103,6 +_,68 @@ +@@ -102,6 +_,68 @@ ); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch index e13cbaac8ec6..be840f254289 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -31,6 +_,21 @@ +@@ -30,6 +_,21 @@ this.ingredients = ingredients; } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch index 699390e1e937..4058cfeaa29d 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -@@ -21,8 +_,15 @@ +@@ -20,8 +_,15 @@ + final Optional addition; final TransmuteResult result; - @Nullable - private PlacementInfo placementInfo; + private @Nullable PlacementInfo placementInfo; + final boolean copyDataComponents; // Paper - Option to prevent data components copy public SmithingTransformRecipe(Optional template, Ingredient base, Optional addition, TransmuteResult result) { @@ -16,7 +16,7 @@ this.template = template; this.base = base; this.addition = addition; -@@ -31,7 +_,7 @@ +@@ -30,7 +_,7 @@ @Override public ItemStack assemble(SmithingRecipeInput input, HolderLookup.Provider registries) { @@ -25,7 +25,7 @@ } @Override -@@ -75,6 +_,17 @@ +@@ -74,6 +_,17 @@ ) ); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch index 7b1e17dcae44..b71e1693cffa 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -@@ -28,8 +_,15 @@ +@@ -27,8 +_,15 @@ + final Ingredient addition; final Holder pattern; - @Nullable - private PlacementInfo placementInfo; + private @Nullable PlacementInfo placementInfo; + final boolean copyDataComponents; // Paper - Option to prevent data components copy public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition, Holder pattern) { @@ -16,7 +16,7 @@ this.template = template; this.base = base; this.addition = addition; -@@ -38,10 +_,15 @@ +@@ -37,10 +_,15 @@ @Override public ItemStack assemble(SmithingRecipeInput input, HolderLookup.Provider registries) { @@ -33,7 +33,7 @@ Optional> fromIngredient = TrimMaterials.getFromIngredient(registries, addition); if (fromIngredient.isPresent()) { ArmorTrim armorTrim = base.get(DataComponents.TRIM); -@@ -49,7 +_,7 @@ +@@ -48,7 +_,7 @@ if (Objects.equals(armorTrim, armorTrim1)) { return ItemStack.EMPTY; } else { @@ -42,7 +42,7 @@ itemStack.set(DataComponents.TRIM, armorTrim1); return itemStack; } -@@ -102,6 +_,13 @@ +@@ -101,6 +_,13 @@ ) ); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch index 53a594391013..742d7149df35 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/TransmuteRecipe.java +++ b/net/minecraft/world/item/crafting/TransmuteRecipe.java -@@ -85,6 +_,13 @@ +@@ -84,6 +_,13 @@ ); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch b/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch index d0e55ad13b41..952ccb273469 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/enchantment/ItemEnchantments.java +++ b/net/minecraft/world/item/enchantment/ItemEnchantments.java @@ -28,21 +_,24 @@ - import net.minecraft.world.item.component.TooltipProvider; + import org.jspecify.annotations.Nullable; public class ItemEnchantments implements TooltipProvider { - public static final ItemEnchantments EMPTY = new ItemEnchantments(new Object2IntOpenHashMap<>()); diff --git a/paper-server/patches/sources/net/minecraft/world/item/trading/Merchant.java.patch b/paper-server/patches/sources/net/minecraft/world/item/trading/Merchant.java.patch index 9a3b747befa4..4e3a8a135e4c 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/trading/Merchant.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/trading/Merchant.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/item/trading/Merchant.java +++ b/net/minecraft/world/item/trading/Merchant.java -@@ -19,6 +_,8 @@ +@@ -18,6 +_,8 @@ void overrideOffers(MerchantOffers offers); -+ default void processTrade(MerchantOffer offer, @Nullable io.papermc.paper.event.player.PlayerPurchaseEvent event) { this.notifyTrade(offer); } // Paper ++ default void processTrade(MerchantOffer offer, io.papermc.paper.event.player.@Nullable PlayerPurchaseEvent event) { this.notifyTrade(offer); } // Paper + void notifyTrade(MerchantOffer offer); void notifyTradeUpdated(ItemStack stack); -@@ -50,4 +_,6 @@ +@@ -49,4 +_,6 @@ boolean isClientSide(); boolean stillValid(Player player); diff --git a/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch index 242a90a4421e..e3d194ac90c1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/BaseCommandBlock.java +++ b/net/minecraft/world/level/BaseCommandBlock.java -@@ -31,6 +_,10 @@ +@@ -30,6 +_,10 @@ + @Nullable Component lastOutput; private String command = ""; - @Nullable - private Component customName; + private @Nullable Component customName; + // CraftBukkit start + protected abstract org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper); + public abstract ServerLevel getLevel(); @@ -11,7 +11,7 @@ public int getSuccessCount() { return this.successCount; -@@ -107,7 +_,13 @@ +@@ -106,7 +_,13 @@ this.successCount++; } }); @@ -26,7 +26,7 @@ } } catch (Throwable var7) { CrashReport crashReport = CrashReport.forThrowable(var7, "Executing command block"); -@@ -164,12 +_,12 @@ +@@ -161,12 +_,12 @@ public abstract boolean isValid(); @@ -41,7 +41,7 @@ this.level = level; } -@@ -191,6 +_,7 @@ +@@ -188,6 +_,7 @@ @Override public void sendSystemMessage(Component message) { if (!this.closed) { @@ -49,7 +49,7 @@ BaseCommandBlock.this.lastOutput = Component.literal("[" + TIME_FORMAT.format(ZonedDateTime.now()) + "] ").append(message); BaseCommandBlock.this.onUpdated(this.level); } -@@ -200,5 +_,12 @@ +@@ -197,5 +_,12 @@ public void close() throws Exception { this.closed = true; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch index ff35481106fb..e2911c4452ff 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/BaseSpawner.java +++ b/net/minecraft/world/level/BaseSpawner.java -@@ -54,13 +_,15 @@ +@@ -52,13 +_,15 @@ public int maxNearbyEntities = 6; public int requiredPlayerRange = 16; public int spawnRange = 4; @@ -17,7 +17,7 @@ } public void clientTick(Level level, BlockPos pos) { -@@ -83,13 +_,19 @@ +@@ -81,13 +_,19 @@ } public void serverTick(ServerLevel level, BlockPos pos) { @@ -39,7 +39,7 @@ } else { boolean flag = false; RandomSource random = level.getRandom(); -@@ -127,6 +_,21 @@ +@@ -125,6 +_,21 @@ continue; } @@ -61,7 +61,7 @@ Entity entity = EntityType.loadEntityRecursive(valueInput, level, EntitySpawnReason.SPAWNER, entity1 -> { entity1.snapTo(vec3.x, vec3.y, vec3.z, entity1.getYRot(), entity1.getXRot()); return entity1; -@@ -160,9 +_,22 @@ +@@ -158,9 +_,22 @@ } nextSpawnData.getEquipment().ifPresent(mob::equip); @@ -85,7 +85,7 @@ this.delay(level, pos); return; } -@@ -173,7 +_,7 @@ +@@ -171,7 +_,7 @@ ((Mob)entity).spawnAnim(); } @@ -94,7 +94,7 @@ } } } -@@ -200,12 +_,14 @@ +@@ -198,12 +_,14 @@ } public void load(@Nullable Level level, BlockPos pos, ValueInput input) { @@ -112,7 +112,7 @@ this.spawnCount = input.getIntOr("SpawnCount", 4); this.maxNearbyEntities = input.getIntOr("MaxNearbyEntities", 6); this.requiredPlayerRange = input.getIntOr("RequiredPlayerRange", 16); -@@ -214,9 +_,19 @@ +@@ -212,9 +_,19 @@ } public void save(ValueOutput output) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch index 54547655bb53..aedc95f317ab 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/level/BlockGetter.java +++ b/net/minecraft/world/level/BlockGetter.java -@@ -32,6 +_,17 @@ +@@ -31,6 +_,17 @@ BlockState getBlockState(BlockPos pos); + // Paper start - if loaded util + @Nullable BlockState getBlockStateIfLoaded(BlockPos pos); + -+ default @Nullable net.minecraft.world.level.block.Block getBlockIfLoaded(BlockPos pos) { ++ default net.minecraft.world.level.block.@Nullable Block getBlockIfLoaded(BlockPos pos) { + BlockState type = this.getBlockStateIfLoaded(pos); + return type == null ? null : type.getBlock(); + } @@ -18,7 +18,7 @@ FluidState getFluidState(BlockPos pos); default int getLightEmission(BlockPos pos) { -@@ -65,10 +_,25 @@ +@@ -64,10 +_,25 @@ ); } @@ -32,7 +32,7 @@ + return clip(traverseContext, traversePos, null); + } + -+ default BlockHitResult clip(ClipContext traverseContext, BlockPos traversePos, @Nullable java.util.function.Predicate canCollide) { ++ default BlockHitResult clip(ClipContext traverseContext, BlockPos traversePos, java.util.function.@Nullable Predicate canCollide) { + // Paper end - Add predicate for blocks when raytracing + // Paper start - Prevent raytrace from loading chunks + BlockState blockState = this.getBlockStateIfLoaded(traversePos); @@ -48,7 +48,7 @@ Vec3 from = traverseContext.getFrom(); Vec3 to = traverseContext.getTo(); VoxelShape blockShape = traverseContext.getBlockShape(blockState, this, traversePos); -@@ -78,6 +_,18 @@ +@@ -77,6 +_,18 @@ double d = blockHitResult == null ? Double.MAX_VALUE : traverseContext.getFrom().distanceToSqr(blockHitResult.getLocation()); double d1 = blockHitResult1 == null ? Double.MAX_VALUE : traverseContext.getFrom().distanceToSqr(blockHitResult1.getLocation()); return d <= d1 ? blockHitResult : blockHitResult1; @@ -60,7 +60,7 @@ + return clip(context, (java.util.function.Predicate) null); + } + -+ default BlockHitResult clip(ClipContext context, @Nullable java.util.function.Predicate canCollide) { ++ default BlockHitResult clip(ClipContext context, java.util.function.@Nullable Predicate canCollide) { + // Paper end - Add predicate for blocks when raytracing + return (BlockHitResult) BlockGetter.traverseBlocks(context.getFrom(), context.getTo(), context, (raytrace1, blockposition) -> { + return this.clip(raytrace1, blockposition, canCollide); // CraftBukkit - moved into separate method // Paper - Add predicate for blocks when raytracing diff --git a/paper-server/patches/sources/net/minecraft/world/level/ClipContext.java.patch b/paper-server/patches/sources/net/minecraft/world/level/ClipContext.java.patch index fb5964b6390c..b5967d32843e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/ClipContext.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/ClipContext.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/ClipContext.java +++ b/net/minecraft/world/level/ClipContext.java -@@ -25,7 +_,7 @@ +@@ -26,7 +_,7 @@ private final CollisionContext collisionContext; public ClipContext(Vec3 from, Vec3 to, ClipContext.Block block, ClipContext.Fluid fluid, Entity entity) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockAndTintGetter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockAndTintGetter.java.patch index f4f7f574b6bb..282491c93436 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockAndTintGetter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockAndTintGetter.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/EmptyBlockAndTintGetter.java +++ b/net/minecraft/world/level/EmptyBlockAndTintGetter.java -@@ -39,6 +_,18 @@ +@@ -38,6 +_,18 @@ return Blocks.AIR.defaultBlockState(); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockGetter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockGetter.java.patch index d98e9785df76..690108e9358e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockGetter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockGetter.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/EmptyBlockGetter.java +++ b/net/minecraft/world/level/EmptyBlockGetter.java -@@ -17,6 +_,18 @@ +@@ -16,6 +_,18 @@ return null; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/EntityGetter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/EntityGetter.java.patch index edf6c3551026..3906f721e590 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/EntityGetter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/EntityGetter.java.patch @@ -10,10 +10,10 @@ + } + // Paper end - Affects Spawning API + - @Nullable - default Player getNearestPlayer(double x, double y, double z, double distance, @Nullable Predicate predicate) { + default @Nullable Player getNearestPlayer(double x, double y, double z, double distance, @Nullable Predicate predicate) { double d = -1.0; -@@ -89,6 +_,28 @@ + Player player = null; +@@ -88,6 +_,28 @@ return player; } @@ -39,10 +39,10 @@ + } + // Paper end + - @Nullable - default Player getNearestPlayer(Entity entity, double distance) { + default @Nullable Player getNearestPlayer(Entity entity, double distance) { return this.getNearestPlayer(entity.getX(), entity.getY(), entity.getZ(), distance, false); -@@ -100,6 +_,20 @@ + } +@@ -97,6 +_,20 @@ return this.getNearestPlayer(x, y, z, distance, predicate); } @@ -63,7 +63,7 @@ default boolean hasNearbyAlivePlayer(double x, double y, double z, double distance) { for (Player player : this.players()) { if (EntitySelector.NO_SPECTATORS.test(player) && EntitySelector.LIVING_ENTITY_STILL_ALIVE.test(player)) { -@@ -124,4 +_,11 @@ +@@ -120,4 +_,11 @@ return null; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch b/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch deleted file mode 100644 index 919f1b35d85d..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch +++ /dev/null @@ -1,314 +0,0 @@ ---- a/net/minecraft/world/level/GameRules.java -+++ b/net/minecraft/world/level/GameRules.java -@@ -36,6 +_,14 @@ - import org.slf4j.Logger; - - public class GameRules { -+ // Paper start - allow disabling gamerule limits -+ private static final boolean DISABLE_LIMITS = Boolean.getBoolean("paper.disableGameRuleLimits"); -+ -+ private static int limit(final int limit, final int unlimited) { -+ return DISABLE_LIMITS ? unlimited : limit; -+ } -+ // Paper end - allow disabling gamerule limits -+ - public static final int DEFAULT_RANDOM_TICK_SPEED = 3; - static final Logger LOGGER = LogUtils.getLogger(); - public static final Map, GameRules.Type> GAME_RULE_TYPES = Maps.newTreeMap(Comparator.comparing(entry -> entry.id)); -@@ -88,10 +_,10 @@ - "sendCommandFeedback", GameRules.Category.CHAT, GameRules.BooleanValue.create(true) - ); - public static final GameRules.Key RULE_REDUCEDDEBUGINFO = register( -- "reducedDebugInfo", GameRules.Category.MISC, GameRules.BooleanValue.create(false, (server, value) -> { -+ "reducedDebugInfo", GameRules.Category.MISC, GameRules.BooleanValue.create(false, (level, value) -> { // Paper - rename param to match changes - byte b = value.get() ? EntityEvent.REDUCED_DEBUG_INFO : EntityEvent.FULL_DEBUG_INFO; - -- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { -+ for (ServerPlayer serverPlayer : level.players()) { - serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, b)); - } - }) -@@ -115,8 +_,8 @@ - "doWeatherCycle", GameRules.Category.UPDATES, GameRules.BooleanValue.create(!SharedConstants.DEBUG_WORLD_RECREATE) - ); - public static final GameRules.Key RULE_LIMITED_CRAFTING = register( -- "doLimitedCrafting", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (server, value) -> { -- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { -+ "doLimitedCrafting", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (level, value) -> { // Paper - rename param to match changes -+ for (ServerPlayer serverPlayer : level.players()) { // Paper - per world gamerules - serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LIMITED_CRAFTING, value.get() ? 1.0F : 0.0F)); - } - }) -@@ -140,8 +_,8 @@ - "doInsomnia", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true) - ); - public static final GameRules.Key RULE_DO_IMMEDIATE_RESPAWN = register( -- "doImmediateRespawn", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (server, value) -> { -- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { -+ "doImmediateRespawn", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (level, value) -> { // Paper - rename param to match changes -+ for (ServerPlayer serverPlayer : level.players()) { // Paper - per world gamerules - serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.IMMEDIATE_RESPAWN, value.get() ? 1.0F : 0.0F)); - } - }) -@@ -212,13 +_,13 @@ - public static final GameRules.Key RULE_MINECART_MAX_SPEED = register( - "minecartMaxSpeed", - GameRules.Category.MISC, -- GameRules.IntegerValue.create(8, 1, 1000, FeatureFlagSet.of(FeatureFlags.MINECART_IMPROVEMENTS), (server, value) -> {}) -+ GameRules.IntegerValue.create(8, 1, limit(1000, Integer.MAX_VALUE), FeatureFlagSet.of(FeatureFlags.MINECART_IMPROVEMENTS), (server, value) -> {}) // Paper - allow disabling gamerule limits - ); - public static final GameRules.Key RULE_TNT_EXPLODES = register( - "tntExplodes", GameRules.Category.MISC, GameRules.BooleanValue.create(true) - ); - public static final GameRules.Key RULE_LOCATOR_BAR = register( -- "locatorBar", GameRules.Category.PLAYER, GameRules.BooleanValue.create(true, (server, value) -> server.getAllLevels().forEach(level -> { -+ "locatorBar", GameRules.Category.PLAYER, GameRules.BooleanValue.create(true, (minecraftServer, value) -> java.util.Optional.of(minecraftServer).ifPresent(level -> { // Paper - per world game rules - ServerWaypointManager waypointManager = level.getWaypointManager(); - if (value.get()) { - level.players().forEach(waypointManager::updatePlayer); -@@ -232,7 +_,11 @@ - "allowEnteringNetherUsingPortals", GameRules.Category.MISC, GameRules.BooleanValue.create(true) - ); - public static final GameRules.Key RULE_SPAWN_MONSTERS = register( -- "spawnMonsters", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true, (server, value) -> server.updateMobSpawningFlags()) -+ // Paper start - per world gamerules -+ "spawnMonsters", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true, (level, value) -> { -+ level.setSpawnSettings(level.serverLevelData.getDifficulty() != net.minecraft.world.Difficulty.PEACEFUL && level.getGameRules().getBoolean(GameRules.RULE_SPAWN_MONSTERS)); -+ }) -+ // Paper end - per world gamerules - ); - public static final GameRules.Key RULE_COMMAND_BLOCKS_ENABLED = register( - "commandBlocksEnabled", GameRules.Category.MISC, GameRules.BooleanValue.create(true) -@@ -242,6 +_,7 @@ - ); - private final Map, GameRules.Value> rules; - private final FeatureFlagSet enabledFeatures; -+ private final GameRules.Value[] gameruleArray; // Paper - Perf: Use array for gamerule storage - - public static > GameRules.Type getType(GameRules.Key key) { - return (GameRules.Type)GAME_RULE_TYPES.get(key); -@@ -289,10 +_,21 @@ - private GameRules(Map, GameRules.Value> rules, FeatureFlagSet enabledFeatures) { - this.rules = rules; - this.enabledFeatures = enabledFeatures; -+ -+ // Paper start - Perf: Use array for gamerule storage -+ int arraySize = GameRules.Key.lastGameRuleIndex + 1; -+ GameRules.Value[] values = new GameRules.Value[arraySize]; -+ -+ for (Entry, GameRules.Value> entry : rules.entrySet()) { -+ values[entry.getKey().gameRuleIndex] = entry.getValue(); -+ } -+ -+ this.gameruleArray = values; -+ // Paper end - Perf: Use array for gamerule storage - } - - public > T getRule(GameRules.Key key) { -- T value = (T)this.rules.get(key); -+ T value = key == null ? null : (T) this.gameruleArray[key.gameRuleIndex]; // Paper - Perf: Use array for gamerule storage - if (value == null) { - throw new IllegalArgumentException("Tried to access invalid game rule"); - } else { -@@ -333,13 +_,13 @@ - } - } - -- public void assignFrom(GameRules rules, @Nullable MinecraftServer server) { -- rules.rules.keySet().forEach(key -> this.assignCap((GameRules.Key)key, rules, server)); -+ public void assignFrom(GameRules rules, @Nullable net.minecraft.server.level.ServerLevel level) { // CraftBukkit - per-world -+ rules.rules.keySet().forEach(key -> this.assignCap((GameRules.Key)key, rules, level)); // CraftBukkit - per-world - } - -- private > void assignCap(GameRules.Key key, GameRules rules, @Nullable MinecraftServer server) { -+ private > void assignCap(GameRules.Key key, GameRules rules, @Nullable net.minecraft.server.level.ServerLevel level) { // CraftBukkit - per-world - T rule = rules.getRule(key); -- this.getRule(key).setFrom(rule, server); -+ this.getRule(key).setFrom(rule, level); // CraftBukkit - per-world - } - - public boolean getBoolean(GameRules.Key key) { -@@ -354,7 +_,7 @@ - private boolean value; - - private static GameRules.Type create( -- boolean defaultValue, BiConsumer changeListener, FeatureFlagSet requiredFeatures -+ boolean defaultValue, BiConsumer changeListener, FeatureFlagSet requiredFeatures // Paper - per world gamerules - ) { - return new GameRules.Type<>( - BoolArgumentType::bool, -@@ -366,7 +_,7 @@ - ); - } - -- static GameRules.Type create(boolean defaultValue, BiConsumer changeListener) { -+ static GameRules.Type create(boolean defaultValue, BiConsumer changeListener) { // Paper - per world gamerules - return new GameRules.Type<>( - BoolArgumentType::bool, - type -> new GameRules.BooleanValue(type, defaultValue), -@@ -387,17 +_,21 @@ - } - - @Override -- protected void updateFromArgument(CommandContext context, String paramName) { -- this.value = BoolArgumentType.getBool(context, paramName); -+ // Paper start - Add WorldGameRuleChangeEvent -+ protected void updateFromArgument(CommandContext context, String paramName, GameRules.Key gameRuleKey) { -+ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(context.getSource().getBukkitWorld(), context.getSource().getBukkitSender(), org.bukkit.GameRule.getByName(gameRuleKey.toString()), String.valueOf(BoolArgumentType.getBool(context, paramName))); -+ if (!event.callEvent()) return; -+ this.value = Boolean.parseBoolean(event.getValue()); -+ // Paper end - Add WorldGameRuleChangeEvent - } - - public boolean get() { - return this.value; - } - -- public void set(boolean value, @Nullable MinecraftServer server) { -+ public void set(boolean value, @Nullable net.minecraft.server.level.ServerLevel level) { // CraftBukkit - per-world - this.value = value; -- this.onChanged(server); -+ this.onChanged(level); // CraftBukkit - per-world - } - - @Override -@@ -426,9 +_,9 @@ - } - - @Override -- public void setFrom(GameRules.BooleanValue value, @Nullable MinecraftServer server) { -+ public void setFrom(GameRules.BooleanValue value, @Nullable net.minecraft.server.level.ServerLevel level) { // CraftBukkit - per-world - this.value = value.value; -- this.onChanged(server); -+ this.onChanged(level); // CraftBukkit - per-world - } - } - -@@ -466,7 +_,7 @@ - public static class IntegerValue extends GameRules.Value { - private int value; - -- private static GameRules.Type create(int defaultValue, BiConsumer changeListener) { -+ private static GameRules.Type create(int defaultValue, BiConsumer changeListener) { // CraftBukkit - per-world - return new GameRules.Type<>( - IntegerArgumentType::integer, - type -> new GameRules.IntegerValue(type, defaultValue), -@@ -478,7 +_,7 @@ - } - - static GameRules.Type create( -- int defaultValue, int min, int max, FeatureFlagSet requiredFeatures, BiConsumer changeListener -+ int defaultValue, int min, int max, FeatureFlagSet requiredFeatures, BiConsumer changeListener // CraftBukkit - per-world - ) { - return new GameRules.Type<>( - () -> IntegerArgumentType.integer(min, max), -@@ -500,17 +_,21 @@ - } - - @Override -- protected void updateFromArgument(CommandContext context, String paramName) { -- this.value = IntegerArgumentType.getInteger(context, paramName); -+ // Paper start - Add WorldGameRuleChangeEvent -+ protected void updateFromArgument(CommandContext context, String paramName, GameRules.Key gameRuleKey) { -+ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(context.getSource().getBukkitWorld(), context.getSource().getBukkitSender(), org.bukkit.GameRule.getByName(gameRuleKey.toString()), String.valueOf(IntegerArgumentType.getInteger(context, paramName))); -+ if (!event.callEvent()) return; -+ this.value = Integer.parseInt(event.getValue()); -+ // Paper end - Add WorldGameRuleChangeEvent - } - - public int get() { - return this.value; - } - -- public void set(int value, @Nullable MinecraftServer server) { -+ public void set(int value, @Nullable net.minecraft.server.level.ServerLevel level) { // CraftBukkit - per-world - this.value = value; -- this.onChanged(server); -+ this.onChanged(level); // CraftBukkit - per-world - } - - @Override -@@ -561,13 +_,17 @@ - } - - @Override -- public void setFrom(GameRules.IntegerValue value, @Nullable MinecraftServer server) { -+ public void setFrom(GameRules.IntegerValue value, @Nullable net.minecraft.server.level.ServerLevel level) { // CraftBukkit - per-world - this.value = value.value; -- this.onChanged(server); -+ this.onChanged(level); // CraftBukkit - per-world - } - } - - public static final class Key> { -+ // Paper start - Perf: Use array for gamerule storage -+ public static int lastGameRuleIndex = 0; -+ public final int gameRuleIndex = lastGameRuleIndex++; -+ // Paper end - Perf: Use array for gamerule storage - final String id; - private final GameRules.Category category; - -@@ -607,7 +_,7 @@ - public static class Type> { - final Supplier> argument; - private final Function, T> constructor; -- final BiConsumer callback; -+ final BiConsumer callback; // CraftBukkit - per-world - private final GameRules.VisitorCaller visitorCaller; - final Class valueClass; - final FeatureFlagSet requiredFeatures; -@@ -615,7 +_,7 @@ - Type( - Supplier> argument, - Function, T> constructor, -- BiConsumer callback, -+ BiConsumer callback, // CraftBukkit - per-world - GameRules.VisitorCaller visitorCaller, - Class valueClass, - FeatureFlagSet requiredFeatures -@@ -643,6 +_,12 @@ - public FeatureFlagSet requiredFeatures() { - return this.requiredFeatures; - } -+ // Paper start - expose FeatureElement wrapper for GameRules.Type. -+ // Chosen over simply adding this to the inheritance to avoid reobf issues with spigot... -+ public net.minecraft.world.flag.FeatureElement asFeatureElement() { -+ return GameRules.Type.this::requiredFeatures; -+ } -+ // Paper end - expose FeatureElement wrapper for GameRules.Type. - } - - public abstract static class Value> { -@@ -652,16 +_,16 @@ - this.type = type; - } - -- protected abstract void updateFromArgument(CommandContext context, String paramName); -+ protected abstract void updateFromArgument(CommandContext context, String paramName, GameRules.Key gameRuleKey); // Paper - Add WorldGameRuleChangeEvent - -- public void setFromArgument(CommandContext context, String paramName) { -- this.updateFromArgument(context, paramName); -- this.onChanged(context.getSource().getServer()); -+ public void setFromArgument(CommandContext context, String paramName, GameRules.Key gameRuleKey) { // Paper - Add WorldGameRuleChangeEvent -+ this.updateFromArgument(context, paramName, gameRuleKey); // Paper - Add WorldGameRuleChangeEvent -+ this.onChanged(context.getSource().getLevel()); // CraftBukkit - per-world - } - -- public void onChanged(@Nullable MinecraftServer server) { -- if (server != null) { -- this.type.callback.accept(server, this.getSelf()); -+ public void onChanged(@Nullable net.minecraft.server.level.ServerLevel level) { // CraftBukkit - per-world -+ if (level != null) { // CraftBukkit - per-world -+ this.type.callback.accept(level, this.getSelf()); // CraftBukkit - per-world - } - } - -@@ -680,7 +_,7 @@ - - protected abstract T copy(); - -- public abstract void setFrom(T value, @Nullable MinecraftServer server); -+ public abstract void setFrom(T value, @Nullable net.minecraft.server.level.ServerLevel level); // CraftBukkit - per-world - } - - interface VisitorCaller> { diff --git a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch index 6aba2789a38b..8eaee59b7567 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -85,6 +_,16 @@ - import net.minecraft.world.scores.Scoreboard; import org.apache.commons.lang3.mutable.MutableBoolean; + import org.jspecify.annotations.Nullable; +// CraftBukkit start +import java.util.Map; @@ -24,7 +24,7 @@ + // CraftBukkit start + private final CraftWorld world; + public net.kyori.adventure.util.TriState pvpMode = net.kyori.adventure.util.TriState.NOT_SET; -+ public @Nullable org.bukkit.generator.ChunkGenerator generator; ++ public org.bukkit.generator.@Nullable ChunkGenerator generator; + + public boolean captureBlockStates = false; + public boolean captureTreeGeneration = false; @@ -81,8 +81,8 @@ long biomeZoomSeed, - int maxChainedNeighborUpdates + int maxChainedNeighborUpdates, -+ @Nullable org.bukkit.generator.ChunkGenerator generator, // Paper -+ @Nullable org.bukkit.generator.BiomeProvider biomeProvider, // Paper ++ org.bukkit.generator.@Nullable ChunkGenerator generator, // Paper ++ org.bukkit.generator.@Nullable BiomeProvider biomeProvider, // Paper + org.bukkit.World.Environment environment, // Paper + java.util.function.Function paperWorldConfigCreator // Paper - create paper world config @@ -148,7 +148,7 @@ @Override public boolean isClientSide() { return this.isClientSide; -@@ -162,8 +_,15 @@ +@@ -161,8 +_,15 @@ return null; } @@ -165,7 +165,7 @@ } public static boolean isInSpawnableBounds(BlockPos pos) { -@@ -171,21 +_,86 @@ +@@ -170,21 +_,86 @@ } private static boolean isInWorldBoundsHorizontal(BlockPos pos) { @@ -255,9 +255,9 @@ + } + // Paper end - @Nullable @Override -@@ -205,6 +_,22 @@ + public @Nullable ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) { +@@ -203,6 +_,22 @@ @Override public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags, int recursionLeft) { @@ -280,7 +280,7 @@ if (this.isOutsideBuildHeight(pos)) { return false; } else if (!this.isClientSide() && this.isDebug()) { -@@ -212,11 +_,31 @@ +@@ -210,11 +_,31 @@ } else { LevelChunk chunkAt = this.getChunkAt(pos); Block block = state.getBlock(); @@ -312,7 +312,7 @@ if (blockState1 == state) { if (blockState != blockState1) { this.setBlocksDirty(pos, blockState, blockState1); -@@ -244,12 +_,68 @@ +@@ -242,12 +_,68 @@ this.updatePOIOnBlockStateChange(pos, blockState, blockState1); } @@ -381,7 +381,7 @@ public void updatePOIOnBlockStateChange(BlockPos pos, BlockState oldState, BlockState newState) { } -@@ -266,13 +_,31 @@ +@@ -264,13 +_,31 @@ return false; } else { FluidState fluidState = this.getFluidState(pos); @@ -416,7 +416,7 @@ } boolean flag = this.setBlock(pos, fluidState.createLegacyBlock(), Block.UPDATE_ALL, recursionLeft); -@@ -338,10 +_,18 @@ +@@ -336,10 +_,18 @@ @Override public BlockState getBlockState(BlockPos pos) { @@ -436,7 +436,7 @@ return chunk.getBlockState(pos); } } -@@ -454,31 +_,47 @@ +@@ -452,31 +_,47 @@ this.pendingBlockEntityTickers.clear(); } @@ -492,10 +492,10 @@ public boolean shouldTickDeath(Entity entity) { return true; -@@ -603,6 +_,12 @@ - @Nullable +@@ -600,6 +_,12 @@ + @Override - public BlockEntity getBlockEntity(BlockPos pos) { + public @Nullable BlockEntity getBlockEntity(BlockPos pos) { + // Paper start - Perf: Optimize capturedTileEntities lookup + net.minecraft.world.level.block.entity.BlockEntity blockEntity; + if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(pos)) != null) { @@ -505,7 +505,7 @@ if (this.isOutsideBuildHeight(pos)) { return null; } else { -@@ -615,6 +_,12 @@ +@@ -612,6 +_,12 @@ public void setBlockEntity(BlockEntity blockEntity) { BlockPos blockPos = blockEntity.getBlockPos(); if (!this.isOutsideBuildHeight(blockPos)) { @@ -518,7 +518,7 @@ this.getChunkAt(blockPos).addAndRegisterBlockEntity(blockEntity); } } -@@ -1030,7 +_,8 @@ +@@ -1021,7 +_,8 @@ BLOCK("block"), MOB("mob"), TNT("tnt"), diff --git a/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch b/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch index ff24d69ed4ea..1985f297a44e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/LevelAccessor.java +++ b/net/minecraft/world/level/LevelAccessor.java -@@ -103,4 +_,6 @@ +@@ -102,4 +_,6 @@ default void gameEvent(ResourceKey gameEvent, BlockPos pos, GameEvent.Context context) { this.gameEvent(this.registryAccess().lookupOrThrow(Registries.GAME_EVENT).getOrThrow(gameEvent), pos, context); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/LevelReader.java.patch b/paper-server/patches/sources/net/minecraft/world/level/LevelReader.java.patch index dcab01a22675..cdaaa11078c6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/LevelReader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/LevelReader.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/LevelReader.java +++ b/net/minecraft/world/level/LevelReader.java -@@ -27,6 +_,9 @@ - @Nullable - ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk); +@@ -26,6 +_,9 @@ + public interface LevelReader extends BlockAndTintGetter, CollisionGetter, SignalGetter, BiomeManager.NoiseBiomeSource { + @Nullable ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk); + @Nullable ChunkAccess getChunkIfLoadedImmediately(int x, int z); // Paper - ifLoaded api (we need this since current impl blocks if the chunk is loading) + @Nullable default ChunkAccess getChunkIfLoadedImmediately(BlockPos pos) { return this.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4);} diff --git a/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch index d126b117ae13..a132dab9b9ad 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch @@ -6,7 +6,7 @@ } + + // CraftBukkit start -+ default boolean addFreshEntity(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ default boolean addFreshEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason reason) { + return false; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch index 56385b437d02..8310777e293c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch @@ -168,8 +168,8 @@ + return success ? PreSpawnStatus.SUCCESS : PreSpawnStatus.FAIL; // Paper - PreCreatureSpawnEvent } - @Nullable -@@ -269,6 +_,7 @@ + private static @Nullable Mob getMobForSpawn(ServerLevel level, EntityType entityType) { +@@ -268,6 +_,7 @@ LOGGER.warn("Can't spawn entity of type: {}", BuiltInRegistries.ENTITY_TYPE.getKey(entityType)); } catch (Exception var4) { LOGGER.warn("Failed to create mob", (Throwable)var4); @@ -177,7 +177,7 @@ } return null; -@@ -375,6 +_,7 @@ +@@ -374,6 +_,7 @@ entity = spawnerData.type().create(level.getLevel(), EntitySpawnReason.NATURAL); } catch (Exception var27) { LOGGER.warn("Failed to create mob", (Throwable)var27); @@ -185,7 +185,7 @@ continue; } -@@ -389,7 +_,7 @@ +@@ -388,7 +_,7 @@ spawnGroupData = mob.finalizeSpawn( level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CHUNK_GENERATION, spawnGroupData ); @@ -194,7 +194,7 @@ flag = true; } } -@@ -509,8 +_,10 @@ +@@ -506,8 +_,10 @@ return this.unmodifiableMobCategoryCounts; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch b/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch index b58ac2ad2cdd..a88e367251e8 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -35,6 +_,14 @@ - import net.minecraft.world.phys.HitResult; +@@ -36,6 +_,14 @@ import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; +// CraftBukkit start +import net.minecraft.world.entity.boss.EnderDragonPart; @@ -178,7 +178,7 @@ + // CraftBukkit start - TNTPrimeEvent + BlockState state = this.level.getBlockState(blockPos); + Block block = state.getBlock(); -+ if (level.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES) && block instanceof net.minecraft.world.level.block.TntBlock) { ++ if (level.getGameRules().get(GameRules.TNT_EXPLODES) && block instanceof net.minecraft.world.level.block.TntBlock) { + Entity sourceEntity = this.source == null ? null : this.source; + BlockPos sourceBlock = sourceEntity == null ? BlockPos.containing(this.center) : null; + if (!CraftEventFactory.callTNTPrimeEvent(this.level, blockPos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.EXPLOSION, sourceEntity, sourceBlock)) { @@ -204,7 +204,7 @@ } } } -@@ -328,4 +_,86 @@ +@@ -322,4 +_,86 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/StructureManager.java.patch b/paper-server/patches/sources/net/minecraft/world/level/StructureManager.java.patch index a62cc178893f..690024da9c8e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/StructureManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/StructureManager.java.patch @@ -15,7 +15,7 @@ Builder builder = ImmutableList.builder(); for (Entry entry : allReferences.entrySet()) { -@@ -114,14 +_,29 @@ +@@ -113,14 +_,29 @@ } public StructureStart getStructureWithPieceAt(BlockPos pos, HolderSet structures) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch index d04da8751dac..9d1bfb3fb2ca 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/TicketStorage.java +++ b/net/minecraft/world/level/TicketStorage.java -@@ -179,7 +_,7 @@ +@@ -177,7 +_,7 @@ } private static boolean isTicketSameTypeAndLevel(Ticket first, Ticket second) { @@ -9,7 +9,7 @@ } public int getTicketLevelAt(long chunkPos, boolean requireSimulation) { -@@ -301,7 +_,7 @@ +@@ -298,7 +_,7 @@ } public void deactivateTicketsOnClosing() { @@ -18,7 +18,7 @@ } public void removeTicketIf(TicketStorage.TicketPredicate predicate, @Nullable Long2ObjectOpenHashMap> tickets) { -@@ -411,4 +_,20 @@ +@@ -408,4 +_,20 @@ public interface TicketPredicate { boolean test(Ticket ticket, long chunkPos); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/biome/MobSpawnSettings.java.patch b/paper-server/patches/sources/net/minecraft/world/level/biome/MobSpawnSettings.java.patch index 8f76166ac20a..1c762eb3f28b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/biome/MobSpawnSettings.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/biome/MobSpawnSettings.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/biome/MobSpawnSettings.java +++ b/net/minecraft/world/level/biome/MobSpawnSettings.java -@@ -70,9 +_,33 @@ +@@ -69,9 +_,33 @@ } public static class Builder { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch index ce188d7f0471..01c89a864918 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BambooStalkBlock.java +++ b/net/minecraft/world/level/block/BambooStalkBlock.java -@@ -120,9 +_,9 @@ +@@ -119,9 +_,9 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (state.getValue(STAGE) == 0) { @@ -12,7 +12,7 @@ this.growBamboo(state, level, pos, random, i); } } -@@ -158,7 +_,7 @@ +@@ -157,7 +_,7 @@ public boolean isValidBonemealTarget(LevelReader level, BlockPos pos, BlockState state) { int heightAboveUpToMax = this.getHeightAboveUpToMax(level, pos); int heightBelowUpToMax = this.getHeightBelowUpToMax(level, pos); @@ -21,7 +21,7 @@ } @Override -@@ -176,7 +_,7 @@ +@@ -175,7 +_,7 @@ for (int i2 = 0; i2 < i1; i2++) { BlockPos blockPos = pos.above(heightAboveUpToMax); BlockState blockState = level.getBlockState(blockPos); @@ -30,7 +30,7 @@ return; } -@@ -191,27 +_,38 @@ +@@ -190,27 +_,38 @@ BlockPos blockPos = pos.below(2); BlockState blockState1 = level.getBlockState(blockPos); BambooLeaves bambooLeaves = BambooLeaves.NONE; @@ -74,7 +74,7 @@ i++; } -@@ -221,7 +_,7 @@ +@@ -220,7 +_,7 @@ protected int getHeightBelowUpToMax(BlockGetter level, BlockPos pos) { int i = 0; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BeaconBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BeaconBlock.java.patch index 060ec697d016..07ff52d43be4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BeaconBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BeaconBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BeaconBlock.java +++ b/net/minecraft/world/level/block/BeaconBlock.java -@@ -46,8 +_,7 @@ +@@ -45,8 +_,7 @@ @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch index d8818f0b904d..0019708d387c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BedBlock.java +++ b/net/minecraft/world/level/block/BedBlock.java -@@ -93,7 +_,7 @@ +@@ -92,7 +_,7 @@ } BedRule bedRule = level.environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos); @@ -9,7 +9,7 @@ bedRule.errorMessage().ifPresent(component -> player.displayClientMessage(component, true)); level.removeBlock(pos, false); BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); -@@ -105,22 +_,56 @@ +@@ -104,22 +_,56 @@ level.explode(null, level.damageSources().badRespawnPointExplosion(center), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); return InteractionResult.SUCCESS_SERVER; } else if (state.getValue(OCCUPIED)) { @@ -67,7 +67,7 @@ private boolean kickVillagerOutOfBed(Level level, BlockPos pos) { List entitiesOfClass = level.getEntitiesOfClass(Villager.class, new AABB(pos), LivingEntity::isSleeping); if (entitiesOfClass.isEmpty()) { -@@ -299,6 +_,11 @@ +@@ -297,6 +_,11 @@ if (!level.isClientSide()) { BlockPos blockPos = pos.relative(state.getValue(FACING)); level.setBlock(blockPos, state.setValue(PART, BedPart.HEAD), Block.UPDATE_ALL); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch index d3b3ba927b8a..c1d513fdc879 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BigDripleafBlock.java +++ b/net/minecraft/world/level/block/BigDripleafBlock.java -@@ -129,7 +_,7 @@ +@@ -126,7 +_,7 @@ @Override protected void onProjectileHit(Level level, BlockState state, BlockHitResult hit, Projectile projectile) { @@ -9,7 +9,7 @@ } @Override -@@ -192,9 +_,23 @@ +@@ -189,9 +_,23 @@ @Override protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean pastEdges) { @@ -34,7 +34,7 @@ } } } -@@ -206,9 +_,9 @@ +@@ -203,9 +_,9 @@ } else { Tilt tilt = state.getValue(TILT); if (tilt == Tilt.UNSTABLE) { @@ -46,7 +46,7 @@ } else if (tilt == Tilt.FULL) { resetTilt(state, level, pos); } -@@ -231,8 +_,11 @@ +@@ -228,8 +_,11 @@ return entity.onGround() && entity.position().y > pos.getY() + 0.6875F; } @@ -60,7 +60,7 @@ if (sound != null) { playTiltSound(level, pos, sound); } -@@ -244,18 +_,26 @@ +@@ -241,18 +_,26 @@ } private static void resetTilt(BlockState state, Level level, BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BlastFurnaceBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BlastFurnaceBlock.java.patch index 11ef775f5eaf..26f43d832a90 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BlastFurnaceBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BlastFurnaceBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlastFurnaceBlock.java +++ b/net/minecraft/world/level/block/BlastFurnaceBlock.java -@@ -45,8 +_,7 @@ +@@ -44,8 +_,7 @@ @Override protected void openContainer(Level level, BlockPos pos, Player player) { BlockEntity blockEntity = level.getBlockEntity(pos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch index d73bf195b882..436493129718 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch @@ -48,10 +48,10 @@ + this != Blocks.JIGSAW; + } + // Paper end - Protect Bedrock and End Portal/Frames from being destroyed - @Nullable - private Item item; + private @Nullable Item item; private static final int CACHE_SIZE = 256; -@@ -367,6 +_,27 @@ + private static final ThreadLocal> OCCLUSION_CACHE = ThreadLocal.withInitial(() -> { +@@ -366,6 +_,27 @@ return state.getDrops(builder); } @@ -79,7 +79,7 @@ public static void dropResources(BlockState state, Level level, BlockPos pos) { if (level instanceof ServerLevel) { getDrops(state, (ServerLevel)level, pos, null).forEach(stack -> popResource(level, pos, stack)); -@@ -382,9 +_,14 @@ +@@ -381,9 +_,14 @@ } public static void dropResources(BlockState state, Level level, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool) { @@ -95,8 +95,8 @@ } } -@@ -415,13 +_,25 @@ - if (level instanceof ServerLevel serverLevel && !stack.isEmpty() && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { +@@ -414,13 +_,25 @@ + if (level instanceof ServerLevel serverLevel && !stack.isEmpty() && serverLevel.getGameRules().get(GameRules.BLOCK_DROPS)) { ItemEntity itemEntity = itemEntitySupplier.get(); itemEntity.setDefaultPickUpDelay(); - level.addFreshEntity(itemEntity); @@ -115,15 +115,15 @@ + popExperience(level, pos, amount, null); + } + -+ public void popExperience(ServerLevel level, BlockPos pos, int amount, @Nullable net.minecraft.world.entity.Entity entity) { ++ public void popExperience(ServerLevel level, BlockPos pos, int amount, net.minecraft.world.entity.@Nullable Entity entity) { + // Paper end - add entity parameter - if (level.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { + if (level.getGameRules().get(GameRules.BLOCK_DROPS)) { - ExperienceOrb.award(level, Vec3.atCenterOf(pos), amount); + ExperienceOrb.awardWithDirection(level, Vec3.atCenterOf(pos), net.minecraft.world.phys.Vec3.ZERO, amount, org.bukkit.entity.ExperienceOrb.SpawnReason.BLOCK_BREAK, entity, null); // Paper } } -@@ -440,10 +_,19 @@ +@@ -438,10 +_,19 @@ return this.defaultBlockState(); } @@ -145,7 +145,7 @@ } public void setPlacedBy(Level level, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { -@@ -582,12 +_,20 @@ +@@ -580,12 +_,20 @@ return this.builtInRegistryHolder; } @@ -169,7 +169,7 @@ record ShapePairKey(VoxelShape first, VoxelShape second) { @Override -@@ -603,6 +_,7 @@ +@@ -601,6 +_,7 @@ @Retention(RetentionPolicy.CLASS) @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.TYPE_USE}) diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BrewingStandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BrewingStandBlock.java.patch index ad6d41474d16..f2dadd1ca3a2 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BrewingStandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BrewingStandBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BrewingStandBlock.java +++ b/net/minecraft/world/level/block/BrewingStandBlock.java -@@ -64,8 +_,7 @@ +@@ -63,8 +_,7 @@ @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch index c5b619fdead2..ba3a3eb68533 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch @@ -11,7 +11,7 @@ } super.entityInside(state, level, pos, entity, effectApplier, pastEdges); -@@ -220,6 +_,11 @@ +@@ -219,6 +_,11 @@ && projectile.mayInteract(serverLevel, blockPos) && !state.getValue(LIT) && !state.getValue(WATERLOGGED)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch index 08c14d335c6a..1536368b6288 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CarvedPumpkinBlock.java +++ b/net/minecraft/world/level/block/CarvedPumpkinBlock.java -@@ -94,6 +_,7 @@ +@@ -87,6 +_,7 @@ CopperGolem copperGolem = EntityType.COPPER_GOLEM.create(level, EntitySpawnReason.TRIGGERED); if (copperGolem != null) { spawnGolemInWorld(level, blockPatternMatch2, copperGolem, blockPatternMatch2.getBlock(0, 0, 0).getPos()); @@ -8,7 +8,7 @@ this.replaceCopperBlockWithChest(level, blockPatternMatch2); copperGolem.spawn(this.getWeatherStateFromPattern(blockPatternMatch2)); } -@@ -112,9 +_,22 @@ +@@ -105,9 +_,22 @@ } private static void spawnGolemInWorld(Level level, BlockPattern.BlockPatternMatch patternMatch, Entity golem, BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch index 3a77d4216c42..5acb1aad3f25 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/CeilingHangingSignBlock.java +++ b/net/minecraft/world/level/block/CeilingHangingSignBlock.java -@@ -166,6 +_,6 @@ - @Nullable +@@ -165,6 +_,6 @@ + @Override - public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { + public @Nullable BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { - return createTickerHelper(blockEntityType, BlockEntityType.HANGING_SIGN, SignBlockEntity::tick); + return null; // CraftBukkit - remove unnecessary sign ticking } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch index e7dc8cd5ffca..e492e02c72d0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch @@ -6,10 +6,10 @@ final Container container = new CompoundContainer(first, second); - return Optional.of(new MenuProvider() { + return Optional.of(DoubleInventory.wrap(new MenuProvider() { // CraftBukkit - wrap for identification - @Nullable @Override - public AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { -@@ -112,10 +_,10 @@ + public @Nullable AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { + if (first.canOpen(player) && second.canOpen(player)) { +@@ -111,10 +_,10 @@ if (first.hasCustomName()) { return first.getDisplayName(); } else { @@ -22,7 +22,7 @@ } @Override -@@ -129,6 +_,34 @@ +@@ -128,6 +_,34 @@ } }; @@ -57,7 +57,7 @@ @Override public MapCodec codec() { return CODEC; -@@ -257,8 +_,7 @@ +@@ -255,8 +_,7 @@ protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { if (level instanceof ServerLevel serverLevel) { MenuProvider menuProvider = this.getMenuProvider(state, level, pos); @@ -67,10 +67,10 @@ player.awardStat(this.getOpenChestStat()); PiglinAi.angerNearbyPiglins(serverLevel, player, true); } -@@ -297,7 +_,14 @@ - @Nullable +@@ -293,7 +_,14 @@ + @Override - public MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos) { + public @Nullable MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos) { - return this.combine(state, level, pos, false).apply(MENU_PROVIDER_COMBINER).orElse(null); + // CraftBukkit start + return this.getMenuProvider(state, level, pos, false); @@ -83,7 +83,7 @@ } public static DoubleBlockCombiner.Combiner opennessCombiner(final LidBlockEntity lid) { -@@ -340,6 +_,11 @@ +@@ -335,6 +_,11 @@ } private static boolean isCatSittingOnChest(LevelAccessor level, BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch index e48da683f8f1..f1fb477ea819 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch @@ -13,7 +13,7 @@ } } } -@@ -116,7 +_,7 @@ +@@ -115,7 +_,7 @@ @Override public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch index 8e9d308cadec..c238837a1b3d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ComparatorBlock.java +++ b/net/minecraft/world/level/block/ComparatorBlock.java -@@ -168,8 +_,18 @@ +@@ -167,8 +_,18 @@ boolean shouldTurnOn = this.shouldTurnOn(level, pos, state); boolean poweredValue = state.getValue(POWERED); if (poweredValue && !shouldTurnOn) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch index 532af18fbb92..853254707bcf 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CrafterBlock.java +++ b/net/minecraft/world/level/block/CrafterBlock.java -@@ -152,6 +_,13 @@ +@@ -151,6 +_,13 @@ } else { RecipeHolder recipeHolder = potentialResults.get(); ItemStack itemStack = recipeHolder.value().assemble(var11, level.registryAccess()); @@ -14,7 +14,7 @@ if (itemStack.isEmpty()) { level.levelEvent(LevelEvent.SOUND_CRAFTER_FAIL, pos, 0); } else { -@@ -186,7 +_,25 @@ +@@ -185,7 +_,25 @@ Container containerAt = HopperBlockEntity.getContainerAt(level, pos.relative(direction)); ItemStack itemStack = stack.copy(); if (containerAt != null && (containerAt instanceof CrafterBlockEntity || stack.getCount() > containerAt.getMaxStackSize(stack))) { @@ -40,7 +40,7 @@ ItemStack itemStack1 = itemStack.copyWithCount(1); ItemStack itemStack2 = HopperBlockEntity.addItem(crafter, containerAt, itemStack1, direction.getOpposite()); if (!itemStack2.isEmpty()) { -@@ -196,7 +_,25 @@ +@@ -195,7 +_,25 @@ itemStack.shrink(1); } } else if (containerAt != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch index 587f3aac91c7..8f6e73e7d302 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch @@ -41,9 +41,9 @@ @Override protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean pastEdges) { -- if (level instanceof ServerLevel serverLevel && entity instanceof Ravager && serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (level instanceof ServerLevel serverLevel && entity instanceof Ravager && serverLevel.getGameRules().get(GameRules.MOB_GRIEFING)) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent -+ if (level instanceof ServerLevel serverLevel && entity instanceof Ravager && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, Blocks.AIR.defaultBlockState(), !serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit ++ if (level instanceof ServerLevel serverLevel && entity instanceof Ravager && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, Blocks.AIR.defaultBlockState(), !serverLevel.getGameRules().get(GameRules.MOB_GRIEFING))) { // CraftBukkit serverLevel.destroyBlock(pos, true, entity); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch index 1c008e5b842c..260767c050ff 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DecoratedPotBlock.java +++ b/net/minecraft/world/level/block/DecoratedPotBlock.java -@@ -210,6 +_,11 @@ +@@ -209,6 +_,11 @@ protected void onProjectileHit(Level level, BlockState state, BlockHitResult hit, Projectile projectile) { BlockPos blockPos = hit.getBlockPos(); if (level instanceof ServerLevel serverLevel && projectile.mayInteract(serverLevel, blockPos) && projectile.mayBreak(serverLevel)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DoorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DoorBlock.java.patch index 18fcad808192..77f0acfcdd6f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DoorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DoorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DoorBlock.java +++ b/net/minecraft/world/level/block/DoorBlock.java -@@ -222,9 +_,22 @@ +@@ -221,9 +_,22 @@ @Override protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DoublePlantBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DoublePlantBlock.java.patch index bf674349fbd8..0d4725287a6d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DoublePlantBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DoublePlantBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DoublePlantBlock.java +++ b/net/minecraft/world/level/block/DoublePlantBlock.java -@@ -110,11 +_,16 @@ +@@ -109,11 +_,16 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/EndGatewayBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/EndGatewayBlock.java.patch index b520d37a11d0..b0a0bea9ebad 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/EndGatewayBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/EndGatewayBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/EndGatewayBlock.java +++ b/net/minecraft/world/level/block/EndGatewayBlock.java -@@ -90,10 +_,15 @@ +@@ -89,10 +_,15 @@ @Override protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean pastEdges) { @@ -16,7 +16,7 @@ entity.setAsInsidePortal(this, pos); TheEndGatewayBlockEntity.triggerCooldown(level, pos, state, theEndGatewayBlockEntity); } -@@ -108,9 +_,9 @@ +@@ -106,9 +_,9 @@ return null; } else { return entity instanceof ThrownEnderpearl diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch index 95ae4bc01432..d9e3c4ce3361 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch @@ -16,8 +16,8 @@ serverPlayer.showEndCredits(); } else { entity.setAsInsidePortal(this, pos); -@@ -73,7 +_,7 @@ - public TeleportTransition getPortalDestination(ServerLevel level, Entity entity, BlockPos pos) { +@@ -72,7 +_,7 @@ + public @Nullable TeleportTransition getPortalDestination(ServerLevel level, Entity entity, BlockPos pos) { LevelData.RespawnData respawnData = level.getRespawnData(); ResourceKey resourceKey = level.dimension(); - boolean flag = resourceKey == Level.END; @@ -25,7 +25,7 @@ ResourceKey resourceKey1 = flag ? respawnData.dimension() : Level.END; BlockPos blockPos = flag ? respawnData.pos() : ServerLevel.END_SPAWN_POINT; ServerLevel level1 = level.getServer().getLevel(resourceKey1); -@@ -85,7 +_,7 @@ +@@ -84,7 +_,7 @@ float f1; Set set; if (!flag) { @@ -34,7 +34,7 @@ f = Direction.WEST.toYRot(); f1 = 0.0F; set = Relative.union(Relative.DELTA, Set.of(Relative.X_ROT)); -@@ -97,15 +_,24 @@ +@@ -96,15 +_,24 @@ f1 = respawnData.pitch(); set = Relative.union(Relative.DELTA, Relative.ROTATION); if (entity instanceof ServerPlayer serverPlayer) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch index 0f801757a1dc..ba5457e83159 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch @@ -25,7 +25,7 @@ if (level instanceof ServerLevel serverLevel && level.random.nextFloat() < fallDistance - 0.5 && entity instanceof LivingEntity - && (entity instanceof Player || serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) + && (entity instanceof Player || serverLevel.getGameRules().get(GameRules.MOB_GRIEFING)) && entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) { + // CraftBukkit start - Interact soil + org.bukkit.event.Cancellable cancellable; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch index 9b166cf09b4b..eb63a4c8835e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FireBlock.java +++ b/net/minecraft/world/level/block/FireBlock.java -@@ -101,7 +_,25 @@ +@@ -99,7 +_,25 @@ BlockState neighborState, RandomSource random ) { @@ -27,83 +27,82 @@ } @Override -@@ -141,18 +_,18 @@ +@@ -139,17 +_,17 @@ @Override protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { - level.scheduleTick(pos, this, getFireTickDelay(level.random)); + level.scheduleTick(pos, this, getFireTickDelay(level)); // Paper - Add fire-tick-delay option - if (level.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { - if (level.getGameRules().getBoolean(GameRules.RULE_ALLOWFIRETICKAWAYFROMPLAYERS) || level.anyPlayerCloseEnoughForSpawning(pos)) { - if (!state.canSurvive(level, pos)) { -- level.removeBlock(pos, false); -+ this.fireExtinguished(level, pos); // CraftBukkit - invalid place location - } - - BlockState blockState = level.getBlockState(pos.below()); - boolean isTag = blockState.is(level.dimensionType().infiniburn()); - int ageValue = state.getValue(AGE); - if (!isTag && level.isRaining() && this.isNearRain(level, pos) && random.nextFloat() < 0.2F + ageValue * 0.03F) { -- level.removeBlock(pos, false); -+ this.fireExtinguished(level, pos); // CraftBukkit - extinguished by rain - } else { - int min = Math.min(15, ageValue + random.nextInt(3) / 2); - if (ageValue != min) { -@@ -164,26 +_,28 @@ - if (!this.isValidFireLocation(level, pos)) { - BlockPos blockPos = pos.below(); - if (!level.getBlockState(blockPos).isFaceSturdy(level, blockPos, Direction.UP) || ageValue > 3) { -- level.removeBlock(pos, false); -+ this.fireExtinguished(level, pos); // CraftBukkit - } - - return; - } + if (level.canSpreadFireAround(pos)) { + if (!state.canSurvive(level, pos)) { +- level.removeBlock(pos, false); ++ this.fireExtinguished(level, pos); // CraftBukkit - invalid place location + } - if (ageValue == 15 && random.nextInt(4) == 0 && !this.canBurn(level.getBlockState(pos.below()))) { + BlockState blockState = level.getBlockState(pos.below()); + boolean isTag = blockState.is(level.dimensionType().infiniburn()); + int ageValue = state.getValue(AGE); + if (!isTag && level.isRaining() && this.isNearRain(level, pos) && random.nextFloat() < 0.2F + ageValue * 0.03F) { +- level.removeBlock(pos, false); ++ this.fireExtinguished(level, pos); // CraftBukkit - extinguished by rain + } else { + int min = Math.min(15, ageValue + random.nextInt(3) / 2); + if (ageValue != min) { +@@ -161,26 +_,28 @@ + if (!this.isValidFireLocation(level, pos)) { + BlockPos blockPos = pos.below(); + if (!level.getBlockState(blockPos).isFaceSturdy(level, blockPos, Direction.UP) || ageValue > 3) { - level.removeBlock(pos, false); + this.fireExtinguished(level, pos); // CraftBukkit - return; } + + return; + } + + if (ageValue == 15 && random.nextInt(4) == 0 && !this.canBurn(level.getBlockState(pos.below()))) { +- level.removeBlock(pos, false); ++ this.fireExtinguished(level, pos); // CraftBukkit + return; } + } - boolean value = level.environmentAttributes().getValue(EnvironmentAttributes.INCREASED_FIRE_BURNOUT, pos); - int i = value ? -50 : 0; -- this.checkBurnOut(level, pos.east(), 300 + i, random, ageValue); -- this.checkBurnOut(level, pos.west(), 300 + i, random, ageValue); -- this.checkBurnOut(level, pos.below(), 250 + i, random, ageValue); -- this.checkBurnOut(level, pos.above(), 250 + i, random, ageValue); -- this.checkBurnOut(level, pos.north(), 300 + i, random, ageValue); -- this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue); -+ // CraftBukkit start - add source blockPos to burn calls -+ this.checkBurnOut(level, pos.east(), 300 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.west(), 300 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.below(), 250 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.above(), 250 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.north(), 300 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue, pos); -+ // CraftBukkit end - BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + boolean value = level.environmentAttributes().getValue(EnvironmentAttributes.INCREASED_FIRE_BURNOUT, pos); + int i = value ? -50 : 0; +- this.checkBurnOut(level, pos.east(), 300 + i, random, ageValue); +- this.checkBurnOut(level, pos.west(), 300 + i, random, ageValue); +- this.checkBurnOut(level, pos.below(), 250 + i, random, ageValue); +- this.checkBurnOut(level, pos.above(), 250 + i, random, ageValue); +- this.checkBurnOut(level, pos.north(), 300 + i, random, ageValue); +- this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue); ++ // CraftBukkit start - add source blockPos to burn calls ++ this.checkBurnOut(level, pos.east(), 300 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.west(), 300 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.below(), 250 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.above(), 250 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.north(), 300 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue, pos); ++ // CraftBukkit end - add source blockPos to burn calls + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); - for (int i1 = -1; i1 <= 1; i1++) { -@@ -205,7 +_,15 @@ + for (int i1 = -1; i1 <= 1; i1++) { +@@ -202,7 +_,15 @@ - if (i5 > 0 && random.nextInt(i4) <= i5 && (!level.isRaining() || !this.isNearRain(level, mutableBlockPos))) { - int min1 = Math.min(15, ageValue + random.nextInt(5) / 4); -- level.setBlock(mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), Block.UPDATE_ALL); -+ // CraftBukkit start - Call to stop spread of fire -+ if (!level.getBlockState(mutableBlockPos).is(Blocks.FIRE)) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, mutableBlockPos, pos).isCancelled()) { -+ continue; -+ } -+ -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), 3); // CraftBukkit + if (i5 > 0 && random.nextInt(i4) <= i5 && (!level.isRaining() || !this.isNearRain(level, mutableBlockPos))) { + int min1 = Math.min(15, ageValue + random.nextInt(5) / 4); +- level.setBlock(mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), Block.UPDATE_ALL); ++ // CraftBukkit start - Call to stop spread of fire ++ if (!level.getBlockState(mutableBlockPos).is(Blocks.FIRE)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, mutableBlockPos, pos).isCancelled()) { ++ continue; + } -+ // CraftBukkit end - } ++ ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), UPDATE_ALL); // CraftBukkit ++ } ++ // CraftBukkit end } } -@@ -237,19 +_,40 @@ + } +@@ -233,19 +_,40 @@ : this.igniteOdds.getInt(state.getBlock()); } @@ -146,7 +145,7 @@ TntBlock.prime(level, pos); } } -@@ -291,13 +_,14 @@ +@@ -287,13 +_,14 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FurnaceBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FurnaceBlock.java.patch index c383a4b8f2d8..7388ee1d652a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FurnaceBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FurnaceBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FurnaceBlock.java +++ b/net/minecraft/world/level/block/FurnaceBlock.java -@@ -45,8 +_,7 @@ +@@ -44,8 +_,7 @@ @Override protected void openContainer(Level level, BlockPos pos, Player player) { BlockEntity blockEntity = level.getBlockEntity(pos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/HopperBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/HopperBlock.java.patch index db77e5ffefa5..8e160a4c11cb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/HopperBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/HopperBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/HopperBlock.java +++ b/net/minecraft/world/level/block/HopperBlock.java -@@ -106,8 +_,7 @@ +@@ -102,8 +_,7 @@ @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { @@ -10,7 +10,7 @@ player.awardStat(Stats.INSPECT_HOPPER); } -@@ -158,6 +_,7 @@ +@@ -154,6 +_,7 @@ @Override protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean pastEdges) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch index b477c022c3c0..8d6d7c1e5aaf 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch @@ -10,7 +10,7 @@ effectApplier.runBefore(InsideBlockEffectType.EXTINGUISH, entity1 -> { - if (entity1.isOnFire() && entity1.mayInteract(serverLevel, blockPos)) { - this.handleEntityOnFireInside(state, level, blockPos); -+ if (entity1.isOnFire() && (entity instanceof net.minecraft.world.entity.player.Player || serverLevel.getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_MOBGRIEFING)) && entity1.mayInteract(serverLevel, blockPos)) { // Paper - Fixes MC-248588 ++ if (entity1.isOnFire() && (entity instanceof net.minecraft.world.entity.player.Player || serverLevel.getGameRules().get(net.minecraft.world.level.gamerules.GameRules.MOB_GRIEFING)) && entity1.mayInteract(serverLevel, blockPos)) { // Paper - Fixes MC-248588 + // Paper start - cauldron level change event + if (this.handleEntityOnFireInside(state, level, blockPos, entity1)) { // Paper - track entity + InsideBlockEffectType.EXTINGUISH.effect().affect(entity1, blockPos); // apply extinguishing if event was not cancelled. diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch index a2e5f2f1ce5d..e8377204ce2a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch @@ -43,7 +43,7 @@ level.setBlock(pos, state.setValue(POWERED, powered), Block.UPDATE_ALL); updateBelow(level, pos, state); } -@@ -244,8 +_,7 @@ +@@ -243,8 +_,7 @@ private void openScreen(Level level, BlockPos pos, Player player) { BlockEntity blockEntity = level.getBlockEntity(pos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LeverBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LeverBlock.java.patch index 89c9166ec4dc..9777099fd666 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LeverBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LeverBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LeverBlock.java +++ b/net/minecraft/world/level/block/LeverBlock.java -@@ -68,6 +_,19 @@ +@@ -67,6 +_,19 @@ makeParticle(blockState, level, pos, 1.0F); } } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/MangrovePropaguleBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/MangrovePropaguleBlock.java.patch index 5bb146741cbb..713e011d6d6c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/MangrovePropaguleBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/MangrovePropaguleBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/MangrovePropaguleBlock.java +++ b/net/minecraft/world/level/block/MangrovePropaguleBlock.java -@@ -103,7 +_,7 @@ +@@ -102,7 +_,7 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (!isHanging(state)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch index ea4a2323a87d..da474d26f0cc 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/MultifaceSpreader.java +++ b/net/minecraft/world/level/block/MultifaceSpreader.java -@@ -154,14 +_,14 @@ +@@ -152,14 +_,14 @@ level.getChunk(pos.pos()).markPosForPostprocessing(pos.pos()); } @@ -17,7 +17,7 @@ } @FunctionalInterface -@@ -173,19 +_,19 @@ +@@ -171,19 +_,19 @@ SAME_POSITION { @Override public MultifaceSpreader.SpreadPos getSpreadPos(BlockPos pos, Direction face, Direction spreadDirection) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch index dd70b34ed719..6fceb1854e4f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch @@ -38,10 +38,10 @@ entity.setAsInsidePortal(this, pos); } } -@@ -131,22 +_,46 @@ - @Nullable +@@ -126,23 +_,46 @@ + @Override - public TeleportTransition getPortalDestination(ServerLevel level, Entity entity, BlockPos pos) { + public @Nullable TeleportTransition getPortalDestination(ServerLevel level, Entity entity, BlockPos pos) { - ResourceKey resourceKey = level.dimension() == Level.NETHER ? Level.OVERWORLD : Level.NETHER; + // CraftBukkit start + ResourceKey resourceKey = level.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER ? Level.OVERWORLD : Level.NETHER; @@ -82,15 +82,16 @@ } } - @Nullable -- private TeleportTransition getExitPortal(ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, boolean isNether, WorldBorder worldBorder) { + private @Nullable TeleportTransition getExitPortal( +- ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, boolean isNether, WorldBorder worldBorder +- ) { - Optional optional = level.getPortalForcer().findClosestPortalPosition(exitPos, isNether, worldBorder); -+ private TeleportTransition getExitPortal(ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, WorldBorder worldBorder, org.bukkit.craftbukkit.event.PortalEventResult result) { // CraftBukkit ++ ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, WorldBorder worldBorder, org.bukkit.craftbukkit.event.PortalEventResult result) { // CraftBukkit + Optional optional = level.getPortalForcer().findClosestPortalPosition(exitPos, worldBorder, result.searchRadius()); // CraftBukkit BlockUtil.FoundRectangle largestRectangleAround; TeleportTransition.PostTeleportTransition postTeleportTransition; if (optional.isPresent()) { -@@ -161,17 +_,22 @@ +@@ -157,17 +_,22 @@ blockPos1 -> level.getBlockState(blockPos1) == blockState ); postTeleportTransition = TeleportTransition.PLAY_PORTAL_SOUND.then(entity1 -> entity1.placePortalTicket(blockPos)); @@ -116,7 +117,7 @@ return getDimensionTransitionFromExit(entity, pos, largestRectangleAround, level, postTeleportTransition); } -@@ -217,7 +_,7 @@ +@@ -213,7 +_,7 @@ boolean flag = axis1 == Direction.Axis.X; Vec3 vec3 = new Vec3(blockPos.getX() + (flag ? d2 : d4), blockPos.getY() + d3, blockPos.getZ() + (flag ? d4 : d2)); Vec3 vec31 = PortalShape.findCollisionFreePosition(vec3, level, entity, dimensions); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch index ec52a7b6e9f5..d1edc4d8998f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/PitcherCropBlock.java +++ b/net/minecraft/world/level/block/PitcherCropBlock.java -@@ -118,6 +_,7 @@ +@@ -117,6 +_,7 @@ @Override public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean pastEdges) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent - if (level instanceof ServerLevel serverLevel && entity instanceof Ravager && serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (level instanceof ServerLevel serverLevel && entity instanceof Ravager && serverLevel.getGameRules().get(GameRules.MOB_GRIEFING)) { serverLevel.destroyBlock(pos, true, entity); } -@@ -140,7 +_,7 @@ +@@ -139,7 +_,7 @@ @Override public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { float growthSpeed = CropBlock.getGrowthSpeed(this, level, pos); @@ -17,7 +17,7 @@ if (flag) { this.grow(level, state, pos, 1); } -@@ -150,7 +_,7 @@ +@@ -149,7 +_,7 @@ int min = Math.min(state.getValue(AGE) + ageIncrement, 4); if (this.canGrow(level, pos, state, min)) { BlockState blockState = state.setValue(AGE, min); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch index 1600c0c27a33..ac731a2994d1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch @@ -34,7 +34,7 @@ } else { BlockPos blockPos1 = findFillableCauldronBelowStalactiteTip(level, blockPos, fluid); if (blockPos1 != null) { -@@ -360,17 +_,17 @@ +@@ -357,17 +_,17 @@ if (isUnmergedTipWithDirection(blockState, direction.getOpposite())) { createMergedTips(blockState, server, blockPos); } else if (blockState.isAir() || blockState.is(Blocks.WATER)) { @@ -55,7 +55,7 @@ } private static void createMergedTips(BlockState state, LevelAccessor level, BlockPos pos) { -@@ -384,8 +_,8 @@ +@@ -381,8 +_,8 @@ blockPos = pos.below(); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PowderSnowBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PowderSnowBlock.java.patch index b3063011ab02..fb6700ff7d0e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PowderSnowBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PowderSnowBlock.java.patch @@ -19,11 +19,11 @@ entity1 -> { if (level instanceof ServerLevel serverLevel && entity1.isOnFire() -- && (serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity1 instanceof Player) +- && (serverLevel.getGameRules().get(GameRules.MOB_GRIEFING) || entity1 instanceof Player) + // CraftBukkit - move down && entity1.mayInteract(serverLevel, blockPos)) { + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity1, pos, Blocks.AIR.defaultBlockState(), !(serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity1 instanceof Player))) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity1, pos, Blocks.AIR.defaultBlockState(), !(serverLevel.getGameRules().get(GameRules.MOB_GRIEFING) || entity1 instanceof Player))) { + return; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch index 8b4e8f8001fd..ab0b98fd47f4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch @@ -13,7 +13,7 @@ public RailState(Level level, BlockPos pos, BlockState state) { this.level = level; this.pos = pos; -@@ -141,6 +_,11 @@ +@@ -140,6 +_,11 @@ } private void connectTo(RailState state) { @@ -25,7 +25,7 @@ this.connections.add(state.pos); BlockPos blockPos = this.pos.north(); BlockPos blockPos1 = this.pos.south(); -@@ -331,10 +_,15 @@ +@@ -330,10 +_,15 @@ this.state = this.state.setValue(this.block.getShapeProperty(), railShape); if (alwaysPlace || this.level.getBlockState(this.pos) != this.state) { this.level.setBlock(this.pos, this.state, Block.UPDATE_ALL); @@ -42,7 +42,7 @@ rail.removeSoftConnections(); if (rail.canConnectTo(this)) { rail.connectTo(this); -@@ -347,6 +_,6 @@ +@@ -346,6 +_,6 @@ } public BlockState getState() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneLampBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneLampBlock.java.patch index 40638c1dbbf1..652ca91bea10 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneLampBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneLampBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/RedstoneLampBlock.java +++ b/net/minecraft/world/level/block/RedstoneLampBlock.java -@@ -41,6 +_,11 @@ +@@ -40,6 +_,11 @@ if (litValue) { level.scheduleTick(pos, this, 4); } else { @@ -12,7 +12,7 @@ level.setBlock(pos, state.cycle(LIT), Block.UPDATE_CLIENTS); } } -@@ -50,6 +_,11 @@ +@@ -49,6 +_,11 @@ @Override protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (state.getValue(LIT) && !level.hasNeighborSignal(pos)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SculkCatalystBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SculkCatalystBlock.java.patch index 5ba297feff6c..b3c120dc3f1d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SculkCatalystBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SculkCatalystBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkCatalystBlock.java +++ b/net/minecraft/world/level/block/SculkCatalystBlock.java -@@ -61,8 +_,16 @@ +@@ -59,8 +_,16 @@ @Override protected void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { super.spawnAfterBreak(state, level, pos, stack, dropExperience); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch index 20d1353b1c5c..167825ee44da 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkSensorBlock.java +++ b/net/minecraft/world/level/block/SculkSensorBlock.java -@@ -102,6 +_,18 @@ +@@ -101,6 +_,18 @@ && level.getBlockEntity(pos) instanceof SculkSensorBlockEntity sculkSensorBlockEntity && level instanceof ServerLevel serverLevel && sculkSensorBlockEntity.getVibrationUser().canReceiveVibration(serverLevel, pos, GameEvent.STEP, GameEvent.Context.of(state))) { @@ -19,7 +19,7 @@ sculkSensorBlockEntity.getListener().forceScheduleVibration(serverLevel, GameEvent.STEP, GameEvent.Context.of(entity), entity.position()); } -@@ -191,10 +_,19 @@ +@@ -188,10 +_,19 @@ } public static boolean canActivate(BlockState state) { @@ -40,7 +40,7 @@ level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.COOLDOWN).setValue(POWER, 0), Block.UPDATE_ALL); level.scheduleTick(pos, state.getBlock(), 10); updateNeighbours(level, pos, state); -@@ -206,6 +_,15 @@ +@@ -203,6 +_,15 @@ } public void activate(@Nullable Entity entity, Level level, BlockPos pos, BlockState state, int power, int frequency) { @@ -56,7 +56,7 @@ level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.ACTIVE).setValue(POWER, power), Block.UPDATE_ALL); level.scheduleTick(pos, state.getBlock(), this.getActiveTicks()); updateNeighbours(level, pos, state); -@@ -283,8 +_,16 @@ +@@ -280,8 +_,16 @@ @Override protected void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { super.spawnAfterBreak(state, level, pos, stack, dropExperience); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SculkShriekerBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SculkShriekerBlock.java.patch index 1c5547e4529a..3bd01d8b8855 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SculkShriekerBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SculkShriekerBlock.java.patch @@ -8,7 +8,7 @@ serverLevel.getBlockEntity(pos, BlockEntityType.SCULK_SHRIEKER).ifPresent(sculkShrieker -> sculkShrieker.tryShriek(serverLevel, serverPlayer)); } } -@@ -128,9 +_,16 @@ +@@ -126,9 +_,16 @@ @Override protected void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { super.spawnAfterBreak(state, level, pos, stack, dropExperience); @@ -25,4 +25,4 @@ + // CraftBukkit end } - @Nullable + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ShelfBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ShelfBlock.java.patch index 67623f8446d0..5ce61082d8a7 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ShelfBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ShelfBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ShelfBlock.java +++ b/net/minecraft/world/level/block/ShelfBlock.java -@@ -109,6 +_,11 @@ +@@ -108,6 +_,11 @@ if (!level.isClientSide()) { boolean hasNeighborSignal = level.hasNeighborSignal(pos); if (state.getValue(POWERED) != hasNeighborSignal) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch index 15ba87e8790d..0edf671ca59d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ShulkerBoxBlock.java +++ b/net/minecraft/world/level/block/ShulkerBoxBlock.java -@@ -78,8 +_,8 @@ +@@ -71,8 +_,8 @@ protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { if (level instanceof ServerLevel serverLevel && level.getBlockEntity(pos) instanceof ShulkerBoxBlockEntity shulkerBoxBlockEntity @@ -11,7 +11,7 @@ player.awardStat(Stats.OPEN_SHULKER_BOX); PiglinAi.angerNearbyPiglins(serverLevel, player, true); } -@@ -117,7 +_,7 @@ +@@ -110,7 +_,7 @@ itemEntity.setDefaultPickUpDelay(); level.addFreshEntity(itemEntity); } else { @@ -20,33 +20,3 @@ } } -@@ -127,7 +_,15 @@ - @Override - protected List getDrops(BlockState state, LootParams.Builder params) { - BlockEntity blockEntity = params.getOptionalParameter(LootContextParams.BLOCK_ENTITY); -+ Runnable reAdd = null; // Paper - if (blockEntity instanceof ShulkerBoxBlockEntity shulkerBoxBlockEntity) { -+ // Paper start - clear loot table if it was already used -+ if (shulkerBoxBlockEntity.lootableData().getLastFill() != -1 || !params.getLevel().paperConfig().lootables.retainUnlootedShulkerBoxLootTableOnNonPlayerBreak) { -+ net.minecraft.resources.ResourceKey lootTableResourceKey = shulkerBoxBlockEntity.getLootTable(); -+ reAdd = () -> shulkerBoxBlockEntity.setLootTable(lootTableResourceKey); -+ shulkerBoxBlockEntity.setLootTable(null); -+ } -+ // Paper end - params = params.withDynamicDrop(CONTENTS, output -> { - for (int i = 0; i < shulkerBoxBlockEntity.getContainerSize(); i++) { - output.accept(shulkerBoxBlockEntity.getItem(i)); -@@ -135,7 +_,13 @@ - }); - } - -+ // Paper start - re-set loot table if it was cleared -+ try { - return super.getDrops(state, params); -+ } finally { -+ if (reAdd != null) reAdd.run(); -+ } -+ // Paper end - re-set loot table if it was cleared - } - - @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SignBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SignBlock.java.patch index eb1e38d31a91..3ea7cf679255 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SignBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SignBlock.java.patch @@ -44,10 +44,10 @@ signEntity.setAllowedPlayerEditor(player.getUUID()); player.openTextEdit(signEntity, isFrontText); } -@@ -192,6 +_,6 @@ - @Nullable +@@ -191,6 +_,6 @@ + @Override - public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { + public @Nullable BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { - return createTickerHelper(blockEntityType, BlockEntityType.SIGN, SignBlockEntity::tick); + return null; // CraftBukkit - remove unnecessary sign ticking } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SmokerBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SmokerBlock.java.patch index 27b9bafcfd4e..dd2321c6f79c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SmokerBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SmokerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SmokerBlock.java +++ b/net/minecraft/world/level/block/SmokerBlock.java -@@ -44,8 +_,7 @@ +@@ -43,8 +_,7 @@ @Override protected void openContainer(Level level, BlockPos pos, Player player) { BlockEntity blockEntity = level.getBlockEntity(pos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SpawnerBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SpawnerBlock.java.patch index d2ce10af2f78..5dfdd1e2d92d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SpawnerBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SpawnerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SpawnerBlock.java +++ b/net/minecraft/world/level/block/SpawnerBlock.java -@@ -41,9 +_,17 @@ +@@ -40,9 +_,17 @@ @Override protected void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { super.spawnAfterBreak(state, level, pos, stack, dropExperience); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch index 5661b3fd72df..478b2ae1b110 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch @@ -41,9 +41,9 @@ } - private static boolean prime(Level level, BlockPos pos, @Nullable LivingEntity entity) { -- if (level instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) { +- if (level instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.TNT_EXPLODES)) { + private static boolean prime(Level level, BlockPos pos, @Nullable LivingEntity entity, java.util.function.BooleanSupplier event) { // Paper -+ if (level instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES) && event.getAsBoolean()) { // Paper ++ if (level instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.TNT_EXPLODES) && event.getAsBoolean()) { // Paper PrimedTnt primedTnt = new PrimedTnt(level, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, entity); level.addFreshEntity(primedTnt); level.playSound(null, primedTnt.getX(), primedTnt.getY(), primedTnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch index bb0a61839340..690161f2fd68 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/net/minecraft/world/level/block/TripWireHookBlock.java -@@ -113,10 +_,10 @@ +@@ -112,10 +_,10 @@ if (optionalValue.isPresent()) { Direction direction = optionalValue.get(); boolean flag = hookState.getOptionalValue(ATTACHED).orElse(false); @@ -13,7 +13,7 @@ int i = 0; BlockState[] blockStates = new BlockState[42]; -@@ -152,21 +_,48 @@ +@@ -151,21 +_,48 @@ flag2 &= i > 1; flag3 &= flag2; BlockState blockState1 = block.defaultBlockState().trySetValue(ATTACHED, flag2).trySetValue(POWERED, flag3); @@ -63,7 +63,7 @@ if (flag != flag2) { for (int i2 = 1; i2 < i; i2++) { -@@ -175,7 +_,7 @@ +@@ -174,7 +_,7 @@ if (blockState2 != null) { BlockState blockState3 = level.getBlockState(blockPos1); if (blockState3.is(Blocks.TRIPWIRE) || blockState3.is(Blocks.TRIPWIRE_HOOK)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch index 705f3164b2fa..fc6f846c34cd 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch @@ -3,7 +3,7 @@ @@ -166,7 +_,7 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { - if (level.getGameRules().getBoolean(GameRules.RULE_DO_VINES_SPREAD)) { + if (level.getGameRules().get(GameRules.SPREAD_VINES)) { - if (random.nextInt(4) == 0) { + if (random.nextFloat() < (level.spigotConfig.vineModifier / (100.0F * 4))) { // Spigot - SPIGOT-7159: Better modifier resolution Direction random1 = Direction.getRandom(random); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/WallHangingSignBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/WallHangingSignBlock.java.patch index e00affc15925..b3a0e5ec97b3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/WallHangingSignBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/WallHangingSignBlock.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/WallHangingSignBlock.java +++ b/net/minecraft/world/level/block/WallHangingSignBlock.java -@@ -176,6 +_,6 @@ - @Nullable +@@ -174,6 +_,6 @@ + @Override - public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { + public @Nullable BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { - return createTickerHelper(blockEntityType, BlockEntityType.HANGING_SIGN, SignBlockEntity::tick); + return null; // CraftBukkit - remove unnecessary sign ticking } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch index 7d61368e22b6..a1496c38cf0b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/WitherSkullBlock.java +++ b/net/minecraft/world/level/block/WitherSkullBlock.java -@@ -51,6 +_,7 @@ +@@ -49,6 +_,7 @@ } public static void checkSpawn(Level level, BlockPos pos, SkullBlockEntity blockEntity) { @@ -8,7 +8,7 @@ if (!level.isClientSide()) { BlockState blockState = blockEntity.getBlockState(); boolean flag = blockState.is(Blocks.WITHER_SKELETON_SKULL) || blockState.is(Blocks.WITHER_SKELETON_WALL_SKULL); -@@ -59,7 +_,7 @@ +@@ -57,7 +_,7 @@ if (blockPatternMatch != null) { WitherBoss witherBoss = EntityType.WITHER.create(level, EntitySpawnReason.TRIGGERED); if (witherBoss != null) { @@ -17,7 +17,7 @@ BlockPos pos1 = blockPatternMatch.getBlock(1, 2, 0).getPos(); witherBoss.snapTo( pos1.getX() + 0.5, -@@ -70,12 +_,18 @@ +@@ -68,12 +_,18 @@ ); witherBoss.yBodyRot = blockPatternMatch.getForwards().getAxis() == Direction.Axis.X ? 0.0F : 90.0F; witherBoss.makeInvulnerable(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch index add1fa3677cb..70016c81ecf8 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch @@ -205,7 +205,7 @@ this.cookingTimer = 0; this.setChanged(); } -@@ -343,8 +_,8 @@ +@@ -342,8 +_,8 @@ public void awardUsedRecipes(Player player, List items) { } @@ -216,7 +216,7 @@ player.awardRecipes(recipesToAwardAndPopExperience); for (RecipeHolder recipeHolder : recipesToAwardAndPopExperience) { -@@ -357,30 +_,60 @@ +@@ -354,30 +_,60 @@ } public List> getRecipesToAwardAndPopExperience(ServerLevel level, Vec3 popVec) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch index 237a3c34e038..6631c94aa4ed 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BannerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BannerBlockEntity.java -@@ -51,7 +_,7 @@ +@@ -49,7 +_,7 @@ @Override protected void saveAdditional(ValueOutput output) { super.saveAdditional(output); @@ -9,7 +9,7 @@ output.store("patterns", BannerPatternLayers.CODEC, this.patterns); } -@@ -62,7 +_,7 @@ +@@ -60,7 +_,7 @@ protected void loadAdditional(ValueInput input) { super.loadAdditional(input); this.name = parseCustomNameSafe(input, "CustomName"); @@ -18,7 +18,7 @@ } @Override -@@ -70,9 +_,18 @@ +@@ -68,9 +_,18 @@ return ClientboundBlockEntityDataPacket.create(this); } @@ -37,7 +37,7 @@ } public BannerPatternLayers getPatterns() { -@@ -92,7 +_,7 @@ +@@ -90,7 +_,7 @@ @Override protected void applyImplicitComponents(DataComponentGetter componentGetter) { super.applyImplicitComponents(componentGetter); @@ -46,7 +46,7 @@ this.name = componentGetter.get(DataComponents.CUSTOM_NAME); } -@@ -108,4 +_,13 @@ +@@ -106,4 +_,13 @@ output.discard("patterns"); output.discard("CustomName"); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch index 2c832a19bb34..e455a3f9962e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -@@ -66,17 +_,45 @@ +@@ -64,17 +_,45 @@ protected abstract Component getDefaultName(); public boolean canOpen(Player player) { @@ -48,14 +48,14 @@ } public boolean isLocked() { -@@ -168,4 +_,12 @@ +@@ -165,4 +_,12 @@ output.discard("lock"); output.discard("Items"); } + + // CraftBukkit start + @Override -+ public @Nullable org.bukkit.Location getLocation() { ++ public org.bukkit.@Nullable Location getLocation() { + if (this.level == null) return null; + return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.worldPosition, this.level); + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch index 06e7df1f2691..50562fa92e2b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch @@ -1,12 +1,11 @@ --- a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -@@ -110,6 +_,53 @@ +@@ -107,6 +_,51 @@ return 3; } }; + // CraftBukkit start - add fields and methods -+ @Nullable -+ public org.bukkit.potion.PotionEffect getPrimaryEffect() { ++ public org.bukkit.potion.@Nullable PotionEffect getPrimaryEffect() { + return (this.primaryPower != null) + ? org.bukkit.craftbukkit.potion.CraftPotionUtil.toBukkit(new MobEffectInstance( + this.primaryPower, @@ -18,8 +17,7 @@ + : null; + } + -+ @Nullable -+ public org.bukkit.potion.PotionEffect getSecondaryEffect() { ++ public org.bukkit.potion.@Nullable PotionEffect getSecondaryEffect() { + return (BeaconBlockEntity.hasSecondaryEffect(this.levels, this.primaryPower, this.secondaryPower)) + ? org.bukkit.craftbukkit.potion.CraftPotionUtil.toBukkit(new MobEffectInstance( + this.secondaryPower, @@ -52,9 +50,9 @@ + } + // Paper end - Custom beacon ranges - @Nullable - static Holder filterEffect(@Nullable Holder effect) { -@@ -167,17 +_,26 @@ + static @Nullable Holder filterEffect(@Nullable Holder effect) { + return VALID_EFFECTS.contains(effect) ? effect : null; +@@ -163,17 +_,26 @@ blockEntity.lastCheckY++; } @@ -83,7 +81,7 @@ if (blockEntity.lastCheckY >= height) { blockEntity.lastCheckY = level.getMinY() - 1; -@@ -228,35 +_,100 @@ +@@ -224,35 +_,100 @@ @Override public void setRemoved() { @@ -202,16 +200,16 @@ public static void playSound(Level level, BlockPos pos, SoundEvent sound) { level.playSound(null, pos, sound, SoundSource.BLOCKS, 1.0F, 1.0F); -@@ -285,7 +_,7 @@ +@@ -280,7 +_,7 @@ + } - @Nullable - private static Holder loadEffect(ValueInput input, String key) { + private static @Nullable Holder loadEffect(ValueInput input, String key) { - return input.read(key, BuiltInRegistries.MOB_EFFECT.holderByNameCodec()).filter(VALID_EFFECTS::contains).orElse(null); + return input.read(key, BuiltInRegistries.MOB_EFFECT.holderByNameCodec()).orElse(null); // CraftBukkit - persist manually set non-default beacon effects (SPIGOT-3598) } @Override -@@ -293,8 +_,10 @@ +@@ -288,8 +_,10 @@ super.loadAdditional(input); this.primaryPower = loadEffect(input, "primary_effect"); this.secondaryPower = loadEffect(input, "secondary_effect"); @@ -222,7 +220,7 @@ } @Override -@@ -305,6 +_,7 @@ +@@ -300,6 +_,7 @@ output.putInt("Levels", this.levels); output.storeNullable("CustomName", ComponentSerialization.CODEC, this.name); this.lockKey.addToTag(output); @@ -230,10 +228,10 @@ } public void setCustomName(@Nullable Component name) { -@@ -320,7 +_,7 @@ - @Nullable +@@ -313,7 +_,7 @@ + @Override - public AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { + public @Nullable AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { - return BaseContainerBlockEntity.canUnlock(player, this.lockKey, this.getDisplayName()) + return BaseContainerBlockEntity.canUnlock(player, this.lockKey, this.getDisplayName(), this) // Paper - Add BlockLockCheckEvent ? new BeaconMenu(containerId, playerInventory, this.dataAccess, ContainerLevelAccess.create(this.level, this.getBlockPos())) diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch index ada76af48298..45531f6515a1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java @@ -84,6 +_,7 @@ + public static final int MIN_OCCUPATION_TICKS_NECTARLESS = 600; private List stored = Lists.newArrayList(); - @Nullable - public BlockPos savedFlowerPos; + public @Nullable BlockPos savedFlowerPos; + public int maxBees = MAX_OCCUPANTS; // CraftBukkit - allow setting max amount of bees a hive can hold public BeehiveBlockEntity(BlockPos pos, BlockState blockState) { @@ -217,7 +217,7 @@ } public BeehiveBlockEntity.Occupant toOccupant() { -@@ -421,6 +_,7 @@ +@@ -420,6 +_,7 @@ } private static void setBeeReleaseData(int ticksInHive, Bee bee) { @@ -225,7 +225,7 @@ int age = bee.getAge(); if (age < 0) { bee.setAge(Math.min(0, age + ticksInHive)); -@@ -429,6 +_,7 @@ +@@ -428,6 +_,7 @@ } bee.setInLoveTime(Math.max(0, bee.getInLoveTime() - ticksInHive)); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BlockEntity.java.patch index 7915f91c6b17..4767a1f8501f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BlockEntity.java.patch @@ -11,7 +11,7 @@ private static final Codec> TYPE_CODEC = BuiltInRegistries.BLOCK_ENTITY_TYPE.byNameCodec(); private static final Logger LOGGER = LogUtils.getLogger(); private final BlockEntityType type; -@@ -52,6 +_,7 @@ +@@ -51,6 +_,7 @@ this.worldPosition = pos.immutable(); this.validateBlockState(blockState); this.blockState = blockState; @@ -19,7 +19,7 @@ } private void validateBlockState(BlockState state) { -@@ -68,6 +_,7 @@ +@@ -67,6 +_,7 @@ int intOr = tag.getIntOr("x", 0); int intOr1 = tag.getIntOr("y", 0); int intOr2 = tag.getIntOr("z", 0); @@ -27,7 +27,7 @@ int sectionPosCoord = SectionPos.blockToSectionCoord(intOr); int sectionPosCoord1 = SectionPos.blockToSectionCoord(intOr2); if (sectionPosCoord != chunkPos.x || sectionPosCoord1 != chunkPos.z) { -@@ -75,6 +_,7 @@ +@@ -74,6 +_,7 @@ intOr = chunkPos.getBlockX(SectionPos.sectionRelative(intOr)); intOr2 = chunkPos.getBlockZ(SectionPos.sectionRelative(intOr2)); } @@ -35,7 +35,7 @@ return new BlockPos(intOr, intOr1, intOr2); } -@@ -93,6 +_,12 @@ +@@ -91,6 +_,12 @@ } protected void loadAdditional(ValueInput input) { @@ -48,7 +48,7 @@ } public final void loadWithComponents(ValueInput input) { -@@ -142,6 +_,11 @@ +@@ -140,6 +_,11 @@ public void saveWithoutMetadata(ValueOutput output) { this.saveAdditional(output); output.store("components", DataComponentMap.CODEC, this.components); @@ -60,7 +60,7 @@ } public final CompoundTag saveCustomOnly(HolderLookup.Provider registries) { -@@ -157,6 +_,11 @@ +@@ -155,6 +_,11 @@ public void saveCustomOnly(ValueOutput output) { this.saveAdditional(output); @@ -72,7 +72,7 @@ } public void saveId(ValueOutput output) { -@@ -289,6 +_,12 @@ +@@ -285,6 +_,12 @@ } public final void applyComponents(DataComponentMap components, DataComponentPatch patch) { @@ -85,7 +85,7 @@ final Set> set = new HashSet<>(); set.add(DataComponents.BLOCK_ENTITY_DATA); set.add(DataComponents.BLOCK_STATE); -@@ -309,6 +_,10 @@ +@@ -304,6 +_,10 @@ }); DataComponentPatch dataComponentPatch = patch.forget(set::contains); this.components = dataComponentPatch.split().added(); @@ -96,17 +96,17 @@ } protected void collectImplicitComponents(DataComponentMap.Builder components) { -@@ -345,6 +_,27 @@ +@@ -339,6 +_,27 @@ @Override public void registerDebugValues(ServerLevel level, DebugValueSource.Registration registrar) { } + + // CraftBukkit start - add method -+ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { ++ public org.bukkit.inventory.@Nullable InventoryHolder getOwner() { + return getOwner(true); + } + -+ public @Nullable org.bukkit.inventory.InventoryHolder getOwner(boolean useSnapshot) { ++ public org.bukkit.inventory.@Nullable InventoryHolder getOwner(boolean useSnapshot) { + if (this.level == null) return null; + org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, this.worldPosition); + org.bukkit.block.BlockState state = block.getState(useSnapshot); // Paper diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch index d84df75e0ba4..9121a4882188 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BrushableBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrushableBlockEntity.java -@@ -68,9 +_,26 @@ +@@ -66,9 +_,26 @@ return false; } else { this.coolDownEndsAtTick = startTick + 10L; @@ -29,7 +29,7 @@ this.brushingCompleted(level, brusher, stack); return true; } else { -@@ -78,7 +_,7 @@ +@@ -76,7 +_,7 @@ int completionState1 = this.getCompletionState(); if (completionState != completionState1) { BlockState blockState = this.getBlockState(); @@ -38,7 +38,7 @@ level.setBlock(this.getBlockPos(), blockState1, Block.UPDATE_ALL); } -@@ -119,6 +_,11 @@ +@@ -117,6 +_,11 @@ this.dropContent(level, brusher, stack); BlockState blockState = this.getBlockState(); level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_BRUSH_BLOCK_COMPLETE, this.getBlockPos(), Block.getId(blockState)); @@ -50,7 +50,7 @@ Block turnsInto; if (this.getBlockState().getBlock() instanceof BrushableBlock brushableBlock) { turnsInto = brushableBlock.getTurnsInto(); -@@ -126,6 +_,11 @@ +@@ -124,6 +_,11 @@ turnsInto = Blocks.AIR; } @@ -62,7 +62,7 @@ level.setBlock(this.worldPosition, turnsInto.defaultBlockState(), Block.UPDATE_ALL); } -@@ -142,7 +_,12 @@ +@@ -140,7 +_,12 @@ double d5 = blockPos.getZ() + 0.5 * d1 + d2; ItemEntity itemEntity = new ItemEntity(level, d3, d4, d5, this.item.split(level.random.nextInt(21) + 10)); itemEntity.setDeltaMovement(Vec3.ZERO); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch index 5730d843586a..da783a5a8b1d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java -@@ -165,8 +_,20 @@ +@@ -164,8 +_,20 @@ } private static void applyEffects(Level level, BlockPos pos, List positions) { @@ -21,7 +21,7 @@ int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); -@@ -175,20 +_,25 @@ +@@ -174,20 +_,25 @@ if (!entitiesOfClass.isEmpty()) { for (Player player : entitiesOfClass) { if (pos.closerThan(player.blockPosition(), i) && player.isInWaterOrRain()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java.patch index 0401a584fd95..6e186effe97c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java +++ b/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java @@ -23,6 +_,48 @@ - import net.minecraft.world.ticks.ContainerSingleItem; + import org.jspecify.annotations.Nullable; public class DecoratedPotBlockEntity extends BlockEntity implements RandomizableContainer, ContainerSingleItem.BlockContainerSingleItem { + @@ -40,7 +40,7 @@ + } + + @Override -+ public @Nullable org.bukkit.Location getLocation() { ++ public org.bukkit.@Nullable Location getLocation() { + if (this.level == null) return null; + return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.worldPosition, this.level); + } @@ -49,7 +49,7 @@ public static final String TAG_SHERDS = "sherds"; public static final String TAG_ITEM = "item"; public static final int EVENT_POT_WOBBLES = 1; -@@ -47,8 +_,8 @@ +@@ -45,8 +_,8 @@ output.store("sherds", PotDecorations.CODEC, this.decorations); } @@ -60,7 +60,7 @@ } } -@@ -70,7 +_,14 @@ +@@ -68,7 +_,14 @@ @Override public CompoundTag getUpdateTag(HolderLookup.Provider registries) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch index 4dde6baac79e..b6f64612fd73 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch @@ -237,13 +237,12 @@ } destination.setChanged(); -@@ -337,14 +_,59 @@ +@@ -337,12 +_,56 @@ return stack; } + // CraftBukkit start -+ @Nullable -+ private static Container runHopperInventorySearchEvent( ++ private static @Nullable Container runHopperInventorySearchEvent( + Container container, + org.bukkit.craftbukkit.block.CraftBlock hopper, + org.bukkit.craftbukkit.block.CraftBlock searchLocation, @@ -260,8 +259,7 @@ + } + // CraftBukkit end + - @Nullable - private static Container getAttachedContainer(Level level, BlockPos pos, HopperBlockEntity blockEntity) { + private static @Nullable Container getAttachedContainer(Level level, BlockPos pos, HopperBlockEntity blockEntity) { - return getContainerAt(level, pos.relative(blockEntity.facing)); + // Paper start + BlockPos searchPosition = pos.relative(blockEntity.facing); @@ -279,8 +277,7 @@ + // Paper end } - @Nullable - private static Container getSourceContainer(Level level, Hopper hopper, BlockPos pos, BlockState state) { + private static @Nullable Container getSourceContainer(Level level, Hopper hopper, BlockPos pos, BlockState state) { - return getContainerAt(level, pos, state, hopper.getLevelX(), hopper.getLevelY() + 1.0, hopper.getLevelZ()); + // Paper start + final Container inventory = HopperBlockEntity.getContainerAt(level, pos, state, hopper.getLevelX(), hopper.getLevelY() + 1.0D, hopper.getLevelZ()); @@ -299,10 +296,10 @@ } public static List getItemsAtAndAbove(Level level, Hopper hopper) { -@@ -369,6 +_,7 @@ +@@ -364,6 +_,7 @@ + } - @Nullable - private static Container getBlockContainer(Level level, BlockPos pos, BlockState state) { + private static @Nullable Container getBlockContainer(Level level, BlockPos pos, BlockState state) { + if (!level.spigotConfig.hopperCanLoadChunks && !level.hasChunkAt(pos)) return null; // Spigot Block block = state.getBlock(); if (block instanceof WorldlyContainerHolder) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch index 8a59797f674b..ed5cfb0cd0e0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch @@ -37,7 +37,7 @@ + } + + @Override -+ public @Nullable org.bukkit.Location getLocation() { ++ public org.bukkit.@Nullable Location getLocation() { + if (LecternBlockEntity.this.level == null) return null; + return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(LecternBlockEntity.this.worldPosition, LecternBlockEntity.this.level); + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch index 83a42ad68e36..e2410f2e654c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -@@ -116,4 +_,13 @@ +@@ -113,4 +_,13 @@ output.discard("LootTable"); output.discard("LootTableSeed"); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch index 320946a1b736..1079d36b8d11 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java -@@ -88,6 +_,13 @@ +@@ -87,6 +_,13 @@ + } - @Nullable - public static ServerPlayer tryGetPlayer(@Nullable Entity entity) { + public static @Nullable ServerPlayer tryGetPlayer(@Nullable Entity entity) { + // Paper start - check global player list where appropriate; ensure level is the same for sculk events + final ServerPlayer player = tryGetPlayer0(entity); + return player != null && player.level() == entity.level() ? player : null; @@ -14,7 +14,7 @@ if (entity instanceof ServerPlayer serverPlayer) { return serverPlayer; } else if (entity != null && entity.getControllingPassenger() instanceof ServerPlayer serverPlayer) { -@@ -163,7 +_,7 @@ +@@ -162,7 +_,7 @@ private boolean trySummonWarden(ServerLevel level) { return this.warningLevel >= 4 && SpawnUtil.trySpawnMob( diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch index 4bce3675d4b3..28174a42b059 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -@@ -50,6 +_,42 @@ - @Nullable - private final DyeColor color; +@@ -49,6 +_,42 @@ + private float progressOld; + private final @Nullable DyeColor color; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList<>(); @@ -43,7 +43,7 @@ public ShulkerBoxBlockEntity(@Nullable DyeColor color, BlockPos pos, BlockState blockState) { super(BlockEntityType.SHULKER_BOX, pos, blockState); this.color = color; -@@ -172,6 +_,7 @@ +@@ -171,6 +_,7 @@ } this.openCount++; @@ -51,7 +51,7 @@ this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); if (this.openCount == 1) { this.level.gameEvent(user.getLivingEntity(), GameEvent.CONTAINER_OPEN, this.worldPosition); -@@ -185,6 +_,7 @@ +@@ -184,6 +_,7 @@ public void stopOpen(ContainerUser user) { if (!this.remove && !user.getLivingEntity().isSpectator()) { this.openCount--; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch index 8ab294db9ede..5e3de0e9dedc 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SignBlockEntity.java -@@ -59,10 +_,15 @@ +@@ -58,10 +_,15 @@ } public boolean isFacingFrontText(Player player) { @@ -18,7 +18,7 @@ float yRotationDegrees = signBlock.getYRotationDegrees(this.getBlockState()); float f = (float)(Mth.atan2(d1, d) * 180.0F / (float)Math.PI) - 90.0F; return Mth.degreesDifferenceAbs(yRotationDegrees, f) <= 90.0F; -@@ -130,11 +_,13 @@ +@@ -129,11 +_,13 @@ public void updateSignText(Player player, boolean isFrontText, List filteredText) { if (!this.isWaxed() && player.getUUID().equals(this.getPlayerWhoMayEdit()) && this.level != null) { @@ -33,7 +33,7 @@ } } -@@ -143,19 +_,41 @@ +@@ -142,19 +_,41 @@ return this.setText(updater.apply(text), isFrontText); } @@ -78,7 +78,7 @@ return text; } -@@ -194,7 +_,23 @@ +@@ -193,7 +_,23 @@ Style style = component.getStyle(); switch (style.getClickEvent()) { case ClickEvent.RunCommand runCommand: @@ -103,7 +103,7 @@ flag = true; break; case ClickEvent.ShowDialog showDialog: -@@ -213,12 +_,56 @@ +@@ -212,12 +_,56 @@ return flag; } @@ -164,10 +164,10 @@ } @Override -@@ -237,12 +_,17 @@ +@@ -235,12 +_,17 @@ + } - @Nullable - public UUID getPlayerWhoMayEdit() { + public @Nullable UUID getPlayerWhoMayEdit() { + // CraftBukkit start - unnecessary sign ticking removed, so do this lazily + if (this.level != null && this.playerWhoMayEdit != null) { + this.clearInvalidPlayerWhoMayEdit(this, this.level, this.playerWhoMayEdit); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch index 09f5bd372611..c9cd6f58f8f0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +++ b/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java -@@ -131,7 +_,7 @@ +@@ -129,7 +_,7 @@ + } - @Nullable - public Vec3 getPortalPosition(ServerLevel level, BlockPos pos) { + public @Nullable Vec3 getPortalPosition(ServerLevel level, BlockPos pos) { - if (this.exitPortal == null && level.dimension() == Level.END) { + if (this.exitPortal == null && level.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.END) { // CraftBukkit - work in alternate worlds BlockPos blockPos = findOrCreateValidTeleportPos(level, pos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch index bcf8b430a4d4..97db3c8b6051 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java +++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java -@@ -219,7 +_,14 @@ +@@ -216,7 +_,14 @@ nextSpawnData.getEquipment().ifPresent(mob::equip); } @@ -16,7 +16,7 @@ return Optional.empty(); } -@@ -234,10 +_,24 @@ +@@ -231,10 +_,24 @@ } public void ejectReward(ServerLevel level, BlockPos pos, ResourceKey lootTable) { @@ -42,7 +42,7 @@ for (ItemStack itemStack : randomItems) { DefaultDispenseItemBehavior.spawnItem(level, itemStack, 2, Direction.UP, Vec3.atBottomCenterOf(pos).relative(Direction.UP, 1.2)); } -@@ -407,6 +_,35 @@ +@@ -400,6 +_,35 @@ this.requiredPlayerRange ); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java.patch index 702a9a8f1cff..f06bd4ea7c52 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java +++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java -@@ -188,7 +_,7 @@ +@@ -186,7 +_,7 @@ mob.dropPreservedEquipment(level); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch index 8c272f01a761..3af49bdb93d6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java +++ b/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java -@@ -258,7 +_,13 @@ +@@ -256,7 +_,13 @@ if (!list.isEmpty()) { player.awardStat(Stats.ITEM_USED.get(stack.getItem())); stack.consume(config.keyItem().getCount(), player); @@ -15,7 +15,7 @@ serverData.addToRewardedPlayers(player); sharedData.updateConnectedPlayersWithinRange(level, pos, serverData, config, config.deactivationRange()); } -@@ -267,8 +_,30 @@ +@@ -265,8 +_,30 @@ } static void setVaultState(ServerLevel level, BlockPos pos, BlockState oldState, BlockState newState, VaultConfig config, VaultSharedData sharedData) { @@ -48,7 +48,7 @@ level.setBlock(pos, newState, Block.UPDATE_ALL); vaultState.onTransition(level, pos, vaultState1, config, sharedData, newState.getValue(VaultBlock.OMINOUS)); } -@@ -280,6 +_,11 @@ +@@ -278,6 +_,11 @@ ItemStack randomDisplayItemFromLootTable = getRandomDisplayItemFromLootTable( level, pos, config.overrideLootTableToDisplay().orElse(config.lootTable()) ); @@ -60,7 +60,7 @@ sharedData.setDisplayItem(randomDisplayItemFromLootTable); } } -@@ -302,10 +_,24 @@ +@@ -300,10 +_,24 @@ VaultSharedData sharedData, List itemsToEject ) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch index 1ad9aa9a7d14..40be0c223f58 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/grower/TreeGrower.java +++ b/net/minecraft/world/level/block/grower/TreeGrower.java -@@ -132,6 +_,7 @@ +@@ -130,6 +_,7 @@ .get(configuredMegaFeature) .orElse(null); if (holder != null) { @@ -8,7 +8,7 @@ for (int i = 0; i >= -1; i--) { for (int i1 = 0; i1 >= -1; i1--) { if (isTwoByTwoSapling(state, level, pos, i, i1)) { -@@ -164,6 +_,7 @@ +@@ -162,6 +_,7 @@ if (holder1 == null) { return false; } else { @@ -16,7 +16,7 @@ ConfiguredFeature configuredFeature2 = holder1.value(); BlockState blockState1 = level.getFluidState(pos).createLegacyBlock(); level.setBlock(pos, blockState1, Block.UPDATE_NONE); -@@ -198,4 +_,58 @@ +@@ -196,4 +_,58 @@ return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch index 1b5e5c96d717..bde64a653281 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch @@ -11,7 +11,7 @@ } + // CraftBukkit start -+ protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston, @Nullable net.minecraft.world.item.context.UseOnContext context) { ++ protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston, net.minecraft.world.item.context.@Nullable UseOnContext context) { + this.onPlace(state, level, pos, oldState, movedByPiston); + } + // CraftBukkit end @@ -44,13 +44,12 @@ } protected boolean canBeReplaced(BlockState state, Fluid fluid) { -@@ -469,6 +_,16 @@ +@@ -466,6 +_,15 @@ this.instrument = properties.instrument; this.replaceable = properties.replaceable; } + // Paper start - Perf: impl cached craft block data, lazy load to fix issue with loading at the wrong time -+ @Nullable -+ private org.bukkit.craftbukkit.block.data.CraftBlockData cachedCraftBlockData; ++ private org.bukkit.craftbukkit.block.data.@Nullable CraftBlockData cachedCraftBlockData; + + public org.bukkit.craftbukkit.block.data.CraftBlockData createCraftBlockData() { + if (this.cachedCraftBlockData == null) this.cachedCraftBlockData = org.bukkit.craftbukkit.block.data.CraftBlockData.createData(this.asState()); @@ -61,7 +60,7 @@ private boolean calculateSolid() { if (this.owner.properties.forceSolidOn) { -@@ -488,12 +_,14 @@ +@@ -485,12 +_,14 @@ } } @@ -76,7 +75,7 @@ this.legacySolid = this.calculateSolid(); this.occlusionShape = this.canOcclude ? this.owner.getOcclusionShape(this.asState()) : Shapes.empty(); -@@ -532,6 +_,11 @@ +@@ -529,6 +_,11 @@ public boolean isSolid() { return this.legacySolid; } @@ -88,7 +87,7 @@ public boolean isValidSpawn(BlockGetter level, BlockPos pos, EntityType entityType) { return this.getBlock().properties.isValidSpawn.test(this.asState(), level, pos, entityType); -@@ -553,19 +_,19 @@ +@@ -550,19 +_,19 @@ return this.occlusionShape; } @@ -113,7 +112,7 @@ return this.isAir; } -@@ -635,14 +_,14 @@ +@@ -632,14 +_,14 @@ } public PushReaction getPistonPushReaction() { @@ -130,7 +129,7 @@ return this.canOcclude; } -@@ -729,7 +_,13 @@ +@@ -726,7 +_,13 @@ } public void onPlace(Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) { @@ -139,13 +138,13 @@ + this.onPlace(level, pos, oldState, movedByPiston, null); + } + -+ public void onPlace(Level level, BlockPos pos, BlockState oldState, boolean movedByPiston, @Nullable net.minecraft.world.item.context.UseOnContext context) { ++ public void onPlace(Level level, BlockPos pos, BlockState oldState, boolean movedByPiston, net.minecraft.world.item.context.@Nullable UseOnContext context) { + this.getBlock().onPlace(this.asState(), level, pos, oldState, movedByPiston, context); + // CraftBukkit end } public void affectNeighborsAfterRemoval(ServerLevel level, BlockPos pos, boolean movedByPiston) { -@@ -754,6 +_,7 @@ +@@ -751,6 +_,7 @@ public void spawnAfterBreak(ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { this.getBlock().spawnAfterBreak(this.asState(), level, pos, stack, dropExperience); @@ -153,7 +152,7 @@ } public List getDrops(LootParams.Builder lootParams) { -@@ -862,11 +_,11 @@ +@@ -857,11 +_,11 @@ return this.getBlock().builtInRegistryHolder().is(block); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/state/properties/Property.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/state/properties/Property.java.patch index 78b6de8b7ee6..9087bd5e8570 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/state/properties/Property.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/state/properties/Property.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/state/properties/Property.java +++ b/net/minecraft/world/level/block/state/properties/Property.java -@@ -72,7 +_,7 @@ +@@ -71,7 +_,7 @@ @Override public boolean equals(Object other) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch index 8028eaa10955..05cc529bf4e7 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java @@ -64,7 +_,7 @@ - protected final ShortList[] postProcessing; + protected final @Nullable ShortList[] postProcessing; private volatile boolean unsaved; private volatile boolean isLightCorrect; - protected final ChunkPos chunkPos; + protected final ChunkPos chunkPos; public final long coordinateKey; public final int locX; public final int locZ; // Paper - cache coordinate key private long inhabitedTime; - @Nullable @Deprecated -@@ -82,6 +_,10 @@ + private @Nullable BiomeGenerationSettings carverBiomeSettings; +@@ -79,6 +_,10 @@ public final Map blockEntities = new Object2ObjectOpenHashMap<>(); protected final LevelHeightAccessor levelHeightAccessor; protected final LevelChunkSection[] sections; @@ -20,8 +20,8 @@ public ChunkAccess( ChunkPos chunkPos, -@@ -92,7 +_,8 @@ - @Nullable LevelChunkSection[] sections, +@@ -89,7 +_,8 @@ + LevelChunkSection @Nullable [] sections, @Nullable BlendingData blendingData ) { - this.chunkPos = chunkPos; @@ -30,16 +30,16 @@ this.upgradeData = upgradeData; this.levelHeightAccessor = levelHeightAccessor; this.sections = new LevelChunkSection[levelHeightAccessor.getSectionsCount()]; -@@ -123,6 +_,8 @@ +@@ -120,6 +_,8 @@ return GameEventListenerRegistry.NOOP; } + public abstract BlockState getBlockState(final int x, final int y, final int z); // Paper + - @Nullable - public BlockState setBlockState(BlockPos pos, BlockState state) { + public @Nullable BlockState setBlockState(BlockPos pos, BlockState state) { return this.setBlockState(pos, state, Block.UPDATE_ALL); -@@ -274,6 +_,7 @@ + } +@@ -266,6 +_,7 @@ public boolean tryMarkSaved() { if (this.unsaved) { this.unsaved = false; @@ -47,7 +47,7 @@ return true; } else { return false; -@@ -281,7 +_,7 @@ +@@ -273,7 +_,7 @@ } public boolean isUnsaved() { @@ -56,7 +56,7 @@ } public abstract ChunkStatus getPersistedStatus(); -@@ -447,6 +_,22 @@ +@@ -438,6 +_,22 @@ throw new ReportedException(crashReport); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch index ea796e005fc8..80080c75bec3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch @@ -11,7 +11,7 @@ } public Optional>> getTypeNameForDataFixer() { -@@ -130,6 +_,24 @@ +@@ -129,6 +_,24 @@ if (SharedConstants.DEBUG_DISABLE_FEATURES) { return null; } else { @@ -36,7 +36,7 @@ ChunkGeneratorStructureState generatorState = level.getChunkSource().getGeneratorState(); Map>> map = new Object2ObjectArrayMap<>(); -@@ -225,6 +_,7 @@ +@@ -223,6 +_,7 @@ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); for (ChunkPos chunkPos : ringPositionsFor) { @@ -44,7 +44,7 @@ mutableBlockPos.set(SectionPos.sectionToBlockCoord(chunkPos.x, 8), 32, SectionPos.sectionToBlockCoord(chunkPos.z, 8)); double d1 = mutableBlockPos.distSqr(pos); boolean flag = pair == null || d1 < d; -@@ -258,11 +_,15 @@ +@@ -255,11 +_,15 @@ int spacing = spreadPlacement.spacing(); for (int i = -z; i <= z; i++) { @@ -64,7 +64,7 @@ int i2 = x + spacing * i; int i3 = y + spacing * i1; ChunkPos potentialStructureChunk = spreadPlacement.getPotentialStructureChunk(seed, i2, i3); -@@ -315,7 +_,7 @@ +@@ -311,7 +_,7 @@ } } @@ -73,7 +73,7 @@ ChunkPos pos = chunk.getPos(); if (!SharedConstants.debugVoidTerrain(pos)) { SectionPos sectionPos = SectionPos.of(pos, level.getMinSectionY()); -@@ -386,7 +_,14 @@ +@@ -382,7 +_,14 @@ int i3 = ints[i2]; PlacedFeature placedFeature = stepFeatureData1.features().get(i3); Supplier supplier1 = () -> registry1.getResourceKey(placedFeature).map(Object::toString).orElseGet(placedFeature::toString); @@ -89,7 +89,7 @@ try { level.setCurrentlyGenerating(supplier1); -@@ -411,6 +_,32 @@ +@@ -407,6 +_,32 @@ } } } @@ -122,7 +122,7 @@ private static BoundingBox getWritableArea(ChunkAccess chunk) { ChunkPos pos = chunk.getPos(); -@@ -488,7 +_,7 @@ +@@ -484,7 +_,7 @@ } } @@ -131,7 +131,7 @@ if (list.size() == 1) { this.tryGenerateStructure( list.get(0), -@@ -583,6 +_,14 @@ +@@ -579,6 +_,14 @@ predicate ); if (structureStart.isValid()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch index 922eaedc8558..865117b6b939 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch @@ -145,7 +145,7 @@ double d = randomSource.nextDouble() * Math.PI * 2.0; int i = 0; int i1 = 0; -@@ -197,7 +_,7 @@ +@@ -196,7 +_,7 @@ for (int i = x - range; i <= x + range; i++) { for (int i1 = z - range; i1 <= z + range; i1++) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch index e857245761ff..bf030502e8ce 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch @@ -11,6 +11,6 @@ + } + // Paper end + - @Nullable @Override - public BlockState setBlockState(BlockPos pos, BlockState state, @Block.UpdateFlags int flags) { + public @Nullable BlockState setBlockState(BlockPos pos, BlockState state, @Block.UpdateFlags int flags) { + return null; diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch index 7346ceb90101..332679661db4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/ImposterProtoChunk.java +++ b/net/minecraft/world/level/chunk/ImposterProtoChunk.java -@@ -50,6 +_,13 @@ +@@ -49,6 +_,13 @@ return this.wrapped.getBlockState(pos); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch index c6fcf3b3d1df..0afd6ef03354 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -1,15 +1,14 @@ --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -86,7 +_,7 @@ +@@ -87,13 +_,21 @@ }; private final Map tickersInLevel = Maps.newHashMap(); public boolean loaded; - public final Level level; + public final ServerLevel level; // CraftBukkit - type - @Nullable - private Supplier fullStatus; - @Nullable -@@ -95,6 +_,14 @@ + private @Nullable Supplier fullStatus; + private LevelChunk.@Nullable PostLoadProcessor postLoad; + private final Int2ObjectMap gameEventListenerRegistrySections; private final LevelChunkTicks blockTicks; private final LevelChunkTicks fluidTicks; private LevelChunk.UnsavedListener unsavedListener = chunkPos -> {}; @@ -24,7 +23,7 @@ public LevelChunk(Level level, ChunkPos pos) { this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null); -@@ -112,7 +_,7 @@ +@@ -111,7 +_,7 @@ @Nullable BlendingData blendingData ) { super(pos, data, level, level.palettedContainerFactory(), inhabitedTime, sections, blendingData); @@ -33,7 +32,7 @@ this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap<>(); for (Heightmap.Types types : Heightmap.Types.values()) { -@@ -164,6 +_,10 @@ +@@ -163,6 +_,10 @@ this.skyLightSources = chunk.skyLightSources; this.setLightCorrect(chunk.isLightCorrect()); this.markUnsaved(); @@ -44,7 +43,7 @@ } public void setUnsavedListener(LevelChunk.UnsavedListener unsavedListener) { -@@ -172,6 +_,12 @@ +@@ -171,6 +_,12 @@ unsavedListener.setUnsaved(this.chunkPos); } } @@ -57,7 +56,7 @@ @Override public void markUnsaved() { -@@ -205,8 +_,28 @@ +@@ -204,8 +_,28 @@ : super.getListenerRegistry(sectionY); } @@ -86,7 +85,7 @@ int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); -@@ -241,28 +_,42 @@ +@@ -240,28 +_,42 @@ } } @@ -130,8 +129,8 @@ + */ // Paper - Perf: Optimise Chunk#getFluid } - @Nullable -@@ -324,7 +_,7 @@ + @Override +@@ -322,7 +_,7 @@ if (!section.getBlockState(i, i1, i2).is(block)) { return null; } else { @@ -140,10 +139,10 @@ state.onPlace(this.level, pos, blockState, flag1); } -@@ -378,7 +_,12 @@ +@@ -373,7 +_,12 @@ + } - @Nullable - public BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType) { + public @Nullable BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType) { - BlockEntity blockEntity = this.blockEntities.get(pos); + // CraftBukkit start + BlockEntity blockEntity = this.level.capturedTileEntities.get(pos); @@ -154,7 +153,7 @@ if (blockEntity == null) { CompoundTag compoundTag = this.pendingBlockEntities.remove(pos); if (compoundTag != null) { -@@ -433,7 +_,13 @@ +@@ -428,7 +_,13 @@ BlockPos blockPos = blockEntity.getBlockPos(); BlockState blockState = this.getBlockState(blockPos); if (!blockState.hasBlockEntity()) { @@ -169,7 +168,7 @@ } else { BlockState blockState1 = blockEntity.getBlockState(); if (blockState != blockState1) { -@@ -481,6 +_,11 @@ +@@ -475,6 +_,11 @@ public void removeBlockEntity(BlockPos pos) { if (this.isInLevel()) { BlockEntity blockEntity = this.blockEntities.remove(pos); @@ -181,7 +180,7 @@ if (blockEntity != null) { if (this.level instanceof ServerLevel serverLevel) { this.removeGameEventListener(blockEntity, serverLevel); -@@ -524,6 +_,65 @@ +@@ -518,6 +_,65 @@ } } @@ -247,7 +246,7 @@ public boolean isEmpty() { return false; } -@@ -762,23 +_,24 @@ +@@ -756,23 +_,24 @@ if (this.blockEntity.getType().isValid(blockState)) { this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity); this.loggedInvalidBlockState = false; diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch index 4024c49f2911..f0f46aee2a6d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/net/minecraft/world/level/chunk/ProtoChunk.java -@@ -93,14 +_,31 @@ +@@ -90,14 +_,31 @@ return new ChunkAccess.PackedTicks(this.blockTicks.pack(gameTime), this.fluidTicks.pack(gameTime)); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch index adc8aaa96866..b04f2e617633 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch @@ -24,7 +24,7 @@ if (sectorNumber < 2) { LOGGER.warn("Region file {} has invalid sector at index: {}; sector {} overlaps with header", path, i1, sectorNumber); this.offsets.put(i1, 0); -@@ -117,6 +_,13 @@ +@@ -116,6 +_,13 @@ } else { int sectorNumber = getSectorNumber(offset); int numSectors = getNumSectors(offset); @@ -38,7 +38,7 @@ int i = numSectors * 4096; ByteBuffer byteBuffer = ByteBuffer.allocate(i); this.file.read(byteBuffer, sectorNumber * 4096); -@@ -260,6 +_,7 @@ +@@ -257,6 +_,7 @@ return true; } } catch (IOException var9) { @@ -46,7 +46,7 @@ return false; } } -@@ -331,6 +_,11 @@ +@@ -328,6 +_,11 @@ try (FileChannel fileChannel = FileChannel.open(path, StandardOpenOption.CREATE, StandardOpenOption.WRITE)) { chunkData.position(5); fileChannel.write(chunkData); diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch index 9af4f5c09254..3d3404cdedc8 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch @@ -22,10 +22,10 @@ RegionFile regionFile1 = new RegionFile(this.info, path, this.folder, this.sync); this.regionCache.putAndMoveToFirst(packedChunkPos, regionFile1); return regionFile1; -@@ -49,7 +_,12 @@ +@@ -48,7 +_,12 @@ + } - @Nullable - public CompoundTag read(ChunkPos chunkPos) throws IOException { + public @Nullable CompoundTag read(ChunkPos chunkPos) throws IOException { - RegionFile regionFile = this.getRegionFile(chunkPos); + // 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); @@ -36,7 +36,7 @@ CompoundTag var4; try (DataInputStream chunkDataInputStream = regionFile.getChunkDataInputStream(chunkPos)) { -@@ -64,7 +_,12 @@ +@@ -63,7 +_,12 @@ } public void scanChunk(ChunkPos chunkPos, StreamTagVisitor visitor) throws IOException { @@ -50,7 +50,7 @@ try (DataInputStream chunkDataInputStream = regionFile.getChunkDataInputStream(chunkPos)) { if (chunkDataInputStream != null) { -@@ -75,7 +_,7 @@ +@@ -74,7 +_,7 @@ protected void write(ChunkPos chunkPos, @Nullable CompoundTag chunkData) throws IOException { if (!SharedConstants.DEBUG_DONT_SAVE_WORLD) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileVersion.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileVersion.java.patch index 86785dab5a50..26636eb668ec 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileVersion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileVersion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/storage/RegionFileVersion.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileVersion.java -@@ -61,6 +_,16 @@ +@@ -60,6 +_,16 @@ private final RegionFileVersion.StreamWrapper inputWrapper; private final RegionFileVersion.StreamWrapper outputWrapper; diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch index d35be8fc46a9..29cbf85f57fb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch @@ -4,11 +4,11 @@ List entities, List blockEntities, CompoundTag structureData -+ , @Nullable net.minecraft.nbt.Tag persistentDataContainer // CraftBukkit - persistentDataContainer ++ , net.minecraft.nbt.@Nullable Tag persistentDataContainer // CraftBukkit - persistentDataContainer ) { private static final Codec>> BLOCK_TICKS_CODEC = SavedTick.codec(BuiltInRegistries.BLOCK.byNameCodec()).listOf(); private static final Codec>> FLUID_TICKS_CODEC = SavedTick.codec(BuiltInRegistries.FLUID.byNameCodec()).listOf(); -@@ -107,12 +_,38 @@ +@@ -107,11 +_,37 @@ public static final String BLOCK_LIGHT_TAG = "BlockLight"; public static final String SKY_LIGHT_TAG = "SkyLight"; @@ -30,7 +30,6 @@ + private static final boolean JUST_CORRUPT_IT = Boolean.getBoolean("Paper.ignoreWorldDataVersion"); + // Paper end - Do not let the server load chunks from newer versions + - @Nullable public static SerializableChunkData parse(LevelHeightAccessor level, PalettedContainerFactory containerFactory, CompoundTag tag) { if (tag.getString("Status").isEmpty()) { return null; @@ -48,16 +47,16 @@ long longOr = tag.getLongOr("LastUpdate", 0L); long longOr1 = tag.getLongOr("InhabitedTime", 0L); ChunkStatus chunkStatus = tag.read("Status", ChunkStatus.CODEC).orElse(ChunkStatus.EMPTY); -@@ -149,7 +_,7 @@ +@@ -150,7 +_,7 @@ CompoundTag compoundOrEmpty = tag.getCompoundOrEmpty("structures"); - ListTag listOrEmpty2 = tag.getListOrEmpty("sections"); - List list5 = new ArrayList<>(listOrEmpty2.size()); + ListTag listOrEmpty1 = tag.getListOrEmpty("sections"); + List list5 = new ArrayList<>(listOrEmpty1.size()); - Codec>> codec = containerFactory.biomeContainerCodec(); + Codec>> codec = containerFactory.biomeContainerRWCodec(); // CraftBukkit - read/write Codec> codec1 = containerFactory.blockStatesContainerCodec(); - for (int i2 = 0; i2 < listOrEmpty2.size(); i2++) { -@@ -166,7 +_,7 @@ + for (int i2 = 0; i2 < listOrEmpty1.size(); i2++) { +@@ -167,7 +_,7 @@ .getOrThrow(SerializableChunkData.ChunkReadException::new) ) .orElseGet(containerFactory::createForBlockStates); @@ -66,7 +65,7 @@ .map( compoundTag1 -> codec.parse(NbtOps.INSTANCE, compoundTag1) .promotePartial(string -> logErrors(chunkPos, byteOr, string)) -@@ -203,6 +_,7 @@ +@@ -204,6 +_,7 @@ list3, list4, compoundOrEmpty @@ -74,7 +73,7 @@ ); } } -@@ -287,6 +_,12 @@ +@@ -288,6 +_,12 @@ } } @@ -87,7 +86,7 @@ chunkAccess.setLightCorrect(this.lightCorrect); EnumSet set = EnumSet.noneOf(Heightmap.Types.class); -@@ -390,6 +_,12 @@ +@@ -394,6 +_,12 @@ CompoundTag compoundTag = packStructureData( StructurePieceSerializationContext.fromLevel(level), pos, chunk.getAllStarts(), chunk.getAllReferences() ); @@ -100,7 +99,7 @@ return new SerializableChunkData( level.palettedContainerFactory(), pos, -@@ -409,6 +_,7 @@ +@@ -413,6 +_,7 @@ list2, list1, compoundTag @@ -108,7 +107,7 @@ ); } } -@@ -476,6 +_,11 @@ +@@ -480,6 +_,11 @@ this.heightmaps.forEach((types, longs) -> compoundTag2.put(types.getSerializationKey(), new LongArrayTag(longs))); compoundTag.put("Heightmaps", compoundTag2); compoundTag.put("structures", this.structureData); @@ -120,7 +119,7 @@ return compoundTag; } -@@ -557,6 +_,12 @@ +@@ -560,6 +_,12 @@ } else { StructureStart structureStart = StructureStart.loadStaticStart(context, compoundOrEmpty.getCompoundOrEmpty(string), seed); if (structureStart != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch index ad78c58b3e8e..e9b4c4a5a21e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch @@ -22,7 +22,7 @@ } - public CompoundTag upgradeChunkTag(CompoundTag tag, int fallbackVersion, @Nullable CompoundTag contextTag) { -+ public CompoundTag upgradeChunkTag(CompoundTag tag, int fallbackVersion, @Nullable CompoundTag contextTag, @Nullable net.minecraft.world.level.LevelAccessor levelAccessor) { // CraftBukkit ++ public CompoundTag upgradeChunkTag(CompoundTag tag, int fallbackVersion, @Nullable CompoundTag contextTag, net.minecraft.world.level.@Nullable LevelAccessor levelAccessor) { // CraftBukkit int dataVersion = NbtUtils.getDataVersion(tag, fallbackVersion); if (dataVersion == SharedConstants.getCurrentVersion().dataVersion().version()) { return tag; diff --git a/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch b/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch index 201c35f63b13..81e8c3b40392 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch @@ -11,7 +11,7 @@ ) .setPlayBossMusic(true) .setCreateWorldFog(true); -@@ -112,7 +_,12 @@ +@@ -108,7 +_,12 @@ if (data.isRespawning) { this.respawnStage = DragonRespawnAnimation.START; } @@ -25,7 +25,7 @@ this.portalLocation = data.exitPortalLocation.orElse(null); this.gateways.addAll(data.gateways.orElseGet(() -> { ObjectArrayList list = new ObjectArrayList<>(ContiguousSet.create(Range.closedOpen(0, 20), DiscreteDomain.integers())); -@@ -209,9 +_,9 @@ +@@ -205,9 +_,9 @@ this.dragonUUID = enderDragon.getUUID(); LOGGER.info("Found that there's a dragon still alive ({})", enderDragon); this.dragonKilled = false; @@ -37,7 +37,7 @@ this.dragonUUID = null; } } -@@ -366,12 +_,22 @@ +@@ -361,12 +_,22 @@ this.dragonEvent.setVisible(false); this.spawnExitPortal(true); this.spawnNewGateway(); @@ -66,7 +66,7 @@ } this.previouslyKilled = true; -@@ -385,6 +_,24 @@ +@@ -380,6 +_,24 @@ this.gateways.clear(); } @@ -91,7 +91,7 @@ private void spawnNewGateway() { if (!this.gateways.isEmpty()) { int i = this.gateways.remove(this.gateways.size() - 1); -@@ -415,6 +_,11 @@ +@@ -410,6 +_,11 @@ this.portalLocation = this.portalLocation.atY(Math.max(this.level.getMinY() + 1, this.portalLocation.getY())); } @@ -103,7 +103,7 @@ if (endPodiumFeature.place( FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), this.portalLocation )) { -@@ -434,6 +_,7 @@ +@@ -428,6 +_,7 @@ enderDragon.snapTo(this.origin.getX(), 128 + this.origin.getY(), this.origin.getZ(), this.level.random.nextFloat() * 360.0F, 0.0F); this.level.addFreshEntity(enderDragon); this.dragonUUID = enderDragon.getUUID(); @@ -111,7 +111,7 @@ } return enderDragon; -@@ -445,6 +_,10 @@ +@@ -439,6 +_,10 @@ this.ticksSinceDragonSeen = 0; if (dragon.hasCustomName()) { this.dragonEvent.setName(dragon.getDisplayName()); @@ -122,7 +122,7 @@ } } } -@@ -472,7 +_,13 @@ +@@ -466,7 +_,13 @@ return this.previouslyKilled; } @@ -137,7 +137,7 @@ if (this.dragonKilled && this.respawnStage == null) { BlockPos blockPos = this.portalLocation; if (blockPos == null) { -@@ -487,6 +_,22 @@ +@@ -481,6 +_,22 @@ blockPos = this.portalLocation; } @@ -160,7 +160,7 @@ List list = Lists.newArrayList(); BlockPos blockPos1 = blockPos.above(1); -@@ -494,18 +_,19 @@ +@@ -488,18 +_,19 @@ for (Direction direction : Direction.Plane.HORIZONTAL) { List entitiesOfClass = this.level.getEntitiesOfClass(EndCrystal.class, new AABB(blockPos1.relative(direction, 2))); if (entitiesOfClass.isEmpty()) { @@ -183,7 +183,7 @@ if (this.dragonKilled && this.respawnStage == null) { for (BlockPattern.BlockPatternMatch blockPatternMatch = this.findExitPortal(); blockPatternMatch != null; blockPatternMatch = this.findExitPortal()) { for (int i = 0; i < this.exitPortalPattern.getWidth(); i++) { -@@ -524,7 +_,9 @@ +@@ -518,7 +_,9 @@ this.respawnTime = 0; this.spawnExitPortal(false); this.respawnCrystals = crystals; diff --git a/paper-server/patches/sources/net/minecraft/world/level/gameevent/DynamicGameEventListener.java.patch b/paper-server/patches/sources/net/minecraft/world/level/gameevent/DynamicGameEventListener.java.patch index c0246df6bb4b..a920d35331d0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/gameevent/DynamicGameEventListener.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/gameevent/DynamicGameEventListener.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/gameevent/DynamicGameEventListener.java +++ b/net/minecraft/world/level/gameevent/DynamicGameEventListener.java -@@ -41,7 +_,7 @@ +@@ -40,7 +_,7 @@ private static void ifChunkExists(LevelReader level, @Nullable SectionPos sectionPos, Consumer dispatcherConsumer) { if (sectionPos != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch b/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch index a69e5d7e9436..e011a54caf62 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch @@ -9,7 +9,7 @@ ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay").orElse(0).forGetter(VibrationSystem.Data::getTravelTimeInTicks) ) .apply( -@@ -214,7 +_,14 @@ +@@ -212,7 +_,14 @@ return false; } else { Vec3 vec3 = position.get(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/gamerules/GameRules.java.patch b/paper-server/patches/sources/net/minecraft/world/level/gamerules/GameRules.java.patch new file mode 100644 index 000000000000..43016612fa34 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/gamerules/GameRules.java.patch @@ -0,0 +1,69 @@ +--- a/net/minecraft/world/level/gamerules/GameRules.java ++++ b/net/minecraft/world/level/gamerules/GameRules.java +@@ -16,6 +_,14 @@ + import org.jspecify.annotations.Nullable; + + public class GameRules { ++ // Paper start - allow disabling gamerule limits ++ private static final boolean DISABLE_LIMITS = Boolean.getBoolean("paper.disableGameRuleLimits"); ++ ++ private static int limit(final int limit, final int unlimited) { ++ return DISABLE_LIMITS ? unlimited : limit; ++ } ++ // Paper end - allow disabling gamerule limits ++ + public static final GameRule ADVANCE_TIME = registerBoolean("advance_time", GameRuleCategory.UPDATES, !SharedConstants.DEBUG_WORLD_RECREATE); + public static final GameRule ADVANCE_WEATHER = registerBoolean("advance_weather", GameRuleCategory.UPDATES, !SharedConstants.DEBUG_WORLD_RECREATE); + public static final GameRule ALLOW_ENTERING_NETHER_USING_PORTALS = registerBoolean( +@@ -113,13 +_,15 @@ + } + } + +- public void set(GameRule rule, T value, @Nullable MinecraftServer server) { ++ public void set(GameRule rule, T value, net.minecraft.server.level.@Nullable ServerLevel level) { // Paper - per-world game rules + if (!this.rules.has(rule)) { + throw new IllegalArgumentException("Tried to set invalid game rule"); + } else { + this.rules.set(rule, value); +- if (server != null) { +- server.onGameRuleChanged(rule, value); ++ // Paper start - per-world game rules ++ if (level != null) { ++ level.getServer().onGameRuleChanged(level, rule, value); ++ // Paper end - per-world game rules + } + } + } +@@ -128,16 +_,22 @@ + return new GameRules(enabledFeatures, this.rules); + } + +- public void setAll(GameRules gameRules, @Nullable MinecraftServer server) { +- this.setAll(gameRules.rules, server); +- } +- +- public void setAll(GameRuleMap rules, @Nullable MinecraftServer server) { +- rules.keySet().forEach(rule -> this.setFromOther(rules, (GameRule)rule, server)); +- } +- +- private void setFromOther(GameRuleMap rules, GameRule rule, @Nullable MinecraftServer server) { +- this.set(rule, Objects.requireNonNull(rules.get(rule)), server); ++ // Paper start - per-world game rules ++ public void setAll(GameRules gameRules, net.minecraft.server.level.@Nullable ServerLevel level) { ++ this.setAll(gameRules.rules, level); ++ // Paper end - per-world game rules ++ } ++ ++ // Paper start - per-world game rules ++ public void setAll(GameRuleMap rules, net.minecraft.server.level.@Nullable ServerLevel level) { ++ rules.keySet().forEach(rule -> this.setFromOther(rules, (GameRule)rule, level)); ++ // Paper end - per-world game rules ++ } ++ ++ // Paper start - per-world game rules ++ private void setFromOther(GameRuleMap rules, GameRule rule, net.minecraft.server.level.@Nullable ServerLevel level) { ++ this.set(rule, Objects.requireNonNull(rules.get(rule)), level); ++ // Paper end - per-world game rules + } + + public void visitGameRuleTypes(GameRuleTypeVisitor visitor) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch index 45c18d59cd3d..88cc5fdf97cb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch @@ -6,7 +6,7 @@ public void tick(ServerLevel level, boolean spawnEnemies) { + if (level.paperConfig().entities.behavior.pillagerPatrols.disable || level.paperConfig().entities.behavior.pillagerPatrols.spawnChance == 0) return; // Paper - Add option to disable pillager patrols & Pillager patrol spawn settings and per player options if (spawnEnemies) { - if (level.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) { + if (level.getGameRules().get(GameRules.SPAWN_PATROLS)) { RandomSource randomSource = level.random; - this.nextTick--; - if (this.nextTick <= 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch index 5101a29d2e7c..602489891fc3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch @@ -3,7 +3,7 @@ @@ -25,13 +_,22 @@ public void tick(ServerLevel level, boolean spawnEnemies) { if (spawnEnemies) { - if (level.getGameRules().getBoolean(GameRules.RULE_DOINSOMNIA)) { + if (level.getGameRules().get(GameRules.SPAWN_PHANTOMS)) { + // Paper start - Ability to control player's insomnia and phantoms + if (level.paperConfig().entities.behavior.phantomsSpawnAttemptMaxSeconds <= 0) { + return; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch index 5c305f72a32d..f6e2f0cfa70c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java +++ b/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java -@@ -107,6 +_,15 @@ +@@ -108,6 +_,15 @@ @Override public CompoundTag applyFix(CompoundTag tag) { int dataVersion = NbtUtils.getDataVersion(tag); @@ -16,15 +16,15 @@ if (dataVersion < 1493) { tag = DataFixTypes.CHUNK.update(this.dataFixer, tag, dataVersion, 1493); if (tag.getCompound("Level").flatMap(compoundTag -> compoundTag.getBoolean("hasLegacyStructureData")).orElse(false)) { -@@ -249,17 +_,18 @@ +@@ -250,17 +_,18 @@ } - public static LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, @Nullable DimensionDataStorage storage, DataFixer dataFixer) { + public static Supplier getLegacyTagFixer(ResourceKey level, Supplier<@Nullable DimensionDataStorage> storage, DataFixer dataFixer) { - if (level == Level.OVERWORLD) { + ResourceKey stemKey = net.minecraft.core.registries.Registries.levelToLevelStem(level); // CraftBukkit + if (stemKey == net.minecraft.world.level.dimension.LevelStem.OVERWORLD) { // CraftBukkit - return new LegacyStructureDataHandler( - storage, + return () -> new LegacyStructureDataHandler( + storage.get(), ImmutableList.of("Monument", "Stronghold", "Village", "Mineshaft", "Temple", "Mansion"), ImmutableList.of("Village", "Mineshaft", "Mansion", "Igloo", "Desert_Pyramid", "Jungle_Pyramid", "Swamp_Hut", "Stronghold", "Monument"), dataFixer @@ -32,9 +32,9 @@ - } else if (level == Level.NETHER) { + } else if (stemKey == net.minecraft.world.level.dimension.LevelStem.NETHER) { // CraftBukkit List list = ImmutableList.of("Fortress"); - return new LegacyStructureDataHandler(storage, list, list, dataFixer); + return () -> new LegacyStructureDataHandler(storage.get(), list, list, dataFixer); - } else if (level == Level.END) { + } else if (stemKey == net.minecraft.world.level.dimension.LevelStem.END) { // CraftBukkit List list = ImmutableList.of("EndCity"); - return new LegacyStructureDataHandler(storage, list, list, dataFixer); + return () -> new LegacyStructureDataHandler(storage.get(), list, list, dataFixer); } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch index c08d93948b83..d358e0362acb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/StructurePiece.java +++ b/net/minecraft/world/level/levelgen/structure/StructurePiece.java -@@ -181,6 +_,11 @@ +@@ -180,6 +_,11 @@ } level.setBlock(worldPos, state, Block.UPDATE_CLIENTS); @@ -12,7 +12,7 @@ FluidState fluidState = level.getFluidState(worldPos); if (!fluidState.isEmpty()) { level.scheduleTick(worldPos, fluidState.getType(), 0); -@@ -193,6 +_,48 @@ +@@ -192,6 +_,48 @@ } } @@ -61,7 +61,7 @@ protected boolean canBeReplaced(LevelReader level, int x, int y, int z, BoundingBox box) { return true; } -@@ -421,11 +_,17 @@ +@@ -420,11 +_,17 @@ state = reorient(level, pos, Blocks.CHEST.defaultBlockState()); } @@ -84,7 +84,7 @@ return true; } else { -@@ -438,11 +_,28 @@ +@@ -437,11 +_,28 @@ ) { BlockPos worldPos = this.getWorldPos(x, y, z); if (box.isInside(worldPos) && !level.getBlockState(worldPos).is(Blocks.DISPENSER)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch index 2f1367496772..c42ee6b4f724 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/levelgen/structure/StructureStart.java +++ b/net/minecraft/world/level/levelgen/structure/StructureStart.java -@@ -30,6 +_,12 @@ - @Nullable - private volatile BoundingBox cachedBoundingBox; +@@ -29,6 +_,12 @@ + private int references; + private volatile @Nullable BoundingBox cachedBoundingBox; + // CraftBukkit start + private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); @@ -13,7 +13,7 @@ public StructureStart(Structure structure, ChunkPos chunkPos, int references, PiecesContainer pieceContainer) { this.structure = structure; this.chunkPos = chunkPos; -@@ -87,11 +_,23 @@ +@@ -85,11 +_,23 @@ BlockPos center = boundingBox.getCenter(); BlockPos blockPos = new BlockPos(center.getX(), boundingBox.minY(), center.getZ()); @@ -40,7 +40,7 @@ this.structure.afterPlace(level, structureManager, generator, random, box, chunkPos, this.pieceContainer); } -@@ -99,6 +_,11 @@ +@@ -97,6 +_,11 @@ public CompoundTag createTag(StructurePieceSerializationContext context, ChunkPos chunkPos) { CompoundTag compoundTag = new CompoundTag(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch index 1794d24018d5..b76a0f994cf1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java -@@ -397,10 +_,13 @@ +@@ -396,10 +_,13 @@ BlockPos worldPos = this.getWorldPos(1, 0, i8); if (box.isInside(worldPos) && this.isInterior(level, 1, 0, i8, box)) { this.hasPlacedSpider = true; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch index abb610b37793..dd3faae71de3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java -@@ -1077,10 +_,13 @@ +@@ -1084,10 +_,13 @@ BlockPos worldPos = this.getWorldPos(3, 5, 5); if (box.isInside(worldPos)) { this.hasPlacedSpawner = true; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java.patch index dc109e132743..9ce178ba9c73 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java -@@ -21,7 +_,7 @@ +@@ -19,7 +_,7 @@ + private @Nullable BoundingBox boundingBox; private LiquidSettings liquidSettings = LiquidSettings.APPLY_WATERLOGGING; - @Nullable - private RandomSource random; + private @Nullable RandomSource random; - private int palette; + public int palette = -1; // CraftBukkit - Set initial value so we know if the palette has been set forcefully private final List processors = Lists.newArrayList(); private boolean knownShape; private boolean finalizeEntities; -@@ -142,6 +_,13 @@ +@@ -139,6 +_,13 @@ int size = palettes.size(); if (size == 0) { throw new IllegalStateException("No palettes"); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch index 28472f9cc4d1..0bffaf4763df 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -137,6 +137,6 @@ private final List blocks; - private final Map> cache = Maps.newHashMap(); + private final Map> cache = Maps.newConcurrentMap(); // Paper - Fix CME due to this collection being shared across threads - @Nullable - private List cachedJigsaws; + private @Nullable List cachedJigsaws; + Palette(List blocks) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch b/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch index 227361c33bcf..8b385e7dbad5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch @@ -1,35 +1,35 @@ --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java -@@ -95,6 +_,13 @@ - BlockState blockState = level.getBlockState(blockPos); - if (blockState.isAir()) { - if (this.hasFlammableNeighbours(level, blockPos)) { -+ // CraftBukkit start - Prevent lava putting something on fire -+ if (!level.getBlockState(blockPos).is(Blocks.FIRE)) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, blockPos, pos).isCancelled()) { -+ continue; -+ } -+ } -+ // CraftBukkit end - level.setBlockAndUpdate(blockPos, BaseFireBlock.getState(level, blockPos)); - return; - } -@@ -110,6 +_,14 @@ - } - - if (level.isEmptyBlock(blockPos1.above()) && this.isFlammable(level, blockPos1)) { +@@ -94,6 +_,13 @@ + BlockState blockState = level.getBlockState(blockPos); + if (blockState.isAir()) { + if (this.hasFlammableNeighbours(level, blockPos)) { + // CraftBukkit start - Prevent lava putting something on fire -+ BlockPos up = blockPos1.above(); -+ if (!level.getBlockState(up).is(Blocks.FIRE)) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, up, pos).isCancelled()) { ++ if (!level.getBlockState(blockPos).is(Blocks.FIRE)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, blockPos, pos).isCancelled()) { + continue; + } + } -+ // CraftBukkit end - Prevent lava putting something on fire - level.setBlockAndUpdate(blockPos1.above(), BaseFireBlock.getState(level, blockPos1)); ++ // CraftBukkit end + level.setBlockAndUpdate(blockPos, BaseFireBlock.getState(level, blockPos)); + return; } +@@ -109,6 +_,14 @@ } -@@ -120,9 +_,10 @@ + + if (level.isEmptyBlock(blockPos1.above()) && this.isFlammable(level, blockPos1)) { ++ // CraftBukkit start - Prevent lava putting something on fire ++ BlockPos up = blockPos1.above(); ++ if (!level.getBlockState(up).is(Blocks.FIRE)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, up, pos).isCancelled()) { ++ continue; ++ } ++ } ++ // CraftBukkit end - Prevent lava putting something on fire + level.setBlockAndUpdate(blockPos1.above(), BaseFireBlock.getState(level, blockPos1)); + } + } +@@ -118,9 +_,10 @@ @Override protected void entityInside(Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { @@ -41,7 +41,7 @@ } private boolean hasFlammableNeighbours(LevelReader level, BlockPos pos) { -@@ -210,7 +_,11 @@ +@@ -207,7 +_,11 @@ FluidState fluidState1 = level.getFluidState(pos); if (this.is(FluidTags.LAVA) && fluidState1.is(FluidTags.WATER)) { if (state.getBlock() instanceof LiquidBlock) { @@ -54,7 +54,7 @@ } this.fizz(level, pos); -@@ -228,7 +_,7 @@ +@@ -225,7 +_,7 @@ @Override protected float getExplosionResistance() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/material/WaterFluid.java.patch b/paper-server/patches/sources/net/minecraft/world/level/material/WaterFluid.java.patch index 2d7aee20e32b..0accdf667c84 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/material/WaterFluid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/material/WaterFluid.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/material/WaterFluid.java +++ b/net/minecraft/world/level/material/WaterFluid.java -@@ -78,6 +_,14 @@ - return level.getGameRules().getBoolean(GameRules.RULE_WATER_SOURCE_CONVERSION); +@@ -77,6 +_,14 @@ + return level.getGameRules().get(GameRules.WATER_SOURCE_CONVERSION); } + // Paper start - Add BlockBreakBlockEvent @@ -15,7 +15,7 @@ @Override protected void beforeDestroyingBlock(LevelAccessor level, BlockPos pos, BlockState state) { BlockEntity blockEntity = state.hasBlockEntity() ? level.getBlockEntity(pos) : null; -@@ -121,7 +_,7 @@ +@@ -120,7 +_,7 @@ @Override protected float getExplosionResistance() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch index 94a7ed2e86b6..cacf29e39716 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java +++ b/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java -@@ -480,7 +_,12 @@ +@@ -477,7 +_,12 @@ } protected static PathType getPathTypeFromState(BlockGetter level, BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch index 6d690ba52d9a..3cbbdd7538ee 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch @@ -14,7 +14,7 @@ this.axis = axis; this.numPortalBlocks = numPortalBlocks; this.rightDir = rightDir; -@@ -63,24 +_,25 @@ +@@ -63,23 +_,24 @@ } public static PortalShape findAnyShape(BlockGetter level, BlockPos bottomLeft, Direction.Axis axis) { @@ -34,20 +34,19 @@ } else { MutableInt mutableInt = new MutableInt(); - int i1 = calculateHeight(level, blockPos, direction, i, mutableInt); -- return new PortalShape(axis, mutableInt.getValue(), direction, blockPos, i, i1); +- return new PortalShape(axis, mutableInt.intValue(), direction, blockPos, i, i1); + int i1 = calculateHeight(level, blockPos, direction, i, mutableInt, blocks); // CraftBukkit -+ return new PortalShape(axis, mutableInt.getValue(), direction, blockPos, i, i1, blocks); // CraftBukkit ++ return new PortalShape(axis, mutableInt.intValue(), direction, blockPos, i, i1, blocks); // CraftBukkit } } } - @Nullable -- private static BlockPos calculateBottomLeft(BlockGetter level, Direction direction, BlockPos pos) { -+ private static BlockPos calculateBottomLeft(BlockGetter level, Direction direction, BlockPos pos, org.bukkit.craftbukkit.util.BlockStateListPopulator blocks) { // CraftBukkit +- private static @Nullable BlockPos calculateBottomLeft(BlockGetter level, Direction direction, BlockPos pos) { ++ private static @Nullable BlockPos calculateBottomLeft(BlockGetter level, Direction direction, BlockPos pos, org.bukkit.craftbukkit.util.BlockStateListPopulator blocks) { // CraftBukkit int max = Math.max(level.getMinY(), pos.getY() - 21); while (pos.getY() > max && isEmpty(level.getBlockState(pos.below()))) { -@@ -88,16 +_,16 @@ +@@ -87,16 +_,16 @@ } Direction opposite = direction.getOpposite(); @@ -68,7 +67,7 @@ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); for (int i = 0; i <= 21; i++) { -@@ -105,6 +_,7 @@ +@@ -104,6 +_,7 @@ BlockState blockState = level.getBlockState(mutableBlockPos); if (!isEmpty(blockState)) { if (FRAME.test(blockState, level, mutableBlockPos)) { @@ -76,7 +75,7 @@ return i; } break; -@@ -114,32 +_,34 @@ +@@ -113,32 +_,34 @@ if (!FRAME.test(blockState1, level, mutableBlockPos)) { break; } @@ -116,7 +115,7 @@ ) { for (int i = 0; i < 21; i++) { checkPos.set(pos).move(Direction.UP, i).move(direction, -1); -@@ -163,6 +_,10 @@ +@@ -162,6 +_,10 @@ portalBlocks.increment(); } } @@ -127,7 +126,7 @@ } return 21; -@@ -176,10 +_,23 @@ +@@ -175,10 +_,23 @@ return this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java.patch b/paper-server/patches/sources/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java.patch index c95d2dfa4d1a..bdae25a276df 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java +++ b/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java -@@ -148,7 +_,7 @@ +@@ -145,7 +_,7 @@ orientation = this.orientation.withFront(direction); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch index 1b10c37a4fe6..2ac346fb508f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch @@ -96,7 +96,7 @@ } public static void addTargetDecoration(ItemStack stack, BlockPos pos, String type, Holder mapDecorationType) { -@@ -356,7 +_,12 @@ +@@ -352,7 +_,12 @@ } public void setColorsDirty(int x, int z) { @@ -110,7 +110,7 @@ for (MapItemSavedData.HoldingPlayer holdingPlayer : this.carriedBy) { holdingPlayer.markColorsDirty(x, z); -@@ -397,7 +_,7 @@ +@@ -393,7 +_,7 @@ return true; } @@ -119,7 +119,7 @@ this.bannerMarkers.put(mapBanner.getId(), mapBanner); this.addDecoration(mapBanner.getDecoration(), level, mapBanner.getId(), d, d1, 180.0, mapBanner.name().orElse(null)); this.setDirty(); -@@ -499,7 +_,7 @@ +@@ -495,7 +_,7 @@ this.player = player; } @@ -128,7 +128,7 @@ int i = this.minDirtyX; int i1 = this.minDirtyY; int i2 = this.maxDirtyX + 1 - this.minDirtyX; -@@ -508,7 +_,7 @@ +@@ -504,7 +_,7 @@ for (int i4 = 0; i4 < i2; i4++) { for (int i5 = 0; i5 < i3; i5++) { @@ -137,9 +137,9 @@ } } -@@ -518,17 +_,38 @@ - @Nullable - Packet nextUpdatePacket(MapId mapId) { +@@ -513,17 +_,38 @@ + + @Nullable Packet nextUpdatePacket(MapId mapId) { MapItemSavedData.MapPatch mapPatch; + // Paper start + if (!this.dirtyData && this.tick % 5 != 0) { @@ -179,7 +179,7 @@ } else { collection = null; } -@@ -556,6 +_,23 @@ +@@ -551,6 +_,23 @@ private void markDecorationsDirty() { this.dirtyDecorations = true; } @@ -203,7 +203,7 @@ } record MapDecorationLocation(Holder type, byte x, byte y, byte rot) { -@@ -600,4 +_,71 @@ +@@ -595,4 +_,71 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch index b0c2fbfb7f92..81c5212d5251 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/DimensionDataStorage.java +++ b/net/minecraft/world/level/storage/DimensionDataStorage.java -@@ -147,7 +_,7 @@ +@@ -145,7 +_,7 @@ } else { int i = Util.maxAllowedExecutorThreads(); int size = map.size(); @@ -9,7 +9,7 @@ this.pendingWriteFuture = this.pendingWriteFuture.thenCompose(object -> { List> list = new ArrayList<>(i); int i1 = Mth.positiveCeilDiv(size, i); -@@ -168,7 +_,7 @@ +@@ -166,7 +_,7 @@ object -> CompletableFuture.allOf( map.entrySet() .stream() diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch index b157d72a9e89..b488224d8d8c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -8,7 +8,7 @@ return new LevelDataAndDimensions(primaryLevelData, complete); } -@@ -339,25 +_,39 @@ +@@ -337,25 +_,39 @@ return this.backupDir; } @@ -53,7 +53,7 @@ public record LevelCandidates(List levels) implements Iterable { public boolean isEmpty() { return this.levels.isEmpty(); -@@ -408,8 +_,12 @@ +@@ -406,8 +_,12 @@ public final LevelStorageSource.LevelDirectory levelDirectory; private final String levelId; private final Map resources = Maps.newHashMap(); @@ -67,7 +67,7 @@ this.levelId = levelId; this.levelDirectory = new LevelStorageSource.LevelDirectory(levelDir); this.lock = DirectoryLock.create(levelDir); -@@ -452,7 +_,7 @@ +@@ -450,7 +_,7 @@ } public Path getDimensionPath(ResourceKey dimensionPath) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/PrimaryLevelData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/PrimaryLevelData.java.patch index 5ebc8a8f21cb..75ca0c09e94b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/PrimaryLevelData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/PrimaryLevelData.java.patch @@ -8,8 +8,8 @@ + public net.minecraft.resources.ResourceKey respawnDimension = net.minecraft.world.level.Level.OVERWORLD; // Paper private long gameTime; private long dayTime; - @Nullable -@@ -74,6 +_,21 @@ + private final @Nullable CompoundTag loadedPlayerTag; +@@ -71,6 +_,21 @@ private final Set removedFeatureFlags; private final TimerQueue scheduledEvents; @@ -31,7 +31,7 @@ private PrimaryLevelData( @Nullable CompoundTag loadedPlayerTag, boolean wasModded, -@@ -171,7 +_,7 @@ +@@ -168,7 +_,7 @@ Lifecycle worldGenSettingsLifecycle ) { long _long = tag.get("Time").asLong(0L); @@ -40,7 +40,7 @@ tag.get("Player").flatMap(CompoundTag.CODEC::parse).result().orElse(null), tag.get("WasModded").asBoolean(false), tag.get("spawn").read(LevelData.RespawnData.CODEC).result().orElse(LevelData.RespawnData.DEFAULT), -@@ -205,6 +_,13 @@ +@@ -202,6 +_,13 @@ specialWorldProperty, worldGenSettingsLifecycle ); @@ -54,7 +54,7 @@ } @Override -@@ -233,11 +_,12 @@ +@@ -230,11 +_,12 @@ tag.put("Version", compoundTag); NbtUtils.addCurrentDataVersion(tag); DynamicOps dynamicOps = registry.createSerializationContext(NbtOps.INSTANCE); @@ -68,7 +68,7 @@ tag.putLong("Time", this.gameTime); tag.putLong("DayTime", this.dayTime); tag.putLong("LastPlayed", Util.getEpochMillis()); -@@ -269,6 +_,8 @@ +@@ -266,6 +_,8 @@ tag.putInt("WanderingTraderSpawnDelay", this.wanderingTraderSpawnDelay); tag.putInt("WanderingTraderSpawnChance", this.wanderingTraderSpawnChance); tag.storeNullable("WanderingTraderId", UUIDUtil.CODEC, this.wanderingTraderId); @@ -77,7 +77,7 @@ } private static ListTag stringCollectionToTag(Set stringCollection) { -@@ -340,6 +_,25 @@ +@@ -336,6 +_,25 @@ @Override public void setThundering(boolean thundering) { @@ -103,7 +103,7 @@ this.thundering = thundering; } -@@ -360,6 +_,26 @@ +@@ -356,6 +_,26 @@ @Override public void setRaining(boolean isRaining) { @@ -130,7 +130,7 @@ this.raining = isRaining; } -@@ -426,6 +_,12 @@ +@@ -422,6 +_,12 @@ @Override public void setDifficulty(Difficulty difficulty) { this.settings = this.settings.withDifficulty(difficulty); @@ -143,7 +143,7 @@ } @Override -@@ -561,6 +_,14 @@ +@@ -555,6 +_,14 @@ public LevelSettings getLevelSettings() { return this.settings.copy(); } diff --git a/paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch b/paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch index dc31c0bf3027..24a2d294325d 100644 --- a/paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/scores/Scoreboard.java +++ b/net/minecraft/world/scores/Scoreboard.java -@@ -381,7 +_,7 @@ +@@ -375,7 +_,7 @@ } protected List packPlayerTeams() { diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java index e990a0f5027f..1ab8c51e820d 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java @@ -185,7 +185,7 @@ public static Holder resolveSound(final Key key) { // Component - public static @NotNull Component asAdventure(@Nullable final net.minecraft.network.chat.Component component) { + public static @NotNull Component asAdventure(final net.minecraft.network.chat.@Nullable Component component) { return component == null ? Component.empty() : WRAPPER_AWARE_SERIALIZER.deserialize(component); } @@ -261,7 +261,7 @@ private static Component translated(final Component component, final Locale loca ); } - public static Component resolveWithContext(final @NotNull Component component, final @Nullable CommandSender context, final @Nullable org.bukkit.entity.Entity scoreboardSubject, final boolean bypassPermissions) throws IOException { + public static Component resolveWithContext(final @NotNull Component component, final @Nullable CommandSender context, final org.bukkit.entity.@Nullable Entity scoreboardSubject, final boolean bypassPermissions) throws IOException { final CommandSourceStack css = context != null ? VanillaCommandWrapper.getListener(context) : null; Boolean previous = null; if (css != null && bypassPermissions) { diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/Configurations.java b/paper-server/src/main/java/io/papermc/paper/configuration/Configurations.java index d0c4037c3cc6..964951251ed4 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/Configurations.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/Configurations.java @@ -18,7 +18,7 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.gamerules.GameRules; import org.jetbrains.annotations.MustBeInvokedByOverriders; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java index 940f60cd8461..1ee16e3ee24d 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java @@ -61,7 +61,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.Item; -import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import org.apache.commons.lang3.RandomStringUtils; diff --git a/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java b/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java index e0a595324a7b..179042955e33 100644 --- a/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java @@ -9,7 +9,7 @@ import net.minecraft.world.flag.FeatureElement; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; -import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.gamerules.GameRules; import org.bukkit.FeatureFlag; import org.bukkit.GameRule; import org.bukkit.craftbukkit.entity.CraftEntityType; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java index 872552864cd3..97b097eca4f1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -385,7 +385,7 @@ public Location getRespawnLocation(final boolean loadLocationAndValidate) { } private ServerStatsCounter getStatisticManager() { - return this.server.getHandle().getPlayerStats(this.getUniqueId(), this.getName()); + return this.server.getHandle().getPlayerStats(this.nameAndId.toUncompletedGameProfile()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 11911a74f607..3924f3219cf4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -95,7 +95,7 @@ import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.crafting.RepairItemRecipe; import net.minecraft.world.level.CustomSpawner; -import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.GameType; import net.minecraft.world.level.LevelSettings; import net.minecraft.world.level.biome.BiomeManager; @@ -995,7 +995,7 @@ public void reload() { this.console.paperConfigurations.reloadConfigs(this.console); for (ServerLevel world : this.console.getAllLevels()) { // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty - world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && world.getGameRules().getBoolean(GameRules.RULE_SPAWN_MONSTERS)); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) + world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && world.getGameRules().get(GameRules.SPAWN_MONSTERS)); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) for (SpawnCategory spawnCategory : SpawnCategory.values()) { if (CraftSpawnCategory.isValidForLimits(spawnCategory)) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 4513b1824bdd..d42c6a0c5b0c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -67,7 +67,7 @@ import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.Climate; import net.minecraft.world.level.chunk.ChunkAccess; @@ -830,7 +830,7 @@ public void setFullTime(long time) { CraftPlayer cp = (CraftPlayer) p; if (cp.getHandle().connection == null) continue; - cp.getHandle().connection.send(new ClientboundSetTimePacket(cp.getHandle().level().getGameTime(), cp.getHandle().getPlayerTime(), cp.getHandle().relativeTime && cp.getHandle().level().getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); + cp.getHandle().connection.send(new ClientboundSetTimePacket(cp.getHandle().level().getGameTime(), cp.getHandle().getPlayerTime(), cp.getHandle().relativeTime && cp.getHandle().level().getGameRules().get(GameRules.ADVANCE_TIME))); } } @@ -1246,12 +1246,12 @@ public long getSeed() { @Override public boolean getPVP() { - return this.world.pvpMode.toBooleanOrElseGet(() -> this.world.getGameRules().getBoolean(GameRules.RULE_PVP)); + return this.world.pvpMode.toBooleanOrElseGet(() -> this.world.getGameRules().get(GameRules.PVP)); } @Override public void setPVP(boolean pvp) { - if (this.world.getGameRules().getBoolean(GameRules.RULE_PVP) == pvp) { + if (this.world.getGameRules().get(GameRules.PVP) == pvp) { return; } this.world.pvpMode = TriState.byBoolean(pvp); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index b177e23db960..3af0846ef740 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -330,7 +330,7 @@ public static net.minecraft.world.entity.Relative deltaRelativeToNMS(TeleportFla }; } - public static @Nullable TeleportFlag.Relative deltaRelativeToAPI(net.minecraft.world.entity.Relative nmsFlag) { + public static TeleportFlag.@Nullable Relative deltaRelativeToAPI(net.minecraft.world.entity.Relative nmsFlag) { return switch (nmsFlag) { case DELTA_X -> TeleportFlag.Relative.VELOCITY_X; case DELTA_Y -> TeleportFlag.Relative.VELOCITY_Y; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 7e909fa6537d..23337d8f2e7e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -2119,7 +2119,7 @@ public static void callEntityRemoveEvent(Entity entity, EntityRemoveEvent.Cause Bukkit.getPluginManager().callEvent(new EntityRemoveEvent(entity.getBukkitEntity(), cause)); } - public static void callPlayerUseUnknownEntityEvent(net.minecraft.world.entity.player.Player player, net.minecraft.network.protocol.game.ServerboundInteractPacket packet, InteractionHand hand, @Nullable net.minecraft.world.phys.Vec3 vector) { + public static void callPlayerUseUnknownEntityEvent(net.minecraft.world.entity.player.Player player, net.minecraft.network.protocol.game.ServerboundInteractPacket packet, InteractionHand hand, net.minecraft.world.phys.@Nullable Vec3 vector) { new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent( (Player) player.getBukkitEntity(), packet.getEntityId(), packet.isAttack(), CraftEquipmentSlot.getHand(hand), diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java index 228da1dc019b..936c96a028d0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java @@ -148,7 +148,7 @@ public String getOwner() { } @Override - public void setPlayerProfile(@Nullable com.destroystokyo.paper.profile.PlayerProfile profile) { + public void setPlayerProfile(com.destroystokyo.paper.profile.@Nullable PlayerProfile profile) { setProfile((profile == null) ? null : com.destroystokyo.paper.profile.CraftPlayerProfile.asResolvableProfileCopy(profile)); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java index d3053d0939cd..a2c9b4a9e220 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java @@ -718,7 +718,7 @@ public boolean addFreshEntity(Entity entity) { } @Override - public boolean addFreshEntity(Entity entity, @Nullable CreatureSpawnEvent.SpawnReason reason) { + public boolean addFreshEntity(Entity entity, CreatureSpawnEvent.@Nullable SpawnReason reason) { return this.delegate.addFreshEntity(entity, reason); } diff --git a/todo-snapshot.txt b/todo-snapshot.txt index fe60a0cdacf9..739928f1249d 100644 --- a/todo-snapshot.txt +++ b/todo-snapshot.txt @@ -2,3 +2,6 @@ - anything marked with 'TODO - snapshot' - 25w43a: - Connection, ServerConnectionListener - dropped diff for thread pool config (fields gone) +- 25w44a: + - ShulkerBoxBlock: retainUnlootedShulkerBoxLootTableOnNonPlayerBreak patch no longer applies (getDrops override removed) + - Add back array storage for game rules in GameRuleMap? From 8c45a9c981c99c2397d0bc32330f5abb3d15087f Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 3 Nov 2025 13:20:03 -0700 Subject: [PATCH 037/112] Remove extraneous diff --- .../util/random/WeightedList.java.patch | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch b/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch index 80963a1ae0db..e67149c78ee4 100644 --- a/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch @@ -16,26 +16,6 @@ this.items = List.copyOf(items); this.totalWeight = WeightedRandom.getTotalWeight(items, Weighted::weight); if (this.totalWeight == 0) { -@@ -38,15 +_,15 @@ - return new WeightedList<>(List.of()); - } - -- public static WeightedList of(E element) { -- return new WeightedList<>(List.of(new Weighted<>(element, 1))); -- } -- - @SafeVarargs - public static WeightedList of(Weighted... items) { - return new WeightedList<>(List.of(items)); - } - -+ public static WeightedList of(E element) { -+ return new WeightedList<>(List.of(new Weighted<>(element, 1))); -+ } -+ - public static WeightedList of(List> items) { - return new WeightedList<>(items); - } @@ -128,7 +_,7 @@ } From 98c529669bfa1cfc20669a9d2046955f6e654538 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 3 Nov 2025 13:24:36 -0700 Subject: [PATCH 038/112] Fix requestedUsername field diff --- .../server/network/ServerLoginPacketListenerImpl.java.patch | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch index 92f8260e5ab5..309f08241a73 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch @@ -17,13 +17,12 @@ private static final int MAX_TICKS_BEFORE_LOGIN = 600; private final byte[] challenge; final MinecraftServer server; -@@ -56,10 +_,16 @@ +@@ -56,10 +_,15 @@ final ServerActivityMonitor serverActivityMonitor; public volatile ServerLoginPacketListenerImpl.State state = ServerLoginPacketListenerImpl.State.HELLO; private int tick; - @Nullable String requestedUsername; -+ @Nullable -+ public String requestedUsername; // Paper ++ public @Nullable String requestedUsername; // Paper - public public @Nullable GameProfile authenticatedProfile; private final String serverId = ""; - private final boolean transferred; From 5b18398da6c983b86983ea8bac61f42ae785aece Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 3 Nov 2025 13:32:20 -0700 Subject: [PATCH 039/112] remove extraneous diff in Util --- .../sources/net/minecraft/Util.java.patch | 88 +------------------ 1 file changed, 4 insertions(+), 84 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/Util.java.patch b/paper-server/patches/sources/net/minecraft/Util.java.patch index 3c2c1f2231d0..4e46d661ba26 100644 --- a/paper-server/patches/sources/net/minecraft/Util.java.patch +++ b/paper-server/patches/sources/net/minecraft/Util.java.patch @@ -91,10 +91,11 @@ } private static int getMaxThreads() { -@@ -231,6 +_,21 @@ +@@ -230,6 +_,21 @@ + return thread; })); } - ++ + // Paper start - Separate dimension data IO pool + private static TracingExecutor makeExtraIoExecutor(String namePrefix) { + AtomicInteger atomicInteger = new AtomicInteger(1); @@ -109,87 +110,6 @@ + })); + } + // Paper end - Separate dimension data IO pool -+ + public static void throwAsRuntime(Throwable throwable) { throw throwable instanceof RuntimeException ? (RuntimeException)throwable : new RuntimeException(throwable); - } -@@ -297,6 +_,19 @@ - return input -> true; - } - -+ @SafeVarargs -+ public static Predicate allOf(Predicate... predicates) { -+ return input -> { -+ for (Predicate predicate : predicates) { -+ if (!predicate.test(input)) { -+ return false; -+ } -+ } -+ -+ return true; -+ }; -+ } -+ - public static Predicate allOf(Predicate predicate) { - return (Predicate)predicate; - } -@@ -325,19 +_,6 @@ - return input -> predicate1.test(input) && predicate2.test(input) && predicate3.test(input) && predicate4.test(input) && predicate5.test(input); - } - -- @SafeVarargs -- public static Predicate allOf(Predicate... predicates) { -- return input -> { -- for (Predicate predicate : predicates) { -- if (!predicate.test(input)) { -- return false; -- } -- } -- -- return true; -- }; -- } -- - public static Predicate allOf(List> predicates) { - return switch (predicates.size()) { - case 0 -> allOf(); -@@ -368,6 +_,19 @@ - return input -> false; - } - -+ @SafeVarargs -+ public static Predicate anyOf(Predicate... predicates) { -+ return input -> { -+ for (Predicate predicate : predicates) { -+ if (predicate.test(input)) { -+ return true; -+ } -+ } -+ -+ return false; -+ }; -+ } -+ - public static Predicate anyOf(Predicate predicate) { - return (Predicate)predicate; - } -@@ -394,19 +_,6 @@ - Predicate predicate5 - ) { - return input -> predicate1.test(input) || predicate2.test(input) || predicate3.test(input) || predicate4.test(input) || predicate5.test(input); -- } -- -- @SafeVarargs -- public static Predicate anyOf(Predicate... predicates) { -- return input -> { -- for (Predicate predicate : predicates) { -- if (predicate.test(input)) { -- return true; -- } -- } -- -- return false; -- }; - } - - public static Predicate anyOf(List> predicates) { From 926cff8faa62a4ef8c1b7f9e74ec1dfce8a4da8d Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 3 Nov 2025 13:43:06 -0700 Subject: [PATCH 040/112] Fixup LightningBolt diff --- .../world/entity/LightningBolt.java.patch | 49 +++++++------------ 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch index e83be8e541c0..ee61c2808ba1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch @@ -48,47 +48,32 @@ List entities = this.level() .getEntities( this, -@@ -167,34 +_,47 @@ +@@ -167,34 +_,43 @@ } private void spawnFire(int extraIgnitions) { - if (!this.visualOnly && this.level() instanceof ServerLevel serverLevel) { -+ if (!this.visualOnly && !this.isEffect && this.level() instanceof ServerLevel serverLevel) { // Paper - prevent any fire if only effect ++ if (!this.visualOnly && !this.isEffect && this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(net.minecraft.world.level.gamerules.GameRules.FIRE_DAMAGE)) { // Paper - prevent any fire if only effect BlockPos var7 = this.blockPosition(); if (serverLevel.canSpreadFireAround(var7)) { -- BlockState state = BaseFireBlock.getState(serverLevel, var7); -- if (serverLevel.getBlockState(var7).isAir() && state.canSurvive(serverLevel, var7)) { -- serverLevel.setBlockAndUpdate(var7, state); -- this.blocksSetOnFire++; -- } -- -- for (int i = 0; i < extraIgnitions; i++) { -- BlockPos blockPos1 = var7.offset(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); -- state = BaseFireBlock.getState(serverLevel, blockPos1); -- if (serverLevel.getBlockState(blockPos1).isAir() && state.canSurvive(serverLevel, blockPos1)) { -- serverLevel.setBlockAndUpdate(blockPos1, state); -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), var7, this).isCancelled()) { -+ BlockState state = BaseFireBlock.getState(serverLevel, var7); -+ if (serverLevel.getBlockState(var7).isAir() && state.canSurvive(serverLevel, var7)) { -+ serverLevel.setBlockAndUpdate(var7, state); + BlockState state = BaseFireBlock.getState(serverLevel, var7); + if (serverLevel.getBlockState(var7).isAir() && state.canSurvive(serverLevel, var7)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), var7, this).isCancelled()) { // CraftBukkit + serverLevel.setBlockAndUpdate(var7, state); + this.blocksSetOnFire++; ++ } // CraftBukkit + } + + for (int i = 0; i < extraIgnitions; i++) { + BlockPos blockPos1 = var7.offset(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); + state = BaseFireBlock.getState(serverLevel, blockPos1); + if (serverLevel.getBlockState(blockPos1).isAir() && state.canSurvive(serverLevel, blockPos1)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), blockPos1, this).isCancelled()) { // CraftBukkit + serverLevel.setBlockAndUpdate(blockPos1, state); this.blocksSetOnFire++; ++ } // CraftBukkit } -+ -+ for (int i = 0; i < extraIgnitions; i++) { -+ BlockPos blockPos1 = var7.offset(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); -+ state = BaseFireBlock.getState(serverLevel, blockPos1); -+ if (serverLevel.getBlockState(blockPos1).isAir() && state.canSurvive(serverLevel, blockPos1)) { -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), blockPos1, this).isCancelled()) { -+ serverLevel.setBlockAndUpdate(blockPos1, state); -+ this.blocksSetOnFire++; -+ } -+ // CraftBukkit end -+ } -+ } } -+ // CraftBukkit end } } } From cb7de0803eb56815638dfdbb1411f75a0b5b6f65 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Mon, 3 Nov 2025 22:58:11 +0100 Subject: [PATCH 041/112] drop redundant gamerule check and add back kqueue support --- .../server/dedicated/Settings.java.patch | 6 ++---- .../network/EventLoopGroupHolder.java.patch | 18 ++++++++++++------ .../world/entity/LightningBolt.java.patch | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch index 1c8c31a9719b..f09c795ed4d6 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch @@ -92,12 +92,10 @@ } protected @Nullable V getLegacy(String key, Function serializer) { -@@ -106,7 +_,16 @@ - } +@@ -107,6 +_,15 @@ } -- protected V get(String key, Function serializer, Function deserializer, V defaultValue) { -+ protected V get(String key, Function serializer, Function deserializer, V defaultValue) { + protected V get(String key, Function serializer, Function deserializer, V defaultValue) { + // CraftBukkit start + try { + return this.get0(key, serializer, deserializer, defaultValue); diff --git a/paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch b/paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch index 72b4be725f8d..84488a498354 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch @@ -21,18 +21,24 @@ public static EventLoopGroupHolder remote(boolean tryNativeTransport) { if (tryNativeTransport) { if (KQueue.isAvailable()) { -@@ -66,6 +_,19 @@ +@@ -66,6 +_,25 @@ return NIO; } + + // Paper start - Unix domain socket support + public static EventLoopGroupHolder remote(java.net.SocketAddress address, boolean tryNativeTransport) { -+ if (tryNativeTransport && Epoll.isAvailable()) { -+ if (address instanceof io.netty.channel.unix.DomainSocketAddress) { -+ return EPOLL_UNIX_DOMAIN; -+ } else { -+ return EPOLL; ++ if (tryNativeTransport) { ++ if (KQueue.isAvailable()) { ++ return KQUEUE; ++ } ++ ++ if (Epoll.isAvailable()) { ++ if (address instanceof io.netty.channel.unix.DomainSocketAddress) { ++ return EPOLL_UNIX_DOMAIN; ++ } else { ++ return EPOLL; ++ } + } + } + return NIO; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch index ee61c2808ba1..ebe1f9fbce02 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch @@ -53,7 +53,7 @@ private void spawnFire(int extraIgnitions) { - if (!this.visualOnly && this.level() instanceof ServerLevel serverLevel) { -+ if (!this.visualOnly && !this.isEffect && this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(net.minecraft.world.level.gamerules.GameRules.FIRE_DAMAGE)) { // Paper - prevent any fire if only effect ++ if (!this.visualOnly && !this.isEffect && this.level() instanceof ServerLevel serverLevel) { // Paper - Properly handle lightning effects api BlockPos var7 = this.blockPosition(); if (serverLevel.canSpreadFireAround(var7)) { BlockState state = BaseFireBlock.getState(serverLevel, var7); From bdde20a6b12f432ae32bf22c18bac1b026a8d82b Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Mon, 3 Nov 2025 23:39:58 +0100 Subject: [PATCH 042/112] reduce diff --- .../sources/net/minecraft/commands/Commands.java.patch | 10 ---------- .../world/level/block/NetherPortalBlock.java.patch | 6 +++--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch index fd41340e2755..dfe4e32943b8 100644 --- a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch @@ -102,16 +102,6 @@ StackTraceElement[] stackTrace = var12.getStackTrace(); for (int i = 0; i < Math.min(stackTrace.length, 3); i++) { -@@ -356,7 +_,8 @@ - } - } - -- private static @Nullable ContextChain finishParsing( -+ -+ private ContextChain finishParsing( - ParseResults parseResults, String command, CommandSourceStack source - ) { - try { @@ -364,7 +_,11 @@ return ContextChain.tryFlatten(parseResults.getContext().build(command)) .orElseThrow(() -> CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().createWithContext(parseResults.getReader())); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch index 6fceb1854e4f..30b239c9d2f8 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch @@ -38,7 +38,7 @@ entity.setAsInsidePortal(this, pos); } } -@@ -126,23 +_,46 @@ +@@ -126,23 +_,47 @@ @Override public @Nullable TeleportTransition getPortalDestination(ServerLevel level, Entity entity, BlockPos pos) { @@ -84,9 +84,9 @@ private @Nullable TeleportTransition getExitPortal( - ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, boolean isNether, WorldBorder worldBorder -- ) { ++ ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, WorldBorder worldBorder, org.bukkit.craftbukkit.event.PortalEventResult result // CraftBukkit + ) { - Optional optional = level.getPortalForcer().findClosestPortalPosition(exitPos, isNether, worldBorder); -+ ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, WorldBorder worldBorder, org.bukkit.craftbukkit.event.PortalEventResult result) { // CraftBukkit + Optional optional = level.getPortalForcer().findClosestPortalPosition(exitPos, worldBorder, result.searchRadius()); // CraftBukkit BlockUtil.FoundRectangle largestRectangleAround; TeleportTransition.PostTeleportTransition postTeleportTransition; From a6e775d1a15e44e7f5005bc4ea4727772c9c31ea Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Mon, 3 Nov 2025 23:46:48 +0100 Subject: [PATCH 043/112] fix non gamerule related compile errors --- .../main/java/org/bukkit/craftbukkit/entity/CraftEntity.java | 3 ++- .../org/bukkit/craftbukkit/entity/CraftEntitySnapshot.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 3af0846ef740..20c344f78a5a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -29,6 +29,7 @@ import net.minecraft.server.network.ServerPlayerConnection; import net.minecraft.util.ProblemReporter; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityProcessor; import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.boss.EnderDragonPart; import net.minecraft.world.entity.boss.enderdragon.EnderDragon; @@ -1028,7 +1029,7 @@ private Entity copy(net.minecraft.world.level.Level level) { final TagValueOutput output = TagValueOutput.createWithContext(problemReporter, level.registryAccess()); this.getHandle().saveAsPassenger(output, false, true, true); - return net.minecraft.world.entity.EntityType.loadEntityRecursive(output.buildResult(), level, EntitySpawnReason.LOAD, java.util.function.Function.identity()); + return net.minecraft.world.entity.EntityType.loadEntityRecursive(output.buildResult(), level, EntitySpawnReason.LOAD, EntityProcessor.NOP); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntitySnapshot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntitySnapshot.java index b3228adb70f9..3df77f98529a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntitySnapshot.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntitySnapshot.java @@ -5,6 +5,7 @@ import com.mojang.logging.LogUtils; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.ProblemReporter; +import net.minecraft.world.entity.EntityProcessor; import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.level.storage.TagValueInput; import net.minecraft.world.level.storage.TagValueOutput; @@ -58,7 +59,7 @@ public String getAsString() { private net.minecraft.world.entity.Entity createInternal(World world) { net.minecraft.world.level.Level level = ((CraftWorld) world).getHandle(); - net.minecraft.world.entity.Entity internal = net.minecraft.world.entity.EntityType.loadEntityRecursive(this.data, level, EntitySpawnReason.LOAD, Function.identity()); + net.minecraft.world.entity.Entity internal = net.minecraft.world.entity.EntityType.loadEntityRecursive(this.data, level, EntitySpawnReason.LOAD, EntityProcessor.NOP); if (internal == null) { // Try creating by type internal = CraftEntityType.bukkitToMinecraft(this.type).create(level, EntitySpawnReason.LOAD); } From 31ff7d6554381b8a4be707b14b6edca10015b8c0 Mon Sep 17 00:00:00 2001 From: Owen <23108066+Owen1212055@users.noreply.github.com> Date: Tue, 4 Nov 2025 16:05:54 -0500 Subject: [PATCH 044/112] Initial pass at GameRule refactor (#13273) --- build-data/paper.at | 1 + .../paper/registry/keys/GameRuleKeys.java | 447 ++++++++++++++++++ .../io/papermc/paper/InternalAPIBridge.java | 4 + .../papermc/paper/registry/RegistryKey.java | 2 + .../src/main/java/org/bukkit/GameRule.java | 434 ++++++++--------- paper-api/src/main/java/org/bukkit/World.java | 4 +- .../java/io/papermc/generator/Rewriters.java | 3 + .../generator/registry/RegistryEntries.java | 5 +- .../types/simple/GameRuleTypeRewriter.java | 18 + .../commands/GameRuleCommand.java.patch | 18 +- .../paper/PaperServerInternalAPIBridge.java | 9 + .../paper/registry/PaperRegistries.java | 3 + .../registry/entry/RegistryTypeMapper.java | 3 +- .../io/papermc/paper/util/Holderable.java | 5 +- .../java/io/papermc/paper/util/MCUtil.java | 11 - .../flag/PaperFeatureFlagProviderImpl.java | 11 +- .../org/bukkit/craftbukkit/CraftGameRule.java | 111 +++++ .../org/bukkit/craftbukkit/CraftRegistry.java | 6 +- .../org/bukkit/craftbukkit/CraftWorld.java | 129 ++--- .../craftbukkit/block/CraftFurnace.java | 6 +- .../craftbukkit/event/CraftEventFactory.java | 25 +- .../craftbukkit/util/CraftNamespacedKey.java | 13 + todo-snapshot.txt | 2 + 23 files changed, 905 insertions(+), 365 deletions(-) create mode 100644 paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/GameRuleTypeRewriter.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java diff --git a/build-data/paper.at b/build-data/paper.at index e7b5fcf29df5..82fbb1f3d8f7 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -718,6 +718,7 @@ public net.minecraft.world.level.dimension.end.EndDragonFight spawnExitPortal(Z) public net.minecraft.world.level.dimension.end.EndDragonFight spawnNewGateway(Lnet/minecraft/core/BlockPos;)V public net.minecraft.world.level.entity.PersistentEntitySectionManager ensureChunkQueuedForLoad(J)V public net.minecraft.world.level.entity.PersistentEntitySectionManager permanentStorage +public net.minecraft.world.level.gamerules.GameRules rules public net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator settings public net.minecraft.world.level.levelgen.SurfaceRules$Condition public net.minecraft.world.level.levelgen.SurfaceRules$Context diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java new file mode 100644 index 000000000000..a19519dc097d --- /dev/null +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java @@ -0,0 +1,447 @@ +package io.papermc.paper.registry.keys; + +import static net.kyori.adventure.key.Key.key; + +import io.papermc.paper.annotation.GeneratedClass; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import net.kyori.adventure.key.Key; +import org.bukkit.GameRule; +import org.jspecify.annotations.NullMarked; + +/** + * Vanilla keys for {@link RegistryKey#GAME_RULE}. + * + * @apiNote The fields provided here are a direct representation of + * what is available from the vanilla game source. They may be + * changed (including removals) on any Minecraft version + * bump, so cross-version compatibility is not provided on the + * same level as it is on most of the other API. + */ +@SuppressWarnings({ + "unused", + "SpellCheckingInspection" +}) +@NullMarked +@GeneratedClass +public final class GameRuleKeys { + /** + * {@code minecraft:advance_time} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ADVANCE_TIME = create(key("advance_time")); + + /** + * {@code minecraft:advance_weather} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ADVANCE_WEATHER = create(key("advance_weather")); + + /** + * {@code minecraft:allow_entering_nether_using_portals} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ALLOW_ENTERING_NETHER_USING_PORTALS = create(key("allow_entering_nether_using_portals")); + + /** + * {@code minecraft:block_drops} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_DROPS = create(key("block_drops")); + + /** + * {@code minecraft:block_explosion_drop_decay} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_EXPLOSION_DROP_DECAY = create(key("block_explosion_drop_decay")); + + /** + * {@code minecraft:command_block_output} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey COMMAND_BLOCK_OUTPUT = create(key("command_block_output")); + + /** + * {@code minecraft:command_blocks_work} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey COMMAND_BLOCKS_WORK = create(key("command_blocks_work")); + + /** + * {@code minecraft:drowning_damage} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DROWNING_DAMAGE = create(key("drowning_damage")); + + /** + * {@code minecraft:elytra_movement_check} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ELYTRA_MOVEMENT_CHECK = create(key("elytra_movement_check")); + + /** + * {@code minecraft:ender_pearls_vanish_on_death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENDER_PEARLS_VANISH_ON_DEATH = create(key("ender_pearls_vanish_on_death")); + + /** + * {@code minecraft:entity_drops} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_DROPS = create(key("entity_drops")); + + /** + * {@code minecraft:fall_damage} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FALL_DAMAGE = create(key("fall_damage")); + + /** + * {@code minecraft:fire_damage} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FIRE_DAMAGE = create(key("fire_damage")); + + /** + * {@code minecraft:fire_spread_radius_around_player} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FIRE_SPREAD_RADIUS_AROUND_PLAYER = create(key("fire_spread_radius_around_player")); + + /** + * {@code minecraft:forgive_dead_players} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FORGIVE_DEAD_PLAYERS = create(key("forgive_dead_players")); + + /** + * {@code minecraft:freeze_damage} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FREEZE_DAMAGE = create(key("freeze_damage")); + + /** + * {@code minecraft:global_sound_events} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GLOBAL_SOUND_EVENTS = create(key("global_sound_events")); + + /** + * {@code minecraft:immediate_respawn} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey IMMEDIATE_RESPAWN = create(key("immediate_respawn")); + + /** + * {@code minecraft:keep_inventory} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey KEEP_INVENTORY = create(key("keep_inventory")); + + /** + * {@code minecraft:lava_source_conversion} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LAVA_SOURCE_CONVERSION = create(key("lava_source_conversion")); + + /** + * {@code minecraft:limited_crafting} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LIMITED_CRAFTING = create(key("limited_crafting")); + + /** + * {@code minecraft:locator_bar} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LOCATOR_BAR = create(key("locator_bar")); + + /** + * {@code minecraft:log_admin_commands} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LOG_ADMIN_COMMANDS = create(key("log_admin_commands")); + + /** + * {@code minecraft:max_block_modifications} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAX_BLOCK_MODIFICATIONS = create(key("max_block_modifications")); + + /** + * {@code minecraft:max_command_forks} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAX_COMMAND_FORKS = create(key("max_command_forks")); + + /** + * {@code minecraft:max_command_sequence_length} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAX_COMMAND_SEQUENCE_LENGTH = create(key("max_command_sequence_length")); + + /** + * {@code minecraft:max_entity_cramming} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAX_ENTITY_CRAMMING = create(key("max_entity_cramming")); + + /** + * {@code minecraft:max_minecart_speed} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAX_MINECART_SPEED = create(key("max_minecart_speed")); + + /** + * {@code minecraft:max_snow_accumulation_height} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAX_SNOW_ACCUMULATION_HEIGHT = create(key("max_snow_accumulation_height")); + + /** + * {@code minecraft:mob_drops} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MOB_DROPS = create(key("mob_drops")); + + /** + * {@code minecraft:mob_explosion_drop_decay} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MOB_EXPLOSION_DROP_DECAY = create(key("mob_explosion_drop_decay")); + + /** + * {@code minecraft:mob_griefing} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MOB_GRIEFING = create(key("mob_griefing")); + + /** + * {@code minecraft:natural_health_regeneration} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey NATURAL_HEALTH_REGENERATION = create(key("natural_health_regeneration")); + + /** + * {@code minecraft:player_movement_check} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PLAYER_MOVEMENT_CHECK = create(key("player_movement_check")); + + /** + * {@code minecraft:players_nether_portal_creative_delay} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = create(key("players_nether_portal_creative_delay")); + + /** + * {@code minecraft:players_nether_portal_default_delay} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = create(key("players_nether_portal_default_delay")); + + /** + * {@code minecraft:players_sleeping_percentage} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PLAYERS_SLEEPING_PERCENTAGE = create(key("players_sleeping_percentage")); + + /** + * {@code minecraft:projectiles_can_break_blocks} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PROJECTILES_CAN_BREAK_BLOCKS = create(key("projectiles_can_break_blocks")); + + /** + * {@code minecraft:pvp} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PVP = create(key("pvp")); + + /** + * {@code minecraft:raids} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RAIDS = create(key("raids")); + + /** + * {@code minecraft:random_tick_speed} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RANDOM_TICK_SPEED = create(key("random_tick_speed")); + + /** + * {@code minecraft:reduced_debug_info} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey REDUCED_DEBUG_INFO = create(key("reduced_debug_info")); + + /** + * {@code minecraft:respawn_radius} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RESPAWN_RADIUS = create(key("respawn_radius")); + + /** + * {@code minecraft:send_command_feedback} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SEND_COMMAND_FEEDBACK = create(key("send_command_feedback")); + + /** + * {@code minecraft:show_advancement_messages} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SHOW_ADVANCEMENT_MESSAGES = create(key("show_advancement_messages")); + + /** + * {@code minecraft:show_death_messages} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SHOW_DEATH_MESSAGES = create(key("show_death_messages")); + + /** + * {@code minecraft:spawn_mobs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SPAWN_MOBS = create(key("spawn_mobs")); + + /** + * {@code minecraft:spawn_monsters} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SPAWN_MONSTERS = create(key("spawn_monsters")); + + /** + * {@code minecraft:spawn_patrols} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SPAWN_PATROLS = create(key("spawn_patrols")); + + /** + * {@code minecraft:spawn_phantoms} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SPAWN_PHANTOMS = create(key("spawn_phantoms")); + + /** + * {@code minecraft:spawn_wandering_traders} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SPAWN_WANDERING_TRADERS = create(key("spawn_wandering_traders")); + + /** + * {@code minecraft:spawn_wardens} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SPAWN_WARDENS = create(key("spawn_wardens")); + + /** + * {@code minecraft:spawner_blocks_work} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SPAWNER_BLOCKS_WORK = create(key("spawner_blocks_work")); + + /** + * {@code minecraft:spectators_generate_chunks} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SPECTATORS_GENERATE_CHUNKS = create(key("spectators_generate_chunks")); + + /** + * {@code minecraft:spread_vines} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SPREAD_VINES = create(key("spread_vines")); + + /** + * {@code minecraft:tnt_explodes} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TNT_EXPLODES = create(key("tnt_explodes")); + + /** + * {@code minecraft:tnt_explosion_drop_decay} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TNT_EXPLOSION_DROP_DECAY = create(key("tnt_explosion_drop_decay")); + + /** + * {@code minecraft:universal_anger} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey UNIVERSAL_ANGER = create(key("universal_anger")); + + /** + * {@code minecraft:water_source_conversion} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WATER_SOURCE_CONVERSION = create(key("water_source_conversion")); + + private GameRuleKeys() { + } + + private static TypedKey create(final Key key) { + throw new UnsupportedOperationException(); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java b/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java index 3bc45d6c7bd5..2b488289b34d 100644 --- a/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java +++ b/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java @@ -7,6 +7,7 @@ import io.papermc.paper.world.damagesource.FallLocationType; import net.kyori.adventure.text.Component; import net.kyori.adventure.util.Services; +import org.bukkit.GameRule; import org.bukkit.block.Biome; import org.bukkit.damage.DamageEffect; import org.bukkit.damage.DamageSource; @@ -16,6 +17,7 @@ import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import java.util.function.Function; import java.util.function.Predicate; /** @@ -97,5 +99,7 @@ class Holder { SkinParts.Mutable allSkinParts(); Component defaultMannequinDescription(); + + GameRule legacyGameRuleBridge(GameRule rule, @Nullable Function fromLegacyToModern, @Nullable Function toLegacyFromModern, Class legacyClass); } diff --git a/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java b/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java index fe22a5fadc17..9e3b06ab5c24 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java @@ -9,6 +9,7 @@ import org.bukkit.Art; import org.bukkit.Fluid; import org.bukkit.GameEvent; +import org.bukkit.GameRule; import org.bukkit.JukeboxSong; import org.bukkit.MusicInstrument; import org.bukkit.Particle; @@ -127,6 +128,7 @@ public sealed interface RegistryKey extends Keyed permits RegistryKeyImpl { RegistryKey DATA_COMPONENT_TYPE = create("data_component_type"); + RegistryKey> GAME_RULE = create("game_rule"); /* ********************** * * Data-driven Registries * diff --git a/paper-api/src/main/java/org/bukkit/GameRule.java b/paper-api/src/main/java/org/bukkit/GameRule.java index e48e17c45a59..e01a5f01dc6c 100644 --- a/paper-api/src/main/java/org/bukkit/GameRule.java +++ b/paper-api/src/main/java/org/bukkit/GameRule.java @@ -1,9 +1,16 @@ package org.bukkit; import com.google.common.base.Preconditions; +import io.papermc.paper.InternalAPIBridge; +import io.papermc.paper.registry.RegistryAccess; +import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.world.flag.FeatureDependant; import java.util.HashMap; import java.util.Map; +import java.util.NoSuchElementException; +import java.util.function.UnaryOperator; + +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -16,242 +23,257 @@ * * @param type of rule (Boolean or Integer) */ -public final class GameRule implements net.kyori.adventure.translation.Translatable, FeatureDependant { +@ApiStatus.NonExtendable +public abstract class GameRule implements net.kyori.adventure.translation.Translatable, FeatureDependant, Keyed { + + // Start generate - GameRule + public static final GameRule ADVANCE_TIME = getByName("advance_time"); + + public static final GameRule ADVANCE_WEATHER = getByName("advance_weather"); + + public static final GameRule ALLOW_ENTERING_NETHER_USING_PORTALS = getByName("allow_entering_nether_using_portals"); + + public static final GameRule BLOCK_DROPS = getByName("block_drops"); + + public static final GameRule BLOCK_EXPLOSION_DROP_DECAY = getByName("block_explosion_drop_decay"); + + public static final GameRule COMMAND_BLOCK_OUTPUT = getByName("command_block_output"); + + public static final GameRule COMMAND_BLOCKS_WORK = getByName("command_blocks_work"); + + public static final GameRule DROWNING_DAMAGE = getByName("drowning_damage"); + + public static final GameRule ELYTRA_MOVEMENT_CHECK = getByName("elytra_movement_check"); + + public static final GameRule ENDER_PEARLS_VANISH_ON_DEATH = getByName("ender_pearls_vanish_on_death"); + + public static final GameRule ENTITY_DROPS = getByName("entity_drops"); + + public static final GameRule FALL_DAMAGE = getByName("fall_damage"); + + public static final GameRule FIRE_DAMAGE = getByName("fire_damage"); + + public static final GameRule FIRE_SPREAD_RADIUS_AROUND_PLAYER = getByName("fire_spread_radius_around_player"); + + public static final GameRule FORGIVE_DEAD_PLAYERS = getByName("forgive_dead_players"); + + public static final GameRule FREEZE_DAMAGE = getByName("freeze_damage"); + + public static final GameRule GLOBAL_SOUND_EVENTS = getByName("global_sound_events"); + + public static final GameRule IMMEDIATE_RESPAWN = getByName("immediate_respawn"); + + public static final GameRule KEEP_INVENTORY = getByName("keep_inventory"); + + public static final GameRule LAVA_SOURCE_CONVERSION = getByName("lava_source_conversion"); + + public static final GameRule LIMITED_CRAFTING = getByName("limited_crafting"); + + public static final GameRule LOCATOR_BAR = getByName("locator_bar"); + + public static final GameRule LOG_ADMIN_COMMANDS = getByName("log_admin_commands"); + + public static final GameRule MAX_BLOCK_MODIFICATIONS = getByName("max_block_modifications"); + + public static final GameRule MAX_COMMAND_FORKS = getByName("max_command_forks"); + + public static final GameRule MAX_COMMAND_SEQUENCE_LENGTH = getByName("max_command_sequence_length"); + + public static final GameRule MAX_ENTITY_CRAMMING = getByName("max_entity_cramming"); + + public static final GameRule MAX_MINECART_SPEED = getByName("max_minecart_speed"); + + public static final GameRule MAX_SNOW_ACCUMULATION_HEIGHT = getByName("max_snow_accumulation_height"); + + public static final GameRule MOB_DROPS = getByName("mob_drops"); + + public static final GameRule MOB_EXPLOSION_DROP_DECAY = getByName("mob_explosion_drop_decay"); + + public static final GameRule MOB_GRIEFING = getByName("mob_griefing"); + + public static final GameRule NATURAL_HEALTH_REGENERATION = getByName("natural_health_regeneration"); + + public static final GameRule PLAYER_MOVEMENT_CHECK = getByName("player_movement_check"); + + public static final GameRule PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = getByName("players_nether_portal_creative_delay"); + + public static final GameRule PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = getByName("players_nether_portal_default_delay"); + + public static final GameRule PLAYERS_SLEEPING_PERCENTAGE = getByName("players_sleeping_percentage"); + + public static final GameRule PROJECTILES_CAN_BREAK_BLOCKS = getByName("projectiles_can_break_blocks"); + + public static final GameRule PVP = getByName("pvp"); + + public static final GameRule RAIDS = getByName("raids"); + + public static final GameRule RANDOM_TICK_SPEED = getByName("random_tick_speed"); + + public static final GameRule REDUCED_DEBUG_INFO = getByName("reduced_debug_info"); + + public static final GameRule RESPAWN_RADIUS = getByName("respawn_radius"); + + public static final GameRule SEND_COMMAND_FEEDBACK = getByName("send_command_feedback"); + + public static final GameRule SHOW_ADVANCEMENT_MESSAGES = getByName("show_advancement_messages"); + + public static final GameRule SHOW_DEATH_MESSAGES = getByName("show_death_messages"); + + public static final GameRule SPAWN_MOBS = getByName("spawn_mobs"); + + public static final GameRule SPAWN_MONSTERS = getByName("spawn_monsters"); + + public static final GameRule SPAWN_PATROLS = getByName("spawn_patrols"); + + public static final GameRule SPAWN_PHANTOMS = getByName("spawn_phantoms"); + + public static final GameRule SPAWN_WANDERING_TRADERS = getByName("spawn_wandering_traders"); + + public static final GameRule SPAWN_WARDENS = getByName("spawn_wardens"); + + public static final GameRule SPAWNER_BLOCKS_WORK = getByName("spawner_blocks_work"); + + public static final GameRule SPECTATORS_GENERATE_CHUNKS = getByName("spectators_generate_chunks"); + + public static final GameRule SPREAD_VINES = getByName("spread_vines"); + + public static final GameRule TNT_EXPLODES = getByName("tnt_explodes"); + + public static final GameRule TNT_EXPLOSION_DROP_DECAY = getByName("tnt_explosion_drop_decay"); + + public static final GameRule UNIVERSAL_ANGER = getByName("universal_anger"); + + public static final GameRule WATER_SOURCE_CONVERSION = getByName("water_source_conversion"); + // End generate - GameRule - private static Map> gameRules = new HashMap<>(); // Boolean rules /** * Toggles the announcing of advancements. */ - public static final GameRule ANNOUNCE_ADVANCEMENTS = new GameRule<>("announceAdvancements", Boolean.class); - - /** - * Whether command blocks should notify admins when they perform commands. - */ - public static final GameRule COMMAND_BLOCK_OUTPUT = new GameRule<>("commandBlockOutput", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule ANNOUNCE_ADVANCEMENTS = InternalAPIBridge.get().legacyGameRuleBridge(SHOW_ADVANCEMENT_MESSAGES, null, null, Boolean.class); /** * Whether the server should skip checking player speed. */ - public static final GameRule DISABLE_PLAYER_MOVEMENT_CHECK = new GameRule<>("disablePlayerMovementCheck", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DISABLE_PLAYER_MOVEMENT_CHECK = InternalAPIBridge.get().legacyGameRuleBridge(PLAYER_MOVEMENT_CHECK, inverseBool(), inverseBool(), Boolean.class); /** * Whether the server should skip checking player speed when the player is * wearing elytra. */ - public static final GameRule DISABLE_ELYTRA_MOVEMENT_CHECK = new GameRule<>("disableElytraMovementCheck", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DISABLE_ELYTRA_MOVEMENT_CHECK = InternalAPIBridge.get().legacyGameRuleBridge(ELYTRA_MOVEMENT_CHECK, inverseBool(), inverseBool(), Boolean.class); /** * Whether time progresses from the current moment. */ - public static final GameRule DO_DAYLIGHT_CYCLE = new GameRule<>("doDaylightCycle", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_DAYLIGHT_CYCLE = InternalAPIBridge.get().legacyGameRuleBridge(ADVANCE_TIME, null, null, Boolean.class); /** * Whether entities that are not mobs should have drops. */ - public static final GameRule DO_ENTITY_DROPS = new GameRule<>("doEntityDrops", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_ENTITY_DROPS = InternalAPIBridge.get().legacyGameRuleBridge(ENTITY_DROPS, null, null, Boolean.class); /** * Whether fire should spread and naturally extinguish. */ - public static final GameRule DO_FIRE_TICK = new GameRule<>("doFireTick", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_FIRE_TICK = InternalAPIBridge.get().legacyGameRuleBridge(FIRE_SPREAD_RADIUS_AROUND_PLAYER, (value) -> value ? 128 : 0, (value) -> value != 0, Boolean.class); /** * Whether players should only be able to craft recipes they've unlocked * first. */ - public static final GameRule DO_LIMITED_CRAFTING = new GameRule<>("doLimitedCrafting", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_LIMITED_CRAFTING = InternalAPIBridge.get().legacyGameRuleBridge(LIMITED_CRAFTING, null, null, Boolean.class); /** * Whether mobs should drop items. */ - public static final GameRule DO_MOB_LOOT = new GameRule<>("doMobLoot", Boolean.class); - - /** - * Whether projectiles can break blocks. - */ - public static final GameRule PROJECTILES_CAN_BREAK_BLOCKS = new GameRule<>("projectilesCanBreakBlocks", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_MOB_LOOT = InternalAPIBridge.get().legacyGameRuleBridge(MOB_DROPS, null, null, Boolean.class); /** * Whether mobs should naturally spawn. */ - public static final GameRule DO_MOB_SPAWNING = new GameRule<>("doMobSpawning", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_MOB_SPAWNING = InternalAPIBridge.get().legacyGameRuleBridge(SPAWN_MOBS, null, null, Boolean.class); /** * Whether blocks should have drops. */ - public static final GameRule DO_TILE_DROPS = new GameRule<>("doTileDrops", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_TILE_DROPS = InternalAPIBridge.get().legacyGameRuleBridge(BLOCK_DROPS, null, null, Boolean.class); /** * Whether the weather will change from the current moment. */ - public static final GameRule DO_WEATHER_CYCLE = new GameRule<>("doWeatherCycle", Boolean.class); - - /** - * Whether the player should keep items in their inventory after death. - */ - public static final GameRule KEEP_INVENTORY = new GameRule<>("keepInventory", Boolean.class); - - /** - * Whether to log admin commands to server log. - */ - public static final GameRule LOG_ADMIN_COMMANDS = new GameRule<>("logAdminCommands", Boolean.class); - - /** - * Whether mobs can pick up items or change blocks. - */ - public static final GameRule MOB_GRIEFING = new GameRule<>("mobGriefing", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_WEATHER_CYCLE = InternalAPIBridge.get().legacyGameRuleBridge(ADVANCE_WEATHER, null, null, Boolean.class); /** * Whether players can regenerate health naturally through their hunger bar. */ - public static final GameRule NATURAL_REGENERATION = new GameRule<>("naturalRegeneration", Boolean.class); - - /** - * Whether the debug screen shows all or reduced information. - */ - public static final GameRule REDUCED_DEBUG_INFO = new GameRule<>("reducedDebugInfo", Boolean.class); - - /** - * Whether the feedback from commands executed by a player should show up in - * chat. Also affects the default behavior of whether command blocks store - * their output text. - */ - public static final GameRule SEND_COMMAND_FEEDBACK = new GameRule<>("sendCommandFeedback", Boolean.class); - - /** - * Whether a message appears in chat when a player dies. - */ - public static final GameRule SHOW_DEATH_MESSAGES = new GameRule<>("showDeathMessages", Boolean.class); - - /** - * Whether players in spectator mode can generate chunks. - */ - public static final GameRule SPECTATORS_GENERATE_CHUNKS = new GameRule<>("spectatorsGenerateChunks", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule NATURAL_REGENERATION = InternalAPIBridge.get().legacyGameRuleBridge(NATURAL_HEALTH_REGENERATION, null, null, Boolean.class); /** * Whether pillager raids are enabled or not. */ - public static final GameRule DISABLE_RAIDS = new GameRule<>("disableRaids", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DISABLE_RAIDS = InternalAPIBridge.get().legacyGameRuleBridge(RAIDS, inverseBool(), inverseBool(), Boolean.class); /** * Whether phantoms will appear without sleeping or not. */ - public static final GameRule DO_INSOMNIA = new GameRule<>("doInsomnia", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_INSOMNIA = InternalAPIBridge.get().legacyGameRuleBridge(SPAWN_PHANTOMS, null, null, Boolean.class); /** * Whether clients will respawn immediately after death or not. */ - public static final GameRule DO_IMMEDIATE_RESPAWN = new GameRule<>("doImmediateRespawn", Boolean.class); - - /** - * Whether drowning damage is enabled or not. - */ - public static final GameRule DROWNING_DAMAGE = new GameRule<>("drowningDamage", Boolean.class); - - /** - * Whether fall damage is enabled or not. - */ - public static final GameRule FALL_DAMAGE = new GameRule<>("fallDamage", Boolean.class); - - /** - * Whether fire damage is enabled or not. - */ - public static final GameRule FIRE_DAMAGE = new GameRule<>("fireDamage", Boolean.class); - - /** - * Whether freeze damage is enabled or not. - */ - public static final GameRule FREEZE_DAMAGE = new GameRule<>("freezeDamage", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_IMMEDIATE_RESPAWN = InternalAPIBridge.get().legacyGameRuleBridge(IMMEDIATE_RESPAWN, null, null, Boolean.class); /** * Whether patrols should naturally spawn. */ - public static final GameRule DO_PATROL_SPAWNING = new GameRule<>("doPatrolSpawning", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_PATROL_SPAWNING = InternalAPIBridge.get().legacyGameRuleBridge(SPAWN_PATROLS, null, null, Boolean.class); /** * Whether traders should naturally spawn. */ - public static final GameRule DO_TRADER_SPAWNING = new GameRule<>("doTraderSpawning", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_TRADER_SPAWNING = InternalAPIBridge.get().legacyGameRuleBridge(SPAWN_WANDERING_TRADERS, null, null, Boolean.class); /** * Whether wardens should naturally spawn. */ - public static final GameRule DO_WARDEN_SPAWNING = new GameRule<>("doWardenSpawning", Boolean.class); - - /** - * Whether mobs should cease being angry at a player once they die. - */ - public static final GameRule FORGIVE_DEAD_PLAYERS = new GameRule<>("forgiveDeadPlayers", Boolean.class); - - /** - * Whether mobs will target all player entities once angered. - */ - public static final GameRule UNIVERSAL_ANGER = new GameRule<>("universalAnger", Boolean.class); - /** - * Whether block explosions will destroy dropped items. - */ - public static final GameRule BLOCK_EXPLOSION_DROP_DECAY = new GameRule<>("blockExplosionDropDecay", Boolean.class); - /** - * * Whether mob explosions will destroy dropped items. - */ - public static final GameRule MOB_EXPLOSION_DROP_DECAY = new GameRule<>("mobExplosionDropDecay", Boolean.class); - /** - * Whether tnt explosions will destroy dropped items. - */ - public static final GameRule TNT_EXPLOSION_DROP_DECAY = new GameRule<>("tntExplosionDropDecay", Boolean.class); - /** - * Whether water blocks can convert into water source blocks. - */ - public static final GameRule WATER_SOURCE_CONVERSION = new GameRule<>("waterSourceConversion", Boolean.class); - /** - * Whether lava blocks can convert into lava source blocks. - */ - public static final GameRule LAVA_SOURCE_CONVERSION = new GameRule<>("lavaSourceConversion", Boolean.class); - /** - * Whether global level events such as ender dragon, wither, and completed - * end portal effects will propagate across the entire server. - */ - public static final GameRule GLOBAL_SOUND_EVENTS = new GameRule<>("globalSoundEvents", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_WARDEN_SPAWNING = InternalAPIBridge.get().legacyGameRuleBridge(SPAWN_WARDENS, null, null, Boolean.class); /** * Whether vines will spread. */ - public static final GameRule DO_VINES_SPREAD = new GameRule<>("doVinesSpread", Boolean.class); - /** - * Whether ender pearls will vanish on player death. - */ - public static final GameRule ENDER_PEARLS_VANISH_ON_DEATH = new GameRule<>("enderPearlsVanishOnDeath", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_VINES_SPREAD = InternalAPIBridge.get().legacyGameRuleBridge(SPREAD_VINES, null, null, Boolean.class); /** * Whether fire will still propagate far away from players (8 chunks). */ - public static final GameRule ALLOW_FIRE_TICKS_AWAY_FROM_PLAYER = new GameRule<>("allowFireTicksAwayFromPlayer", Boolean.class); - /** - * Whether primed tnt explodes. - */ - public static final GameRule TNT_EXPLODES = new GameRule<>("tntExplodes", Boolean.class); - - // Numerical rules - /** - * How often a random block tick occurs (such as plant growth, leaf decay, - * etc.) per chunk section per game tick. 0 will disable random ticks, - * higher numbers will increase random ticks. - */ - public static final GameRule RANDOM_TICK_SPEED = new GameRule<>("randomTickSpeed", Integer.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule ALLOW_FIRE_TICKS_AWAY_FROM_PLAYER = InternalAPIBridge.get().legacyGameRuleBridge(FIRE_SPREAD_RADIUS_AROUND_PLAYER, (value) -> value ? 128 : 0, (value) -> value != 0, Boolean.class); /** * The number of blocks outward from the world spawn coordinates that a * player will spawn in when first joining a server or when dying without a * spawnpoint. */ - public static final GameRule SPAWN_RADIUS = new GameRule<>("spawnRadius", Integer.class); - - /** - * The maximum number of other pushable entities a mob or player can push, - * before taking suffocation damage. - *
- * Setting to 0 disables this rule. - */ - public static final GameRule MAX_ENTITY_CRAMMING = new GameRule<>("maxEntityCramming", Integer.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SPAWN_RADIUS = InternalAPIBridge.get().legacyGameRuleBridge(RESPAWN_RADIUS, null, null, Integer.class); /** * Determines the number at which the chain of command blocks act as a @@ -260,37 +282,24 @@ public final class GameRule implements net.kyori.adventure.translation.Transl * This is the maximum amount of command blocks that can be activated in a * single tick from a single chain. */ - public static final GameRule MAX_COMMAND_CHAIN_LENGTH = new GameRule<>("maxCommandChainLength", Integer.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule MAX_COMMAND_CHAIN_LENGTH = InternalAPIBridge.get().legacyGameRuleBridge(MAX_COMMAND_SEQUENCE_LENGTH, null, null, Integer.class); /** * Determines the number of different commands/functions which execute * commands can fork into. */ - public static final GameRule MAX_COMMAND_FORK_COUNT = new GameRule<>("maxCommandForkCount", Integer.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule MAX_COMMAND_FORK_COUNT = InternalAPIBridge.get().legacyGameRuleBridge(MAX_COMMAND_FORKS, null, null, Integer.class); /** * Determines the maximum number of blocks which a command can modify. */ - public static final GameRule COMMAND_MODIFICATION_BLOCK_LIMIT = new GameRule<>("commandModificationBlockLimit", Integer.class); - - /** - * The percentage of online players which must be sleeping for the night to - * advance. - */ - public static final GameRule PLAYERS_SLEEPING_PERCENTAGE = new GameRule<>("playersSleepingPercentage", Integer.class); - public static final GameRule SNOW_ACCUMULATION_HEIGHT = new GameRule<>("snowAccumulationHeight", Integer.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule COMMAND_MODIFICATION_BLOCK_LIMIT = InternalAPIBridge.get().legacyGameRuleBridge(MAX_BLOCK_MODIFICATIONS, null, null, Integer.class); - /** - * The amount of time a player must stand in a nether portal before the - * portal activates. - */ - public static final GameRule PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = new GameRule<>("playersNetherPortalDefaultDelay", Integer.class); - - /** - * The amount of time a player in creative mode must stand in a nether - * portal before the portal activates. - */ - public static final GameRule PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = new GameRule<>("playersNetherPortalCreativeDelay", Integer.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SNOW_ACCUMULATION_HEIGHT = InternalAPIBridge.get().legacyGameRuleBridge(MAX_SNOW_ACCUMULATION_HEIGHT, null, null, Integer.class); /** * The maximum speed of minecarts (when the new movement algorithm is @@ -298,49 +307,23 @@ public final class GameRule implements net.kyori.adventure.translation.Transl */ @MinecraftExperimental(MinecraftExperimental.Requires.MINECART_IMPROVEMENTS) // Paper - add missing annotation @org.jetbrains.annotations.ApiStatus.Experimental // Paper - add missing annotation - public static final GameRule MINECART_MAX_SPEED = new GameRule<>("minecartMaxSpeed", Integer.class); - - /** - * Configures if the world uses the locator bar. - */ - public static final GameRule LOCATOR_BAR = new GameRule<>("locatorBar", Boolean.class); - - /** - * Whether player versus player combat is allowed. - */ - public static final GameRule PVP = new GameRule<>("pvp", Boolean.class); - - /** - * Whether monsters should naturally spawn. - */ - public static final GameRule SPAWN_MONSTERS = new GameRule<>("spawnMonsters", Boolean.class); - - /** - * Whether players can enter the Nether using portals. - */ - public static final GameRule ALLOW_ENTERING_NETHER_USING_PORTALS = new GameRule<>("allowEnteringNetherUsingPortals", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule MINECART_MAX_SPEED = InternalAPIBridge.get().legacyGameRuleBridge(MAX_MINECART_SPEED, null, null, Integer.class); /** * Whether command blocks are enabled. */ - public static final GameRule COMMAND_BLOCKS_ENABLED = new GameRule<>("commandBlocksEnabled", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule COMMAND_BLOCKS_ENABLED = InternalAPIBridge.get().legacyGameRuleBridge(COMMAND_BLOCKS_WORK, null, null, Boolean.class); /** * Whether spawner blocks are enabled. */ - public static final GameRule SPAWNER_BLOCKS_ENABLED = new GameRule<>("spawnerBlocksEnabled", Boolean.class); - - // All GameRules instantiated above this for organizational purposes - private final String name; - private final Class type; - - private GameRule(@NotNull String name, @NotNull Class clazz) { - Preconditions.checkNotNull(name, "GameRule name cannot be null"); - Preconditions.checkNotNull(clazz, "GameRule type cannot be null"); - Preconditions.checkArgument(clazz == Boolean.class || clazz == Integer.class, "Must be of type Boolean or Integer. Found %s ", clazz.getName()); - this.name = name; - this.type = clazz; - gameRules.put(name, this); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SPAWNER_BLOCKS_ENABLED = InternalAPIBridge.get().legacyGameRuleBridge(SPAWNER_BLOCKS_WORK, null, null, Boolean.class); + + private static UnaryOperator inverseBool() { + return operand -> !operand; } /** @@ -349,9 +332,7 @@ private GameRule(@NotNull String name, @NotNull Class clazz) { * @return the name of this GameRule */ @NotNull - public String getName() { - return name; - } + public abstract String getName(); /** * Get the type of this rule. @@ -359,26 +340,7 @@ public String getName() { * @return the rule type; Integer or Boolean */ @NotNull - public Class getType() { - return type; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof GameRule)) { - return false; - } - GameRule other = (GameRule) obj; - return this.getName().equals(other.getName()) && this.getType() == other.getType(); - } - - @Override - public String toString() { - return "GameRule{" + "key=" + name + ", type=" + type + '}'; - } + public abstract Class getType(); /** * Get a {@link GameRule} by its name. @@ -388,9 +350,13 @@ public String toString() { * name */ @Nullable - public static GameRule getByName(@NotNull String rule) { + public static GameRule getByName(@NotNull String rule) { Preconditions.checkNotNull(rule, "Rule cannot be null"); - return gameRules.get(rule); + try { + return (GameRule) RegistryAccess.registryAccess().getRegistry(RegistryKey.GAME_RULE).getOrThrow(NamespacedKey.minecraft(rule)); + } catch (IllegalArgumentException | NoSuchElementException e) { + return null; + } } /** @@ -400,12 +366,12 @@ public static GameRule getByName(@NotNull String rule) { */ @NotNull public static GameRule[] values() { - return gameRules.values().toArray(new GameRule[gameRules.size()]); + return RegistryAccess.registryAccess().getRegistry(RegistryKey.GAME_RULE) + .stream() + .toArray(GameRule[]::new); } @Override - public @NotNull String translationKey() { - return "gamerule." + this.name; - } + public abstract @NotNull String translationKey(); } diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index 408f1ea16c42..d1e47051bd8f 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -3788,7 +3788,7 @@ default void playSound(@NotNull Entity entity, @NotNull String sound, float volu * @return String value of rule * @deprecated use {@link #getGameRuleValue(GameRule)} instead */ - @Deprecated(since = "1.13") + @Deprecated(since = "1.21.11", forRemoval = true) @Contract("null -> null; !null -> !null") @Nullable public String getGameRuleValue(@Nullable String rule); @@ -3806,7 +3806,7 @@ default void playSound(@NotNull Entity entity, @NotNull String sound, float volu * @return True if rule was set * @deprecated use {@link #setGameRule(GameRule, Object)} instead. */ - @Deprecated(since = "1.13") + @Deprecated(since = "1.13", forRemoval = true) public boolean setGameRuleValue(@NotNull String rule, @NotNull String value); /** diff --git a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java index 3cb31687e3a6..410cd1e6b426 100644 --- a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java +++ b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java @@ -16,6 +16,7 @@ import io.papermc.generator.rewriter.types.simple.CraftBlockEntityStateMapping; import io.papermc.generator.rewriter.types.simple.CraftPotionUtilRewriter; import io.papermc.generator.rewriter.types.simple.EntityTypeRewriter; +import io.papermc.generator.rewriter.types.simple.GameRuleTypeRewriter; import io.papermc.generator.rewriter.types.simple.MapPaletteRewriter; import io.papermc.generator.rewriter.types.simple.MaterialRewriter; import io.papermc.generator.rewriter.types.simple.MemoryKeyRewriter; @@ -48,6 +49,7 @@ import org.bukkit.FeatureFlag; import org.bukkit.Fluid; import org.bukkit.GameEvent; +import org.bukkit.GameRule; import org.bukkit.JukeboxSong; import org.bukkit.Material; import org.bukkit.MusicInstrument; @@ -212,6 +214,7 @@ protected String rewriteFieldName(Holder.Reference(Registries.PIG_VARIANT, "getVariant")) .register("Dialog", Dialog.class, new RegistryFieldRewriter<>(Registries.DIALOG, "getDialog")) .register("MemoryKey", MemoryKey.class, new MemoryKeyRewriter()) + .register("GameRule", GameRule.class, new GameRuleTypeRewriter()) // .register("ItemType", org.bukkit.inventory.ItemType.class, new io.papermc.generator.rewriter.types.simple.ItemTypeRewriter()) - disable for now, lynx want the generic type .register("BlockType", BlockType.class, new BlockTypeRewriter()) .register("FeatureFlag", FeatureFlag.class, new FeatureFlagRewriter()) diff --git a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java index a4e46283c758..278eb671f4dd 100644 --- a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java +++ b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java @@ -62,12 +62,14 @@ import net.minecraft.world.level.biome.Biomes; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BannerPatterns; +import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.levelgen.structure.BuiltinStructures; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.saveddata.maps.MapDecorationTypes; import org.bukkit.Art; import org.bukkit.Fluid; import org.bukkit.GameEvent; +import org.bukkit.GameRule; import org.bukkit.JukeboxSong; import org.bukkit.Keyed; import org.bukkit.MusicInstrument; @@ -164,7 +166,8 @@ private static RegistryEntry inconsistentEntry(ResourceKey> DATA_DRIVEN = List.of( diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/GameRuleTypeRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/GameRuleTypeRewriter.java new file mode 100644 index 000000000000..a9746adc583d --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/GameRuleTypeRewriter.java @@ -0,0 +1,18 @@ +package io.papermc.generator.rewriter.types.simple; + +import io.papermc.generator.rewriter.types.registry.RegistryFieldRewriter; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.level.gamerules.GameRule; + +public class GameRuleTypeRewriter extends RegistryFieldRewriter> { + + public GameRuleTypeRewriter() { + super(Registries.GAME_RULE, "getByName"); + } + + @Override + protected String rewriteFieldType(Holder.Reference> reference) { + return "%s<%s>".formatted(this.registryEntry.apiClass().getSimpleName(), this.importCollector.getShortName(reference.value().valueClass())); + } +} diff --git a/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch index 95d7b3d5f300..64f6c524bca6 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch @@ -1,22 +1,12 @@ --- a/net/minecraft/server/commands/GameRuleCommand.java +++ b/net/minecraft/server/commands/GameRuleCommand.java -@@ -34,7 +_,18 @@ +@@ -33,8 +_,7 @@ + static int setRule(CommandContext context, GameRule rule) { CommandSourceStack commandSourceStack = context.getSource(); - T argument = context.getArgument("value", rule.valueClass()); +- T argument = context.getArgument("value", rule.valueClass()); - commandSourceStack.getLevel().getGameRules().set(rule, argument, context.getSource().getServer()); -+ // Paper start - Add WorldGameRuleChangeEvent -+ final var event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent( -+ context.getSource().getBukkitWorld(), -+ context.getSource().getBukkitSender(), -+ org.bukkit.GameRule.getByName(gameRuleKey.toString()), -+ String.valueOf(argument) -+ ); -+ if (!event.callEvent()) { -+ return 0; -+ } -+ // Paper end - Add WorldGameRuleChangeEvent -+ commandSourceStack.getLevel().getGameRules().set(rule, argument, context.getSource().getLevel()); // Paper - per-world game rules ++ T argument = org.bukkit.craftbukkit.event.CraftEventFactory.handleGameRuleSet(rule, context.getArgument("value", rule.valueClass()), commandSourceStack.getLevel(), context.getSource().getBukkitSender()).value(); // Paper - per-world game rules and event commandSourceStack.sendSuccess(() -> Component.translatable("commands.gamerule.set", rule.id(), rule.serialize(argument)), true); return rule.getCommandResult(argument); } diff --git a/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java b/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java index c87a7f8caf5f..0ac6e1cf00ec 100644 --- a/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java +++ b/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java @@ -15,7 +15,9 @@ import net.minecraft.commands.Commands; import net.minecraft.world.damagesource.FallLocation; import net.minecraft.world.entity.decoration.Mannequin; +import org.bukkit.GameRule; import org.bukkit.block.Biome; +import org.bukkit.craftbukkit.CraftGameRule; import org.bukkit.craftbukkit.block.CraftBiome; import org.bukkit.craftbukkit.damage.CraftDamageEffect; import org.bukkit.craftbukkit.damage.CraftDamageSource; @@ -25,6 +27,8 @@ import org.bukkit.entity.LivingEntity; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; + +import java.util.function.Function; import java.util.function.Predicate; @NullMarked @@ -108,4 +112,9 @@ public SkinParts.Mutable allSkinParts() { public Component defaultMannequinDescription() { return PaperAdventure.asAdventure(Mannequin.DEFAULT_DESCRIPTION); } + + @Override + public GameRule legacyGameRuleBridge(GameRule rule, @Nullable Function fromLegacyToModern, @Nullable Function toLegacyFromModern, Class legacyClass) { + return CraftGameRule.wrap(rule, fromLegacyToModern, toLegacyFromModern, legacyClass); + } } diff --git a/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java index 844c2b8fd46d..247fa2f61b03 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java @@ -35,6 +35,7 @@ import org.bukkit.Art; import org.bukkit.Fluid; import org.bukkit.GameEvent; +import org.bukkit.GameRule; import org.bukkit.JukeboxSong; import org.bukkit.Keyed; import org.bukkit.MusicInstrument; @@ -46,6 +47,7 @@ import org.bukkit.craftbukkit.CraftArt; import org.bukkit.craftbukkit.CraftFluid; import org.bukkit.craftbukkit.CraftGameEvent; +import org.bukkit.craftbukkit.CraftGameRule; import org.bukkit.craftbukkit.CraftJukeboxSong; import org.bukkit.craftbukkit.CraftMusicInstrument; import org.bukkit.craftbukkit.CraftSound; @@ -115,6 +117,7 @@ public final class PaperRegistries { start(Registries.FLUID, RegistryKey.FLUID).craft(Fluid.class, CraftFluid::new).build(), start(Registries.SOUND_EVENT, RegistryKey.SOUND_EVENT).craft(Sound.class, CraftSound::new, true).create(PaperSoundEventRegistryEntry.PaperBuilder::new, RegistryEntryMeta.RegistryModificationApiSupport.NONE), start(Registries.DATA_COMPONENT_TYPE, RegistryKey.DATA_COMPONENT_TYPE).craft(DataComponentTypes.class, PaperDataComponentType::of).build(), + start(Registries.GAME_RULE, RegistryKey.GAME_RULE).craft(GameRule.class, CraftGameRule::new).build(), // data-driven start(Registries.BIOME, RegistryKey.BIOME).craft(Biome.class, CraftBiome::new).build().delayed(), diff --git a/paper-server/src/main/java/io/papermc/paper/registry/entry/RegistryTypeMapper.java b/paper-server/src/main/java/io/papermc/paper/registry/entry/RegistryTypeMapper.java index 87c0f502afb5..b34d415d70e1 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/entry/RegistryTypeMapper.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/entry/RegistryTypeMapper.java @@ -6,6 +6,7 @@ import java.util.function.Function; import net.minecraft.core.Holder; import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; public final class RegistryTypeMapper { @@ -14,7 +15,7 @@ public final class RegistryTypeMapper { if (!(holder instanceof final Holder.Reference reference)) { throw new IllegalArgumentException("This type does not support direct holders: " + holder); } - return byValueCreator.apply(MCUtil.fromResourceKey(reference.key()), reference.value()); + return byValueCreator.apply(CraftNamespacedKey.fromResourceKey(reference.key()), reference.value()); }; } diff --git a/paper-server/src/main/java/io/papermc/paper/util/Holderable.java b/paper-server/src/main/java/io/papermc/paper/util/Holderable.java index 746c14b1792d..fd300b21350b 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/Holderable.java +++ b/paper-server/src/main/java/io/papermc/paper/util/Holderable.java @@ -12,6 +12,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.Registry; import org.bukkit.craftbukkit.CraftRegistry; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.craftbukkit.util.Handleable; import org.intellij.lang.annotations.Subst; import org.jspecify.annotations.NullMarked; @@ -80,10 +81,10 @@ default String implToString() { } default @Nullable NamespacedKey getKeyOrNull() { - return this.getHolder().unwrapKey().map(MCUtil::fromResourceKey).orElse(null); + return this.getHolder().unwrapKey().map(CraftNamespacedKey::fromResourceKey).orElse(null); } default NamespacedKey getKey() { - return MCUtil.fromResourceKey(this.getHolder().unwrapKey().orElseThrow(() -> new IllegalStateException("Cannot get key for this registry item, because it is not registered."))); + return CraftNamespacedKey.fromResourceKey(this.getHolder().unwrapKey().orElseThrow(() -> new IllegalStateException("Cannot get key for this registry item, because it is not registered."))); } } diff --git a/paper-server/src/main/java/io/papermc/paper/util/MCUtil.java b/paper-server/src/main/java/io/papermc/paper/util/MCUtil.java index e3138cd67378..46f6750b1eae 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/MCUtil.java +++ b/paper-server/src/main/java/io/papermc/paper/util/MCUtil.java @@ -199,17 +199,6 @@ public static void scheduleAsyncTask(Runnable run) { ASYNC_EXECUTOR.execute(run); } - public static ResourceKey toResourceKey( - final ResourceKey> registry, - final NamespacedKey namespacedKey - ) { - return ResourceKey.create(registry, CraftNamespacedKey.toMinecraft(namespacedKey)); - } - - public static NamespacedKey fromResourceKey(final ResourceKey key) { - return CraftNamespacedKey.fromMinecraft(key.location()); - } - public static List transformUnmodifiable(final List nms, final Function converter) { return Collections.unmodifiableList(Lists.transform(nms, converter::apply)); } diff --git a/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java b/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java index 179042955e33..098da4a8bd86 100644 --- a/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java @@ -12,6 +12,7 @@ import net.minecraft.world.level.gamerules.GameRules; import org.bukkit.FeatureFlag; import org.bukkit.GameRule; +import org.bukkit.craftbukkit.CraftGameRule; import org.bukkit.craftbukkit.entity.CraftEntityType; import org.bukkit.craftbukkit.potion.CraftPotionType; import org.bukkit.entity.EntityType; @@ -51,18 +52,10 @@ static FeatureElement getFeatureElement(final FeatureDependant dependant) { } else if (dependant instanceof final PotionType potionType) { return CraftPotionType.bukkitToMinecraft(potionType); } else if (dependant instanceof final GameRule gameRule) { - return getGameRuleType(gameRule.getName()).asFeatureElement(); + return () -> CraftGameRule.bukkitToMinecraft(gameRule).requiredFeatures(); } else { throw new IllegalArgumentException(dependant + " is not a valid feature dependant"); } } - private static GameRules.Type getGameRuleType(final String name) { - for (final Map.Entry, GameRules.Type> gameRules : GameRules.GAME_RULE_TYPES.entrySet()) { - if (gameRules.getKey().getId().equals(name)) { - return gameRules.getValue(); - } - } - return null; - } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java new file mode 100644 index 000000000000..aa09c08aaa98 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java @@ -0,0 +1,111 @@ +package org.bukkit.craftbukkit; + +import io.papermc.paper.util.Holderable; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import org.bukkit.GameRule; +import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +import java.util.function.Function; + +@NullMarked +public class CraftGameRule extends GameRule implements Holderable> { + + public static GameRule minecraftToBukkit(net.minecraft.world.level.gamerules.GameRule minecraft) { + return CraftRegistry.minecraftToBukkit(minecraft, Registries.GAME_RULE); + } + + public static net.minecraft.world.level.gamerules.GameRule bukkitToMinecraft(GameRule bukkit) { + return CraftRegistry.bukkitToMinecraft(bukkit); + } + + public static Holder> bukkitToMinecraftHolder(GameRule bukkit) { + return CraftRegistry.bukkitToMinecraftHolder(bukkit); + } + + private final Holder> holder; + + @SuppressWarnings("unchecked") + public CraftGameRule(Holder> holder) { + this.holder = (Holder) holder; + } + + public static GameRule wrap(GameRule rule, @Nullable Function fromLegacyToModern, @Nullable Function toLegacyFromModern, Class legacyClass) { + return new LegacyGameRuleWrapper<>(bukkitToMinecraftHolder(rule), fromLegacyToModern, toLegacyFromModern, legacyClass); + } + + @Override + public Holder> getHolder() { + return this.holder; + } + + @Override + public NamespacedKey getKey() { + return Holderable.super.getKey(); + } + + @Override + public int hashCode() { + return Holderable.super.implHashCode(); + } + + @Override + public boolean equals(final Object obj) { + return Holderable.super.implEquals(obj); + } + + @Override + public String toString() { + return Holderable.super.implToString(); + } + + @Override + public @NotNull String getName() { + return this.holder.getRegisteredName(); + } + + @SuppressWarnings("unchecked") + @Override + public @NotNull Class getType() { + return (Class) switch (this.holder.value().gameRuleType()) { + case INT -> Integer.class; + case BOOL -> Boolean.class; + }; + } + + @Override + public @NotNull String translationKey() { + return this.holder.value().id(); + } + + public static class LegacyGameRuleWrapper extends CraftGameRule { + + private final Class typeOverride; + private final @Nullable Function fromLegacyToModern; + private final @Nullable Function toLegacyFromModern; + + public LegacyGameRuleWrapper(Holder> holder, @Nullable Function fromLegacyToModern, @Nullable Function toLegacyFromModern, Class typeOverride) { + super(holder); + this.fromLegacyToModern = fromLegacyToModern; + this.toLegacyFromModern = toLegacyFromModern; + this.typeOverride = typeOverride; + } + + + public @Nullable Function getFromLegacyToModern() { + return fromLegacyToModern; + } + + public @Nullable Function getToLegacyFromModern() { + return toLegacyFromModern; + } + + @Override + public @NotNull Class getType() { + return this.typeOverride; + } + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java index 889d8c3fbc5f..6dfd2763023a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java @@ -84,7 +84,7 @@ public static B minecraftHolderToBukkit(final Holder min } yield ((CraftRegistry) bukkitRegistry).createBukkit(direct); } - case final Holder.Reference reference -> bukkitRegistry.get(MCUtil.fromResourceKey(reference.key())); + case final Holder.Reference reference -> bukkitRegistry.get(CraftNamespacedKey.fromResourceKey(reference.key())); default -> throw new IllegalArgumentException("Unknown holder: " + minecraft); }; Preconditions.checkArgument(bukkit != null); @@ -196,7 +196,7 @@ public B get(NamespacedKey namespacedKey) { } // Important to use the ResourceKey "get" method below because it will work before registry is frozen - final Optional> holderOptional = this.minecraftRegistry.get(MCUtil.toResourceKey(this.minecraftRegistry.key(), namespacedKey)); + final Optional> holderOptional = this.minecraftRegistry.get(CraftNamespacedKey.toResourceKey(this.minecraftRegistry.key(), namespacedKey)); final Holder.Reference holder; if (holderOptional.isPresent()) { holder = holderOptional.get(); @@ -204,7 +204,7 @@ public B get(NamespacedKey namespacedKey) { // we lock the reference holders after the preload class has been initialized // this is to support the vanilla mechanic of preventing vanilla registry entries being loaded. We need // to create something to fill the API constant fields, so we create a dummy reference holder. - holder = Holder.Reference.createStandAlone(this.invalidHolderOwner, MCUtil.toResourceKey(this.minecraftRegistry.key(), namespacedKey)); + holder = Holder.Reference.createStandAlone(this.invalidHolderOwner, CraftNamespacedKey.toResourceKey(this.minecraftRegistry.key(), namespacedKey)); } else { return null; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index d42c6a0c5b0c..24dde641b730 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -26,6 +26,7 @@ import java.util.Random; import java.util.Set; import java.util.UUID; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -67,6 +68,7 @@ import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.gamerules.GameRule; import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.Climate; @@ -88,7 +90,6 @@ import org.bukkit.Difficulty; import org.bukkit.Effect; import org.bukkit.FluidCollisionMode; -import org.bukkit.GameRule; import org.bukkit.Location; import org.bukkit.NamespacedKey; import org.bukkit.Particle; @@ -110,6 +111,7 @@ import org.bukkit.craftbukkit.boss.CraftDragonBattle; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.generator.structure.CraftGeneratedStructure; import org.bukkit.craftbukkit.generator.structure.CraftStructure; import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -1647,54 +1649,22 @@ private java.util.function.BiConsumer, } // Paper end - Adventure - private Map> gamerules; - public synchronized Map> getGameRulesNMS() { - if (this.gamerules != null) { - return this.gamerules; - } - - return this.gamerules = CraftWorld.getGameRulesNMS(this.getHandle().getGameRules()); - } - - public static Map> getGameRulesNMS(GameRules gameRules) { - Map> gamerules = new HashMap<>(); - gameRules.visitGameRuleTypes(new GameRules.GameRuleTypeVisitor() { - @Override - public > void visit(GameRules.Key key, GameRules.Type type) { - gamerules.put(key.getId(), key); - } - }); - return gamerules; - } - - private Map> gameruleDefinitions; - public synchronized Map> getGameRuleDefinitions() { - if (this.gameruleDefinitions != null) { - return this.gameruleDefinitions; - } - - Map> gameruleDefinitions = new HashMap<>(); - this.getHandle().getGameRules().visitGameRuleTypes(new GameRules.GameRuleTypeVisitor() { - @Override - public > void visit(GameRules.Key key, GameRules.Type type) { - gameruleDefinitions.put(key.getId(), type); - } - }); - - return this.gameruleDefinitions = gameruleDefinitions; - } - @Override public String getGameRuleValue(String rule) { // In method contract for some reason if (rule == null) { return null; } + GameRule nms = CraftGameRule.bukkitToMinecraft(org.bukkit.GameRule.getByName(rule)); + GameRules gameRules = this.getHandle().getGameRules(); + if (!gameRules.rules.has(nms)) { + return ""; + } - GameRules.Value value = this.getHandle().getGameRules().getRule(this.getGameRulesNMS().get(rule)); - return value != null ? value.toString() : ""; + return gameRules.getAsString(nms); } + @SuppressWarnings({"unchecked", "rawtypes"}) @Override public boolean setGameRuleValue(String rule, String value) { // No null values allowed @@ -1702,76 +1672,69 @@ public boolean setGameRuleValue(String rule, String value) { if (!this.isGameRule(rule)) return false; // Paper start - Add WorldGameRuleChangeEvent - GameRule gameRule = GameRule.getByName(rule); - io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(this, null, gameRule, value); - if (!event.callEvent()) return false; - // Paper end - Add WorldGameRuleChangeEvent - - GameRules.Value handle = this.getHandle().getGameRules().getRule(this.getGameRulesNMS().get(rule)); - handle.deserialize(event.getValue()); // Paper - Add WorldGameRuleChangeEvent - handle.onChanged(this.getHandle()); - return true; + org.bukkit.GameRule bukkit = org.bukkit.GameRule.getByName(rule); + + GameRule nms = CraftGameRule.bukkitToMinecraft(bukkit); + + return !CraftEventFactory.handleGameRuleSet(nms, nms.deserialize(value).getOrThrow(), this.getHandle(), null).cancelled(); } @Override public String[] getGameRules() { - return this.getGameRulesNMS().keySet().toArray(new String[this.getGameRulesNMS().size()]); + return this.getHandle().getGameRules().availableRules() + .map(GameRule::id) + .toArray(String[]::new); } @Override public boolean isGameRule(String rule) { Preconditions.checkArgument(rule != null, "String rule cannot be null"); Preconditions.checkArgument(!rule.isEmpty(), "String rule cannot be empty"); - return this.getGameRulesNMS().containsKey(rule); + + GameRule nms = CraftGameRule.bukkitToMinecraft(org.bukkit.GameRule.getByName(rule)); + GameRules gameRules = this.getHandle().getGameRules(); + return gameRules.rules.has(nms); } - @Override - public T getGameRuleValue(GameRule rule) { - Preconditions.checkArgument(rule != null, "GameRule cannot be null"); - GameRules.Key> key = this.getGameRulesNMS().get(rule.getName()); - Preconditions.checkArgument(key != null, "GameRule '%s' is not available", rule.getName()); + public static T shimLegacyValue(T value, org.bukkit.GameRule gameRule){ + //noinspection all + if (gameRule instanceof CraftGameRule.LegacyGameRuleWrapper legacyGameRuleWrapper) { + //noinspection all + return (T) legacyGameRuleWrapper.getToLegacyFromModern().apply(value); + } - return this.getGameRuleResult(rule, this.getHandle().getGameRules().getRule(key)); + return value; } @Override - public T getGameRuleDefault(GameRule rule) { + public @Nullable T getGameRuleValue(org.bukkit.@NotNull GameRule rule) { Preconditions.checkArgument(rule != null, "GameRule cannot be null"); - GameRules.Type type = this.getGameRuleDefinitions().get(rule.getName()); - Preconditions.checkArgument(type != null, "GameRule '%s' is not available", rule.getName()); - return this.getGameRuleResult(rule, type.createRule()); + T value = this.getHandle().getGameRules().get(CraftGameRule.bukkitToMinecraft(rule)); + return shimLegacyValue(value, rule); } @Override - public boolean setGameRule(GameRule rule, T newValue) { + public @Nullable T getGameRuleDefault(org.bukkit.@NotNull GameRule rule) { Preconditions.checkArgument(rule != null, "GameRule cannot be null"); - Preconditions.checkArgument(newValue != null, "GameRule value cannot be null"); - - if (!this.isGameRule(rule.getName())) return false; - // Paper start - Add WorldGameRuleChangeEvent - io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(this, null, rule, String.valueOf(newValue)); - if (!event.callEvent()) return false; - // Paper end - Add WorldGameRuleChangeEvent + T value = CraftGameRule.bukkitToMinecraft(rule).defaultValue(); - GameRules.Value handle = this.getHandle().getGameRules().getRule(this.getGameRulesNMS().get(rule.getName())); - handle.deserialize(event.getValue()); // Paper - Add WorldGameRuleChangeEvent - handle.onChanged(this.getHandle()); - return true; + return shimLegacyValue(value, rule); } - private T getGameRuleResult(GameRule rule, GameRules.Value value) { - if (value == null) { - return null; + @Override + public boolean setGameRule(org.bukkit.@NotNull GameRule rule, @NotNull T newValue) { + Preconditions.checkArgument(rule != null, "GameRule cannot be null"); + Preconditions.checkArgument(newValue != null, "GameRule value cannot be null"); + GameRule<@NotNull T> nms = CraftGameRule.bukkitToMinecraft(rule); + if (!this.getHandle().getGameRules().rules.has(nms)) { + return false; } - - if (value instanceof GameRules.BooleanValue) { - return rule.getType().cast(((GameRules.BooleanValue) value).get()); - } else if (value instanceof GameRules.IntegerValue) { - return rule.getType().cast(value.getCommandResult()); - } else { - throw new IllegalArgumentException("Invalid GameRule type (" + value + ") for GameRule " + rule.getName()); + if (rule instanceof CraftGameRule.LegacyGameRuleWrapper legacyGameRuleWrapper) { + newValue = (T) legacyGameRuleWrapper.getFromLegacyToModern().apply(newValue); } + + return !CraftEventFactory.handleGameRuleSet(nms, newValue, this.getHandle(), null).cancelled(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java index b652f93063f7..c7f958024968 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java @@ -106,17 +106,17 @@ public void setCookSpeedMultiplier(double multiplier) { @Override public int getRecipeUsedCount(org.bukkit.NamespacedKey furnaceRecipe) { - return this.getSnapshot().recipesUsed.getInt(io.papermc.paper.util.MCUtil.toResourceKey(net.minecraft.core.registries.Registries.RECIPE, furnaceRecipe)); + return this.getSnapshot().recipesUsed.getInt(CraftNamespacedKey.toResourceKey(net.minecraft.core.registries.Registries.RECIPE, furnaceRecipe)); } @Override public boolean hasRecipeUsedCount(org.bukkit.NamespacedKey furnaceRecipe) { - return this.getSnapshot().recipesUsed.containsKey(io.papermc.paper.util.MCUtil.toResourceKey(net.minecraft.core.registries.Registries.RECIPE, furnaceRecipe)); + return this.getSnapshot().recipesUsed.containsKey(CraftNamespacedKey.toResourceKey(net.minecraft.core.registries.Registries.RECIPE, furnaceRecipe)); } @Override public void setRecipeUsedCount(org.bukkit.inventory.CookingRecipe furnaceRecipe, int count) { - final var location = io.papermc.paper.util.MCUtil.toResourceKey(net.minecraft.core.registries.Registries.RECIPE, furnaceRecipe.getKey()); + final var location = CraftNamespacedKey.toResourceKey(net.minecraft.core.registries.Registries.RECIPE, furnaceRecipe.getKey()); java.util.Optional> nmsRecipe = (this.isPlaced() ? this.world.getHandle().recipeAccess() : net.minecraft.server.MinecraftServer.getServer().getRecipeManager()).byKey(location); com.google.common.base.Preconditions.checkArgument(nmsRecipe.isPresent() && nmsRecipe.get().value() instanceof net.minecraft.world.item.crafting.AbstractCookingRecipe, furnaceRecipe.getKey() + " is not recognized as a valid and registered furnace recipe"); if (count > 0) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 23337d8f2e7e..5671d70ddce5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -25,7 +25,6 @@ import net.minecraft.network.Connection; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ServerboundContainerClosePacket; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -34,7 +33,6 @@ import net.minecraft.util.Unit; import net.minecraft.world.Container; import net.minecraft.world.InteractionHand; -import net.minecraft.world.attribute.EnvironmentAttribute; import net.minecraft.world.attribute.EnvironmentAttributes; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageTypes; @@ -68,6 +66,7 @@ import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.entity.SignBlockEntity; import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; +import net.minecraft.world.level.gamerules.GameRule; import net.minecraft.world.level.redstone.Redstone; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootTable; @@ -86,9 +85,11 @@ import org.bukkit.block.BlockState; import org.bukkit.block.Sign; import org.bukkit.block.sign.Side; +import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.CraftChunk; import org.bukkit.craftbukkit.CraftEquipmentSlot; import org.bukkit.craftbukkit.CraftExplosionResult; +import org.bukkit.craftbukkit.CraftGameRule; import org.bukkit.craftbukkit.CraftLootTable; import org.bukkit.craftbukkit.CraftRaid; import org.bukkit.craftbukkit.CraftServer; @@ -270,6 +271,7 @@ import org.bukkit.inventory.view.AnvilView; import org.bukkit.potion.PotionEffect; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class CraftEventFactory { @@ -2222,4 +2224,23 @@ public static boolean callTransporterValidateTarget(final PathfinderMob mob, fin event.callEvent(); return event.isAllowed(); } + + public static GameRuleSetResult handleGameRuleSet(GameRule<@NotNull T> rule, T value, ServerLevel level, @Nullable CommandSender sender) { + final var event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent( + level.getWorld(), + sender, + CraftGameRule.minecraftToBukkit(rule), + String.valueOf(value) + ); + if (event.callEvent()) { + level.getGameRules().set(rule, value, level); + return new GameRuleSetResult<>(value, false); + } else { + return new GameRuleSetResult<>(level.getGameRules().get(rule), true); + } + } + + public record GameRuleSetResult(T value, boolean cancelled) { + + } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java index 5c13e11344e0..74ea22eb7faf 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.util; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import org.bukkit.NamespacedKey; import org.jspecify.annotations.NullMarked; @@ -21,4 +22,16 @@ public static NamespacedKey fromMinecraft(ResourceLocation minecraft) { public static ResourceLocation toMinecraft(NamespacedKey key) { return ResourceLocation.fromNamespaceAndPath(key.getNamespace(), key.getKey()); } + + public static NamespacedKey fromResourceKey(final ResourceKey key) { + return CraftNamespacedKey.fromMinecraft(key.location()); + } + + public static ResourceKey toResourceKey( + final ResourceKey> registry, + final NamespacedKey namespacedKey + ) { + return ResourceKey.create(registry, CraftNamespacedKey.toMinecraft(namespacedKey)); + } + } diff --git a/todo-snapshot.txt b/todo-snapshot.txt index 739928f1249d..bd088b010912 100644 --- a/todo-snapshot.txt +++ b/todo-snapshot.txt @@ -5,3 +5,5 @@ - 25w44a: - ShulkerBoxBlock: retainUnlootedShulkerBoxLootTableOnNonPlayerBreak patch no longer applies (getDrops override removed) - Add back array storage for game rules in GameRuleMap? + - Generate GAME_RULE in RegistryKey + - Make sure the experiemental annotations generate on game rules \ No newline at end of file From d8efc81210f38cf2ebb2d183d79bf1adbbd0f227 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Tue, 4 Nov 2025 16:39:20 -0500 Subject: [PATCH 045/112] Update to 25w44a --- .../paper/registry/keys/GameRuleKeys.java | 122 +++++++------- .../paper/registry/keys/ItemTypeKeys.java | 14 ++ .../paper/registry/keys/SoundEventKeys.java | 154 +++++++++++++++++- .../registry/keys/tags/EntityTypeTagKeys.java | 7 + .../registry/keys/tags/ItemTypeTagKeys.java | 7 + .../com/destroystokyo/paper/MaterialTags.java | 2 +- .../src/main/java/org/bukkit/GameRule.java | 2 +- .../src/main/java/org/bukkit/Material.java | 2 + paper-api/src/main/java/org/bukkit/Sound.java | 44 ++++- .../src/main/java/org/bukkit/Statistic.java | 1 + paper-api/src/main/java/org/bukkit/Tag.java | 4 + .../java/org/bukkit/entity/CamelHusk.java | 8 + .../java/org/bukkit/entity/EntityType.java | 2 + .../main/java/org/bukkit/entity/Parched.java | 8 + .../main/java/org/bukkit/entity/Skeleton.java | 6 +- .../generator/registry/RegistryEntries.java | 2 +- .../generator/types/goal/MobGoalNames.java | 2 + .../paper/entity/ai/MobGoalHelper.java | 2 + .../bukkit/craftbukkit/CraftStatistic.java | 1 + .../craftbukkit/entity/CraftCamelHusk.java | 16 ++ .../craftbukkit/entity/CraftEntityTypes.java | 4 + .../craftbukkit/entity/CraftParched.java | 23 +++ .../paper/world/TranslationKeyTest.java | 9 - .../paper/world/flag/FeatureFlagTest.java | 6 + .../test/java/org/bukkit/GameRuleTest.java | 13 -- .../bukkit/craftbukkit/legacy/LegacyTest.java | 2 +- .../provider/RegistriesArgumentProvider.java | 3 + 27 files changed, 369 insertions(+), 97 deletions(-) create mode 100644 paper-api/src/main/java/org/bukkit/entity/CamelHusk.java create mode 100644 paper-api/src/main/java/org/bukkit/entity/Parched.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCamelHusk.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java index a19519dc097d..d7f0e34d21c2 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java @@ -30,418 +30,418 @@ public final class GameRuleKeys { * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey ADVANCE_TIME = create(key("advance_time")); + public static final TypedKey> ADVANCE_TIME = create(key("advance_time")); /** * {@code minecraft:advance_weather} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey ADVANCE_WEATHER = create(key("advance_weather")); + public static final TypedKey> ADVANCE_WEATHER = create(key("advance_weather")); /** * {@code minecraft:allow_entering_nether_using_portals} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey ALLOW_ENTERING_NETHER_USING_PORTALS = create(key("allow_entering_nether_using_portals")); + public static final TypedKey> ALLOW_ENTERING_NETHER_USING_PORTALS = create(key("allow_entering_nether_using_portals")); /** * {@code minecraft:block_drops} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey BLOCK_DROPS = create(key("block_drops")); + public static final TypedKey> BLOCK_DROPS = create(key("block_drops")); /** * {@code minecraft:block_explosion_drop_decay} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey BLOCK_EXPLOSION_DROP_DECAY = create(key("block_explosion_drop_decay")); + public static final TypedKey> BLOCK_EXPLOSION_DROP_DECAY = create(key("block_explosion_drop_decay")); /** * {@code minecraft:command_block_output} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey COMMAND_BLOCK_OUTPUT = create(key("command_block_output")); + public static final TypedKey> COMMAND_BLOCK_OUTPUT = create(key("command_block_output")); /** * {@code minecraft:command_blocks_work} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey COMMAND_BLOCKS_WORK = create(key("command_blocks_work")); + public static final TypedKey> COMMAND_BLOCKS_WORK = create(key("command_blocks_work")); /** * {@code minecraft:drowning_damage} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey DROWNING_DAMAGE = create(key("drowning_damage")); + public static final TypedKey> DROWNING_DAMAGE = create(key("drowning_damage")); /** * {@code minecraft:elytra_movement_check} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey ELYTRA_MOVEMENT_CHECK = create(key("elytra_movement_check")); + public static final TypedKey> ELYTRA_MOVEMENT_CHECK = create(key("elytra_movement_check")); /** * {@code minecraft:ender_pearls_vanish_on_death} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey ENDER_PEARLS_VANISH_ON_DEATH = create(key("ender_pearls_vanish_on_death")); + public static final TypedKey> ENDER_PEARLS_VANISH_ON_DEATH = create(key("ender_pearls_vanish_on_death")); /** * {@code minecraft:entity_drops} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey ENTITY_DROPS = create(key("entity_drops")); + public static final TypedKey> ENTITY_DROPS = create(key("entity_drops")); /** * {@code minecraft:fall_damage} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey FALL_DAMAGE = create(key("fall_damage")); + public static final TypedKey> FALL_DAMAGE = create(key("fall_damage")); /** * {@code minecraft:fire_damage} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey FIRE_DAMAGE = create(key("fire_damage")); + public static final TypedKey> FIRE_DAMAGE = create(key("fire_damage")); /** * {@code minecraft:fire_spread_radius_around_player} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey FIRE_SPREAD_RADIUS_AROUND_PLAYER = create(key("fire_spread_radius_around_player")); + public static final TypedKey> FIRE_SPREAD_RADIUS_AROUND_PLAYER = create(key("fire_spread_radius_around_player")); /** * {@code minecraft:forgive_dead_players} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey FORGIVE_DEAD_PLAYERS = create(key("forgive_dead_players")); + public static final TypedKey> FORGIVE_DEAD_PLAYERS = create(key("forgive_dead_players")); /** * {@code minecraft:freeze_damage} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey FREEZE_DAMAGE = create(key("freeze_damage")); + public static final TypedKey> FREEZE_DAMAGE = create(key("freeze_damage")); /** * {@code minecraft:global_sound_events} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey GLOBAL_SOUND_EVENTS = create(key("global_sound_events")); + public static final TypedKey> GLOBAL_SOUND_EVENTS = create(key("global_sound_events")); /** * {@code minecraft:immediate_respawn} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey IMMEDIATE_RESPAWN = create(key("immediate_respawn")); + public static final TypedKey> IMMEDIATE_RESPAWN = create(key("immediate_respawn")); /** * {@code minecraft:keep_inventory} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey KEEP_INVENTORY = create(key("keep_inventory")); + public static final TypedKey> KEEP_INVENTORY = create(key("keep_inventory")); /** * {@code minecraft:lava_source_conversion} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey LAVA_SOURCE_CONVERSION = create(key("lava_source_conversion")); + public static final TypedKey> LAVA_SOURCE_CONVERSION = create(key("lava_source_conversion")); /** * {@code minecraft:limited_crafting} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey LIMITED_CRAFTING = create(key("limited_crafting")); + public static final TypedKey> LIMITED_CRAFTING = create(key("limited_crafting")); /** * {@code minecraft:locator_bar} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey LOCATOR_BAR = create(key("locator_bar")); + public static final TypedKey> LOCATOR_BAR = create(key("locator_bar")); /** * {@code minecraft:log_admin_commands} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey LOG_ADMIN_COMMANDS = create(key("log_admin_commands")); + public static final TypedKey> LOG_ADMIN_COMMANDS = create(key("log_admin_commands")); /** * {@code minecraft:max_block_modifications} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey MAX_BLOCK_MODIFICATIONS = create(key("max_block_modifications")); + public static final TypedKey> MAX_BLOCK_MODIFICATIONS = create(key("max_block_modifications")); /** * {@code minecraft:max_command_forks} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey MAX_COMMAND_FORKS = create(key("max_command_forks")); + public static final TypedKey> MAX_COMMAND_FORKS = create(key("max_command_forks")); /** * {@code minecraft:max_command_sequence_length} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey MAX_COMMAND_SEQUENCE_LENGTH = create(key("max_command_sequence_length")); + public static final TypedKey> MAX_COMMAND_SEQUENCE_LENGTH = create(key("max_command_sequence_length")); /** * {@code minecraft:max_entity_cramming} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey MAX_ENTITY_CRAMMING = create(key("max_entity_cramming")); + public static final TypedKey> MAX_ENTITY_CRAMMING = create(key("max_entity_cramming")); /** * {@code minecraft:max_minecart_speed} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey MAX_MINECART_SPEED = create(key("max_minecart_speed")); + public static final TypedKey> MAX_MINECART_SPEED = create(key("max_minecart_speed")); /** * {@code minecraft:max_snow_accumulation_height} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey MAX_SNOW_ACCUMULATION_HEIGHT = create(key("max_snow_accumulation_height")); + public static final TypedKey> MAX_SNOW_ACCUMULATION_HEIGHT = create(key("max_snow_accumulation_height")); /** * {@code minecraft:mob_drops} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey MOB_DROPS = create(key("mob_drops")); + public static final TypedKey> MOB_DROPS = create(key("mob_drops")); /** * {@code minecraft:mob_explosion_drop_decay} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey MOB_EXPLOSION_DROP_DECAY = create(key("mob_explosion_drop_decay")); + public static final TypedKey> MOB_EXPLOSION_DROP_DECAY = create(key("mob_explosion_drop_decay")); /** * {@code minecraft:mob_griefing} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey MOB_GRIEFING = create(key("mob_griefing")); + public static final TypedKey> MOB_GRIEFING = create(key("mob_griefing")); /** * {@code minecraft:natural_health_regeneration} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey NATURAL_HEALTH_REGENERATION = create(key("natural_health_regeneration")); + public static final TypedKey> NATURAL_HEALTH_REGENERATION = create(key("natural_health_regeneration")); /** * {@code minecraft:player_movement_check} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey PLAYER_MOVEMENT_CHECK = create(key("player_movement_check")); + public static final TypedKey> PLAYER_MOVEMENT_CHECK = create(key("player_movement_check")); /** * {@code minecraft:players_nether_portal_creative_delay} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = create(key("players_nether_portal_creative_delay")); + public static final TypedKey> PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = create(key("players_nether_portal_creative_delay")); /** * {@code minecraft:players_nether_portal_default_delay} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = create(key("players_nether_portal_default_delay")); + public static final TypedKey> PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = create(key("players_nether_portal_default_delay")); /** * {@code minecraft:players_sleeping_percentage} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey PLAYERS_SLEEPING_PERCENTAGE = create(key("players_sleeping_percentage")); + public static final TypedKey> PLAYERS_SLEEPING_PERCENTAGE = create(key("players_sleeping_percentage")); /** * {@code minecraft:projectiles_can_break_blocks} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey PROJECTILES_CAN_BREAK_BLOCKS = create(key("projectiles_can_break_blocks")); + public static final TypedKey> PROJECTILES_CAN_BREAK_BLOCKS = create(key("projectiles_can_break_blocks")); /** * {@code minecraft:pvp} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey PVP = create(key("pvp")); + public static final TypedKey> PVP = create(key("pvp")); /** * {@code minecraft:raids} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey RAIDS = create(key("raids")); + public static final TypedKey> RAIDS = create(key("raids")); /** * {@code minecraft:random_tick_speed} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey RANDOM_TICK_SPEED = create(key("random_tick_speed")); + public static final TypedKey> RANDOM_TICK_SPEED = create(key("random_tick_speed")); /** * {@code minecraft:reduced_debug_info} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey REDUCED_DEBUG_INFO = create(key("reduced_debug_info")); + public static final TypedKey> REDUCED_DEBUG_INFO = create(key("reduced_debug_info")); /** * {@code minecraft:respawn_radius} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey RESPAWN_RADIUS = create(key("respawn_radius")); + public static final TypedKey> RESPAWN_RADIUS = create(key("respawn_radius")); /** * {@code minecraft:send_command_feedback} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey SEND_COMMAND_FEEDBACK = create(key("send_command_feedback")); + public static final TypedKey> SEND_COMMAND_FEEDBACK = create(key("send_command_feedback")); /** * {@code minecraft:show_advancement_messages} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey SHOW_ADVANCEMENT_MESSAGES = create(key("show_advancement_messages")); + public static final TypedKey> SHOW_ADVANCEMENT_MESSAGES = create(key("show_advancement_messages")); /** * {@code minecraft:show_death_messages} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey SHOW_DEATH_MESSAGES = create(key("show_death_messages")); + public static final TypedKey> SHOW_DEATH_MESSAGES = create(key("show_death_messages")); /** * {@code minecraft:spawn_mobs} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey SPAWN_MOBS = create(key("spawn_mobs")); + public static final TypedKey> SPAWN_MOBS = create(key("spawn_mobs")); /** * {@code minecraft:spawn_monsters} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey SPAWN_MONSTERS = create(key("spawn_monsters")); + public static final TypedKey> SPAWN_MONSTERS = create(key("spawn_monsters")); /** * {@code minecraft:spawn_patrols} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey SPAWN_PATROLS = create(key("spawn_patrols")); + public static final TypedKey> SPAWN_PATROLS = create(key("spawn_patrols")); /** * {@code minecraft:spawn_phantoms} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey SPAWN_PHANTOMS = create(key("spawn_phantoms")); + public static final TypedKey> SPAWN_PHANTOMS = create(key("spawn_phantoms")); /** * {@code minecraft:spawn_wandering_traders} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey SPAWN_WANDERING_TRADERS = create(key("spawn_wandering_traders")); + public static final TypedKey> SPAWN_WANDERING_TRADERS = create(key("spawn_wandering_traders")); /** * {@code minecraft:spawn_wardens} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey SPAWN_WARDENS = create(key("spawn_wardens")); + public static final TypedKey> SPAWN_WARDENS = create(key("spawn_wardens")); /** * {@code minecraft:spawner_blocks_work} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey SPAWNER_BLOCKS_WORK = create(key("spawner_blocks_work")); + public static final TypedKey> SPAWNER_BLOCKS_WORK = create(key("spawner_blocks_work")); /** * {@code minecraft:spectators_generate_chunks} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey SPECTATORS_GENERATE_CHUNKS = create(key("spectators_generate_chunks")); + public static final TypedKey> SPECTATORS_GENERATE_CHUNKS = create(key("spectators_generate_chunks")); /** * {@code minecraft:spread_vines} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey SPREAD_VINES = create(key("spread_vines")); + public static final TypedKey> SPREAD_VINES = create(key("spread_vines")); /** * {@code minecraft:tnt_explodes} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey TNT_EXPLODES = create(key("tnt_explodes")); + public static final TypedKey> TNT_EXPLODES = create(key("tnt_explodes")); /** * {@code minecraft:tnt_explosion_drop_decay} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey TNT_EXPLOSION_DROP_DECAY = create(key("tnt_explosion_drop_decay")); + public static final TypedKey> TNT_EXPLOSION_DROP_DECAY = create(key("tnt_explosion_drop_decay")); /** * {@code minecraft:universal_anger} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey UNIVERSAL_ANGER = create(key("universal_anger")); + public static final TypedKey> UNIVERSAL_ANGER = create(key("universal_anger")); /** * {@code minecraft:water_source_conversion} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey WATER_SOURCE_CONVERSION = create(key("water_source_conversion")); + public static final TypedKey> WATER_SOURCE_CONVERSION = create(key("water_source_conversion")); private GameRuleKeys() { } - private static TypedKey create(final Key key) { - throw new UnsupportedOperationException(); + private static TypedKey> create(final Key key) { + return TypedKey.create(RegistryKey.GAME_RULE, key); } } diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java index 096a5a83730e..23d8214609d3 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java @@ -1383,6 +1383,13 @@ public final class ItemTypeKeys { */ public static final TypedKey CALIBRATED_SCULK_SENSOR = create(key("calibrated_sculk_sensor")); + /** + * {@code minecraft:camel_husk_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CAMEL_HUSK_SPAWN_EGG = create(key("camel_husk_spawn_egg")); + /** * {@code minecraft:camel_spawn_egg} * @@ -6787,6 +6794,13 @@ public final class ItemTypeKeys { */ public static final TypedKey PAPER = create(key("paper")); + /** + * {@code minecraft:parched_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PARCHED_SPAWN_EGG = create(key("parched_spawn_egg")); + /** * {@code minecraft:parrot_spawn_egg} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java index 44e34687732d..aaa7abd93bb3 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java @@ -6395,6 +6395,83 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_CAMEL_STEP_SAND = create(key("entity.camel.step_sand")); + /** + * {@code minecraft:entity.camel_husk.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_AMBIENT = create(key("entity.camel_husk.ambient")); + + /** + * {@code minecraft:entity.camel_husk.dash} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_DASH = create(key("entity.camel_husk.dash")); + + /** + * {@code minecraft:entity.camel_husk.dash_ready} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_DASH_READY = create(key("entity.camel_husk.dash_ready")); + + /** + * {@code minecraft:entity.camel_husk.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_DEATH = create(key("entity.camel_husk.death")); + + /** + * {@code minecraft:entity.camel_husk.eat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_EAT = create(key("entity.camel_husk.eat")); + + /** + * {@code minecraft:entity.camel_husk.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_HURT = create(key("entity.camel_husk.hurt")); + + /** + * {@code minecraft:entity.camel_husk.saddle} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_SADDLE = create(key("entity.camel_husk.saddle")); + + /** + * {@code minecraft:entity.camel_husk.sit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_SIT = create(key("entity.camel_husk.sit")); + + /** + * {@code minecraft:entity.camel_husk.stand} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_STAND = create(key("entity.camel_husk.stand")); + + /** + * {@code minecraft:entity.camel_husk.step} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_STEP = create(key("entity.camel_husk.step")); + + /** + * {@code minecraft:entity.camel_husk.step_sand} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_STEP_SAND = create(key("entity.camel_husk.step_sand")); + /** * {@code minecraft:entity.cat.ambient} * @@ -8684,6 +8761,34 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_PANDA_WORRIED_AMBIENT = create(key("entity.panda.worried_ambient")); + /** + * {@code minecraft:entity.parched.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARCHED_AMBIENT = create(key("entity.parched.ambient")); + + /** + * {@code minecraft:entity.parched.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARCHED_DEATH = create(key("entity.parched.death")); + + /** + * {@code minecraft:entity.parched.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARCHED_HURT = create(key("entity.parched.hurt")); + + /** + * {@code minecraft:entity.parched.step} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARCHED_STEP = create(key("entity.parched.step")); + /** * {@code minecraft:entity.parrot.ambient} * @@ -8740,6 +8845,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_PARROT_IMITATE_BREEZE = create(key("entity.parrot.imitate.breeze")); + /** + * {@code minecraft:entity.parrot.imitate.camel_husk} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARROT_IMITATE_CAMEL_HUSK = create(key("entity.parrot.imitate.camel_husk")); + /** * {@code minecraft:entity.parrot.imitate.creaking} * @@ -8831,6 +8943,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_PARROT_IMITATE_MAGMA_CUBE = create(key("entity.parrot.imitate.magma_cube")); + /** + * {@code minecraft:entity.parrot.imitate.parched} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARROT_IMITATE_PARCHED = create(key("entity.parrot.imitate.parched")); + /** * {@code minecraft:entity.parrot.imitate.phantom} * @@ -8964,6 +9083,20 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_PARROT_IMITATE_ZOMBIE = create(key("entity.parrot.imitate.zombie")); + /** + * {@code minecraft:entity.parrot.imitate.zombie_horse} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARROT_IMITATE_ZOMBIE_HORSE = create(key("entity.parrot.imitate.zombie_horse")); + + /** + * {@code minecraft:entity.parrot.imitate.zombie_nautilus} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARROT_IMITATE_ZOMBIE_NAUTILUS = create(key("entity.parrot.imitate.zombie_nautilus")); + /** * {@code minecraft:entity.parrot.imitate.zombie_villager} * @@ -11967,6 +12100,20 @@ public final class SoundEventKeys { */ public static final TypedKey ITEM_MACE_SMASH_GROUND_HEAVY = create(key("item.mace.smash_ground_heavy")); + /** + * {@code minecraft:item.nautilus_saddle_equip} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_NAUTILUS_SADDLE_EQUIP = create(key("item.nautilus_saddle_equip")); + + /** + * {@code minecraft:item.nautilus_saddle_underwater_equip} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_NAUTILUS_SADDLE_UNDERWATER_EQUIP = create(key("item.nautilus_saddle_underwater_equip")); + /** * {@code minecraft:item.nether_wart.plant} * @@ -12156,13 +12303,6 @@ public final class SoundEventKeys { */ public static final TypedKey ITEM_TRIDENT_THUNDER = create(key("item.trident.thunder")); - /** - * {@code minecraft:item.underwater_saddle.equip} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey ITEM_UNDERWATER_SADDLE_EQUIP = create(key("item.underwater_saddle.equip")); - /** * {@code minecraft:item.wolf_armor.break} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java index 97d4b0af8e66..f24cd0efc90f 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java @@ -109,6 +109,13 @@ public final class EntityTypeTagKeys { */ public static final TagKey CAN_EQUIP_SADDLE = create(key("can_equip_saddle")); + /** + * {@code #minecraft:can_float_while_ridden} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CAN_FLOAT_WHILE_RIDDEN = create(key("can_float_while_ridden")); + /** * {@code #minecraft:can_turn_in_boats} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java index 3e6ff0c0c383..40202e9e23ad 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java @@ -172,6 +172,13 @@ public final class ItemTypeTagKeys { */ public static final TagKey CAMEL_FOOD = create(key("camel_food")); + /** + * {@code #minecraft:camel_husk_food} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CAMEL_HUSK_FOOD = create(key("camel_husk_food")); + /** * {@code #minecraft:candles} * diff --git a/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java b/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java index 41f83b2e2522..e9ff88d50482 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java @@ -340,7 +340,7 @@ private static MaterialSetTag replacedBy(Tag vanillaTag, String legacy */ public static final MaterialSetTag SPAWN_EGGS = new MaterialSetTag(keyFor("spawn_eggs")) .endsWith("_SPAWN_EGG") - .ensureSize("SPAWN_EGGS", 85).lock(); + .ensureSize("SPAWN_EGGS", 87).lock(); /** * Covers all colors of stained glass. diff --git a/paper-api/src/main/java/org/bukkit/GameRule.java b/paper-api/src/main/java/org/bukkit/GameRule.java index e01a5f01dc6c..6b32388b205f 100644 --- a/paper-api/src/main/java/org/bukkit/GameRule.java +++ b/paper-api/src/main/java/org/bukkit/GameRule.java @@ -353,7 +353,7 @@ private static UnaryOperator inverseBool() { public static GameRule getByName(@NotNull String rule) { Preconditions.checkNotNull(rule, "Rule cannot be null"); try { - return (GameRule) RegistryAccess.registryAccess().getRegistry(RegistryKey.GAME_RULE).getOrThrow(NamespacedKey.minecraft(rule)); + return (GameRule) RegistryAccess.registryAccess().getRegistry(RegistryKey.GAME_RULE).getOrThrow(NamespacedKey.fromString(rule)); } catch (IllegalArgumentException | NoSuchElementException e) { return null; } diff --git a/paper-api/src/main/java/org/bukkit/Material.java b/paper-api/src/main/java/org/bukkit/Material.java index 4e1dec4828c8..8868459a28fa 100644 --- a/paper-api/src/main/java/org/bukkit/Material.java +++ b/paper-api/src/main/java/org/bukkit/Material.java @@ -205,6 +205,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla BUCKET(-1, 16), BUNDLE(-1, 1), BURN_POTTERY_SHERD(-1), + CAMEL_HUSK_SPAWN_EGG(-1), CAMEL_SPAWN_EGG(-1), CARROT(-1), CARROT_ON_A_STICK(-1, 1), @@ -484,6 +485,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla PALE_OAK_CHEST_BOAT(-1, 1), PANDA_SPAWN_EGG(-1), PAPER(-1), + PARCHED_SPAWN_EGG(-1), PARROT_SPAWN_EGG(-1), PHANTOM_MEMBRANE(-1), PHANTOM_SPAWN_EGG(-1), diff --git a/paper-api/src/main/java/org/bukkit/Sound.java b/paper-api/src/main/java/org/bukkit/Sound.java index 98af1dcf5ae4..b67cecbf538a 100644 --- a/paper-api/src/main/java/org/bukkit/Sound.java +++ b/paper-api/src/main/java/org/bukkit/Sound.java @@ -1843,6 +1843,28 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_CAMEL_STEP_SAND = getSound("entity.camel.step_sand"); + Sound ENTITY_CAMEL_HUSK_AMBIENT = getSound("entity.camel_husk.ambient"); + + Sound ENTITY_CAMEL_HUSK_DASH = getSound("entity.camel_husk.dash"); + + Sound ENTITY_CAMEL_HUSK_DASH_READY = getSound("entity.camel_husk.dash_ready"); + + Sound ENTITY_CAMEL_HUSK_DEATH = getSound("entity.camel_husk.death"); + + Sound ENTITY_CAMEL_HUSK_EAT = getSound("entity.camel_husk.eat"); + + Sound ENTITY_CAMEL_HUSK_HURT = getSound("entity.camel_husk.hurt"); + + Sound ENTITY_CAMEL_HUSK_SADDLE = getSound("entity.camel_husk.saddle"); + + Sound ENTITY_CAMEL_HUSK_SIT = getSound("entity.camel_husk.sit"); + + Sound ENTITY_CAMEL_HUSK_STAND = getSound("entity.camel_husk.stand"); + + Sound ENTITY_CAMEL_HUSK_STEP = getSound("entity.camel_husk.step"); + + Sound ENTITY_CAMEL_HUSK_STEP_SAND = getSound("entity.camel_husk.step_sand"); + Sound ENTITY_CAT_AMBIENT = getSound("entity.cat.ambient"); Sound ENTITY_CAT_BEG_FOR_FOOD = getSound("entity.cat.beg_for_food"); @@ -2497,6 +2519,14 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_PANDA_WORRIED_AMBIENT = getSound("entity.panda.worried_ambient"); + Sound ENTITY_PARCHED_AMBIENT = getSound("entity.parched.ambient"); + + Sound ENTITY_PARCHED_DEATH = getSound("entity.parched.death"); + + Sound ENTITY_PARCHED_HURT = getSound("entity.parched.hurt"); + + Sound ENTITY_PARCHED_STEP = getSound("entity.parched.step"); + Sound ENTITY_PARROT_AMBIENT = getSound("entity.parrot.ambient"); Sound ENTITY_PARROT_DEATH = getSound("entity.parrot.death"); @@ -2513,6 +2543,8 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_PARROT_IMITATE_BREEZE = getSound("entity.parrot.imitate.breeze"); + Sound ENTITY_PARROT_IMITATE_CAMEL_HUSK = getSound("entity.parrot.imitate.camel_husk"); + Sound ENTITY_PARROT_IMITATE_CREAKING = getSound("entity.parrot.imitate.creaking"); Sound ENTITY_PARROT_IMITATE_CREEPER = getSound("entity.parrot.imitate.creeper"); @@ -2539,6 +2571,8 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_PARROT_IMITATE_MAGMA_CUBE = getSound("entity.parrot.imitate.magma_cube"); + Sound ENTITY_PARROT_IMITATE_PARCHED = getSound("entity.parrot.imitate.parched"); + Sound ENTITY_PARROT_IMITATE_PHANTOM = getSound("entity.parrot.imitate.phantom"); Sound ENTITY_PARROT_IMITATE_PIGLIN = getSound("entity.parrot.imitate.piglin"); @@ -2577,6 +2611,10 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_PARROT_IMITATE_ZOMBIE = getSound("entity.parrot.imitate.zombie"); + Sound ENTITY_PARROT_IMITATE_ZOMBIE_HORSE = getSound("entity.parrot.imitate.zombie_horse"); + + Sound ENTITY_PARROT_IMITATE_ZOMBIE_NAUTILUS = getSound("entity.parrot.imitate.zombie_nautilus"); + Sound ENTITY_PARROT_IMITATE_ZOMBIE_VILLAGER = getSound("entity.parrot.imitate.zombie_villager"); Sound ENTITY_PARROT_STEP = getSound("entity.parrot.step"); @@ -3435,6 +3473,10 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ITEM_MACE_SMASH_GROUND_HEAVY = getSound("item.mace.smash_ground_heavy"); + Sound ITEM_NAUTILUS_SADDLE_EQUIP = getSound("item.nautilus_saddle_equip"); + + Sound ITEM_NAUTILUS_SADDLE_UNDERWATER_EQUIP = getSound("item.nautilus_saddle_underwater_equip"); + Sound ITEM_NETHER_WART_PLANT = getSound("item.nether_wart.plant"); Sound ITEM_OMINOUS_BOTTLE_DISPOSE = getSound("item.ominous_bottle.dispose"); @@ -3489,8 +3531,6 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ITEM_TRIDENT_THUNDER = getSound("item.trident.thunder"); - Sound ITEM_UNDERWATER_SADDLE_EQUIP = getSound("item.underwater_saddle.equip"); - Sound ITEM_WOLF_ARMOR_BREAK = getSound("item.wolf_armor.break"); Sound ITEM_WOLF_ARMOR_CRACK = getSound("item.wolf_armor.crack"); diff --git a/paper-api/src/main/java/org/bukkit/Statistic.java b/paper-api/src/main/java/org/bukkit/Statistic.java index c290406fcbe9..fc3d04da1453 100644 --- a/paper-api/src/main/java/org/bukkit/Statistic.java +++ b/paper-api/src/main/java/org/bukkit/Statistic.java @@ -55,6 +55,7 @@ public enum Statistic implements Keyed { LEAVE_GAME, MINECART_ONE_CM, MOB_KILLS, + NAUTILUS_ONE_CM, OPEN_BARREL, CHEST_OPENED, ENDERCHEST_OPENED, diff --git a/paper-api/src/main/java/org/bukkit/Tag.java b/paper-api/src/main/java/org/bukkit/Tag.java index 542082e33dbf..5fbb1ccaeb42 100644 --- a/paper-api/src/main/java/org/bukkit/Tag.java +++ b/paper-api/src/main/java/org/bukkit/Tag.java @@ -474,6 +474,8 @@ public interface Tag extends Keyed { Tag ITEMS_CAMEL_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("camel_food"), Material.class); + Tag ITEMS_CAMEL_HUSK_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("camel_husk_food"), Material.class); + Tag ITEMS_CANDLES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("candles"), Material.class); Tag ITEMS_CAT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("cat_food"), Material.class); @@ -858,6 +860,8 @@ public interface Tag extends Keyed { Tag ENTITY_TYPES_CAN_EQUIP_SADDLE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_equip_saddle"), EntityType.class); + Tag ENTITY_TYPES_CAN_FLOAT_WHILE_RIDDEN = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_float_while_ridden"), EntityType.class); + Tag ENTITY_TYPES_CAN_TURN_IN_BOATS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_turn_in_boats"), EntityType.class); Tag ENTITY_TYPES_CAN_WEAR_HORSE_ARMOR = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_wear_horse_armor"), EntityType.class); diff --git a/paper-api/src/main/java/org/bukkit/entity/CamelHusk.java b/paper-api/src/main/java/org/bukkit/entity/CamelHusk.java new file mode 100644 index 000000000000..3f1e5779d956 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/CamelHusk.java @@ -0,0 +1,8 @@ +package org.bukkit.entity; + +/** + * Represents a Camel Husk. + */ +public interface CamelHusk extends Camel { + +} diff --git a/paper-api/src/main/java/org/bukkit/entity/EntityType.java b/paper-api/src/main/java/org/bukkit/entity/EntityType.java index 0d7d6af83dc5..e84da0628407 100644 --- a/paper-api/src/main/java/org/bukkit/entity/EntityType.java +++ b/paper-api/src/main/java/org/bukkit/entity/EntityType.java @@ -66,6 +66,7 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans BREEZE("breeze", Breeze.class, -1), BREEZE_WIND_CHARGE("breeze_wind_charge", BreezeWindCharge.class, -1), CAMEL("camel", Camel.class, -1), + CAMEL_HUSK("camel_husk", CamelHusk.class, -1), CAT("cat", Cat.class, -1), CAVE_SPIDER("cave_spider", CaveSpider.class, 59), CHERRY_BOAT("cherry_boat", CherryBoat.class, -1), @@ -144,6 +145,7 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans PALE_OAK_BOAT("pale_oak_boat", PaleOakBoat.class, -1), PALE_OAK_CHEST_BOAT("pale_oak_chest_boat", PaleOakChestBoat.class, -1), PANDA("panda", Panda.class, -1), + PARCHED("parched", Parched.class, -1), PARROT("parrot", Parrot.class, 105), PHANTOM("phantom", Phantom.class, -1), PIG("pig", Pig.class, 90), diff --git a/paper-api/src/main/java/org/bukkit/entity/Parched.java b/paper-api/src/main/java/org/bukkit/entity/Parched.java new file mode 100644 index 000000000000..e7aba9f66b61 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/Parched.java @@ -0,0 +1,8 @@ +package org.bukkit.entity; + +/** + * Represents a parched Skeleton. + */ +public interface Parched extends AbstractSkeleton { + +} diff --git a/paper-api/src/main/java/org/bukkit/entity/Skeleton.java b/paper-api/src/main/java/org/bukkit/entity/Skeleton.java index 42e1f5141b8d..11051b20ac21 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Skeleton.java +++ b/paper-api/src/main/java/org/bukkit/entity/Skeleton.java @@ -74,6 +74,10 @@ public enum SkeletonType { /** * Bogged skeleton. */ - BOGGED; + BOGGED, + /** + * Parched skeleton + */ + PARCHED; } } diff --git a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java index 278eb671f4dd..409833c4e0cf 100644 --- a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java +++ b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java @@ -167,7 +167,7 @@ private static RegistryEntry inconsistentEntry(ResourceKey> DATA_DRIVEN = List.of( diff --git a/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java b/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java index a797995c1ddb..67b48abb69e4 100644 --- a/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java @@ -140,6 +140,8 @@ public final class MobGoalNames { // todo sync with MobGoalHelper ideally this s map.put(net.minecraft.world.entity.animal.nautilus.AbstractNautilus.class, org.bukkit.entity.AbstractNautilus.class); map.put(net.minecraft.world.entity.animal.nautilus.Nautilus.class, org.bukkit.entity.Nautilus.class); map.put(net.minecraft.world.entity.animal.nautilus.ZombieNautilus.class, org.bukkit.entity.ZombieNautilus.class); + map.put(net.minecraft.world.entity.animal.camel.CamelHusk.class, org.bukkit.entity.CamelHusk.class); + map.put(net.minecraft.world.entity.monster.Parched.class, org.bukkit.entity.Parched.class); // }); diff --git a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java index f4b9ee6acd3d..6f33eb70ba1f 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java @@ -138,6 +138,8 @@ public class MobGoalHelper { map.put(net.minecraft.world.entity.animal.nautilus.AbstractNautilus.class, AbstractNautilus.class); map.put(net.minecraft.world.entity.animal.nautilus.Nautilus.class, Nautilus.class); map.put(net.minecraft.world.entity.animal.nautilus.ZombieNautilus.class, ZombieNautilus.class); + map.put(net.minecraft.world.entity.animal.camel.CamelHusk.class, CamelHusk.class); + map.put(net.minecraft.world.entity.monster.Parched.class, Parched.class); // End generate - MobGoalHelper#BUKKIT_BRIDGE // }); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java index f79833051f31..dedfeacb66bd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java @@ -70,6 +70,7 @@ public enum CraftStatistic { LEAVE_GAME(Stats.LEAVE_GAME), MINECART_ONE_CM(Stats.MINECART_ONE_CM), MOB_KILLS(Stats.MOB_KILLS), + NAUTILUS_ONE_CM(Stats.NAUTILUS_ONE_CM), OPEN_BARREL(Stats.OPEN_BARREL), CHEST_OPENED(Stats.OPEN_CHEST), ENDERCHEST_OPENED(Stats.OPEN_ENDERCHEST), diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCamelHusk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCamelHusk.java new file mode 100644 index 000000000000..e0008d4708bc --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCamelHusk.java @@ -0,0 +1,16 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.world.entity.animal.camel.CamelHusk; +import net.minecraft.world.entity.animal.nautilus.ZombieNautilus; +import org.bukkit.craftbukkit.CraftServer; + +public class CraftCamelHusk extends CraftCamel implements org.bukkit.entity.CamelHusk { + public CraftCamelHusk(final CraftServer server, final CamelHusk entity) { + super(server, entity); + } + + @Override + public CamelHusk getHandle() { + return (CamelHusk) this.entity; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java index 4ed5d89576a1..0c4f859ed392 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java @@ -70,6 +70,7 @@ import org.bukkit.entity.Breeze; import org.bukkit.entity.BreezeWindCharge; import org.bukkit.entity.Camel; +import org.bukkit.entity.CamelHusk; import org.bukkit.entity.Cat; import org.bukkit.entity.CaveSpider; import org.bukkit.entity.Chicken; @@ -133,6 +134,7 @@ import org.bukkit.entity.OminousItemSpawner; import org.bukkit.entity.Painting; import org.bukkit.entity.Panda; +import org.bukkit.entity.Parched; import org.bukkit.entity.Parrot; import org.bukkit.entity.Phantom; import org.bukkit.entity.Pig; @@ -362,6 +364,8 @@ Level minecraftWorld() { register(new EntityTypeData<>(EntityType.MANNEQUIN, Mannequin.class, CraftMannequin::new, createLiving(net.minecraft.world.entity.EntityType.MANNEQUIN))); register(new EntityTypeData<>(EntityType.NAUTILUS, Nautilus.class, CraftNautilus::new, createLiving(net.minecraft.world.entity.EntityType.NAUTILUS))); register(new EntityTypeData<>(EntityType.ZOMBIE_NAUTILUS, ZombieNautilus.class, CraftZombieNautilus::new, createLiving(net.minecraft.world.entity.EntityType.ZOMBIE_NAUTILUS))); + register(new EntityTypeData<>(EntityType.CAMEL_HUSK, CamelHusk.class, CraftCamelHusk::new, createLiving(net.minecraft.world.entity.EntityType.CAMEL_HUSK))); + register(new EntityTypeData<>(EntityType.PARCHED, Parched.class, CraftParched::new, createLiving(net.minecraft.world.entity.EntityType.PARCHED))); Function dragonFunction = createLiving(net.minecraft.world.entity.EntityType.ENDER_DRAGON); register(new EntityTypeData<>(EntityType.ENDER_DRAGON, EnderDragon.class, CraftEnderDragon::new, spawnData -> { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java new file mode 100644 index 000000000000..4794f8902936 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java @@ -0,0 +1,23 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.world.entity.animal.nautilus.ZombieNautilus; +import net.minecraft.world.entity.monster.Parched; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Skeleton; +import org.jetbrains.annotations.NotNull; + +public class CraftParched extends CraftAbstractSkeleton implements org.bukkit.entity.Parched { + public CraftParched(final CraftServer server, final Parched entity) { + super(server, entity); + } + + @Override + public Parched getHandle() { + return (Parched) this.entity; + } + + @Override + public Skeleton.@NotNull SkeletonType getSkeletonType() { + return Skeleton.SkeletonType.PARCHED; + } +} diff --git a/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java b/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java index 9642618fb59f..e3b925824782 100644 --- a/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java +++ b/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java @@ -5,7 +5,6 @@ import net.minecraft.network.chat.contents.TranslatableContents; import net.minecraft.resources.ResourceKey; import net.minecraft.world.flag.FeatureFlags; -import net.minecraft.world.level.GameRules; import net.minecraft.world.level.GameType; import net.minecraft.world.level.biome.Biome; import org.bukkit.Difficulty; @@ -29,14 +28,6 @@ public void testDifficultyKeys() { } } - @Test - public void testGameruleKeys() { - final Map> gameRules = CraftWorld.getGameRulesNMS(new GameRules(FeatureFlags.REGISTRY.allFlags())); - for (GameRule rule : GameRule.values()) { - Assertions.assertEquals(gameRules.get(rule.getName()).getDescriptionId(), rule.translationKey(), rule.getName() + "'s translation doesn't match"); - } - } - @Test public void testFireworkEffectType() { for (final FireworkEffect.Type type : FireworkEffect.Type.values()) { diff --git a/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java b/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java index 2e07ff04faa5..d52a10fcbf43 100644 --- a/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java +++ b/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java @@ -9,6 +9,7 @@ import java.util.Set; import java.util.stream.Stream; import net.kyori.adventure.key.Key; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.flag.FeatureElement; @@ -82,6 +83,11 @@ void testApiImplementsFeatureDependant(final RegistryKey re static Stream> nonFeatureFilteredRegistries() { return RegistryHelper.getRegistry().registries().filter(r -> { + // TODO: Game rule does not properly support the feature flag system. + if (r.key().equals(Registries.GAME_RULE)) { + return false; + } + final RegistryEntry entry = PaperRegistries.getEntry(r.key()); // has an API registry and isn't a filtered registry return entry != null && !FeatureElement.FILTERED_REGISTRIES.contains(r.key()); diff --git a/paper-server/src/test/java/org/bukkit/GameRuleTest.java b/paper-server/src/test/java/org/bukkit/GameRuleTest.java index 7fd36402fbf6..2d0c87f6fc9d 100644 --- a/paper-server/src/test/java/org/bukkit/GameRuleTest.java +++ b/paper-server/src/test/java/org/bukkit/GameRuleTest.java @@ -3,7 +3,6 @@ import static org.junit.jupiter.api.Assertions.*; import java.util.Map; import net.minecraft.world.flag.FeatureFlags; -import net.minecraft.world.level.GameRules; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Test; @@ -22,18 +21,6 @@ public void testBukkitRules() { } } - @Test - public void testMinecraftRules() { - Map> minecraftRules = CraftWorld.getGameRulesNMS(new GameRules(FeatureFlags.REGISTRY.allFlags())); - - for (Map.Entry> entry : minecraftRules.entrySet()) { - GameRule bukkitRule = GameRule.getByName(entry.getKey()); - - assertNotNull(bukkitRule, "Missing " + entry.getKey()); - assertEquals(bukkitRule.getName(), entry.getKey(), "Invalid GameRule Name"); - } - } - @Test public void nullGameRuleName() { assertThrows(NullPointerException.class, () -> GameRule.getByName(null)); diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java index 20eb623f1e48..002ce32b2020 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java @@ -155,7 +155,7 @@ public class LegacyTest { Material.WEATHERED_COPPER_CHEST, Material.WEATHERED_COPPER_GOLEM_STATUE, Material.WEATHERED_COPPER_LANTERN, Material.WEATHERED_LIGHTNING_ROD, // 1.21.11 Material.COPPER_NAUTILUS_ARMOR, Material.COPPER_SPEAR, Material.DIAMOND_NAUTILUS_ARMOR, Material.DIAMOND_SPEAR, Material.GOLDEN_NAUTILUS_ARMOR, Material.GOLDEN_SPEAR, Material.IRON_NAUTILUS_ARMOR, Material.IRON_SPEAR, Material.NAUTILUS_SPAWN_EGG, - Material.NETHERITE_NAUTILUS_ARMOR, Material.NETHERITE_SPEAR, Material.STONE_SPEAR, Material.WOODEN_SPEAR, Material.ZOMBIE_NAUTILUS_SPAWN_EGG, + Material.NETHERITE_NAUTILUS_ARMOR, Material.NETHERITE_SPEAR, Material.STONE_SPEAR, Material.WOODEN_SPEAR, Material.ZOMBIE_NAUTILUS_SPAWN_EGG, Material.CAMEL_HUSK_SPAWN_EGG, Material.PARCHED_SPAWN_EGG, // Material.LEGACY_AIR, Material.LEGACY_DEAD_BUSH, Material.LEGACY_BURNING_FURNACE, Material.LEGACY_WALL_SIGN, Material.LEGACY_REDSTONE_TORCH_OFF, Material.LEGACY_SKULL, Material.LEGACY_REDSTONE_COMPARATOR_ON, Material.LEGACY_WALL_BANNER, Material.LEGACY_MONSTER_EGG)); diff --git a/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java b/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java index 919f13143dba..1ece467188b2 100644 --- a/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java +++ b/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java @@ -26,6 +26,7 @@ import org.bukkit.Art; import org.bukkit.Fluid; import org.bukkit.GameEvent; +import org.bukkit.GameRule; import org.bukkit.JukeboxSong; import org.bukkit.MusicInstrument; import org.bukkit.Sound; @@ -36,6 +37,7 @@ import org.bukkit.craftbukkit.CraftArt; import org.bukkit.craftbukkit.CraftFluid; import org.bukkit.craftbukkit.CraftGameEvent; +import org.bukkit.craftbukkit.CraftGameRule; import org.bukkit.craftbukkit.CraftJukeboxSong; import org.bukkit.craftbukkit.CraftMusicInstrument; import org.bukkit.craftbukkit.CraftSound; @@ -118,6 +120,7 @@ public class RegistriesArgumentProvider implements ArgumentsProvider { register(RegistryKey.COW_VARIANT, Cow.Variant.class, Registries.COW_VARIANT, CraftCow.CraftVariant.class, CowVariant.class); register(RegistryKey.PIG_VARIANT, Pig.Variant.class, Registries.PIG_VARIANT, CraftPig.CraftVariant.class, PigVariant.class); register(RegistryKey.DIALOG, Dialog.class, Registries.DIALOG, PaperDialog.class, net.minecraft.server.dialog.Dialog.class); + register(RegistryKey.GAME_RULE, GameRule.class, Registries.DIALOG, CraftGameRule.class, net.minecraft.world.level.gamerules.GameRule.class); } private static void register(RegistryKey registryKey, Class bukkit, ResourceKey registry, Class craft, Class minecraft) { // Paper From fc22a8c0c29a4890149f6a09e315a4966c914e25 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Tue, 4 Nov 2025 16:53:26 -0500 Subject: [PATCH 046/112] Fixup my todos, also registry key is not auto generated. Basically, game rule sucks rn! --- .../papermc/paper/registry/keys/GameRuleKeys.java | 4 ++++ .../java/io/papermc/paper/registry/RegistryKey.java | 6 ++++-- paper-api/src/main/java/org/bukkit/GameRule.java | 2 ++ .../types/registry/RegistryFieldRewriter.java | 13 ++++++++++++- .../generator/types/registry/GeneratedKeyType.java | 12 +++++++++++- todo-snapshot.txt | 4 +--- 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java index d7f0e34d21c2..2d619b4129ef 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java @@ -7,6 +7,8 @@ import io.papermc.paper.registry.TypedKey; import net.kyori.adventure.key.Key; import org.bukkit.GameRule; +import org.bukkit.MinecraftExperimental; +import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; /** @@ -219,6 +221,8 @@ public final class GameRuleKeys { * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ + @ApiStatus.Experimental + @MinecraftExperimental(MinecraftExperimental.Requires.MINECART_IMPROVEMENTS) public static final TypedKey> MAX_MINECART_SPEED = create(key("max_minecart_speed")); /** diff --git a/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java b/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java index 9e3b06ab5c24..8c6545a4489e 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java @@ -126,8 +126,10 @@ public sealed interface RegistryKey extends Keyed permits RegistryKeyImpl { * @see io.papermc.paper.registry.keys.DataComponentTypeKeys */ RegistryKey DATA_COMPONENT_TYPE = create("data_component_type"); - - + /** + * Data-driven registry for game rules. + * @see io.papermc.paper.registry.keys.GameRuleKeys + */ RegistryKey> GAME_RULE = create("game_rule"); /* ********************** * diff --git a/paper-api/src/main/java/org/bukkit/GameRule.java b/paper-api/src/main/java/org/bukkit/GameRule.java index 6b32388b205f..d7f3d8dbd6b2 100644 --- a/paper-api/src/main/java/org/bukkit/GameRule.java +++ b/paper-api/src/main/java/org/bukkit/GameRule.java @@ -81,6 +81,8 @@ public abstract class GameRule implements net.kyori.adventure.translation.Tra public static final GameRule MAX_ENTITY_CRAMMING = getByName("max_entity_cramming"); + @MinecraftExperimental(MinecraftExperimental.Requires.MINECART_IMPROVEMENTS) + @ApiStatus.Experimental public static final GameRule MAX_MINECART_SPEED = getByName("max_minecart_speed"); public static final GameRule MAX_SNOW_ACCUMULATION_HEIGHT = getByName("max_snow_accumulation_height"); diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java index bce5e9e254ff..5f5b98238c77 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java @@ -20,9 +20,11 @@ import java.util.function.Supplier; import net.minecraft.core.Holder; import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.world.flag.FeatureElement; import net.minecraft.world.flag.FeatureFlags; +import net.minecraft.world.level.gamerules.GameRule; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -47,7 +49,7 @@ public class RegistryFieldRewriter extends SearchReplaceRewriter { public RegistryFieldRewriter(ResourceKey> registryKey, @Nullable String fetchMethod) { this.registryEntry = RegistryEntries.byRegistryKey(registryKey); - this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(registryKey); + this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(registryKey) || registryKey.equals(Registries.GAME_RULE); // TODO: GAME RULE SUCKS - SNAPSHOT this.fetchMethod = fetchMethod; } @@ -127,6 +129,15 @@ protected String rewriteFieldValue(Holder.Reference reference) { protected @Nullable SingleFlagHolder getRequiredFeature(Holder.Reference reference) { if (this.isFilteredRegistry) { + // TODO: GAME RULE SUCKS - SNAPSHOT + if (reference.value() instanceof GameRule gameRule) { + if (FeatureFlags.isExperimental(gameRule.requiredFeatures())) { + return SingleFlagHolder.fromSet(gameRule.requiredFeatures()); + } + return null; + } + // TODO: GAME RULE SUCKS - SNAPSHOT + // built-in registry FeatureElement element = (FeatureElement) reference.value(); if (FeatureFlags.isExperimental(element.requiredFeatures())) { diff --git a/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java index 6aeb4c897911..cca0056ad4e4 100644 --- a/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java @@ -24,9 +24,11 @@ import javax.lang.model.SourceVersion; import net.kyori.adventure.key.Key; import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.world.flag.FeatureElement; import net.minecraft.world.flag.FeatureFlags; +import net.minecraft.world.level.gamerules.GameRule; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -49,7 +51,7 @@ public GeneratedKeyType(String packageName, RegistryEntry entry) { super(entry.keyClassName().concat("Keys"), packageName); this.entry = entry; this.experimentalKeys = Suppliers.memoize(() -> ExperimentalCollector.collectDataDrivenElementIds(entry.registry())); - this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(entry.registryKey()); + this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(entry.registryKey()) || entry.registryKey().equals(Registries.GAME_RULE); // TODO: GAME RULE SUCKS - SNAPSHOT } private MethodSpec.Builder createMethod(TypeName returnType) { @@ -131,6 +133,14 @@ protected JavaFile.Builder file(JavaFile.Builder builder) { protected @Nullable SingleFlagHolder getRequiredFeature(Holder.Reference reference) { if (this.isFilteredRegistry) { + // TODO: GAME RULE SUCKS - SNAPSHOT + if (reference.value() instanceof GameRule gameRule) { + if (FeatureFlags.isExperimental(gameRule.requiredFeatures())) { + return SingleFlagHolder.fromSet(gameRule.requiredFeatures()); + } + return null; + } + // TODO: GAME RULE SUCKS - SNAPSHOT // built-in registry FeatureElement element = (FeatureElement) reference.value(); if (FeatureFlags.isExperimental(element.requiredFeatures())) { diff --git a/todo-snapshot.txt b/todo-snapshot.txt index bd088b010912..dda9d1d602a7 100644 --- a/todo-snapshot.txt +++ b/todo-snapshot.txt @@ -4,6 +4,4 @@ - Connection, ServerConnectionListener - dropped diff for thread pool config (fields gone) - 25w44a: - ShulkerBoxBlock: retainUnlootedShulkerBoxLootTableOnNonPlayerBreak patch no longer applies (getDrops override removed) - - Add back array storage for game rules in GameRuleMap? - - Generate GAME_RULE in RegistryKey - - Make sure the experiemental annotations generate on game rules \ No newline at end of file + - Add back array storage for game rules in GameRuleMap? \ No newline at end of file From 9b58b6ab0f5856c15502cd644e4ee95b76266b88 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Tue, 4 Nov 2025 16:56:23 -0500 Subject: [PATCH 047/112] Fix typo --- .../org/bukkit/support/provider/RegistriesArgumentProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java b/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java index 1ece467188b2..6e18d1ff95a8 100644 --- a/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java +++ b/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java @@ -120,7 +120,7 @@ public class RegistriesArgumentProvider implements ArgumentsProvider { register(RegistryKey.COW_VARIANT, Cow.Variant.class, Registries.COW_VARIANT, CraftCow.CraftVariant.class, CowVariant.class); register(RegistryKey.PIG_VARIANT, Pig.Variant.class, Registries.PIG_VARIANT, CraftPig.CraftVariant.class, PigVariant.class); register(RegistryKey.DIALOG, Dialog.class, Registries.DIALOG, PaperDialog.class, net.minecraft.server.dialog.Dialog.class); - register(RegistryKey.GAME_RULE, GameRule.class, Registries.DIALOG, CraftGameRule.class, net.minecraft.world.level.gamerules.GameRule.class); + register(RegistryKey.GAME_RULE, GameRule.class, Registries.GAME_RULE, CraftGameRule.class, net.minecraft.world.level.gamerules.GameRule.class); } private static void register(RegistryKey registryKey, Class bukkit, ResourceKey registry, Class craft, Class minecraft) { // Paper From 10770fc2bb03689a1586fbdff235fa349b5d46e6 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 4 Nov 2025 18:06:58 -0700 Subject: [PATCH 048/112] Init 25w45a Some manual patch fixups Entity, LivingEntity, Util AbstractMinecart, Identifier ServerLevel ServerStatsCounter Player PatrolSpawner MinecraftServer 'critereon' First compile fixes Update some ATs and disable old paper commit some critereon fixes more compile fixes --- build-data/paper.at | 6 +- gradle.properties | 4 +- paper-server/build.gradle.kts | 4 +- .../mojang/serialization/Dynamic.java.patch | 4 +- .../io/papermc/paper/FeatureHooks.java.patch | 2 +- .../net/minecraft/CrashReport.java.patch | 4 +- .../LocationPredicate.java.patch | 4 +- .../SimpleCriterionTrigger.java.patch | 4 +- .../blocks/BlockStateParser.java.patch | 2 +- .../net/minecraft/core/ClientAsset.java.patch | 4 +- .../minecraft/core/MappedRegistry.java.patch | 12 +- .../core/component/DataComponents.java.patch | 4 +- .../registries/BuiltInRegistries.java.patch | 20 +- .../framework/GameTestInfo.java.patch | 2 +- .../common/custom/DiscardedPayload.java.patch | 8 +- .../ClientboundCustomQueryPacket.java.patch | 2 +- .../syncher/EntityDataSerializers.java.patch | 2 +- ...ation.java.patch => Identifier.java.patch} | 26 +-- .../resources/RegistryDataLoader.java.patch | 24 +-- .../server/MinecraftServer.java.patch | 118 +++++----- .../server/PlayerAdvancements.java.patch | 8 +- .../ReloadableServerRegistries.java.patch | 10 +- .../ServerAdvancementManager.java.patch | 16 +- .../server/ServerFunctionLibrary.java.patch | 4 +- .../bossevents/CustomBossEvent.java.patch | 2 +- .../commands/ScheduleCommand.java.patch | 4 +- .../commands/SetSpawnCommand.java.patch | 2 +- .../commands/WaypointCommand.java.patch | 2 +- .../server/level/ChunkMap.java.patch | 6 +- .../server/level/ServerLevel.java.patch | 106 ++++----- .../server/level/ServerPlayer.java.patch | 144 ++++++------- .../LoggingLevelLoadListener.java.patch | 4 +- .../ServerCommonPacketListenerImpl.java.patch | 8 +- .../ServerGamePacketListenerImpl.java.patch | 2 +- .../server/packs/PathPackResources.java.patch | 2 +- .../repository/ServerPacksSource.java.patch | 2 +- .../stats/ServerStatsCounter.java.patch | 16 +- .../net/minecraft/tags/TagLoader.java.patch | 8 +- .../net/minecraft/{ => util}/Util.java.patch | 102 ++++++++- .../minecraft/world/entity/Entity.java.patch | 204 +++++++++--------- .../world/entity/EntityType.java.patch | 9 + .../world/entity/LivingEntity.java.patch | 96 ++++----- .../net/minecraft/world/entity/Mob.java.patch | 38 ++-- .../attributes/AttributeInstance.java.patch | 2 +- .../world/entity/animal/Bee.java.patch | 20 +- .../world/entity/animal/Cat.java.patch | 10 +- .../animal/armadillo/Armadillo.java.patch | 2 +- .../animal/horse/SkeletonHorse.java.patch | 2 +- .../nautilus/AbstractNautilus.java.patch | 4 +- .../world/entity/item/PrimedTnt.java.patch | 2 +- .../world/entity/monster/Slime.java.patch | 34 +-- .../world/entity/monster/Zombie.java.patch | 6 +- .../world/entity/player/Player.java.patch | 42 ++-- .../projectile/AbstractArrow.java.patch | 2 +- .../FireworkRocketEntity.java.patch | 2 +- .../vehicle/AbstractMinecart.java.patch | 12 +- .../entity/vehicle/ContainerEntity.java.patch | 2 +- .../inventory/EnchantmentMenu.java.patch | 2 +- .../inventory/StonecutterMenu.java.patch | 6 +- .../world/item/ItemCooldowns.java.patch | 4 +- .../minecraft/world/item/MaceItem.java.patch | 4 +- .../world/item/ServerItemCooldowns.java.patch | 8 +- .../item/component/TypedEntityData.java.patch | 4 +- .../item/crafting/RecipeHolder.java.patch | 2 +- .../enchantment/ItemEnchantments.java.patch | 2 +- .../minecraft/world/level/Level.java.patch | 32 +-- .../world/level/LevelAccessor.java.patch | 2 +- .../world/level/ServerExplosion.java.patch | 128 +++++------ .../block/DaylightDetectorBlock.java.patch | 2 +- .../level/block/FlowerPotBlock.java.patch | 4 +- .../level/block/TurtleEggBlock.java.patch | 10 +- .../entity/BeehiveBlockEntity.java.patch | 39 ++-- .../ChunkGeneratorStructureState.java.patch | 4 +- .../level/gameevent/GameEvent.java.patch | 4 +- .../level/levelgen/PatrolSpawner.java.patch | 7 +- .../structures/OceanRuinPieces.java.patch | 2 +- .../storage/LevelStorageSource.java.patch | 2 +- .../storage/loot/LootDataType.java.patch | 2 +- .../level/storage/loot/LootTable.java.patch | 2 +- .../paper/entity/ai/MobGoalHelper.java | 2 +- .../destroystokyo/paper/gui/RAMDetails.java | 2 +- .../paper/profile/CraftPlayerProfile.java | 2 +- .../paper/proxy/VelocityProxy.java | 4 +- .../paper/adventure/AdventureCodecs.java | 2 +- .../paper/adventure/ChatProcessor.java | 8 +- .../paper/adventure/PaperAdventure.java | 18 +- .../providers/ClickCallbackProviderImpl.java | 8 +- .../io/papermc/paper/command/CommandUtil.java | 4 +- .../papermc/paper/command/PaperCommand.java | 2 +- .../argument/VanillaArgumentProviderImpl.java | 12 +- .../command/subcommands/DumpItemCommand.java | 4 +- .../command/subcommands/EntityCommand.java | 14 +- .../paper/configuration/Configurations.java | 6 +- .../configuration/GlobalConfiguration.java | 4 +- .../configuration/PaperConfigurations.java | 10 +- .../configuration/WorldConfiguration.java | 8 +- .../serializer/IdentifierSerializer.java | 27 +++ .../ResourceLocationSerializer.java | 27 --- .../ServerboundPacketClassSerializer.java | 10 +- .../registry/RegistryEntrySerializer.java | 10 +- .../registry/RegistryValueSerializer.java | 2 +- .../global/versioned/V30_PacketIds.java | 8 +- .../world/FeatureSeedsGeneration.java | 6 +- .../world/LegacyPaperWorldConfig.java | 8 +- .../PaperPlayerConfigurationConnection.java | 4 +- .../ReadablePlayerCookieConnectionImpl.java | 8 +- .../datacomponent/item/PaperEquippable.java | 4 +- .../item/PaperItemAdventurePredicate.java | 6 +- .../item/PaperSeededContainerLoot.java | 2 +- .../datacomponent/item/PaperUseCooldown.java | 4 +- .../paper/registry/PaperRegistries.java | 2 +- .../PaperRegistryListenerManager.java | 14 +- .../data/PaperBannerPatternRegistryEntry.java | 4 +- .../PaperPaintingVariantRegistryEntry.java | 4 +- .../data/PaperSoundEventRegistryEntry.java | 4 +- .../data/dialog/PaperDialogCodecs.java | 10 +- .../registry/set/NamedRegistryKeySetImpl.java | 4 +- .../tag/PaperPostFlattenTagRegistrar.java | 16 +- .../tag/PaperPreFlattenTagRegistrar.java | 12 +- .../paper/tag/PaperTagListenerManager.java | 12 +- .../io/papermc/paper/tag/TagEventConfig.java | 6 +- .../io/papermc/paper/util/Holderable.java | 2 +- .../papermc/paper/util/OldEnumHolderable.java | 6 +- .../paper/util/ServerWorkerThread.java | 2 +- .../sanitizer/ItemComponentSanitizer.java | 2 +- .../sanitizer/ItemObfuscationBinding.java | 8 +- .../papermc/paper/world/PaperWorldLoader.java | 2 +- .../PaperCombatTrackerWrapper.java | 2 +- .../OptionallyFlatBedrockConditionSource.java | 8 +- .../craftbukkit/CraftEquipmentSlot.java | 2 +- .../bukkit/craftbukkit/CraftLootTable.java | 6 +- .../org/bukkit/craftbukkit/CraftParticle.java | 2 +- .../craftbukkit/CraftRegionAccessor.java | 2 +- .../org/bukkit/craftbukkit/CraftRegistry.java | 4 +- .../org/bukkit/craftbukkit/CraftServer.java | 6 +- .../bukkit/craftbukkit/CraftStatistic.java | 32 +-- .../org/bukkit/craftbukkit/CraftWorld.java | 12 +- .../bukkit/craftbukkit/block/CraftBeacon.java | 6 +- .../craftbukkit/block/CraftContainer.java | 6 +- .../craftbukkit/block/CraftFurnace.java | 2 +- .../bukkit/craftbukkit/block/CraftSkull.java | 6 +- .../block/data/CraftBlockData.java | 2 +- .../ConfigSerializationUtil.java | 8 +- .../enchantments/CraftEnchantment.java | 4 +- .../craftbukkit/entity/CraftEntityType.java | 2 +- .../craftbukkit/entity/CraftHumanEntity.java | 4 +- .../craftbukkit/entity/CraftPlayer.java | 16 +- .../entity/memory/CraftMemoryKey.java | 2 +- .../craftbukkit/event/CraftEventFactory.java | 2 +- .../inventory/CraftItemFactory.java | 4 +- .../craftbukkit/inventory/CraftItemStack.java | 6 +- .../inventory/CraftMetaCompass.java | 6 +- .../craftbukkit/inventory/CraftMetaItem.java | 36 ++-- .../inventory/CraftMetaKnowledgeBook.java | 2 +- .../craftbukkit/inventory/CraftMetaSkull.java | 10 +- .../components/CraftEquippableComponent.java | 8 +- .../components/CraftJukeboxComponent.java | 6 +- .../components/CraftUseCooldownComponent.java | 4 +- .../craftbukkit/legacy/CraftLegacy.java | 6 +- .../craftbukkit/map/CraftMapColorCache.java | 2 +- .../craftbukkit/potion/CraftPotionType.java | 2 +- .../profile/CraftPlayerProfile.java | 2 +- .../structure/CraftStructureManager.java | 20 +- .../craftbukkit/util/CraftMagicNumbers.java | 8 +- .../craftbukkit/util/CraftNamespacedKey.java | 12 +- .../util/DelegatedGeneratorAccess.java | 21 -- .../main/java/org/spigotmc/SpigotConfig.java | 6 +- .../paper/adventure/AdventureCodecsTest.java | 6 +- .../block/CraftBlockDataDestroySpeedTest.java | 2 +- .../datacomponent/DataComponentTypesTest.java | 26 +-- .../paper/registry/RegistryKeyTest.java | 4 +- .../paper/world/flag/FeatureFlagTest.java | 10 +- .../structure/StructureSeedConfigTest.java | 4 +- .../test/java/org/bukkit/MaterialTest.java | 6 +- .../test/java/org/bukkit/ParticleTest.java | 4 +- .../java/org/bukkit/PotionEffectTypeTest.java | 4 +- .../profile/PlayerProfileTest.java | 2 +- .../java/org/bukkit/potion/PotionTest.java | 4 +- .../bukkit/registry/RegistryClassTest.java | 6 +- .../registry/RegistryConstantsTest.java | 6 +- .../registry/RegistryLoadOrderTest.java | 8 +- .../org/bukkit/support/DummyServerHelper.java | 2 +- todo-snapshot.txt | 4 +- 183 files changed, 1140 insertions(+), 1066 deletions(-) rename paper-server/patches/sources/net/minecraft/advancements/{critereon => criterion}/LocationPredicate.java.patch (85%) rename paper-server/patches/sources/net/minecraft/advancements/{critereon => criterion}/SimpleCriterionTrigger.java.patch (96%) rename paper-server/patches/sources/net/minecraft/resources/{ResourceLocation.java.patch => Identifier.java.patch} (50%) rename paper-server/patches/sources/net/minecraft/{ => util}/Util.java.patch (68%) create mode 100644 paper-server/src/main/java/io/papermc/paper/configuration/serializer/IdentifierSerializer.java delete mode 100644 paper-server/src/main/java/io/papermc/paper/configuration/serializer/ResourceLocationSerializer.java diff --git a/build-data/paper.at b/build-data/paper.at index 82fbb1f3d8f7..6cbad38188ad 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -9,7 +9,6 @@ private-f net.minecraft.world.level.block.entity.BeehiveBlockEntity stored protected net.minecraft.world.entity.LivingEntity skipDropExperience protected-f net.minecraft.server.MinecraftServer worldData public net.minecraft.ChatFormatting code -public net.minecraft.Util onThreadException(Ljava/lang/Thread;Ljava/lang/Throwable;)V public net.minecraft.advancements.Advancement decorateName(Lnet/minecraft/advancements/DisplayInfo;)Lnet/minecraft/network/chat/Component; public net.minecraft.commands.CommandSourceStack source public net.minecraft.commands.arguments.DimensionArgument ERROR_INVALID_VALUE @@ -120,6 +119,7 @@ public net.minecraft.stats.ServerRecipeBook known public net.minecraft.tags.TagEntry id public net.minecraft.tags.TagEntry required public net.minecraft.tags.TagEntry tag +public net.minecraft.util.Util onThreadException(Ljava/lang/Thread;Ljava/lang/Throwable;)V public net.minecraft.util.datafix.fixes.BlockStateData register(ILcom/mojang/serialization/Dynamic;[Lcom/mojang/serialization/Dynamic;)V public net.minecraft.util.datafix.fixes.ItemIdFix ITEM_NAMES public net.minecraft.util.datafix.fixes.ItemSpawnEggFix ID_TO_ENTITY @@ -739,8 +739,8 @@ public net.minecraft.world.level.levelgen.structure.placement.StructurePlacement public net.minecraft.world.level.levelgen.structure.placement.StructurePlacement salt public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate entityInfoList public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate palettes -public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager loadFromGenerated(Lnet/minecraft/resources/ResourceLocation;)Ljava/util/Optional; -public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager loadFromResource(Lnet/minecraft/resources/ResourceLocation;)Ljava/util/Optional; +public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager loadFromGenerated(Lnet/minecraft/resources/Identifier;)Ljava/util/Optional; +public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager loadFromResource(Lnet/minecraft/resources/Identifier;)Ljava/util/Optional; public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager readStructure(Ljava/io/InputStream;)Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate; public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager structureRepository public net.minecraft.world.level.material.MapColor MATERIAL_COLORS diff --git a/gradle.properties b/gradle.properties index b16462300185..5610727339b4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group=io.papermc.paper -version=25w44a-R0.1-SNAPSHOT -mcVersion=25w44a +version=25w45a-R0.1-SNAPSHOT +mcVersion=25w45a # This is the current API version for use in (paper-)plugin.yml files # During snapshot cycles this should be the anticipated version of the release target apiVersion=1.21.11 diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index bb47232fb24d..e0a3b241b0d9 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:25w44a+build.2") + mache("io.papermc:mache:25w45a+build.5") paperclip("io.papermc:paperclip:3.0.3") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } @@ -42,7 +42,7 @@ paperweight { ) updatingMinecraft { - // oldPaperCommit = "1eb13b0290e7617407e6bde0e59570ebde61d2ed" + // oldPaperCommit = "9b58b6ab0f5856c15502cd644e4ee95b76266b88" } } diff --git a/paper-server/patches/sources/com/mojang/serialization/Dynamic.java.patch b/paper-server/patches/sources/com/mojang/serialization/Dynamic.java.patch index 98fe6924975c..5af9881635a4 100644 --- a/paper-server/patches/sources/com/mojang/serialization/Dynamic.java.patch +++ b/paper-server/patches/sources/com/mojang/serialization/Dynamic.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/serialization/Dynamic.java +++ b/com/mojang/serialization/Dynamic.java -@@ -19,6 +_,7 @@ +@@ -20,6 +_,7 @@ @SuppressWarnings("unused") public class Dynamic extends DynamicLike { @@ -8,7 +8,7 @@ private final T value; public Dynamic(final DynamicOps ops) { -@@ -120,7 +_,7 @@ +@@ -121,7 +_,7 @@ return new OptionalDynamic<>(ops, ops.getMap(value).flatMap(m -> { final T value = m.get(key); if (value == null) { diff --git a/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch b/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch index b0f903228bdb..8d94e6c9e93a 100644 --- a/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch +++ b/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch @@ -228,7 +228,7 @@ + } + + public static java.util.concurrent.Executor getWorldgenExecutor() { -+ return net.minecraft.Util.backgroundExecutor(); ++ return net.minecraft.util.Util.backgroundExecutor(); + } + + public static void setViewDistance(ServerPlayer player, int distance) { diff --git a/paper-server/patches/sources/net/minecraft/CrashReport.java.patch b/paper-server/patches/sources/net/minecraft/CrashReport.java.patch index 9ac4c79d30ac..9166f45ad73a 100644 --- a/paper-server/patches/sources/net/minecraft/CrashReport.java.patch +++ b/paper-server/patches/sources/net/minecraft/CrashReport.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/CrashReport.java +++ b/net/minecraft/CrashReport.java -@@ -31,8 +_,10 @@ +@@ -32,8 +_,10 @@ private final SystemReport systemReport = new SystemReport(); public CrashReport(String title, Throwable exception) { @@ -11,7 +11,7 @@ } public String getTitle() { -@@ -216,7 +_,7 @@ +@@ -217,7 +_,7 @@ } public static void preload() { diff --git a/paper-server/patches/sources/net/minecraft/advancements/critereon/LocationPredicate.java.patch b/paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch similarity index 85% rename from paper-server/patches/sources/net/minecraft/advancements/critereon/LocationPredicate.java.patch rename to paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch index e43dabe61746..d559a186341d 100644 --- a/paper-server/patches/sources/net/minecraft/advancements/critereon/LocationPredicate.java.patch +++ b/paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/advancements/critereon/LocationPredicate.java -+++ b/net/minecraft/advancements/critereon/LocationPredicate.java +--- a/net/minecraft/advancements/criterion/LocationPredicate.java ++++ b/net/minecraft/advancements/criterion/LocationPredicate.java @@ -44,7 +_,7 @@ public boolean matches(ServerLevel level, double x, double y, double z) { if (this.position.isPresent() && !this.position.get().matches(x, y, z)) { diff --git a/paper-server/patches/sources/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java.patch b/paper-server/patches/sources/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java.patch similarity index 96% rename from paper-server/patches/sources/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java.patch rename to paper-server/patches/sources/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java.patch index c4d763988944..8764e1c98d7a 100644 --- a/paper-server/patches/sources/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java.patch +++ b/paper-server/patches/sources/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java -+++ b/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java +--- a/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java ++++ b/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java @@ -15,41 +_,41 @@ import net.minecraft.world.level.storage.loot.LootContext; diff --git a/paper-server/patches/sources/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch b/paper-server/patches/sources/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch index 6b9c60c09010..4a39a4919f11 100644 --- a/paper-server/patches/sources/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch @@ -7,5 +7,5 @@ - private final Map, Comparable> properties = Maps.newHashMap(); + private final Map, Comparable> properties = Maps.newLinkedHashMap(); // CraftBukkit - stable private final Map vagueProperties = Maps.newHashMap(); - private ResourceLocation id = ResourceLocation.withDefaultNamespace(""); + private Identifier id = Identifier.withDefaultNamespace(""); private @Nullable StateDefinition definition; diff --git a/paper-server/patches/sources/net/minecraft/core/ClientAsset.java.patch b/paper-server/patches/sources/net/minecraft/core/ClientAsset.java.patch index 9c9c783ebd0c..9567a6a67952 100644 --- a/paper-server/patches/sources/net/minecraft/core/ClientAsset.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/ClientAsset.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/core/ClientAsset.java +++ b/net/minecraft/core/ClientAsset.java -@@ -24,7 +_,7 @@ +@@ -23,7 +_,7 @@ .map(ClientAsset.ResourceTexture::new, ClientAsset.ResourceTexture::id); - public ResourceTexture(ResourceLocation id) { + public ResourceTexture(Identifier id) { - this(id, id.withPath(path -> "textures/" + path + ".png")); + this(id, id.withPath(path -> "textures/" + path + ".png")); // Paper - diff on change - io.papermc.paper.registry.data.client.ClientAssetImpl#pathFromIdentifier } diff --git a/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch b/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch index 37e67005c52c..1c658944e836 100644 --- a/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch @@ -5,12 +5,12 @@ private final ResourceKey> key; private final ObjectList> byId = new ObjectArrayList<>(256); - private final Reference2IntMap toId = Util.make(new Reference2IntOpenHashMap<>(), map -> map.defaultReturnValue(-1)); -- private final Map> byLocation = new HashMap<>(); +- private final Map> byLocation = new HashMap<>(); - private final Map, Holder.Reference> byKey = new HashMap<>(); - private final Map> byValue = new IdentityHashMap<>(); - private final Map, RegistrationInfo> registrationInfos = new IdentityHashMap<>(); + private final Reference2IntMap toId = Util.make(new Reference2IntOpenHashMap<>(2048), map -> map.defaultReturnValue(-1)); // Paper - Perf: Use bigger expected size to reduce collisions -+ private final Map> byLocation = new HashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions ++ private final Map> byLocation = new HashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions + private final Map, Holder.Reference> byKey = new HashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions + private final Map> byValue = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions + private final Map, RegistrationInfo> registrationInfos = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions @@ -20,11 +20,11 @@ private boolean frozen; private @Nullable Map> unregisteredIntrusiveHolders; + // Paper start - support pre-filling in registry mod API -+ private final Map temporaryUnfrozenMap = new HashMap<>(); ++ private final Map temporaryUnfrozenMap = new HashMap<>(); + + @Override + public Optional getValueForCopying(final ResourceKey resourceKey) { -+ return this.frozen ? this.getOptional(resourceKey) : Optional.ofNullable(this.temporaryUnfrozenMap.get(resourceKey.location())); ++ return this.frozen ? this.getOptional(resourceKey) : Optional.ofNullable(this.temporaryUnfrozenMap.get(resourceKey.identifier())); + } + // Paper end - support pre-filling in registry mod API @@ -34,7 +34,7 @@ this.toId.put(value, size); this.registrationInfos.put(key, registrationInfo); this.registryLifecycle = this.registryLifecycle.add(registrationInfo.lifecycle()); -+ this.temporaryUnfrozenMap.put(key.location(), value); // Paper - support pre-filling in registry mod API ++ this.temporaryUnfrozenMap.put(key.identifier(), value); // Paper - support pre-filling in registry mod API return reference; } } @@ -44,7 +44,7 @@ this.frozen = true; + this.temporaryUnfrozenMap.clear(); // Paper - support pre-filling in registry mod API this.byValue.forEach((object, reference) -> reference.bindValue((T)object)); - List list = this.byKey + List list = this.byKey .entrySet() @@ -502,4 +_,13 @@ diff --git a/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch b/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch index b46c42cbc965..90983e700e4a 100644 --- a/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/component/DataComponents.java +++ b/net/minecraft/core/component/DataComponents.java -@@ -231,10 +_,10 @@ +@@ -232,10 +_,10 @@ "map_post_processing", builder -> builder.networkSynchronized(MapPostProcessing.STREAM_CODEC) ); public static final DataComponentType CHARGED_PROJECTILES = register( @@ -13,7 +13,7 @@ ); public static final DataComponentType POTION_CONTENTS = register( "potion_contents", builder -> builder.persistent(PotionContents.CODEC).networkSynchronized(PotionContents.STREAM_CODEC).cacheEncoding() -@@ -317,7 +_,7 @@ +@@ -318,7 +_,7 @@ "pot_decorations", builder -> builder.persistent(PotDecorations.CODEC).networkSynchronized(PotDecorations.STREAM_CODEC).cacheEncoding() ); public static final DataComponentType CONTAINER = register( diff --git a/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch b/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch index 253ebe5b2fdf..83c57bdfd6a3 100644 --- a/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/registries/BuiltInRegistries.java +++ b/net/minecraft/core/registries/BuiltInRegistries.java -@@ -358,6 +_,11 @@ +@@ -356,6 +_,11 @@ public static final Registry> SLOT_SOURCE_TYPE = registerSimple(Registries.SLOT_SOURCE_TYPE, SlotSources::bootstrap); public static final Registry> TEST_FUNCTION = registerSimple(Registries.TEST_FUNCTION, BuiltinTestFunctions::bootstrap); public static final Registry> REGISTRY = WRITABLE_REGISTRY; @@ -12,15 +12,15 @@ private static Registry registerSimple(ResourceKey> registryKey, BuiltInRegistries.RegistryBootstrap bootstrap) { return internalRegister(registryKey, new MappedRegistry<>(registryKey, Lifecycle.stable(), false), bootstrap); -@@ -385,6 +_,7 @@ +@@ -383,6 +_,7 @@ ResourceKey> registryKey, R registry, BuiltInRegistries.RegistryBootstrap bootstrap ) { - Bootstrap.checkBootstrapCalled(() -> "registry " + registryKey.location()); + Bootstrap.checkBootstrapCalled(() -> "registry " + registryKey.identifier()); + io.papermc.paper.registry.PaperRegistryAccess.instance().registerRegistry(registry); // Paper - initialize API registry - ResourceLocation resourceLocation = registryKey.location(); - LOADERS.put(resourceLocation, () -> bootstrap.run(registry)); + Identifier identifier = registryKey.identifier(); + LOADERS.put(identifier, () -> bootstrap.run(registry)); WRITABLE_REGISTRY.register((ResourceKey)registryKey, registry, RegistrationInfo.BUILT_IN); -@@ -392,16 +_,34 @@ +@@ -390,16 +_,34 @@ } public static void bootStrap() { @@ -47,15 +47,15 @@ + throw new RuntimeException(ex); + } + // Paper end - class-load org.bukkit.Registry - LOADERS.forEach((resourceLocation, supplier) -> { + LOADERS.forEach((identifier, supplier) -> { if (supplier.get() == null) { - LOGGER.error("Unable to bootstrap registry '{}'", resourceLocation); + LOGGER.error("Unable to bootstrap registry '{}'", identifier); } -+ io.papermc.paper.registry.PaperRegistryAccess.instance().lockReferenceHolders(ResourceKey.createRegistryKey(resourceLocation)); // Paper - lock reference holder creation ++ io.papermc.paper.registry.PaperRegistryAccess.instance().lockReferenceHolders(ResourceKey.createRegistryKey(identifier)); // Paper - lock reference holder creation }); } -@@ -410,6 +_,7 @@ +@@ -408,6 +_,7 @@ for (Registry registry : REGISTRY) { bindBootstrappedTagsToEmpty(registry); diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch index 35ce20da5340..b41f4ca1b28a 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestInfo.java +++ b/net/minecraft/gametest/framework/GameTestInfo.java -@@ -243,7 +_,7 @@ +@@ -244,7 +_,7 @@ AABB structureBounds = this.getStructureBounds(); List entitiesOfClass = this.getLevel() .getEntitiesOfClass(Entity.class, structureBounds.inflate(1.0), entity -> !(entity instanceof Player)); diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/common/custom/DiscardedPayload.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/common/custom/DiscardedPayload.java.patch index d0e27d1590aa..59f5e69f5568 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/common/custom/DiscardedPayload.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/common/custom/DiscardedPayload.java.patch @@ -2,11 +2,11 @@ +++ b/net/minecraft/network/protocol/common/custom/DiscardedPayload.java @@ -4,13 +_,19 @@ import net.minecraft.network.codec.StreamCodec; - import net.minecraft.resources.ResourceLocation; + import net.minecraft.resources.Identifier; --public record DiscardedPayload(ResourceLocation id) implements CustomPacketPayload { -+public record DiscardedPayload(ResourceLocation id, byte[] data) implements CustomPacketPayload { // Paper - store data - public static StreamCodec codec(ResourceLocation id, int maxSize) { +-public record DiscardedPayload(Identifier id) implements CustomPacketPayload { ++public record DiscardedPayload(Identifier id, byte[] data) implements CustomPacketPayload { // Paper - store data + public static StreamCodec codec(Identifier id, int maxSize) { - return CustomPacketPayload.codec((value, output) -> {}, buffer -> { + return CustomPacketPayload.codec((value, output) -> { + // Paper start diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch index e1eb0709fe12..d8ce01b3e11d 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch @@ -6,7 +6,7 @@ } + + // Paper start - MC Utils - default query payloads -+ public static record PlayerInfoChannelPayload(ResourceLocation id, FriendlyByteBuf buffer) implements CustomQueryPayload { ++ public static record PlayerInfoChannelPayload(Identifier id, FriendlyByteBuf buffer) implements CustomQueryPayload { + @Override + public void write(final FriendlyByteBuf buf) { + buf.writeBytes(this.buffer.copy()); diff --git a/paper-server/patches/sources/net/minecraft/network/syncher/EntityDataSerializers.java.patch b/paper-server/patches/sources/net/minecraft/network/syncher/EntityDataSerializers.java.patch index aa852751be21..24afdbddedb8 100644 --- a/paper-server/patches/sources/net/minecraft/network/syncher/EntityDataSerializers.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/syncher/EntityDataSerializers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/syncher/EntityDataSerializers.java +++ b/net/minecraft/network/syncher/EntityDataSerializers.java -@@ -53,10 +_,27 @@ +@@ -55,10 +_,27 @@ public static final EntityDataSerializer> OPTIONAL_COMPONENT = EntityDataSerializer.forValueType( ComponentSerialization.TRUSTED_OPTIONAL_STREAM_CODEC ); diff --git a/paper-server/patches/sources/net/minecraft/resources/ResourceLocation.java.patch b/paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch similarity index 50% rename from paper-server/patches/sources/net/minecraft/resources/ResourceLocation.java.patch rename to paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch index 5340cbd25c30..23ea05ccf452 100644 --- a/paper-server/patches/sources/net/minecraft/resources/ResourceLocation.java.patch +++ b/paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/resources/ResourceLocation.java -+++ b/net/minecraft/resources/ResourceLocation.java -@@ -23,6 +_,7 @@ +--- a/net/minecraft/resources/Identifier.java ++++ b/net/minecraft/resources/Identifier.java +@@ -20,6 +_,7 @@ public static final char NAMESPACE_SEPARATOR = ':'; public static final String DEFAULT_NAMESPACE = "minecraft"; public static final String REALMS_NAMESPACE = "realms"; @@ -8,35 +8,35 @@ private final String namespace; private final String path; -@@ -31,6 +_,13 @@ +@@ -28,6 +_,13 @@ assert isValidPath(path); -+ // Paper start - Validate ResourceLocation ++ // Paper start - Validate Identifier + // Check for the max network string length (capped at Short.MAX_VALUE) as well as the max bytes of a StringTag (length written as an unsigned short) + final String resourceLocation = namespace + ":" + path; + if (resourceLocation.length() > Short.MAX_VALUE || io.netty.buffer.ByteBufUtil.utf8MaxBytes(resourceLocation) > 2 * Short.MAX_VALUE + 1) { -+ throw new ResourceLocationException("Resource location too long: " + resourceLocation); ++ throw new IdentifierException("Resource location too long: " + resourceLocation); + } -+ // Paper end - Validate ResourceLocation ++ // Paper end - Validate Identifier this.namespace = namespace; this.path = path; } -@@ -244,7 +_,7 @@ +@@ -238,7 +_,7 @@ private static String assertValidNamespace(String namespace, String path) { if (!isValidNamespace(namespace)) { -- throw new ResourceLocationException("Non [a-z0-9_.-] character in namespace of location: " + namespace + ":" + path); -+ throw new ResourceLocationException("Non [a-z0-9_.-] character in namespace of location: " + org.apache.commons.lang3.StringUtils.normalizeSpace(namespace) + ":" + org.apache.commons.lang3.StringUtils.normalizeSpace(path)); // Paper - Sanitize ResourceLocation error logging +- throw new IdentifierException("Non [a-z0-9_.-] character in namespace of location: " + namespace + ":" + path); ++ throw new IdentifierException("Non [a-z0-9_.-] character in namespace of location: " + org.apache.commons.lang3.StringUtils.normalizeSpace(namespace) + ":" + org.apache.commons.lang3.StringUtils.normalizeSpace(path)); // Paper - Sanitize Identifier error logging } else { return namespace; } -@@ -269,7 +_,7 @@ +@@ -263,7 +_,7 @@ private static String assertValidPath(String namespace, String path) { if (!isValidPath(path)) { -- throw new ResourceLocationException("Non [a-z0-9/._-] character in path of location: " + namespace + ":" + path); -+ throw new ResourceLocationException("Non [a-z0-9/._-] character in path of location: " + namespace + ":" + org.apache.commons.lang3.StringUtils.normalizeSpace(path)); // Paper - Sanitize ResourceLocation error logging +- throw new IdentifierException("Non [a-z0-9/._-] character in path of location: " + namespace + ":" + path); ++ throw new IdentifierException("Non [a-z0-9/._-] character in path of location: " + namespace + ":" + org.apache.commons.lang3.StringUtils.normalizeSpace(path)); // Paper - Sanitize Identifier error logging } else { return path; } diff --git a/paper-server/patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch b/paper-server/patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch index 3f52e9a7fc62..5776d719e9a2 100644 --- a/paper-server/patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch +++ b/paper-server/patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/resources/RegistryDataLoader.java +++ b/net/minecraft/resources/RegistryDataLoader.java -@@ -206,11 +_,21 @@ +@@ -212,11 +_,21 @@ final Map>, RegistryOps.RegistryInfo> map = new HashMap<>(); registryLookups.forEach(registryLookup -> map.put(registryLookup.key(), createInfoForContextRegistry((HolderLookup.RegistryLookup)registryLookup))); loaders.forEach(loader -> map.put(loader.registry.key(), createInfoForNewRegistry(loader.registry))); @@ -22,7 +22,7 @@ }; } -@@ -274,13 +_,14 @@ +@@ -280,13 +_,14 @@ RegistryOps ops, ResourceKey resourceKey, Resource resource, @@ -39,15 +39,15 @@ } } -@@ -294,6 +_,7 @@ +@@ -300,6 +_,7 @@ FileToIdConverter fileToIdConverter = FileToIdConverter.registry(registry.key()); RegistryOps registryOps = RegistryOps.create(JsonOps.INSTANCE, registryInfoLookup); + final io.papermc.paper.registry.data.util.Conversions conversions = new io.papermc.paper.registry.data.util.Conversions(registryInfoLookup); // Paper - create conversions - for (Entry entry : fileToIdConverter.listMatchingResources(resourceManager).entrySet()) { - ResourceLocation resourceLocation = entry.getKey(); - ResourceKey resourceKey = ResourceKey.create(registry.key(), fileToIdConverter.fileToId(resourceLocation)); -@@ -301,7 +_,7 @@ + for (Entry entry : fileToIdConverter.listMatchingResources(resourceManager).entrySet()) { + Identifier identifier = entry.getKey(); + ResourceKey resourceKey = ResourceKey.create(registry.key(), fileToIdConverter.fileToId(identifier)); +@@ -307,7 +_,7 @@ RegistrationInfo registrationInfo = REGISTRATION_INFO_CACHE.apply(resource.knownPackInfo()); try { @@ -56,7 +56,7 @@ } catch (Exception var14) { loadingErrors.put( resourceKey, -@@ -310,7 +_,9 @@ +@@ -316,7 +_,9 @@ } } @@ -67,7 +67,7 @@ } static void loadContentsFromNetwork( -@@ -327,6 +_,7 @@ +@@ -333,6 +_,7 @@ RegistryOps registryOps1 = RegistryOps.create(JsonOps.INSTANCE, registryInfoLookup); FileToIdConverter fileToIdConverter = FileToIdConverter.registry(registry.key()); @@ -75,16 +75,16 @@ for (RegistrySynchronization.PackedRegistryEntry packedRegistryEntry : networkedRegistryData.elements) { ResourceKey resourceKey = ResourceKey.create(registry.key(), packedRegistryEntry.id()); Optional optional = packedRegistryEntry.data(); -@@ -345,7 +_,7 @@ +@@ -351,7 +_,7 @@ try { - Resource resourceOrThrow = resourceProvider.getResourceOrThrow(resourceLocation); + Resource resourceOrThrow = resourceProvider.getResourceOrThrow(identifier); - loadElementFromResource(registry, codec, registryOps1, resourceKey, resourceOrThrow, NETWORK_REGISTRATION_INFO); + loadElementFromResource(registry, codec, registryOps1, resourceKey, resourceOrThrow, NETWORK_REGISTRATION_INFO, conversions); // Paper - pass conversions } catch (Exception var17) { loadingErrors.put(resourceKey, new IllegalStateException("Failed to parse local data", var17)); } -@@ -387,6 +_,7 @@ +@@ -393,6 +_,7 @@ RegistryDataLoader.Loader create(Lifecycle registryLifecycle, Map, Exception> loadingErrors) { WritableRegistry writableRegistry = new MappedRegistry<>(this.key, registryLifecycle); diff --git a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch index 8e74bbbe7d1c..8f1620e87977 100644 --- a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -188,11 +_,13 @@ +@@ -185,11 +_,13 @@ import org.slf4j.Logger; public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ServerInfo, CommandSource, ChunkIOErrorReporter { @@ -15,7 +15,7 @@ private static final int OVERLOADED_TICKS_THRESHOLD = 20; private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeUtil.NANOSECONDS_PER_SECOND; private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100; -@@ -219,7 +_,7 @@ +@@ -216,7 +_,7 @@ private MinecraftServer.@Nullable TimeProfiler debugCommandProfiler; private boolean debugCommandProfilerDelayStart; private ServerConnectionListener connection; @@ -24,7 +24,7 @@ private @Nullable ServerStatus status; private ServerStatus.@Nullable Favicon statusIcon; private final RandomSource random = RandomSource.create(); -@@ -230,13 +_,14 @@ +@@ -227,13 +_,14 @@ private Map, ServerLevel> levels = Maps.newLinkedHashMap(); private PlayerList playerList; private volatile boolean running = true; @@ -40,7 +40,7 @@ private int playerIdleTimeout; private final long[] tickTimesNanos = new long[100]; private long aggregatedTickTimesNanos = 0L; -@@ -283,10 +_,108 @@ +@@ -280,10 +_,108 @@ private final DiscontinuousFrame tickFrame; private final PacketProcessor packetProcessor; @@ -150,7 +150,7 @@ if (Runtime.getRuntime().availableProcessors() > 4) { thread.setPriority(8); } -@@ -298,6 +_,10 @@ +@@ -295,6 +_,10 @@ } public MinecraftServer( @@ -161,7 +161,7 @@ Thread serverThread, LevelStorageSource.LevelStorageAccess storageSource, PackRepository packRepository, -@@ -308,18 +_,19 @@ +@@ -305,18 +_,19 @@ LevelLoadListener levelLoadListener ) { super("Server"); @@ -184,7 +184,7 @@ this.storageSource = storageSource; this.playerDataStorage = storageSource.createPlayerStorage(); this.fixerUpper = fixerUpper; -@@ -339,6 +_,38 @@ +@@ -336,6 +_,38 @@ this.serverActivityMonitor = new ServerActivityMonitor(this.notificationManager, 30); this.packetProcessor = new PacketProcessor(serverThread); } @@ -223,7 +223,7 @@ } protected abstract boolean initServer() throws IOException; -@@ -371,15 +_,15 @@ +@@ -368,15 +_,15 @@ }; } @@ -244,7 +244,7 @@ if (profiledDuration != null) { profiledDuration.finish(true); } -@@ -393,31 +_,127 @@ +@@ -390,31 +_,127 @@ } } @@ -314,7 +314,7 @@ + if (biomeProvider == null && chunkGenerator != null) { + biomeProvider = chunkGenerator.getDefaultBiomeProvider(worldInfo); + } -+ final ResourceKey dimensionKey = ResourceKey.create(Registries.DIMENSION, loadingInfo.stemKey().location()); ++ final ResourceKey dimensionKey = ResourceKey.create(Registries.DIMENSION, loadingInfo.stemKey().identifier()); + ServerLevel serverLevel; + if (loadingInfo.stemKey() == LevelStem.OVERWORLD) { + serverLevel = new ServerLevel( @@ -382,7 +382,7 @@ serverLevelData.setInitialized(true); if (isDebugWorld) { this.setupDebugLevel(this.worldData); -@@ -437,38 +_,16 @@ +@@ -434,38 +_,16 @@ } GlobalPos globalPos = this.selectLevelLoadFocusPos(); @@ -401,7 +401,7 @@ - ResourceKey resourceKey = entry.getKey(); - ServerLevel serverLevel1; - if (resourceKey != LevelStem.OVERWORLD) { -- ResourceKey resourceKey1 = ResourceKey.create(Registries.DIMENSION, resourceKey.location()); +- ResourceKey resourceKey1 = ResourceKey.create(Registries.DIMENSION, resourceKey.identifier()); - DerivedLevelData derivedLevelData = new DerivedLevelData(this.worldData, serverLevelData); - serverLevel1 = new ServerLevel( - this, @@ -429,7 +429,7 @@ Optional legacyWorldBorderSettings = serverLevelData.getLegacyWorldBorderSettings(); if (legacyWorldBorderSettings.isPresent()) { WorldBorder.Settings settings = legacyWorldBorderSettings.get(); -@@ -491,16 +_,14 @@ +@@ -488,16 +_,14 @@ dataStorage1.set(WorldBorder.TYPE, worldBorder); } @@ -452,7 +452,7 @@ } private static void setInitialSpawn( -@@ -512,6 +_,30 @@ +@@ -509,6 +_,30 @@ levelData.setSpawn(LevelData.RespawnData.of(level.dimension(), BlockPos.ZERO.above(80), 0.0F, 0.0F)); } else { ServerChunkCache chunkSource = level.getChunkSource(); @@ -483,7 +483,7 @@ ChunkPos chunkPos = new ChunkPos(chunkSource.randomState().sampler().findSpawnPosition()); levelLoadListener.start(LevelLoadListener.Stage.PREPARE_GLOBAL_SPAWN, 0); levelLoadListener.updateFocus(level.dimension(), chunkPos); -@@ -568,10 +_,13 @@ +@@ -565,10 +_,13 @@ serverLevelData.setGameType(GameType.SPECTATOR); } @@ -499,7 +499,7 @@ chunkLoadCounter.track(serverLevel, () -> { TicketStorage ticketStorage = serverLevel.getDataStorage().get(TicketStorage.TYPE); if (ticketStorage != null) { -@@ -580,17 +_,19 @@ +@@ -577,17 +_,19 @@ }); } @@ -525,7 +525,7 @@ } protected GlobalPos selectLevelLoadFocusPos() { -@@ -624,8 +_,10 @@ +@@ -621,8 +_,10 @@ flag = true; } @@ -538,7 +538,7 @@ if (flush) { for (ServerLevel serverLevel : this.getAllLevels()) { LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", serverLevel.getChunkSource().chunkMap.getStorageName()); -@@ -655,19 +_,49 @@ +@@ -652,19 +_,49 @@ this.stopServer(); } @@ -589,7 +589,7 @@ } LOGGER.info("Saving worlds"); -@@ -709,6 +_,25 @@ +@@ -706,6 +_,25 @@ } catch (IOException var4) { LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), var4); } @@ -615,7 +615,7 @@ } public String getLocalIp() { -@@ -724,6 +_,14 @@ +@@ -721,6 +_,14 @@ } public void halt(boolean waitForShutdown) { @@ -630,7 +630,7 @@ this.running = false; if (waitForShutdown) { try { -@@ -734,6 +_,124 @@ +@@ -731,6 +_,124 @@ } } @@ -755,7 +755,7 @@ protected void runServer() { try { if (!this.initServer()) { -@@ -741,26 +_,68 @@ +@@ -738,26 +_,68 @@ } this.nextTickTimeNanos = Util.getNanos(); @@ -834,7 +834,7 @@ boolean flag = l == 0L; if (this.debugCommandProfilerDelayStart) { -@@ -768,22 +_,22 @@ +@@ -765,22 +_,22 @@ this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount); } @@ -862,7 +862,7 @@ this.finishMeasuringTaskExecutionTime(); if (flag) { this.tickRateManager.endTickWork(); -@@ -817,7 +_,7 @@ +@@ -814,7 +_,7 @@ } catch (Throwable var64) { LOGGER.error("Exception stopping the server", var64); } finally { @@ -871,7 +871,7 @@ } } } -@@ -869,7 +_,14 @@ +@@ -866,7 +_,14 @@ } private boolean haveTime() { @@ -887,7 +887,7 @@ } public static boolean throwIfFatalException() { -@@ -895,11 +_,11 @@ +@@ -892,11 +_,11 @@ } protected void waitUntilNextTick() { @@ -901,7 +901,7 @@ } finally { this.waitingForNextTick = false; } -@@ -918,17 +_,23 @@ +@@ -915,17 +_,23 @@ @Override public TickTask wrapRunnable(Runnable runnable) { @@ -927,7 +927,7 @@ this.mayHaveDelayedTasks = flag; return flag; } -@@ -937,15 +_,16 @@ +@@ -934,15 +_,16 @@ if (super.pollTask()) { return true; } else { @@ -946,7 +946,7 @@ } } -@@ -997,26 +_,44 @@ +@@ -995,26 +_,44 @@ } public void tickServer(BooleanSupplier hasTimeLeft) { @@ -992,7 +992,7 @@ this.tickCount++; this.tickRateManager.tick(); this.tickChildren(hasTimeLeft); -@@ -1026,11 +_,18 @@ +@@ -1024,11 +_,18 @@ } this.ticksUntilAutosave--; @@ -1012,7 +1012,7 @@ profilerFiller.push("tallying"); long l = Util.getNanos() - nanos; int i1 = this.tickCount % 100; -@@ -1043,7 +_,7 @@ +@@ -1041,7 +_,7 @@ } private void autoSave() { @@ -1021,7 +1021,7 @@ LOGGER.debug("Autosave started"); ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("save"); -@@ -1085,7 +_,7 @@ +@@ -1083,7 +_,7 @@ private ServerStatus buildServerStatus() { ServerStatus.Players players = this.buildPlayerStatus(); return new ServerStatus( @@ -1030,7 +1030,7 @@ Optional.of(players), Optional.of(ServerStatus.Version.current()), Optional.ofNullable(this.statusIcon), -@@ -1099,7 +_,7 @@ +@@ -1097,7 +_,7 @@ if (this.hidesOnlinePlayers()) { return new ServerStatus.Players(maxPlayers, players.size(), List.of()); } else { @@ -1039,7 +1039,7 @@ ObjectArrayList list = new ObjectArrayList<>(min); int randomInt = Mth.nextInt(this.random, 0, players.size() - min); -@@ -1116,18 +_,77 @@ +@@ -1114,18 +_,77 @@ protected void tickChildren(BooleanSupplier hasTimeLeft) { ProfilerFiller profilerFiller = Profiler.get(); this.getPlayerList().getPlayers().forEach(serverPlayer1 -> serverPlayer1.connection.suspendFlushing()); @@ -1106,7 +1106,7 @@ + serverLevel.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent + serverLevel.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent + serverLevel.updateLagCompensationTick(); // Paper - lag compensation - profilerFiller.push(() -> serverLevel + " " + serverLevel.dimension().location()); + profilerFiller.push(() -> serverLevel + " " + serverLevel.dimension().identifier()); + /* Drop global time updates if (this.tickCount % 20 == 0) { profilerFiller.push("timeSync"); @@ -1117,7 +1117,7 @@ profilerFiller.push("tick"); -@@ -1141,7 +_,9 @@ +@@ -1139,7 +_,9 @@ profilerFiller.pop(); profilerFiller.pop(); @@ -1127,7 +1127,7 @@ profilerFiller.popPush("connection"); this.tickConnection(); -@@ -1171,9 +_,12 @@ +@@ -1169,9 +_,12 @@ this.serverActivityMonitor.tick(); } @@ -1142,7 +1142,7 @@ this.effectiveRespawnData = serverLevel.getWorldBorderAdjustedRespawnData(respawnData); } -@@ -1223,6 +_,22 @@ +@@ -1221,6 +_,22 @@ return this.levels.get(dimension); } @@ -1165,7 +1165,7 @@ public Set> levelKeys() { return this.levels.keySet(); } -@@ -1247,7 +_,7 @@ +@@ -1245,7 +_,7 @@ @DontObfuscate public String getServerModName() { @@ -1174,7 +1174,7 @@ } public SystemReport fillSystemReport(SystemReport systemReport) { -@@ -1282,7 +_,7 @@ +@@ -1280,7 +_,7 @@ @Override public void sendSystemMessage(Component message) { @@ -1183,7 +1183,7 @@ } public KeyPair getKeyPair() { -@@ -1319,11 +_,17 @@ +@@ -1317,11 +_,17 @@ } } @@ -1206,7 +1206,7 @@ } } -@@ -1395,10 +_,20 @@ +@@ -1393,10 +_,20 @@ @Override public String getMotd() { @@ -1228,7 +1228,7 @@ this.motd = motd; } -@@ -1427,9 +_,13 @@ +@@ -1425,9 +_,13 @@ int i = 0; for (ServerPlayer serverPlayer : this.getPlayerList().getPlayers()) { @@ -1244,7 +1244,7 @@ } return i; -@@ -1437,7 +_,7 @@ +@@ -1435,7 +_,7 @@ } public ServerConnectionListener getConnection() { @@ -1253,7 +1253,7 @@ } public boolean isReady() { -@@ -1504,7 +_,7 @@ +@@ -1502,7 +_,7 @@ @Override public void executeIfPossible(Runnable task) { if (this.isStopped()) { @@ -1262,7 +1262,7 @@ } else { super.executeIfPossible(task); } -@@ -1539,7 +_,14 @@ +@@ -1537,7 +_,14 @@ return this.functionManager; } @@ -1277,7 +1277,7 @@ CompletableFuture completableFuture = CompletableFuture.supplyAsync( () -> selectedIds.stream().map(this.packRepository::getPack).filter(Objects::nonNull).map(Pack::open).collect(ImmutableList.toImmutableList()), this -@@ -1547,7 +_,7 @@ +@@ -1545,7 +_,7 @@ .thenCompose( list -> { CloseableResourceManager closeableResourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, list); @@ -1286,7 +1286,7 @@ return ReloadableServerResources.loadResources( closeableResourceManager, this.registries, -@@ -1568,20 +_,39 @@ +@@ -1566,20 +_,39 @@ ) .thenAcceptAsync( reloadableResources -> { @@ -1328,7 +1328,7 @@ }, this ); -@@ -1598,7 +_,7 @@ +@@ -1596,7 +_,7 @@ DataPackConfig dataPackConfig = initialDataConfig.dataPacks(); FeatureFlagSet featureFlagSet = initMode ? FeatureFlagSet.of() : initialDataConfig.enabledFeatures(); FeatureFlagSet featureFlagSet1 = initMode ? FeatureFlags.REGISTRY.allFlags() : initialDataConfig.enabledFeatures(); @@ -1337,7 +1337,7 @@ if (safeMode) { return configureRepositoryWithSelection(packRepository, List.of("vanilla"), featureFlagSet, false); } else { -@@ -1653,7 +_,7 @@ +@@ -1651,7 +_,7 @@ private static WorldDataConfiguration configureRepositoryWithSelection( PackRepository packRepository, Collection selectedPacks, FeatureFlagSet enabledFeatures, boolean safeMode ) { @@ -1346,7 +1346,7 @@ enableForcedFeaturePacks(packRepository, enabledFeatures); DataPackConfig selectedPacks1 = getSelectedPacks(packRepository, safeMode); FeatureFlagSet featureFlagSet = packRepository.getRequestedFeatureFlags().join(enabledFeatures); -@@ -1685,7 +_,7 @@ +@@ -1683,7 +_,7 @@ } } @@ -1355,7 +1355,7 @@ } } -@@ -1702,8 +_,8 @@ +@@ -1700,8 +_,8 @@ UserWhiteList whiteList = playerList.getWhiteList(); for (ServerPlayer serverPlayer : Lists.newArrayList(playerList.getPlayers())) { @@ -1366,7 +1366,7 @@ } } } -@@ -1733,12 +_,12 @@ +@@ -1731,12 +_,12 @@ } public ServerLevel findRespawnDimension() { @@ -1381,7 +1381,7 @@ public void setRespawnData(LevelData.RespawnData respawnData) { ServerLevelData serverLevelData = this.worldData.overworldData(); LevelData.RespawnData respawnData1 = serverLevelData.getRespawnData(); -@@ -1940,6 +_,17 @@ +@@ -1938,6 +_,17 @@ } } @@ -1399,7 +1399,7 @@ private ProfilerFiller createProfiler() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted( -@@ -2060,16 +_,22 @@ +@@ -2058,16 +_,22 @@ } public void logChatMessage(Component content, ChatType.Bound boundChatType, @Nullable String header) { @@ -1426,7 +1426,7 @@ } public boolean logIPs() { -@@ -2080,8 +_,9 @@ +@@ -2078,8 +_,9 @@ LOGGER.debug("Received custom click action {} with payload {}", id, payload.orElse(null)); } @@ -1437,7 +1437,7 @@ } public boolean setAutoSave(boolean autoSave) { -@@ -2107,12 +_,14 @@ +@@ -2105,12 +_,14 @@ return false; } @@ -1455,7 +1455,7 @@ serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, b)); } } else if (rule == GameRules.LIMITED_CRAFTING || rule == GameRules.IMMEDIATE_RESPAWN) { -@@ -2120,18 +_,18 @@ +@@ -2118,18 +_,18 @@ ? ClientboundGameEventPacket.LIMITED_CRAFTING : ClientboundGameEventPacket.IMMEDIATE_RESPAWN; ClientboundGameEventPacket clientboundGameEventPacket = new ClientboundGameEventPacket(type, (Boolean)value ? 1.0F : 0.0F); @@ -1478,7 +1478,7 @@ } } -@@ -2266,4 +_,53 @@ +@@ -2264,4 +_,53 @@ }; } } diff --git a/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch b/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch index dd0559c5bd82..91cc5562a305 100644 --- a/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch @@ -13,7 +13,7 @@ private @Nullable AdvancementHolder lastSelectedTab; private boolean isFirstPacket = true; private final Codec codec; -+ public final Map, Set>> criterionData = new java.util.IdentityHashMap<>(); // Paper - fix advancement data player leakage ++ public final Map, Set>> criterionData = new java.util.IdentityHashMap<>(); // Paper - fix advancement data player leakage public PlayerAdvancements(DataFixer dataFixer, PlayerList playerList, ServerAdvancementManager manager, Path playerSavePath, ServerPlayer player) { this.playerList = playerList; @@ -29,7 +29,7 @@ data.forEach((path, progress) -> { AdvancementHolder advancementHolder = advancementManager.get(path); if (advancementHolder == null) { -+ if (!path.getNamespace().equals(ResourceLocation.DEFAULT_NAMESPACE)) return; // CraftBukkit ++ if (!path.getNamespace().equals(Identifier.DEFAULT_NAMESPACE)) return; // CraftBukkit LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", path, this.playerSavePath); } else { this.startProgress(advancementHolder, progress); @@ -70,9 +70,9 @@ @@ -245,7 +_,7 @@ public void flushDirty(ServerPlayer player, boolean showAdvancements) { if (this.isFirstPacket || !this.rootsToUpdate.isEmpty() || !this.progressChanged.isEmpty()) { - Map map = new HashMap<>(); + Map map = new HashMap<>(); - Set set = new HashSet<>(); + Set set = new java.util.TreeSet<>(java.util.Comparator.comparing(adv -> adv.id().toString())); // Paper - Changed from HashSet to TreeSet ordered alphabetically. - Set set1 = new HashSet<>(); + Set set1 = new HashSet<>(); for (AdvancementNode advancementNode : this.rootsToUpdate) { diff --git a/paper-server/patches/sources/net/minecraft/server/ReloadableServerRegistries.java.patch b/paper-server/patches/sources/net/minecraft/server/ReloadableServerRegistries.java.patch index 138e996818e6..17d2976357a1 100644 --- a/paper-server/patches/sources/net/minecraft/server/ReloadableServerRegistries.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ReloadableServerRegistries.java.patch @@ -22,13 +22,13 @@ () -> { WritableRegistry writableRegistry = new MappedRegistry<>(lootDataType.registryKey(), Lifecycle.experimental()); + io.papermc.paper.registry.PaperRegistryAccess.instance().registerReloadableRegistry(writableRegistry); // Paper - register reloadable registry - Map map = new HashMap<>(); + Map map = new HashMap<>(); SimpleJsonResourceReloadListener.scanDirectory(resourceManager, lootDataType.registryKey(), ops, lootDataType.codec(), map); map.forEach( -- (resourceLocation, object) -> writableRegistry.register( -- ResourceKey.create(lootDataType.registryKey(), resourceLocation), (T)object, DEFAULT_REGISTRATION_INFO -+ (resourceLocation, object) -> io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.registerWithListeners(writableRegistry, // Paper - register with listeners -+ ResourceKey.create(lootDataType.registryKey(), resourceLocation), (T)object, DEFAULT_REGISTRATION_INFO, conversions // Paper - register with listeners +- (identifier, object) -> writableRegistry.register( +- ResourceKey.create(lootDataType.registryKey(), identifier), (T)object, DEFAULT_REGISTRATION_INFO ++ (identifier, object) -> io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.registerWithListeners(writableRegistry, // Paper - register with listeners ++ ResourceKey.create(lootDataType.registryKey(), identifier), (T)object, DEFAULT_REGISTRATION_INFO, conversions // Paper - register with listeners ) ); - TagLoader.loadTagsForRegistry(resourceManager, writableRegistry); diff --git a/paper-server/patches/sources/net/minecraft/server/ServerAdvancementManager.java.patch b/paper-server/patches/sources/net/minecraft/server/ServerAdvancementManager.java.patch index 3be388af5518..3f0820b171c8 100644 --- a/paper-server/patches/sources/net/minecraft/server/ServerAdvancementManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ServerAdvancementManager.java.patch @@ -4,22 +4,22 @@ public class ServerAdvancementManager extends SimpleJsonResourceReloadListener { private static final Logger LOGGER = LogUtils.getLogger(); -- public Map advancements = Map.of(); -+ public Map advancements = new java.util.HashMap<>(); // CraftBukkit - SPIGOT-7734: mutable +- public Map advancements = Map.of(); ++ public Map advancements = new java.util.HashMap<>(); // CraftBukkit - SPIGOT-7734: mutable private AdvancementTree tree = new AdvancementTree(); private final HolderLookup.Provider registries; @@ -35,12 +_,18 @@ - protected void apply(Map object, ResourceManager resourceManager, ProfilerFiller profiler) { - Builder builder = ImmutableMap.builder(); - object.forEach((resourceLocation, advancement) -> { + protected void apply(Map object, ResourceManager resourceManager, ProfilerFiller profiler) { + Builder builder = ImmutableMap.builder(); + object.forEach((identifier, advancement) -> { + // Spigot start -+ if (org.spigotmc.SpigotConfig.disabledAdvancements != null && (org.spigotmc.SpigotConfig.disabledAdvancements.contains("*") || org.spigotmc.SpigotConfig.disabledAdvancements.contains(resourceLocation.toString()) || org.spigotmc.SpigotConfig.disabledAdvancements.contains(resourceLocation.getNamespace()))) { ++ if (org.spigotmc.SpigotConfig.disabledAdvancements != null && (org.spigotmc.SpigotConfig.disabledAdvancements.contains("*") || org.spigotmc.SpigotConfig.disabledAdvancements.contains(identifier.toString()) || org.spigotmc.SpigotConfig.disabledAdvancements.contains(identifier.getNamespace()))) { + return; + } + // Spigot end - this.validate(resourceLocation, advancement); - builder.put(resourceLocation, new AdvancementHolder(resourceLocation, advancement)); + this.validate(identifier, advancement); + builder.put(identifier, new AdvancementHolder(identifier, advancement)); }); - this.advancements = builder.buildOrThrow(); + this.advancements = new java.util.HashMap<>(builder.buildOrThrow()); // CraftBukkit - SPIGOT-7734: mutable diff --git a/paper-server/patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch b/paper-server/patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch index 6f49e308d06e..5b4c62b4b947 100644 --- a/paper-server/patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch @@ -4,8 +4,8 @@ return null; }).join()); this.functions = builder.build(); -- this.tags = this.tagsLoader.build((Map>)pair.getFirst()); -+ this.tags = this.tagsLoader.build((Map>)pair.getFirst(), null); // Paper - command function tags are not implemented yet +- this.tags = this.tagsLoader.build((Map>)pair.getFirst()); ++ this.tags = this.tagsLoader.build((Map>)pair.getFirst(), null); // Paper - command function tags are not implemented yet }, gameExecutor ); diff --git a/paper-server/patches/sources/net/minecraft/server/bossevents/CustomBossEvent.java.patch b/paper-server/patches/sources/net/minecraft/server/bossevents/CustomBossEvent.java.patch index 3338d7d8be9e..511f66f064a7 100644 --- a/paper-server/patches/sources/net/minecraft/server/bossevents/CustomBossEvent.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/bossevents/CustomBossEvent.java.patch @@ -15,5 +15,5 @@ + } + // CraftBukkit end - public CustomBossEvent(ResourceLocation id, Component name) { + public CustomBossEvent(Identifier id, Component name) { super(name, BossEvent.BossBarColor.WHITE, BossEvent.BossBarOverlay.PROGRESS); diff --git a/paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch index bd614fe2f377..1e8073d25ded 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch @@ -12,13 +12,13 @@ @@ -101,7 +_,7 @@ } else { long l = source.getLevel().getGameTime() + time; - ResourceLocation resourceLocation = function.getFirst(); + Identifier identifier = function.getFirst(); - TimerQueue scheduledEvents = source.getServer().getWorldData().overworldData().getScheduledEvents(); + TimerQueue scheduledEvents = source.getLevel().serverLevelData.overworldData().getScheduledEvents(); // CraftBukkit - SPIGOT-6667: Use world specific function timer Optional> optional = function.getSecond().left(); if (optional.isPresent()) { if (optional.get() instanceof MacroFunction) { -@@ -132,7 +_,7 @@ +@@ -130,7 +_,7 @@ } private static int remove(CommandSourceStack source, String function) throws CommandSyntaxException { diff --git a/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch index 6a0d5e35ae9b..de35da33ce39 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch @@ -20,7 +20,7 @@ + } + // Paper end - Add PlayerSetSpawnEvent - String string = resourceKey.location().toString(); + String string = resourceKey.identifier().toString(); - if (targets.size() == 1) { + if (actualTargets.size() == 1) { // Paper - Add PlayerSetSpawnEvent source.sendSuccess( diff --git a/paper-server/patches/sources/net/minecraft/server/commands/WaypointCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/WaypointCommand.java.patch index e24fe52eb569..17c29d6a3d34 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/WaypointCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/WaypointCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/WaypointCommand.java +++ b/net/minecraft/server/commands/WaypointCommand.java -@@ -168,7 +_,7 @@ +@@ -166,7 +_,7 @@ } private static void mutateIcon(CommandSourceStack source, WaypointTransmitter waypoint, Consumer mutator) { diff --git a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch index 622c09a01cec..9a82881e1e11 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch @@ -175,9 +175,9 @@ - public static CompoundTag getChunkDataFixContextTag(ResourceKey dimension, Optional>> generator) { + public static CompoundTag getChunkDataFixContextTag(ResourceKey stemKey, Optional>> generator) { // CraftBukkit CompoundTag compoundTag = new CompoundTag(); -- compoundTag.putString("dimension", dimension.location().toString()); -+ compoundTag.putString("dimension", stemKey.location().toString()); // CraftBukkit - generator.ifPresent(resourceKey -> compoundTag.putString("generator", resourceKey.location().toString())); +- compoundTag.putString("dimension", dimension.identifier().toString()); ++ compoundTag.putString("dimension", stemKey.identifier().toString()); // CraftBukkit + generator.ifPresent(resourceKey -> compoundTag.putString("generator", resourceKey.identifier().toString())); return compoundTag; } @@ -939,7 +_,7 @@ diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch index 49697c615f3d..c48d3ffaa44f 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -189,7 +_,7 @@ +@@ -193,7 +_,7 @@ final List players = Lists.newArrayList(); public final ServerChunkCache chunkSource; private final MinecraftServer server; @@ -8,8 +8,8 @@ + public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type final EntityTickList entityTickList = new EntityTickList(); private final ServerWaypointManager waypointManager; - public final PersistentEntitySectionManager entityManager; -@@ -216,25 +_,170 @@ + private final EnvironmentAttributeSystem environmentAttributes; +@@ -221,25 +_,170 @@ private final RandomSequences randomSequences; final LevelDebugSynchronizers debugSynchronizers = new LevelDebugSynchronizers(this); @@ -154,7 +154,7 @@ ) { - super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates()); + // CraftBukkit start -+ super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules()))); // Paper - create paper world configs ++ super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.identifier(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules()))); // Paper - create paper world configs + this.levelStorageAccess = levelStorageAccess; + this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getOrCreate(levelStorageAccess.levelDirectory.path().toFile()); + this.levelLoadListener = new net.minecraft.server.level.progress.LoggingLevelLoadListener(false, this); @@ -183,7 +183,7 @@ boolean flag = server.forceSynchronousWrites(); DataFixer fixerUpper = server.getFixerUpper(); EntityPersistentStorage entityPersistentStorage = new EntityStorage( -@@ -256,8 +_,8 @@ +@@ -261,8 +_,8 @@ server.getStructureManager(), dispatcher, chunkGenerator, @@ -194,7 +194,7 @@ flag, this.entityManager::updateChunkStatus, () -> server.overworld().getDataStorage() -@@ -276,7 +_,7 @@ +@@ -280,7 +_,7 @@ this.chunkSource.chunkScanner(), this.registryAccess(), server.getStructureManager(), @@ -203,7 +203,7 @@ chunkGenerator, this.chunkSource.randomState(), this, -@@ -284,9 +_,9 @@ +@@ -288,9 +_,9 @@ seed, fixerUpper ); @@ -216,10 +216,10 @@ } else { this.dragonFight = null; } -@@ -295,7 +_,15 @@ - this.gameEventDispatcher = new GameEventDispatcher(this); - this.randomSequences = Objects.requireNonNullElseGet(randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE)); +@@ -301,7 +_,15 @@ this.waypointManager = new ServerWaypointManager(); + this.environmentAttributes = EnvironmentAttributeSystem.builder().addDefaultLayers(this).build(); + this.updateSkyBrightness(); - } + this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit + } @@ -233,7 +233,7 @@ @Deprecated @VisibleForTesting -@@ -307,8 +_,8 @@ +@@ -313,8 +_,8 @@ this.serverLevelData.setClearWeatherTime(clearTime); this.serverLevelData.setRainTime(weatherTime); this.serverLevelData.setThunderTime(weatherTime); @@ -244,7 +244,7 @@ } @Override -@@ -335,12 +_,25 @@ +@@ -346,12 +_,25 @@ int i = this.getGameRules().get(GameRules.PLAYERS_SLEEPING_PERCENTAGE); if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { @@ -273,7 +273,7 @@ if (this.getGameRules().get(GameRules.ADVANCE_WEATHER) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -355,9 +_,9 @@ +@@ -366,9 +_,9 @@ if (!this.isDebug() && runsNormally) { long l = this.getGameTime(); profilerFiller.push("blockTicks"); @@ -285,7 +285,7 @@ profilerFiller.pop(); } -@@ -375,7 +_,7 @@ +@@ -386,7 +_,7 @@ this.handlingTick = false; profilerFiller.pop(); @@ -294,7 +294,7 @@ if (hasActiveTickets) { this.resetEmptyTime(); } -@@ -483,11 +_,13 @@ +@@ -495,11 +_,13 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("iceandsnow"); @@ -308,7 +308,7 @@ profilerFiller.popPush("tickBlocks"); if (randomTickSpeed > 0) { -@@ -530,12 +_,12 @@ +@@ -542,12 +_,12 @@ int minBlockZ = pos.getMinBlockZ(); ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("thunder"); @@ -323,7 +323,7 @@ && !this.getBlockState(blockPos.below()).is(BlockTags.LIGHTNING_RODS); if (flag) { SkeletonHorse skeletonHorse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT); -@@ -543,7 +_,7 @@ +@@ -555,7 +_,7 @@ skeletonHorse.setTrap(true); skeletonHorse.setAge(0); skeletonHorse.setPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()); @@ -332,7 +332,7 @@ } } -@@ -551,7 +_,7 @@ +@@ -563,7 +_,7 @@ if (lightningBolt != null) { lightningBolt.snapTo(Vec3.atBottomCenterOf(blockPos)); lightningBolt.setVisualOnly(flag); @@ -341,7 +341,7 @@ } } } -@@ -565,7 +_,7 @@ +@@ -577,7 +_,7 @@ BlockPos blockPos = heightmapPos.below(); Biome biome = this.getBiome(heightmapPos).value(); if (biome.shouldFreeze(this, blockPos)) { @@ -350,7 +350,7 @@ } if (this.isRaining()) { -@@ -577,10 +_,10 @@ +@@ -589,10 +_,10 @@ if (layersValue < Math.min(i, 8)) { BlockState blockState1 = blockState.setValue(SnowLayerBlock.LAYERS, layersValue + 1); Block.pushEntitiesUp(blockState, blockState1, this, heightmapPos); @@ -363,7 +363,7 @@ } } -@@ -605,6 +_,12 @@ +@@ -617,6 +_,12 @@ } protected BlockPos findLightningTargetAround(BlockPos pos) { @@ -376,7 +376,7 @@ BlockPos heightmapPos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos); Optional optional = this.findLightningRod(heightmapPos); if (optional.isPresent()) { -@@ -612,11 +_,12 @@ +@@ -624,11 +_,12 @@ } else { AABB aabb = AABB.encapsulatingFullBlocks(heightmapPos, heightmapPos.atY(this.getMaxY() + 1)).inflate(3.0); List entitiesOfClass = this.getEntitiesOfClass( @@ -390,7 +390,7 @@ if (heightmapPos.getY() == this.getMinY() - 1) { heightmapPos = heightmapPos.above(2); } -@@ -720,8 +_,8 @@ +@@ -737,8 +_,8 @@ this.serverLevelData.setThunderTime(thunderTime); this.serverLevelData.setRainTime(rainTime); this.serverLevelData.setClearWeatherTime(clearWeatherTime); @@ -401,7 +401,7 @@ } this.oThunderLevel = this.thunderLevel; -@@ -742,6 +_,7 @@ +@@ -759,6 +_,7 @@ this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -409,7 +409,7 @@ if (this.oRainLevel != this.rainLevel) { this.server .getPlayerList() -@@ -764,14 +_,47 @@ +@@ -781,14 +_,47 @@ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -461,7 +461,7 @@ } public void resetEmptyTime() { -@@ -793,18 +_,46 @@ +@@ -810,18 +_,46 @@ } } @@ -508,7 +508,7 @@ } private void tickPassenger(Entity ridingEntity, Entity passengerEntity) { -@@ -813,10 +_,12 @@ +@@ -830,10 +_,12 @@ } else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) { passengerEntity.setOldPosAndRot(); passengerEntity.tickCount++; @@ -521,7 +521,7 @@ profilerFiller.pop(); for (Entity entity : passengerEntity.getPassengers()) { -@@ -847,6 +_,7 @@ +@@ -864,6 +_,7 @@ public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) { ServerChunkCache chunkSource = this.getChunkSource(); if (!skipSave) { @@ -529,7 +529,7 @@ if (progress != null) { progress.progressStartNoAbort(Component.translatable("menu.savingLevel")); } -@@ -863,11 +_,18 @@ +@@ -880,11 +_,18 @@ this.entityManager.autoSave(); } } @@ -549,7 +549,7 @@ } DimensionDataStorage dataStorage = this.getChunkSource().getDataStorage(); -@@ -931,18 +_,40 @@ +@@ -948,18 +_,40 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -593,7 +593,7 @@ } } -@@ -965,41 +_,120 @@ +@@ -982,41 +_,120 @@ this.entityManager.addNewEntity(player); } @@ -719,7 +719,7 @@ if (d * d + d1 * d1 + d2 * d2 < 1024.0) { serverPlayer.connection.send(new ClientboundBlockDestructionPacket(breakerId, pos, progress)); } -@@ -1074,7 +_,7 @@ +@@ -1091,7 +_,7 @@ pos.getX(), pos.getY(), pos.getZ(), @@ -728,7 +728,7 @@ this.dimension(), new ClientboundLevelEventPacket(type, pos, data, false) ); -@@ -1086,6 +_,11 @@ +@@ -1103,6 +_,11 @@ @Override public void gameEvent(Holder gameEvent, Vec3 pos, GameEvent.Context context) { @@ -740,7 +740,7 @@ this.gameEventDispatcher.post(gameEvent, pos, context); } -@@ -1098,17 +_,28 @@ +@@ -1115,17 +_,28 @@ this.getChunkSource().blockChanged(pos); this.pathTypesByPosCache.invalidate(pos); @@ -769,7 +769,7 @@ try { this.isUpdatingNavigations = true; -@@ -1120,15 +_,23 @@ +@@ -1137,15 +_,23 @@ this.isUpdatingNavigations = false; } } @@ -793,7 +793,7 @@ this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, block, null, orientation); } -@@ -1178,6 +_,44 @@ +@@ -1195,6 +_,44 @@ WeightedList blockParticles, Holder explosionSound ) { @@ -838,7 +838,7 @@ Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) { case NONE -> Explosion.BlockInteraction.KEEP; case BLOCK -> this.getDestroyType(GameRules.BLOCK_EXPLOSION_DROP_DECAY); -@@ -1186,10 +_,17 @@ +@@ -1203,10 +_,17 @@ : Explosion.BlockInteraction.KEEP; case TNT -> this.getDestroyType(GameRules.TNT_EXPLOSION_DROP_DECAY); case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; @@ -856,7 +856,7 @@ ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles; for (ServerPlayer serverPlayer : this.players) { -@@ -1198,6 +_,8 @@ +@@ -1215,6 +_,8 @@ serverPlayer.connection.send(new ClientboundExplodePacket(vec3, radius, i, optional, particleOptions, explosionSound, blockParticles)); } } @@ -865,7 +865,7 @@ } private Explosion.BlockInteraction getDestroyType(GameRule decayGameRule) { -@@ -1267,19 +_,55 @@ +@@ -1284,19 +_,55 @@ public int sendParticles( T options, double x, double y, double z, int count, double xDist, double yDist, double zDist, double speed ) { @@ -924,7 +924,7 @@ if (this.sendParticles(serverPlayer, overrideLimiter, x, y, z, clientboundLevelParticlesPacket)) { i++; } -@@ -1363,7 +_,7 @@ +@@ -1380,7 +_,7 @@ } public @Nullable BlockPos findNearestMapStructure(TagKey structureTag, BlockPos pos, int radius, boolean skipKnownStructures) { @@ -933,7 +933,7 @@ return null; } else { Optional> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag); -@@ -1415,10 +_,36 @@ +@@ -1432,10 +_,36 @@ @Override public @Nullable MapItemSavedData getMapData(MapId mapId) { @@ -971,7 +971,7 @@ this.getServer().overworld().getDataStorage().set(MapItemSavedData.type(mapId), data); } -@@ -1428,7 +_,19 @@ +@@ -1445,7 +_,19 @@ @Override public void setRespawnData(LevelData.RespawnData respawnData) { @@ -992,7 +992,7 @@ } @Override -@@ -1465,6 +_,11 @@ +@@ -1482,6 +_,11 @@ this.debugSynchronizers.dropPoi(blockPos); })); optional1.ifPresent(holder -> this.getServer().execute(() -> { @@ -1004,7 +1004,7 @@ PoiRecord poiRecord = this.getPoiManager().add(blockPos, (Holder)holder); if (poiRecord != null) { this.debugSynchronizers.registerPoi(poiRecord); -@@ -1618,12 +_,12 @@ +@@ -1635,12 +_,12 @@ } public boolean isFlat() { @@ -1019,7 +1019,7 @@ } public @Nullable EndDragonFight getDragonFight() { -@@ -1673,6 +_,7 @@ +@@ -1690,6 +_,7 @@ @Override public LevelEntityGetter getEntities() { @@ -1027,7 +1027,7 @@ return this.entityManager.getEntityGetter(); } -@@ -1788,6 +_,28 @@ +@@ -1805,6 +_,28 @@ return this.serverLevelData.getGameRules(); } @@ -1056,7 +1056,7 @@ @Override public CrashReportCategory fillReportDetails(CrashReport report) { CrashReportCategory crashReportCategory = super.fillReportDetails(report); -@@ -1832,6 +_,7 @@ +@@ -1849,6 +_,7 @@ if (entity instanceof WaypointTransmitter waypointTransmitter && waypointTransmitter.isTransmittingWaypoint()) { ServerLevel.this.getWaypointManager().trackWaypoint(waypointTransmitter); } @@ -1064,7 +1064,7 @@ } @Override -@@ -1845,17 +_,24 @@ +@@ -1862,17 +_,24 @@ @Override public void onTickingStart(Entity entity) { @@ -1090,7 +1090,7 @@ if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.add(serverPlayer); if (serverPlayer.isReceivingWaypoints()) { -@@ -1870,7 +_,7 @@ +@@ -1887,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1099,7 +1099,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1887,10 +_,52 @@ +@@ -1904,10 +_,52 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -1152,7 +1152,7 @@ ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); -@@ -1899,7 +_,7 @@ +@@ -1916,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1161,7 +1161,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1917,6 +_,15 @@ +@@ -1934,6 +_,15 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); ServerLevel.this.debugSynchronizers.dropEntity(entity); @@ -1177,7 +1177,7 @@ } @Override -@@ -1924,4 +_,24 @@ +@@ -1941,4 +_,24 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::move); } } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index c1715ea0d357..53b3ba38b8c7 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -255,7 +_,8 @@ +@@ -254,7 +_,8 @@ private int levitationStartTime; private boolean disconnected; private int requestedViewDistance = 2; @@ -10,7 +10,7 @@ private @Nullable Vec3 startingToFallPosition; private @Nullable Vec3 enteredNetherPosition; private @Nullable Vec3 enteredLavaOnVehiclePosition; -@@ -299,6 +_,13 @@ +@@ -298,6 +_,13 @@ } } @@ -24,7 +24,7 @@ @Override public void sendSlotChange(AbstractContainerMenu container, int slot, ItemStack stack) { ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(container.containerId, container.incrementStateId(), slot, stack)); -@@ -334,6 +_,32 @@ +@@ -333,6 +_,32 @@ } } @@ -57,7 +57,7 @@ @Override public void dataChanged(AbstractContainerMenu containerMenu, int dataSlotIndex, int value) { } -@@ -360,10 +_,43 @@ +@@ -359,10 +_,43 @@ public void sendSystemMessage(Component message) { ServerPlayer.this.sendSystemMessage(message); } @@ -101,7 +101,7 @@ public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) { super(level, gameProfile); -@@ -374,8 +_,14 @@ +@@ -373,8 +_,14 @@ this.recipeBook = new ServerRecipeBook((recipe, output) -> server.getRecipeManager().listDisplaysForRecipe(recipe, output)); this.stats = server.getPlayerList().getPlayerStats(this); this.advancements = server.getPlayerList().getPlayerAdvancements(this); @@ -117,7 +117,7 @@ } @Override -@@ -393,6 +_,7 @@ +@@ -392,6 +_,7 @@ this.seenCredits = input.getBooleanOr("seenCredits", false); input.read("recipeBook", ServerRecipeBook.Packed.CODEC) .ifPresent(packed -> this.recipeBook.loadUntrusted(packed, key -> this.server.getRecipeManager().byKey(key).isPresent())); @@ -125,7 +125,7 @@ if (this.isSleeping()) { this.stopSleeping(); } -@@ -400,6 +_,19 @@ +@@ -399,6 +_,19 @@ this.respawnConfig = input.read("respawn", ServerPlayer.RespawnConfig.CODEC).orElse(null); this.spawnExtraParticlesOnFall = input.getBooleanOr("spawn_extra_particles_on_fall", false); this.raidOmenPosition = input.read("raid_omen_position", BlockPos.CODEC).orElse(null); @@ -145,7 +145,7 @@ this.gameMode .setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(input, "playerGameType")), readPlayerMode(input, "previousPlayerGameType")); this.setShoulderEntityLeft(input.read("ShoulderEntityLeft", CompoundTag.CODEC).orElseGet(CompoundTag::new)); -@@ -427,12 +_,24 @@ +@@ -426,12 +_,24 @@ if (!this.getShoulderEntityRight().isEmpty()) { output.store("ShoulderEntityRight", CompoundTag.CODEC, this.getShoulderEntityRight()); } @@ -171,7 +171,7 @@ ValueOutput valueOutput = output.child("RootVehicle"); valueOutput.store("Attach", UUIDUtil.CODEC, vehicle.getUUID()); rootVehicle.save(valueOutput.child("Entity")); -@@ -444,7 +_,7 @@ +@@ -443,7 +_,7 @@ if (!optional.isEmpty()) { ServerLevel serverLevel = this.level(); Entity entity = EntityType.loadEntityRecursive( @@ -180,7 +180,7 @@ ); if (entity != null) { UUID uuid = optional.get().read("Attach", UUIDUtil.CODEC).orElse(null); -@@ -461,10 +_,10 @@ +@@ -460,10 +_,10 @@ if (!this.isPassenger()) { LOGGER.warn("Couldn't reattach entity to player"); @@ -193,7 +193,7 @@ } } } -@@ -476,6 +_,7 @@ +@@ -475,6 +_,7 @@ ValueOutput.ValueOutputList valueOutputList = output.childrenList("ender_pearls"); for (ThrownEnderpearl thrownEnderpearl : this.enderPearls) { @@ -201,7 +201,7 @@ if (thrownEnderpearl.isRemoved()) { LOGGER.warn("Trying to save removed ender pearl, skipping"); } else { -@@ -508,6 +_,16 @@ +@@ -507,6 +_,16 @@ } } @@ -218,7 +218,7 @@ public void setExperiencePoints(int experiencePoints) { float f = this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -572,6 +_,11 @@ +@@ -571,6 +_,11 @@ @Override public void tick() { @@ -230,7 +230,7 @@ this.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); -@@ -579,9 +_,18 @@ +@@ -578,9 +_,18 @@ this.invulnerableTime--; } @@ -252,7 +252,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -640,10 +_,10 @@ +@@ -639,10 +_,10 @@ public void doTick() { try { @@ -265,7 +265,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -673,7 +_,7 @@ +@@ -672,7 +_,7 @@ if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -274,7 +274,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -704,6 +_,12 @@ +@@ -703,6 +_,12 @@ this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float)this.lastRecordedExperience)); } @@ -287,7 +287,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float)this.lastRecordedLevel)); -@@ -717,6 +_,21 @@ +@@ -716,6 +_,21 @@ if (this.tickCount % 20 == 0) { CriteriaTriggers.LOCATION.trigger(this); } @@ -309,7 +309,7 @@ } catch (Throwable var4) { CrashReport crashReport = CrashReport.forThrowable(var4, "Ticking player"); CrashReportCategory crashReportCategory = crashReport.addCategory("Player being ticked"); -@@ -741,7 +_,7 @@ +@@ -740,7 +_,7 @@ if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.level().getGameRules().get(GameRules.NATURAL_HEALTH_REGENERATION)) { if (this.tickCount % 20 == 0) { if (this.getHealth() < this.getMaxHealth()) { @@ -318,7 +318,7 @@ } float saturationLevel = this.foodData.getSaturationLevel(); -@@ -761,6 +_,7 @@ +@@ -760,6 +_,7 @@ this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft()); this.playShoulderEntityAmbientSound(this.getShoulderEntityRight()); if (this.fallDistance > 0.5 || this.isInWater() || this.getAbilities().flying || this.isSleeping() || this.isInPowderSnow) { @@ -326,7 +326,7 @@ this.removeEntitiesOnShoulder(); } } -@@ -805,35 +_,64 @@ +@@ -804,35 +_,64 @@ @Override public void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { @@ -398,7 +398,7 @@ } @Override -@@ -870,15 +_,36 @@ +@@ -869,15 +_,36 @@ } private void updateScoreForCriteria(ObjectiveCriteria criteria, int points) { @@ -444,7 +444,7 @@ this.connection .send( new ClientboundPlayerCombatKillPacket(this.getId(), deathMessage), -@@ -895,6 +_,65 @@ +@@ -894,6 +_,65 @@ } ) ); @@ -510,7 +510,7 @@ Team team = this.getTeam(); if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) { this.server.getPlayerList().broadcastSystemMessage(deathMessage, false); -@@ -904,7 +_,7 @@ +@@ -903,7 +_,7 @@ this.server.getPlayerList().broadcastSystemToAllExceptTeam(this, deathMessage); } } else { @@ -519,7 +519,7 @@ } this.removeEntitiesOnShoulder(); -@@ -912,11 +_,35 @@ +@@ -911,11 +_,35 @@ this.tellNeutralMobsThatIDied(); } @@ -558,7 +558,7 @@ LivingEntity killCredit = this.getKillCredit(); if (killCredit != null) { this.awardStat(Stats.ENTITY_KILLED_BY.get(killCredit.getType())); -@@ -950,10 +_,10 @@ +@@ -949,10 +_,10 @@ if (entity != this) { super.awardKillScore(entity, damageSource); Scoreboard scoreboard = this.level().getScoreboard(); @@ -571,7 +571,7 @@ } else { this.awardStat(Stats.MOB_KILLS); } -@@ -965,12 +_,11 @@ +@@ -964,12 +_,11 @@ } private void handleTeamKill(ScoreHolder scoreHolder, ScoreHolder teamMember, ObjectiveCriteria[] criteria) { @@ -586,7 +586,7 @@ } } } -@@ -981,9 +_,20 @@ +@@ -980,9 +_,20 @@ return false; } else { Entity entity = damageSource.getEntity(); @@ -609,7 +609,7 @@ } } -@@ -993,25 +_,95 @@ +@@ -992,25 +_,95 @@ } private boolean isPvpAllowed() { @@ -713,7 +713,7 @@ } public boolean isReceivingWaypoints() { -@@ -1046,14 +_,16 @@ +@@ -1045,14 +_,16 @@ && (flag || blockState.getValue(RespawnAnchorBlock.CHARGE) > 0) && RespawnAnchorBlock.canSetSpawn(level, blockPos)) { Optional optional = RespawnAnchorBlock.findStandUpPosition(EntityType.PLAYER, level, blockPos); @@ -733,7 +733,7 @@ } else if (!flag) { return Optional.empty(); } else { -@@ -1061,7 +_,7 @@ +@@ -1060,7 +_,7 @@ BlockState blockState1 = level.getBlockState(blockPos.above()); boolean isPossibleToRespawnInThis1 = blockState1.getBlock().isPossibleToRespawnInThis(blockState1); return isPossibleToRespawnInThis && isPossibleToRespawnInThis1 @@ -742,7 +742,7 @@ : Optional.empty(); } } -@@ -1078,6 +_,7 @@ +@@ -1077,6 +_,7 @@ @Override public @Nullable ServerPlayer teleport(TeleportTransition teleportTransition) { @@ -750,7 +750,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1087,13 +_,48 @@ +@@ -1086,13 +_,48 @@ ServerLevel level = teleportTransition.newLevel(); ServerLevel serverLevel = this.level(); @@ -802,7 +802,7 @@ this.connection.resetPosition(); teleportTransition.postTeleportTransition().onTransition(this); return this; -@@ -1104,18 +_,19 @@ +@@ -1103,18 +_,19 @@ this.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); PlayerList playerList = this.server.getPlayerList(); playerList.sendPlayerPermissionLevel(this); @@ -824,7 +824,7 @@ this.connection.resetPosition(); level.addDuringTeleport(this); profilerFiller.pop(); -@@ -1130,6 +_,15 @@ +@@ -1129,6 +_,15 @@ this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(teleportTransition, serverLevel); @@ -840,7 +840,7 @@ return this; } } -@@ -1144,12 +_,26 @@ +@@ -1143,12 +_,26 @@ public void triggerDimensionChangeTriggers(ServerLevel level) { ResourceKey resourceKey = level.dimension(); ResourceKey resourceKey1 = this.level().dimension(); @@ -870,7 +870,7 @@ this.enteredNetherPosition = null; } } -@@ -1165,9 +_,8 @@ +@@ -1164,9 +_,8 @@ this.containerMenu.broadcastChanges(); } @@ -882,7 +882,7 @@ if (!this.isSleeping() && this.isAlive()) { BedRule bedRule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, bedPos); boolean canSleep = bedRule.canSleep(this.level()); -@@ -1181,7 +_,7 @@ +@@ -1180,7 +_,7 @@ } else { if (canSetSpawn) { this.setRespawnPosition( @@ -891,7 +891,7 @@ ); } -@@ -1203,7 +_,37 @@ +@@ -1202,7 +_,37 @@ } } @@ -930,7 +930,7 @@ this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1213,10 +_,7 @@ +@@ -1212,10 +_,7 @@ this.level().updateSleepingPlayerList(); return either; @@ -941,7 +941,7 @@ } } -@@ -1242,21 +_,29 @@ +@@ -1241,21 +_,29 @@ @Override public void stopSleepInBed(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) { @@ -974,7 +974,7 @@ } @Override -@@ -1304,8 +_,9 @@ +@@ -1303,8 +_,9 @@ this.connection.send(new ClientboundShowDialogPacket(dialog)); } @@ -985,7 +985,7 @@ } @Override -@@ -1313,12 +_,39 @@ +@@ -1312,12 +_,39 @@ if (menu == null) { return OptionalInt.empty(); } else { @@ -1026,7 +1026,7 @@ if (abstractContainerMenu == null) { if (this.isSpectator()) { this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true); -@@ -1326,10 +_,14 @@ +@@ -1325,10 +_,14 @@ return OptionalInt.empty(); } else { @@ -1043,7 +1043,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1342,14 +_,25 @@ +@@ -1341,14 +_,25 @@ @Override public void openHorseInventory(AbstractHorse horse, Container inventory) { @@ -1072,7 +1072,7 @@ this.initMenu(this.containerMenu); } -@@ -1371,10 +_,30 @@ +@@ -1370,10 +_,30 @@ @Override public void closeContainer() { @@ -1103,7 +1103,7 @@ @Override public void doCloseContainer() { this.containerMenu.removed(this); -@@ -1397,19 +_,19 @@ +@@ -1396,19 +_,19 @@ int rounded = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); if (rounded > 0) { this.awardStat(Stats.SWIM_ONE_CM, rounded); @@ -1126,7 +1126,7 @@ } } else if (this.onClimbable()) { if (dy > 0.0) { -@@ -1420,13 +_,13 @@ +@@ -1419,13 +_,13 @@ if (rounded > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, rounded); @@ -1143,7 +1143,7 @@ } } } else if (this.isFallFlying()) { -@@ -1470,13 +_,13 @@ +@@ -1469,13 +_,13 @@ @Override public void awardStat(Stat stat, int amount) { this.stats.increment(this, stat, amount); @@ -1159,7 +1159,7 @@ } @Override -@@ -1507,9 +_,9 @@ +@@ -1506,9 +_,9 @@ super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1171,7 +1171,7 @@ } } -@@ -1524,6 +_,13 @@ +@@ -1523,6 +_,13 @@ public void disconnect() { this.disconnected = true; this.ejectPassengers(); @@ -1185,7 +1185,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, false); } -@@ -1535,6 +_,7 @@ +@@ -1534,6 +_,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1193,7 +1193,7 @@ } @Override -@@ -1569,12 +_,12 @@ +@@ -1568,12 +_,12 @@ this.onUpdateAbilities(); if (keepEverything) { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1208,7 +1208,7 @@ } this.getInventory().replaceWith(that.getInventory()); -@@ -1585,7 +_,7 @@ +@@ -1584,7 +_,7 @@ this.portalProcess = that.portalProcess; } else { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1217,7 +1217,7 @@ if (this.level().getGameRules().get(GameRules.KEEP_INVENTORY) || that.isSpectator()) { this.getInventory().replaceWith(that.getInventory()); this.experienceLevel = that.experienceLevel; -@@ -1601,7 +_,7 @@ +@@ -1600,7 +_,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1226,7 +1226,7 @@ this.seenCredits = that.seenCredits; this.enteredNetherPosition = that.enteredNetherPosition; this.chunkTrackingView = that.chunkTrackingView; -@@ -1644,9 +_,22 @@ +@@ -1643,9 +_,22 @@ CriteriaTriggers.EFFECTS_CHANGED.trigger(this, null); } @@ -1250,7 +1250,7 @@ } @Override -@@ -1655,7 +_,7 @@ +@@ -1654,7 +_,7 @@ } @Override @@ -1259,7 +1259,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, true); } -@@ -1664,7 +_,7 @@ +@@ -1663,7 +_,7 @@ this.setCamera(this); } @@ -1268,7 +1268,7 @@ if (flag) { this.setYHeadRot(relativeMovements.contains(Relative.Y_ROT) ? this.getYHeadRot() + yaw : yaw); this.connection.resetFlyingTicks(); -@@ -1703,9 +_,18 @@ +@@ -1702,9 +_,18 @@ } public boolean setGameMode(GameType gameMode) { @@ -1289,7 +1289,7 @@ } else { this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, gameMode.getId())); if (gameMode == GameType.SPECTATOR) { -@@ -1721,7 +_,7 @@ +@@ -1720,7 +_,7 @@ this.onUpdateAbilities(); this.updateEffectVisibility(); @@ -1298,7 +1298,7 @@ } } -@@ -1776,8 +_,13 @@ +@@ -1775,8 +_,13 @@ } public void sendChatMessage(OutgoingChatMessage message, boolean filtered, ChatType.Bound boundChatType) { @@ -1313,7 +1313,7 @@ } } -@@ -1788,7 +_,42 @@ +@@ -1787,7 +_,42 @@ } public void updateOptions(ClientInformation clientInformation) { @@ -1324,7 +1324,7 @@ + map.put(com.destroystokyo.paper.ClientOption.CHAT_VISIBILITY, com.destroystokyo.paper.ClientOption.ChatVisibility.valueOf(clientInformation.chatVisibility().name())); + map.put(com.destroystokyo.paper.ClientOption.CHAT_COLORS_ENABLED, clientInformation.chatColors()); + map.put(com.destroystokyo.paper.ClientOption.SKIN_PARTS, new com.destroystokyo.paper.PaperSkinParts(clientInformation.modelCustomisation())); -+ map.put(com.destroystokyo.paper.ClientOption.MAIN_HAND, clientInformation.mainHand() == HumanoidArm.LEFT ? org.bukkit.inventory.MainHand.LEFT : org.bukkit.inventory.MainHand.RIGHT); ++ map.put(com.destroystokyo.paper.ClientOption.MAIN_HAND, clientInformation.mainHand() == net.minecraft.world.entity.HumanoidArm.LEFT ? org.bukkit.inventory.MainHand.LEFT : org.bukkit.inventory.MainHand.RIGHT); + map.put(com.destroystokyo.paper.ClientOption.TEXT_FILTERING_ENABLED, clientInformation.textFilteringEnabled()); + map.put(com.destroystokyo.paper.ClientOption.ALLOW_SERVER_LISTINGS, clientInformation.allowsListing()); + map.put(com.destroystokyo.paper.ClientOption.PARTICLE_VISIBILITY, com.destroystokyo.paper.ClientOption.ParticleVisibility.valueOf(clientInformation.particleStatus().name())); @@ -1334,7 +1334,7 @@ + if (this.getMainArm() != clientInformation.mainHand()) { + org.bukkit.event.player.PlayerChangedMainHandEvent event = new org.bukkit.event.player.PlayerChangedMainHandEvent( + this.getBukkitEntity(), -+ clientInformation.mainHand() == HumanoidArm.LEFT ? org.bukkit.inventory.MainHand.LEFT : org.bukkit.inventory.MainHand.RIGHT ++ clientInformation.mainHand() == net.minecraft.world.entity.HumanoidArm.LEFT ? org.bukkit.inventory.MainHand.LEFT : org.bukkit.inventory.MainHand.RIGHT + ); + this.server.server.getPluginManager().callEvent(event); + } @@ -1356,7 +1356,7 @@ this.requestedViewDistance = clientInformation.viewDistance(); this.chatVisibility = clientInformation.chatVisibility(); this.canChatColor = clientInformation.chatColors(); -@@ -1874,8 +_,23 @@ +@@ -1872,8 +_,23 @@ Entity camera = this.getCamera(); this.camera = (Entity)(entityToSpectate == null ? this : entityToSpectate); if (camera != this.camera) { @@ -1381,7 +1381,7 @@ } if (entityToSpectate != null) { -@@ -1908,11 +_,11 @@ +@@ -1906,11 +_,11 @@ } public @Nullable Component getTabListDisplayName() { @@ -1395,7 +1395,7 @@ } @Override -@@ -1942,11 +_,62 @@ +@@ -1940,11 +_,62 @@ } public void setRespawnPosition(ServerPlayer.@Nullable RespawnConfig respawnConfig, boolean displayInChat) { @@ -1460,7 +1460,7 @@ } public SectionPos getLastSectionPos() { -@@ -1976,16 +_,23 @@ +@@ -1974,16 +_,23 @@ } @Override @@ -1489,7 +1489,7 @@ return itemEntity; } -@@ -2106,9 +_,9 @@ +@@ -2108,9 +_,9 @@ } @Override @@ -1501,7 +1501,7 @@ if (vehicle instanceof LivingEntity livingEntity) { for (MobEffectInstance mobEffectInstance : livingEntity.getActiveEffects()) { this.connection.send(new ClientboundRemoveMobEffectPacket(vehicle.getId(), mobEffectInstance.getEffect())); -@@ -2224,7 +_,7 @@ +@@ -2232,7 +_,7 @@ } public static long placeEnderPearlTicket(ServerLevel level, ChunkPos pos) { @@ -1510,7 +1510,7 @@ return TicketType.ENDER_PEARL.timeout(); } -@@ -2254,9 +_,11 @@ +@@ -2262,9 +_,11 @@ } } @@ -1525,7 +1525,7 @@ } private static float calculateLookAtYaw(Vec3 position, BlockPos towardsPos) { -@@ -2276,4 +_,135 @@ +@@ -2284,4 +_,135 @@ ); public static final ServerPlayer.SavedPosition EMPTY = new ServerPlayer.SavedPosition(Optional.empty(), Optional.empty(), Optional.empty()); } diff --git a/paper-server/patches/sources/net/minecraft/server/level/progress/LoggingLevelLoadListener.java.patch b/paper-server/patches/sources/net/minecraft/server/level/progress/LoggingLevelLoadListener.java.patch index 2fde9483e16e..f935b67dc439 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/progress/LoggingLevelLoadListener.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/progress/LoggingLevelLoadListener.java.patch @@ -31,14 +31,14 @@ case PREPARE_GLOBAL_SPAWN: + // Paper start - log dimension + if (this.level != null) { -+ LOGGER.info("Selecting spawn point for world '{}'...", this.level.dimension().location()); ++ LOGGER.info("Selecting spawn point for world '{}'...", this.level.dimension().identifier()); + } else { LOGGER.info("Selecting global world spawn..."); + } break; case LOAD_INITIAL_CHUNKS: + if (this.level != null) { -+ LOGGER.info("Loading {} persistent chunks for world '{}'...", totalChunks, this.level.dimension().location()); ++ LOGGER.info("Loading {} persistent chunks for world '{}'...", totalChunks, this.level.dimension().identifier()); + } else { LOGGER.info("Loading {} persistent chunks...", totalChunks); + } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch index b3ea5ea045c8..0f41a4c322e1 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch @@ -19,7 +19,7 @@ + // CraftBukkit end + public final java.util.Map packCallbacks = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - adventure resource pack callbacks + private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit -+ protected static final net.minecraft.resources.ResourceLocation MINECRAFT_BRAND = net.minecraft.resources.ResourceLocation.withDefaultNamespace("brand"); // Paper - Brand support ++ protected static final net.minecraft.resources.Identifier MINECRAFT_BRAND = net.minecraft.resources.Identifier.withDefaultNamespace("brand"); // Paper - Brand support + // Paper start - retain certain values + public @Nullable String playerBrand; + public final java.util.Set pluginMessagerChannels; @@ -60,8 +60,8 @@ } + // Paper start -+ public static final net.minecraft.resources.ResourceLocation CUSTOM_REGISTER = net.minecraft.resources.ResourceLocation.withDefaultNamespace("register"); -+ private static final net.minecraft.resources.ResourceLocation CUSTOM_UNREGISTER = net.minecraft.resources.ResourceLocation.withDefaultNamespace("unregister"); ++ public static final net.minecraft.resources.Identifier CUSTOM_REGISTER = net.minecraft.resources.Identifier.withDefaultNamespace("register"); ++ private static final net.minecraft.resources.Identifier CUSTOM_UNREGISTER = net.minecraft.resources.Identifier.withDefaultNamespace("unregister"); + // Paper end + @Override @@ -73,7 +73,7 @@ + + net.minecraft.network.protocol.PacketUtils.ensureRunningOnSameThread(packet, this, this.server.packetProcessor()); + -+ final net.minecraft.resources.ResourceLocation identifier = packet.payload().type().id(); ++ final net.minecraft.resources.Identifier identifier = packet.payload().type().id(); + final byte[] data = discardedPayload.data(); + try { + final boolean registerChannel = CUSTOM_REGISTER.equals(identifier); diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index ff1d12a0da50..4e550a00dc5b 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -2312,7 +2312,7 @@ } + // Paper start - Add PlayerRecipeBookClickEvent -+ NamespacedKey recipeName = org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(recipeHolder.id().location()); ++ NamespacedKey recipeName = org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(recipeHolder.id().identifier()); + boolean makeAll = packet.useMaxItems(); + com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent paperEvent = new com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent( + this.player.getBukkitEntity(), recipeName, makeAll diff --git a/paper-server/patches/sources/net/minecraft/server/packs/PathPackResources.java.patch b/paper-server/patches/sources/net/minecraft/server/packs/PathPackResources.java.patch index f6f98c34221e..95ae2eebfd30 100644 --- a/paper-server/patches/sources/net/minecraft/server/packs/PathPackResources.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/packs/PathPackResources.java.patch @@ -10,6 +10,6 @@ + continue; + } + // Paper end - Improve logging and errors - if (ResourceLocation.isValidNamespace(string)) { + if (Identifier.isValidNamespace(string)) { set.add(string); } else { diff --git a/paper-server/patches/sources/net/minecraft/server/packs/repository/ServerPacksSource.java.patch b/paper-server/patches/sources/net/minecraft/server/packs/repository/ServerPacksSource.java.patch index 599949c60b3e..dbb1f23f29a0 100644 --- a/paper-server/patches/sources/net/minecraft/server/packs/repository/ServerPacksSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/packs/repository/ServerPacksSource.java.patch @@ -5,7 +5,7 @@ return new VanillaPackResourcesBuilder() .setMetadata(BUILT_IN_METADATA) - .exposeNamespace("minecraft") -+ .exposeNamespace("minecraft", ResourceLocation.PAPER_NAMESPACE) // Paper ++ .exposeNamespace("minecraft", Identifier.PAPER_NAMESPACE) // Paper .applyDevelopmentConfig() .pushJarResources() .build(VANILLA_PACK_INFO); diff --git a/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch b/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch index 71d760f9fd73..5b95b1fbe6b1 100644 --- a/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch +++ b/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/stats/ServerStatsCounter.java +++ b/net/minecraft/stats/ServerStatsCounter.java -@@ -74,9 +_,21 @@ +@@ -75,9 +_,21 @@ LOGGER.error("Couldn't parse statistics file {}", file, var9); } } @@ -9,8 +9,8 @@ + // Disables saving any forced stats, so it stays at the same value (without enabling disableStatSaving) + // Fixes stat initialization to not cause a NullPointerException + // Spigot start -+ for (Map.Entry entry : org.spigotmc.SpigotConfig.forcedStats.entrySet()) { -+ Stat wrapper = Stats.CUSTOM.get(java.util.Objects.requireNonNull(BuiltInRegistries.CUSTOM_STAT.getValue(entry.getKey()))); // Paper - ensured by SpigotConfig#stats ++ for (Map.Entry entry : org.spigotmc.SpigotConfig.forcedStats.entrySet()) { ++ Stat wrapper = Stats.CUSTOM.get(java.util.Objects.requireNonNull(BuiltInRegistries.CUSTOM_STAT.getValue(entry.getKey()))); // Paper - ensured by SpigotConfig#stats + this.stats.put(wrapper, entry.getValue().intValue()); + } + // Spigot end @@ -19,15 +19,15 @@ public void save() { + if (org.spigotmc.SpigotConfig.disableStatSaving) return; // Spigot - try (Writer bufferedWriter = Files.newBufferedWriter(this.file, StandardCharsets.UTF_8)) { - GSON.toJson(this.toJson(), GSON.newJsonWriter(bufferedWriter)); - } catch (JsonIOException | IOException var6) { -@@ -86,6 +_,8 @@ + try { + FileUtil.createDirectoriesSafe(this.file.getParent()); + +@@ -91,6 +_,8 @@ @Override public void setValue(Player player, Stat stat, int value) { + if (org.spigotmc.SpigotConfig.disableStatSaving) return; // Spigot -+ if (stat.getType() == Stats.CUSTOM && stat.getValue() instanceof final net.minecraft.resources.ResourceLocation key && org.spigotmc.SpigotConfig.forcedStats.get(key) != null) return; // Paper - disable saving forced stats ++ if (stat.getType() == Stats.CUSTOM && stat.getValue() instanceof final net.minecraft.resources.Identifier key && org.spigotmc.SpigotConfig.forcedStats.get(key) != null) return; // Paper - disable saving forced stats super.setValue(player, stat, value); this.dirty.add(stat); } diff --git a/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch b/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch index 560d7e591da7..482a0e180c8e 100644 --- a/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch +++ b/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch @@ -4,12 +4,12 @@ return list.isEmpty() ? Either.right(List.copyOf(set)) : Either.left(list); } -- public Map> build(Map> builders) { +- public Map> build(Map> builders) { + // Paper start - fire tag registrar events -+ public Map> build(Map> builders, io.papermc.paper.tag.@Nullable TagEventConfig eventConfig) { ++ public Map> build(Map> builders, io.papermc.paper.tag.@Nullable TagEventConfig eventConfig) { + builders = io.papermc.paper.tag.PaperTagListenerManager.INSTANCE.firePreFlattenEvent(builders, eventConfig); + // Paper end - final Map> map = new HashMap<>(); + final Map> map = new HashMap<>(); TagEntry.Lookup lookup = new TagEntry.Lookup() { @Override @@ -112,7 +_,7 @@ @@ -48,7 +48,7 @@ TagLoader> tagLoader = new TagLoader<>(TagLoader.ElementLookup.fromWritableRegistry(registry), Registries.tagsDirPath(resourceKey)); - tagLoader.build(tagLoader.load(resourceManager)) + tagLoader.build(tagLoader.load(resourceManager), io.papermc.paper.tag.PaperTagListenerManager.INSTANCE.createEventConfig(registry, cause)) // Paper - tag lifecycle - add registrar event cause - .forEach((resourceLocation, list) -> registry.bindTag(TagKey.create(resourceKey, resourceLocation), (List>)list)); + .forEach((identifier, list) -> registry.bindTag(TagKey.create(resourceKey, identifier), (List>)list)); } @@ -137,12 +_,12 @@ diff --git a/paper-server/patches/sources/net/minecraft/Util.java.patch b/paper-server/patches/sources/net/minecraft/util/Util.java.patch similarity index 68% rename from paper-server/patches/sources/net/minecraft/Util.java.patch rename to paper-server/patches/sources/net/minecraft/util/Util.java.patch index 4e46d661ba26..6d881e9e7204 100644 --- a/paper-server/patches/sources/net/minecraft/Util.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/Util.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/Util.java -+++ b/net/minecraft/Util.java -@@ -90,9 +_,25 @@ +--- a/net/minecraft/util/Util.java ++++ b/net/minecraft/util/Util.java +@@ -95,9 +_,25 @@ private static final int DEFAULT_MAX_THREADS = 255; private static final int DEFAULT_SAFE_FILE_OPERATION_RETRIES = 10; private static final String MAX_THREADS_SYSTEM_PROPERTY = "max.bg.threads"; @@ -28,7 +28,7 @@ private static final DateTimeFormatter FILENAME_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss", Locale.ROOT); public static final int LINEAR_LOOKUP_THRESHOLD = 8; private static final Set ALLOWED_UNTRUSTED_LINK_PROTOCOLS = Set.of("http", "https"); -@@ -111,6 +_,7 @@ +@@ -116,6 +_,7 @@ .findFirst() .orElseThrow(() -> new IllegalStateException("No jar file system provider found")); private static Consumer thePauser = string -> {}; @@ -36,7 +36,7 @@ public static Collector, ?, Map> toMap() { return Collectors.toMap(Entry::getKey, Entry::getValue); -@@ -133,7 +_,7 @@ +@@ -138,7 +_,7 @@ } public static long getNanos() { @@ -45,7 +45,7 @@ } public static long getEpochMillis() { -@@ -144,9 +_,10 @@ +@@ -149,9 +_,10 @@ return FILENAME_DATE_TIME_FORMATTER.format(ZonedDateTime.now()); } @@ -58,7 +58,7 @@ if (i <= 0) { directExecutorService = MoreExecutors.newDirectExecutorService(); } else { -@@ -171,16 +_,30 @@ +@@ -176,16 +_,30 @@ super.onTermination(throwOnTermination); } }; @@ -91,11 +91,10 @@ } private static int getMaxThreads() { -@@ -230,6 +_,21 @@ - return thread; +@@ -236,6 +_,21 @@ })); } -+ + + // Paper start - Separate dimension data IO pool + private static TracingExecutor makeExtraIoExecutor(String namePrefix) { + AtomicInteger atomicInteger = new AtomicInteger(1); @@ -110,6 +109,87 @@ + })); + } + // Paper end - Separate dimension data IO pool - ++ public static void throwAsRuntime(Throwable throwable) { throw throwable instanceof RuntimeException ? (RuntimeException)throwable : new RuntimeException(throwable); + } +@@ -302,6 +_,19 @@ + return input -> true; + } + ++ @SafeVarargs ++ public static Predicate allOf(Predicate... predicates) { ++ return input -> { ++ for (Predicate predicate : predicates) { ++ if (!predicate.test(input)) { ++ return false; ++ } ++ } ++ ++ return true; ++ }; ++ } ++ + public static Predicate allOf(Predicate predicate) { + return (Predicate)predicate; + } +@@ -330,19 +_,6 @@ + return input -> predicate1.test(input) && predicate2.test(input) && predicate3.test(input) && predicate4.test(input) && predicate5.test(input); + } + +- @SafeVarargs +- public static Predicate allOf(Predicate... predicates) { +- return input -> { +- for (Predicate predicate : predicates) { +- if (!predicate.test(input)) { +- return false; +- } +- } +- +- return true; +- }; +- } +- + public static Predicate allOf(List> predicates) { + return switch (predicates.size()) { + case 0 -> allOf(); +@@ -373,6 +_,19 @@ + return input -> false; + } + ++ @SafeVarargs ++ public static Predicate anyOf(Predicate... predicates) { ++ return input -> { ++ for (Predicate predicate : predicates) { ++ if (predicate.test(input)) { ++ return true; ++ } ++ } ++ ++ return false; ++ }; ++ } ++ + public static Predicate anyOf(Predicate predicate) { + return (Predicate)predicate; + } +@@ -399,19 +_,6 @@ + Predicate predicate5 + ) { + return input -> predicate1.test(input) || predicate2.test(input) || predicate3.test(input) || predicate4.test(input) || predicate5.test(input); +- } +- +- @SafeVarargs +- public static Predicate anyOf(Predicate... predicates) { +- return input -> { +- for (Predicate predicate : predicates) { +- if (predicate.test(input)) { +- return true; +- } +- } +- +- return false; +- }; + } + + public static Predicate anyOf(List> predicates) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch index b59473d204dc..8620f51ebb1f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -126,7 +126,7 @@ private EntityDimensions dimensions; @@ -278,6 +_,7 @@ public boolean hasVisualFire; - private Vec3 lastKnownMovement = Vec3.ZERO; + private Vec3 lastKnownSpeed = Vec3.ZERO; private @Nullable Vec3 lastKnownPosition; + public net.kyori.adventure.util.TriState visualFire = net.kyori.adventure.util.TriState.NOT_SET; // Paper - improve visual fire API private @Nullable BlockState inBlockState = null; @@ -348,7 +348,7 @@ } protected final AABB makeBoundingBox() { -@@ -479,12 +_,28 @@ +@@ -480,12 +_,28 @@ } public void tick() { @@ -374,10 +374,10 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("entityBaseTick"); + if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Prevent entity loading causing async lookups - if (this.lastKnownPosition == null) { - this.lastKnownPosition = this.position(); - } -@@ -501,7 +_,7 @@ + this.computeSpeed(); + this.inBlockState = null; + if (this.isPassenger() && this.getVehicle().isRemoved()) { +@@ -496,7 +_,7 @@ this.boardingCooldown--; } @@ -386,7 +386,7 @@ if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -529,6 +_,10 @@ +@@ -524,6 +_,10 @@ if (this.isInLava()) { this.fallDistance *= 0.5; @@ -397,7 +397,7 @@ } this.checkBelowWorld(); -@@ -545,11 +_,16 @@ +@@ -549,11 +_,16 @@ } public void setSharedFlagOnFire(boolean isOnFire) { @@ -416,7 +416,7 @@ this.onBelowWorld(); } } -@@ -577,15 +_,41 @@ +@@ -581,15 +_,41 @@ } public void lavaIgnite() { @@ -460,7 +460,7 @@ && this.shouldPlayLavaHurtSound() && !this.isSilent()) { serverLevel.playSound( -@@ -600,6 +_,20 @@ +@@ -604,6 +_,20 @@ } public final void igniteForSeconds(float seconds) { @@ -481,7 +481,7 @@ this.igniteForTicks(Mth.floor(seconds * 20.0F)); } -@@ -624,7 +_,7 @@ +@@ -628,7 +_,7 @@ } protected void onBelowWorld() { @@ -490,7 +490,7 @@ } public boolean isFree(double x, double y, double z) { -@@ -680,7 +_,28 @@ +@@ -684,7 +_,28 @@ return this.onGround; } @@ -519,7 +519,7 @@ if (this.noPhysics) { this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); this.horizontalCollision = false; -@@ -763,6 +_,27 @@ +@@ -767,6 +_,27 @@ block.updateEntityMovementAfterFallOn(this.level(), this); } } @@ -547,7 +547,7 @@ if (!this.level().isClientSide() || this.isLocalInstanceAuthoritative()) { Entity.MovementEmission movementEmission = this.getMovementEmission(); -@@ -776,6 +_,13 @@ +@@ -780,6 +_,13 @@ profilerFiller.pop(); } } @@ -561,7 +561,7 @@ } private void applyMovementEmissionAndPlaySound(Entity.MovementEmission movementEmission, Vec3 movement, BlockPos pos, BlockState state) { -@@ -957,7 +_,7 @@ +@@ -961,7 +_,7 @@ } protected BlockPos getOnPos(float yOffset) { @@ -570,7 +570,7 @@ BlockPos blockPos = this.mainSupportingBlockPos.get(); if (!(yOffset > 1.0E-5F)) { return blockPos; -@@ -1212,7 +_,7 @@ +@@ -1216,7 +_,7 @@ if (flag2) { try { boolean flag4 = flag || aabb.intersects(pos); @@ -579,7 +579,7 @@ blockState.entityInside(this.level(), pos, this, stepBasedCollector, flag4); this.onInsideBlock(blockState); } catch (Throwable var20) { -@@ -1226,7 +_,7 @@ +@@ -1230,7 +_,7 @@ } if (flag3) { @@ -588,7 +588,7 @@ blockState.getFluidState().entityInside(this.level(), pos, this, stepBasedCollector); } -@@ -1662,6 +_,7 @@ +@@ -1666,6 +_,7 @@ this.setXRot(Mth.clamp(xRot, -90.0F, 90.0F) % 360.0F); this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); @@ -596,7 +596,7 @@ } public void absSnapTo(double x, double y, double z) { -@@ -1671,6 +_,7 @@ +@@ -1675,6 +_,7 @@ this.yo = y; this.zo = d1; this.setPos(d, y, d1); @@ -604,7 +604,7 @@ } public void snapTo(Vec3 pos) { -@@ -1695,6 +_,7 @@ +@@ -1699,6 +_,7 @@ this.setXRot(xRot); this.setOldPosAndRot(); this.reapplyPosition(); @@ -612,7 +612,7 @@ } public final void setOldPosAndRot() { -@@ -1761,6 +_,7 @@ +@@ -1765,6 +_,7 @@ public void push(Entity entity) { if (!this.isPassengerOfSameVehicle(entity)) { if (!entity.noPhysics && !this.noPhysics) { @@ -620,30 +620,32 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double max = Mth.absMax(d, d1); -@@ -1794,7 +_,21 @@ - } +@@ -1801,7 +_,23 @@ public void push(double x, double y, double z) { -- this.setDeltaMovement(this.getDeltaMovement().add(x, y, z)); -+ // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent -+ this.push(x, y, z, null); + if (Double.isFinite(x) && Double.isFinite(y) && Double.isFinite(z)) { +- this.setDeltaMovement(this.getDeltaMovement().add(x, y, z)); ++ // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent ++ this.push(x, y, z, null); ++ } + } + + public void push(double x, double y, double z, @Nullable Entity pushingEntity) { -+ org.bukkit.util.Vector delta = new org.bukkit.util.Vector(x, y, z); -+ if (pushingEntity != null) { -+ io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent event = new io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent(this.getBukkitEntity(), io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.PUSH, pushingEntity.getBukkitEntity(), delta); -+ if (!event.callEvent()) { -+ return; ++ { ++ org.bukkit.util.Vector delta = new org.bukkit.util.Vector(x, y, z); ++ if (pushingEntity != null) { ++ io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent event = new io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent(this.getBukkitEntity(), io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.PUSH, pushingEntity.getBukkitEntity(), delta); ++ if (!event.callEvent()) { ++ return; ++ } ++ delta = event.getKnockback(); + } -+ delta = event.getKnockback(); -+ } -+ this.setDeltaMovement(this.getDeltaMovement().add(delta.getX(), delta.getY(), delta.getZ())); -+ // Paper end - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent - this.hasImpulse = true; ++ this.setDeltaMovement(this.getDeltaMovement().add(delta.getX(), delta.getY(), delta.getZ())); ++ // Paper end - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent + this.needsSync = true; + } } - -@@ -1901,8 +_,20 @@ +@@ -1909,8 +_,20 @@ } public boolean isPushable() { @@ -664,7 +666,7 @@ public void awardKillScore(Entity entity, DamageSource damageSource) { if (entity instanceof ServerPlayer) { -@@ -1929,15 +_,23 @@ +@@ -1937,15 +_,23 @@ } public boolean saveAsPassenger(ValueOutput output) { @@ -692,7 +694,7 @@ return true; } } -@@ -1948,14 +_,35 @@ +@@ -1956,14 +_,35 @@ } public void saveWithoutId(ValueOutput output) { @@ -728,7 +730,7 @@ output.store("Rotation", Vec2.CODEC, new Vec2(this.getYRot(), this.getXRot())); output.putDouble("fall_distance", this.fallDistance); output.putShort("Fire", (short)this.remainingFireTicks); -@@ -1963,7 +_,29 @@ +@@ -1971,7 +_,29 @@ output.putBoolean("OnGround", this.onGround()); output.putBoolean("Invulnerable", this.invulnerable); output.putInt("PortalCooldown", this.portalCooldown); @@ -758,7 +760,7 @@ output.storeNullable("CustomName", ComponentSerialization.CODEC, this.getCustomName()); if (this.isCustomNameVisible()) { output.putBoolean("CustomNameVisible", this.isCustomNameVisible()); -@@ -1986,9 +_,12 @@ +@@ -1994,9 +_,12 @@ output.putInt("TicksFrozen", this.getTicksFrozen()); } @@ -773,7 +775,7 @@ if (!this.tags.isEmpty()) { output.store("Tags", TAG_LIST_CODEC, List.copyOf(this.tags)); -@@ -1998,13 +_,13 @@ +@@ -2006,13 +_,13 @@ output.store("data", CustomData.CODEC, this.customData); } @@ -789,7 +791,7 @@ valueOutputList.discardLast(); } } -@@ -2013,6 +_,34 @@ +@@ -2021,6 +_,34 @@ output.discard("Passengers"); } } @@ -824,7 +826,7 @@ } catch (Throwable var7) { CrashReport crashReport = CrashReport.forThrowable(var7, "Saving entity NBT"); CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being saved"); -@@ -2024,7 +_,7 @@ +@@ -2032,7 +_,7 @@ public void load(ValueInput input) { try { Vec3 vec3 = input.read("Pos", Vec3.CODEC).orElse(Vec3.ZERO); @@ -832,8 +834,8 @@ + Vec3 vec31 = input.read("Motion", Vec3.CODEC).orElse(Vec3.ZERO); vec31 = io.papermc.paper.util.MCUtil.sanitizeNanInf(vec31, 0D); // Paper - avoid setting NaN values Vec2 vec2 = input.read("Rotation", Vec2.CODEC).orElse(Vec2.ZERO); this.setDeltaMovement(Math.abs(vec31.x) > 10.0 ? 0.0 : vec31.x, Math.abs(vec31.y) > 10.0 ? 0.0 : vec31.y, Math.abs(vec31.z) > 10.0 ? 0.0 : vec31.z); - this.hasImpulse = true; -@@ -2056,7 +_,20 @@ + this.needsSync = true; +@@ -2064,7 +_,20 @@ this.setNoGravity(input.getBooleanOr("NoGravity", false)); this.setGlowingTag(input.getBooleanOr("Glowing", false)); this.setTicksFrozen(input.getIntOr("TicksFrozen", 0)); @@ -855,7 +857,7 @@ this.customData = input.read("data", CustomData.CODEC).orElse(CustomData.EMPTY); this.tags.clear(); input.read("Tags", TAG_LIST_CODEC).ifPresent(this.tags::addAll); -@@ -2067,6 +_,59 @@ +@@ -2075,6 +_,59 @@ } else { throw new IllegalStateException("Entity has invalid rotation"); } @@ -915,7 +917,7 @@ } catch (Throwable var7) { CrashReport crashReport = CrashReport.forThrowable(var7, "Loading entity NBT"); CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being loaded"); -@@ -2080,13 +_,24 @@ +@@ -2088,13 +_,24 @@ } public final @Nullable String getEncodeId() { @@ -925,7 +927,7 @@ + public final @Nullable String getEncodeId(boolean includeNonSaveable) { + // Paper end - Raw entity serialization API EntityType type = this.getType(); - ResourceLocation key = EntityType.getKey(type); + Identifier key = EntityType.getKey(type); - return !type.canSerialize() ? null : key.toString(); + return (type.canSerialize() || includeNonSaveable) ? key.toString() : null; // Paper - Raw entity serialization API } @@ -941,7 +943,7 @@ protected abstract void addAdditionalSaveData(ValueOutput output); public @Nullable ItemEntity spawnAtLocation(ServerLevel level, ItemLike item) { -@@ -2098,11 +_,60 @@ +@@ -2106,11 +_,60 @@ } public @Nullable ItemEntity spawnAtLocation(ServerLevel level, ItemStack stack, Vec3 offset) { @@ -1004,7 +1006,7 @@ level.addFreshEntity(itemEntity); return itemEntity; } -@@ -2147,6 +_,15 @@ +@@ -2155,6 +_,15 @@ for (Leashable leashable1 : list) { if (leashable1.canHaveALeashAttachedTo(this)) { @@ -1020,7 +1022,7 @@ leashable1.setLeashedTo(this, true); flag = true; } -@@ -2161,7 +_,7 @@ +@@ -2169,7 +_,7 @@ } ItemStack itemInHand = player.getItemInHand(hand); @@ -1029,7 +1031,7 @@ itemInHand.hurtAndBreak(1, player, hand); return InteractionResult.SUCCESS; } else if (this instanceof Mob mob -@@ -2174,11 +_,13 @@ +@@ -2182,11 +_,13 @@ if (this.isAlive() && this instanceof Leashable leashable2) { if (leashable2.getLeashHolder() == player) { if (!this.level().isClientSide()) { @@ -1047,9 +1049,9 @@ this.gameEvent(GameEvent.ENTITY_INTERACT, player); this.playSound(SoundEvents.LEAD_UNTIED); -@@ -2191,9 +_,22 @@ - if (itemInHand1.is(Items.LEAD) && !(leashable2.getLeashHolder() instanceof Player)) { - if (!this.level().isClientSide() && leashable2.canHaveALeashAttachedTo(player)) { +@@ -2203,9 +_,22 @@ + + if (leashable2.canHaveALeashAttachedTo(player)) { if (leashable2.isLeashed()) { - leashable2.dropLeash(); + // Paper start - EntityUnleashEvent @@ -1071,7 +1073,7 @@ leashable2.setLeashedTo(player, true); this.playSound(SoundEvents.LEAD_TIED); itemInHand1.shrink(1); -@@ -2208,7 +_,12 @@ +@@ -2219,7 +_,12 @@ } public boolean shearOffAllLeashConnections(@Nullable Player player) { @@ -1085,7 +1087,7 @@ if (flag && this.level() instanceof ServerLevel serverLevel) { serverLevel.playSound(null, this.blockPosition(), SoundEvents.SHEARS_SNIP, player != null ? player.getSoundSource() : this.getSoundSource()); } -@@ -2217,15 +_,38 @@ +@@ -2228,15 +_,38 @@ } public boolean dropAllLeashConnections(@Nullable Player player) { @@ -1128,7 +1130,7 @@ } if (flag) { -@@ -2249,7 +_,9 @@ +@@ -2260,7 +_,9 @@ this.gameEvent(GameEvent.SHEAR, player); this.playSound(equippable.shearingSound().value()); if (this.level() instanceof ServerLevel serverLevel) { @@ -1138,7 +1140,7 @@ CriteriaTriggers.PLAYER_SHEARED_EQUIPMENT.trigger((ServerPlayer)player, itemBySlot, mob); } -@@ -2322,11 +_,11 @@ +@@ -2333,11 +_,11 @@ } public boolean startRiding(Entity entity, boolean force, boolean triggerEvents) { @@ -1152,7 +1154,7 @@ return false; } else { for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) { -@@ -2336,6 +_,27 @@ +@@ -2347,6 +_,27 @@ } if (force || this.canRide(entity) && entity.canAddPassenger(this)) { @@ -1180,7 +1182,7 @@ if (this.isPassenger()) { this.stopRiding(); } -@@ -2368,10 +_,16 @@ +@@ -2379,10 +_,16 @@ } public void removeVehicle() { @@ -1198,7 +1200,7 @@ Entity.RemovalReason removalReason = this.getRemovalReason(); if (removalReason == null || removalReason.shouldDestroy()) { this.level().gameEvent(this, GameEvent.ENTITY_DISMOUNT, entity.position); -@@ -2380,7 +_,13 @@ +@@ -2391,7 +_,13 @@ } public void stopRiding() { @@ -1213,7 +1215,7 @@ } protected void addPassenger(Entity passenger) { -@@ -2402,10 +_,43 @@ +@@ -2413,10 +_,43 @@ } } @@ -1258,7 +1260,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == passenger) { this.passengers = ImmutableList.of(); } else { -@@ -2414,6 +_,7 @@ +@@ -2425,6 +_,7 @@ passenger.boardingCooldown = 60; } @@ -1266,7 +1268,7 @@ } protected boolean canAddPassenger(Entity passenger) { -@@ -2513,7 +_,8 @@ +@@ -2524,7 +_,8 @@ TeleportTransition portalDestination = this.portalProcess.getPortalDestination(serverLevel, this); if (portalDestination != null) { ServerLevel level = portalDestination.newLevel(); @@ -1276,7 +1278,7 @@ ) { this.teleport(portalDestination); -@@ -2596,7 +_,7 @@ +@@ -2607,7 +_,7 @@ } public boolean isCrouching() { @@ -1285,7 +1287,7 @@ } public boolean isSprinting() { -@@ -2612,7 +_,7 @@ +@@ -2623,7 +_,7 @@ } public boolean isVisuallySwimming() { @@ -1294,7 +1296,7 @@ } public boolean isVisuallyCrawling() { -@@ -2620,6 +_,13 @@ +@@ -2631,6 +_,13 @@ } public void setSwimming(boolean swimming) { @@ -1308,7 +1310,7 @@ this.setSharedFlag(FLAG_SWIMMING, swimming); } -@@ -2657,6 +_,7 @@ +@@ -2668,6 +_,7 @@ } public @Nullable PlayerTeam getTeam() { @@ -1316,7 +1318,7 @@ return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -2673,7 +_,11 @@ +@@ -2684,7 +_,11 @@ } public void setInvisible(boolean invisible) { @@ -1329,7 +1331,7 @@ } public boolean getSharedFlag(int flag) { -@@ -2690,7 +_,7 @@ +@@ -2701,7 +_,7 @@ } public int getMaxAirSupply() { @@ -1338,7 +1340,7 @@ } public int getAirSupply() { -@@ -2698,10 +_,22 @@ +@@ -2709,10 +_,22 @@ } public void setAirSupply(int airSupply) { @@ -1362,7 +1364,7 @@ this.setTicksFrozen(0); } -@@ -2728,11 +_,43 @@ +@@ -2739,11 +_,43 @@ public void thunderHit(ServerLevel level, LightningBolt lightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -1410,7 +1412,7 @@ } public void onAboveBubbleColumn(boolean downwards, BlockPos pos) { -@@ -2888,26 +_,30 @@ +@@ -2899,26 +_,30 @@ return this.removalReason != null ? String.format( Locale.ROOT, @@ -1444,7 +1446,7 @@ ); } -@@ -2931,6 +_,13 @@ +@@ -2942,6 +_,13 @@ } public void restoreFrom(Entity entity) { @@ -1458,7 +1460,7 @@ try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) { TagValueOutput tagValueOutput = TagValueOutput.createWithContext(scopedCollector, entity.registryAccess()); entity.saveWithoutId(tagValueOutput); -@@ -2942,7 +_,65 @@ +@@ -2953,7 +_,65 @@ } public @Nullable Entity teleport(TeleportTransition teleportTransition) { @@ -1524,7 +1526,7 @@ ServerLevel level = teleportTransition.newLevel(); boolean flag = level.dimension() != serverLevel.dimension(); if (!teleportTransition.asPassenger()) { -@@ -2991,10 +_,15 @@ +@@ -3002,10 +_,15 @@ profilerFiller.pop(); return null; } else { @@ -1541,7 +1543,7 @@ for (Entity entity2 : list) { entity2.startRiding(entityx, true, false); -@@ -3084,9 +_,17 @@ +@@ -3095,9 +_,17 @@ } protected void removeAfterChangingDimensions() { @@ -1562,7 +1564,7 @@ } if (this instanceof WaypointTransmitter waypointTransmitter && this.level instanceof ServerLevel serverLevel) { -@@ -3103,6 +_,7 @@ +@@ -3114,6 +_,7 @@ } public boolean canTeleport(Level fromLevel, Level toLevel) { @@ -1570,7 +1572,7 @@ if (fromLevel.dimension() == Level.END && toLevel.dimension() == Level.OVERWORLD) { for (Entity entity : this.getPassengers()) { if (entity instanceof ServerPlayer serverPlayer && !serverPlayer.seenCredits) { -@@ -3209,13 +_,19 @@ +@@ -3220,13 +_,19 @@ return this.entityData.get(DATA_CUSTOM_NAME_VISIBLE); } @@ -1593,7 +1595,7 @@ } public void teleportTo(double x, double y, double z) { -@@ -3324,7 +_,26 @@ +@@ -3335,7 +_,26 @@ } public final void setBoundingBox(AABB bb) { @@ -1621,7 +1623,7 @@ } public final float getEyeHeight(Pose pose) { -@@ -3352,6 +_,12 @@ +@@ -3363,6 +_,12 @@ } public void stopSeenByPlayer(ServerPlayer player) { @@ -1634,7 +1636,7 @@ } public float rotate(Rotation transformRotation) { -@@ -3410,21 +_,32 @@ +@@ -3421,21 +_,32 @@ } private Stream getIndirectPassengersStream() { @@ -1668,7 +1670,7 @@ } public int countPlayerPassengers() { -@@ -3432,6 +_,7 @@ +@@ -3443,6 +_,7 @@ } public boolean hasExactlyOnePlayerPassenger() { @@ -1676,7 +1678,7 @@ return this.countPlayerPassengers() == 1; } -@@ -3512,9 +_,38 @@ +@@ -3523,9 +_,38 @@ return 0; } @@ -1716,7 +1718,7 @@ this.position(), this.getRotationVector(), level, -@@ -3580,6 +_,11 @@ +@@ -3591,6 +_,11 @@ vec3 = vec3.add(flow); i++; } @@ -1728,17 +1730,17 @@ } } } -@@ -3678,7 +_,9 @@ - } +@@ -3690,7 +_,9 @@ public void setDeltaMovement(Vec3 deltaMovement) { -+ synchronized (this.posLock) { // Paper - detailed watchdog information - this.deltaMovement = deltaMovement; -+ } // Paper - detailed watchdog information + if (deltaMovement.isFinite()) { ++ synchronized (this.posLock) { // Paper - detailed watchdog information + this.deltaMovement = deltaMovement; ++ } // Paper - detailed watchdog information + } } - public void addDeltaMovement(Vec3 addend) { -@@ -3741,9 +_,35 @@ +@@ -3756,9 +_,35 @@ return this.getZ((2.0 * this.random.nextDouble() - 1.0) * scale); } @@ -1774,14 +1776,14 @@ int floor = Mth.floor(x); int floor1 = Mth.floor(y); int floor2 = Mth.floor(z); -@@ -3765,7 +_,18 @@ +@@ -3780,7 +_,18 @@ serverLevel.getWaypointManager().updatePlayer(serverPlayer); } } - } + // Paper start - Fix MC-44654 + if (this.getType().updateInterval() == Integer.MAX_VALUE) { -+ this.hasImpulse = true; ++ this.needsSync = true; + } + // Paper end - Fix MC-44654 + } @@ -1794,7 +1796,7 @@ } public void checkDespawn() { -@@ -3817,6 +_,12 @@ +@@ -3832,6 +_,12 @@ return this.getTicksFrozen() > 0; } @@ -1807,7 +1809,7 @@ public float getYRot() { return this.yRot; } -@@ -3867,7 +_,9 @@ +@@ -3882,7 +_,9 @@ } @Override @@ -1818,7 +1820,7 @@ if (this.removalReason == null) { this.removalReason = removalReason; } -@@ -3879,12 +_,28 @@ +@@ -3894,12 +_,28 @@ this.getPassengers().forEach(Entity::stopRiding); this.levelCallback.onRemove(removalReason); this.onRemoval(removalReason); @@ -1847,7 +1849,7 @@ @Override public void setLevelCallback(EntityInLevelCallback levelCallback) { this.levelCallback = levelCallback; -@@ -4078,4 +_,14 @@ +@@ -4097,4 +_,14 @@ return this.save; } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch index 018611242bd6..6d33b22d614d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch @@ -1,5 +1,14 @@ --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java +@@ -186,6 +_,8 @@ + import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; + import org.slf4j.Logger; ++import net.minecraft.util.Util; ++import net.minecraft.resources.Identifier; + + public class EntityType implements FeatureElement, EntityTypeTest { + private static final Logger LOGGER = LogUtils.getLogger(); @@ -1289,6 +_,22 @@ boolean shouldOffsetY, boolean shouldOffsetYMore diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index 71ae2b9750b1..c54ba95ebd05 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -791,9 +791,9 @@ if (killCredit != null) { killCredit.awardKillScore(this, damageSource); } -@@ -1438,68 +_,147 @@ - } +@@ -1439,68 +_,147 @@ + this.stopUsingItem(); if (!this.level().isClientSide() && this.hasCustomName()) { - LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); + if (org.spigotmc.SpigotConfig.logNamedDeaths) LivingEntity.LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); // Spigot @@ -952,7 +952,7 @@ } protected void dropCustomDeathLoot(ServerLevel level, DamageSource damageSource, boolean recentlyHit) { -@@ -1603,9 +_,14 @@ +@@ -1604,9 +_,14 @@ } public void knockback(double strength, double x, double z) { @@ -963,13 +963,13 @@ + public void knockback(double strength, double x, double z, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause eventCause) { // Paper - knockback events strength *= 1.0 - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); - if (!(strength <= 0.0)) { -- this.hasImpulse = true; +- this.needsSync = true; + if (true || !(strength <= 0.0)) { // CraftBukkit - Call event even when force is 0 -+ // this.hasImpulse = true; // CraftBukkit - Move down ++ // this.needsSync = true; // CraftBukkit - Move down Vec3 deltaMovement = this.getDeltaMovement(); while (x * x + z * z < 1.0E-5F) { -@@ -1614,11 +_,22 @@ +@@ -1615,11 +_,22 @@ } Vec3 vec3 = new Vec3(x, 0.0, z).normalize().scale(strength); @@ -987,13 +987,13 @@ + return; + } + -+ this.hasImpulse = true; ++ this.needsSync = true; + this.setDeltaMovement(deltaMovement.add(event.getKnockback().getX(), event.getKnockback().getY(), event.getKnockback().getZ())); // Paper - knockback events + // CraftBukkit end } } -@@ -1709,7 +_,7 @@ +@@ -1710,7 +_,7 @@ @Override public boolean isAlive() { @@ -1002,7 +1002,7 @@ } public boolean isLookingAtMe(LivingEntity entity, double tolerance, boolean scaleByDistance, boolean visual, double... yValues) { -@@ -1743,9 +_,14 @@ +@@ -1744,9 +_,14 @@ boolean flag = super.causeFallDamage(fallDistance, damageMultiplier, damageSource); int i = this.calculateFallDamage(fallDistance, damageMultiplier); if (i > 0) { @@ -1018,7 +1018,7 @@ return true; } else { return flag; -@@ -1810,7 +_,7 @@ +@@ -1811,7 +_,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damageSource, float damageAmount) { if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -1027,7 +1027,7 @@ damageAmount = CombatRules.getDamageAfterAbsorb( this, damageAmount, damageSource, this.getArmorValue(), (float)this.getAttributeValue(Attributes.ARMOR_TOUGHNESS) ); -@@ -1823,7 +_,8 @@ +@@ -1824,7 +_,8 @@ if (damageSource.is(DamageTypeTags.BYPASSES_EFFECTS)) { return damageAmount; } else { @@ -1037,7 +1037,7 @@ int i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int i1 = 25 - i; float f = damageAmount * i1; -@@ -1860,24 +_,201 @@ +@@ -1861,24 +_,201 @@ } } @@ -1249,7 +1249,7 @@ } public CombatTracker getCombatTracker() { -@@ -1905,7 +_,17 @@ +@@ -1906,7 +_,17 @@ } public final void setArrowCount(int count) { @@ -1268,7 +1268,7 @@ } public final int getStingerCount() { -@@ -1952,7 +_,7 @@ +@@ -1953,7 +_,7 @@ @Override public void handleDamageEvent(DamageSource damageSource) { this.walkAnimation.setSpeed(1.5F); @@ -1277,7 +1277,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; SoundEvent hurtSound = this.getHurtSound(damageSource); -@@ -2071,7 +_,7 @@ +@@ -2072,7 +_,7 @@ @Override protected void onBelowWorld() { @@ -1286,7 +1286,7 @@ } protected void updateSwingTime() { -@@ -2165,8 +_,15 @@ +@@ -2166,8 +_,15 @@ } public void setItemSlot(EquipmentSlot slot, ItemStack stack) { @@ -1304,7 +1304,7 @@ public float getArmorCoverPercentage() { int i = 0; -@@ -2258,14 +_,27 @@ +@@ -2259,14 +_,27 @@ return this.hasEffect(MobEffects.JUMP_BOOST) ? 0.1F * (this.getEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1.0F) : 0.0F; } @@ -1332,7 +1332,7 @@ this.addDeltaMovement(new Vec3(-Mth.sin(f) * 0.2, 0.0, Mth.cos(f) * 0.2)); } -@@ -2448,8 +_,10 @@ +@@ -2449,8 +_,10 @@ } public void stopFallFlying() { @@ -1343,7 +1343,7 @@ } private Vec3 updateFallFlyingMovement(Vec3 deltaMovement) { -@@ -2593,7 +_,7 @@ +@@ -2594,7 +_,7 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F && target instanceof LivingEntity livingEntity) { @@ -1352,7 +1352,7 @@ this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); } } -@@ -2669,37 +_,15 @@ +@@ -2670,37 +_,15 @@ profilerFiller.pop(); profilerFiller.push("rangeChecks"); @@ -1399,7 +1399,7 @@ profilerFiller.pop(); if (this.isFallFlying()) { -@@ -2780,16 +_,39 @@ +@@ -2785,16 +_,39 @@ private @Nullable Map collectEquipmentChanges() { Map map = null; @@ -1439,7 +1439,7 @@ AttributeMap attributes = this.getAttributes(); if (!itemStack.isEmpty()) { this.stopLocationBasedEffects(itemStack, equipmentSlot, attributes); -@@ -2814,6 +_,8 @@ +@@ -2819,6 +_,8 @@ } } } @@ -1448,7 +1448,7 @@ } return map; -@@ -2845,7 +_,7 @@ +@@ -2850,7 +_,7 @@ list.add(Pair.of(equipmentSlot, itemStack1)); this.lastEquipmentItems.put(equipmentSlot, itemStack1); }); @@ -1457,7 +1457,7 @@ } protected void tickHeadTurn(float yBodyRot) { -@@ -2931,8 +_,10 @@ +@@ -2936,8 +_,10 @@ if (!flag || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if (!this.isInLava() || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if ((this.onGround() || flag && fluidHeight <= fluidJumpThreshold) && this.noJumpDelay == 0) { @@ -1468,7 +1468,7 @@ } } else { this.jumpInLiquid(FluidTags.LAVA); -@@ -2973,7 +_,7 @@ +@@ -2978,7 +_,7 @@ profilerFiller.pop(); if (this.level() instanceof ServerLevel serverLevel) { profilerFiller.push("freezing"); @@ -1477,7 +1477,7 @@ this.setTicksFrozen(Math.max(0, this.getTicksFrozen() - 2)); } -@@ -2994,6 +_,20 @@ +@@ -2999,6 +_,20 @@ this.pushEntities(); profilerFiller.pop(); @@ -1498,7 +1498,7 @@ if (this.level() instanceof ServerLevel serverLevel && this.isSensitiveToWater() && this.isInWaterOrRain()) { this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F); } -@@ -3016,6 +_,7 @@ +@@ -3021,6 +_,7 @@ this.checkFallDistanceAccumulation(); if (!this.level().isClientSide()) { if (!this.canGlide()) { @@ -1506,7 +1506,7 @@ this.setSharedFlag(Entity.FLAG_FALL_FLYING, false); return; } -@@ -3055,10 +_,25 @@ +@@ -3060,10 +_,25 @@ } protected void pushEntities() { @@ -1533,7 +1533,7 @@ if (i > 0 && pushableEntities.size() > i - 1 && this.random.nextInt(4) == 0) { int i1 = 0; -@@ -3074,7 +_,16 @@ +@@ -3079,7 +_,16 @@ } } @@ -1550,7 +1550,7 @@ this.doPush(entity1); } } -@@ -3083,16 +_,32 @@ +@@ -3088,16 +_,32 @@ protected void checkAutoSpinAttack(AABB boundingBoxBeforeSpin, AABB boundingBoxAfterSpin) { AABB aabb = boundingBoxBeforeSpin.minmax(boundingBoxAfterSpin); List entities = this.level().getEntities(this, aabb); @@ -1584,7 +1584,7 @@ this.autoSpinAttackTicks = 0; } -@@ -3115,10 +_,10 @@ +@@ -3120,10 +_,10 @@ } @Override @@ -1598,7 +1598,7 @@ this.dismountVehicle(vehicle); } } -@@ -3145,7 +_,7 @@ +@@ -3150,7 +_,7 @@ } public void onItemPickup(ItemEntity itemEntity) { @@ -1607,7 +1607,7 @@ if (owner instanceof ServerPlayer) { CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer)owner, itemEntity.getItem(), this); } -@@ -3157,7 +_,7 @@ +@@ -3162,7 +_,7 @@ && (entity instanceof ItemEntity || entity instanceof AbstractArrow || entity instanceof ExperienceOrb)) { ((ServerLevel)this.level()) .getChunkSource() @@ -1616,7 +1616,7 @@ } } -@@ -3171,7 +_,8 @@ +@@ -3176,7 +_,8 @@ } else { Vec3 vec3 = new Vec3(this.getX(), this.getEyeY(), this.getZ()); Vec3 vec31 = new Vec3(entity.getX(), y, entity.getZ()); @@ -1626,7 +1626,7 @@ } } -@@ -3191,13 +_,27 @@ +@@ -3196,13 +_,27 @@ @Override public boolean isPickable() { @@ -1657,7 +1657,7 @@ @Override public float getYHeadRot() { -@@ -3228,7 +_,7 @@ +@@ -3233,7 +_,7 @@ } public final void setAbsorptionAmount(float absorptionAmount) { @@ -1666,7 +1666,7 @@ } protected void internalSetAbsorptionAmount(float absorptionAmount) { -@@ -3255,6 +_,15 @@ +@@ -3260,6 +_,15 @@ return (this.entityData.get(DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; } @@ -1682,7 +1682,7 @@ private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { -@@ -3271,6 +_,11 @@ +@@ -3276,6 +_,11 @@ return null; } else { double d = this.getEyeY() - 0.3F; @@ -1694,7 +1694,7 @@ ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), d, this.getZ(), stack); itemEntity.setPickUpDelay(40); if (includeThrower) { -@@ -3302,7 +_,12 @@ +@@ -3307,7 +_,12 @@ protected void updateUsingItem(ItemStack usingItem) { usingItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); @@ -1708,7 +1708,7 @@ this.completeUsingItem(); } } -@@ -3328,10 +_,19 @@ +@@ -3333,10 +_,19 @@ } public void startUsingItem(InteractionHand hand) { @@ -1730,7 +1730,7 @@ if (!this.level().isClientSide()) { this.setLivingEntityFlag(LIVING_ENTITY_FLAG_IS_USING, true); this.setLivingEntityFlag(LIVING_ENTITY_FLAG_OFF_HAND, hand == InteractionHand.OFF_HAND); -@@ -3358,7 +_,10 @@ +@@ -3363,7 +_,10 @@ } } else if (!this.isUsingItem() && !this.useItem.isEmpty()) { this.useItem = ItemStack.EMPTY; @@ -1742,7 +1742,7 @@ } } } -@@ -3397,7 +_,38 @@ +@@ -3402,7 +_,38 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1782,7 +1782,7 @@ if (itemStack != this.useItem) { this.setItemInHand(usedItemHand, itemStack); } -@@ -3431,6 +_,7 @@ +@@ -3436,6 +_,7 @@ ItemStack itemInHand = this.getItemInHand(this.getUsedItemHand()); if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemInHand, this.useItem)) { this.useItem = itemInHand; @@ -1790,7 +1790,7 @@ this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); if (this.useItem.useOnRelease()) { this.updatingUsingItem(); -@@ -3451,7 +_,10 @@ +@@ -3456,7 +_,10 @@ } this.useItem = ItemStack.EMPTY; @@ -1802,7 +1802,7 @@ } public boolean isBlocking() { -@@ -3474,6 +_,60 @@ +@@ -3479,6 +_,60 @@ } } @@ -1863,7 +1863,7 @@ public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); } -@@ -3492,6 +_,12 @@ +@@ -3497,6 +_,12 @@ } public boolean randomTeleport(double x, double y, double z, boolean broadcastTeleport) { @@ -1876,7 +1876,7 @@ double x1 = this.getX(); double y1 = this.getY(); double z1 = this.getZ(); -@@ -3514,16 +_,39 @@ +@@ -3519,16 +_,39 @@ } if (flag1) { @@ -1919,7 +1919,7 @@ } else { if (broadcastTeleport) { level.broadcastEntityEvent(this, EntityEvent.TELEPORT); -@@ -3533,7 +_,7 @@ +@@ -3538,7 +_,7 @@ pathfinderMob.getNavigation().stop(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch index e457d625dc5b..2421ffa5732c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -91,6 +_,14 @@ +@@ -92,6 +_,14 @@ import net.minecraft.world.ticks.ContainerSingleItem; import org.jspecify.annotations.Nullable; @@ -15,7 +15,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashable, Targeting { private static final EntityDataAccessor DATA_MOB_FLAGS_ID = SynchedEntityData.defineId(Mob.class, EntityDataSerializers.BYTE); private static final int MOB_FLAG_NO_AI = 1; -@@ -126,6 +_,7 @@ +@@ -127,6 +_,7 @@ private final BodyRotationControl bodyRotationControl; protected PathNavigation navigation; public GoalSelector goalSelector; @@ -23,7 +23,7 @@ public GoalSelector targetSelector; private @Nullable LivingEntity target; private final Sensing sensing; -@@ -138,6 +_,8 @@ +@@ -139,6 +_,8 @@ private Leashable.@Nullable LeashData leashData; private BlockPos homePosition = BlockPos.ZERO; private int homeRadius = -1; @@ -32,7 +32,7 @@ protected Mob(EntityType type, Level level) { super(type, level); -@@ -154,6 +_,12 @@ +@@ -155,6 +_,12 @@ } } @@ -45,7 +45,7 @@ protected void registerGoals() { } -@@ -231,7 +_,39 @@ +@@ -232,7 +_,39 @@ } public void setTarget(@Nullable LivingEntity target) { @@ -85,7 +85,7 @@ } @Override -@@ -370,13 +_,27 @@ +@@ -371,13 +_,27 @@ if (this.isNoAi()) { output.putBoolean("NoAI", this.isNoAi()); } @@ -115,7 +115,7 @@ this.dropChances = input.read("drop_chances", DropChances.CODEC).orElse(DropChances.DEFAULT); this.readLeashData(input); this.homeRadius = input.getIntOr("home_radius", -1); -@@ -388,6 +_,13 @@ +@@ -389,6 +_,13 @@ this.lootTable = input.read("DeathLootTable", LootTable.KEY_CODEC); this.lootTableSeed = input.getLongOr("DeathLootTableSeed", 0L); this.setNoAi(input.getBooleanOr("NoAI", false)); @@ -129,7 +129,7 @@ } @Override -@@ -455,6 +_,11 @@ +@@ -456,6 +_,11 @@ && !itemEntity.getItem().isEmpty() && !itemEntity.hasPickUpDelay() && this.wantsToPickUp(serverLevel, itemEntity.getItem())) { @@ -141,7 +141,7 @@ this.pickUpItem(serverLevel, itemEntity); } } -@@ -508,18 +_,24 @@ +@@ -509,18 +_,24 @@ protected void pickUpItem(ServerLevel level, ItemEntity entity) { ItemStack item = entity.getItem(); @@ -168,7 +168,7 @@ EquipmentSlot equipmentSlotForItem = this.getEquipmentSlotForItem(stack); if (!this.isEquippableInSlot(stack, equipmentSlotForItem)) { return ItemStack.EMPTY; -@@ -532,10 +_,18 @@ +@@ -533,10 +_,18 @@ canReplaceCurrentItem = itemBySlot.isEmpty(); } @@ -188,7 +188,7 @@ } ItemStack itemStack = equipmentSlotForItem.limit(stack); -@@ -648,25 +_,38 @@ +@@ -649,25 +_,38 @@ return this.isPassenger(); } @@ -241,7 +241,7 @@ this.noActionTime = 0; } } -@@ -678,6 +_,15 @@ +@@ -679,6 +_,15 @@ @Override protected final void serverAiStep() { this.noActionTime++; @@ -257,7 +257,7 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("sensing"); this.sensing.tick(); -@@ -852,14 +_,69 @@ +@@ -853,14 +_,69 @@ public boolean stillValid(Player player) { return player.getVehicle() == Mob.this || player.canInteractWithEntity(Mob.this, 4.0); } @@ -327,7 +327,7 @@ ItemStack itemBySlot = this.getItemBySlot(equipmentSlot); float f = this.dropChances.byEquipment(equipmentSlot); if (f != 0.0F) { -@@ -879,7 +_,13 @@ +@@ -880,7 +_,13 @@ } this.spawnAtLocation(level, itemBySlot); @@ -341,7 +341,7 @@ } } } -@@ -903,7 +_,9 @@ +@@ -904,7 +_,9 @@ set.add(equipmentSlot); } else if (this.dropChances.isPreserved(equipmentSlot)) { this.setItemSlot(equipmentSlot, ItemStack.EMPTY); @@ -351,7 +351,7 @@ } } } -@@ -1194,6 +_,21 @@ +@@ -1195,6 +_,21 @@ public @Nullable T convertTo( EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.AfterConversion afterConversion ) { @@ -373,7 +373,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1202,13 +_,23 @@ +@@ -1203,13 +_,23 @@ return null; } else { conversionParams.type().convert(this, mob, conversionParams); @@ -400,7 +400,7 @@ } return mob; -@@ -1219,7 +_,17 @@ +@@ -1220,7 +_,17 @@ public @Nullable T convertTo( EntityType entityType, ConversionParams conversionParams, ConversionParams.AfterConversion afterConversion ) { @@ -419,7 +419,7 @@ } @Override -@@ -1260,7 +_,17 @@ +@@ -1261,7 +_,17 @@ public boolean startRiding(Entity entity, boolean force, boolean triggerEvents) { boolean flag = super.startRiding(entity, force, triggerEvents); if (flag && this.isLeashed()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch index f800fedeb545..38c76aeede01 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/attributes/AttributeInstance.java +++ b/net/minecraft/world/entity/ai/attributes/AttributeInstance.java -@@ -150,20 +_,20 @@ +@@ -148,20 +_,20 @@ double baseValue = this.getBaseValue(); for (AttributeModifier attributeModifier : this.getModifiersOrEmpty(AttributeModifier.Operation.ADD_VALUE)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch index fa1468aff6d1..8fa87a270a5e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Bee.java +++ b/net/minecraft/world/entity/animal/Bee.java -@@ -146,10 +_,26 @@ +@@ -147,10 +_,26 @@ Bee.BeeGoToHiveGoal goToHiveGoal; private Bee.BeeGoToKnownFlowerGoal goToKnownFlowerGoal; private int underWaterTicks; @@ -28,7 +28,7 @@ this.lookControl = new Bee.BeeLookControl(this); this.setPathfindingMalus(PathType.DANGER_FIRE, -1.0F); this.setPathfindingMalus(PathType.WATER, -1.0F); -@@ -196,9 +_,18 @@ +@@ -197,9 +_,18 @@ @Override protected void addAdditionalSaveData(ValueOutput output) { @@ -47,7 +47,7 @@ output.putBoolean("HasNectar", this.hasNectar()); output.putBoolean("HasStung", this.hasStung()); output.putInt("TicksSincePollination", this.ticksWithoutNectarSinceExitingHive); -@@ -236,7 +_,7 @@ +@@ -237,7 +_,7 @@ } if (i > 0) { @@ -56,7 +56,7 @@ } } -@@ -479,7 +_,11 @@ +@@ -478,7 +_,11 @@ if (this.hivePos == null) { return null; } else { @@ -69,7 +69,7 @@ } } -@@ -512,6 +_,7 @@ +@@ -511,6 +_,7 @@ } public void setRolling(boolean isRolling) { @@ -77,7 +77,7 @@ this.setFlag(FLAG_ROLL, isRolling); } -@@ -568,7 +_,7 @@ +@@ -567,7 +_,7 @@ if (beeInteractionEffect != null) { this.usePlayerItem(player, hand, itemInHand); if (!this.level().isClientSide()) { @@ -86,7 +86,7 @@ } return InteractionResult.SUCCESS; -@@ -636,8 +_,9 @@ +@@ -635,8 +_,9 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { @@ -97,7 +97,7 @@ } } -@@ -978,7 +_,7 @@ +@@ -977,7 +_,7 @@ } } @@ -106,7 +106,7 @@ Bee.this.level().levelEvent(LevelEvent.PARTICLES_BEE_GROWTH, blockPos, 15); Bee.this.level().setBlockAndUpdate(blockPos, blockState1); Bee.this.incrementNumCropsGrownSincePollination(); -@@ -1002,7 +_,7 @@ +@@ -1001,7 +_,7 @@ @Override protected void alertOther(Mob mob, LivingEntity target) { if (mob instanceof Bee && this.mob.hasLineOfSight(target)) { @@ -115,7 +115,7 @@ } } } -@@ -1159,7 +_,7 @@ +@@ -1158,7 +_,7 @@ Bee.this.dropFlower(); this.pollinating = false; Bee.this.remainingCooldownBeforeLocatingNewFlower = 200; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch index a4e3f5c26948..c9d574ad6c3e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Cat.java +++ b/net/minecraft/world/entity/animal/Cat.java -@@ -368,6 +_,11 @@ +@@ -369,6 +_,11 @@ if (item instanceof DyeItem dyeItem) { DyeColor dyeColor = dyeItem.getDyeColor(); if (dyeColor != this.getCollarColor()) { @@ -12,7 +12,7 @@ if (!this.level().isClientSide()) { this.setCollarColor(dyeColor); itemInHand.consume(1, player); -@@ -380,7 +_,7 @@ +@@ -381,7 +_,7 @@ if (!this.level().isClientSide()) { this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); @@ -21,7 +21,7 @@ this.playEatingSound(); } -@@ -442,7 +_,7 @@ +@@ -443,7 +_,7 @@ } private void tryToTame(Player player) { @@ -30,7 +30,7 @@ this.tame(player); this.setOrderedToSit(true); this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); -@@ -578,15 +_,20 @@ +@@ -576,15 +_,20 @@ .dropFromGiftLootTable( getServerLevel(this.cat), BuiltInLootTables.CAT_MORNING_GIFT, @@ -55,7 +55,7 @@ ); } -@@ -612,7 +_,7 @@ +@@ -610,7 +_,7 @@ } static class CatTemptGoal extends TemptGoal { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch index 24fa5f2176eb..81ee48b69608 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch @@ -3,7 +3,7 @@ @@ -137,10 +_,12 @@ ArmadilloAi.updateActivity(this); profilerFiller.pop(); - if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) { + if (this.isAlive() && --this.scuteTime <= 0 && this.shouldDropLoot(level)) { + this.forceDrops = true; // CraftBukkit if (this.dropFromGiftLootTable(level, BuiltInLootTables.ARMADILLO_SHED, this::spawnAtLocation)) { this.playSound(SoundEvents.ARMADILLO_SCUTE_DROP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch index cb9143e8fccf..c33ff9aea112 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/SkeletonHorse.java +++ b/net/minecraft/world/entity/animal/horse/SkeletonHorse.java -@@ -125,7 +_,7 @@ +@@ -126,7 +_,7 @@ public void aiStep() { super.aiStep(); if (this.isTrap() && this.trapTime++ >= 18000) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch index 70da9d7b0e84..32029fb07da5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java +++ b/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java -@@ -381,7 +_,7 @@ +@@ -387,7 +_,7 @@ if (this.isFood(itemInHand) && this.getHealth() < this.getMaxHealth()) { this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); @@ -9,7 +9,7 @@ this.playEatingSound(); return InteractionResult.SUCCESS; } -@@ -402,7 +_,7 @@ +@@ -408,7 +_,7 @@ } private void tryToTame(Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch index 35574d47b784..2c49055d3d3f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch @@ -69,7 +69,7 @@ + // Paper start - Option to prevent TNT from moving in water + if (!this.isRemoved() && this.wasTouchingWater && this.level().paperConfig().fixes.preventTntFromMovingInWater) { + this.hurtMarked = true; -+ this.hasImpulse = true; ++ this.needsSync = true; + } + // Paper end - Option to prevent TNT from moving in water } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch index 1b6e77d4bcd8..9ed5f13b01f3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Slime.java +++ b/net/minecraft/world/entity/monster/Slime.java -@@ -58,6 +_,7 @@ +@@ -59,6 +_,7 @@ public float squish; public float oSquish; private boolean wasOnGround = false; @@ -8,7 +8,7 @@ public Slime(EntityType type, Level level) { super(type, level); -@@ -112,6 +_,7 @@ +@@ -113,6 +_,7 @@ super.addAdditionalSaveData(output); output.putInt("Size", this.getSize() - 1); output.putBoolean("wasOnGround", this.wasOnGround); @@ -16,7 +16,7 @@ } @Override -@@ -119,6 +_,7 @@ +@@ -120,6 +_,7 @@ this.setSize(input.getIntOr("Size", 0) + 1, false); super.readAdditionalSaveData(input); this.wasOnGround = input.getBooleanOr("wasOnGround", false); @@ -24,7 +24,7 @@ } public boolean isTiny() { -@@ -193,7 +_,7 @@ +@@ -194,7 +_,7 @@ } @Override @@ -33,7 +33,7 @@ int size = this.getSize(); if (!this.level().isClientSide() && size > 1 && this.isDeadOrDying()) { float width = this.getDimensions(this.getPose()).width(); -@@ -201,18 +_,43 @@ +@@ -202,18 +_,43 @@ int i = size / 2; int i1 = 2 + this.random.nextInt(3); PlayerTeam team = this.getTeam(); @@ -81,7 +81,7 @@ } @Override -@@ -278,7 +_,11 @@ +@@ -279,7 +_,11 @@ return checkMobSpawnRules(entityType, level, spawnReason, pos, random); } @@ -91,10 +91,10 @@ + final double minHeightSwamp = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.minimum; + // Paper end - Replace rules for Height in Swamp Biomes + if (level.getBiome(pos).is(BiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS) && pos.getY() > minHeightSwamp && pos.getY() < maxHeightSwamp) { // Paper - Replace rules for Height in Swamp Biomes - float f = level.getMoonBrightness() * 0.5F; - if (random.nextFloat() < f && level.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) { + float value = level.environmentAttributes().getValue(EnvironmentAttributes.SURFACE_SLIME_SPAWN_CHANCE, pos); + if (random.nextFloat() < value && level.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) { return checkMobSpawnRules(entityType, level, spawnReason, pos, random); -@@ -290,8 +_,11 @@ +@@ -291,8 +_,11 @@ } ChunkPos chunkPos = new ChunkPos(pos); @@ -108,7 +108,7 @@ return checkMobSpawnRules(entityType, level, spawnReason, pos, random); } } -@@ -349,6 +_,16 @@ +@@ -350,6 +_,16 @@ return super.getDefaultDimensions(pose).scale(this.getSize()); } @@ -125,7 +125,7 @@ static class SlimeAttackGoal extends Goal { private final Slime slime; private int growTiredTimer; -@@ -361,7 +_,16 @@ +@@ -362,7 +_,16 @@ @Override public boolean canUse() { LivingEntity target = this.slime.getTarget(); @@ -143,7 +143,7 @@ } @Override -@@ -373,7 +_,16 @@ +@@ -374,7 +_,16 @@ @Override public boolean canContinueToUse() { LivingEntity target = this.slime.getTarget(); @@ -161,7 +161,7 @@ } @Override -@@ -392,6 +_,13 @@ +@@ -393,6 +_,13 @@ slimeMoveControl.setDirection(this.slime.getYRot(), this.slime.isDealsDamage()); } } @@ -175,7 +175,7 @@ } static class SlimeFloatGoal extends Goal { -@@ -405,7 +_,7 @@ +@@ -406,7 +_,7 @@ @Override public boolean canUse() { @@ -184,7 +184,7 @@ } @Override -@@ -435,7 +_,7 @@ +@@ -436,7 +_,7 @@ @Override public boolean canUse() { @@ -193,7 +193,7 @@ } @Override -@@ -513,7 +_,7 @@ +@@ -514,7 +_,7 @@ @Override public boolean canUse() { @@ -202,7 +202,7 @@ && (this.slime.onGround() || this.slime.isInWater() || this.slime.isInLava() || this.slime.hasEffect(MobEffects.LEVITATION)) && this.slime.getMoveControl() instanceof Slime.SlimeMoveControl; } -@@ -523,6 +_,11 @@ +@@ -524,6 +_,11 @@ if (--this.nextRandomizeTime <= 0) { this.nextRandomizeTime = this.adjustedTickDelay(40 + this.slime.getRandom().nextInt(60)); this.chosenDegrees = this.slime.getRandom().nextInt(360); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch index 6f4c34a8fb21..f41237a75717 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch @@ -3,14 +3,14 @@ @@ -66,9 +_,7 @@ public class Zombie extends Monster { - private static final ResourceLocation SPEED_MODIFIER_BABY_ID = ResourceLocation.withDefaultNamespace("baby"); + private static final Identifier SPEED_MODIFIER_BABY_ID = Identifier.withDefaultNamespace("baby"); - private static final AttributeModifier SPEED_MODIFIER_BABY = new AttributeModifier( - SPEED_MODIFIER_BABY_ID, 0.5, AttributeModifier.Operation.ADD_MULTIPLIED_BASE - ); + private final AttributeModifier babyModifier = new AttributeModifier(Zombie.SPEED_MODIFIER_BABY_ID, this.level().paperConfig().entities.behavior.babyZombieMovementModifier, AttributeModifier.Operation.ADD_MULTIPLIED_BASE); // Paper - Make baby speed configurable - private static final ResourceLocation REINFORCEMENT_CALLER_CHARGE_ID = ResourceLocation.withDefaultNamespace("reinforcement_caller_charge"); + private static final Identifier REINFORCEMENT_CALLER_CHARGE_ID = Identifier.withDefaultNamespace("reinforcement_caller_charge"); private static final AttributeModifier ZOMBIE_REINFORCEMENT_CALLEE_CHARGE = new AttributeModifier( - ResourceLocation.withDefaultNamespace("reinforcement_callee_charge"), -0.05F, AttributeModifier.Operation.ADD_VALUE + Identifier.withDefaultNamespace("reinforcement_callee_charge"), -0.05F, AttributeModifier.Operation.ADD_VALUE @@ -89,13 +_,15 @@ private static final boolean DEFAULT_BABY = false; private static final boolean DEFAULT_CAN_BREAK_DOORS = false; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index 213895cd1050..175af9b04800 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -209,7 +209,7 @@ } @Override -@@ -947,16 +_,26 @@ +@@ -947,15 +_,25 @@ } public void attack(Entity target) { @@ -228,10 +228,9 @@ ItemStack weaponItem = this.getWeaponItem(); - DamageSource damageSource = this.createAttackSource(weaponItem); + DamageSource damageSource = this.createAttackSource(weaponItem); final DamageSource dmgSourceFinal = damageSource; // Paper - damage events - float f1 = this.getEnchantedDamage(target, f, damageSource) - f; float attackStrengthScale = this.getAttackStrengthScale(0.5F); - f *= 0.2F + attackStrengthScale * attackStrengthScale * 0.8F; - f1 *= attackStrengthScale; + float f1 = attackStrengthScale * (this.getEnchantedDamage(target, f, damageSource) - f); + f *= this.baseDamageScaleFactor(); this.onAttack(); - if (!this.deflectProjectile(target)) { + final float dmgFinal = f1; // Paper - damage events @@ -239,7 +238,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = attackStrengthScale > 0.9F; boolean flag1; -@@ -969,7 +_,9 @@ +@@ -968,7 +_,9 @@ f += weaponItem.getItem().getAttackDamageBonus(target, f, damageSource); boolean flag2 = flag && this.canCriticalAttack(target); @@ -249,7 +248,7 @@ f *= 1.5F; } -@@ -1011,11 +_,12 @@ +@@ -1014,11 +_,12 @@ return !target.isAttackable() || target.skipAttackInteraction(this); } @@ -264,7 +263,7 @@ return true; } else { return false; -@@ -1108,21 +_,43 @@ +@@ -1111,21 +_,43 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F) { if (target instanceof LivingEntity livingEntity) { @@ -309,7 +308,7 @@ } } -@@ -1143,7 +_,10 @@ +@@ -1146,7 +_,10 @@ && !(livingEntity instanceof ArmorStand armorStand && armorStand.isMarker()) && this.distanceToSqr(livingEntity) < 9.0) { float f1 = this.getEnchantedDamage(livingEntity, var12, damageSource) * strengthScale; @@ -321,7 +320,7 @@ livingEntity.knockback(0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity, damageSource); } -@@ -1170,13 +_,22 @@ +@@ -1178,14 +_,23 @@ @Override public boolean stabAttack(EquipmentSlot slot, Entity target, float damageAmount, boolean damage, boolean knockback, boolean dismount) { @@ -340,13 +339,14 @@ } else { ItemStack itemBySlot = this.getItemBySlot(slot); DamageSource damageSource = this.createAttackSource(itemBySlot); - float f = this.getEnchantedDamage(target, damageAmount, damageSource) - damageAmount; + float f = this.getAttackStrengthScale(0.5F) * (this.getEnchantedDamage(target, damageAmount, damageSource) - damageAmount); + damageAmount *= this.baseDamageScaleFactor(); - if (knockback && this.deflectProjectile(target)) { + if (knockback && this.deflectProjectile(target, () -> !org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(target, damageSource, f, false))) { // Paper - damage events return true; } else { float f1 = damage ? damageAmount + f : 0.0F; -@@ -1204,7 +_,7 @@ +@@ -1213,7 +_,7 @@ this.setLastHurtMob(target); this.itemAttackInteraction(target, itemBySlot, damageSource, flag); this.damageStatsAndHearts(target, f2); @@ -355,7 +355,7 @@ return true; } } -@@ -1215,8 +_,8 @@ +@@ -1224,8 +_,8 @@ } @Override @@ -366,7 +366,7 @@ this.inventoryMenu.removed(this); if (this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1284,6 +_,12 @@ +@@ -1293,6 +_,12 @@ } public Either startSleepInBed(BlockPos bedPos) { @@ -379,7 +379,7 @@ this.startSleeping(bedPos); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1395,7 +_,7 @@ +@@ -1404,7 +_,7 @@ @Override public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) { @@ -388,7 +388,7 @@ return false; } else { if (fallDistance >= 2.0) { -@@ -1436,7 +_,15 @@ +@@ -1445,7 +_,15 @@ } public void startFallFlying() { @@ -405,7 +405,7 @@ } @Override -@@ -1534,7 +_,7 @@ +@@ -1543,7 +_,7 @@ if (levels > 0 && this.experienceLevel % 5 == 0 && this.lastLevelUpTime < this.tickCount - 100.0F) { float f = this.experienceLevel > 30 ? 1.0F : this.experienceLevel / 30.0F; @@ -414,7 +414,7 @@ this.lastLevelUpTime = this.tickCount; } } -@@ -1542,15 +_,35 @@ +@@ -1551,15 +_,35 @@ public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { return 112 + (this.experienceLevel - 30) * 9; @@ -452,7 +452,7 @@ } } } -@@ -1805,7 +_,7 @@ +@@ -1818,7 +_,7 @@ @Override public void onAttack() { @@ -461,7 +461,7 @@ super.onAttack(); } -@@ -1840,17 +_,32 @@ +@@ -1853,17 +_,32 @@ return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } @@ -496,7 +496,7 @@ for (int i = 0; i < this.inventory.getContainerSize(); i++) { ItemStack item = this.inventory.getItem(i); -@@ -1859,6 +_,7 @@ +@@ -1872,6 +_,7 @@ } } @@ -504,7 +504,7 @@ return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; } } -@@ -1945,12 +_,20 @@ +@@ -1958,12 +_,20 @@ } public boolean hasClientLoaded() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch index c18de65f21b3..7e747f41c175 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -40,7 +40,7 @@ if (this.isAlive() && hitResult.getType() != HitResult.Type.MISS) { - this.hitTargetOrDeflectSelf(hitResult); + this.preHitTargetOrDeflectSelf(hitResult); // CraftBukkit - projectile hit event - this.hasImpulse = true; + this.needsSync = true; } break; @@ -290,7 +_,7 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch index 655f97818f9d..15e4b962ee8e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch @@ -14,7 +14,7 @@ if (!this.noPhysics && this.isAlive() && hitResultOnMoveVector.getType() != HitResult.Type.MISS) { - this.hitTargetOrDeflectSelf(hitResultOnMoveVector); + this.preHitTargetOrDeflectSelf(hitResultOnMoveVector); // CraftBukkit - projectile hit event - this.hasImpulse = true; + this.needsSync = true; } @@ -187,7 +_,11 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch index d569a2acd33b..4c32e25a43a5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch @@ -55,10 +55,10 @@ if (this.getHurtTime() > 0) { this.setHurtTime(this.getHurtTime() - 1); } -@@ -265,8 +_,20 @@ - } +@@ -266,8 +_,20 @@ this.checkBelowWorld(); + this.computeSpeed(); - this.handlePortal(); + // this.handlePortal(); // CraftBukkit - handled in postTick this.behavior.tick(); @@ -77,7 +77,7 @@ this.updateInWaterStateAndDoFluidPushing(); if (this.isInLava()) { this.lavaIgnite(); -@@ -354,12 +_,16 @@ +@@ -355,12 +_,16 @@ Vec3 deltaMovement = this.getDeltaMovement(); this.setDeltaMovement(Mth.clamp(deltaMovement.x, -maxSpeed, maxSpeed), deltaMovement.y, Mth.clamp(deltaMovement.z, -maxSpeed, maxSpeed)); if (this.onGround()) { @@ -96,7 +96,7 @@ } } -@@ -461,6 +_,15 @@ +@@ -462,6 +_,15 @@ this.setDisplayOffset(input.getIntOr("DisplayOffset", this.getDefaultDisplayOffset())); this.flipped = input.getBooleanOr("FlippedRotation", false); this.firstTick = input.getBooleanOr("HasTicked", false); @@ -112,7 +112,7 @@ } @Override -@@ -473,13 +_,26 @@ +@@ -474,13 +_,26 @@ output.putBoolean("FlippedRotation", this.flipped); output.putBoolean("HasTicked", this.firstTick); @@ -139,7 +139,7 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double d2 = d * d + d1 * d1; -@@ -588,4 +_,26 @@ +@@ -589,4 +_,26 @@ public boolean isFurnace() { return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch index bfc73e99d069..d2f7b286e9be 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch @@ -3,7 +3,7 @@ @@ -59,12 +_,12 @@ default void addChestVehicleSaveData(ValueOutput output) { if (this.getContainerLootTable() != null) { - output.putString("LootTable", this.getContainerLootTable().location().toString()); + output.putString("LootTable", this.getContainerLootTable().identifier().toString()); + this.lootableData().saveNbt(output); // Paper if (this.getContainerLootTableSeed() != 0L) { output.putLong("LootTableSeed", this.getContainerLootTableSeed()); diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch index 239c786ecddb..0a8bd3647751 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -3,7 +3,7 @@ @@ -31,19 +_,17 @@ public class EnchantmentMenu extends AbstractContainerMenu { - static final ResourceLocation EMPTY_SLOT_LAPIS_LAZULI = ResourceLocation.withDefaultNamespace("container/slot/lapis_lazuli"); + static final Identifier EMPTY_SLOT_LAPIS_LAZULI = Identifier.withDefaultNamespace("container/slot/lapis_lazuli"); - private final Container enchantSlots = new SimpleContainer(2) { - @Override - public void setChanged() { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch index 185263b89d9c..f0262737cac7 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch @@ -101,10 +101,10 @@ + return false; + } + -+ net.minecraft.resources.ResourceLocation key = org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()); -+ if (!recipe.get().id().location().equals(key)) { // If the recipe did NOT stay the same ++ net.minecraft.resources.Identifier key = org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()); ++ if (!recipe.get().id().identifier().equals(key)) { // If the recipe did NOT stay the same + for (int newRecipeIndex = 0; newRecipeIndex < this.recipesForInput.entries().size(); newRecipeIndex++) { -+ if (this.recipesForInput.entries().get(newRecipeIndex).recipe().recipe().filter(r -> r.id().location().equals(key)).isPresent()) { ++ if (this.recipesForInput.entries().get(newRecipeIndex).recipe().recipe().filter(r -> r.id().identifier().equals(key)).isPresent()) { + recipeIndex = newRecipeIndex; + break; + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/ItemCooldowns.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ItemCooldowns.java.patch index 4b0f5b28976f..902edf377e51 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ItemCooldowns.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ItemCooldowns.java.patch @@ -3,12 +3,12 @@ @@ -56,6 +_,13 @@ } - public void addCooldown(ResourceLocation group, int cooldown) { + public void addCooldown(Identifier group, int cooldown) { + // Paper start - Item cooldown events + this.addCooldown(group, cooldown, true); + } + -+ public void addCooldown(ResourceLocation group, int cooldown, boolean callEvent) { ++ public void addCooldown(Identifier group, int cooldown, boolean callEvent) { + // Event called in server override + // Paper end - Item cooldown events this.cooldowns.put(group, new ItemCooldowns.CooldownInstance(this.tickCount, this.tickCount + cooldown)); diff --git a/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch index 1cdcd7b2ee57..5d1dddfbae69 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/MaceItem.java +++ b/net/minecraft/world/item/MaceItem.java -@@ -53,7 +_,13 @@ +@@ -54,7 +_,13 @@ @Override public void hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) { @@ -15,7 +15,7 @@ ServerLevel serverLevel = (ServerLevel)attacker.level(); attacker.setDeltaMovement(attacker.getDeltaMovement().with(Direction.Axis.Y, 0.01F)); if (attacker instanceof ServerPlayer serverPlayer) { -@@ -128,7 +_,7 @@ +@@ -129,7 +_,7 @@ double knockbackPower = getKnockbackPower(attacker, livingEntity, vec3); Vec3 vec31 = vec3.normalize().scale(knockbackPower); if (knockbackPower > 0.0) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/ServerItemCooldowns.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ServerItemCooldowns.java.patch index bbc0b10653c8..3f975521c9f1 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ServerItemCooldowns.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ServerItemCooldowns.java.patch @@ -5,7 +5,7 @@ } + // Paper start - Add PlayerItemCooldownEvent -+ private int getCurrentCooldown(final ResourceLocation groupId) { ++ private int getCurrentCooldown(final Identifier groupId) { + final net.minecraft.world.item.ItemCooldowns.CooldownInstance cooldownInstance = this.cooldowns.get(groupId); + if (cooldownInstance == null) { + return 0; @@ -15,7 +15,7 @@ + + @Override + public void addCooldown(ItemStack item, int duration) { -+ final ResourceLocation cooldownGroup = this.getCooldownGroup(item); ++ final Identifier cooldownGroup = this.getCooldownGroup(item); + final io.papermc.paper.event.player.PlayerItemCooldownEvent event = new io.papermc.paper.event.player.PlayerItemCooldownEvent( + this.player.getBukkitEntity(), + org.bukkit.craftbukkit.inventory.CraftItemType.minecraftToBukkit(item.getItem()), @@ -30,7 +30,7 @@ + } + + @Override -+ public void addCooldown(ResourceLocation groupId, int duration, boolean callEvent) { ++ public void addCooldown(Identifier groupId, int duration, boolean callEvent) { + if (callEvent) { + final io.papermc.paper.event.player.PlayerItemGroupCooldownEvent event = new io.papermc.paper.event.player.PlayerItemGroupCooldownEvent( + this.player.getBukkitEntity(), @@ -49,5 +49,5 @@ + // Paper end - Add PlayerItemCooldownEvent + @Override - protected void onCooldownStarted(ResourceLocation group, int cooldown) { + protected void onCooldownStarted(Identifier group, int cooldown) { super.onCooldownStarted(group, cooldown); diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/TypedEntityData.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/TypedEntityData.java.patch index 164cb696762c..cf02814d415d 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/component/TypedEntityData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/component/TypedEntityData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/component/TypedEntityData.java +++ b/net/minecraft/world/item/component/TypedEntityData.java -@@ -78,6 +_,32 @@ +@@ -84,6 +_,32 @@ this.tag = stripId(tag); } @@ -33,7 +33,7 @@ public static TypedEntityData of(T type, CompoundTag tag) { return new TypedEntityData<>(type, tag); } -@@ -175,7 +_,7 @@ +@@ -181,7 +_,7 @@ public void addToTooltip(Item.TooltipContext context, Consumer tooltipAdder, TooltipFlag flag, DataComponentGetter componentGetter) { if (this.type.getClass() == EntityType.class) { EntityType entityType = (EntityType)this.type; diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeHolder.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeHolder.java.patch index 538297e2aa92..a62881aad338 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeHolder.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeHolder.java.patch @@ -6,7 +6,7 @@ + // CraftBukkit start + public final org.bukkit.inventory.Recipe toBukkitRecipe() { -+ return this.value.toBukkitRecipe(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.id.location())); ++ return this.value.toBukkitRecipe(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.id.identifier())); + } + // CraftBukkit end + diff --git a/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch b/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch index 952ccb273469..69112ac4b10c 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch @@ -13,7 +13,7 @@ public static final Codec CODEC = Codec.unboundedMap(Enchantment.CODEC, LEVEL_CODEC) .xmap( - map -> new ItemEnchantments(new Object2IntOpenHashMap<>((Map, ? extends Integer>)map)), -+ map -> new net.minecraft.world.item.enchantment.ItemEnchantments(net.minecraft.Util.make(new it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap<>(ENCHANTMENT_ORDER), m -> m.putAll(map))), // Paper - sort enchantments ++ map -> new net.minecraft.world.item.enchantment.ItemEnchantments(net.minecraft.util.Util.make(new it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap<>(ENCHANTMENT_ORDER), m -> m.putAll(map))), // Paper - sort enchantments itemEnchantments -> itemEnchantments.enchantments ); public static final StreamCodec STREAM_CODEC = StreamCodec.composite( diff --git a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch index 8eaee59b7567..b92398a3cda5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -85,6 +_,16 @@ +@@ -86,6 +_,16 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.jspecify.annotations.Nullable; @@ -16,9 +16,9 @@ + public abstract class Level implements LevelAccessor, AutoCloseable { public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); - public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("overworld")); + public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, Identifier.withDefaultNamespace("overworld")); @@ -127,6 +_,57 @@ - private final EnvironmentAttributeSystem environmentAttributes; + private final PalettedContainerFactory palettedContainerFactory; private long subTickCount; + // CraftBukkit start @@ -101,8 +101,8 @@ this.levelData = levelData; this.dimensionTypeRegistration = dimensionTypeRegistration; this.dimension = dimension; -@@ -151,6 +_,46 @@ - this.environmentAttributes = new EnvironmentAttributeSystem(dimensionTypeRegistration, registryAccess, this.biomeManager); +@@ -150,6 +_,46 @@ + this.damageSources = new DamageSources(registryAccess); } + // Paper start - Cancel hit for vanished players @@ -148,7 +148,7 @@ @Override public boolean isClientSide() { return this.isClientSide; -@@ -161,8 +_,15 @@ +@@ -160,8 +_,15 @@ return null; } @@ -165,7 +165,7 @@ } public static boolean isInSpawnableBounds(BlockPos pos) { -@@ -170,21 +_,86 @@ +@@ -169,21 +_,86 @@ } private static boolean isInWorldBoundsHorizontal(BlockPos pos) { @@ -257,7 +257,7 @@ @Override public @Nullable ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) { -@@ -203,6 +_,22 @@ +@@ -202,6 +_,22 @@ @Override public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags, int recursionLeft) { @@ -280,7 +280,7 @@ if (this.isOutsideBuildHeight(pos)) { return false; } else if (!this.isClientSide() && this.isDebug()) { -@@ -210,11 +_,31 @@ +@@ -209,11 +_,31 @@ } else { LevelChunk chunkAt = this.getChunkAt(pos); Block block = state.getBlock(); @@ -312,7 +312,7 @@ if (blockState1 == state) { if (blockState != blockState1) { this.setBlocksDirty(pos, blockState, blockState1); -@@ -242,12 +_,68 @@ +@@ -241,12 +_,68 @@ this.updatePOIOnBlockStateChange(pos, blockState, blockState1); } @@ -381,7 +381,7 @@ public void updatePOIOnBlockStateChange(BlockPos pos, BlockState oldState, BlockState newState) { } -@@ -264,13 +_,31 @@ +@@ -263,13 +_,31 @@ return false; } else { FluidState fluidState = this.getFluidState(pos); @@ -416,7 +416,7 @@ } boolean flag = this.setBlock(pos, fluidState.createLegacyBlock(), Block.UPDATE_ALL, recursionLeft); -@@ -336,10 +_,18 @@ +@@ -335,10 +_,18 @@ @Override public BlockState getBlockState(BlockPos pos) { @@ -436,7 +436,7 @@ return chunk.getBlockState(pos); } } -@@ -452,31 +_,47 @@ +@@ -437,31 +_,47 @@ this.pendingBlockEntityTickers.clear(); } @@ -492,7 +492,7 @@ public boolean shouldTickDeath(Entity entity) { return true; -@@ -600,6 +_,12 @@ +@@ -585,6 +_,12 @@ @Override public @Nullable BlockEntity getBlockEntity(BlockPos pos) { @@ -505,7 +505,7 @@ if (this.isOutsideBuildHeight(pos)) { return null; } else { -@@ -612,6 +_,12 @@ +@@ -597,6 +_,12 @@ public void setBlockEntity(BlockEntity blockEntity) { BlockPos blockPos = blockEntity.getBlockPos(); if (!this.isOutsideBuildHeight(blockPos)) { @@ -518,7 +518,7 @@ this.getChunkAt(blockPos).addAndRegisterBlockEntity(blockEntity); } } -@@ -1021,7 +_,8 @@ +@@ -1001,7 +_,8 @@ BLOCK("block"), MOB("mob"), TNT("tnt"), diff --git a/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch b/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch index 1985f297a44e..8f8e291a66b5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/LevelAccessor.java +++ b/net/minecraft/world/level/LevelAccessor.java -@@ -102,4 +_,6 @@ +@@ -97,4 +_,6 @@ default void gameEvent(ResourceKey gameEvent, BlockPos pos, GameEvent.Context context) { this.gameEvent(this.registryAccess().lookupOrThrow(Registries.GAME_EVENT).getOrThrow(gameEvent), pos, context); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch b/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch index a88e367251e8..4a607bcc0be0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch @@ -64,77 +64,79 @@ } d3 += d * 0.3F; -@@ -176,8 +_,8 @@ - int floor3 = Mth.floor(this.center.y + f + 1.0); - int floor4 = Mth.floor(this.center.z - f - 1.0); - int floor5 = Mth.floor(this.center.z + f + 1.0); +@@ -177,8 +_,8 @@ + int floor3 = Mth.floor(this.center.y + f + 1.0); + int floor4 = Mth.floor(this.center.z - f - 1.0); + int floor5 = Mth.floor(this.center.z + f + 1.0); - -- for (Entity entity : this.level.getEntities(this.source, new AABB(floor, floor2, floor4, floor1, floor3, floor5))) { -+ List list = this.level.getEntities(this.excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source -+ for (Entity entity : list) { // Paper - used in loop - if (!entity.ignoreExplosion(this)) { - double d = Math.sqrt(entity.distanceToSqr(this.center)) / f; - if (!(d > 1.0)) { -@@ -185,18 +_,54 @@ - Vec3 vec31 = vec3.subtract(this.center).normalize(); - boolean shouldDamageEntity = this.damageCalculator.shouldDamageEntity(this, entity); - float knockbackMultiplier = this.damageCalculator.getKnockbackMultiplier(entity); -- float f1 = !shouldDamageEntity && knockbackMultiplier == 0.0F ? 0.0F : getSeenPercent(this.center, entity); -+ float f1 = !shouldDamageEntity && knockbackMultiplier == 0.0F ? 0.0F : this.getBlockDensity(this.center, entity); // Paper - Optimize explosions - if (shouldDamageEntity) { -- entity.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f1)); -+ // CraftBukkit start +- for (Entity entity : this.level.getEntities(this.source, new AABB(floor, floor2, floor4, floor1, floor3, floor5))) { ++ List list = this.level.getEntities(this.excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source ++ for (Entity entity : list) { // Paper - used in loop + if (!entity.ignoreExplosion(this)) { + double d = Math.sqrt(entity.distanceToSqr(this.center)) / f; + if (!(d > 1.0)) { +@@ -186,20 +_,56 @@ + Vec3 vec31 = vec3.subtract(this.center).normalize(); + boolean shouldDamageEntity = this.damageCalculator.shouldDamageEntity(this, entity); + float knockbackMultiplier = this.damageCalculator.getKnockbackMultiplier(entity); +- float f1 = !shouldDamageEntity && knockbackMultiplier == 0.0F ? 0.0F : getSeenPercent(this.center, entity); ++ float f1 = !shouldDamageEntity && knockbackMultiplier == 0.0F ? 0.0F : this.getBlockDensity(this.center, entity); // Paper - Optimize explosions + if (shouldDamageEntity) { +- entity.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f1)); ++ // CraftBukkit start + -+ // Special case ender dragon only give knockback if no damage is cancelled -+ // Thinks to note: -+ // - Setting a velocity to a EnderDragonPart is ignored (and therefore not needed) -+ // - Damaging EnderDragonPart while forward the damage to EnderDragon -+ // - Damaging EnderDragon does nothing -+ // - EnderDragon hitbox always covers the other parts and is therefore always present -+ if (entity instanceof EnderDragonPart) { -+ continue; -+ } ++ // Special case ender dragon only give knockback if no damage is cancelled ++ // Thinks to note: ++ // - Setting a velocity to a EnderDragonPart is ignored (and therefore not needed) ++ // - Damaging EnderDragonPart while forward the damage to EnderDragon ++ // - Damaging EnderDragon does nothing ++ // - EnderDragon hitbox always covers the other parts and is therefore always present ++ if (entity instanceof EnderDragonPart) { ++ continue; ++ } + -+ entity.lastDamageCancelled = false; ++ entity.lastDamageCancelled = false; + -+ if (entity instanceof EnderDragon) { -+ for (EnderDragonPart dragonPart : ((EnderDragon) entity).getSubEntities()) { -+ // Calculate damage separately for each EntityComplexPart -+ if (list.contains(dragonPart)) { -+ dragonPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, dragonPart, f1)); ++ if (entity instanceof EnderDragon) { ++ for (EnderDragonPart dragonPart : ((EnderDragon) entity).getSubEntities()) { ++ // Calculate damage separately for each EntityComplexPart ++ if (list.contains(dragonPart)) { ++ dragonPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, dragonPart, f1)); ++ } + } ++ } else { ++ entity.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f1)); + } -+ } else { -+ entity.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f1)); -+ } + -+ if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled -+ continue; ++ if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled ++ continue; ++ } ++ // CraftBukkit end + } + + double d1 = entity instanceof LivingEntity livingEntity + ? livingEntity.getAttributeValue(Attributes.EXPLOSION_KNOCKBACK_RESISTANCE) + : 0.0; +- double d2 = (1.0 - d) * f1 * knockbackMultiplier * (1.0 - d1); ++ double d2 = entity instanceof Player && this.level.paperConfig().environment.disableExplosionKnockback ? 0 : (1.0 - d) * f1 * knockbackMultiplier * (1.0 - d1); // Paper + Vec3 vec32 = vec31.scale(d2); ++ // CraftBukkit start - Call EntityKnockbackEvent ++ if (entity instanceof LivingEntity) { ++ // Paper start - knockback events ++ io.papermc.paper.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), this.source, this.damageSource.getEntity() != null ? this.damageSource.getEntity() : this.source, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.EXPLOSION, d2, vec32); ++ vec32 = event.isCancelled() ? Vec3.ZERO : org.bukkit.craftbukkit.util.CraftVector.toVec3(event.getKnockback()); ++ // Paper end - knockback events + } + // CraftBukkit end - } - - double d1 = entity instanceof LivingEntity livingEntity ? livingEntity.getAttributeValue(Attributes.EXPLOSION_KNOCKBACK_RESISTANCE) : 0.0; -- double d2 = (1.0 - d) * f1 * knockbackMultiplier * (1.0 - d1); -+ double d2 = entity instanceof Player && this.level.paperConfig().environment.disableExplosionKnockback ? 0 : (1.0 - d) * f1 * knockbackMultiplier * (1.0 - d1); // Paper - Vec3 vec32 = vec31.scale(d2); -+ // CraftBukkit start - Call EntityKnockbackEvent -+ if (entity instanceof LivingEntity) { -+ // Paper start - knockback events -+ io.papermc.paper.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), this.source, this.damageSource.getEntity() != null ? this.damageSource.getEntity() : this.source, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.EXPLOSION, d2, vec32); -+ vec32 = event.isCancelled() ? Vec3.ZERO : org.bukkit.craftbukkit.util.CraftVector.toVec3(event.getKnockback()); -+ // Paper end - knockback events -+ } -+ // CraftBukkit end - entity.push(vec32); - if (entity.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && entity instanceof Projectile projectile) { - projectile.setOwner(this.damageSource.getEntity()); -- } else if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying)) { -+ } else if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback - this.hitPlayers.put(player, vec32); - } + entity.push(vec32); + if (entity.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && entity instanceof Projectile projectile) { + projectile.setOwner(this.damageSource.getEntity()); +- } else if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying)) { ++ } else if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback + this.hitPlayers.put(player, vec32); + } -@@ -210,7 +_,56 @@ +@@ -214,7 +_,56 @@ List list = new ArrayList<>(); Util.shuffle(blocks, this.level.random); @@ -191,7 +193,7 @@ this.level .getBlockState(blockPos) .onExplosionHit(this.level, blockPos, this, (itemStack, blockPos1) -> addOrAppendStack(list, itemStack, blockPos1)); -@@ -224,7 +_,11 @@ +@@ -228,7 +_,11 @@ private void createFire(List blocks) { for (BlockPos blockPos : blocks) { if (this.level.random.nextInt(3) == 0 && this.level.getBlockState(blockPos).isAir() && this.level.getBlockState(blockPos.below()).isSolidRender()) { @@ -204,7 +206,7 @@ } } } -@@ -322,4 +_,86 @@ +@@ -326,4 +_,86 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch index e0cfede41022..8e8a4959038e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DaylightDetectorBlock.java +++ b/net/minecraft/world/level/block/DaylightDetectorBlock.java -@@ -70,6 +_,7 @@ +@@ -71,6 +_,7 @@ i = Mth.clamp(i, 0, 15); if (state.getValue(POWER) != i) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch index 9d85e5f8b437..6bd8c0239747 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FlowerPotBlock.java +++ b/net/minecraft/world/level/block/FlowerPotBlock.java -@@ -66,6 +_,18 @@ +@@ -67,6 +_,18 @@ } else if (!this.isEmpty()) { return InteractionResult.CONSUME; } else { @@ -19,7 +19,7 @@ level.setBlock(pos, blockState, Block.UPDATE_ALL); level.gameEvent(player, GameEvent.BLOCK_CHANGE, pos); player.awardStat(Stats.POT_FLOWER); -@@ -80,6 +_,18 @@ +@@ -81,6 +_,18 @@ return InteractionResult.CONSUME; } else { ItemStack itemStack = new ItemStack(this.potted); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch index 0efd1a5c33fa..a10acf0be51c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TurtleEggBlock.java +++ b/net/minecraft/world/level/block/TurtleEggBlock.java -@@ -74,6 +_,19 @@ +@@ -75,6 +_,19 @@ && level instanceof ServerLevel serverLevel && this.canDestroyEgg(serverLevel, entity) && level.random.nextInt(chance) == 0) { @@ -20,8 +20,8 @@ this.decreaseEggs(serverLevel, pos, state); } } -@@ -95,10 +_,19 @@ - if (this.shouldUpdateHatchLevel(level) && onSand(level, pos)) { +@@ -96,10 +_,19 @@ + if (this.shouldUpdateHatchLevel(level, pos) && onSand(level, pos)) { int hatchValue = state.getValue(HATCH); if (hatchValue < 2) { + // CraftBukkit start - Call BlockGrowEvent @@ -41,7 +41,7 @@ level.playSound(null, pos, SoundEvents.TURTLE_EGG_HATCH, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); level.removeBlock(pos, false); level.gameEvent(GameEvent.BLOCK_DESTROY, pos, GameEvent.Context.of(state)); -@@ -110,7 +_,7 @@ +@@ -111,7 +_,7 @@ turtle.setAge(-24000); turtle.setHomePos(pos); turtle.snapTo(pos.getX() + 0.3 + i * 0.2, pos.getY(), pos.getZ() + 0.3, 0.0F, 0.0F); @@ -50,7 +50,7 @@ } } } -@@ -142,8 +_,8 @@ +@@ -139,8 +_,8 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch index 45531f6515a1..0ee4679347a5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -@@ -84,6 +_,7 @@ +@@ -85,6 +_,7 @@ public static final int MIN_OCCUPATION_TICKS_NECTARLESS = 600; private List stored = Lists.newArrayList(); public @Nullable BlockPos savedFlowerPos; @@ -8,7 +8,7 @@ public BeehiveBlockEntity(BlockPos pos, BlockState blockState) { super(BlockEntityType.BEEHIVE, pos, blockState); -@@ -117,7 +_,7 @@ +@@ -118,7 +_,7 @@ } public boolean isFull() { @@ -17,7 +17,7 @@ } public void emptyAllLivingFromHive(@Nullable Player player, BlockState state, BeehiveBlockEntity.BeeReleaseStatus releaseStatus) { -@@ -126,7 +_,7 @@ +@@ -127,7 +_,7 @@ for (Entity entity : list) { if (entity instanceof Bee bee && player.position().distanceToSqr(entity.position()) <= 16.0) { if (!this.isSedated()) { @@ -26,7 +26,7 @@ } else { bee.setStayOutOfHiveCountdown(400); } -@@ -136,8 +_,14 @@ +@@ -137,8 +_,14 @@ } private List releaseAllOccupants(BlockState state, BeehiveBlockEntity.BeeReleaseStatus releaseStatus) { @@ -42,7 +42,7 @@ if (!list.isEmpty()) { super.setChanged(); } -@@ -150,6 +_,11 @@ +@@ -151,6 +_,11 @@ return this.stored.size(); } @@ -54,7 +54,7 @@ public static int getHoneyLevel(BlockState state) { return state.getValue(BeehiveBlock.HONEY_LEVEL); } -@@ -160,7 +_,16 @@ +@@ -161,7 +_,16 @@ } public void addOccupant(Bee bee) { @@ -72,7 +72,7 @@ bee.stopRiding(); bee.ejectPassengers(); bee.dropLeash(); -@@ -185,7 +_,7 @@ +@@ -186,7 +_,7 @@ this.level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(bee, this.getBlockState())); } @@ -81,11 +81,12 @@ super.setChanged(); } } -@@ -203,7 +_,21 @@ +@@ -204,8 +_,21 @@ BeehiveBlockEntity.BeeReleaseStatus releaseStatus, @Nullable BlockPos storedFlowerPos ) { -- if (Bee.isNightOrRaining(level) && releaseStatus != BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY) { +- if (level.environmentAttributes().getValue(EnvironmentAttributes.BEES_STAY_IN_HIVE, pos) +- && releaseStatus != BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY) { + // CraftBukkit start + return releaseOccupant(level, pos, state, occupant, storedInHives, releaseStatus, storedFlowerPos, false); + } @@ -99,12 +100,12 @@ + @Nullable BlockPos storedFlowerPos, + boolean force + ) { -+ if (!force && Bee.isNightOrRaining(level) && releaseStatus != BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY) { ++ if (!force && level.environmentAttributes().getValue(EnvironmentAttributes.BEES_STAY_IN_HIVE, pos) && releaseStatus != BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY) { + // CraftBukkit end return false; } else { Direction direction = state.getValue(BeehiveBlock.FACING); -@@ -214,6 +_,17 @@ +@@ -216,6 +_,17 @@ } else { Entity entity = occupant.createEntity(level, pos); if (entity != null) { @@ -122,7 +123,7 @@ if (entity instanceof Bee bee) { if (storedFlowerPos != null && !bee.hasSavedFlowerPos() && level.random.nextFloat() < 0.9F) { bee.setSavedFlowerPos(storedFlowerPos); -@@ -229,7 +_,13 @@ +@@ -231,7 +_,13 @@ i--; } @@ -137,7 +138,7 @@ } } } -@@ -238,17 +_,19 @@ +@@ -240,17 +_,19 @@ storedInHives.add(bee); } @@ -158,7 +159,7 @@ } else { return false; } -@@ -274,6 +_,11 @@ +@@ -276,6 +_,11 @@ flag = true; iterator.remove(); } @@ -170,7 +171,7 @@ } } -@@ -295,9 +_,10 @@ +@@ -297,9 +_,10 @@ @Override protected void loadAdditional(ValueInput input) { super.loadAdditional(input); @@ -182,7 +183,7 @@ } @Override -@@ -305,12 +_,13 @@ +@@ -307,12 +_,13 @@ super.saveAdditional(output); output.store("bees", BeehiveBlockEntity.Occupant.LIST_CODEC, this.getBees()); output.storeNullable("flower_pos", BlockPos.CODEC, this.savedFlowerPos); @@ -197,7 +198,7 @@ List list = componentGetter.getOrDefault(DataComponents.BEES, Bees.EMPTY).bees(); list.forEach(this::storeBee); } -@@ -338,15 +_,18 @@ +@@ -340,15 +_,18 @@ static class BeeData { private final BeehiveBlockEntity.Occupant occupant; @@ -217,7 +218,7 @@ } public BeehiveBlockEntity.Occupant toOccupant() { -@@ -420,6 +_,7 @@ +@@ -422,6 +_,7 @@ } private static void setBeeReleaseData(int ticksInHive, Bee bee) { @@ -225,7 +226,7 @@ int age = bee.getAge(); if (age < 0) { bee.setAge(Math.min(0, age + ticksInHive)); -@@ -428,6 +_,7 @@ +@@ -430,6 +_,7 @@ } bee.setInLoveTime(Math.max(0, bee.getInLoveTime() - ticksInHive)); diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch index 865117b6b939..30d517aba8b1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch @@ -41,8 +41,8 @@ + return list.stream().map((holder) -> { + StructureSet structureset = holder.value(); + final Holder newHolder; // Paper - Add missing structure set seed configs -+ if (structureset.placement() instanceof net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement randomConfig && holder.unwrapKey().orElseThrow().location().getNamespace().equals(net.minecraft.resources.ResourceLocation.DEFAULT_NAMESPACE)) { // Paper - Add missing structure set seed configs; check namespace cause datapacks could add structure sets with the same path -+ String name = holder.unwrapKey().orElseThrow().location().getPath(); ++ if (structureset.placement() instanceof net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement randomConfig && holder.unwrapKey().orElseThrow().identifier().getNamespace().equals(net.minecraft.resources.Identifier.DEFAULT_NAMESPACE)) { // Paper - Add missing structure set seed configs; check namespace cause datapacks could add structure sets with the same path ++ String name = holder.unwrapKey().orElseThrow().identifier().getPath(); + int seed = randomConfig.salt; + + switch (name) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEvent.java.patch b/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEvent.java.patch index be2290d7c916..efcac86d58ce 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEvent.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEvent.java.patch @@ -4,8 +4,8 @@ } private static Holder.Reference register(String name, int notificationRadius) { -- return Registry.registerForHolder(BuiltInRegistries.GAME_EVENT, ResourceLocation.withDefaultNamespace(name), new GameEvent(notificationRadius)); -+ return io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.registerForHolderWithListeners(BuiltInRegistries.GAME_EVENT, ResourceLocation.withDefaultNamespace(name), new GameEvent(notificationRadius)); // Paper - run with listeners +- return Registry.registerForHolder(BuiltInRegistries.GAME_EVENT, Identifier.withDefaultNamespace(name), new GameEvent(notificationRadius)); ++ return io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.registerForHolderWithListeners(BuiltInRegistries.GAME_EVENT, Identifier.withDefaultNamespace(name), new GameEvent(notificationRadius)); // Paper - run with listeners } public record Context(@Nullable Entity sourceEntity, @Nullable BlockState affectedState) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch index 88cc5fdf97cb..76603adde963 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/PatrolSpawner.java +++ b/net/minecraft/world/level/levelgen/PatrolSpawner.java -@@ -20,18 +_,47 @@ +@@ -18,17 +_,47 @@ @Override public void tick(ServerLevel level, boolean spawnEnemies) { @@ -11,8 +11,7 @@ - this.nextTick--; - if (this.nextTick <= 0) { - this.nextTick = this.nextTick + 12000 + randomSource.nextInt(1200); -- long dayCount = level.getDayCount(); -- if (dayCount >= 5L && level.isBrightOutside()) { +- if (level.isBrightOutside()) { - if (randomSource.nextInt(5) == 0) { - int size = level.players().size(); + // this.nextTick--; @@ -56,7 +55,7 @@ if (!player.isSpectator()) { if (!level.isCloseToVillage(player.blockPosition(), 2)) { int i = (24 + randomSource.nextInt(24)) * (randomSource.nextBoolean() ? -1 : 1); -@@ -88,7 +_,7 @@ +@@ -84,7 +_,7 @@ patrollingMonster.setPos(pos.getX(), pos.getY(), pos.getZ()); patrollingMonster.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EntitySpawnReason.PATROL, null); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch index b1642fdef4c5..75dc3003e1a4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java -@@ -314,14 +_,20 @@ +@@ -308,14 +_,20 @@ @Override protected void handleDataMarker(String name, BlockPos pos, ServerLevelAccessor level, RandomSource random, BoundingBox box) { if ("chest".equals(name)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch index b488224d8d8c..ab7b5675fab3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -45,7 +45,7 @@ + } else if (dimensionType == LevelStem.END) { + return path.resolve("DIM1"); + } else { -+ return path.resolve("dimensions").resolve(dimensionType.location().getNamespace()).resolve(dimensionType.location().getPath()); ++ return path.resolve("dimensions").resolve(dimensionType.identifier().getNamespace()).resolve(dimensionType.identifier().getPath()); + } + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootDataType.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootDataType.java.patch index 521ff0103e15..0b8df8cc19cd 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootDataType.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootDataType.java.patch @@ -12,7 +12,7 @@ + value.validate( + context.setContextKeySet(value.getParamSet()).enterElement(new ProblemReporter.RootElementPathElement(key), key) + ); -+ value.craftLootTable = new org.bukkit.craftbukkit.CraftLootTable(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(key.location()), value); ++ value.craftLootTable = new org.bukkit.craftbukkit.CraftLootTable(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(key.identifier()), value); + // CraftBukkit end + }; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch index e94a2298f50f..3e2647744fbb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch @@ -6,7 +6,7 @@ private final BiFunction compositeFunction; + public org.bukkit.craftbukkit.CraftLootTable craftLootTable; // CraftBukkit - LootTable(ContextKeySet paramSet, Optional randomSequence, List pools, List functions) { + LootTable(ContextKeySet paramSet, Optional randomSequence, List pools, List functions) { this.paramSet = paramSet; @@ -63,9 +_,10 @@ } diff --git a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java index 6f33eb70ba1f..4158b36deffd 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java @@ -14,7 +14,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.monster.RangedAttackMob; import org.apache.commons.lang3.math.NumberUtils; diff --git a/paper-server/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java b/paper-server/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java index 581e988bd7dc..9863aed2417e 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java @@ -1,6 +1,6 @@ package com.destroystokyo.paper.gui; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.server.MinecraftServer; import net.minecraft.util.TimeUtil; diff --git a/paper-server/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/paper-server/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java index f8fa27f99ac6..b4ce727bd292 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java @@ -9,7 +9,7 @@ import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.PropertyMap; import io.papermc.paper.profile.MutablePropertyMap; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.UUIDUtil; import net.minecraft.server.MinecraftServer; import net.minecraft.server.players.NameAndId; diff --git a/paper-server/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java b/paper-server/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java index cc65129c868a..fcd94bb0b7d2 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java @@ -15,7 +15,7 @@ import javax.crypto.spec.SecretKeySpec; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.login.custom.CustomQueryPayload; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.entity.player.ProfilePublicKey; /** @@ -35,7 +35,7 @@ public class VelocityProxy { public static final int MODERN_FORWARDING_WITH_KEY_V2 = 3; public static final int MODERN_LAZY_SESSION = 4; public static final byte MAX_SUPPORTED_FORWARDING_VERSION = MODERN_LAZY_SESSION; - public static final ResourceLocation PLAYER_INFO_CHANNEL = ResourceLocation.fromNamespaceAndPath("velocity", "player_info"); + public static final Identifier PLAYER_INFO_CHANNEL = Identifier.fromNamespaceAndPath("velocity", "player_info"); public static boolean checkIntegrity(final FriendlyByteBuf buf) { final byte[] signature = new byte[32]; diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java b/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java index 34dc37f83538..fad4840d2c11 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java @@ -195,7 +195,7 @@ public String getSerializedName() { ).apply(instance, (key, uuid, component) -> HoverEvent.showEntity(key, uuid, component.orElse(null)))); static final MapCodec> SHOW_ITEM_CODEC = net.minecraft.network.chat.HoverEvent.ShowItem.CODEC.xmap(internal -> { - @Subst("key") final String typeKey = internal.item().getItemHolder().unwrapKey().orElseThrow().location().toString(); + @Subst("key") final String typeKey = internal.item().getItemHolder().unwrapKey().orElseThrow().identifier().toString(); return HoverEvent.showItem(Key.key(typeKey), internal.item().getCount(), PaperAdventure.asAdventure(internal.item().getComponentsPatch())); }, adventure -> { final Item itemType = BuiltInRegistries.ITEM.getValue(PaperAdventure.asVanilla(adventure.value().item())); diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/paper-server/src/main/java/io/papermc/paper/adventure/ChatProcessor.java index f6266b3ca9c0..965ddeb8f575 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/ChatProcessor.java @@ -22,13 +22,13 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.minecraft.ChatFormatting; import net.minecraft.Optionull; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.OutgoingChatMessage; import net.minecraft.network.chat.PlayerChatMessage; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import org.bukkit.command.ConsoleCommandSender; @@ -50,7 +50,7 @@ @DefaultQualifier(NonNull.class) public final class ChatProcessor { - static final ResourceKey PAPER_RAW = ResourceKey.create(Registries.CHAT_TYPE, ResourceLocation.fromNamespaceAndPath(ResourceLocation.PAPER_NAMESPACE, "raw")); + static final ResourceKey PAPER_RAW = ResourceKey.create(Registries.CHAT_TYPE, Identifier.fromNamespaceAndPath(Identifier.PAPER_NAMESPACE, "raw")); static final String DEFAULT_LEGACY_FORMAT = "<%1$s> %2$s"; // copied from PlayerChatEvent/AsyncPlayerChatEvent final MinecraftServer server; final ServerPlayer player; @@ -280,7 +280,7 @@ private void broadcastToViewers(Collection viewers, final ChatType.Bou private net.kyori.adventure.chat.ChatType.Bound adventure(ChatType.Bound chatType) { @Subst("key:value") final String stringKey = Objects.requireNonNull( - chatType.chatType().unwrapKey().orElseThrow().location(), + chatType.chatType().unwrapKey().orElseThrow().identifier(), () -> "No key for '%s' in CHAT_TYPE registry.".formatted(chatType) ).toString(); net.kyori.adventure.chat.@Nullable ChatType adventure = BUILT_IN_CHAT_TYPES.get(stringKey); diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java index 1ab8c51e820d..f488223c89bf 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java @@ -54,7 +54,7 @@ import net.minecraft.network.protocol.game.ClientboundSoundPacket; import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.network.Filterable; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; @@ -146,12 +146,12 @@ private PaperAdventure() { // Key - public static Key asAdventure(final ResourceLocation key) { + public static Key asAdventure(final Identifier key) { return Key.key(key.getNamespace(), key.getPath()); } - public static ResourceLocation asVanilla(final Key key) { - return ResourceLocation.fromNamespaceAndPath(key.namespace(), key.value()); + public static Identifier asVanilla(final Key key) { + return Identifier.fromNamespaceAndPath(key.namespace(), key.value()); } public static ResourceKey asVanilla( @@ -162,10 +162,10 @@ public static ResourceKey asVanilla( } public static Key asAdventureKey(final ResourceKey key) { - return asAdventure(key.location()); + return asAdventure(key.identifier()); } - public static @Nullable ResourceLocation asVanillaNullable(final Key key) { + public static @Nullable Identifier asVanillaNullable(final Key key) { if (key == null) { return null; } @@ -173,7 +173,7 @@ public static Key asAdventureKey(final ResourceKey key) { } public static Holder resolveSound(final Key key) { - ResourceLocation id = asVanilla(key); + Identifier id = asVanilla(key); Optional> vanilla = BuiltInRegistries.SOUND_EVENT.get(id); if (vanilla.isPresent()) { return vanilla.get(); @@ -381,7 +381,7 @@ public static SoundSource asVanilla(final Sound.Source source) { } public static Packet asSoundPacket(final Sound sound, final double x, final double y, final double z, final long seed, @Nullable BiConsumer, Float> packetConsumer) { - final ResourceLocation name = asVanilla(sound.name()); + final Identifier name = asVanilla(sound.name()); final Optional soundEvent = BuiltInRegistries.SOUND_EVENT.getOptional(name); final SoundSource source = asVanilla(sound.source()); @@ -394,7 +394,7 @@ public static Packet asSoundPacket(final Sound sound, final double x, final d } public static Packet asSoundPacket(final Sound sound, final Entity emitter, final long seed, @Nullable BiConsumer, Float> packetConsumer) { - final ResourceLocation name = asVanilla(sound.name()); + final Identifier name = asVanilla(sound.name()); final Optional soundEvent = BuiltInRegistries.SOUND_EVENT.getOptional(name); final SoundSource source = asVanilla(sound.source()); diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/providers/ClickCallbackProviderImpl.java b/paper-server/src/main/java/io/papermc/paper/adventure/providers/ClickCallbackProviderImpl.java index e62cfa5f47f5..85b8c1dcc5f9 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/providers/ClickCallbackProviderImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/providers/ClickCallbackProviderImpl.java @@ -19,7 +19,7 @@ import net.minecraft.core.UUIDUtil; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.NotNull; @SuppressWarnings("UnstableApiUsage") // permitted provider @@ -85,11 +85,11 @@ void doRunCallback(final @NotNull Audience audience, final Key key, final Tag ta abstract static class CallbackManager { - private final Predicate locationPredicate; + private final Predicate locationPredicate; protected final Map> callbacks = new HashMap<>(); private final Queue> queue = new ConcurrentLinkedQueue<>(); - protected CallbackManager(final Predicate locationPredicate) { + protected CallbackManager(final Predicate locationPredicate) { this.locationPredicate = locationPredicate; } @@ -125,7 +125,7 @@ final void tryConsumeCallback(final I key, final Consumer callbackCon abstract void doRunCallback(final @NotNull Audience audience, final Key key, final Tag tag); - public final void tryRunCallback(final @NotNull Audience audience, final ResourceLocation key, final Optional tag) { + public final void tryRunCallback(final @NotNull Audience audience, final Identifier key, final Optional tag) { if (!this.locationPredicate.test(key) || tag.isEmpty()) return; this.doRunCallback(audience, PaperAdventure.asAdventure(key), tag.get()); } diff --git a/paper-server/src/main/java/io/papermc/paper/command/CommandUtil.java b/paper-server/src/main/java/io/papermc/paper/command/CommandUtil.java index 953c30500892..a9443f24971f 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/CommandUtil.java +++ b/paper-server/src/main/java/io/papermc/paper/command/CommandUtil.java @@ -8,7 +8,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.command.CommandSender; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.framework.qual.DefaultQualifier; @@ -56,7 +56,7 @@ public static List getListMatchingLast( while (iterator.hasNext()) { Object object = iterator.next(); - if (object instanceof ResourceLocation && matches(last, ((ResourceLocation) object).getPath())) { + if (object instanceof Identifier && matches(last, ((Identifier) object).getPath())) { results.add(String.valueOf(object)); } } diff --git a/paper-server/src/main/java/io/papermc/paper/command/PaperCommand.java b/paper-server/src/main/java/io/papermc/paper/command/PaperCommand.java index 33b10d4eb634..b629a9a37ce7 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/PaperCommand.java +++ b/paper-server/src/main/java/io/papermc/paper/command/PaperCommand.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import net.minecraft.Util; +import net.minecraft.util.Util; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.command.Command; diff --git a/paper-server/src/main/java/io/papermc/paper/command/brigadier/argument/VanillaArgumentProviderImpl.java b/paper-server/src/main/java/io/papermc/paper/command/brigadier/argument/VanillaArgumentProviderImpl.java index d1309cc51f8e..bff395667f69 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/brigadier/argument/VanillaArgumentProviderImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/command/brigadier/argument/VanillaArgumentProviderImpl.java @@ -49,7 +49,7 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.Style; import net.kyori.adventure.text.format.TextColor; -import net.minecraft.advancements.critereon.MinMaxBounds; +import net.minecraft.advancements.criterion.MinMaxBounds; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.AngleArgument; import net.minecraft.commands.arguments.ColorArgument; @@ -66,7 +66,7 @@ import net.minecraft.commands.arguments.RangeArgument; import net.minecraft.commands.arguments.ResourceArgument; import net.minecraft.commands.arguments.ResourceKeyArgument; -import net.minecraft.commands.arguments.ResourceLocationArgument; +import net.minecraft.commands.arguments.IdentifierArgument; import net.minecraft.commands.arguments.ScoreboardSlotArgument; import net.minecraft.commands.arguments.StyleArgument; import net.minecraft.commands.arguments.TemplateMirrorArgument; @@ -318,12 +318,12 @@ public ArgumentType scoreboardDisplaySlot() { @Override public ArgumentType namespacedKey() { - return this.wrap(ResourceLocationArgument.id(), CraftNamespacedKey::fromMinecraft); + return this.wrap(IdentifierArgument.id(), CraftNamespacedKey::fromMinecraft); } @Override public ArgumentType key() { - return this.wrap(ResourceLocationArgument.id(), CraftNamespacedKey::fromMinecraft); + return this.wrap(IdentifierArgument.id(), CraftNamespacedKey::fromMinecraft); } @Override @@ -407,7 +407,7 @@ public ArgumentType templateRotation() { public ArgumentType> resourceKey(final RegistryKey registryKey) { return this.wrap( ResourceKeyArgument.key(PaperRegistries.registryToNms(registryKey)), - nmsRegistryKey -> TypedKey.create(registryKey, CraftNamespacedKey.fromMinecraft(nmsRegistryKey.location())) + nmsRegistryKey -> TypedKey.create(registryKey, CraftNamespacedKey.fromMinecraft(nmsRegistryKey.identifier())) ); } @@ -424,7 +424,7 @@ private ArgumentType resourceRaw(final RegistryKey regis resource -> requireNonNull( RegistryAccess.registryAccess() .getRegistry(registryKey) - .get(CraftNamespacedKey.fromMinecraft(resource.key().location())) + .get(CraftNamespacedKey.fromMinecraft(resource.key().identifier())) ) ); } diff --git a/paper-server/src/main/java/io/papermc/paper/command/subcommands/DumpItemCommand.java b/paper-server/src/main/java/io/papermc/paper/command/subcommands/DumpItemCommand.java index b4b90c1bda72..4c3d5712c677 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/subcommands/DumpItemCommand.java +++ b/paper-server/src/main/java/io/papermc/paper/command/subcommands/DumpItemCommand.java @@ -65,7 +65,7 @@ private void doDumpItem(final CommandSender sender, final boolean includeAllComp final ItemStack itemStack = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand()); final TextComponent.Builder visualOutput = Component.text(); final StringBuilder itemCommandBuilder = new StringBuilder(); - final String itemName = itemStack.getItemHolder().unwrapKey().orElseThrow().location().toString(); + final String itemName = itemStack.getItemHolder().unwrapKey().orElseThrow().identifier().toString(); itemCommandBuilder.append(itemName); visualOutput.append(text(itemName, YELLOW)); // item type final Set> referencedComponentTypes = Collections.newSetFromMap(new IdentityHashMap<>()); @@ -82,7 +82,7 @@ private void doDumpItem(final CommandSender sender, final boolean includeAllComp final List componentComponents = new ArrayList<>(); final List commandComponents = new ArrayList<>(); for (final DataComponentType type : referencedComponentTypes) { - final String path = registry.getResourceKey(type).orElseThrow().location().getPath(); + final String path = registry.getResourceKey(type).orElseThrow().identifier().getPath(); final @Nullable Optional patchedValue = patch.get(type); final @Nullable TypedDataComponent prototypeValue = prototype.getTyped(type); if (patchedValue != null) { diff --git a/paper-server/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java b/paper-server/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java index e3ddc201b328..e3e21acb82b5 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java +++ b/paper-server/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java @@ -14,7 +14,7 @@ import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.EntityType; @@ -73,7 +73,7 @@ private void listEntities(final CommandSender sender, final String[] args) { filter = args[1]; } final String cleanfilter = filter.replace("?", ".?").replace("*", ".*?"); - Set names = BuiltInRegistries.ENTITY_TYPE.keySet().stream() + Set names = BuiltInRegistries.ENTITY_TYPE.keySet().stream() .filter(n -> n.toString().matches(cleanfilter)) .collect(Collectors.toSet()); if (names.isEmpty()) { @@ -92,7 +92,7 @@ private void listEntities(final CommandSender sender, final String[] args) { sender.sendMessage(text("Usage: /paper entity list [filter] [worldName]", RED)); return; } - Map>> list = Maps.newHashMap(); + Map>> list = Maps.newHashMap(); @Nullable World bukkitWorld = Bukkit.getWorld(worldName); if (bukkitWorld == null) { sender.sendMessage(text("Could not load world for " + worldName + ". Please select a valid world.", RED)); @@ -100,10 +100,10 @@ private void listEntities(final CommandSender sender, final String[] args) { return; } ServerLevel world = ((CraftWorld) bukkitWorld).getHandle(); - Map nonEntityTicking = Maps.newHashMap(); + Map nonEntityTicking = Maps.newHashMap(); ServerChunkCache chunkProviderServer = world.getChunkSource(); FeatureHooks.getAllEntities(world).forEach(e -> { - ResourceLocation key = EntityType.getKey(e.getType()); + Identifier key = EntityType.getKey(e.getType()); MutablePair> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap())); ChunkPos chunk = e.chunkPosition(); @@ -114,7 +114,7 @@ private void listEntities(final CommandSender sender, final String[] args) { } }); if (names.size() == 1) { - ResourceLocation name = names.iterator().next(); + Identifier name = names.iterator().next(); Pair> info = list.get(name); int nonTicking = nonEntityTicking.getOrDefault(name, 0); if (info == null) { @@ -133,7 +133,7 @@ private void listEntities(final CommandSender sender, final String[] args) { sender.sendMessage(message); }); } else { - List> info = list.entrySet().stream() + List> info = list.entrySet().stream() .filter(e -> names.contains(e.getKey())) .map(e -> Pair.of(e.getKey(), e.getValue().left)) .sorted((a, b) -> !a.getRight().equals(b.getRight()) ? b.getRight() - a.getRight() : a.getKey().toString().compareTo(b.getKey().toString())) diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/Configurations.java b/paper-server/src/main/java/io/papermc/paper/configuration/Configurations.java index 964951251ed4..889051d2d6e6 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/Configurations.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/Configurations.java @@ -16,7 +16,7 @@ import java.util.Objects; import java.util.function.UnaryOperator; import net.minecraft.core.RegistryAccess; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.gamerules.GameRules; import org.jetbrains.annotations.MustBeInvokedByOverriders; @@ -35,7 +35,7 @@ public abstract class Configurations { private static final Logger LOGGER = LogUtils.getClassLogger(); public static final String WORLD_DEFAULTS = "__world_defaults__"; - public static final ResourceLocation WORLD_DEFAULTS_KEY = ResourceLocation.fromNamespaceAndPath("configurations", WORLD_DEFAULTS); + public static final Identifier WORLD_DEFAULTS_KEY = Identifier.fromNamespaceAndPath("configurations", WORLD_DEFAULTS); protected final Path globalFolder; protected final Class globalConfigClass; protected final Class worldConfigClass; @@ -341,7 +341,7 @@ public ContextMap build() { public static final ContextKey WORLD_DIRECTORY = new ContextKey<>(Path.class, "world directory"); public static final ContextKey WORLD_NAME = new ContextKey<>(String.class, "world name"); // TODO remove when we deprecate level names - public static final ContextKey WORLD_KEY = new ContextKey<>(ResourceLocation.class, "world key"); + public static final ContextKey WORLD_KEY = new ContextKey<>(Identifier.class, "world key"); public static final ContextKey FIRST_DEFAULT = new ContextKey<>(Void.class, "first default"); public static final ContextKey REGISTRY_ACCESS = new ContextKey<>(RegistryAccess.class, "registry access"); public static final ContextKey GAME_RULES = new ContextKey<>(GameRules.class, "game rules"); diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/paper-server/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java index 81553c3f08bf..1ae8f8587fc9 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java @@ -12,7 +12,7 @@ import net.minecraft.core.component.DataComponents; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ServerboundPlaceRecipePacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.spongepowered.configurate.objectmapping.ConfigSerializable; @@ -374,7 +374,7 @@ public class Items extends ConfigurationPart { Set.of() ); - public Map modelOverrides = Map.of( + public Map modelOverrides = Map.of( Objects.requireNonNull(net.minecraft.world.item.Items.ELYTRA.components().get(DataComponents.ITEM_MODEL)), new ItemObfuscationBinding.AssetObfuscationConfiguration( true, diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java index 1ee16e3ee24d..e0491ef5cfc0 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java @@ -13,7 +13,7 @@ import io.papermc.paper.configuration.serializer.EnumValueSerializer; import io.papermc.paper.configuration.serializer.NbtPathSerializer; import io.papermc.paper.configuration.serializer.ServerboundPacketClassSerializer; -import io.papermc.paper.configuration.serializer.ResourceLocationSerializer; +import io.papermc.paper.configuration.serializer.IdentifierSerializer; import io.papermc.paper.configuration.serializer.StringRepresentableSerializer; import io.papermc.paper.configuration.serializer.collection.TableSerializer; import io.papermc.paper.configuration.serializer.collection.map.FastutilMapSerializer; @@ -56,7 +56,7 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.core.component.DataComponentType; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.EntityType; @@ -191,7 +191,7 @@ private static ConfigurationOptions defaultOptions(ConfigurationOptions options) .register(Duration.SERIALIZER) .register(DurationOrDisabled.SERIALIZER) .register(NbtPathSerializer.SERIALIZER) - .register(ResourceLocationSerializer.INSTANCE) + .register(IdentifierSerializer.INSTANCE) ); } @@ -347,10 +347,10 @@ public void reloadConfigs(MinecraftServer server) { } private static ContextMap createWorldContextMap(ServerLevel level) { - return createWorldContextMap(level.levelStorageAccess.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location(), level.spigotConfig, level.registryAccess(), level.getGameRules()); + return createWorldContextMap(level.levelStorageAccess.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().identifier(), level.spigotConfig, level.registryAccess(), level.getGameRules()); } - public static ContextMap createWorldContextMap(final Path dir, final String levelName, final ResourceLocation worldKey, final SpigotWorldConfig spigotConfig, final RegistryAccess registryAccess, final GameRules gameRules) { + public static ContextMap createWorldContextMap(final Path dir, final String levelName, final Identifier worldKey, final SpigotWorldConfig spigotConfig, final RegistryAccess registryAccess, final GameRules gameRules) { return ContextMap.builder() .put(WORLD_DIRECTORY, dir) .put(WORLD_NAME, levelName) diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/paper-server/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java index 6877056ddfe5..10ca4e8370fe 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java @@ -34,11 +34,11 @@ import java.util.OptionalInt; import java.util.function.Function; import java.util.stream.Collectors; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.commands.arguments.NbtPathArgument; import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.Difficulty; import net.minecraft.world.entity.Display; import net.minecraft.world.entity.Entity; @@ -73,9 +73,9 @@ public class WorldConfiguration extends ConfigurationPart { static final int CURRENT_VERSION = 31; // (when you change the version, change the comment, so it conflicts on rebases): migrate spawn loaded configs to gamerule private final transient SpigotWorldConfig spigotConfig; - private final transient ResourceLocation worldKey; + private final transient Identifier worldKey; - WorldConfiguration(final SpigotWorldConfig spigotConfig, final ResourceLocation worldKey) { + WorldConfiguration(final SpigotWorldConfig spigotConfig, final Identifier worldKey) { this.spigotConfig = spigotConfig; this.worldKey = worldKey; } diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/IdentifierSerializer.java b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/IdentifierSerializer.java new file mode 100644 index 000000000000..8ff097d1b7c5 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/IdentifierSerializer.java @@ -0,0 +1,27 @@ +package io.papermc.paper.configuration.serializer; + +import java.lang.reflect.AnnotatedType; +import java.lang.reflect.Type; +import java.util.function.Predicate; +import net.minecraft.resources.Identifier; +import org.spongepowered.configurate.serialize.ScalarSerializer; +import org.spongepowered.configurate.serialize.SerializationException; + +public class IdentifierSerializer extends ScalarSerializer.Annotated { + + public static final ScalarSerializer INSTANCE = new IdentifierSerializer(); + + private IdentifierSerializer() { + super(Identifier.class); + } + + @Override + public Identifier deserialize(final AnnotatedType annotatedType, final Object obj) throws SerializationException { + return Identifier.read(obj.toString()).getOrThrow(s -> new SerializationException(Identifier.class, s)); + } + + @Override + protected Object serialize(final AnnotatedType annotatedType, final Identifier item, final Predicate> typeSupported) { + return item.toString(); + } +} diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/ResourceLocationSerializer.java b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/ResourceLocationSerializer.java deleted file mode 100644 index 9a6c278d6264..000000000000 --- a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/ResourceLocationSerializer.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.papermc.paper.configuration.serializer; - -import java.lang.reflect.AnnotatedType; -import java.lang.reflect.Type; -import java.util.function.Predicate; -import net.minecraft.resources.ResourceLocation; -import org.spongepowered.configurate.serialize.ScalarSerializer; -import org.spongepowered.configurate.serialize.SerializationException; - -public class ResourceLocationSerializer extends ScalarSerializer.Annotated { - - public static final ScalarSerializer INSTANCE = new ResourceLocationSerializer(); - - private ResourceLocationSerializer() { - super(ResourceLocation.class); - } - - @Override - public ResourceLocation deserialize(final AnnotatedType annotatedType, final Object obj) throws SerializationException { - return ResourceLocation.read(obj.toString()).getOrThrow(s -> new SerializationException(ResourceLocation.class, s)); - } - - @Override - protected Object serialize(final AnnotatedType annotatedType, final ResourceLocation item, final Predicate> typeSupported) { - return item.toString(); - } -} diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/ServerboundPacketClassSerializer.java b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/ServerboundPacketClassSerializer.java index 6d4df95336c2..3dd96af2ffea 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/ServerboundPacketClassSerializer.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/ServerboundPacketClassSerializer.java @@ -23,7 +23,7 @@ import net.minecraft.network.protocol.login.LoginPacketTypes; import net.minecraft.network.protocol.ping.PingPacketTypes; import net.minecraft.network.protocol.status.StatusPacketTypes; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.spongepowered.configurate.serialize.ScalarSerializer; @@ -44,12 +44,12 @@ public final class ServerboundPacketClassSerializer extends ScalarSerializer ID_TO_INFO; + private static final Map ID_TO_INFO; private static final Map, PacketInfo> CLASS_TO_INFO; static { try { - final ImmutableMap.Builder idBuilder = ImmutableMap.builder(); + final ImmutableMap.Builder idBuilder = ImmutableMap.builder(); final ImmutableMap.Builder, PacketInfo> classBuilder = ImmutableMap.builder(); for (final Class holder : PACKET_CLASS_HOLDERS) { for (final Field field : holder.getDeclaredFields()) { @@ -85,9 +85,9 @@ public ServerboundPacketClassSerializer() { @Override public Class> deserialize(final Type type, final Object obj) throws SerializationException { - final ResourceLocation location = ResourceLocation.tryParse(obj.toString()); + final Identifier location = Identifier.tryParse(obj.toString()); if (location == null) { - throw new SerializationException(ResourceLocation.class, "Could not deserialize a packet from " + obj); + throw new SerializationException(Identifier.class, "Could not deserialize a packet from " + obj); } final PacketInfo info = ID_TO_INFO.get(location); if (info == null) { diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryEntrySerializer.java b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryEntrySerializer.java index 5ca61cb1e543..cabd06b9842a 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryEntrySerializer.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryEntrySerializer.java @@ -7,7 +7,7 @@ import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.spongepowered.configurate.serialize.ScalarSerializer; import org.spongepowered.configurate.serialize.SerializationException; @@ -57,15 +57,15 @@ public final T deserialize(final AnnotatedType type, final Object obj) throws Se @Override protected final Object serialize(final AnnotatedType type, final T item, final Predicate> typeSupported) { final ResourceKey key = this.convertToResourceKey(item); - if (this.omitMinecraftNamespace && key.location().getNamespace().equals(ResourceLocation.DEFAULT_NAMESPACE)) { - return key.location().getPath(); + if (this.omitMinecraftNamespace && key.identifier().getNamespace().equals(Identifier.DEFAULT_NAMESPACE)) { + return key.identifier().getPath(); } else { - return key.location().toString(); + return key.identifier().toString(); } } private ResourceKey deserializeKey(final Object input) throws SerializationException { - final ResourceLocation key = ResourceLocation.tryParse(input.toString()); + final Identifier key = Identifier.tryParse(input.toString()); if (key == null) { throw new SerializationException("Could not create a key from " + input); } diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryValueSerializer.java b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryValueSerializer.java index ad08f242cd19..6d39c5ee997f 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryValueSerializer.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryValueSerializer.java @@ -33,7 +33,7 @@ public RegistryValueSerializer( protected T convertFromResourceKey(final ResourceKey key) throws SerializationException { final T value = this.registry().getValue(key); if (value == null) { - throw new SerializationException("Missing value in " + this.registry() + " with key " + key.location()); + throw new SerializationException("Missing value in " + this.registry() + " with key " + key.identifier()); } return value; } diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V30_PacketIds.java b/paper-server/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V30_PacketIds.java index 9838438ef7d6..36895faebc19 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V30_PacketIds.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V30_PacketIds.java @@ -12,7 +12,7 @@ import java.io.Reader; import java.util.Map; import java.util.Objects; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jspecify.annotations.Nullable; import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.NodePath; @@ -28,10 +28,10 @@ public class V30_PacketIds implements TransformAction { private static final int VERSION = 30; private static final Gson GSON = new Gson(); - private static final Map MOJANG_TO_ID; + private static final Map MOJANG_TO_ID; static { - final ImmutableMap.Builder builder2 = ImmutableMap.builder(); + final ImmutableMap.Builder builder2 = ImmutableMap.builder(); final InputStream input = V30_PacketIds.class.getResourceAsStream("/config-data/packet-limiter-upgrade-data.json"); if (input == null) { throw new RuntimeException("Failed to load packet limiter upgrade data"); @@ -40,7 +40,7 @@ public class V30_PacketIds implements TransformAction { final JsonArray array = GSON.fromJson(reader, JsonArray.class); for (final JsonElement element : array) { final JsonObject obj = element.getAsJsonObject(); - builder2.put(obj.get("simple_class_name").getAsString(), ResourceLocation.parse(obj.get("id").getAsString())); + builder2.put(obj.get("simple_class_name").getAsString(), Identifier.parse(obj.get("id").getAsString())); } } catch (final IOException e) { throw new RuntimeException("Failed to load packet limiter upgrade data", e); diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java b/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java index d670865dc9bf..7345db4342ea 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java @@ -7,7 +7,7 @@ import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import org.jspecify.annotations.Nullable; @@ -33,9 +33,9 @@ public final class FeatureSeedsGeneration implements TransformAction { private static final Logger LOGGER = LogUtils.getClassLogger(); - private final ResourceLocation worldKey; + private final Identifier worldKey; - private FeatureSeedsGeneration(ResourceLocation worldKey) { + private FeatureSeedsGeneration(Identifier worldKey) { this.worldKey = worldKey; } diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/LegacyPaperWorldConfig.java b/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/LegacyPaperWorldConfig.java index 7af8f613ac63..f64cc8381d94 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/LegacyPaperWorldConfig.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/LegacyPaperWorldConfig.java @@ -11,7 +11,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.item.Item; import org.bukkit.Material; @@ -103,7 +103,7 @@ private static ConfigurationTransformation.Versioned versioned() { ) .addVersion(26, ConfigurationTransformation.builder().addAction(path("alt-item-despawn-rate", "items", ConfigurationTransformation.WILDCARD_OBJECT), (path, value) -> { String itemName = path.get(path.size() - 1).toString(); - final Optional> item = BuiltInRegistries.ITEM.get(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(itemName.toLowerCase(Locale.ROOT)))); + final Optional> item = BuiltInRegistries.ITEM.get(ResourceKey.create(Registries.ITEM, Identifier.parse(itemName.toLowerCase(Locale.ROOT)))); if (item.isEmpty()) { itemName = Material.valueOf(itemName).getKey().getKey(); } @@ -135,13 +135,13 @@ private static ConfigurationTransformation notVersioned() { Map rebuild = new HashMap<>(); value.childrenMap().forEach((key, node) -> { String itemName = key.toString(); - final Optional> itemHolder = BuiltInRegistries.ITEM.get(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(itemName.toLowerCase(Locale.ROOT)))); + final Optional> itemHolder = BuiltInRegistries.ITEM.get(ResourceKey.create(Registries.ITEM, Identifier.parse(itemName.toLowerCase(Locale.ROOT)))); final String item; if (itemHolder.isEmpty()) { final Material bukkitMat = Material.matchMaterial(itemName); item = bukkitMat != null ? bukkitMat.getKey().getKey() : null; } else { - item = itemHolder.get().unwrapKey().orElseThrow().location().getPath(); + item = itemHolder.get().unwrapKey().orElseThrow().identifier().getPath(); } if (item != null) { rebuild.put(item, node.getInt()); diff --git a/paper-server/src/main/java/io/papermc/paper/connection/PaperPlayerConfigurationConnection.java b/paper-server/src/main/java/io/papermc/paper/connection/PaperPlayerConfigurationConnection.java index 38b5fd22de8f..416a94d6a53e 100644 --- a/paper-server/src/main/java/io/papermc/paper/connection/PaperPlayerConfigurationConnection.java +++ b/paper-server/src/main/java/io/papermc/paper/connection/PaperPlayerConfigurationConnection.java @@ -26,7 +26,7 @@ import net.minecraft.network.protocol.common.ClientboundShowDialogPacket; import net.minecraft.network.protocol.common.custom.DiscardedPayload; import net.minecraft.network.protocol.configuration.ClientboundResetChatPacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ClientInformation; import net.minecraft.server.network.ConfigurationTask; import net.minecraft.server.network.ServerConfigurationPacketListenerImpl; @@ -134,7 +134,7 @@ public void sendPluginMessage(final Plugin source, final String channel, final b if (this.channels().contains(channel)) { @SuppressWarnings("deprecation") // "not an API method" does not apply to us - ResourceLocation id = ResourceLocation.parse(StandardMessenger.validateAndCorrectChannel(channel)); + Identifier id = Identifier.parse(StandardMessenger.validateAndCorrectChannel(channel)); ClientboundCustomPayloadPacket packet = new ClientboundCustomPayloadPacket(new DiscardedPayload(id, message)); this.handle.send(packet); } diff --git a/paper-server/src/main/java/io/papermc/paper/connection/ReadablePlayerCookieConnectionImpl.java b/paper-server/src/main/java/io/papermc/paper/connection/ReadablePlayerCookieConnectionImpl.java index a537efef8ac6..226e63bd7749 100644 --- a/paper-server/src/main/java/io/papermc/paper/connection/ReadablePlayerCookieConnectionImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/connection/ReadablePlayerCookieConnectionImpl.java @@ -7,7 +7,7 @@ import net.minecraft.network.Connection; import net.minecraft.network.protocol.cookie.ClientboundCookieRequestPacket; import net.minecraft.network.protocol.cookie.ServerboundCookieResponsePacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.NamespacedKey; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.jspecify.annotations.NullMarked; @@ -16,7 +16,7 @@ public abstract class ReadablePlayerCookieConnectionImpl implements ReadablePlayerCookieConnection { // Because we support async cookies, order is not promised. - private final Map requestedCookies = new ConcurrentHashMap<>(); + private final Map requestedCookies = new ConcurrentHashMap<>(); private final Connection connection; public ReadablePlayerCookieConnectionImpl(final Connection connection) { @@ -28,7 +28,7 @@ public CompletableFuture retrieveCookie(final NamespacedKey key) { Preconditions.checkArgument(key != null, "Cookie key cannot be null"); CompletableFuture future = new CompletableFuture<>(); - ResourceLocation resourceLocation = CraftNamespacedKey.toMinecraft(key); + Identifier resourceLocation = CraftNamespacedKey.toMinecraft(key); this.requestedCookies.put(resourceLocation, new CookieFuture(resourceLocation, future)); this.connection.send(new ClientboundCookieRequestPacket(resourceLocation)); @@ -55,6 +55,6 @@ public boolean isAwaitingCookies() { return !this.requestedCookies.isEmpty(); } - public record CookieFuture(ResourceLocation key, CompletableFuture future) { + public record CookieFuture(Identifier key, CompletableFuture future) { } } diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperEquippable.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperEquippable.java index 3ead3fbaf9cd..aa10ee49b810 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperEquippable.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperEquippable.java @@ -12,7 +12,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.item.equipment.EquipmentAsset; @@ -114,7 +114,7 @@ static final class BuilderImpl implements Builder { private final net.minecraft.world.entity.EquipmentSlot equipmentSlot; private Holder equipSound = SoundEvents.ARMOR_EQUIP_GENERIC; private Optional> assetId = Optional.empty(); - private Optional cameraOverlay = Optional.empty(); + private Optional cameraOverlay = Optional.empty(); private Optional>> allowedEntities = Optional.empty(); private boolean dispensable = true; private boolean swappable = true; diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemAdventurePredicate.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemAdventurePredicate.java index 705f5a4f1d18..c2e2ff3a8c1b 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemAdventurePredicate.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemAdventurePredicate.java @@ -8,7 +8,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.List; import java.util.Optional; -import net.minecraft.advancements.critereon.DataComponentMatchers; +import net.minecraft.advancements.criterion.DataComponentMatchers; import net.minecraft.core.registries.Registries; import org.bukkit.craftbukkit.util.Handleable; @@ -33,11 +33,11 @@ public List predicates() { static final class BuilderImpl implements ItemAdventurePredicate.Builder { - private final List predicates = new ObjectArrayList<>(); + private final List predicates = new ObjectArrayList<>(); @Override public ItemAdventurePredicate.Builder addPredicate(final BlockPredicate predicate) { - this.predicates.add(new net.minecraft.advancements.critereon.BlockPredicate(Optional.ofNullable(predicate.blocks()).map( + this.predicates.add(new net.minecraft.advancements.criterion.BlockPredicate(Optional.ofNullable(predicate.blocks()).map( blocks -> PaperRegistrySets.convertToNms(Registries.BLOCK, Conversions.global().lookup(), blocks) ), Optional.empty(), Optional.empty(), DataComponentMatchers.ANY)); // TODO DataComponentMatchers return this; diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSeededContainerLoot.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSeededContainerLoot.java index 1ee469b3b690..c5a9bafdaaec 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSeededContainerLoot.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSeededContainerLoot.java @@ -19,7 +19,7 @@ public net.minecraft.world.item.component.SeededContainerLoot getHandle() { @Override public Key lootTable() { - return CraftNamespacedKey.fromMinecraft(this.impl.lootTable().location()); + return CraftNamespacedKey.fromMinecraft(this.impl.lootTable().identifier()); } @Override diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseCooldown.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseCooldown.java index b5e2e7387431..ad6c99782a6e 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseCooldown.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseCooldown.java @@ -3,7 +3,7 @@ import io.papermc.paper.adventure.PaperAdventure; import java.util.Optional; import net.kyori.adventure.key.Key; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.craftbukkit.util.Handleable; import org.jspecify.annotations.Nullable; @@ -31,7 +31,7 @@ public float seconds() { static final class BuilderImpl implements Builder { private final float seconds; - private Optional cooldownGroup = Optional.empty(); + private Optional cooldownGroup = Optional.empty(); BuilderImpl(final float seconds) { this.seconds = seconds; diff --git a/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java index 247fa2f61b03..98d776e44b20 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java @@ -189,7 +189,7 @@ public static ResourceKey> registryToNms(final Regi } public static TypedKey fromNms(final ResourceKey resourceKey) { - return TypedKey.create(registryFromNms(resourceKey.registryKey()), CraftNamespacedKey.fromMinecraft(resourceKey.location())); + return TypedKey.create(registryFromNms(resourceKey.registryKey()), CraftNamespacedKey.fromMinecraft(resourceKey.identifier())); } @SuppressWarnings({"unchecked", "RedundantCast"}) diff --git a/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistryListenerManager.java b/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistryListenerManager.java index 65339315be6b..24cd0d16ccc4 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistryListenerManager.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistryListenerManager.java @@ -28,7 +28,7 @@ import net.minecraft.core.WritableRegistry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.Keyed; import org.intellij.lang.annotations.Subst; import org.jspecify.annotations.Nullable; @@ -47,13 +47,13 @@ private PaperRegistryListenerManager() { * For {@link Registry#register(Registry, String, Object)} */ public M registerWithListeners(final Registry registry, final String id, final M nms) { - return this.registerWithListeners(registry, ResourceLocation.withDefaultNamespace(id), nms); + return this.registerWithListeners(registry, Identifier.withDefaultNamespace(id), nms); } /** - * For {@link Registry#register(Registry, ResourceLocation, Object)} + * For {@link Registry#register(Registry, Identifier, Object)} */ - public M registerWithListeners(final Registry registry, final ResourceLocation loc, final M nms) { + public M registerWithListeners(final Registry registry, final Identifier loc, final M nms) { return this.registerWithListeners(registry, ResourceKey.create(registry.key(), loc), nms); } @@ -65,9 +65,9 @@ public M registerWithListeners(final Registry registry, final ResourceKey } /** - * For {@link Registry#registerForHolder(Registry, ResourceLocation, Object)} + * For {@link Registry#registerForHolder(Registry, Identifier, Object)} */ - public Holder.Reference registerForHolderWithListeners(final Registry registry, final ResourceLocation loc, final M nms) { + public Holder.Reference registerForHolderWithListeners(final Registry registry, final Identifier loc, final M nms) { return this.registerForHolderWithListeners(registry, ResourceKey.create(registry.key(), loc), nms); } @@ -131,7 +131,7 @@ public , R> R registerW final RegisterMethod registerMethod, final Conversions conversions ) { - @Subst("namespace:key") final ResourceLocation beingAdded = key.location(); + @Subst("namespace:key") final Identifier beingAdded = key.identifier(); @SuppressWarnings("PatternValidation") final TypedKey typedKey = TypedKey.create(entry.apiKey(), Key.key(beingAdded.getNamespace(), beingAdded.getPath())); final RegistryEntryAddEventImpl event = entry.createEntryAddEvent(typedKey, builder, conversions); LifecycleEventRunner.INSTANCE.callEvent(this.valueAddEventTypes.getEventType(entry.apiKey()), event); diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperBannerPatternRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperBannerPatternRegistryEntry.java index 70d226a14a8d..93f1aa9a8816 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperBannerPatternRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperBannerPatternRegistryEntry.java @@ -4,7 +4,7 @@ import io.papermc.paper.registry.PaperRegistryBuilder; import io.papermc.paper.registry.data.util.Conversions; import net.kyori.adventure.key.Key; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.block.entity.BannerPattern; import org.bukkit.block.banner.PatternType; import org.jspecify.annotations.Nullable; @@ -13,7 +13,7 @@ public class PaperBannerPatternRegistryEntry implements BannerPatternRegistryEntry { - protected @Nullable ResourceLocation assetId; + protected @Nullable Identifier assetId; protected @Nullable String translationKey; public PaperBannerPatternRegistryEntry( diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java index 31430bfbec5b..46802fce6346 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java @@ -7,7 +7,7 @@ import java.util.OptionalInt; import net.kyori.adventure.key.Key; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.entity.decoration.PaintingVariant; import org.bukkit.Art; import org.jetbrains.annotations.Range; @@ -23,7 +23,7 @@ public class PaperPaintingVariantRegistryEntry implements PaintingVariantRegistr protected OptionalInt height = OptionalInt.empty(); protected @Nullable Component title; protected @Nullable Component author; - protected @Nullable ResourceLocation assetId; + protected @Nullable Identifier assetId; protected final Conversions conversions; diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperSoundEventRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperSoundEventRegistryEntry.java index 9590faa0c6c1..d60bd7867e92 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperSoundEventRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperSoundEventRegistryEntry.java @@ -5,7 +5,7 @@ import io.papermc.paper.registry.data.util.Conversions; import java.util.Optional; import net.kyori.adventure.key.Key; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.sounds.SoundEvent; import org.bukkit.Sound; import org.jspecify.annotations.Nullable; @@ -20,7 +20,7 @@ public class PaperSoundEventRegistryEntry implements SoundEventRegistryEntry { protected final Conversions conversions; - protected @Nullable ResourceLocation location; + protected @Nullable Identifier location; protected @Nullable Float fixedRange; public PaperSoundEventRegistryEntry(final Conversions conversions, final @Nullable SoundEvent soundEvent) { diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/dialog/PaperDialogCodecs.java b/paper-server/src/main/java/io/papermc/paper/registry/data/dialog/PaperDialogCodecs.java index 9e2a26aeb21b..209ea05ade06 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/dialog/PaperDialogCodecs.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/dialog/PaperDialogCodecs.java @@ -22,11 +22,11 @@ import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.MappedRegistry; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.dialog.CommonButtonData; import net.minecraft.server.dialog.Dialog; import net.minecraft.server.dialog.action.ParsedTemplate; @@ -54,7 +54,7 @@ private PaperDialogCodecs() { ); private static final Map> STATIC_ACTION_CODECS = Arrays.stream(AdventureCodecs.CLICK_EVENT_TYPES.get()).collect(Collectors.toMap(Function.identity(), type -> type.codec().xmap(DialogAction::staticAction, DialogAction.StaticAction::value))); private static final Registry> DIALOG_ACTION_TYPES = Util.make(() -> { - final MappedRegistry> registry = new MappedRegistry<>(ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ResourceLocation.PAPER_NAMESPACE, "dialog_action_type")), Lifecycle.experimental()); + final MappedRegistry> registry = new MappedRegistry<>(ResourceKey.createRegistryKey(Identifier.fromNamespaceAndPath(Identifier.PAPER_NAMESPACE, "dialog_action_type")), Lifecycle.experimental()); STATIC_ACTION_CODECS.forEach((clickType, actionCodec) -> { Registry.register(registry, clickType.getSerializedName(), actionCodec); }); @@ -94,7 +94,7 @@ private PaperDialogCodecs() { ).apply(instance, (itemStack, plainMessageBody, showDecorations, showTooltip, width, height) -> DialogBody.item(itemStack, plainMessageBody.orElse(null), showDecorations, showTooltip, width, height)) ); private static final Registry> DIALOG_BODY_TYPES = Util.make(() -> { - final MappedRegistry> registry = new MappedRegistry<>(ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ResourceLocation.PAPER_NAMESPACE, "dialog_body_type")), Lifecycle.experimental()); + final MappedRegistry> registry = new MappedRegistry<>(ResourceKey.createRegistryKey(Identifier.fromNamespaceAndPath(Identifier.PAPER_NAMESPACE, "dialog_body_type")), Lifecycle.experimental()); Registry.register(registry, "item", ITEM_BODY_CODEC); Registry.register(registry, "plain_message", PLAIN_MESSAGE_BODY_CODEC); return registry.freeze(); @@ -155,7 +155,7 @@ private PaperDialogCodecs() { DialogInput.text(key, width, label, labelVisible, initial, maxLength, multilineOptions.orElse(null)) )); private static final Registry> DIALOG_INPUT_TYPES = Util.make(() -> { - final MappedRegistry> registry = new MappedRegistry<>(ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ResourceLocation.PAPER_NAMESPACE, "dialog_input_type")), Lifecycle.experimental()); + final MappedRegistry> registry = new MappedRegistry<>(ResourceKey.createRegistryKey(Identifier.fromNamespaceAndPath(Identifier.PAPER_NAMESPACE, "dialog_input_type")), Lifecycle.experimental()); Registry.register(registry, "boolean", BOOLEAN_DIALOG_INPUT_TYPE_MAP_CODEC); Registry.register(registry, "number_range", NUMBER_RANGE_INPUT_MAP_CODEC); Registry.register(registry, "single_option", SINGLE_OPTION_DIALOG_INPUT_TYPE_MAP_CODEC); diff --git a/paper-server/src/main/java/io/papermc/paper/registry/set/NamedRegistryKeySetImpl.java b/paper-server/src/main/java/io/papermc/paper/registry/set/NamedRegistryKeySetImpl.java index 7fbde6cd6817..10f86a16ef74 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/set/NamedRegistryKeySetImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/set/NamedRegistryKeySetImpl.java @@ -32,7 +32,7 @@ public NamedRegistryKeySetImpl(final HolderSet.Named namedSet) { public @Unmodifiable Collection> values() { final ImmutableList.Builder> builder = ImmutableList.builder(); for (final Holder holder : this.namedSet) { - builder.add(TypedKey.create(this.tagKey.registryKey(), CraftNamespacedKey.fromMinecraft(((Holder.Reference) holder).key().location()))); + builder.add(TypedKey.create(this.tagKey.registryKey(), CraftNamespacedKey.fromMinecraft(((Holder.Reference) holder).key().identifier()))); } return builder.build(); } @@ -53,7 +53,7 @@ public boolean contains(final TypedKey valueKey) { public @Unmodifiable Collection resolve(final Registry registry) { final ImmutableList.Builder builder = ImmutableList.builder(); for (final Holder holder : this.namedSet) { - builder.add(registry.getOrThrow(CraftNamespacedKey.fromMinecraft(((Holder.Reference) holder).key().location()))); + builder.add(registry.getOrThrow(CraftNamespacedKey.fromMinecraft(((Holder.Reference) holder).key().identifier()))); } return builder.build(); } diff --git a/paper-server/src/main/java/io/papermc/paper/tag/PaperPostFlattenTagRegistrar.java b/paper-server/src/main/java/io/papermc/paper/tag/PaperPostFlattenTagRegistrar.java index 2596586fd7e2..53e2b0d20d0a 100644 --- a/paper-server/src/main/java/io/papermc/paper/tag/PaperPostFlattenTagRegistrar.java +++ b/paper-server/src/main/java/io/papermc/paper/tag/PaperPostFlattenTagRegistrar.java @@ -17,7 +17,7 @@ import java.util.NoSuchElementException; import java.util.Optional; import java.util.function.Function; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -27,13 +27,13 @@ @DefaultQualifier(NonNull.class) public class PaperPostFlattenTagRegistrar implements PaperRegistrar, PostFlattenTagRegistrar { - public final Map> tags; - private final Function> fromIdConverter; - private final Function toIdConverter; + public final Map> tags; + private final Function> fromIdConverter; + private final Function toIdConverter; private final RegistryKey registryKey; public PaperPostFlattenTagRegistrar( - final Map> tags, + final Map> tags, final TagEventConfig config ) { this.tags = tags; @@ -54,7 +54,7 @@ public RegistryKey registryKey() { @Override public Map, Collection>> getAllTags() { final ImmutableMap.Builder, Collection>> tags = ImmutableMap.builderWithExpectedSize(this.tags.size()); - for (final Map.Entry> entry : this.tags.entrySet()) { + for (final Map.Entry> entry : this.tags.entrySet()) { final TagKey key = TagKey.create(this.registryKey, CraftNamespacedKey.fromMinecraft(entry.getKey())); tags.put(key, this.convert(entry.getValue())); } @@ -67,7 +67,7 @@ private List> convert(final List nms) { ); } - private TypedKey convert(final ResourceLocation location) { + private TypedKey convert(final Identifier location) { return TypedKey.create(this.registryKey, CraftNamespacedKey.fromMinecraft(location)); } @@ -85,7 +85,7 @@ public boolean hasTag(final TagKey tagKey) { } private List getNmsTag(final TagKey tagKey, final boolean create) { - final ResourceLocation vanillaKey = PaperAdventure.asVanilla(tagKey.key()); + final Identifier vanillaKey = PaperAdventure.asVanilla(tagKey.key()); List tag = this.tags.get(vanillaKey); if (tag == null) { if (create) { diff --git a/paper-server/src/main/java/io/papermc/paper/tag/PaperPreFlattenTagRegistrar.java b/paper-server/src/main/java/io/papermc/paper/tag/PaperPreFlattenTagRegistrar.java index 44111b55eaa6..229543e88182 100644 --- a/paper-server/src/main/java/io/papermc/paper/tag/PaperPreFlattenTagRegistrar.java +++ b/paper-server/src/main/java/io/papermc/paper/tag/PaperPreFlattenTagRegistrar.java @@ -16,7 +16,7 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagLoader; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.checkerframework.checker.nullness.qual.NonNull; @@ -27,13 +27,13 @@ @DefaultQualifier(NonNull.class) public class PaperPreFlattenTagRegistrar implements PaperRegistrar, PreFlattenTagRegistrar { - public final Map> tags; + public final Map> tags; private final RegistryKey registryKey; private @Nullable BootstrapContext owner; public PaperPreFlattenTagRegistrar( - final Map> tags, + final Map> tags, final TagEventConfig config ) { this.tags = new HashMap<>(tags); @@ -53,7 +53,7 @@ public RegistryKey registryKey() { @Override public Map, Collection>> getAllTags() { final ImmutableMap.Builder, Collection>> builder = ImmutableMap.builderWithExpectedSize(this.tags.size()); - for (final Map.Entry> entry : this.tags.entrySet()) { + for (final Map.Entry> entry : this.tags.entrySet()) { final TagKey key = TagKey.create(this.registryKey, CraftNamespacedKey.fromMinecraft(entry.getKey())); builder.put(key, convert(entry.getValue())); } @@ -70,7 +70,7 @@ private static io.papermc.paper.tag.TagEntry convert(final TagLoader.Entr private TagLoader.EntryWithSource convert(final TagEntry entry) { Preconditions.checkState(this.owner != null, "Owner is not set"); - final ResourceLocation vanilla = PaperAdventure.asVanilla(entry.key()); + final Identifier vanilla = PaperAdventure.asVanilla(entry.key()); final net.minecraft.tags.TagEntry nmsEntry; if (entry.isTag()) { if (entry.isRequired()) { @@ -94,7 +94,7 @@ public boolean hasTag(final TagKey tagKey) { } private List getNmsTag(final TagKey tagKey, boolean create) { - final ResourceLocation vanillaKey = PaperAdventure.asVanilla(tagKey.key()); + final Identifier vanillaKey = PaperAdventure.asVanilla(tagKey.key()); List tag = this.tags.get(vanillaKey); if (tag == null) { if (create) { diff --git a/paper-server/src/main/java/io/papermc/paper/tag/PaperTagListenerManager.java b/paper-server/src/main/java/io/papermc/paper/tag/PaperTagListenerManager.java index e1ffb7f1df66..05e88076cf84 100644 --- a/paper-server/src/main/java/io/papermc/paper/tag/PaperTagListenerManager.java +++ b/paper-server/src/main/java/io/papermc/paper/tag/PaperTagListenerManager.java @@ -13,7 +13,7 @@ import java.util.Map; import net.minecraft.core.Holder; import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagLoader; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -33,8 +33,8 @@ public class PaperTagListenerManager { private PaperTagListenerManager() { } - public Map> firePreFlattenEvent( - final Map> initial, + public Map> firePreFlattenEvent( + final Map> initial, final @Nullable TagEventConfig config ) { if (config == null || config.preFlatten() == null || !config.preFlatten().hasHandlers()) { @@ -50,8 +50,8 @@ public Map> firePreFlatten return Map.copyOf(registrar.tags); } - public Map> firePostFlattenEvent( - final Map> initial, + public Map> firePostFlattenEvent( + final Map> initial, final @Nullable TagEventConfig config ) { if (config == null || config.postFlatten() == null || !config.postFlatten().hasHandlers()) { @@ -86,7 +86,7 @@ public Map> firePostFlattenEvent( postFlatten, cause, registry::get, - h -> ((Holder.Reference) h).key().location(), + h -> ((Holder.Reference) h).key().identifier(), PaperRegistries.registryFromNms(registry.key()) ); } diff --git a/paper-server/src/main/java/io/papermc/paper/tag/TagEventConfig.java b/paper-server/src/main/java/io/papermc/paper/tag/TagEventConfig.java index d6d4bfc6f45d..497f2e3dc4c6 100644 --- a/paper-server/src/main/java/io/papermc/paper/tag/TagEventConfig.java +++ b/paper-server/src/main/java/io/papermc/paper/tag/TagEventConfig.java @@ -6,7 +6,7 @@ import io.papermc.paper.registry.RegistryKey; import java.util.Optional; import java.util.function.Function; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.framework.qual.DefaultQualifier; @@ -16,8 +16,8 @@ public record TagEventConfig( @Nullable AbstractLifecycleEventType>, ?> preFlatten, @Nullable AbstractLifecycleEventType>, ?> postFlatten, ReloadableRegistrarEvent.Cause cause, - Function> fromIdConverter, - Function toIdConverter, + Function> fromIdConverter, + Function toIdConverter, RegistryKey apiRegistryKey ) { } diff --git a/paper-server/src/main/java/io/papermc/paper/util/Holderable.java b/paper-server/src/main/java/io/papermc/paper/util/Holderable.java index fd300b21350b..a1927b6bcea6 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/Holderable.java +++ b/paper-server/src/main/java/io/papermc/paper/util/Holderable.java @@ -55,7 +55,7 @@ default Object toBukkitSerializationObject(final Codec directCodec) { final RegistryOps ops = CraftRegistry.getMinecraftRegistry().createSerializationContext(JsonOps.INSTANCE); yield new JsonObjectWrapper(directCodec.encodeStart(ops, direct.value()).getOrThrow().getAsJsonObject()); } - case final Holder.Reference reference -> reference.key().location().toString(); + case final Holder.Reference reference -> reference.key().identifier().toString(); default -> throw new IllegalArgumentException("Cannot serialize " + this.getHolder()); }; } diff --git a/paper-server/src/main/java/io/papermc/paper/util/OldEnumHolderable.java b/paper-server/src/main/java/io/papermc/paper/util/OldEnumHolderable.java index 6734280b9205..5b1fa5bd5495 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/OldEnumHolderable.java +++ b/paper-server/src/main/java/io/papermc/paper/util/OldEnumHolderable.java @@ -26,10 +26,10 @@ protected OldEnumHolderable(final Holder holder, final int ordinal) { // in case plugins use for example the name as key in a config file to receive registry item specific values. // Custom registry items will return the key with namespace. For a plugin this should look than like a new registry item // (which can always be added in new minecraft versions and the plugin should therefore handle it accordingly). - if (NamespacedKey.MINECRAFT.equals(reference.key().location().getNamespace())) { - this.name = reference.key().location().getPath().toUpperCase(Locale.ROOT); + if (NamespacedKey.MINECRAFT.equals(reference.key().identifier().getNamespace())) { + this.name = reference.key().identifier().getPath().toUpperCase(Locale.ROOT); } else { - this.name = reference.key().location().toString(); + this.name = reference.key().identifier().toString(); } } else { this.name = null; diff --git a/paper-server/src/main/java/io/papermc/paper/util/ServerWorkerThread.java b/paper-server/src/main/java/io/papermc/paper/util/ServerWorkerThread.java index ee76a9c488ef..b09f79d22fdd 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/ServerWorkerThread.java +++ b/paper-server/src/main/java/io/papermc/paper/util/ServerWorkerThread.java @@ -1,7 +1,7 @@ package io.papermc.paper.util; import java.util.concurrent.atomic.AtomicInteger; -import net.minecraft.Util; +import net.minecraft.util.Util; public class ServerWorkerThread extends Thread { private static final AtomicInteger threadId = new AtomicInteger(1); diff --git a/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemComponentSanitizer.java b/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemComponentSanitizer.java index aabbf7b18479..47810cb33204 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemComponentSanitizer.java +++ b/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemComponentSanitizer.java @@ -6,7 +6,7 @@ import java.util.Map; import java.util.Optional; import java.util.function.UnaryOperator; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.component.DataComponentType; import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.Registries; diff --git a/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemObfuscationBinding.java b/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemObfuscationBinding.java index 95d510a704f2..c0f68462d9bb 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemObfuscationBinding.java +++ b/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemObfuscationBinding.java @@ -9,7 +9,7 @@ import java.util.function.UnaryOperator; import net.minecraft.core.component.DataComponentType; import net.minecraft.core.component.DataComponents; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.ItemStack; import org.jspecify.annotations.NullMarked; import org.spongepowered.configurate.objectmapping.ConfigSerializable; @@ -24,13 +24,13 @@ public final class ItemObfuscationBinding { public final ItemObfuscationSession.ObfuscationLevel level; private final BoundObfuscationConfiguration base; - private final Map overrides; + private final Map overrides; public ItemObfuscationBinding(final GlobalConfiguration.Anticheat.Obfuscation.Items items) { this.level = items.enableItemObfuscation ? ItemObfuscationSession.ObfuscationLevel.ALL : ItemObfuscationSession.ObfuscationLevel.OVERSIZED; this.base = bind(items.allModels); - final Map overrides = new HashMap<>(); - for (final Map.Entry entry : items.modelOverrides.entrySet()) { + final Map overrides = new HashMap<>(); + for (final Map.Entry entry : items.modelOverrides.entrySet()) { overrides.put(entry.getKey(), bind(entry.getValue())); } this.overrides = Collections.unmodifiableMap(overrides); diff --git a/paper-server/src/main/java/io/papermc/paper/world/PaperWorldLoader.java b/paper-server/src/main/java/io/papermc/paper/world/PaperWorldLoader.java index f5e9dd588068..51a01f86fee5 100644 --- a/paper-server/src/main/java/io/papermc/paper/world/PaperWorldLoader.java +++ b/paper-server/src/main/java/io/papermc/paper/world/PaperWorldLoader.java @@ -57,7 +57,7 @@ private WorldLoadingInfo getWorldInfo( dimension = -999; } String worldType = dimension == -999 - ? stemKey.location().getNamespace() + "_" + stemKey.location().getPath() + ? stemKey.identifier().getNamespace() + "_" + stemKey.identifier().getPath() : World.Environment.getEnvironment(dimension).toString().toLowerCase(Locale.ROOT); String name = stemKey == LevelStem.OVERWORLD ? levelId diff --git a/paper-server/src/main/java/io/papermc/paper/world/damagesource/PaperCombatTrackerWrapper.java b/paper-server/src/main/java/io/papermc/paper/world/damagesource/PaperCombatTrackerWrapper.java index 43afa79e9834..f5ce9f4b8df8 100644 --- a/paper-server/src/main/java/io/papermc/paper/world/damagesource/PaperCombatTrackerWrapper.java +++ b/paper-server/src/main/java/io/papermc/paper/world/damagesource/PaperCombatTrackerWrapper.java @@ -7,7 +7,7 @@ import java.util.List; import net.kyori.adventure.text.Component; import net.minecraft.Optionull; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.world.damagesource.FallLocation; import org.bukkit.entity.LivingEntity; import org.jspecify.annotations.NullMarked; diff --git a/paper-server/src/main/java/io/papermc/paper/world/worldgen/OptionallyFlatBedrockConditionSource.java b/paper-server/src/main/java/io/papermc/paper/world/worldgen/OptionallyFlatBedrockConditionSource.java index 60b6e040df57..8fa41e9d4210 100644 --- a/paper-server/src/main/java/io/papermc/paper/world/worldgen/OptionallyFlatBedrockConditionSource.java +++ b/paper-server/src/main/java/io/papermc/paper/world/worldgen/OptionallyFlatBedrockConditionSource.java @@ -7,7 +7,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.util.KeyDispatchDataCodec; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; @@ -20,15 +20,15 @@ // Modelled off of SurfaceRules$VerticalGradientConditionSource // Flat bedrock generator settings @DefaultQualifier(NonNull.class) -public record OptionallyFlatBedrockConditionSource(ResourceLocation randomName, VerticalAnchor trueAtAndBelow, VerticalAnchor falseAtAndAbove, boolean isRoof) implements SurfaceRules.ConditionSource { +public record OptionallyFlatBedrockConditionSource(Identifier randomName, VerticalAnchor trueAtAndBelow, VerticalAnchor falseAtAndAbove, boolean isRoof) implements SurfaceRules.ConditionSource { private static final ResourceKey> CODEC_RESOURCE_KEY = ResourceKey.create( Registries.MATERIAL_CONDITION, - ResourceLocation.fromNamespaceAndPath(ResourceLocation.PAPER_NAMESPACE, "optionally_flat_bedrock_condition_source") + Identifier.fromNamespaceAndPath(Identifier.PAPER_NAMESPACE, "optionally_flat_bedrock_condition_source") ); private static final KeyDispatchDataCodec CODEC = KeyDispatchDataCodec.of(RecordCodecBuilder.mapCodec((instance) -> { return instance.group( - ResourceLocation.CODEC.fieldOf("random_name").forGetter(OptionallyFlatBedrockConditionSource::randomName), + Identifier.CODEC.fieldOf("random_name").forGetter(OptionallyFlatBedrockConditionSource::randomName), VerticalAnchor.CODEC.fieldOf("true_at_and_below").forGetter(OptionallyFlatBedrockConditionSource::trueAtAndBelow), VerticalAnchor.CODEC.fieldOf("false_at_and_above").forGetter(OptionallyFlatBedrockConditionSource::falseAtAndAbove), Codec.BOOL.fieldOf("is_roof").forGetter(OptionallyFlatBedrockConditionSource::isRoof) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java index a21bf2c5bc7c..8607b31c9c4d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java @@ -3,7 +3,7 @@ import java.util.Locale; import com.google.common.collect.BiMap; import com.google.common.collect.EnumBiMap; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.EquipmentSlotGroup; import org.bukkit.inventory.EquipmentSlot; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java index 7a67d38af41b..f1a616432ea7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java @@ -7,7 +7,7 @@ import java.util.Random; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.context.ContextKey; import net.minecraft.util.context.ContextKeySet; @@ -34,7 +34,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { - public static org.bukkit.loot.LootTable minecraftToBukkit(ResourceLocation minecraft) { + public static org.bukkit.loot.LootTable minecraftToBukkit(Identifier minecraft) { return (minecraft == null) ? null : Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(minecraft)); } @@ -43,7 +43,7 @@ public static org.bukkit.loot.LootTable minecraftToBukkit(ResourceKey } public static NamespacedKey minecraftToBukkitKey(ResourceKey minecraft) { - return (minecraft == null) ? null : CraftNamespacedKey.fromMinecraft(minecraft.location()); + return (minecraft == null) ? null : CraftNamespacedKey.fromMinecraft(minecraft.identifier()); } public static ResourceKey bukkitToMinecraft(org.bukkit.loot.LootTable table) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java index b8c0b05f589d..3f940a89a336 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java @@ -48,7 +48,7 @@ public static Particle minecraftToBukkit(net.minecraft.core.particles.ParticleTy Preconditions.checkArgument(minecraft != null); net.minecraft.core.Registry> registry = CraftRegistry.getMinecraftRegistry(Registries.PARTICLE_TYPE); - Particle bukkit = Registry.PARTICLE_TYPE.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().location())); + Particle bukkit = Registry.PARTICLE_TYPE.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().identifier())); Preconditions.checkArgument(bukkit != null); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java index dce109eb10a8..9b010b57c04b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java @@ -471,7 +471,7 @@ public io.papermc.paper.world.MoonPhase getMoonPhase() { @Override public org.bukkit.NamespacedKey getKey() { - return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.getHandle().getLevel().dimension().location()); + return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.getHandle().getLevel().dimension().identifier()); } public boolean lineOfSightExists(Location from, Location to) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java index 6dfd2763023a..0d343556fbb6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java @@ -66,7 +66,7 @@ public static B minecraftToBukkit(M minecraft, ResourceKey< } else if (resourceKey.isEmpty()) { throw new IllegalStateException(String.format("Cannot convert '%s' to bukkit representation, since it is not registered.", minecraft)); } - final B bukkit = bukkitRegistry.get(CraftNamespacedKey.fromMinecraft(resourceKey.get().location())); + final B bukkit = bukkitRegistry.get(CraftNamespacedKey.fromMinecraft(resourceKey.get().identifier())); Preconditions.checkArgument(bukkit != null); @@ -119,7 +119,7 @@ public static Optional unwrapAndConvertHolder(final Regi if (registry instanceof final CraftRegistry craftRegistry && craftRegistry.supportsDirectHolders() && value.kind() == Holder.Kind.DIRECT) { return Optional.of(((CraftRegistry) registry).createBukkit(value)); } - return value.unwrapKey().map(key -> registry.get(CraftNamespacedKey.fromMinecraft(key.location()))); + return value.unwrapKey().map(key -> registry.get(CraftNamespacedKey.fromMinecraft(key.identifier()))); } // Paper end - fixup upstream being dum diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 3924f3219cf4..b0cd68083ae3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -54,7 +54,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.ReloadableServerRegistries; import net.minecraft.server.WorldLoader; @@ -1283,7 +1283,7 @@ public World createWorld(WorldCreator creator) { } else if (name.equals(levelName + "_the_end")) { dimensionKey = net.minecraft.world.level.Level.END; } else { - dimensionKey = ResourceKey.create(Registries.DIMENSION, ResourceLocation.fromNamespaceAndPath(creator.key().namespace(), creator.key().value())); + dimensionKey = ResourceKey.create(Registries.DIMENSION, Identifier.fromNamespaceAndPath(creator.key().namespace(), creator.key().value())); } ServerLevel serverLevel = new ServerLevel( @@ -2555,7 +2555,7 @@ public org.bukkit.Tag getTag(String registry, NamespacedKey Preconditions.checkArgument(registry != null, "registry cannot be null"); Preconditions.checkArgument(tag != null, "NamespacedKey tag cannot be null"); Preconditions.checkArgument(clazz != null, "Class clazz cannot be null"); - ResourceLocation key = CraftNamespacedKey.toMinecraft(tag); + Identifier key = CraftNamespacedKey.toMinecraft(tag); switch (registry) { case org.bukkit.Tag.REGISTRY_BLOCKS -> { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java index dedfeacb66bd..e786c0cce9ce 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java @@ -5,7 +5,7 @@ import com.google.common.collect.ImmutableBiMap; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import net.minecraft.stats.ServerStatsCounter; import net.minecraft.stats.Stats; @@ -102,21 +102,21 @@ public enum CraftStatistic { WALK_UNDER_WATER_ONE_CM(Stats.WALK_UNDER_WATER_ONE_CM), // End generate - CraftStatisticCustom // Start generate - CraftStatisticType - BREAK_ITEM(ResourceLocation.withDefaultNamespace("broken")), - CRAFT_ITEM(ResourceLocation.withDefaultNamespace("crafted")), - DROP(ResourceLocation.withDefaultNamespace("dropped")), - KILL_ENTITY(ResourceLocation.withDefaultNamespace("killed")), - ENTITY_KILLED_BY(ResourceLocation.withDefaultNamespace("killed_by")), - MINE_BLOCK(ResourceLocation.withDefaultNamespace("mined")), - PICKUP(ResourceLocation.withDefaultNamespace("picked_up")), - USE_ITEM(ResourceLocation.withDefaultNamespace("used")); + BREAK_ITEM(Identifier.withDefaultNamespace("broken")), + CRAFT_ITEM(Identifier.withDefaultNamespace("crafted")), + DROP(Identifier.withDefaultNamespace("dropped")), + KILL_ENTITY(Identifier.withDefaultNamespace("killed")), + ENTITY_KILLED_BY(Identifier.withDefaultNamespace("killed_by")), + MINE_BLOCK(Identifier.withDefaultNamespace("mined")), + PICKUP(Identifier.withDefaultNamespace("picked_up")), + USE_ITEM(Identifier.withDefaultNamespace("used")); // End generate - CraftStatisticType - private final ResourceLocation minecraftKey; + private final Identifier minecraftKey; private final org.bukkit.Statistic bukkit; - private static final BiMap statistics; + private static final BiMap statistics; static { - ImmutableBiMap.Builder statisticBuilder = ImmutableBiMap.builder(); + ImmutableBiMap.Builder statisticBuilder = ImmutableBiMap.builder(); for (CraftStatistic statistic : CraftStatistic.values()) { statisticBuilder.put(statistic.minecraftKey, statistic.bukkit); } @@ -124,7 +124,7 @@ public enum CraftStatistic { statistics = statisticBuilder.build(); } - private CraftStatistic(ResourceLocation minecraftKey) { + private CraftStatistic(Identifier minecraftKey) { this.minecraftKey = minecraftKey; this.bukkit = org.bukkit.Statistic.valueOf(this.name()); @@ -134,10 +134,10 @@ private CraftStatistic(ResourceLocation minecraftKey) { public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.stats.Stat statistic) { Preconditions.checkArgument(statistic != null, "NMS Statistic cannot be null"); Registry statRegistry = statistic.getType().getRegistry(); - ResourceLocation nmsKey = BuiltInRegistries.STAT_TYPE.getKey(statistic.getType()); + Identifier nmsKey = BuiltInRegistries.STAT_TYPE.getKey(statistic.getType()); if (statRegistry == BuiltInRegistries.CUSTOM_STAT) { - nmsKey = (ResourceLocation) statistic.getValue(); + nmsKey = (Identifier) statistic.getValue(); } return statistics.get(nmsKey); @@ -146,7 +146,7 @@ public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.stats.Stat nms = Stats.CUSTOM.get(statistics.inverse().get(bukkit)); + net.minecraft.stats.Stat nms = Stats.CUSTOM.get(statistics.inverse().get(bukkit)); Preconditions.checkArgument(nms != null, "NMS Statistic %s does not exist", bukkit); return nms; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 24dde641b730..d609564340f7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -46,7 +46,7 @@ import net.minecraft.network.protocol.game.ClientboundSoundEntityPacket; import net.minecraft.network.protocol.game.ClientboundSoundPacket; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.DistanceManager; @@ -348,7 +348,7 @@ private boolean setSpawnLocation(int x, int y, int z, float yaw, float pitch) { this.world.serverLevelData.setSpawn( new LevelData.RespawnData( GlobalPos.of( - ResourceKey.create(Registries.DIMENSION, this.world.dimension().location()), + ResourceKey.create(Registries.DIMENSION, this.world.dimension().identifier()), new BlockPos(x, y, z) ), Mth.wrapDegrees(yaw), @@ -789,7 +789,7 @@ public UUID getUID() { @Override public NamespacedKey getKey() { - return CraftNamespacedKey.fromMinecraft(this.world.dimension().location()); + return CraftNamespacedKey.fromMinecraft(this.world.dimension().identifier()); } @Override @@ -1575,7 +1575,7 @@ public void playSound(Location loc, String sound, org.bukkit.SoundCategory categ double y = loc.getY(); double z = loc.getZ(); - ClientboundSoundPacket packet = new ClientboundSoundPacket(Holder.direct(SoundEvent.createVariableRangeEvent(ResourceLocation.parse(sound))), SoundSource.valueOf(category.name()), x, y, z, volume, pitch, seed); + ClientboundSoundPacket packet = new ClientboundSoundPacket(Holder.direct(SoundEvent.createVariableRangeEvent(Identifier.parse(sound))), SoundSource.valueOf(category.name()), x, y, z, volume, pitch, seed); this.world.getServer().getPlayerList().broadcast(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension(), packet); } @@ -1615,7 +1615,7 @@ public void playSound(Entity entity, String sound, org.bukkit.SoundCategory cate org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return; - ClientboundSoundEntityPacket packet = new ClientboundSoundEntityPacket(Holder.direct(SoundEvent.createVariableRangeEvent(ResourceLocation.parse(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, seed); + ClientboundSoundEntityPacket packet = new ClientboundSoundEntityPacket(Holder.direct(SoundEvent.createVariableRangeEvent(Identifier.parse(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, seed); ChunkMap.TrackedEntity entityTracker = this.getHandle().getChunkSource().chunkMap.entityMap.get(entity.getEntityId()); if (entityTracker != null) { entityTracker.sendToTrackingPlayersAndSelf(packet); @@ -1931,7 +1931,7 @@ public Collection getStructures(int x, int z, Structure stru Preconditions.checkArgument(structure != null, "Structure cannot be null"); net.minecraft.core.Registry registry = CraftRegistry.getMinecraftRegistry(Registries.STRUCTURE); - ResourceLocation key = registry.getKey(CraftStructure.bukkitToMinecraft(structure)); + Identifier key = registry.getKey(CraftStructure.bukkitToMinecraft(structure)); return this.getStructures(x, z, struct -> registry.getKey(struct).equals(key)); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java index 61d1bf58204c..687311a9224d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java @@ -4,9 +4,9 @@ import java.util.Collection; import java.util.Collections; import java.util.Optional; -import net.minecraft.advancements.critereon.DataComponentMatchers; -import net.minecraft.advancements.critereon.ItemPredicate; -import net.minecraft.advancements.critereon.MinMaxBounds; +import net.minecraft.advancements.criterion.DataComponentMatchers; +import net.minecraft.advancements.criterion.ItemPredicate; +import net.minecraft.advancements.criterion.MinMaxBounds; import net.minecraft.core.component.DataComponentExactPredicate; import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java index cdb594244993..075921649b8a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java @@ -2,9 +2,9 @@ import java.util.Collections; import java.util.Optional; -import net.minecraft.advancements.critereon.DataComponentMatchers; -import net.minecraft.advancements.critereon.ItemPredicate; -import net.minecraft.advancements.critereon.MinMaxBounds; +import net.minecraft.advancements.criterion.DataComponentMatchers; +import net.minecraft.advancements.criterion.ItemPredicate; +import net.minecraft.advancements.criterion.MinMaxBounds; import net.minecraft.core.component.DataComponentExactPredicate; import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java index c7f958024968..a8b57a406b9f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java @@ -74,7 +74,7 @@ public void setCookTimeTotal(int cookTimeTotal) { public Map, Integer> getRecipesUsed() { ImmutableMap.Builder, Integer> recipesUsed = ImmutableMap.builder(); this.getSnapshot().recipesUsed.reference2IntEntrySet().fastForEach(entrySet -> { - Recipe recipe = Bukkit.getRecipe(CraftNamespacedKey.fromMinecraft(entrySet.getKey().location())); + Recipe recipe = Bukkit.getRecipe(CraftNamespacedKey.fromMinecraft(entrySet.getKey().identifier())); if (recipe instanceof CookingRecipe cookingRecipe) { recipesUsed.put(cookingRecipe, entrySet.getValue()); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java index ed3fcbbaaaa2..f044c303075f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java @@ -7,8 +7,8 @@ import io.papermc.paper.adventure.PaperAdventure; import io.papermc.paper.datacomponent.item.PaperResolvableProfile; import net.kyori.adventure.text.Component; -import net.minecraft.Util; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Util; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.players.NameAndId; import net.minecraft.world.entity.player.PlayerSkin; @@ -163,7 +163,7 @@ public void setOwnerProfile(PlayerProfile profile) { @Override public NamespacedKey getNoteBlockSound() { - ResourceLocation key = this.getSnapshot().getNoteBlockSound(); + Identifier key = this.getSnapshot().getNoteBlockSound(); return (key != null) ? CraftNamespacedKey.fromMinecraft(key) : null; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java index 66cebe94bac3..68bb1b852273 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -579,7 +579,7 @@ public static CraftBlockData newData(BlockType blockType, String data) { if (blockType != null) { Block block = CraftBlockType.bukkitToMinecraftNew(blockType); if (block != null) { - net.minecraft.resources.ResourceLocation key = BuiltInRegistries.BLOCK.getKey(block); + net.minecraft.resources.Identifier key = BuiltInRegistries.BLOCK.getKey(block); data = data == null ? key.toString() : key + data; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/configuration/ConfigSerializationUtil.java b/paper-server/src/main/java/org/bukkit/craftbukkit/configuration/ConfigSerializationUtil.java index 7e13f9227ca1..38b07b508205 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/configuration/ConfigSerializationUtil.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/configuration/ConfigSerializationUtil.java @@ -10,7 +10,7 @@ import net.minecraft.core.HolderSet; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.craftbukkit.CraftRegistry; @@ -47,14 +47,14 @@ public static T getObject(Class clazz, Map map, String key, boolean public static void setHolderSet(Map result, String key, HolderSet holders) { holders.unwrap() .ifLeft(tag -> result.put(key, "#" + tag.location().toString())) // Tag - .ifRight(list -> result.put(key, list.stream().map((entry) -> entry.unwrapKey().orElseThrow().location().toString()).toList())); // List + .ifRight(list -> result.put(key, list.stream().map((entry) -> entry.unwrapKey().orElseThrow().identifier().toString()).toList())); // List } public static HolderSet getHolderSet(Object from, ResourceKey> registryKey) { Registry registry = CraftRegistry.getMinecraftRegistry(registryKey); if (from instanceof String parseString && parseString.startsWith("#")) { // Tag parseString = parseString.substring(1); - ResourceLocation key = ResourceLocation.tryParse(parseString); + Identifier key = Identifier.tryParse(parseString); if (key != null) { Optional> tag = registry.get(TagKey.create(registryKey, key)); if (tag.isPresent()) { @@ -65,7 +65,7 @@ public static HolderSet getHolderSet(Object from, ResourceKey List> holderList = new ArrayList<>(parseList.size()); for (Object entry : parseList) { - ResourceLocation key = ResourceLocation.tryParse(entry.toString()); + Identifier key = Identifier.tryParse(entry.toString()); if (key == null) { continue; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index 286ed00c01bc..dbe3e37fcd9c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -4,7 +4,7 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.util.Holderable; import java.util.Locale; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; import net.minecraft.tags.EnchantmentTags; @@ -236,7 +236,7 @@ public io.papermc.paper.registry.set.RegistryKeySet> registry = CraftRegistry.getMinecraftRegistry(Registries.ENTITY_TYPE); - EntityType bukkit = Registry.ENTITY_TYPE.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().location())); + EntityType bukkit = Registry.ENTITY_TYPE.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().identifier())); Preconditions.checkArgument(bukkit != null); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 73b55c2de10d..8b04c7a86ab7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -14,7 +14,7 @@ import net.minecraft.network.protocol.game.ClientboundHorseScreenOpenPacket; import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; import net.minecraft.network.protocol.game.ServerboundContainerClosePacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.HumanoidArm; @@ -645,7 +645,7 @@ public boolean hasCooldown(ItemStack item) { public int getCooldown(ItemStack item) { Preconditions.checkArgument(item != null, "Item cannot be null"); - ResourceLocation group = this.getHandle().getCooldowns().getCooldownGroup(CraftItemStack.asNMSCopy(item)); + Identifier group = this.getHandle().getCooldowns().getCooldownGroup(CraftItemStack.asNMSCopy(item)); if (group == null) { return 0; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 2a46c8c89698..2b216f84ddcb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -99,7 +99,7 @@ import net.minecraft.network.protocol.game.ClientboundTabListPacket; import net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket; import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.PlayerAdvancements; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; @@ -797,7 +797,7 @@ public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory catego public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) { if (loc == null || sound == null || category == null || this.getHandle().connection == null) return; - this.playSound0(loc, Holder.direct(SoundEvent.createVariableRangeEvent(ResourceLocation.parse(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), volume, pitch, seed); + this.playSound0(loc, Holder.direct(SoundEvent.createVariableRangeEvent(Identifier.parse(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), volume, pitch, seed); } private void playSound0(Location loc, Holder soundEffectHolder, net.minecraft.sounds.SoundSource categoryNMS, float volume, float pitch, long seed) { @@ -830,7 +830,7 @@ public void playSound(org.bukkit.entity.Entity entity, Sound sound, org.bukkit.S public void playSound(org.bukkit.entity.Entity entity, String sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) { if (!(entity instanceof CraftEntity) || sound == null || category == null || this.getHandle().connection == null) return; - this.playSound0(entity, Holder.direct(SoundEvent.createVariableRangeEvent(ResourceLocation.parse(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), volume, pitch, seed); + this.playSound0(entity, Holder.direct(SoundEvent.createVariableRangeEvent(Identifier.parse(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), volume, pitch, seed); } private void playSound0(org.bukkit.entity.Entity entity, Holder soundEffectHolder, net.minecraft.sounds.SoundSource categoryNMS, float volume, float pitch, long seed) { @@ -849,7 +849,7 @@ private void playSound0(org.bukkit.entity.Entity entity, Holder soun public void stopSound(String sound, org.bukkit.SoundCategory category) { if (this.getHandle().connection == null) return; - this.getHandle().connection.send(new ClientboundStopSoundPacket(ResourceLocation.parse(sound), category == null ? net.minecraft.sounds.SoundSource.MASTER : net.minecraft.sounds.SoundSource.valueOf(category.name()))); + this.getHandle().connection.send(new ClientboundStopSoundPacket(Identifier.parse(sound), category == null ? net.minecraft.sounds.SoundSource.MASTER : net.minecraft.sounds.SoundSource.valueOf(category.name()))); } @Override @@ -1428,7 +1428,7 @@ public boolean hasDiscoveredRecipe(NamespacedKey recipe) { @Override public Set getDiscoveredRecipes() { ImmutableSet.Builder bukkitRecipeKeys = ImmutableSet.builder(); - this.getHandle().getRecipeBook().known.forEach(key -> bukkitRecipeKeys.add(CraftNamespacedKey.fromMinecraft(key.location()))); + this.getHandle().getRecipeBook().known.forEach(key -> bukkitRecipeKeys.add(CraftNamespacedKey.fromMinecraft(key.identifier()))); return bukkitRecipeKeys.build(); } @@ -2201,12 +2201,12 @@ public void sendPluginMessage(Plugin source, String channel, byte[] message) { if (this.getHandle().connection == null) return; if (this.channels().contains(channel)) { - ResourceLocation id = ResourceLocation.parse(StandardMessenger.validateAndCorrectChannel(channel)); + Identifier id = Identifier.parse(StandardMessenger.validateAndCorrectChannel(channel)); this.sendCustomPayload(id, message); } } - private void sendCustomPayload(ResourceLocation id, byte[] message) { + private void sendCustomPayload(Identifier id, byte[] message) { ClientboundCustomPayloadPacket packet = new ClientboundCustomPayloadPacket(new DiscardedPayload(id, message)); this.getHandle().connection.send(packet); } @@ -3122,7 +3122,7 @@ public void increaseWardenWarningLevel() { // Paper start @Override public Duration getIdleDuration() { - return Duration.ofMillis(net.minecraft.Util.getMillis() - this.getHandle().getLastActionTime()); + return Duration.ofMillis(net.minecraft.util.Util.getMillis() - this.getHandle().getLastActionTime()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryKey.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryKey.java index 291a19c39b0a..558921d7caa4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryKey.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryKey.java @@ -17,7 +17,7 @@ public static MemoryKey minecraftToBukkit(MemoryModuleType minecraf } net.minecraft.core.Registry> registry = CraftRegistry.getMinecraftRegistry(Registries.MEMORY_MODULE_TYPE); - MemoryKey bukkit = (MemoryKey) Registry.MEMORY_MODULE_TYPE.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().location())); + MemoryKey bukkit = (MemoryKey) Registry.MEMORY_MODULE_TYPE.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().identifier())); return bukkit; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 5671d70ddce5..4f20f0411d77 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1849,7 +1849,7 @@ public static boolean handleBatToggleSleepEvent(Entity bat, boolean awake) { } public static PlayerRecipeDiscoverEvent callPlayerRecipeListUpdateEvent(net.minecraft.world.entity.player.Player player, RecipeHolder recipeHolder) { - PlayerRecipeDiscoverEvent event = new PlayerRecipeDiscoverEvent((Player) player.getBukkitEntity(), CraftNamespacedKey.fromMinecraft(recipeHolder.id().location()), recipeHolder.value().showNotification()); + PlayerRecipeDiscoverEvent event = new PlayerRecipeDiscoverEvent((Player) player.getBukkitEntity(), CraftNamespacedKey.fromMinecraft(recipeHolder.id().identifier()), recipeHolder.value().showNotification()); event.callEvent(); return event; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index f896417d37ba..4abee7b6d922 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -10,7 +10,7 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.EnchantmentTags; import net.minecraft.util.RandomSource; import net.minecraft.world.item.Item; @@ -302,7 +302,7 @@ public ItemStack getSpawnEgg0(org.bukkit.entity.EntityType type) { return null; } String typeId = type.getKey().toString(); - net.minecraft.resources.ResourceLocation typeKey = ResourceLocation.parse(typeId); + net.minecraft.resources.Identifier typeKey = Identifier.parse(typeId); net.minecraft.world.entity.EntityType nmsType = net.minecraft.core.registries.BuiltInRegistries.ENTITY_TYPE.getValue(typeKey); net.minecraft.world.item.SpawnEggItem eggItem = net.minecraft.world.item.SpawnEggItem.byId(nmsType); return eggItem == null ? null : new net.minecraft.world.item.ItemStack(eggItem).asBukkitMirror(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index 96c0797aaea7..002682049fe8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -9,9 +9,9 @@ import java.util.function.Consumer; import java.util.function.Predicate; import net.kyori.adventure.text.Component; -import net.minecraft.advancements.critereon.DataComponentMatchers; -import net.minecraft.advancements.critereon.ItemPredicate; -import net.minecraft.advancements.critereon.MinMaxBounds; +import net.minecraft.advancements.criterion.DataComponentMatchers; +import net.minecraft.advancements.criterion.ItemPredicate; +import net.minecraft.advancements.criterion.MinMaxBounds; import net.minecraft.core.Holder; import net.minecraft.core.HolderSet; import net.minecraft.core.component.DataComponentExactPredicate; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java index 4f4c1748f802..ded1e398ff3b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java @@ -11,7 +11,7 @@ import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.component.LodestoneTracker; @@ -54,7 +54,7 @@ public class CraftMetaCompass extends CraftMetaItem implements CompassMeta { super(map); String lodestoneWorldKey = SerializableMeta.getString(map, CraftMetaCompass.LODESTONE_POS_WORLD.BUKKIT, true); if (lodestoneWorldKey != null) { - ResourceKey lodestoneWorld = ResourceKey.create(Registries.DIMENSION, ResourceLocation.tryParse(lodestoneWorldKey)); + ResourceKey lodestoneWorld = ResourceKey.create(Registries.DIMENSION, Identifier.tryParse(lodestoneWorldKey)); int lodestoneX = (Integer) map.get(CraftMetaCompass.LODESTONE_POS_X.BUKKIT); int lodestoneY = (Integer) map.get(CraftMetaCompass.LODESTONE_POS_Y.BUKKIT); int lodestoneZ = (Integer) map.get(CraftMetaCompass.LODESTONE_POS_Z.BUKKIT); @@ -182,7 +182,7 @@ Builder serialize(Builder builder) { if (this.isLodestoneCompass()) { if (this.tracker.target().isPresent()) { - builder.put(CraftMetaCompass.LODESTONE_POS_WORLD.BUKKIT, this.tracker.target().get().dimension().location().toString()); + builder.put(CraftMetaCompass.LODESTONE_POS_WORLD.BUKKIT, this.tracker.target().get().dimension().identifier().toString()); builder.put(CraftMetaCompass.LODESTONE_POS_X.BUKKIT, this.tracker.target().get().pos().getX()); builder.put(CraftMetaCompass.LODESTONE_POS_Y.BUKKIT, this.tracker.target().get().pos().getY()); builder.put(CraftMetaCompass.LODESTONE_POS_Z.BUKKIT, this.tracker.target().get().pos().getZ()); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index c0f44885f4dc..3825cd713a42 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -55,7 +55,7 @@ import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.SnbtPrinterTagVisitor; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import net.minecraft.util.Unit; import net.minecraft.world.entity.EquipmentSlotGroup; @@ -236,9 +236,9 @@ DataComponentPatch build() { @Specific(Specific.To.NBT) static final ItemMetaKeyType TOOLTIP_DISPLAY = new ItemMetaKeyType<>(DataComponents.TOOLTIP_DISPLAY, "tool-tip-display"); @Specific(Specific.To.NBT) - static final ItemMetaKeyType TOOLTIP_STYLE = new ItemMetaKeyType<>(DataComponents.TOOLTIP_STYLE, "tool-tip-style"); + static final ItemMetaKeyType TOOLTIP_STYLE = new ItemMetaKeyType<>(DataComponents.TOOLTIP_STYLE, "tool-tip-style"); @Specific(Specific.To.NBT) - static final ItemMetaKeyType ITEM_MODEL = new ItemMetaKeyType<>(DataComponents.ITEM_MODEL, "item-model"); + static final ItemMetaKeyType ITEM_MODEL = new ItemMetaKeyType<>(DataComponents.ITEM_MODEL, "item-model"); @Specific(Specific.To.NBT) static final ItemMetaKeyType UNBREAKABLE = new ItemMetaKeyType<>(DataComponents.UNBREAKABLE, "Unbreakable"); @Specific(Specific.To.NBT) @@ -302,8 +302,8 @@ DataComponentPatch build() { private CraftJukeboxComponent jukebox; private Integer damage; private Integer maxDamage; - private List canPlaceOnPredicates; - private List canBreakPredicates; + private List canPlaceOnPredicates; + private List canBreakPredicates; // hide_additional_tooltip backward compatibility based on TooltipDisplayComponentFix#CONVERTED_ADDITIONAL_TOOLTIP_TYPES private static final Set> HIDDEN_COMPONENTS_PREVIOUSLY = Set.of( @@ -794,7 +794,7 @@ static Multimap buildModifiers(ItemAttributeModifi for (Object removedObject : removed) { String removedString = (String) removedObject; - DataComponentType component = componentTypeRegistry.getValue(ResourceLocation.parse(removedString)); + DataComponentType component = componentTypeRegistry.getValue(Identifier.parse(removedString)); if (component != null) { this.removedTags.add(component); } @@ -1841,7 +1841,7 @@ public String getAsComponentString() { for (Entry, Optional> entry : patch.entrySet()) { DataComponentType componentType = entry.getKey(); Optional componentValue = entry.getValue(); - String componentKey = componentTypeRegistry.getResourceKey(componentType).orElseThrow().location().toString(); + String componentKey = componentTypeRegistry.getResourceKey(componentType).orElseThrow().identifier().toString(); if (componentValue.isPresent()) { net.minecraft.nbt.Tag componentValueAsNBT = (net.minecraft.nbt.Tag) ((DataComponentType) componentType).codecOrThrow().encodeStart(ops, componentValue.get()).getOrThrow(); @@ -2278,7 +2278,7 @@ ImmutableMap.Builder serialize(ImmutableMap.Builder removedTags = new ArrayList<>(); for (DataComponentType removed : this.removedTags) { - String componentKey = componentTypeRegistry.getResourceKey(removed).orElseThrow().location().toString(); + String componentKey = componentTypeRegistry.getResourceKey(removed).orElseThrow().identifier().toString(); removedTags.add(componentKey); } @@ -2519,14 +2519,14 @@ public void setCanPlaceOn(final Set canPlaceOn) { this.canPlaceOnPredicates = convertFromLegacyMaterial(canPlaceOn); } - private static List convertFromLegacyMaterial(final Collection materials) { + private static List convertFromLegacyMaterial(final Collection materials) { final net.minecraft.core.Registry blockRegistry = CraftRegistry.getMinecraftRegistry().lookupOrThrow(net.minecraft.core.registries.Registries.BLOCK); return materials.stream().map(m -> { - return net.minecraft.advancements.critereon.BlockPredicate.Builder.block().of(blockRegistry, CraftBlockType.bukkitToMinecraft(m)).build(); + return net.minecraft.advancements.criterion.BlockPredicate.Builder.block().of(blockRegistry, CraftBlockType.bukkitToMinecraft(m)).build(); }).toList(); } - private static Set convertToLegacyMaterial(final List predicates) { + private static Set convertToLegacyMaterial(final List predicates) { return predicates.stream() .flatMap(p -> p.blocks().map(net.minecraft.core.HolderSet::stream).orElse(java.util.stream.Stream.empty())) .map(holder -> CraftBlockType.minecraftToBukkit(holder.value())) @@ -2557,22 +2557,22 @@ public void setPlaceableKeys(final Collection convertFromLegacyNamespaced(final Collection namespaceds) { - final List predicates = new ArrayList<>(); + private static List convertFromLegacyNamespaced(final Collection namespaceds) { + final List predicates = new ArrayList<>(); final net.minecraft.core.Registry blockRegistry = CraftRegistry.getMinecraftRegistry().lookupOrThrow(net.minecraft.core.registries.Registries.BLOCK); for (final com.destroystokyo.paper.Namespaced namespaced : namespaceds) { if (namespaced instanceof final org.bukkit.NamespacedKey key) { - predicates.add(net.minecraft.advancements.critereon.BlockPredicate.Builder.block().of(blockRegistry, CraftBlockType.bukkitToMinecraft(Objects.requireNonNull(org.bukkit.Registry.MATERIAL.get(key)))).build()); + predicates.add(net.minecraft.advancements.criterion.BlockPredicate.Builder.block().of(blockRegistry, CraftBlockType.bukkitToMinecraft(Objects.requireNonNull(org.bukkit.Registry.MATERIAL.get(key)))).build()); } else if (namespaced instanceof final com.destroystokyo.paper.NamespacedTag tag) { - predicates.add(net.minecraft.advancements.critereon.BlockPredicate.Builder.block().of(blockRegistry, net.minecraft.tags.TagKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(tag.getNamespace(), tag.getKey()))).build()); + predicates.add(net.minecraft.advancements.criterion.BlockPredicate.Builder.block().of(blockRegistry, net.minecraft.tags.TagKey.create(Registries.BLOCK, Identifier.fromNamespaceAndPath(tag.getNamespace(), tag.getKey()))).build()); } } return predicates; } - private static Set convertToLegacyNamespaced(final Collection predicates) { + private static Set convertToLegacyNamespaced(final Collection predicates) { final Set namespaceds = Sets.newHashSet(); - for (final net.minecraft.advancements.critereon.BlockPredicate predicate : predicates) { + for (final net.minecraft.advancements.criterion.BlockPredicate predicate : predicates) { if (predicate.blocks().isEmpty()) { continue; } @@ -2582,7 +2582,7 @@ private static Set convertToLegacyNamespaced } else { holders.forEach(h -> { h.unwrapKey().ifPresent(key -> { - namespaceds.add(new org.bukkit.NamespacedKey(key.location().getNamespace(), key.location().getPath())); + namespaceds.add(new org.bukkit.NamespacedKey(key.identifier().getNamespace(), key.identifier().getPath())); }); }); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java index b162af62cfc3..e6ef13de6a15 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java @@ -35,7 +35,7 @@ public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBo getOrEmpty(tag, CraftMetaKnowledgeBook.BOOK_RECIPES).ifPresent((recipes) -> { for (ResourceKey recipe : recipes) { - this.addRecipe(CraftNamespacedKey.fromMinecraft(recipe.location())); + this.addRecipe(CraftNamespacedKey.fromMinecraft(recipe.identifier())); } }); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java index 936c96a028d0..0266193900db 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java @@ -5,13 +5,13 @@ import java.util.Map; import java.util.Objects; import com.mojang.datafixers.util.Either; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.UUIDUtil; import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.component.DataComponents; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtOps; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.entity.player.PlayerSkin; import net.minecraft.world.item.component.ResolvableProfile; import org.bukkit.Bukkit; @@ -35,11 +35,11 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { @ItemMetaKey.Specific(ItemMetaKey.Specific.To.NBT) static final ItemMetaKey BLOCK_ENTITY_TAG = new ItemMetaKey("BlockEntityTag"); - static final ItemMetaKeyType NOTE_BLOCK_SOUND = new ItemMetaKeyType<>(DataComponents.NOTE_BLOCK_SOUND, "note_block_sound"); + static final ItemMetaKeyType NOTE_BLOCK_SOUND = new ItemMetaKeyType<>(DataComponents.NOTE_BLOCK_SOUND, "note_block_sound"); static final int MAX_OWNER_LENGTH = 16; private ResolvableProfile profile; - private ResourceLocation noteBlockSound; + private Identifier noteBlockSound; CraftMetaSkull(CraftMetaItem meta) { super(meta); @@ -93,7 +93,7 @@ void deserializeInternal(CompoundTag tag, Object context) { tag.getCompound(CraftMetaSkull.BLOCK_ENTITY_TAG.NBT) .flatMap(blockEntityTag -> blockEntityTag.copy().getString(CraftMetaSkull.NOTE_BLOCK_SOUND.NBT)) .ifPresent(noteBlockSound -> { - this.noteBlockSound = ResourceLocation.tryParse(noteBlockSound); + this.noteBlockSound = Identifier.tryParse(noteBlockSound); }); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java index 2090613ef840..9db372844211 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java @@ -11,7 +11,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.item.equipment.EquipmentAssets; import net.minecraft.world.item.equipment.Equippable; @@ -69,8 +69,8 @@ public CraftEquippableComponent(Map map) { this.handle = new Equippable(slot, (equipSound != null) ? CraftSound.bukkitToMinecraftHolder(equipSound) : SoundEvents.ARMOR_EQUIP_GENERIC, - Optional.ofNullable(model).map(ResourceLocation::parse).map((k) -> ResourceKey.create(EquipmentAssets.ROOT_ID, k)), - Optional.ofNullable(cameraOverlay).map(ResourceLocation::parse), + Optional.ofNullable(model).map(Identifier::parse).map((k) -> ResourceKey.create(EquipmentAssets.ROOT_ID, k)), + Optional.ofNullable(cameraOverlay).map(Identifier::parse), Optional.ofNullable(allowedEntities), (dispensable != null) ? dispensable : true, (swappable != null) ? swappable : true, @@ -132,7 +132,7 @@ public void setEquipSound(Sound sound) { @Override public NamespacedKey getModel() { - return this.handle.assetId().map((a) -> CraftNamespacedKey.fromMinecraft(a.location())).orElse(null); + return this.handle.assetId().map((a) -> CraftNamespacedKey.fromMinecraft(a.identifier())).orElse(null); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftJukeboxComponent.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftJukeboxComponent.java index eff1cad2c360..616d409a8753 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftJukeboxComponent.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftJukeboxComponent.java @@ -7,7 +7,7 @@ import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.EitherHolder; import net.minecraft.world.item.JukeboxPlayable; import org.bukkit.JukeboxSong; @@ -35,7 +35,7 @@ public CraftJukeboxComponent(CraftJukeboxComponent jukebox) { public CraftJukeboxComponent(Map map) { String song = SerializableMeta.getObject(String.class, map, "song", false); - this.handle = new JukeboxPlayable(new EitherHolder<>(ResourceKey.create(Registries.JUKEBOX_SONG, ResourceLocation.parse(song)))); + this.handle = new JukeboxPlayable(new EitherHolder<>(ResourceKey.create(Registries.JUKEBOX_SONG, Identifier.parse(song)))); } @Override @@ -57,7 +57,7 @@ public JukeboxSong getSong() { @Override public NamespacedKey getSongKey() { - return CraftNamespacedKey.fromMinecraft(this.handle.song().key().orElseThrow().location()); + return CraftNamespacedKey.fromMinecraft(this.handle.song().key().orElseThrow().identifier()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftUseCooldownComponent.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftUseCooldownComponent.java index b6f285d5e84b..84025d9c2b7e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftUseCooldownComponent.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftUseCooldownComponent.java @@ -4,7 +4,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Optional; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.component.UseCooldown; import org.bukkit.NamespacedKey; import org.bukkit.configuration.serialization.SerializableAs; @@ -29,7 +29,7 @@ public CraftUseCooldownComponent(Map map) { Float seconds = SerializableMeta.getObject(Float.class, map, "seconds", false); String cooldownGroup = SerializableMeta.getString(map, "cooldown-group", true); - this.handle = new UseCooldown(seconds, Optional.ofNullable(cooldownGroup).map(ResourceLocation::parse)); + this.handle = new UseCooldown(seconds, Optional.ofNullable(cooldownGroup).map(Identifier::parse)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java b/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java index 0b9b29753984..ced48449ad7e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java @@ -13,7 +13,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.Tag; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.Bootstrap; import net.minecraft.server.MinecraftServer; import net.minecraft.util.datafix.DataFixers; @@ -338,7 +338,7 @@ public static void init() { } String name = blockTag.get("Name").asString(""); - Block block = BuiltInRegistries.BLOCK.getValue(ResourceLocation.parse(name)); + Block block = BuiltInRegistries.BLOCK.getValue(Identifier.parse(name)); if (block == null) { continue; } @@ -412,7 +412,7 @@ public static void init() { } // Preconditions.checkState(newId.contains("minecraft:"), "Unknown new material for " + matData); - Item newMaterial = BuiltInRegistries.ITEM.getValue(ResourceLocation.parse(newId)); + Item newMaterial = BuiltInRegistries.ITEM.getValue(Identifier.parse(newId)); if (newMaterial == Items.AIR) { continue; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java index db51e0f1ad8c..77f89f390f09 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java @@ -15,7 +15,7 @@ import java.util.logging.Logger; import java.util.zip.DeflaterOutputStream; import java.util.zip.InflaterInputStream; -import net.minecraft.Util; +import net.minecraft.util.Util; import org.bukkit.map.MapPalette; public class CraftMapColorCache implements MapPalette.MapColorCache { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java index 24010b74ac13..a304fafd78f6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java @@ -29,7 +29,7 @@ public static PotionType minecraftToBukkit(Potion minecraft) { Preconditions.checkArgument(minecraft != null); net.minecraft.core.Registry registry = CraftRegistry.getMinecraftRegistry(Registries.POTION); - PotionType bukkit = Registry.POTION.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().location())); + PotionType bukkit = Registry.POTION.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().identifier())); Preconditions.checkArgument(bukkit != null); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java b/paper-server/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java index 362f0427d0c6..4d4c7861323a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java @@ -18,7 +18,7 @@ import java.util.stream.Collectors; import com.mojang.datafixers.util.Either; import io.papermc.paper.profile.MutablePropertyMap; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.server.dedicated.DedicatedServer; import net.minecraft.server.players.NameAndId; import net.minecraft.world.entity.player.PlayerSkin; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructureManager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructureManager.java index 0fc33b97d502..5cdc356f7288 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructureManager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructureManager.java @@ -16,7 +16,7 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; import org.bukkit.NamespacedKey; @@ -37,7 +37,7 @@ public CraftStructureManager(StructureTemplateManager structureManager, Registry @Override public Map getStructures() { Map cachedStructures = new HashMap<>(); - for (Map.Entry> entry : this.structureManager.structureRepository.entrySet()) { + for (Map.Entry> entry : this.structureManager.structureRepository.entrySet()) { entry.getValue().ifPresent(definedStructure -> cachedStructures.put(CraftNamespacedKey.fromMinecraft(entry.getKey()), new CraftStructure(definedStructure, this.registry))); } return Collections.unmodifiableMap(cachedStructures); @@ -56,7 +56,7 @@ public Structure getStructure(NamespacedKey structureKey) { @Override public Structure loadStructure(NamespacedKey structureKey, boolean register) { - ResourceLocation minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); + Identifier minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); Optional structure = this.structureManager.structureRepository.get(minecraftKey); structure = structure == null ? Optional.empty() : structure; @@ -77,7 +77,7 @@ public Structure loadStructure(NamespacedKey structureKey) { @Override public void saveStructure(NamespacedKey structureKey) { - ResourceLocation minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); + Identifier minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); this.structureManager.save(minecraftKey); } @@ -96,7 +96,7 @@ public void saveStructure(NamespacedKey structureKey, Structure structure) throw public Structure registerStructure(NamespacedKey structureKey, Structure structure) { Preconditions.checkArgument(structureKey != null, "NamespacedKey structureKey cannot be null"); Preconditions.checkArgument(structure != null, "Structure cannot be null"); - ResourceLocation minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); + Identifier minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); final Optional optionalDefinedStructure = Optional.of(((CraftStructure) structure).getHandle()); final Optional previousStructure = this.structureManager.structureRepository.put(minecraftKey, optionalDefinedStructure); @@ -106,7 +106,7 @@ public Structure registerStructure(NamespacedKey structureKey, Structure structu @Override public Structure unregisterStructure(NamespacedKey structureKey) { Preconditions.checkArgument(structureKey != null, "NamespacedKey structureKey cannot be null"); - ResourceLocation minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); + Identifier minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); final Optional previousStructure = this.structureManager.structureRepository.remove(minecraftKey); return previousStructure == null ? null : previousStructure.map((s) -> new CraftStructure(s, this.registry)).orElse(null); @@ -119,7 +119,7 @@ public void deleteStructure(NamespacedKey structureKey) throws IOException { @Override public void deleteStructure(NamespacedKey structureKey, boolean unregister) throws IOException { - ResourceLocation key = CraftNamespacedKey.toMinecraft(structureKey); + Identifier key = CraftNamespacedKey.toMinecraft(structureKey); if (unregister) { this.structureManager.structureRepository.remove(key); @@ -130,7 +130,7 @@ public void deleteStructure(NamespacedKey structureKey, boolean unregister) thro @Override public File getStructureFile(NamespacedKey structureKey) { - ResourceLocation minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); + Identifier minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); return this.structureManager.createAndValidatePathToGeneratedStructure(minecraftKey, ".nbt").toFile(); } @@ -172,10 +172,10 @@ public Structure createStructure() { return new CraftStructure(new StructureTemplate(), this.registry); } - private ResourceLocation createAndValidateMinecraftStructureKey(NamespacedKey structureKey) { + private Identifier createAndValidateMinecraftStructureKey(NamespacedKey structureKey) { Preconditions.checkArgument(structureKey != null, "NamespacedKey structureKey cannot be null"); - ResourceLocation key = CraftNamespacedKey.toMinecraft(structureKey); + Identifier key = CraftNamespacedKey.toMinecraft(structureKey); Preconditions.checkArgument(!key.getPath().contains("//"), "Resource key for Structures can not contain \"//\""); return key; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index f83067eaa4ee..299e53032471 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -38,7 +38,7 @@ import net.minecraft.nbt.StringTag; import net.minecraft.nbt.Tag; import net.minecraft.nbt.TagParser; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.ProblemReporter; @@ -177,7 +177,7 @@ public static MaterialData getMaterialData(Item item) { continue; } - ResourceLocation key = CraftNamespacedKey.toMinecraft(material.getKey()); + Identifier key = CraftNamespacedKey.toMinecraft(material.getKey()); BuiltInRegistries.ITEM.getOptional(key).ifPresent((item) -> { CraftMagicNumbers.MATERIAL_ITEM.put(material, item); }); @@ -301,13 +301,13 @@ private static File getBukkitDataPackFolder() { @Override public Advancement loadAdvancement(NamespacedKey key, String advancement) { Preconditions.checkArgument(Bukkit.getAdvancement(key) == null, "Advancement %s already exists", key); - ResourceLocation resourceKey = CraftNamespacedKey.toMinecraft(key); + Identifier resourceKey = CraftNamespacedKey.toMinecraft(key); JsonElement jsonelement = JsonParser.parseString(advancement); final net.minecraft.resources.RegistryOps ops = CraftRegistry.getMinecraftRegistry().createSerializationContext(JsonOps.INSTANCE); // Paper - use RegistryOps final net.minecraft.advancements.Advancement nms = net.minecraft.advancements.Advancement.CODEC.parse(ops, jsonelement).getOrThrow(JsonParseException::new); // Paper - use RegistryOps if (nms != null) { - final com.google.common.collect.ImmutableMap.Builder mapBuilder = com.google.common.collect.ImmutableMap.builder(); + final com.google.common.collect.ImmutableMap.Builder mapBuilder = com.google.common.collect.ImmutableMap.builder(); mapBuilder.putAll(MinecraftServer.getServer().getAdvancements().advancements); final AdvancementHolder holder = new AdvancementHolder(resourceKey, nms); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java index 74ea22eb7faf..90a466cab30a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.util; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.NamespacedKey; import org.jspecify.annotations.NullMarked; @@ -12,19 +12,19 @@ public CraftNamespacedKey() { } public static NamespacedKey fromString(String string) { - return CraftNamespacedKey.fromMinecraft(ResourceLocation.parse(string)); + return CraftNamespacedKey.fromMinecraft(Identifier.parse(string)); } - public static NamespacedKey fromMinecraft(ResourceLocation minecraft) { + public static NamespacedKey fromMinecraft(Identifier minecraft) { return new NamespacedKey(minecraft.getNamespace(), minecraft.getPath()); } - public static ResourceLocation toMinecraft(NamespacedKey key) { - return ResourceLocation.fromNamespaceAndPath(key.getNamespace(), key.getKey()); + public static Identifier toMinecraft(NamespacedKey key) { + return Identifier.fromNamespaceAndPath(key.getNamespace(), key.getKey()); } public static NamespacedKey fromResourceKey(final ResourceKey key) { - return CraftNamespacedKey.fromMinecraft(key.location()); + return CraftNamespacedKey.fromMinecraft(key.identifier()); } public static ResourceKey toResourceKey( diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java index a2c9b4a9e220..bb117482fe9d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java @@ -30,7 +30,6 @@ import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.ColorResolver; import net.minecraft.world.level.LightLayer; -import net.minecraft.world.level.MoonPhase; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.BiomeManager; @@ -97,11 +96,6 @@ public ServerLevel getMinecraftWorld() { return this.delegate.getMinecraftWorld(); } - @Override - public long dayTime() { - return this.delegate.dayTime(); - } - @Override public long nextSubTickCount() { return this.delegate.nextSubTickCount(); @@ -247,21 +241,6 @@ public BlockPos getHeightmapPos(Heightmap.Types heightmap, BlockPos pos) { return this.delegate.getHeightmapPos(heightmap, pos); } - @Override - public float getMoonBrightness() { - return this.delegate.getMoonBrightness(); - } - - @Override - public float getTimeOfDay(float tickDelta) { - return this.delegate.getTimeOfDay(tickDelta); - } - - @Override - public MoonPhase getMoonPhase() { - return this.delegate.getMoonPhase(); - } - @Override public ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { return this.delegate.getChunk(chunkX, chunkZ, leastStatus, create); diff --git a/paper-server/src/main/java/org/spigotmc/SpigotConfig.java b/paper-server/src/main/java/org/spigotmc/SpigotConfig.java index ba539e6a37eb..97d81401484b 100644 --- a/paper-server/src/main/java/org/spigotmc/SpigotConfig.java +++ b/paper-server/src/main/java/org/spigotmc/SpigotConfig.java @@ -15,7 +15,7 @@ import java.util.Set; import java.util.logging.Level; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.RangedAttribute; @@ -202,7 +202,7 @@ private static void nettyThreads() { } public static boolean disableStatSaving; - public static Map forcedStats = new HashMap<>(); + public static Map forcedStats = new HashMap<>(); private static void stats() { SpigotConfig.disableStatSaving = SpigotConfig.getBoolean("stats.disable-saving", false); @@ -215,7 +215,7 @@ private static void stats() { for (String name : section.getKeys(true)) { if (section.isInt(name)) { try { - ResourceLocation key = ResourceLocation.parse(name); + Identifier key = Identifier.parse(name); if (BuiltInRegistries.CUSTOM_STAT.get(key) == null) { Bukkit.getLogger().log(Level.WARNING, "Ignoring non existent stats.forced-stats " + name); continue; diff --git a/paper-server/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java b/paper-server/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java index 9bfeb1cee6cc..4e7f7f043a6d 100644 --- a/paper-server/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java +++ b/paper-server/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java @@ -37,7 +37,7 @@ import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.Tag; import net.minecraft.network.chat.ComponentSerialization; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import org.bukkit.support.RegistryHelper; @@ -108,7 +108,7 @@ void testKey() { final Key key = key("hello", "there"); final Tag result = KEY_CODEC.encodeStart(NbtOps.INSTANCE, key).result().orElseThrow(); assertEquals("\"" + key.asString() + "\"", result.toString()); - final ResourceLocation location = ResourceLocation.CODEC.decode(NbtOps.INSTANCE, result).result().orElseThrow().getFirst(); + final Identifier location = Identifier.CODEC.decode(NbtOps.INSTANCE, result).result().orElseThrow().getFirst(); assertEquals(key.asString(), location.toString()); } @@ -138,7 +138,7 @@ void testClickEvent(final ClickEvent.Action action) { assertEquals(((ClickEvent.Payload.Text) event.payload()).value(), value); case net.minecraft.network.chat.ClickEvent.ChangePage(int page) -> assertEquals(((ClickEvent.Payload.Int) event.payload()).integer(), page); - case net.minecraft.network.chat.ClickEvent.Custom(ResourceLocation id, Optional payload) -> { + case net.minecraft.network.chat.ClickEvent.Custom(Identifier id, Optional payload) -> { assertEquals(((ClickEvent.Payload.Custom) event.payload()).key().toString(), id.toString()); assertEquals(((ClickEvent.Payload.Custom) event.payload()).nbt(), payload.orElseThrow().asString()); } diff --git a/paper-server/src/test/java/io/papermc/paper/block/CraftBlockDataDestroySpeedTest.java b/paper-server/src/test/java/io/papermc/paper/block/CraftBlockDataDestroySpeedTest.java index 32d38205a5a7..e83c38c74898 100644 --- a/paper-server/src/test/java/io/papermc/paper/block/CraftBlockDataDestroySpeedTest.java +++ b/paper-server/src/test/java/io/papermc/paper/block/CraftBlockDataDestroySpeedTest.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import static net.minecraft.resources.ResourceLocation.fromNamespaceAndPath; +import static net.minecraft.resources.Identifier.fromNamespaceAndPath; /** * CraftBlockData's {@link org.bukkit.craftbukkit.block.data.CraftBlockData#getDestroySpeed(ItemStack, boolean)} diff --git a/paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java b/paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java index 01bc3f54a27f..02bb41e1c535 100644 --- a/paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java +++ b/paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java @@ -3,7 +3,7 @@ import com.google.common.collect.Collections2; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.support.RegistryHelper; import org.bukkit.support.environment.AllFeatures; @@ -18,20 +18,20 @@ @AllFeatures public class DataComponentTypesTest { - private static final Set NOT_IN_API = Set.of( - ResourceLocation.parse("custom_data"), - ResourceLocation.parse("entity_data"), - ResourceLocation.parse("bees"), - ResourceLocation.parse("debug_stick_state"), - ResourceLocation.parse("block_entity_data"), - ResourceLocation.parse("bucket_entity_data"), - ResourceLocation.parse("lock"), - ResourceLocation.parse("creative_slot_lock") + private static final Set NOT_IN_API = Set.of( + Identifier.parse("custom_data"), + Identifier.parse("entity_data"), + Identifier.parse("bees"), + Identifier.parse("debug_stick_state"), + Identifier.parse("block_entity_data"), + Identifier.parse("bucket_entity_data"), + Identifier.parse("lock"), + Identifier.parse("creative_slot_lock") ); @Test public void testAllDataComponentsAreMapped() throws IllegalAccessException { - final Set vanillaDataComponentTypes = new ObjectOpenHashSet<>( + final Set vanillaDataComponentTypes = new ObjectOpenHashSet<>( RegistryHelper.getRegistry() .lookupOrThrow(Registries.DATA_COMPONENT_TYPE) .keySet() @@ -47,12 +47,12 @@ public void testAllDataComponentsAreMapped() throws IllegalAccessException { } if (!vanillaDataComponentTypes.containsAll(NOT_IN_API)) { - Assertions.fail("API defined data components that were marked as not-yet-implemented: " + NOT_IN_API.stream().filter(Predicate.not(vanillaDataComponentTypes::contains)).map(ResourceLocation::toString).collect(Collectors.joining(", "))); + Assertions.fail("API defined data components that were marked as not-yet-implemented: " + NOT_IN_API.stream().filter(Predicate.not(vanillaDataComponentTypes::contains)).map(Identifier::toString).collect(Collectors.joining(", "))); } vanillaDataComponentTypes.removeAll(NOT_IN_API); if (!vanillaDataComponentTypes.isEmpty()) { - Assertions.fail("API did not define following vanilla data component types: " + String.join(", ", Collections2.transform(vanillaDataComponentTypes, ResourceLocation::toString))); + Assertions.fail("API did not define following vanilla data component types: " + String.join(", ", Collections2.transform(vanillaDataComponentTypes, Identifier::toString))); } } diff --git a/paper-server/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java b/paper-server/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java index 41c38b1b6d25..fcf52e47c76e 100644 --- a/paper-server/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java +++ b/paper-server/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java @@ -5,7 +5,7 @@ import java.util.stream.Stream; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.support.RegistryHelper; import org.bukkit.support.environment.AllFeatures; import org.checkerframework.checker.nullness.qual.Nullable; @@ -31,7 +31,7 @@ static Stream> data() { @ParameterizedTest @MethodSource("data") void testApiRegistryKeysExist(final RegistryKey key) { - final Optional> registry = RegistryHelper.getRegistry().lookup(ResourceKey.createRegistryKey(ResourceLocation.parse(key.key().asString()))); + final Optional> registry = RegistryHelper.getRegistry().lookup(ResourceKey.createRegistryKey(Identifier.parse(key.key().asString()))); assertTrue(registry.isPresent(), "Missing vanilla registry for " + key.key().asString()); } diff --git a/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java b/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java index d52a10fcbf43..b35d5ef407e3 100644 --- a/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java +++ b/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java @@ -11,7 +11,7 @@ import net.kyori.adventure.key.Key; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.flag.FeatureElement; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; @@ -35,7 +35,7 @@ class FeatureFlagTest { @Test void testFeatureFlagParity() { - final Set locations = new HashSet<>(); + final Set locations = new HashSet<>(); for (final FeatureFlag flag : FeatureFlag.ALL_FLAGS.values()) { locations.add(PaperAdventure.asVanilla(flag.getKey())); } @@ -43,7 +43,7 @@ void testFeatureFlagParity() { fail("Unknown api feature flag: " + unknown); }); - for (final ResourceLocation nmsFlag : allNames()) { + for (final Identifier nmsFlag : allNames()) { assertNotNull(FeatureFlag.ALL_FLAGS.value(Key.key(nmsFlag.toString())), "can't find api flag for " + nmsFlag); } } @@ -53,12 +53,12 @@ void testFeatureFlagConversion() { assertEquals(allNames().size(), PaperFeatureFlagProviderImpl.FLAGS.size()); for (final FeatureFlag featureFlag : PaperFeatureFlagProviderImpl.FLAGS.keySet()) { final net.minecraft.world.flag.FeatureFlag nmsFlag = PaperFeatureFlagProviderImpl.FLAGS.get(featureFlag); - final ResourceLocation nmsFlagName = FeatureFlags.REGISTRY.toNames(FeatureFlagSet.of(nmsFlag)).iterator().next(); + final Identifier nmsFlagName = FeatureFlags.REGISTRY.toNames(FeatureFlagSet.of(nmsFlag)).iterator().next(); assertEquals(nmsFlagName.toString(), featureFlag.key().asString()); } } - static Set allNames() { + static Set allNames() { return FeatureFlags.REGISTRY.toNames(FeatureFlags.REGISTRY.allFlags()); } diff --git a/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java b/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java index cc1fb5ae9e08..ffe15276c054 100644 --- a/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java +++ b/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java @@ -6,7 +6,7 @@ import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.levelgen.structure.BuiltinStructureSets; import net.minecraft.world.level.levelgen.structure.StructureSet; import net.minecraft.world.level.levelgen.structure.placement.StructurePlacement; @@ -36,7 +36,7 @@ public void save(final @NotNull File file) { final Registry structureSets = RegistryHelper.getRegistry().lookupOrThrow(Registries.STRUCTURE_SET); for (final ResourceKey setKey : structureSets.registryKeySet()) { - assertEquals(ResourceLocation.DEFAULT_NAMESPACE, setKey.location().getNamespace()); + assertEquals(Identifier.DEFAULT_NAMESPACE, setKey.location().getNamespace()); final StructureSet set = structureSets.getValueOrThrow(setKey); if (setKey == BuiltinStructureSets.STRONGHOLDS) { // special case due to seed matching world seed assertEquals(0, set.placement().salt); diff --git a/paper-server/src/test/java/org/bukkit/MaterialTest.java b/paper-server/src/test/java/org/bukkit/MaterialTest.java index d57396a9353b..ba6bae7e59a1 100644 --- a/paper-server/src/test/java/org/bukkit/MaterialTest.java +++ b/paper-server/src/test/java/org/bukkit/MaterialTest.java @@ -8,7 +8,7 @@ import java.util.Iterator; import java.util.Map; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.Item; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.craftbukkit.util.CraftNamespacedKey; @@ -21,7 +21,7 @@ public class MaterialTest { @Test public void verifyMapping() { - Map materials = Maps.newHashMap(); + Map materials = Maps.newHashMap(); for (Material material : Material.values()) { if (LegacyHelper.getInvalidatedMaterials().contains(material)) { continue; @@ -36,7 +36,7 @@ public void verifyMapping() { Item item = items.next(); if (item == null) continue; - ResourceLocation id = BuiltInRegistries.ITEM.getKey(item); + Identifier id = BuiltInRegistries.ITEM.getKey(item); String name = item.getDescriptionId(); Material material = materials.remove(id); diff --git a/paper-server/src/test/java/org/bukkit/ParticleTest.java b/paper-server/src/test/java/org/bukkit/ParticleTest.java index 61c7e94fb76c..fd00c0d8a100 100644 --- a/paper-server/src/test/java/org/bukkit/ParticleTest.java +++ b/paper-server/src/test/java/org/bukkit/ParticleTest.java @@ -20,7 +20,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.Tag; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.phys.Vec3; import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.CraftParticle; @@ -46,7 +46,7 @@ public static Stream data() { @ParameterizedTest @MethodSource("data") - public void testBukkitValuesPresent(ResourceLocation minecraft) { + public void testBukkitValuesPresent(Identifier minecraft) { // TODO: 10/19/23 Remove with enum PR, it is then no longer needed, since the enum PR has a extra test for this assertNotNull(Registry.PARTICLE_TYPE.get(CraftNamespacedKey.fromMinecraft(minecraft)), String.format(""" No bukkit particle found for minecraft particle %s. diff --git a/paper-server/src/test/java/org/bukkit/PotionEffectTypeTest.java b/paper-server/src/test/java/org/bukkit/PotionEffectTypeTest.java index 139f2c08acc0..46b31eeec639 100644 --- a/paper-server/src/test/java/org/bukkit/PotionEffectTypeTest.java +++ b/paper-server/src/test/java/org/bukkit/PotionEffectTypeTest.java @@ -7,7 +7,7 @@ import java.util.Collections; import java.util.List; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.effect.MobEffectCategory; import org.bukkit.craftbukkit.potion.CraftPotionEffectTypeCategory; import org.bukkit.craftbukkit.util.CraftNamespacedKey; @@ -23,7 +23,7 @@ public class PotionEffectTypeTest { public void verifyMapping() { List effects = Lists.newArrayList(PotionEffectType.values()); - for (ResourceLocation key : BuiltInRegistries.MOB_EFFECT.keySet()) { + for (Identifier key : BuiltInRegistries.MOB_EFFECT.keySet()) { String name = key.getPath(); PotionEffectType effect = PotionEffectType.getByKey(CraftNamespacedKey.fromMinecraft(key)); diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/profile/PlayerProfileTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/profile/PlayerProfileTest.java index fcf773894fbc..0e35a1c505af 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/profile/PlayerProfileTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/profile/PlayerProfileTest.java @@ -9,7 +9,7 @@ import java.net.URL; import java.util.UUID; import com.mojang.authlib.properties.PropertyMap; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.world.item.component.ResolvableProfile; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; diff --git a/paper-server/src/test/java/org/bukkit/potion/PotionTest.java b/paper-server/src/test/java/org/bukkit/potion/PotionTest.java index 0cfe19d91d82..de7295459fe9 100644 --- a/paper-server/src/test/java/org/bukkit/potion/PotionTest.java +++ b/paper-server/src/test/java/org/bukkit/potion/PotionTest.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Map; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.item.alchemy.Potion; @@ -20,7 +20,7 @@ public class PotionTest { @Test public void testEffectType() { for (MobEffect nms : BuiltInRegistries.MOB_EFFECT) { - ResourceLocation key = BuiltInRegistries.MOB_EFFECT.getKey(nms); + Identifier key = BuiltInRegistries.MOB_EFFECT.getKey(nms); PotionEffectType bukkit = CraftPotionEffectType.minecraftToBukkit(nms); diff --git a/paper-server/src/test/java/org/bukkit/registry/RegistryClassTest.java b/paper-server/src/test/java/org/bukkit/registry/RegistryClassTest.java index c118c911972f..279307c7afc3 100644 --- a/paper-server/src/test/java/org/bukkit/registry/RegistryClassTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/RegistryClassTest.java @@ -25,7 +25,7 @@ import java.util.stream.Stream; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.flag.FeatureElement; import net.minecraft.world.flag.FeatureFlags; import org.bukkit.Bukkit; @@ -492,10 +492,10 @@ public void testMatchingFieldNames(Class type, ResourceKey< @MethodSource("fieldData") public void testMissingConstants(Class type, ResourceKey> registryKey) throws IllegalAccessException { net.minecraft.core.Registry registry = RegistryHelper.getRegistry().lookupOrThrow(registryKey); - List missingKeys = new ArrayList<>(); + List missingKeys = new ArrayList<>(); for (Object nmsObject : registry) { - ResourceLocation minecraftKey = registry.getKey(nmsObject); + Identifier minecraftKey = registry.getKey(nmsObject); try { Field field = type.getField(this.convertToFieldName(minecraftKey.getPath())); diff --git a/paper-server/src/test/java/org/bukkit/registry/RegistryConstantsTest.java b/paper-server/src/test/java/org/bukkit/registry/RegistryConstantsTest.java index 7848c3bb7835..886e52f7f680 100644 --- a/paper-server/src/test/java/org/bukkit/registry/RegistryConstantsTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/RegistryConstantsTest.java @@ -8,7 +8,7 @@ import java.util.Locale; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.Registry; @@ -61,11 +61,11 @@ private void testExcessConstants(Class clazz, org.bukkit.Re } private void testMissingConstants(Class clazz, ResourceKey> nmsRegistryKey) { - List missingKeys = new ArrayList<>(); + List missingKeys = new ArrayList<>(); net.minecraft.core.Registry nmsRegistry = RegistryHelper.getRegistry().lookupOrThrow(nmsRegistryKey); for (M nmsObject : nmsRegistry) { - ResourceLocation minecraftKey = nmsRegistry.getKey(nmsObject); + Identifier minecraftKey = nmsRegistry.getKey(nmsObject); try { @SuppressWarnings("unchecked") diff --git a/paper-server/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java b/paper-server/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java index d548ff4a9656..cffef2022a2a 100644 --- a/paper-server/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java @@ -9,7 +9,7 @@ import net.minecraft.core.MappedRegistry; import net.minecraft.core.RegistrationInfo; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.Registry; @@ -51,11 +51,11 @@ public static Stream data() { public void testRegistryLoadOrder(Supplier init, Class keyedClass, BiFunction minecraftToBukkit, Supplier first, Supplier second) { this.testClassNotLoaded(init.get()); - ResourceKey> resourceKey = ResourceKey.createRegistryKey(ResourceLocation.tryBuild("bukkit", "test-registry")); + ResourceKey> resourceKey = ResourceKey.createRegistryKey(Identifier.tryBuild("bukkit", "test-registry")); MappedRegistry minecraftRegistry = new MappedRegistry<>(resourceKey, Lifecycle.experimental()); - minecraftRegistry.register(ResourceKey.create(resourceKey, ResourceLocation.tryBuild("bukkit", "test-one")), new MinecraftTestType(), new RegistrationInfo(Optional.empty(), Lifecycle.experimental())); - minecraftRegistry.register(ResourceKey.create(resourceKey, ResourceLocation.tryBuild("bukkit", "test-two")), new MinecraftTestType(), new RegistrationInfo(Optional.empty(), Lifecycle.experimental())); + minecraftRegistry.register(ResourceKey.create(resourceKey, Identifier.tryBuild("bukkit", "test-one")), new MinecraftTestType(), new RegistrationInfo(Optional.empty(), Lifecycle.experimental())); + minecraftRegistry.register(ResourceKey.create(resourceKey, Identifier.tryBuild("bukkit", "test-two")), new MinecraftTestType(), new RegistrationInfo(Optional.empty(), Lifecycle.experimental())); minecraftRegistry.freeze(); RegistryLoadOrderTest.registry = new CraftRegistry<>(keyedClass, minecraftRegistry, minecraftToBukkit, (namespacedKey, apiVersion) -> namespacedKey); diff --git a/paper-server/src/test/java/org/bukkit/support/DummyServerHelper.java b/paper-server/src/test/java/org/bukkit/support/DummyServerHelper.java index a2094842c724..ea10b443dfa1 100644 --- a/paper-server/src/test/java/org/bukkit/support/DummyServerHelper.java +++ b/paper-server/src/test/java/org/bukkit/support/DummyServerHelper.java @@ -48,7 +48,7 @@ public static Server setup() { when(instance.getTag(any(), any(), any())).then(mock -> { String registry = mock.getArgument(0); Class clazz = mock.getArgument(2); - net.minecraft.resources.ResourceLocation key = CraftNamespacedKey.toMinecraft(mock.getArgument(1)); // Paper - address remapping issues + net.minecraft.resources.Identifier key = CraftNamespacedKey.toMinecraft(mock.getArgument(1)); // Paper - address remapping issues switch (registry) { case org.bukkit.Tag.REGISTRY_BLOCKS -> { diff --git a/todo-snapshot.txt b/todo-snapshot.txt index dda9d1d602a7..e76c660e9e28 100644 --- a/todo-snapshot.txt +++ b/todo-snapshot.txt @@ -4,4 +4,6 @@ - Connection, ServerConnectionListener - dropped diff for thread pool config (fields gone) - 25w44a: - ShulkerBoxBlock: retainUnlootedShulkerBoxLootTableOnNonPlayerBreak patch no longer applies (getDrops override removed) - - Add back array storage for game rules in GameRuleMap? \ No newline at end of file + - Add back array storage for game rules in GameRuleMap? +- 25w45a: + - PatrolSpawner: Paper start day config is overriding timeline environment attribute From 81723482c4eac31b2a60293e95c3738376dc89c6 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 4 Nov 2025 18:50:35 -0700 Subject: [PATCH 049/112] Fixup a couple of funny diffs --- .../net/minecraft/util/Util.java.patch | 88 +------------------ .../world/entity/EntityType.java.patch | 9 -- 2 files changed, 4 insertions(+), 93 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/util/Util.java.patch b/paper-server/patches/sources/net/minecraft/util/Util.java.patch index 6d881e9e7204..df53cdc99793 100644 --- a/paper-server/patches/sources/net/minecraft/util/Util.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/Util.java.patch @@ -91,10 +91,11 @@ } private static int getMaxThreads() { -@@ -236,6 +_,21 @@ +@@ -235,6 +_,21 @@ + return thread; })); } - ++ + // Paper start - Separate dimension data IO pool + private static TracingExecutor makeExtraIoExecutor(String namePrefix) { + AtomicInteger atomicInteger = new AtomicInteger(1); @@ -109,87 +110,6 @@ + })); + } + // Paper end - Separate dimension data IO pool -+ + public static void throwAsRuntime(Throwable throwable) { throw throwable instanceof RuntimeException ? (RuntimeException)throwable : new RuntimeException(throwable); - } -@@ -302,6 +_,19 @@ - return input -> true; - } - -+ @SafeVarargs -+ public static Predicate allOf(Predicate... predicates) { -+ return input -> { -+ for (Predicate predicate : predicates) { -+ if (!predicate.test(input)) { -+ return false; -+ } -+ } -+ -+ return true; -+ }; -+ } -+ - public static Predicate allOf(Predicate predicate) { - return (Predicate)predicate; - } -@@ -330,19 +_,6 @@ - return input -> predicate1.test(input) && predicate2.test(input) && predicate3.test(input) && predicate4.test(input) && predicate5.test(input); - } - -- @SafeVarargs -- public static Predicate allOf(Predicate... predicates) { -- return input -> { -- for (Predicate predicate : predicates) { -- if (!predicate.test(input)) { -- return false; -- } -- } -- -- return true; -- }; -- } -- - public static Predicate allOf(List> predicates) { - return switch (predicates.size()) { - case 0 -> allOf(); -@@ -373,6 +_,19 @@ - return input -> false; - } - -+ @SafeVarargs -+ public static Predicate anyOf(Predicate... predicates) { -+ return input -> { -+ for (Predicate predicate : predicates) { -+ if (predicate.test(input)) { -+ return true; -+ } -+ } -+ -+ return false; -+ }; -+ } -+ - public static Predicate anyOf(Predicate predicate) { - return (Predicate)predicate; - } -@@ -399,19 +_,6 @@ - Predicate predicate5 - ) { - return input -> predicate1.test(input) || predicate2.test(input) || predicate3.test(input) || predicate4.test(input) || predicate5.test(input); -- } -- -- @SafeVarargs -- public static Predicate anyOf(Predicate... predicates) { -- return input -> { -- for (Predicate predicate : predicates) { -- if (predicate.test(input)) { -- return true; -- } -- } -- -- return false; -- }; - } - - public static Predicate anyOf(List> predicates) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch index 6d33b22d614d..018611242bd6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch @@ -1,14 +1,5 @@ --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -186,6 +_,8 @@ - import net.minecraft.world.phys.shapes.VoxelShape; - import org.jspecify.annotations.Nullable; - import org.slf4j.Logger; -+import net.minecraft.util.Util; -+import net.minecraft.resources.Identifier; - - public class EntityType implements FeatureElement, EntityTypeTest { - private static final Logger LOGGER = LogUtils.getLogger(); @@ -1289,6 +_,22 @@ boolean shouldOffsetY, boolean shouldOffsetYMore From b0be66c13a4f7acefe1b630e5b6baa79142db80a Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 4 Nov 2025 19:24:10 -0700 Subject: [PATCH 050/112] last 3 compile fixes --- paper-api/src/main/java/org/bukkit/World.java | 2 ++ .../server/level/ServerPlayer.java.patch | 18 ++++++++++++++++++ .../craftbukkit/CraftRegionAccessor.java | 2 +- .../org/bukkit/craftbukkit/CraftWorld.java | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index d1e47051bd8f..26b576bc2470 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -2799,7 +2799,9 @@ default double getHumidity(int x, int z) { * zombified piglins. * * @return true if world is natural + * @deprecated replaced by the gameplay/eyeblossom_open and gameplay/creaking_active environment attributes */ + @Deprecated(since = "1.21.11") public boolean isNatural(); /** diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index 53b3ba38b8c7..f403367301ea 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -1489,6 +1489,24 @@ return itemEntity; } +@@ -2035,7 +_,7 @@ + super.updateUsingItem(usingItem); + } + +- public void drop(boolean flag) { ++ public boolean drop(boolean flag) { // Paper - add back success return + Inventory inventory = this.getInventory(); + ItemStack itemStack = inventory.removeFromSelected(flag); + this.containerMenu +@@ -2045,7 +_,7 @@ + this.stopUsingItem(); + } + +- this.drop(itemStack, false, true); ++ return this.drop(itemStack, false, true) != null; // Paper - add back success return + } + + @Override @@ -2108,9 +_,9 @@ } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java index 9b010b57c04b..21d594a39d09 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java @@ -466,7 +466,7 @@ public net.minecraft.world.entity.Entity createEntity(Location location, Class Date: Tue, 4 Nov 2025 19:30:24 -0700 Subject: [PATCH 051/112] Run & update generators --- .../paper/registry/keys/DataComponentTypeKeys.java | 7 +++++++ .../papermc/paper/registry/keys/ItemTypeKeys.java | 7 +++++++ .../paper/registry/keys/tags/BiomeTagKeys.java | 14 +++++++------- paper-api/src/main/java/org/bukkit/Material.java | 1 + .../main/java/io/papermc/generator/Generators.java | 2 +- .../src/main/java/io/papermc/generator/Main.java | 6 +++--- .../main/java/io/papermc/generator/Rewriters.java | 5 +++-- .../types/registry/EnumRegistryRewriter.java | 4 ++-- .../types/registry/FeatureFlagRewriter.java | 8 ++++---- .../types/registry/PaperFeatureFlagMapping.java | 6 +++--- .../types/registry/PaperRegistriesRewriter.java | 2 +- .../types/registry/RegistryFieldRewriter.java | 4 ++-- .../types/simple/CraftBlockEntityStateMapping.java | 4 ++-- .../types/simple/CraftPotionUtilRewriter.java | 4 ++-- .../rewriter/types/simple/EntityTypeRewriter.java | 8 ++++---- .../rewriter/types/simple/MaterialRewriter.java | 4 ++-- .../rewriter/types/simple/MemoryKeyRewriter.java | 2 +- .../rewriter/types/simple/StatisticRewriter.java | 14 +++++++------- .../papermc/generator/types/goal/MobGoalNames.java | 2 +- .../generator/types/registry/GeneratedKeyType.java | 6 +++--- .../types/registry/GeneratedTagKeyType.java | 2 +- .../generator/utils/BlockEntityMapping.java | 2 +- .../io/papermc/generator/utils/Formatting.java | 2 +- .../generator/utils/experimental/FlagHolders.java | 2 +- .../utils/experimental/SingleFlagHolder.java | 6 +++--- .../papermc/generator/RegistryMigrationTest.java | 4 ++-- 26 files changed, 72 insertions(+), 56 deletions(-) diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java index e082492f24ed..32e5909fc79a 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java @@ -739,6 +739,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey WRITTEN_BOOK_CONTENT = create(key("written_book_content")); + /** + * {@code minecraft:zombie_nautilus/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ZOMBIE_NAUTILUS_VARIANT = create(key("zombie_nautilus/variant")); + private DataComponentTypeKeys() { } diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java index 23d8214609d3..33b92219df8b 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java @@ -6136,6 +6136,13 @@ public final class ItemTypeKeys { */ public static final TypedKey NETHERITE_HOE = create(key("netherite_hoe")); + /** + * {@code minecraft:netherite_horse_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey NETHERITE_HORSE_ARMOR = create(key("netherite_horse_armor")); + /** * {@code minecraft:netherite_ingot} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java index 07cb23cc2bc1..4d508a667878 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java @@ -431,6 +431,13 @@ public final class BiomeTagKeys { */ public static final TagKey SPAWNS_COLD_VARIANT_FROGS = create(key("spawns_cold_variant_frogs")); + /** + * {@code #minecraft:spawns_coral_variant_zombie_nautilus} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SPAWNS_CORAL_VARIANT_ZOMBIE_NAUTILUS = create(key("spawns_coral_variant_zombie_nautilus")); + /** * {@code #minecraft:spawns_gold_rabbits} * @@ -480,13 +487,6 @@ public final class BiomeTagKeys { */ public static final TagKey WATER_ON_MAP_OUTLINES = create(key("water_on_map_outlines")); - /** - * {@code #minecraft:without_patrol_spawns} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TagKey WITHOUT_PATROL_SPAWNS = create(key("without_patrol_spawns")); - /** * {@code #minecraft:without_wandering_trader_spawns} * diff --git a/paper-api/src/main/java/org/bukkit/Material.java b/paper-api/src/main/java/org/bukkit/Material.java index 8868459a28fa..24acfb4f89a1 100644 --- a/paper-api/src/main/java/org/bukkit/Material.java +++ b/paper-api/src/main/java/org/bukkit/Material.java @@ -463,6 +463,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla NETHERITE_CHESTPLATE(-1, 1), NETHERITE_HELMET(-1, 1), NETHERITE_HOE(-1, 1), + NETHERITE_HORSE_ARMOR(-1, 1), NETHERITE_INGOT(-1), NETHERITE_LEGGINGS(-1, 1), NETHERITE_NAUTILUS_ARMOR(-1, 1), diff --git a/paper-generator/src/main/java/io/papermc/generator/Generators.java b/paper-generator/src/main/java/io/papermc/generator/Generators.java index ae7353b5b400..a2152b4a3423 100644 --- a/paper-generator/src/main/java/io/papermc/generator/Generators.java +++ b/paper-generator/src/main/java/io/papermc/generator/Generators.java @@ -7,7 +7,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import net.minecraft.Util; +import net.minecraft.util.Util; import org.jspecify.annotations.NullMarked; @NullMarked diff --git a/paper-generator/src/main/java/io/papermc/generator/Main.java b/paper-generator/src/main/java/io/papermc/generator/Main.java index fd9cb7216329..3a1ab1537111 100644 --- a/paper-generator/src/main/java/io/papermc/generator/Main.java +++ b/paper-generator/src/main/java/io/papermc/generator/Main.java @@ -17,14 +17,14 @@ import java.util.function.Consumer; import java.util.stream.Stream; import net.minecraft.SharedConstants; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.commands.Commands; import net.minecraft.core.HolderLookup; import net.minecraft.core.LayeredRegistryAccess; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.RegistryDataLoader; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.Bootstrap; import net.minecraft.server.MinecraftServer; import net.minecraft.server.RegistryLayer; @@ -79,7 +79,7 @@ public static CompletableFuture bootStrap(boolean withTags) { PackRepository packRepository = ServerPacksSource.createVanillaTrustedRepository(); FeatureFlagSet flags = FeatureFlags.REGISTRY.allFlags(); - MinecraftServer.configurePackRepository(packRepository, new WorldDataConfiguration(new DataPackConfig(FeatureFlags.REGISTRY.toNames(flags).stream().map(ResourceLocation::getPath).toList(), List.of()), flags), true, false); + MinecraftServer.configurePackRepository(packRepository, new WorldDataConfiguration(new DataPackConfig(FeatureFlags.REGISTRY.toNames(flags).stream().map(Identifier::getPath).toList(), List.of()), flags), true, false); CloseableResourceManager resourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, packRepository.openAllSelected()); LayeredRegistryAccess layers = RegistryLayer.createRegistryAccess(); diff --git a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java index 410cd1e6b426..1058ce045f29 100644 --- a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java +++ b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java @@ -38,6 +38,7 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.contents.TranslatableContents; import net.minecraft.server.level.ParticleStatus; import net.minecraft.sounds.SoundSource; import net.minecraft.world.entity.Mob; @@ -145,13 +146,13 @@ protected EnumValue.Builder rewriteEnumValue(net.minecraft.world.entity.animal.P holder("ChatVisibility", ClientOption.ChatVisibility.class, new EnumCloneRewriter<>(ChatVisiblity.class) { @Override protected EnumValue.Builder rewriteEnumValue(ChatVisiblity visibility) { - return super.rewriteEnumValue(visibility).argument(quoted(visibility.getKey())); + return super.rewriteEnumValue(visibility).argument(quoted(((TranslatableContents) visibility.caption().getContents()).getKey())); } }.reachEnd(false)), holder("ParticleVisibility", ClientOption.ParticleVisibility.class, new EnumCloneRewriter<>(ParticleStatus.class) { @Override protected EnumValue.Builder rewriteEnumValue(ParticleStatus status) { - return super.rewriteEnumValue(status).argument(quoted(status.getKey())); + return super.rewriteEnumValue(status).argument(quoted(((TranslatableContents) status.caption().getContents()).getKey())); } }) )) diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/EnumRegistryRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/EnumRegistryRewriter.java index b2ab2aac1d90..3b114d5f198a 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/EnumRegistryRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/EnumRegistryRewriter.java @@ -48,9 +48,9 @@ protected Iterable> getValues() { @Override protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { - EnumValue.Builder value = EnumValue.builder(Formatting.formatKeyAsField(reference.key().location().getPath())); + EnumValue.Builder value = EnumValue.builder(Formatting.formatKeyAsField(reference.key().identifier().getPath())); if (this.hasKeyArgument) { - value.argument(quoted(reference.key().location().getPath())); + value.argument(quoted(reference.key().identifier().getPath())); } return value; } diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/FeatureFlagRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/FeatureFlagRewriter.java index ede08c4a00fa..8447a56bebd8 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/FeatureFlagRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/FeatureFlagRewriter.java @@ -7,7 +7,7 @@ import io.papermc.typewriter.replace.SearchReplaceRewriter; import java.util.Iterator; import java.util.Map; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.flag.FeatureFlag; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; @@ -37,10 +37,10 @@ public boolean registerFor(SourceFile file) { @Override protected void insert(SearchMetadata metadata, StringBuilder builder) { - Iterator> flagIterator = FeatureFlags.REGISTRY.names.entrySet().stream().sorted(Formatting.alphabeticKeyOrder(entry -> entry.getKey().getPath())).iterator(); + Iterator> flagIterator = FeatureFlags.REGISTRY.names.entrySet().stream().sorted(Formatting.alphabeticKeyOrder(entry -> entry.getKey().getPath())).iterator(); while (flagIterator.hasNext()) { - Map.Entry entry = flagIterator.next(); - ResourceLocation name = entry.getKey(); + Map.Entry entry = flagIterator.next(); + Identifier name = entry.getKey(); if (FeatureFlags.isExperimental(FeatureFlagSet.of(entry.getValue()))) { builder.append(metadata.indent()).append(annotation(ApiStatus.Experimental.class, this.importCollector)).append('\n'); } diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperFeatureFlagMapping.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperFeatureFlagMapping.java index 06287f65a0c8..8f21f8306b6e 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperFeatureFlagMapping.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperFeatureFlagMapping.java @@ -4,7 +4,7 @@ import io.papermc.typewriter.replace.SearchMetadata; import io.papermc.typewriter.replace.SearchReplaceRewriter; import java.util.Iterator; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.flag.FeatureFlags; import org.bukkit.FeatureFlag; import org.jspecify.annotations.NullMarked; @@ -14,10 +14,10 @@ public class PaperFeatureFlagMapping extends SearchReplaceRewriter { @Override protected void insert(SearchMetadata metadata, StringBuilder builder) { - Iterator flagIterator = FeatureFlags.REGISTRY.toNames(FeatureFlags.REGISTRY.allFlags()).stream().sorted(Formatting.alphabeticKeyOrder(ResourceLocation::getPath)).iterator(); + Iterator flagIterator = FeatureFlags.REGISTRY.toNames(FeatureFlags.REGISTRY.allFlags()).stream().sorted(Formatting.alphabeticKeyOrder(Identifier::getPath)).iterator(); while (flagIterator.hasNext()) { - ResourceLocation name = flagIterator.next(); + Identifier name = flagIterator.next(); String keyedName = Formatting.formatKeyAsField(name.getPath()); builder.append(metadata.indent()); builder.append("%s.%s, %s.%s".formatted(FeatureFlag.class.getSimpleName(), keyedName, FeatureFlags.class.getSimpleName(), keyedName)); diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperRegistriesRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperRegistriesRewriter.java index 599356eba752..0ebef90e86ef 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperRegistriesRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperRegistriesRewriter.java @@ -30,7 +30,7 @@ private void appendEntry(String indent, StringBuilder builder, RegistryEntry if (apiOnly) { builder.append("apiOnly("); if (entry.apiClass().isEnum()) { - builder.append(this.importCollector.getShortName(Types.PAPER_SIMPLE_REGISTRY)).append("::").append(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, entry.registryKey().location().getPath())); + builder.append(this.importCollector.getShortName(Types.PAPER_SIMPLE_REGISTRY)).append("::").append(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, entry.registryKey().identifier().getPath())); } else { builder.append("() -> "); builder.append(Registry.class.getCanonicalName()).append('.').append(entry.apiRegistryField().orElse(entry.registryKeyField())); diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java index 5f5b98238c77..cff345a48c2f 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java @@ -120,11 +120,11 @@ protected String rewriteFieldType(Holder.Reference reference) { } protected String rewriteFieldName(Holder.Reference reference) { - return Formatting.formatKeyAsField(reference.key().location().getPath()); + return Formatting.formatKeyAsField(reference.key().identifier().getPath()); } protected String rewriteFieldValue(Holder.Reference reference) { - return "%s(%s)".formatted(this.fetchMethod, quoted(reference.key().location().getPath())); + return "%s(%s)".formatted(this.fetchMethod, quoted(reference.key().identifier().getPath())); } protected @Nullable SingleFlagHolder getRequiredFeature(Holder.Reference reference) { diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockEntityStateMapping.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockEntityStateMapping.java index 2fd4d0c69fdd..4b3f2abf9b4e 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockEntityStateMapping.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockEntityStateMapping.java @@ -10,10 +10,10 @@ public class CraftBlockEntityStateMapping extends SearchReplaceRewriter { @Override protected void insert(SearchMetadata metadata, StringBuilder builder) { - BlockEntityMapping.MAPPING.entrySet().stream().sorted(Formatting.alphabeticKeyOrder(entry -> entry.getKey().location().getPath())).forEach(entry -> { + BlockEntityMapping.MAPPING.entrySet().stream().sorted(Formatting.alphabeticKeyOrder(entry -> entry.getKey().identifier().getPath())).forEach(entry -> { builder.append(metadata.indent()); builder.append("register(%s.%s, %s.class, %s::new);".formatted( - BlockEntityType.class.getSimpleName(), Formatting.formatKeyAsField(entry.getKey().location().getPath()), + BlockEntityType.class.getSimpleName(), Formatting.formatKeyAsField(entry.getKey().identifier().getPath()), entry.getValue(), entry.getValue())); builder.append('\n'); }); diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftPotionUtilRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftPotionUtilRewriter.java index df57fadbc810..08e8a84de610 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftPotionUtilRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftPotionUtilRewriter.java @@ -5,7 +5,7 @@ import io.papermc.typewriter.replace.SearchReplaceRewriter; import java.util.Locale; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.potion.PotionType; @Deprecated(forRemoval = true) @@ -22,7 +22,7 @@ protected void insert(SearchMetadata metadata, StringBuilder builder) { String upperStatePrefix = this.statePrefix.toUpperCase(Locale.ENGLISH); BuiltInRegistries.POTION.keySet().stream() .filter(key -> BuiltInRegistries.POTION.containsKey(key.withPath(path -> this.statePrefix + "_" + path))) - .sorted(Formatting.alphabeticKeyOrder(ResourceLocation::getPath)).forEach(key -> { + .sorted(Formatting.alphabeticKeyOrder(Identifier::getPath)).forEach(key -> { String keyedName = Formatting.formatKeyAsField(key.getPath()); builder.append(metadata.indent()); builder.append(".put(%s.%s, %s.%s_%s)".formatted(PotionType.class.getSimpleName(), keyedName, PotionType.class.getSimpleName(), upperStatePrefix, keyedName)); diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/EntityTypeRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/EntityTypeRewriter.java index dd4994fd369d..3b8785d64dee 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/EntityTypeRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/EntityTypeRewriter.java @@ -15,7 +15,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; @@ -150,7 +150,7 @@ public EntityTypeRewriter() { @Override protected EnumValue.Builder rewriteEnumValue(Holder.Reference> reference) { - String path = reference.key().location().getPath(); + String path = reference.key().identifier().getPath(); List arguments = new ArrayList<>(4); arguments.add(quoted(path)); arguments.add(toBukkitClass(reference).concat(".class")); @@ -168,9 +168,9 @@ private String toBukkitClass(Holder.Reference> reference) { return this.importCollector.getShortName(MobGoalNames.BUKKIT_BRIDGE.get((Class) internalClass)); } - String className = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, reference.key().location().getPath()); // use the key instead of the internal class name since name match a bit more + String className = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, reference.key().identifier().getPath()); // use the key instead of the internal class name since name match a bit more ClassNamed resolvedClass = this.classNamedView.tryFindFirst(CLASS_RENAMES.getOrDefault(className, className)) - .orElseThrow(() -> new IllegalStateException("Could not find entity class for " + reference.key().location())) + .orElseThrow(() -> new IllegalStateException("Could not find entity class for " + reference.key().identifier())) .resolve(runtime); Preconditions.checkArgument(org.bukkit.entity.Entity.class.isAssignableFrom(resolvedClass.knownClass()), "Generic type must be an entity"); return this.importCollector.getShortName(this.classNamedView.findFirst(CLASS_RENAMES.getOrDefault(className, className)).resolve(runtime)); diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MaterialRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MaterialRewriter.java index 764fa4a50623..98b079f4d057 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MaterialRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MaterialRewriter.java @@ -39,7 +39,7 @@ protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) if (BlockStateMapping.MAPPING.containsKey(block.getClass())) { // some block can also be represented as item in that enum // doing a double job - Optional equivalentItem = BuiltInRegistries.ITEM.getOptional(reference.key().location()); + Optional equivalentItem = BuiltInRegistries.ITEM.getOptional(reference.key().identifier()); if (equivalentItem.isEmpty() && block instanceof WallSignBlock) { // wall sign block stack size is 16 for some reason like the sign item? @@ -84,7 +84,7 @@ public Items() { @Override protected Iterable> getValues() { - return BuiltInRegistries.ITEM.listElements().filter(reference -> BuiltInRegistries.BLOCK.getOptional(reference.key().location()).isEmpty() || reference.value().equals(net.minecraft.world.item.Items.AIR)) + return BuiltInRegistries.ITEM.listElements().filter(reference -> BuiltInRegistries.BLOCK.getOptional(reference.key().identifier()).isEmpty() || reference.value().equals(net.minecraft.world.item.Items.AIR)) .sorted(Formatting.HOLDER_ORDER)::iterator; } diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java index 92e20b37509c..dad0cefa24b0 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java @@ -109,7 +109,7 @@ protected String rewriteFieldValue(Holder.Reference> referen return "new %s<>(%s.minecraft(%s), %s.class)".formatted( this.registryEntry.apiClass().getSimpleName(), NamespacedKey.class.getSimpleName(), - quoted(reference.key().location().getPath()), + quoted(reference.key().identifier().getPath()), this.apiMemoryType.getSimpleName() // assume the type is already import (see above in rewriteFieldType) ); } diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/StatisticRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/StatisticRewriter.java index f082536d4668..fa2b6d42a38c 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/StatisticRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/StatisticRewriter.java @@ -9,7 +9,7 @@ import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.stats.StatType; import net.minecraft.stats.Stats; import net.minecraft.world.entity.EntityType; @@ -57,19 +57,19 @@ public class StatisticRewriter { .put("OPEN_SHULKER_BOX", "SHULKER_BOX_OPENED") .buildOrThrow(); - public static class Custom extends EnumRegistryRewriter { + public static class Custom extends EnumRegistryRewriter { public Custom() { super(Registries.CUSTOM_STAT, false); } @Override - protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { + protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { return super.rewriteEnumValue(reference).rename(name -> FIELD_RENAMES.getOrDefault(name, name)); } } - public static class CraftCustom extends EnumRegistryRewriter { + public static class CraftCustom extends EnumRegistryRewriter { private static final Map INTERNAL_FIELD_RENAMES = Map.of( "SNEAK_TIME", "CROUCH_TIME" @@ -80,8 +80,8 @@ public CraftCustom() { } @Override - protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { - String keyedName = Formatting.formatKeyAsField(reference.key().location().getPath()); + protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { + String keyedName = Formatting.formatKeyAsField(reference.key().identifier().getPath()); return super.rewriteEnumValue(reference) .rename(name -> FIELD_RENAMES.getOrDefault(name, name)) @@ -137,7 +137,7 @@ protected Iterable>> getValues() { protected EnumValue.Builder rewriteEnumValue(Holder.Reference> reference) { return super.rewriteEnumValue(reference) .rename(name -> FIELD_RENAMES.getOrDefault(name, name)) - .argument("%s.withDefaultNamespace(%s)".formatted(ResourceLocation.class.getSimpleName(), quoted(reference.key().location().getPath()))); + .argument("%s.withDefaultNamespace(%s)".formatted(Identifier.class.getSimpleName(), quoted(reference.key().identifier().getPath()))); } } } diff --git a/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java b/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java index 67b48abb69e4..257c98c4a932 100644 --- a/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java @@ -15,7 +15,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.monster.RangedAttackMob; import org.apache.commons.lang3.math.NumberUtils; diff --git a/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java index cca0056ad4e4..ba6301cecf10 100644 --- a/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java @@ -64,7 +64,7 @@ private MethodSpec.Builder createMethod(TypeName returnType) { .addCode("return $T.create($T.$L, $N);", TypedKey.class, RegistryKey.class, this.entry.registryKeyField(), keyParam) .returns(returnType); if (publicCreateKeyMethod) { - create.addJavadoc(Javadocs.CREATE_TYPED_KEY_JAVADOC, this.entry.apiClass(), this.entry.registryKey().location().toString()); + create.addJavadoc(Javadocs.CREATE_TYPED_KEY_JAVADOC, this.entry.apiClass(), this.entry.registryKey().identifier().toString()); } return create; } @@ -100,7 +100,7 @@ protected TypeSpec getTypeSpec() { boolean allExperimental = true; for (Holder.Reference reference : this.entry.registry().listElements().sorted(Formatting.HOLDER_ORDER).toList()) { ResourceKey key = reference.key(); - String keyPath = key.location().getPath(); + String keyPath = key.identifier().getPath(); String fieldName = Formatting.formatKeyAsField(keyPath); if (!SourceVersion.isIdentifier(fieldName) && this.entry.getFieldNames().containsKey(key)) { fieldName = this.entry.getFieldNames().get(key); @@ -108,7 +108,7 @@ protected TypeSpec getTypeSpec() { FieldSpec.Builder fieldBuilder = FieldSpec.builder(typedKeyType, fieldName, PUBLIC, STATIC, FINAL) .initializer("$N(key($S))", createMethod.build(), keyPath) - .addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), key.location().toString()); + .addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), key.identifier().toString()); SingleFlagHolder requiredFeature = this.getRequiredFeature(reference); if (requiredFeature != null) { diff --git a/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedTagKeyType.java b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedTagKeyType.java index 10bef7f38de6..1d8810710c81 100644 --- a/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedTagKeyType.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedTagKeyType.java @@ -50,7 +50,7 @@ private MethodSpec.Builder createMethod(TypeName returnType) { .addCode("return $T.create($T.$L, $N);", TagKey.class, RegistryKey.class, this.entry.registryKeyField(), keyParam) .returns(returnType); if (publicCreateKeyMethod) { - create.addJavadoc(Javadocs.CREATED_TAG_KEY_JAVADOC, this.entry.apiClass(), this.entry.registryKey().location().toString()); + create.addJavadoc(Javadocs.CREATED_TAG_KEY_JAVADOC, this.entry.apiClass(), this.entry.registryKey().identifier().toString()); } return create; } diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/BlockEntityMapping.java b/paper-generator/src/main/java/io/papermc/generator/utils/BlockEntityMapping.java index d8d7d0f56ab9..7637c8cf866b 100644 --- a/paper-generator/src/main/java/io/papermc/generator/utils/BlockEntityMapping.java +++ b/paper-generator/src/main/java/io/papermc/generator/utils/BlockEntityMapping.java @@ -26,7 +26,7 @@ public final class BlockEntityMapping { static { Map>, String> mapping = new IdentityHashMap<>(); BuiltInRegistries.BLOCK_ENTITY_TYPE.registryKeySet().forEach(key -> { - String name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, key.location().getPath()); + String name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, key.identifier().getPath()); String implName = "Craft".concat(name); mapping.put(key, RENAMES.getOrDefault(implName, implName)); diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/Formatting.java b/paper-generator/src/main/java/io/papermc/generator/utils/Formatting.java index 7009304f573d..4178e5c83053 100644 --- a/paper-generator/src/main/java/io/papermc/generator/utils/Formatting.java +++ b/paper-generator/src/main/java/io/papermc/generator/utils/Formatting.java @@ -75,7 +75,7 @@ public static String stripWordOfCamelCaseName(String name, String word, boolean return newName; } - public static final Comparator> HOLDER_ORDER = alphabeticKeyOrder(reference -> reference.key().location().getPath()); + public static final Comparator> HOLDER_ORDER = alphabeticKeyOrder(reference -> reference.key().identifier().getPath()); public static final Comparator> TAG_ORDER = alphabeticKeyOrder(tagKey -> tagKey.location().getPath()); public static Comparator alphabeticKeyOrder(Function pathConverter) { diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolders.java b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolders.java index 1472ebb5949b..41da83548651 100644 --- a/paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolders.java +++ b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolders.java @@ -3,7 +3,7 @@ import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.world.flag.FeatureFlag; import net.minecraft.world.flag.FeatureFlags; import org.bukkit.MinecraftExperimental; diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/experimental/SingleFlagHolder.java b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/SingleFlagHolder.java index 497805310fe1..9312547b4609 100644 --- a/paper-generator/src/main/java/io/papermc/generator/utils/experimental/SingleFlagHolder.java +++ b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/SingleFlagHolder.java @@ -4,7 +4,7 @@ import com.google.common.collect.HashBiMap; import java.util.HashMap; import java.util.Map; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.flag.FeatureFlag; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; @@ -15,7 +15,7 @@ public record SingleFlagHolder(FeatureFlag flag) implements FlagHolder { // todo support multiple flags? private static final Map FEATURE_FLAG_CACHE = new HashMap<>(); - private static final Map FEATURE_FLAG_NAME = HashBiMap.create(FeatureFlags.REGISTRY.names).inverse(); + private static final Map FEATURE_FLAG_NAME = HashBiMap.create(FeatureFlags.REGISTRY.names).inverse(); static SingleFlagHolder fromValue(FeatureFlag flag) { return new SingleFlagHolder(flag); @@ -35,7 +35,7 @@ public static SingleFlagHolder fromSet(FeatureFlagSet standaloneSet) { public static SingleFlagHolder fromName(String name) { return fromValue(FEATURE_FLAG_CACHE.computeIfAbsent(name, key -> { - return FeatureFlags.REGISTRY.names.get(ResourceLocation.withDefaultNamespace(key)); + return FeatureFlags.REGISTRY.names.get(Identifier.withDefaultNamespace(key)); })); } diff --git a/paper-generator/src/test/java/io/papermc/generator/RegistryMigrationTest.java b/paper-generator/src/test/java/io/papermc/generator/RegistryMigrationTest.java index 61a2648438e9..defb55285dc5 100644 --- a/paper-generator/src/test/java/io/papermc/generator/RegistryMigrationTest.java +++ b/paper-generator/src/test/java/io/papermc/generator/RegistryMigrationTest.java @@ -27,7 +27,7 @@ public void testBuiltInToDataDriven() { Set migratedRegistries = new HashSet<>(); for (RegistryEntry entry : RegistryEntries.BUILT_IN) { ResourceKey> key = entry.registryKey(); - if (!BuiltInRegistries.REGISTRY.containsKey(key.location())) { + if (!BuiltInRegistries.REGISTRY.containsKey(key.identifier())) { migratedRegistries.add(key.toString()); } } @@ -40,7 +40,7 @@ public void testDataDrivenToBuiltIn() { // shouldn't really happen but just in c Set migratedRegistries = new HashSet<>(); for (RegistryEntry entry : RegistryEntries.DATA_DRIVEN) { ResourceKey> key = entry.registryKey(); - if (BuiltInRegistries.REGISTRY.containsKey(key.location())) { + if (BuiltInRegistries.REGISTRY.containsKey(key.identifier())) { migratedRegistries.add(key.toString()); } } From 5554667fc0691b33850a6dc90a979cab756e2ab4 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 4 Nov 2025 19:33:18 -0700 Subject: [PATCH 052/112] Some test fixes --- .../test/java/io/papermc/paper/world/TranslationKeyTest.java | 4 ++-- .../paper/world/structure/StructureSeedConfigTest.java | 4 ++-- .../test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java b/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java index e3b925824782..0fc19c8da251 100644 --- a/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java +++ b/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java @@ -58,8 +58,8 @@ public void testGameMode() { @Test public void testBiome() { for (Map.Entry, Biome> nms : RegistryHelper.getBiomes().entrySet()) { - org.bukkit.block.Biome bukkit = org.bukkit.block.Biome.valueOf(nms.getKey().location().getPath().toUpperCase(Locale.ROOT)); - Assertions.assertEquals(nms.getKey().location().toLanguageKey("biome"), bukkit.translationKey(), "translation key mismatch for " + bukkit); + org.bukkit.block.Biome bukkit = org.bukkit.block.Biome.valueOf(nms.getKey().identifier().getPath().toUpperCase(Locale.ROOT)); + Assertions.assertEquals(nms.getKey().identifier().toLanguageKey("biome"), bukkit.translationKey(), "translation key mismatch for " + bukkit); } } } diff --git a/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java b/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java index ffe15276c054..a6493b17607d 100644 --- a/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java +++ b/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java @@ -36,13 +36,13 @@ public void save(final @NotNull File file) { final Registry structureSets = RegistryHelper.getRegistry().lookupOrThrow(Registries.STRUCTURE_SET); for (final ResourceKey setKey : structureSets.registryKeySet()) { - assertEquals(Identifier.DEFAULT_NAMESPACE, setKey.location().getNamespace()); + assertEquals(Identifier.DEFAULT_NAMESPACE, setKey.identifier().getNamespace()); final StructureSet set = structureSets.getValueOrThrow(setKey); if (setKey == BuiltinStructureSets.STRONGHOLDS) { // special case due to seed matching world seed assertEquals(0, set.placement().salt); continue; } - int salt = switch (setKey.location().getPath()) { + int salt = switch (setKey.identifier().getPath()) { case "villages" -> config.villageSeed; case "desert_pyramids" -> config.desertSeed; case "igloos" -> config.iglooSeed; diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java index 002ce32b2020..c6e5e2506b46 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java @@ -155,7 +155,7 @@ public class LegacyTest { Material.WEATHERED_COPPER_CHEST, Material.WEATHERED_COPPER_GOLEM_STATUE, Material.WEATHERED_COPPER_LANTERN, Material.WEATHERED_LIGHTNING_ROD, // 1.21.11 Material.COPPER_NAUTILUS_ARMOR, Material.COPPER_SPEAR, Material.DIAMOND_NAUTILUS_ARMOR, Material.DIAMOND_SPEAR, Material.GOLDEN_NAUTILUS_ARMOR, Material.GOLDEN_SPEAR, Material.IRON_NAUTILUS_ARMOR, Material.IRON_SPEAR, Material.NAUTILUS_SPAWN_EGG, - Material.NETHERITE_NAUTILUS_ARMOR, Material.NETHERITE_SPEAR, Material.STONE_SPEAR, Material.WOODEN_SPEAR, Material.ZOMBIE_NAUTILUS_SPAWN_EGG, Material.CAMEL_HUSK_SPAWN_EGG, Material.PARCHED_SPAWN_EGG, + Material.NETHERITE_NAUTILUS_ARMOR, Material.NETHERITE_SPEAR, Material.STONE_SPEAR, Material.WOODEN_SPEAR, Material.ZOMBIE_NAUTILUS_SPAWN_EGG, Material.CAMEL_HUSK_SPAWN_EGG, Material.PARCHED_SPAWN_EGG, Material.NETHERITE_HORSE_ARMOR, // Material.LEGACY_AIR, Material.LEGACY_DEAD_BUSH, Material.LEGACY_BURNING_FURNACE, Material.LEGACY_WALL_SIGN, Material.LEGACY_REDSTONE_TORCH_OFF, Material.LEGACY_SKULL, Material.LEGACY_REDSTONE_COMPARATOR_ON, Material.LEGACY_WALL_BANNER, Material.LEGACY_MONSTER_EGG)); From d1682d9e98a4de2ce1dced8e34f17ef437683fbb Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Wed, 5 Nov 2025 12:27:53 -0700 Subject: [PATCH 053/112] Update mache --- paper-server/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index e0a3b241b0d9..f6af0780d388 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:25w45a+build.5") + mache("io.papermc:mache:25w45a+build.6") paperclip("io.papermc:paperclip:3.0.3") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } From 5b0f2a9b957e233a1406d38660abefb21cfaecb6 Mon Sep 17 00:00:00 2001 From: Pedro <3602279+Doc94@users.noreply.github.com> Date: Wed, 5 Nov 2025 17:17:45 -0300 Subject: [PATCH 054/112] Update horse armor material tag (#13277) --- .../src/main/java/com/destroystokyo/paper/MaterialTags.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java b/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java index e9ff88d50482..96e92f3760ef 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java @@ -202,7 +202,7 @@ private static MaterialSetTag replacedBy(Tag vanillaTag, String legacy */ public static final MaterialSetTag HORSE_ARMORS = new MaterialSetTag(keyFor("horse_armors")) .endsWith("_HORSE_ARMOR") - .ensureSize("HORSE_ARMORS", 5).lock(); + .ensureSize("HORSE_ARMORS", 6).lock(); /** * Covers the variants of infested blocks. From 8c580b1ee0684a3e8742ecfbe9554d0e000a5fb8 Mon Sep 17 00:00:00 2001 From: Pedro <3602279+Doc94@users.noreply.github.com> Date: Thu, 6 Nov 2025 01:04:22 -0300 Subject: [PATCH 055/112] Add ZombieNautilus.Variant (#13278) --- .../keys/ZombieNautilusVariantKeys.java | 54 +++++++++++++ .../datacomponent/DataComponentTypes.java | 2 + .../papermc/paper/registry/RegistryKey.java | 6 ++ .../ZombieNautilusVariantRegistryEntry.java | 78 ++++++++++++++++++ .../paper/registry/event/RegistryEvents.java | 3 + .../org/bukkit/entity/ZombieNautilus.java | 37 +++++++++ .../java/io/papermc/generator/Rewriters.java | 2 + .../generator/registry/RegistryEntries.java | 4 + .../datacomponent/DataComponentAdapters.java | 2 + .../paper/registry/PaperRegistries.java | 4 + ...perZombieNautilusVariantRegistryEntry.java | 81 +++++++++++++++++++ .../craftbukkit/entity/CraftParched.java | 1 - .../entity/CraftZombieNautilus.java | 43 ++++++++++ .../registry/RegistryArgumentAddedTest.java | 1 - .../provider/RegistriesArgumentProvider.java | 4 + 15 files changed, 320 insertions(+), 2 deletions(-) create mode 100644 paper-api/src/generated/java/io/papermc/paper/registry/keys/ZombieNautilusVariantKeys.java create mode 100644 paper-api/src/main/java/io/papermc/paper/registry/data/ZombieNautilusVariantRegistryEntry.java create mode 100644 paper-server/src/main/java/io/papermc/paper/registry/data/PaperZombieNautilusVariantRegistryEntry.java diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/ZombieNautilusVariantKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ZombieNautilusVariantKeys.java new file mode 100644 index 000000000000..3e2cc8dc9a3a --- /dev/null +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ZombieNautilusVariantKeys.java @@ -0,0 +1,54 @@ +package io.papermc.paper.registry.keys; + +import static net.kyori.adventure.key.Key.key; + +import io.papermc.paper.annotation.GeneratedClass; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import net.kyori.adventure.key.Key; +import org.bukkit.entity.ZombieNautilus; +import org.jspecify.annotations.NullMarked; + +/** + * Vanilla keys for {@link RegistryKey#ZOMBIE_NAUTILUS_VARIANT}. + * + * @apiNote The fields provided here are a direct representation of + * what is available from the vanilla game source. They may be + * changed (including removals) on any Minecraft version + * bump, so cross-version compatibility is not provided on the + * same level as it is on most of the other API. + */ +@SuppressWarnings({ + "unused", + "SpellCheckingInspection" +}) +@NullMarked +@GeneratedClass +public final class ZombieNautilusVariantKeys { + /** + * {@code minecraft:temperate} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TEMPERATE = create(key("temperate")); + + /** + * {@code minecraft:warm} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WARM = create(key("warm")); + + private ZombieNautilusVariantKeys() { + } + + /** + * Creates a typed key for {@link ZombieNautilus.Variant} in the registry {@code minecraft:zombie_nautilus_variant}. + * + * @param key the value's key in the registry + * @return a new typed key + */ + public static TypedKey create(final Key key) { + return TypedKey.create(RegistryKey.ZOMBIE_NAUTILUS_VARIANT, key); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java index 7ae54b2028cd..247f14bd61fc 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java @@ -72,6 +72,7 @@ import org.bukkit.entity.TropicalFish; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; +import org.bukkit.entity.ZombieNautilus; import org.bukkit.inventory.ItemRarity; import org.bukkit.inventory.meta.trim.TrimMaterial; import org.checkerframework.checker.index.qual.NonNegative; @@ -383,6 +384,7 @@ public final class DataComponentTypes { public static final DataComponentType.Valued PAINTING_VARIANT = valued("painting/variant"); public static final DataComponentType.Valued LLAMA_VARIANT = valued("llama/variant"); public static final DataComponentType.Valued AXOLOTL_VARIANT = valued("axolotl/variant"); + public static final DataComponentType.Valued ZOMBIE_NAUTILUS_VARIANT = valued("zombie_nautilus/variant"); public static final DataComponentType.Valued CAT_VARIANT = valued("cat/variant"); public static final DataComponentType.Valued CAT_COLLAR = valued("cat/collar"); public static final DataComponentType.Valued SHEEP_COLOR = valued("sheep/color"); diff --git a/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java b/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java index 8c6545a4489e..15fbd69022c1 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java @@ -28,6 +28,7 @@ import org.bukkit.entity.Pig; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; +import org.bukkit.entity.ZombieNautilus; import org.bukkit.entity.memory.MemoryKey; import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.StructureType; @@ -220,6 +221,11 @@ public sealed interface RegistryKey extends Keyed permits RegistryKeyImpl { * @see io.papermc.paper.registry.keys.PigVariantKeys */ RegistryKey PIG_VARIANT = create("pig_variant"); + /** + * Data-driven registry for zombie nautilus variants. + * @see io.papermc.paper.registry.keys.ZombieNautilusVariantKeys + */ + RegistryKey ZOMBIE_NAUTILUS_VARIANT = create("zombie_nautilus_variant"); /** * Data-driven registry for dialogs. * @see io.papermc.paper.registry.keys.DialogKeys diff --git a/paper-api/src/main/java/io/papermc/paper/registry/data/ZombieNautilusVariantRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/ZombieNautilusVariantRegistryEntry.java new file mode 100644 index 000000000000..9aecc310792f --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/registry/data/ZombieNautilusVariantRegistryEntry.java @@ -0,0 +1,78 @@ +package io.papermc.paper.registry.data; + +import io.papermc.paper.registry.RegistryBuilder; +import io.papermc.paper.registry.data.client.ClientTextureAsset; +import org.bukkit.entity.ZombieNautilus; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; + +/** + * A data-centric version-specific registry entry for the {@link org.bukkit.entity.ZombieNautilus.Variant} type. + */ +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface ZombieNautilusVariantRegistryEntry { + + /** + * The model of the variant to render the configured texture on. + */ + enum Model { + /** + * The normal model. + */ + NORMAL, + + /** + * The warm model. + */ + WARM, + } + + /** + * Provides the client texture asset of the variant, which represents the texture to use. + * + * @return the client texture asset. + */ + ClientTextureAsset clientTextureAsset(); + + /** + * Provides the model of the variant. + * + * @return the model. + */ + Model model(); + + /** + * A mutable builder for the {@link ZombieNautilusVariantRegistryEntry} plugins may change in applicable registry events. + *

+ * The following values are required for each builder: + *

    + *
  • {@link #clientTextureAsset(ClientTextureAsset)}
  • + *
  • {@link #model(Model)}
  • + *
+ */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends ZombieNautilusVariantRegistryEntry, RegistryBuilder { + + /** + * Sets the client texture asset of the variant, which is the location of the texture to use. + * + * @param clientTextureAsset the client texture asset. + * @return this builder instance. + * @see ZombieNautilusVariantRegistryEntry#clientTextureAsset() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder clientTextureAsset(ClientTextureAsset clientTextureAsset); + + /** + * Sets the model to use for this variant. + * + * @param model the model. + * @return this builder instance. + * @see ZombieNautilusVariantRegistryEntry#model() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder model(Model model); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java b/paper-api/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java index 8890b8183b3d..6ae47dac3496 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java @@ -15,6 +15,7 @@ import io.papermc.paper.registry.data.PaintingVariantRegistryEntry; import io.papermc.paper.registry.data.PigVariantRegistryEntry; import io.papermc.paper.registry.data.WolfVariantRegistryEntry; +import io.papermc.paper.registry.data.ZombieNautilusVariantRegistryEntry; import io.papermc.paper.registry.data.dialog.DialogRegistryEntry; import org.bukkit.Art; import org.bukkit.GameEvent; @@ -29,6 +30,7 @@ import org.bukkit.entity.Frog; import org.bukkit.entity.Pig; import org.bukkit.entity.Wolf; +import org.bukkit.entity.ZombieNautilus; import static io.papermc.paper.registry.event.RegistryEventProviderImpl.create; @@ -52,6 +54,7 @@ public final class RegistryEvents { public static final RegistryEventProvider CHICKEN_VARIANT = create(RegistryKey.CHICKEN_VARIANT); public static final RegistryEventProvider COW_VARIANT = create(RegistryKey.COW_VARIANT); public static final RegistryEventProvider PIG_VARIANT = create(RegistryKey.PIG_VARIANT); + public static final RegistryEventProvider ZOMBIE_NAUTILUS_VARIANT = create(RegistryKey.ZOMBIE_NAUTILUS_VARIANT); public static final RegistryEventProvider DIALOG = create(RegistryKey.DIALOG); // End generate - RegistryEvents diff --git a/paper-api/src/main/java/org/bukkit/entity/ZombieNautilus.java b/paper-api/src/main/java/org/bukkit/entity/ZombieNautilus.java index 03fe9bfe4c1b..a12db166d2aa 100644 --- a/paper-api/src/main/java/org/bukkit/entity/ZombieNautilus.java +++ b/paper-api/src/main/java/org/bukkit/entity/ZombieNautilus.java @@ -1,4 +1,41 @@ package org.bukkit.entity; +import io.papermc.paper.registry.RegistryAccess; +import io.papermc.paper.registry.RegistryKey; +import org.bukkit.Keyed; +import org.bukkit.NamespacedKey; +import org.jspecify.annotations.NullMarked; + +@NullMarked public interface ZombieNautilus extends AbstractNautilus { + + /** + * Gets the variant of this zombie nautilus. + * + * @return the variant + */ + Variant getVariant(); + + /** + * Sets the variant of this zombie nautilus. + * + * @param variant the variant + */ + void setVariant(Variant variant); + + /** + * Represents the variant of a Zombie Nautilus. + */ + interface Variant extends Keyed { + + // Start generate - ZombieNautilusVariant + Variant TEMPERATE = getVariant("temperate"); + + Variant WARM = getVariant("warm"); + // End generate - ZombieNautilusVariant + + private static Variant getVariant(String key) { + return RegistryAccess.registryAccess().getRegistry(RegistryKey.ZOMBIE_NAUTILUS_VARIANT).getOrThrow(NamespacedKey.minecraft(key)); + } + } } diff --git a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java index 1058ce045f29..8cd7fe67e1bd 100644 --- a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java +++ b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java @@ -78,6 +78,7 @@ import org.bukkit.entity.TropicalFish; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; +import org.bukkit.entity.ZombieNautilus; import org.bukkit.entity.memory.MemoryKey; import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.StructureType; @@ -213,6 +214,7 @@ protected String rewriteFieldName(Holder.Reference(Registries.CHICKEN_VARIANT, "getVariant")) .register("CowVariant", Cow.Variant.class, new RegistryFieldRewriter<>(Registries.COW_VARIANT, "getVariant")) .register("PigVariant", Pig.Variant.class, new RegistryFieldRewriter<>(Registries.PIG_VARIANT, "getVariant")) + .register("ZombieNautilusVariant", ZombieNautilus.Variant.class, new RegistryFieldRewriter<>(Registries.ZOMBIE_NAUTILUS_VARIANT, "getVariant")) .register("Dialog", Dialog.class, new RegistryFieldRewriter<>(Registries.DIALOG, "getDialog")) .register("MemoryKey", MemoryKey.class, new MemoryKeyRewriter()) .register("GameRule", GameRule.class, new GameRuleTypeRewriter()) diff --git a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java index 409833c4e0cf..f9ef6646bef3 100644 --- a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java +++ b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java @@ -18,6 +18,7 @@ import io.papermc.paper.registry.data.PigVariantRegistryEntry; import io.papermc.paper.registry.data.SoundEventRegistryEntry; import io.papermc.paper.registry.data.WolfVariantRegistryEntry; +import io.papermc.paper.registry.data.ZombieNautilusVariantRegistryEntry; import io.papermc.paper.registry.data.dialog.DialogRegistryEntry; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -46,6 +47,7 @@ import net.minecraft.world.entity.animal.ChickenVariants; import net.minecraft.world.entity.animal.CowVariants; import net.minecraft.world.entity.animal.PigVariants; +import net.minecraft.world.entity.animal.ZombieNautilusVariant; import net.minecraft.world.entity.animal.frog.FrogVariants; import net.minecraft.world.entity.animal.wolf.WolfSoundVariants; import net.minecraft.world.entity.animal.wolf.WolfVariants; @@ -89,6 +91,7 @@ import org.bukkit.entity.Pig; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; +import org.bukkit.entity.ZombieNautilus; import org.bukkit.entity.memory.MemoryKey; import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.StructureType; @@ -188,6 +191,7 @@ private static RegistryEntry inconsistentEntry(ResourceKey CraftChicken.CraftVariant.minecraftHolderToBukkit(nms.unwrap(CraftRegistry.getMinecraftRegistry()).orElseThrow()), api -> new EitherHolder<>(CraftChicken.CraftVariant.bukkitToMinecraftHolder(api))); register(DataComponents.FROG_VARIANT, CraftFrog.CraftVariant::minecraftHolderToBukkit, CraftFrog.CraftVariant::bukkitToMinecraftHolder); + register(DataComponents.ZOMBIE_NAUTILUS_VARIANT, nms -> CraftZombieNautilus.CraftVariant.minecraftHolderToBukkit(nms.unwrap(CraftRegistry.getMinecraftRegistry()).orElseThrow()), api -> new EitherHolder<>(CraftZombieNautilus.CraftVariant.bukkitToMinecraftHolder(api))); register(DataComponents.HORSE_VARIANT, nms -> Horse.Color.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.horse.Variant.byId(api.ordinal())); register(DataComponents.PAINTING_VARIANT, CraftArt::minecraftHolderToBukkit, CraftArt::bukkitToMinecraftHolder); register(DataComponents.LLAMA_VARIANT, nms -> Llama.Color.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.horse.Llama.Variant.byId(api.ordinal())); diff --git a/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java index 98d776e44b20..121babcfdda5 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java @@ -20,6 +20,7 @@ import io.papermc.paper.registry.data.PaperPigVariantRegistryEntry; import io.papermc.paper.registry.data.PaperSoundEventRegistryEntry; import io.papermc.paper.registry.data.PaperWolfVariantRegistryEntry; +import io.papermc.paper.registry.data.PaperZombieNautilusVariantRegistryEntry; import io.papermc.paper.registry.data.dialog.PaperDialogRegistryEntry; import io.papermc.paper.registry.entry.RegistryEntry; import io.papermc.paper.registry.entry.RegistryEntryMeta; @@ -64,6 +65,7 @@ import org.bukkit.craftbukkit.entity.CraftPig; import org.bukkit.craftbukkit.entity.CraftVillager; import org.bukkit.craftbukkit.entity.CraftWolf; +import org.bukkit.craftbukkit.entity.CraftZombieNautilus; import org.bukkit.craftbukkit.generator.structure.CraftStructure; import org.bukkit.craftbukkit.generator.structure.CraftStructureType; import org.bukkit.craftbukkit.inventory.CraftItemType; @@ -83,6 +85,7 @@ import org.bukkit.entity.Pig; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; +import org.bukkit.entity.ZombieNautilus; import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.StructureType; import org.bukkit.inventory.ItemType; @@ -137,6 +140,7 @@ public final class PaperRegistries { start(Registries.CHICKEN_VARIANT, RegistryKey.CHICKEN_VARIANT).craft(Chicken.Variant.class, CraftChicken.CraftVariant::new).writable(PaperChickenVariantRegistryEntry.PaperBuilder::new), start(Registries.COW_VARIANT, RegistryKey.COW_VARIANT).craft(Cow.Variant.class, CraftCow.CraftVariant::new).writable(PaperCowVariantRegistryEntry.PaperBuilder::new), start(Registries.PIG_VARIANT, RegistryKey.PIG_VARIANT).craft(Pig.Variant.class, CraftPig.CraftVariant::new).writable(PaperPigVariantRegistryEntry.PaperBuilder::new), + start(Registries.ZOMBIE_NAUTILUS_VARIANT, RegistryKey.ZOMBIE_NAUTILUS_VARIANT).craft(ZombieNautilus.Variant.class, CraftZombieNautilus.CraftVariant::new).writable(PaperZombieNautilusVariantRegistryEntry.PaperBuilder::new), start(Registries.DIALOG, RegistryKey.DIALOG).craft(Dialog.class, PaperDialog::new, true).writable(PaperDialogRegistryEntry.PaperBuilder::new), // api-only diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperZombieNautilusVariantRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperZombieNautilusVariantRegistryEntry.java new file mode 100644 index 000000000000..31cf65bf5b44 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperZombieNautilusVariantRegistryEntry.java @@ -0,0 +1,81 @@ +package io.papermc.paper.registry.data; + +import io.papermc.paper.registry.PaperRegistryBuilder; +import io.papermc.paper.registry.data.client.ClientTextureAsset; +import io.papermc.paper.registry.data.util.Conversions; +import net.minecraft.core.ClientAsset; +import net.minecraft.world.entity.animal.ZombieNautilusVariant; +import net.minecraft.world.entity.variant.ModelAndTexture; +import net.minecraft.world.entity.variant.SpawnPrioritySelectors; +import org.bukkit.entity.ZombieNautilus; +import org.jspecify.annotations.Nullable; + +import static io.papermc.paper.registry.data.util.Checks.asArgument; +import static io.papermc.paper.registry.data.util.Checks.asConfigured; + +public class PaperZombieNautilusVariantRegistryEntry implements ZombieNautilusVariantRegistryEntry { + + protected ZombieNautilusVariant.@Nullable ModelType model; + protected ClientAsset.@Nullable ResourceTexture clientTextureAsset; + protected SpawnPrioritySelectors spawnConditions; + + protected final Conversions conversions; + + public PaperZombieNautilusVariantRegistryEntry( + final Conversions conversions, + final @Nullable ZombieNautilusVariant internal + ) { + this.conversions = conversions; + if (internal == null) { + this.spawnConditions = SpawnPrioritySelectors.EMPTY; + return; + } + + this.clientTextureAsset = internal.modelAndTexture().asset(); + this.model = internal.modelAndTexture().model(); + this.spawnConditions = internal.spawnConditions(); + } + + @Override + public ClientTextureAsset clientTextureAsset() { + return this.conversions.asBukkit(asConfigured(this.clientTextureAsset, "clientTextureAsset")); + } + + @Override + public ZombieNautilusVariantRegistryEntry.Model model() { + return switch (asConfigured(this.model, "model")) { + case NORMAL -> ZombieNautilusVariantRegistryEntry.Model.NORMAL; + case WARM -> ZombieNautilusVariantRegistryEntry.Model.WARM; + }; + } + + public static final class PaperBuilder extends PaperZombieNautilusVariantRegistryEntry implements Builder, PaperRegistryBuilder { + + public PaperBuilder(final Conversions conversions, final @Nullable ZombieNautilusVariant internal) { + super(conversions, internal); + } + + @Override + public ZombieNautilusVariantRegistryEntry.Builder clientTextureAsset(final ClientTextureAsset clientTextureAsset) { + this.clientTextureAsset = this.conversions.asVanilla(asArgument(clientTextureAsset, "clientTextureAsset")); + return this; + } + + @Override + public ZombieNautilusVariantRegistryEntry.Builder model(final ZombieNautilusVariantRegistryEntry.Model model) { + this.model = switch (asArgument(model, "model")) { + case NORMAL -> ZombieNautilusVariant.ModelType.NORMAL; + case WARM -> ZombieNautilusVariant.ModelType.WARM; + }; + return this; + } + + @Override + public ZombieNautilusVariant build() { + return new ZombieNautilusVariant( + new ModelAndTexture<>(asConfigured(this.model, "model"), asConfigured(this.clientTextureAsset, "clientTextureAsset")), + asConfigured(this.spawnConditions, "spawnConditions") + ); + } + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java index 4794f8902936..cb179f1143a5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java @@ -1,6 +1,5 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.animal.nautilus.ZombieNautilus; import net.minecraft.world.entity.monster.Parched; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Skeleton; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java index 489508fbab7d..9f342e2e3863 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java @@ -1,8 +1,16 @@ package org.bukkit.craftbukkit.entity; +import com.google.common.base.Preconditions; +import io.papermc.paper.registry.HolderableBase; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.entity.animal.ZombieNautilusVariant; import net.minecraft.world.entity.animal.nautilus.ZombieNautilus; +import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftServer; +import org.jspecify.annotations.NullMarked; +@NullMarked public class CraftZombieNautilus extends CraftAbstractNautilus implements org.bukkit.entity.ZombieNautilus { public CraftZombieNautilus(final CraftServer server, final ZombieNautilus entity) { super(server, entity); @@ -12,4 +20,39 @@ public CraftZombieNautilus(final CraftServer server, final ZombieNautilus entity public ZombieNautilus getHandle() { return (ZombieNautilus) this.entity; } + + @Override + public org.bukkit.entity.ZombieNautilus.Variant getVariant() { + return CraftVariant.minecraftHolderToBukkit(this.getHandle().getVariant()); + } + + @Override + public void setVariant(org.bukkit.entity.ZombieNautilus.Variant variant) { + Preconditions.checkArgument(variant != null, "variant cannot be null"); + + this.getHandle().setVariant(CraftVariant.bukkitToMinecraftHolder(variant)); + } + + public static class CraftVariant extends HolderableBase implements org.bukkit.entity.ZombieNautilus.Variant { + + public static org.bukkit.entity.ZombieNautilus.Variant minecraftToBukkit(ZombieNautilusVariant minecraft) { + return CraftRegistry.minecraftToBukkit(minecraft, Registries.ZOMBIE_NAUTILUS_VARIANT); + } + + public static org.bukkit.entity.ZombieNautilus.Variant minecraftHolderToBukkit(Holder minecraft) { + return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.ZOMBIE_NAUTILUS_VARIANT); + } + + public static ZombieNautilusVariant bukkitToMinecraft(Variant bukkit) { + return CraftRegistry.bukkitToMinecraft(bukkit); + } + + public static Holder bukkitToMinecraftHolder(Variant bukkit) { + return CraftRegistry.bukkitToMinecraftHolder(bukkit); + } + + public CraftVariant(final Holder holder) { + super(holder); + } + } } diff --git a/paper-server/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java b/paper-server/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java index c1016e0eb00e..677697409dcf 100644 --- a/paper-server/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java @@ -6,7 +6,6 @@ import java.util.Set; import org.bukkit.Registry; import org.bukkit.support.environment.AllFeatures; -import org.bukkit.support.extension.AllFeaturesExtension; import org.bukkit.support.provider.RegistriesArgumentProvider; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.provider.Arguments; diff --git a/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java b/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java index 6e18d1ff95a8..8c06180b674d 100644 --- a/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java +++ b/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java @@ -14,6 +14,7 @@ import net.minecraft.world.entity.animal.ChickenVariant; import net.minecraft.world.entity.animal.CowVariant; import net.minecraft.world.entity.animal.PigVariant; +import net.minecraft.world.entity.animal.ZombieNautilusVariant; import net.minecraft.world.entity.animal.frog.FrogVariant; import net.minecraft.world.entity.animal.wolf.WolfSoundVariant; import net.minecraft.world.entity.animal.wolf.WolfVariant; @@ -54,6 +55,7 @@ import org.bukkit.craftbukkit.entity.CraftPig; import org.bukkit.craftbukkit.entity.CraftVillager; import org.bukkit.craftbukkit.entity.CraftWolf; +import org.bukkit.craftbukkit.entity.CraftZombieNautilus; import org.bukkit.craftbukkit.generator.structure.CraftStructure; import org.bukkit.craftbukkit.generator.structure.CraftStructureType; import org.bukkit.craftbukkit.inventory.CraftItemType; @@ -71,6 +73,7 @@ import org.bukkit.entity.Pig; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; +import org.bukkit.entity.ZombieNautilus; import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.StructureType; import org.bukkit.inventory.ItemType; @@ -119,6 +122,7 @@ public class RegistriesArgumentProvider implements ArgumentsProvider { register(RegistryKey.CHICKEN_VARIANT, Chicken.Variant.class, Registries.CHICKEN_VARIANT, CraftChicken.CraftVariant.class, ChickenVariant.class); register(RegistryKey.COW_VARIANT, Cow.Variant.class, Registries.COW_VARIANT, CraftCow.CraftVariant.class, CowVariant.class); register(RegistryKey.PIG_VARIANT, Pig.Variant.class, Registries.PIG_VARIANT, CraftPig.CraftVariant.class, PigVariant.class); + register(RegistryKey.ZOMBIE_NAUTILUS_VARIANT, ZombieNautilus.Variant.class, Registries.ZOMBIE_NAUTILUS_VARIANT, CraftZombieNautilus.CraftVariant.class, ZombieNautilusVariant.class); register(RegistryKey.DIALOG, Dialog.class, Registries.DIALOG, PaperDialog.class, net.minecraft.server.dialog.Dialog.class); register(RegistryKey.GAME_RULE, GameRule.class, Registries.GAME_RULE, CraftGameRule.class, net.minecraft.world.level.gamerules.GameRule.class); } From 9b1f6b4eb1f7612d996fff843dd71279a51a5da6 Mon Sep 17 00:00:00 2001 From: Pedro <3602279+Doc94@users.noreply.github.com> Date: Thu, 6 Nov 2025 12:39:23 -0300 Subject: [PATCH 056/112] Add ExhaustionReason for ApplyExhaustion EnchantmentEffect (#13224) --- .../bukkit/event/entity/EntityExhaustionEvent.java | 6 ++++++ .../enchantment/effects/ApplyExhaustion.java.patch | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ApplyExhaustion.java.patch diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityExhaustionEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityExhaustionEvent.java index fc59cdaac369..f02c1c2e0882 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityExhaustionEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityExhaustionEvent.java @@ -134,6 +134,12 @@ public enum ExhaustionReason { * Player regenerated health */ REGEN, + /** + * Player was affected by an enchantment + * @see Minecraft Wiki: Enchantment Effects "apply_exhaustion" + */ + // TODO - snapshot - In release check if this Wiki URL exists + ENCHANTMENT_EFFECT, /** * Unknown exhaustion reason */ diff --git a/paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ApplyExhaustion.java.patch b/paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ApplyExhaustion.java.patch new file mode 100644 index 000000000000..6c7e2f12762e --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ApplyExhaustion.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/enchantment/effects/ApplyExhaustion.java ++++ b/net/minecraft/world/item/enchantment/effects/ApplyExhaustion.java +@@ -17,7 +_,7 @@ + @Override + public void apply(ServerLevel level, int enchantmentLevel, EnchantedItemInUse item, Entity entity, Vec3 origin) { + if (entity instanceof Player player) { +- player.causeFoodExhaustion(this.amount.calculate(enchantmentLevel)); ++ player.causeFoodExhaustion(this.amount.calculate(enchantmentLevel), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.ENCHANTMENT_EFFECT); // Paper - add ExhaustionReason + } + } + From 270f7bf457a2d17b65333b5c0dde010d317f5a86 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Thu, 6 Nov 2025 18:58:52 +0100 Subject: [PATCH 057/112] update parchment --- paper-server/build.gradle.kts | 2 +- .../net/minecraft/server/level/ServerPlayer.java.patch | 6 +++--- .../net/minecraft/world/entity/npc/Villager.java.patch | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index f6af0780d388..afd7809f78bf 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:25w45a+build.6") + mache("io.papermc:mache:25w45a+build.7") paperclip("io.papermc:paperclip:3.0.3") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index f403367301ea..ddb50de9c809 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -1493,10 +1493,10 @@ super.updateUsingItem(usingItem); } -- public void drop(boolean flag) { -+ public boolean drop(boolean flag) { // Paper - add back success return +- public void drop(boolean dropStack) { ++ public boolean drop(boolean dropStack) { // Paper - add back success return Inventory inventory = this.getInventory(); - ItemStack itemStack = inventory.removeFromSelected(flag); + ItemStack itemStack = inventory.removeFromSelected(dropStack); this.containerMenu @@ -2045,7 +_,7 @@ this.stopUsingItem(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch index 4040534803d8..213ff7ba75e4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch @@ -75,10 +75,10 @@ return VillagerData.canLevelUp(level) && this.villagerXp >= VillagerData.getMaxXpPerLevel(level); } -- private void increaseMerchantCareer(ServerLevel serverLevel) { -+ public void increaseMerchantCareer(ServerLevel serverLevel) { // Paper - public +- private void increaseMerchantCareer(ServerLevel level) { ++ public void increaseMerchantCareer(ServerLevel level) { // Paper - public this.setVillagerData(this.getVillagerData().withLevel(this.getVillagerData().level() + 1)); - this.updateTrades(serverLevel); + this.updateTrades(level); } @@ -772,12 +_,19 @@ @Override From 7690b42ca2cd28e34ac07710685571e84cb69704 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Thu, 6 Nov 2025 19:03:12 +0100 Subject: [PATCH 058/112] gamerule is a built-in registry --- .../src/main/java/io/papermc/paper/InternalAPIBridge.java | 5 ++--- .../src/main/java/io/papermc/paper/registry/RegistryKey.java | 2 +- .../java/io/papermc/paper/PaperServerInternalAPIBridge.java | 5 ++--- .../src/main/java/org/bukkit/craftbukkit/CraftGameRule.java | 3 +-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java b/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java index 2b488289b34d..d40229a39cad 100644 --- a/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java +++ b/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java @@ -5,6 +5,8 @@ import io.papermc.paper.datacomponent.item.ResolvableProfile; import io.papermc.paper.world.damagesource.CombatEntry; import io.papermc.paper.world.damagesource.FallLocationType; +import java.util.function.Function; +import java.util.function.Predicate; import net.kyori.adventure.text.Component; import net.kyori.adventure.util.Services; import org.bukkit.GameRule; @@ -17,9 +19,6 @@ import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; -import java.util.function.Function; -import java.util.function.Predicate; - /** * Static bridge to the server internals. *

diff --git a/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java b/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java index 15fbd69022c1..dcee3d88f5b7 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java @@ -128,7 +128,7 @@ public sealed interface RegistryKey extends Keyed permits RegistryKeyImpl { */ RegistryKey DATA_COMPONENT_TYPE = create("data_component_type"); /** - * Data-driven registry for game rules. + * Built-in registry for game rules. * @see io.papermc.paper.registry.keys.GameRuleKeys */ RegistryKey> GAME_RULE = create("game_rule"); diff --git a/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java b/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java index 0ac6e1cf00ec..afad46f7b927 100644 --- a/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java +++ b/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java @@ -10,6 +10,8 @@ import io.papermc.paper.world.damagesource.FallLocationType; import io.papermc.paper.world.damagesource.PaperCombatEntryWrapper; import io.papermc.paper.world.damagesource.PaperCombatTrackerWrapper; +import java.util.function.Function; +import java.util.function.Predicate; import net.kyori.adventure.text.Component; import net.minecraft.Optionull; import net.minecraft.commands.Commands; @@ -28,9 +30,6 @@ import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; -import java.util.function.Function; -import java.util.function.Predicate; - @NullMarked public class PaperServerInternalAPIBridge implements InternalAPIBridge { public static final PaperServerInternalAPIBridge INSTANCE = new PaperServerInternalAPIBridge(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java index aa09c08aaa98..f027feb866bd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit; import io.papermc.paper.util.Holderable; +import java.util.function.Function; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; import org.bukkit.GameRule; @@ -9,8 +10,6 @@ import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; -import java.util.function.Function; - @NullMarked public class CraftGameRule extends GameRule implements Holderable> { From 2916473228b6c83b35b4a87b02c9a0435b88046b Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Thu, 6 Nov 2025 19:08:37 +0100 Subject: [PATCH 059/112] add missing registry field for gamerule --- paper-api/src/main/java/org/bukkit/GameRule.java | 3 --- paper-api/src/main/java/org/bukkit/Registry.java | 8 +++++++- .../main/java/org/bukkit/craftbukkit/CraftGameRule.java | 9 ++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/GameRule.java b/paper-api/src/main/java/org/bukkit/GameRule.java index d7f3d8dbd6b2..13e1849dd987 100644 --- a/paper-api/src/main/java/org/bukkit/GameRule.java +++ b/paper-api/src/main/java/org/bukkit/GameRule.java @@ -5,11 +5,8 @@ import io.papermc.paper.registry.RegistryAccess; import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.world.flag.FeatureDependant; -import java.util.HashMap; -import java.util.Map; import java.util.NoSuchElementException; import java.util.function.UnaryOperator; - import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/paper-api/src/main/java/org/bukkit/Registry.java b/paper-api/src/main/java/org/bukkit/Registry.java index f9774834e5a7..d3aef5ebe9c8 100644 --- a/paper-api/src/main/java/org/bukkit/Registry.java +++ b/paper-api/src/main/java/org/bukkit/Registry.java @@ -348,7 +348,13 @@ public int size() { * * @see DataComponentType */ - Registry DATA_COMPONENT_TYPE = registryFor(RegistryKey.DATA_COMPONENT_TYPE); // Paper + Registry DATA_COMPONENT_TYPE = registryFor(RegistryKey.DATA_COMPONENT_TYPE); + /** + * Game rules. + * + * @see GameRule + */ + Registry> GAME_RULE = registryFor(RegistryKey.GAME_RULE); // /** diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java index f027feb866bd..f2c8ba89b93e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java @@ -6,7 +6,6 @@ import net.minecraft.core.registries.Registries; import org.bukkit.GameRule; import org.bukkit.NamespacedKey; -import org.jetbrains.annotations.NotNull; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -62,13 +61,13 @@ public String toString() { } @Override - public @NotNull String getName() { + public String getName() { return this.holder.getRegisteredName(); } @SuppressWarnings("unchecked") @Override - public @NotNull Class getType() { + public Class getType() { return (Class) switch (this.holder.value().gameRuleType()) { case INT -> Integer.class; case BOOL -> Boolean.class; @@ -76,7 +75,7 @@ public String toString() { } @Override - public @NotNull String translationKey() { + public String translationKey() { return this.holder.value().id(); } @@ -103,7 +102,7 @@ public LegacyGameRuleWrapper(Holder getType() { + public Class getType() { return this.typeOverride; } } From 17ae7228d980089d2d73b66c342a508576ac61c9 Mon Sep 17 00:00:00 2001 From: Pedro <3602279+Doc94@users.noreply.github.com> Date: Thu, 6 Nov 2025 15:32:59 -0300 Subject: [PATCH 060/112] Add EntityPotionEffectEvent.Cause.NAUTILUS (#13281) --- .../org/bukkit/event/entity/EntityPotionEffectEvent.java | 4 ++++ .../entity/animal/nautilus/AbstractNautilus.java.patch | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java index 054a38983f85..61ff80a91c39 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java @@ -218,6 +218,10 @@ public enum Cause { * When all effects are removed due to a bucket of milk. */ MILK, + /** + * When the entity gets the effect from a nautilus. + */ + NAUTILUS, /** * When a player gets bad omen after killing a patrol captain. * diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch index 32029fb07da5..3ff93cb0e3cc 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch @@ -1,5 +1,14 @@ --- a/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java +++ b/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java +@@ -247,7 +_,7 @@ + boolean hasEffect = player.hasEffect(MobEffects.BREATH_OF_THE_NAUTILUS); + boolean flag = level.getGameTime() % 40L == 0L; + if (!hasEffect || flag) { +- player.addEffect(new MobEffectInstance(MobEffects.BREATH_OF_THE_NAUTILUS, 60, 0, true, true, true)); ++ player.addEffect(new MobEffectInstance(MobEffects.BREATH_OF_THE_NAUTILUS, 60, 0, true, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.NAUTILUS); // Paper - Add cause + } + } + } @@ -387,7 +_,7 @@ if (this.isFood(itemInHand) && this.getHealth() < this.getMaxHealth()) { this.usePlayerItem(player, hand, itemInHand); From f0a7909c73af308aed89450726f7d427cf6f8b7d Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Thu, 6 Nov 2025 23:25:15 +0100 Subject: [PATCH 061/112] fix gamerule translation key --- .../src/main/java/org/bukkit/craftbukkit/CraftGameRule.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java index f2c8ba89b93e..d4e1455e2bc8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java @@ -68,7 +68,7 @@ public String getName() { @SuppressWarnings("unchecked") @Override public Class getType() { - return (Class) switch (this.holder.value().gameRuleType()) { + return (Class) switch (this.getHandle().gameRuleType()) { case INT -> Integer.class; case BOOL -> Boolean.class; }; @@ -76,7 +76,7 @@ public Class getType() { @Override public String translationKey() { - return this.holder.value().id(); + return this.getHandle().getDescriptionId(); } public static class LegacyGameRuleWrapper extends CraftGameRule { From 8e0412f5d12d3e71279801f955ffa46fd15652a2 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Fri, 7 Nov 2025 21:33:59 +0100 Subject: [PATCH 062/112] tweaks gamerules move constants out of class, fix a bunch NPE, fix event setter, fix world methods too --- .../event/world/WorldGameRuleChangeEvent.java | 2 +- .../main/java/org/bukkit/ExplosionResult.java | 6 +- .../src/main/java/org/bukkit/GameRule.java | 530 +++++++++++------- .../src/main/java/org/bukkit/GameRules.java | 141 +++++ .../src/main/java/org/bukkit/Server.java | 2 +- paper-api/src/main/java/org/bukkit/World.java | 8 +- .../main/java/org/bukkit/command/Command.java | 5 +- .../main/java/org/bukkit/entity/Minecart.java | 3 +- .../bukkit/event/block/BlockExplodeEvent.java | 2 +- .../event/entity/EntityDamageEvent.java | 2 +- .../event/entity/EntityExplodeEvent.java | 2 +- .../bukkit/event/entity/PlayerDeathEvent.java | 4 +- .../java/io/papermc/generator/Rewriters.java | 11 +- .../generator/registry/RegistryEntries.java | 2 +- .../types/simple/GameRuleTypeRewriter.java | 18 - .../paper/PaperServerInternalAPIBridge.java | 2 +- .../world/PaperWorldGameRuleChangeEvent.java | 24 + .../flag/PaperFeatureFlagProviderImpl.java | 2 - .../org/bukkit/craftbukkit/CraftGameRule.java | 23 +- .../org/bukkit/craftbukkit/CraftWorld.java | 34 +- .../craftbukkit/event/CraftEventFactory.java | 14 +- .../test/java/org/bukkit/GameRuleTest.java | 7 +- 22 files changed, 579 insertions(+), 265 deletions(-) create mode 100644 paper-api/src/main/java/org/bukkit/GameRules.java delete mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/GameRuleTypeRewriter.java create mode 100644 paper-server/src/main/java/io/papermc/paper/event/world/PaperWorldGameRuleChangeEvent.java diff --git a/paper-api/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java b/paper-api/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java index 4d259e31c4b1..c44006faf327 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java @@ -19,7 +19,7 @@ public class WorldGameRuleChangeEvent extends WorldEvent implements Cancellable private static final HandlerList HANDLER_LIST = new HandlerList(); private final @Nullable CommandSender commandSender; - private final GameRule gameRule; + protected final GameRule gameRule; private String value; private boolean cancelled; diff --git a/paper-api/src/main/java/org/bukkit/ExplosionResult.java b/paper-api/src/main/java/org/bukkit/ExplosionResult.java index c875a10480e5..670b3ed55f59 100644 --- a/paper-api/src/main/java/org/bukkit/ExplosionResult.java +++ b/paper-api/src/main/java/org/bukkit/ExplosionResult.java @@ -11,7 +11,7 @@ public enum ExplosionResult { /** * Represents an explosion where no change took place. * - * This is the case when {@link org.bukkit.GameRule#MOB_GRIEFING} is + * This is the case when {@link org.bukkit.GameRules#MOB_GRIEFING} is * disabled. */ KEEP, @@ -19,8 +19,8 @@ public enum ExplosionResult { * Represents an explosion where all destroyed blocks drop their items. * * This is the case when - * {@link org.bukkit.GameRule#TNT_EXPLOSION_DROP_DECAY} or - * {@link org.bukkit.GameRule#BLOCK_EXPLOSION_DROP_DECAY} is disabled. + * {@link org.bukkit.GameRules#TNT_EXPLOSION_DROP_DECAY} or + * {@link org.bukkit.GameRules#BLOCK_EXPLOSION_DROP_DECAY} is disabled. */ DESTROY, /** diff --git a/paper-api/src/main/java/org/bukkit/GameRule.java b/paper-api/src/main/java/org/bukkit/GameRule.java index 13e1849dd987..07a3cfe00cd1 100644 --- a/paper-api/src/main/java/org/bukkit/GameRule.java +++ b/paper-api/src/main/java/org/bukkit/GameRule.java @@ -2,10 +2,7 @@ import com.google.common.base.Preconditions; import io.papermc.paper.InternalAPIBridge; -import io.papermc.paper.registry.RegistryAccess; -import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.world.flag.FeatureDependant; -import java.util.NoSuchElementException; import java.util.function.UnaryOperator; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @@ -19,307 +16,455 @@ * Wiki * * @param type of rule (Boolean or Integer) + * @see GameRules */ @ApiStatus.NonExtendable public abstract class GameRule implements net.kyori.adventure.translation.Translatable, FeatureDependant, Keyed { - // Start generate - GameRule - public static final GameRule ADVANCE_TIME = getByName("advance_time"); - - public static final GameRule ADVANCE_WEATHER = getByName("advance_weather"); - - public static final GameRule ALLOW_ENTERING_NETHER_USING_PORTALS = getByName("allow_entering_nether_using_portals"); - - public static final GameRule BLOCK_DROPS = getByName("block_drops"); - - public static final GameRule BLOCK_EXPLOSION_DROP_DECAY = getByName("block_explosion_drop_decay"); - - public static final GameRule COMMAND_BLOCK_OUTPUT = getByName("command_block_output"); - - public static final GameRule COMMAND_BLOCKS_WORK = getByName("command_blocks_work"); - - public static final GameRule DROWNING_DAMAGE = getByName("drowning_damage"); - - public static final GameRule ELYTRA_MOVEMENT_CHECK = getByName("elytra_movement_check"); - - public static final GameRule ENDER_PEARLS_VANISH_ON_DEATH = getByName("ender_pearls_vanish_on_death"); - - public static final GameRule ENTITY_DROPS = getByName("entity_drops"); - - public static final GameRule FALL_DAMAGE = getByName("fall_damage"); - - public static final GameRule FIRE_DAMAGE = getByName("fire_damage"); - - public static final GameRule FIRE_SPREAD_RADIUS_AROUND_PLAYER = getByName("fire_spread_radius_around_player"); - - public static final GameRule FORGIVE_DEAD_PLAYERS = getByName("forgive_dead_players"); - - public static final GameRule FREEZE_DAMAGE = getByName("freeze_damage"); - - public static final GameRule GLOBAL_SOUND_EVENTS = getByName("global_sound_events"); - - public static final GameRule IMMEDIATE_RESPAWN = getByName("immediate_respawn"); - - public static final GameRule KEEP_INVENTORY = getByName("keep_inventory"); - - public static final GameRule LAVA_SOURCE_CONVERSION = getByName("lava_source_conversion"); - - public static final GameRule LIMITED_CRAFTING = getByName("limited_crafting"); - - public static final GameRule LOCATOR_BAR = getByName("locator_bar"); - - public static final GameRule LOG_ADMIN_COMMANDS = getByName("log_admin_commands"); - - public static final GameRule MAX_BLOCK_MODIFICATIONS = getByName("max_block_modifications"); - - public static final GameRule MAX_COMMAND_FORKS = getByName("max_command_forks"); - - public static final GameRule MAX_COMMAND_SEQUENCE_LENGTH = getByName("max_command_sequence_length"); - - public static final GameRule MAX_ENTITY_CRAMMING = getByName("max_entity_cramming"); - - @MinecraftExperimental(MinecraftExperimental.Requires.MINECART_IMPROVEMENTS) - @ApiStatus.Experimental - public static final GameRule MAX_MINECART_SPEED = getByName("max_minecart_speed"); - - public static final GameRule MAX_SNOW_ACCUMULATION_HEIGHT = getByName("max_snow_accumulation_height"); - - public static final GameRule MOB_DROPS = getByName("mob_drops"); - - public static final GameRule MOB_EXPLOSION_DROP_DECAY = getByName("mob_explosion_drop_decay"); - - public static final GameRule MOB_GRIEFING = getByName("mob_griefing"); - - public static final GameRule NATURAL_HEALTH_REGENERATION = getByName("natural_health_regeneration"); - - public static final GameRule PLAYER_MOVEMENT_CHECK = getByName("player_movement_check"); - - public static final GameRule PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = getByName("players_nether_portal_creative_delay"); - - public static final GameRule PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = getByName("players_nether_portal_default_delay"); - - public static final GameRule PLAYERS_SLEEPING_PERCENTAGE = getByName("players_sleeping_percentage"); - - public static final GameRule PROJECTILES_CAN_BREAK_BLOCKS = getByName("projectiles_can_break_blocks"); - - public static final GameRule PVP = getByName("pvp"); - - public static final GameRule RAIDS = getByName("raids"); - - public static final GameRule RANDOM_TICK_SPEED = getByName("random_tick_speed"); - - public static final GameRule REDUCED_DEBUG_INFO = getByName("reduced_debug_info"); - - public static final GameRule RESPAWN_RADIUS = getByName("respawn_radius"); - - public static final GameRule SEND_COMMAND_FEEDBACK = getByName("send_command_feedback"); - - public static final GameRule SHOW_ADVANCEMENT_MESSAGES = getByName("show_advancement_messages"); - - public static final GameRule SHOW_DEATH_MESSAGES = getByName("show_death_messages"); - - public static final GameRule SPAWN_MOBS = getByName("spawn_mobs"); - - public static final GameRule SPAWN_MONSTERS = getByName("spawn_monsters"); - - public static final GameRule SPAWN_PATROLS = getByName("spawn_patrols"); - - public static final GameRule SPAWN_PHANTOMS = getByName("spawn_phantoms"); - - public static final GameRule SPAWN_WANDERING_TRADERS = getByName("spawn_wandering_traders"); - - public static final GameRule SPAWN_WARDENS = getByName("spawn_wardens"); - - public static final GameRule SPAWNER_BLOCKS_WORK = getByName("spawner_blocks_work"); - - public static final GameRule SPECTATORS_GENERATE_CHUNKS = getByName("spectators_generate_chunks"); - - public static final GameRule SPREAD_VINES = getByName("spread_vines"); - - public static final GameRule TNT_EXPLODES = getByName("tnt_explodes"); - - public static final GameRule TNT_EXPLOSION_DROP_DECAY = getByName("tnt_explosion_drop_decay"); - - public static final GameRule UNIVERSAL_ANGER = getByName("universal_anger"); - - public static final GameRule WATER_SOURCE_CONVERSION = getByName("water_source_conversion"); - // End generate - GameRule - // Boolean rules /** * Toggles the announcing of advancements. + * + * @deprecated renamed to {@link GameRules#SHOW_ADVANCEMENT_MESSAGES} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule ANNOUNCE_ADVANCEMENTS = InternalAPIBridge.get().legacyGameRuleBridge(SHOW_ADVANCEMENT_MESSAGES, null, null, Boolean.class); - + public static final GameRule ANNOUNCE_ADVANCEMENTS = GameRules.SHOW_ADVANCEMENT_MESSAGES; + /** + * Whether command blocks should notify admins when they perform commands. + * + * @deprecated renamed to {@link GameRules#COMMAND_BLOCK_OUTPUT} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule COMMAND_BLOCK_OUTPUT = GameRules.COMMAND_BLOCK_OUTPUT; /** * Whether the server should skip checking player speed. + * + * @deprecated renamed to {@link GameRules#PLAYER_MOVEMENT_CHECK} (inverted) */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DISABLE_PLAYER_MOVEMENT_CHECK = InternalAPIBridge.get().legacyGameRuleBridge(PLAYER_MOVEMENT_CHECK, inverseBool(), inverseBool(), Boolean.class); - + public static final GameRule DISABLE_PLAYER_MOVEMENT_CHECK = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.PLAYER_MOVEMENT_CHECK, inverseBool(), inverseBool(), Boolean.class); /** * Whether the server should skip checking player speed when the player is * wearing elytra. + * + * @deprecated renamed to {@link GameRules#ELYTRA_MOVEMENT_CHECK} (inverted) */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DISABLE_ELYTRA_MOVEMENT_CHECK = InternalAPIBridge.get().legacyGameRuleBridge(ELYTRA_MOVEMENT_CHECK, inverseBool(), inverseBool(), Boolean.class); - + public static final GameRule DISABLE_ELYTRA_MOVEMENT_CHECK = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.ELYTRA_MOVEMENT_CHECK, inverseBool(), inverseBool(), Boolean.class); /** * Whether time progresses from the current moment. + * + * @deprecated renamed to {@link GameRules#ADVANCE_TIME} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DO_DAYLIGHT_CYCLE = InternalAPIBridge.get().legacyGameRuleBridge(ADVANCE_TIME, null, null, Boolean.class); - + public static final GameRule DO_DAYLIGHT_CYCLE = GameRules.ADVANCE_TIME; /** * Whether entities that are not mobs should have drops. + * + * @deprecated renamed to {@link GameRules#ENTITY_DROPS} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DO_ENTITY_DROPS = InternalAPIBridge.get().legacyGameRuleBridge(ENTITY_DROPS, null, null, Boolean.class); - + public static final GameRule DO_ENTITY_DROPS = GameRules.ENTITY_DROPS; /** * Whether fire should spread and naturally extinguish. + * + * @deprecated use {@link GameRules#FIRE_SPREAD_RADIUS_AROUND_PLAYER} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DO_FIRE_TICK = InternalAPIBridge.get().legacyGameRuleBridge(FIRE_SPREAD_RADIUS_AROUND_PLAYER, (value) -> value ? 128 : 0, (value) -> value != 0, Boolean.class); - + public static final GameRule DO_FIRE_TICK = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.FIRE_SPREAD_RADIUS_AROUND_PLAYER, (value) -> value ? 128 : 0, (value) -> value != 0, Boolean.class); /** * Whether players should only be able to craft recipes they've unlocked * first. + * + * @deprecated renamed to {@link GameRules#LIMITED_CRAFTING} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DO_LIMITED_CRAFTING = InternalAPIBridge.get().legacyGameRuleBridge(LIMITED_CRAFTING, null, null, Boolean.class); - + public static final GameRule DO_LIMITED_CRAFTING = GameRules.LIMITED_CRAFTING; + /** + * Whether projectiles can break blocks. + * + * @deprecated renamed to {@link GameRules#PROJECTILES_CAN_BREAK_BLOCKS} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule PROJECTILES_CAN_BREAK_BLOCKS = GameRules.PROJECTILES_CAN_BREAK_BLOCKS; /** * Whether mobs should drop items. + * + * @deprecated renamed to {@link GameRules#MOB_DROPS} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DO_MOB_LOOT = InternalAPIBridge.get().legacyGameRuleBridge(MOB_DROPS, null, null, Boolean.class); - + public static final GameRule DO_MOB_LOOT = GameRules.MOB_DROPS; /** * Whether mobs should naturally spawn. + * + * @deprecated renamed to {@link GameRules#SPAWN_MOBS} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DO_MOB_SPAWNING = InternalAPIBridge.get().legacyGameRuleBridge(SPAWN_MOBS, null, null, Boolean.class); - + public static final GameRule DO_MOB_SPAWNING = GameRules.SPAWN_MOBS; /** * Whether blocks should have drops. + * + * @deprecated renamed to {@link GameRules#BLOCK_DROPS} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DO_TILE_DROPS = InternalAPIBridge.get().legacyGameRuleBridge(BLOCK_DROPS, null, null, Boolean.class); - + public static final GameRule DO_TILE_DROPS = GameRules.BLOCK_DROPS; /** * Whether the weather will change from the current moment. + * + * @deprecated renamed to {@link GameRules#ADVANCE_WEATHER} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DO_WEATHER_CYCLE = InternalAPIBridge.get().legacyGameRuleBridge(ADVANCE_WEATHER, null, null, Boolean.class); - + public static final GameRule DO_WEATHER_CYCLE = GameRules.ADVANCE_WEATHER; + /** + * Whether the player should keep items in their inventory after death. + * + * @deprecated renamed to {@link GameRules#KEEP_INVENTORY} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule KEEP_INVENTORY = GameRules.KEEP_INVENTORY; + /** + * Whether to log admin commands to server log. + * + * @deprecated renamed to {@link GameRules#LOG_ADMIN_COMMANDS} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule LOG_ADMIN_COMMANDS = GameRules.LOG_ADMIN_COMMANDS; + /** + * Whether mobs can pick up items or change blocks. + * + * @deprecated renamed to {@link GameRules#MOB_GRIEFING} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule MOB_GRIEFING = GameRules.MOB_GRIEFING; /** * Whether players can regenerate health naturally through their hunger bar. + * + * @deprecated renamed to {@link GameRules#NATURAL_HEALTH_REGENERATION} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule NATURAL_REGENERATION = InternalAPIBridge.get().legacyGameRuleBridge(NATURAL_HEALTH_REGENERATION, null, null, Boolean.class); - + public static final GameRule NATURAL_REGENERATION = GameRules.NATURAL_HEALTH_REGENERATION; + /** + * Whether the debug screen shows all or reduced information. + * + * @deprecated renamed to {@link GameRules#REDUCED_DEBUG_INFO} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule REDUCED_DEBUG_INFO = GameRules.REDUCED_DEBUG_INFO; + /** + * Whether the feedback from commands executed by a player should show up in + * chat. Also affects the default behavior of whether command blocks store + * their output text. + * + * @deprecated renamed to {@link GameRules#SEND_COMMAND_FEEDBACK} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SEND_COMMAND_FEEDBACK = GameRules.SEND_COMMAND_FEEDBACK; + /** + * Whether a message appears in chat when a player dies. + * + * @deprecated renamed to {@link GameRules#SHOW_DEATH_MESSAGES} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SHOW_DEATH_MESSAGES = GameRules.SHOW_DEATH_MESSAGES; + /** + * Whether players in spectator mode can generate chunks. + * + * @deprecated renamed to {@link GameRules#SPECTATORS_GENERATE_CHUNKS} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SPECTATORS_GENERATE_CHUNKS = GameRules.SPECTATORS_GENERATE_CHUNKS; /** * Whether pillager raids are enabled or not. + * + * @deprecated renamed to {@link GameRules#RAIDS} (inverted) */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DISABLE_RAIDS = InternalAPIBridge.get().legacyGameRuleBridge(RAIDS, inverseBool(), inverseBool(), Boolean.class); - + public static final GameRule DISABLE_RAIDS = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.RAIDS, inverseBool(), inverseBool(), Boolean.class); /** * Whether phantoms will appear without sleeping or not. + * + * @deprecated renamed to {@link GameRules#SPAWN_PHANTOMS} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DO_INSOMNIA = InternalAPIBridge.get().legacyGameRuleBridge(SPAWN_PHANTOMS, null, null, Boolean.class); - + public static final GameRule DO_INSOMNIA = GameRules.SPAWN_PHANTOMS; /** * Whether clients will respawn immediately after death or not. + * + * @deprecated renamed to {@link GameRules#IMMEDIATE_RESPAWN} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DO_IMMEDIATE_RESPAWN = InternalAPIBridge.get().legacyGameRuleBridge(IMMEDIATE_RESPAWN, null, null, Boolean.class); - + public static final GameRule DO_IMMEDIATE_RESPAWN = GameRules.IMMEDIATE_RESPAWN; + /** + * Whether drowning damage is enabled or not. + * + * @deprecated renamed to {@link GameRules#DROWNING_DAMAGE} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DROWNING_DAMAGE = GameRules.DROWNING_DAMAGE; + /** + * Whether fall damage is enabled or not. + * + * @deprecated renamed to {@link GameRules#FALL_DAMAGE} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule FALL_DAMAGE = GameRules.FALL_DAMAGE; + /** + * Whether fire damage is enabled or not. + * + * @deprecated renamed to {@link GameRules#FIRE_DAMAGE} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule FIRE_DAMAGE = GameRules.FIRE_DAMAGE; + /** + * Whether freeze damage is enabled or not. + * + * @deprecated renamed to {@link GameRules#FREEZE_DAMAGE} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule FREEZE_DAMAGE = GameRules.FREEZE_DAMAGE; /** * Whether patrols should naturally spawn. + * + * @deprecated renamed to {@link GameRules#SPAWN_PATROLS} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DO_PATROL_SPAWNING = InternalAPIBridge.get().legacyGameRuleBridge(SPAWN_PATROLS, null, null, Boolean.class); - + public static final GameRule DO_PATROL_SPAWNING = GameRules.SPAWN_PATROLS; /** * Whether traders should naturally spawn. + * + * @deprecated renamed to {@link GameRules#SPAWN_WANDERING_TRADERS} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DO_TRADER_SPAWNING = InternalAPIBridge.get().legacyGameRuleBridge(SPAWN_WANDERING_TRADERS, null, null, Boolean.class); - + public static final GameRule DO_TRADER_SPAWNING = GameRules.SPAWN_WANDERING_TRADERS; /** * Whether wardens should naturally spawn. + * + * @deprecated renamed to {@link GameRules#SPAWN_WARDENS} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_WARDEN_SPAWNING = GameRules.SPAWN_WARDENS; + /** + * Whether mobs should cease being angry at a player once they die. + * + * @deprecated renamed to {@link GameRules#FORGIVE_DEAD_PLAYERS} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule FORGIVE_DEAD_PLAYERS = GameRules.FORGIVE_DEAD_PLAYERS; + /** + * Whether mobs will target all player entities once angered. + * + * @deprecated renamed to {@link GameRules#UNIVERSAL_ANGER} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule UNIVERSAL_ANGER = GameRules.UNIVERSAL_ANGER; + /** + * Whether block explosions will destroy dropped items. + * + * @deprecated renamed to {@link GameRules#BLOCK_EXPLOSION_DROP_DECAY} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule BLOCK_EXPLOSION_DROP_DECAY = GameRules.BLOCK_EXPLOSION_DROP_DECAY; + /** + * * Whether mob explosions will destroy dropped items. + * + * @deprecated renamed to {@link GameRules#MOB_EXPLOSION_DROP_DECAY} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule MOB_EXPLOSION_DROP_DECAY = GameRules.MOB_EXPLOSION_DROP_DECAY; + /** + * Whether tnt explosions will destroy dropped items. + * + * @deprecated renamed to {@link GameRules#TNT_EXPLOSION_DROP_DECAY} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule TNT_EXPLOSION_DROP_DECAY = GameRules.TNT_EXPLOSION_DROP_DECAY; + /** + * Whether water blocks can convert into water source blocks. + * + * @deprecated renamed to {@link GameRules#WATER_SOURCE_CONVERSION} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule WATER_SOURCE_CONVERSION = GameRules.WATER_SOURCE_CONVERSION; + /** + * Whether lava blocks can convert into lava source blocks. + * + * @deprecated renamed to {@link GameRules#LAVA_SOURCE_CONVERSION} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule LAVA_SOURCE_CONVERSION = GameRules.LAVA_SOURCE_CONVERSION; + /** + * Whether global level events such as ender dragon, wither, and completed + * end portal effects will propagate across the entire server. + * + * @deprecated renamed to {@link GameRules#GLOBAL_SOUND_EVENTS} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DO_WARDEN_SPAWNING = InternalAPIBridge.get().legacyGameRuleBridge(SPAWN_WARDENS, null, null, Boolean.class); + public static final GameRule GLOBAL_SOUND_EVENTS = GameRules.GLOBAL_SOUND_EVENTS; /** * Whether vines will spread. + * + * @deprecated renamed to {@link GameRules#SPREAD_VINES} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_VINES_SPREAD = GameRules.SPREAD_VINES; + /** + * Whether ender pearls will vanish on player death. + * + * @deprecated renamed to {@link GameRules#ENDER_PEARLS_VANISH_ON_DEATH} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DO_VINES_SPREAD = InternalAPIBridge.get().legacyGameRuleBridge(SPREAD_VINES, null, null, Boolean.class); + public static final GameRule ENDER_PEARLS_VANISH_ON_DEATH = GameRules.ENDER_PEARLS_VANISH_ON_DEATH; /** * Whether fire will still propagate far away from players (8 chunks). + * + * @deprecated use {@link GameRules#FIRE_SPREAD_RADIUS_AROUND_PLAYER} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule ALLOW_FIRE_TICKS_AWAY_FROM_PLAYER = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.FIRE_SPREAD_RADIUS_AROUND_PLAYER, (value) -> value ? 128 : 0, (value) -> value != 0, Boolean.class); + /** + * Whether primed tnt explodes. + * + * @deprecated renamed to {@link GameRules#TNT_EXPLODES} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule ALLOW_FIRE_TICKS_AWAY_FROM_PLAYER = InternalAPIBridge.get().legacyGameRuleBridge(FIRE_SPREAD_RADIUS_AROUND_PLAYER, (value) -> value ? 128 : 0, (value) -> value != 0, Boolean.class); + public static final GameRule TNT_EXPLODES = GameRules.TNT_EXPLODES; + /** + * Configures if the world uses the locator bar. + * + * @deprecated renamed to {@link GameRules#LOCATOR_BAR} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule LOCATOR_BAR = GameRules.LOCATOR_BAR; + /** + * Whether player versus player combat is allowed. + * + * @deprecated renamed to {@link GameRules#PVP} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule PVP = GameRules.PVP; + /** + * Whether monsters should naturally spawn. + * + * @deprecated renamed to {@link GameRules#SPAWN_MONSTERS} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SPAWN_MONSTERS = GameRules.SPAWN_MONSTERS; + /** + * Whether players can enter the Nether using portals. + * + * @deprecated renamed to {@link GameRules#ALLOW_ENTERING_NETHER_USING_PORTALS} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule ALLOW_ENTERING_NETHER_USING_PORTALS = GameRules.ALLOW_ENTERING_NETHER_USING_PORTALS; + /** + * Whether command blocks are enabled. + * + * @deprecated renamed to {@link GameRules#COMMAND_BLOCKS_WORK} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule COMMAND_BLOCKS_ENABLED = GameRules.COMMAND_BLOCKS_WORK; + /** + * Whether spawner blocks are enabled. + * + * @deprecated renamed to {@link GameRules#SPAWNER_BLOCKS_WORK} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SPAWNER_BLOCKS_ENABLED = GameRules.SPAWNER_BLOCKS_WORK; + // Numerical rules + /** + * How often a random block tick occurs (such as plant growth, leaf decay, + * etc.) per chunk section per game tick. 0 will disable random ticks, + * higher numbers will increase random ticks. + * + * @deprecated renamed to {@link GameRules#RANDOM_TICK_SPEED} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule RANDOM_TICK_SPEED = GameRules.RANDOM_TICK_SPEED; /** * The number of blocks outward from the world spawn coordinates that a * player will spawn in when first joining a server or when dying without a * spawnpoint. + * + * @deprecated renamed to {@link GameRules#RESPAWN_RADIUS} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule SPAWN_RADIUS = InternalAPIBridge.get().legacyGameRuleBridge(RESPAWN_RADIUS, null, null, Integer.class); - + public static final GameRule SPAWN_RADIUS = GameRules.RESPAWN_RADIUS; + /** + * The maximum number of other pushable entities a mob or player can push, + * before taking suffocation damage. + *
+ * Setting to 0 disables this rule. + * + * @deprecated renamed to {@link GameRules#MAX_ENTITY_CRAMMING} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule MAX_ENTITY_CRAMMING = GameRules.MAX_ENTITY_CRAMMING; /** * Determines the number at which the chain of command blocks act as a * "chain." *
* This is the maximum amount of command blocks that can be activated in a * single tick from a single chain. + * + * @deprecated renamed to {@link GameRules#MAX_COMMAND_SEQUENCE_LENGTH} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule MAX_COMMAND_CHAIN_LENGTH = InternalAPIBridge.get().legacyGameRuleBridge(MAX_COMMAND_SEQUENCE_LENGTH, null, null, Integer.class); - + public static final GameRule MAX_COMMAND_CHAIN_LENGTH = GameRules.MAX_COMMAND_SEQUENCE_LENGTH; /** * Determines the number of different commands/functions which execute * commands can fork into. + * + * @deprecated renamed to {@link GameRules#MAX_COMMAND_FORKS} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule MAX_COMMAND_FORK_COUNT = InternalAPIBridge.get().legacyGameRuleBridge(MAX_COMMAND_FORKS, null, null, Integer.class); - + public static final GameRule MAX_COMMAND_FORK_COUNT = GameRules.MAX_COMMAND_FORKS; /** * Determines the maximum number of blocks which a command can modify. + * + * @deprecated renamed to {@link GameRules#MAX_BLOCK_MODIFICATIONS} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule COMMAND_MODIFICATION_BLOCK_LIMIT = InternalAPIBridge.get().legacyGameRuleBridge(MAX_BLOCK_MODIFICATIONS, null, null, Integer.class); - + public static final GameRule COMMAND_MODIFICATION_BLOCK_LIMIT = GameRules.MAX_BLOCK_MODIFICATIONS; + /** + * The percentage of online players which must be sleeping for the night to + * advance. + * + * @deprecated renamed to {@link GameRules#PLAYERS_SLEEPING_PERCENTAGE} + */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule SNOW_ACCUMULATION_HEIGHT = InternalAPIBridge.get().legacyGameRuleBridge(MAX_SNOW_ACCUMULATION_HEIGHT, null, null, Integer.class); - + public static final GameRule PLAYERS_SLEEPING_PERCENTAGE = GameRules.PLAYERS_SLEEPING_PERCENTAGE; /** - * The maximum speed of minecarts (when the new movement algorithm is - * enabled). + * @deprecated renamed to {@link GameRules#MAX_SNOW_ACCUMULATION_HEIGHT} */ - @MinecraftExperimental(MinecraftExperimental.Requires.MINECART_IMPROVEMENTS) // Paper - add missing annotation - @org.jetbrains.annotations.ApiStatus.Experimental // Paper - add missing annotation @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule MINECART_MAX_SPEED = InternalAPIBridge.get().legacyGameRuleBridge(MAX_MINECART_SPEED, null, null, Integer.class); - + public static final GameRule SNOW_ACCUMULATION_HEIGHT = GameRules.MAX_SNOW_ACCUMULATION_HEIGHT; /** - * Whether command blocks are enabled. + * The amount of time a player must stand in a nether portal before the + * portal activates. + * + * @deprecated renamed to {@link GameRules#PLAYERS_NETHER_PORTAL_DEFAULT_DELAY} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule COMMAND_BLOCKS_ENABLED = InternalAPIBridge.get().legacyGameRuleBridge(COMMAND_BLOCKS_WORK, null, null, Boolean.class); - + public static final GameRule PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = GameRules.PLAYERS_NETHER_PORTAL_DEFAULT_DELAY; /** - * Whether spawner blocks are enabled. + * The amount of time a player in creative mode must stand in a nether + * portal before the portal activates. + * + * @deprecated renamed to {@link GameRules#PLAYERS_NETHER_PORTAL_CREATIVE_DELAY} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule SPAWNER_BLOCKS_ENABLED = InternalAPIBridge.get().legacyGameRuleBridge(SPAWNER_BLOCKS_WORK, null, null, Boolean.class); + public static final GameRule PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = GameRules.PLAYERS_NETHER_PORTAL_CREATIVE_DELAY; + /** + * The maximum speed of minecarts (when the new movement algorithm is + * enabled). + * + * @deprecated renamed to {@link GameRules#MAX_MINECART_SPEED} + */ + @MinecraftExperimental(MinecraftExperimental.Requires.MINECART_IMPROVEMENTS) + @ApiStatus.Experimental + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule MINECART_MAX_SPEED = GameRules.MAX_MINECART_SPEED; private static UnaryOperator inverseBool() { return operand -> !operand; @@ -329,8 +474,10 @@ private static UnaryOperator inverseBool() { * Get the name of this GameRule. * * @return the name of this GameRule + * @deprecated Game rule is now a registry, use {@link #getKey()} instead */ @NotNull + @Deprecated(since = "1.21.11", forRemoval = true) public abstract String getName(); /** @@ -347,27 +494,30 @@ private static UnaryOperator inverseBool() { * @param rule the name of the GameRule * @return the {@link GameRule} or null if no GameRule matches the given * name + * @deprecated Game rule is now a registry, fetch element from it */ @Nullable + @Deprecated(since = "1.21.11", forRemoval = true) public static GameRule getByName(@NotNull String rule) { - Preconditions.checkNotNull(rule, "Rule cannot be null"); - try { - return (GameRule) RegistryAccess.registryAccess().getRegistry(RegistryKey.GAME_RULE).getOrThrow(NamespacedKey.fromString(rule)); - } catch (IllegalArgumentException | NoSuchElementException e) { + Preconditions.checkArgument(rule != null, "Rule cannot be null"); + NamespacedKey key = NamespacedKey.fromString(rule); + if (key == null) { return null; } + + return (GameRule) Registry.GAME_RULE.get(key); } /** * Get an immutable collection of {@link GameRule}s. * * @return an immutable collection containing all registered GameRules. + * @deprecated Game rule is now a registry, fetch elements from it */ @NotNull + @Deprecated(since = "1.21.11", forRemoval = true) public static GameRule[] values() { - return RegistryAccess.registryAccess().getRegistry(RegistryKey.GAME_RULE) - .stream() - .toArray(GameRule[]::new); + return Registry.GAME_RULE.stream().toArray(GameRule[]::new); } @Override diff --git a/paper-api/src/main/java/org/bukkit/GameRules.java b/paper-api/src/main/java/org/bukkit/GameRules.java new file mode 100644 index 000000000000..c1ad190d537b --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/GameRules.java @@ -0,0 +1,141 @@ +package org.bukkit; + +import net.kyori.adventure.key.KeyPattern; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; + +/** + * All the vanilla gamerules + */ +@NullMarked +public final class GameRules { + + // Start generate - GameRules + public static final GameRule ADVANCE_TIME = getRule("advance_time"); + + public static final GameRule ADVANCE_WEATHER = getRule("advance_weather"); + + public static final GameRule ALLOW_ENTERING_NETHER_USING_PORTALS = getRule("allow_entering_nether_using_portals"); + + public static final GameRule BLOCK_DROPS = getRule("block_drops"); + + public static final GameRule BLOCK_EXPLOSION_DROP_DECAY = getRule("block_explosion_drop_decay"); + + public static final GameRule COMMAND_BLOCK_OUTPUT = getRule("command_block_output"); + + public static final GameRule COMMAND_BLOCKS_WORK = getRule("command_blocks_work"); + + public static final GameRule DROWNING_DAMAGE = getRule("drowning_damage"); + + public static final GameRule ELYTRA_MOVEMENT_CHECK = getRule("elytra_movement_check"); + + public static final GameRule ENDER_PEARLS_VANISH_ON_DEATH = getRule("ender_pearls_vanish_on_death"); + + public static final GameRule ENTITY_DROPS = getRule("entity_drops"); + + public static final GameRule FALL_DAMAGE = getRule("fall_damage"); + + public static final GameRule FIRE_DAMAGE = getRule("fire_damage"); + + public static final GameRule FIRE_SPREAD_RADIUS_AROUND_PLAYER = getRule("fire_spread_radius_around_player"); + + public static final GameRule FORGIVE_DEAD_PLAYERS = getRule("forgive_dead_players"); + + public static final GameRule FREEZE_DAMAGE = getRule("freeze_damage"); + + public static final GameRule GLOBAL_SOUND_EVENTS = getRule("global_sound_events"); + + public static final GameRule IMMEDIATE_RESPAWN = getRule("immediate_respawn"); + + public static final GameRule KEEP_INVENTORY = getRule("keep_inventory"); + + public static final GameRule LAVA_SOURCE_CONVERSION = getRule("lava_source_conversion"); + + public static final GameRule LIMITED_CRAFTING = getRule("limited_crafting"); + + public static final GameRule LOCATOR_BAR = getRule("locator_bar"); + + public static final GameRule LOG_ADMIN_COMMANDS = getRule("log_admin_commands"); + + public static final GameRule MAX_BLOCK_MODIFICATIONS = getRule("max_block_modifications"); + + public static final GameRule MAX_COMMAND_FORKS = getRule("max_command_forks"); + + public static final GameRule MAX_COMMAND_SEQUENCE_LENGTH = getRule("max_command_sequence_length"); + + public static final GameRule MAX_ENTITY_CRAMMING = getRule("max_entity_cramming"); + + @MinecraftExperimental(MinecraftExperimental.Requires.MINECART_IMPROVEMENTS) + @ApiStatus.Experimental + public static final GameRule MAX_MINECART_SPEED = getRule("max_minecart_speed"); + + public static final GameRule MAX_SNOW_ACCUMULATION_HEIGHT = getRule("max_snow_accumulation_height"); + + public static final GameRule MOB_DROPS = getRule("mob_drops"); + + public static final GameRule MOB_EXPLOSION_DROP_DECAY = getRule("mob_explosion_drop_decay"); + + public static final GameRule MOB_GRIEFING = getRule("mob_griefing"); + + public static final GameRule NATURAL_HEALTH_REGENERATION = getRule("natural_health_regeneration"); + + public static final GameRule PLAYER_MOVEMENT_CHECK = getRule("player_movement_check"); + + public static final GameRule PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = getRule("players_nether_portal_creative_delay"); + + public static final GameRule PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = getRule("players_nether_portal_default_delay"); + + public static final GameRule PLAYERS_SLEEPING_PERCENTAGE = getRule("players_sleeping_percentage"); + + public static final GameRule PROJECTILES_CAN_BREAK_BLOCKS = getRule("projectiles_can_break_blocks"); + + public static final GameRule PVP = getRule("pvp"); + + public static final GameRule RAIDS = getRule("raids"); + + public static final GameRule RANDOM_TICK_SPEED = getRule("random_tick_speed"); + + public static final GameRule REDUCED_DEBUG_INFO = getRule("reduced_debug_info"); + + public static final GameRule RESPAWN_RADIUS = getRule("respawn_radius"); + + public static final GameRule SEND_COMMAND_FEEDBACK = getRule("send_command_feedback"); + + public static final GameRule SHOW_ADVANCEMENT_MESSAGES = getRule("show_advancement_messages"); + + public static final GameRule SHOW_DEATH_MESSAGES = getRule("show_death_messages"); + + public static final GameRule SPAWN_MOBS = getRule("spawn_mobs"); + + public static final GameRule SPAWN_MONSTERS = getRule("spawn_monsters"); + + public static final GameRule SPAWN_PATROLS = getRule("spawn_patrols"); + + public static final GameRule SPAWN_PHANTOMS = getRule("spawn_phantoms"); + + public static final GameRule SPAWN_WANDERING_TRADERS = getRule("spawn_wandering_traders"); + + public static final GameRule SPAWN_WARDENS = getRule("spawn_wardens"); + + public static final GameRule SPAWNER_BLOCKS_WORK = getRule("spawner_blocks_work"); + + public static final GameRule SPECTATORS_GENERATE_CHUNKS = getRule("spectators_generate_chunks"); + + public static final GameRule SPREAD_VINES = getRule("spread_vines"); + + public static final GameRule TNT_EXPLODES = getRule("tnt_explodes"); + + public static final GameRule TNT_EXPLOSION_DROP_DECAY = getRule("tnt_explosion_drop_decay"); + + public static final GameRule UNIVERSAL_ANGER = getRule("universal_anger"); + + public static final GameRule WATER_SOURCE_CONVERSION = getRule("water_source_conversion"); + // End generate - GameRules + + private static GameRule getRule(@KeyPattern.Value String key) { + return (GameRule) Registry.GAME_RULE.getOrThrow(NamespacedKey.minecraft(key)); + } + + private GameRules() { + } +} diff --git a/paper-api/src/main/java/org/bukkit/Server.java b/paper-api/src/main/java/org/bukkit/Server.java index 964b57bb2401..3b98f224e31f 100644 --- a/paper-api/src/main/java/org/bukkit/Server.java +++ b/paper-api/src/main/java/org/bukkit/Server.java @@ -243,7 +243,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi * Separate from the portal game rule. * * @return whether this server allows the Nether or not - * @see GameRule#ALLOW_ENTERING_NETHER_USING_PORTALS + * @see GameRules#ALLOW_ENTERING_NETHER_USING_PORTALS */ public boolean getAllowNether(); diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index 674d9abb16c0..54c0d40c8bee 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -2288,7 +2288,7 @@ default boolean createExplosion(double x, double y, double z, float power, boole *

* Note that if a non-null {@code source} Entity is provided and {@code * breakBlocks} is {@code true}, the value of {@code breakBlocks} will be - * ignored if {@link GameRule#MOB_GRIEFING} is {@code false} in the world + * ignored if {@link GameRules#MOB_GRIEFING} is {@code false} in the world * in which the explosion occurs. In other words, the mob griefing gamerule * will take priority over {@code breakBlocks} if explosions are not allowed. * @@ -2445,7 +2445,7 @@ default boolean createExplosion(@NotNull Location loc, float power, boolean setF *

* Note that if a non-null {@code source} Entity is provided and {@code * breakBlocks} is {@code true}, the value of {@code breakBlocks} will be - * ignored if {@link GameRule#MOB_GRIEFING} is {@code false} in the world + * ignored if {@link GameRules#MOB_GRIEFING} is {@code false} in the world * in which the explosion occurs. In other words, the mob griefing gamerule * will take priority over {@code breakBlocks} if explosions are not allowed. * @@ -2462,7 +2462,7 @@ default boolean createExplosion(@NotNull Location loc, float power, boolean setF * Gets the current PVP setting for this world. * * @return True if PVP is enabled - * @deprecated use {@link GameRule#PVP} instead + * @deprecated use {@link GameRules#PVP} instead */ @Deprecated(since = "1.21.9") public boolean getPVP(); @@ -2471,7 +2471,7 @@ default boolean createExplosion(@NotNull Location loc, float power, boolean setF * Sets the PVP setting for this world. * * @param pvp True/False whether PVP should be Enabled. - * @deprecated use {@link GameRule#PVP} instead + * @deprecated use {@link GameRules#PVP} instead */ @Deprecated(since = "1.21.9") public void setPVP(boolean pvp); diff --git a/paper-api/src/main/java/org/bukkit/command/Command.java b/paper-api/src/main/java/org/bukkit/command/Command.java index e387ba67f0b6..2bc493846bd8 100644 --- a/paper-api/src/main/java/org/bukkit/command/Command.java +++ b/paper-api/src/main/java/org/bukkit/command/Command.java @@ -8,6 +8,7 @@ import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.GameRule; +import org.bukkit.GameRules; import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.entity.Player; @@ -477,14 +478,14 @@ public static void broadcastCommandMessage(@NotNull CommandSender source, net.ky if (source instanceof BlockCommandSender) { BlockCommandSender blockCommandSender = (BlockCommandSender) source; - if (!blockCommandSender.getBlock().getWorld().getGameRuleValue(GameRule.COMMAND_BLOCK_OUTPUT)) { + if (!blockCommandSender.getBlock().getWorld().getGameRuleValue(GameRules.COMMAND_BLOCK_OUTPUT)) { Bukkit.getConsoleSender().sendMessage(result); return; } } else if (source instanceof CommandMinecart) { CommandMinecart commandMinecart = (CommandMinecart) source; - if (!commandMinecart.getWorld().getGameRuleValue(GameRule.COMMAND_BLOCK_OUTPUT)) { + if (!commandMinecart.getWorld().getGameRuleValue(GameRules.COMMAND_BLOCK_OUTPUT)) { Bukkit.getConsoleSender().sendMessage(result); return; } diff --git a/paper-api/src/main/java/org/bukkit/entity/Minecart.java b/paper-api/src/main/java/org/bukkit/entity/Minecart.java index 0e4163c9358d..160a083c1b3b 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Minecart.java +++ b/paper-api/src/main/java/org/bukkit/entity/Minecart.java @@ -1,6 +1,7 @@ package org.bukkit.entity; import org.bukkit.GameRule; +import org.bukkit.GameRules; import org.bukkit.Material; import org.bukkit.block.data.BlockData; import org.bukkit.material.MaterialData; @@ -37,7 +38,7 @@ public interface Minecart extends Vehicle, io.papermc.paper.entity.Frictional { /** * Sets the maximum speed of a minecart. Must be nonnegative. Default is - * 0.4D or {@link GameRule#MINECART_MAX_SPEED}. + * 0.4D or {@link GameRules#MAX_MINECART_SPEED}. * * @param speed The max speed */ diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java index 96444dac986a..11d5e8b21e5a 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java @@ -16,7 +16,7 @@ * an air block. {@link #getExplodedBlockState()} should be used to get * information about the block state that exploded. *

- * The event isn't called if the {@link org.bukkit.GameRule#MOB_GRIEFING} + * The event isn't called if the {@link org.bukkit.GameRules#MOB_GRIEFING} * is disabled as no block interaction will occur. */ public class BlockExplodeEvent extends BlockEvent implements Cancellable { diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java index 4fa6689f53bd..456ca29c92b6 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java @@ -476,7 +476,7 @@ public enum DamageCause { CAMPFIRE, /** * Damage caused when an entity is colliding with too many entities due - * to the {@link org.bukkit.GameRule#MAX_ENTITY_CRAMMING}. + * to the {@link org.bukkit.GameRules#MAX_ENTITY_CRAMMING}. *

* Damage: 6 */ diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java index 9a8f5f6dca26..84950b371521 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java @@ -12,7 +12,7 @@ /** * Called when an entity explodes interacting with blocks. The - * event isn't called if the {@link org.bukkit.GameRule#MOB_GRIEFING} + * event isn't called if the {@link org.bukkit.GameRules#MOB_GRIEFING} * is disabled as no block interaction will occur. */ public class EntityExplodeEvent extends EntityEvent implements Cancellable { diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java index 6316a2f1d2dc..78497c423eda 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java @@ -92,7 +92,7 @@ public Player getEntity() { /** * Get whether the death message should be shown. - * By default, this is determined by {@link org.bukkit.GameRule#SHOW_DEATH_MESSAGES}. + * By default, this is determined by {@link org.bukkit.GameRules#SHOW_DEATH_MESSAGES}. * * @return whether the death message should be shown * @see #deathMessage() @@ -104,7 +104,7 @@ public boolean getShowDeathMessages() { /** * Set whether the death message should be shown. - * By default, this is determined by {@link org.bukkit.GameRule#SHOW_DEATH_MESSAGES}. + * By default, this is determined by {@link org.bukkit.GameRules#SHOW_DEATH_MESSAGES}. * * @param displayDeathMessage whether the death message should be shown * @see #deathMessage() diff --git a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java index 8cd7fe67e1bd..d505ca8a76dd 100644 --- a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java +++ b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java @@ -16,7 +16,6 @@ import io.papermc.generator.rewriter.types.simple.CraftBlockEntityStateMapping; import io.papermc.generator.rewriter.types.simple.CraftPotionUtilRewriter; import io.papermc.generator.rewriter.types.simple.EntityTypeRewriter; -import io.papermc.generator.rewriter.types.simple.GameRuleTypeRewriter; import io.papermc.generator.rewriter.types.simple.MapPaletteRewriter; import io.papermc.generator.rewriter.types.simple.MaterialRewriter; import io.papermc.generator.rewriter.types.simple.MemoryKeyRewriter; @@ -51,6 +50,7 @@ import org.bukkit.Fluid; import org.bukkit.GameEvent; import org.bukkit.GameRule; +import org.bukkit.GameRules; import org.bukkit.JukeboxSong; import org.bukkit.Material; import org.bukkit.MusicInstrument; @@ -192,6 +192,14 @@ protected String rewriteFieldName(Holder.Reference(Registries.GAME_RULE, "getRule") { + @Override + protected String rewriteFieldType(Holder.Reference> reference) { + return "%s<%s>".formatted( + this.registryEntry.apiClass().getSimpleName(), this.importCollector.getShortName(reference.value().valueClass()) + ); + } + }) .register("DamageTypeTags", DamageTypeTags.class, new RegistryTagRewriter<>(Registries.DAMAGE_TYPE, DamageType.class)) .register("MapCursorType", MapCursor.Type.class, new RegistryFieldRewriter<>(Registries.MAP_DECORATION_TYPE, "getType")) .register("Structure", Structure.class, new RegistryFieldRewriter<>(Registries.STRUCTURE, "getStructure")) @@ -217,7 +225,6 @@ protected String rewriteFieldName(Holder.Reference(Registries.ZOMBIE_NAUTILUS_VARIANT, "getVariant")) .register("Dialog", Dialog.class, new RegistryFieldRewriter<>(Registries.DIALOG, "getDialog")) .register("MemoryKey", MemoryKey.class, new MemoryKeyRewriter()) - .register("GameRule", GameRule.class, new GameRuleTypeRewriter()) // .register("ItemType", org.bukkit.inventory.ItemType.class, new io.papermc.generator.rewriter.types.simple.ItemTypeRewriter()) - disable for now, lynx want the generic type .register("BlockType", BlockType.class, new BlockTypeRewriter()) .register("FeatureFlag", FeatureFlag.class, new FeatureFlagRewriter()) diff --git a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java index f9ef6646bef3..87570724f4b6 100644 --- a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java +++ b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java @@ -170,7 +170,7 @@ private static RegistryEntry inconsistentEntry(ResourceKey> DATA_DRIVEN = List.of( diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/GameRuleTypeRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/GameRuleTypeRewriter.java deleted file mode 100644 index a9746adc583d..000000000000 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/GameRuleTypeRewriter.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.papermc.generator.rewriter.types.simple; - -import io.papermc.generator.rewriter.types.registry.RegistryFieldRewriter; -import net.minecraft.core.Holder; -import net.minecraft.core.registries.Registries; -import net.minecraft.world.level.gamerules.GameRule; - -public class GameRuleTypeRewriter extends RegistryFieldRewriter> { - - public GameRuleTypeRewriter() { - super(Registries.GAME_RULE, "getByName"); - } - - @Override - protected String rewriteFieldType(Holder.Reference> reference) { - return "%s<%s>".formatted(this.registryEntry.apiClass().getSimpleName(), this.importCollector.getShortName(reference.value().valueClass())); - } -} diff --git a/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java b/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java index afad46f7b927..f7979f188c3d 100644 --- a/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java +++ b/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java @@ -113,7 +113,7 @@ public Component defaultMannequinDescription() { } @Override - public GameRule legacyGameRuleBridge(GameRule rule, @Nullable Function fromLegacyToModern, @Nullable Function toLegacyFromModern, Class legacyClass) { + public GameRule legacyGameRuleBridge(GameRule rule, Function fromLegacyToModern, Function toLegacyFromModern, Class legacyClass) { return CraftGameRule.wrap(rule, fromLegacyToModern, toLegacyFromModern, legacyClass); } } diff --git a/paper-server/src/main/java/io/papermc/paper/event/world/PaperWorldGameRuleChangeEvent.java b/paper-server/src/main/java/io/papermc/paper/event/world/PaperWorldGameRuleChangeEvent.java new file mode 100644 index 000000000000..62f3e7a4df19 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/event/world/PaperWorldGameRuleChangeEvent.java @@ -0,0 +1,24 @@ +package io.papermc.paper.event.world; + +import org.bukkit.GameRule; +import org.bukkit.World; +import org.bukkit.command.CommandSender; +import org.bukkit.craftbukkit.CraftGameRule; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +public class PaperWorldGameRuleChangeEvent extends WorldGameRuleChangeEvent { + + public PaperWorldGameRuleChangeEvent(final World world, final @Nullable CommandSender commandSender, final GameRule gameRule, final String value) { + super(world, commandSender, gameRule, value); + } + + @Override + public void setValue(final String value) { + ((CraftGameRule) this.gameRule).getHandle().deserialize(value).ifError(error -> { + throw new IllegalArgumentException("Invalid value: %s (%s)".formatted(value, error.message())); + }); + super.setValue(value); + } +} diff --git a/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java b/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java index 098da4a8bd86..c0953bb67dcf 100644 --- a/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java @@ -4,12 +4,10 @@ import com.google.common.collect.ImmutableBiMap; import java.util.Collections; import java.util.HashSet; -import java.util.Map; import java.util.Set; import net.minecraft.world.flag.FeatureElement; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; -import net.minecraft.world.level.gamerules.GameRules; import org.bukkit.FeatureFlag; import org.bukkit.GameRule; import org.bukkit.craftbukkit.CraftGameRule; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java index d4e1455e2bc8..72992fc61410 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java @@ -7,7 +7,6 @@ import org.bukkit.GameRule; import org.bukkit.NamespacedKey; import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; @NullMarked public class CraftGameRule extends GameRule implements Holderable> { @@ -20,7 +19,7 @@ public static net.minecraft.world.level.gamerules.GameRule bukkitToMinecr return CraftRegistry.bukkitToMinecraft(bukkit); } - public static Holder> bukkitToMinecraftHolder(GameRule bukkit) { + public static Holder> bukkitToMinecraftHolder(GameRule bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } @@ -31,8 +30,9 @@ public CraftGameRule(Holder> hol this.holder = (Holder) holder; } - public static GameRule wrap(GameRule rule, @Nullable Function fromLegacyToModern, @Nullable Function toLegacyFromModern, Class legacyClass) { - return new LegacyGameRuleWrapper<>(bukkitToMinecraftHolder(rule), fromLegacyToModern, toLegacyFromModern, legacyClass); + @SuppressWarnings("unchecked") + public static GameRule wrap(GameRule rule, Function fromLegacyToModern, Function toLegacyFromModern, Class legacyClass) { + return new LegacyGameRuleWrapper<>(((CraftGameRule) rule).getHolder(), fromLegacyToModern, toLegacyFromModern, legacyClass); } @Override @@ -82,23 +82,22 @@ public String translationKey() { public static class LegacyGameRuleWrapper extends CraftGameRule { private final Class typeOverride; - private final @Nullable Function fromLegacyToModern; - private final @Nullable Function toLegacyFromModern; + private final Function fromLegacyToModern; + private final Function toLegacyFromModern; - public LegacyGameRuleWrapper(Holder> holder, @Nullable Function fromLegacyToModern, @Nullable Function toLegacyFromModern, Class typeOverride) { + public LegacyGameRuleWrapper(Holder> holder, Function fromLegacyToModern, Function toLegacyFromModern, Class typeOverride) { super(holder); this.fromLegacyToModern = fromLegacyToModern; this.toLegacyFromModern = toLegacyFromModern; this.typeOverride = typeOverride; } - - public @Nullable Function getFromLegacyToModern() { - return fromLegacyToModern; + public Function getFromLegacyToModern() { + return this.fromLegacyToModern; } - public @Nullable Function getToLegacyFromModern() { - return toLegacyFromModern; + public Function getToLegacyFromModern() { + return this.toLegacyFromModern; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index fdda5078442b..9e7c294e9ef5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1656,13 +1656,13 @@ public String getGameRuleValue(String rule) { if (rule == null) { return null; } - GameRule nms = CraftGameRule.bukkitToMinecraft(org.bukkit.GameRule.getByName(rule)); - GameRules gameRules = this.getHandle().getGameRules(); - if (!gameRules.rules.has(nms)) { - return ""; + + org.bukkit.GameRule bukkit = org.bukkit.GameRule.getByName(rule); + if (bukkit == null) { + throw new IllegalArgumentException("Unknown gamerule: " + rule); } - return gameRules.getAsString(nms); + return this.getHandle().getGameRules().getAsString(CraftGameRule.bukkitToMinecraft(bukkit)); } @SuppressWarnings({"unchecked", "rawtypes"}) @@ -1671,12 +1671,15 @@ public boolean setGameRuleValue(String rule, String value) { // No null values allowed if (rule == null || value == null) return false; - if (!this.isGameRule(rule)) return false; - // Paper start - Add WorldGameRuleChangeEvent org.bukkit.GameRule bukkit = org.bukkit.GameRule.getByName(rule); + if (bukkit == null) { + return false; + } GameRule nms = CraftGameRule.bukkitToMinecraft(bukkit); - + if (!this.getHandle().getGameRules().rules.has(nms)) { + return false; + } return !CraftEventFactory.handleGameRuleSet(nms, nms.deserialize(value).getOrThrow(), this.getHandle(), null).cancelled(); } @@ -1692,15 +1695,18 @@ public boolean isGameRule(String rule) { Preconditions.checkArgument(rule != null, "String rule cannot be null"); Preconditions.checkArgument(!rule.isEmpty(), "String rule cannot be empty"); - GameRule nms = CraftGameRule.bukkitToMinecraft(org.bukkit.GameRule.getByName(rule)); - GameRules gameRules = this.getHandle().getGameRules(); - return gameRules.rules.has(nms); + org.bukkit.GameRule bukkit = org.bukkit.GameRule.getByName(rule); + if (bukkit == null) { + return false; + } + + return this.getHandle().getGameRules().rules.has(CraftGameRule.bukkitToMinecraft(bukkit)); } public static T shimLegacyValue(T value, org.bukkit.GameRule gameRule){ - //noinspection all + //noinspection rawtypes unchecked if (gameRule instanceof CraftGameRule.LegacyGameRuleWrapper legacyGameRuleWrapper) { - //noinspection all + //noinspection unchecked return (T) legacyGameRuleWrapper.getToLegacyFromModern().apply(value); } @@ -1727,10 +1733,12 @@ public static T shimLegacyValue(T value, org.bukkit.GameRule gameRule){ public boolean setGameRule(org.bukkit.@NotNull GameRule rule, @NotNull T newValue) { Preconditions.checkArgument(rule != null, "GameRule cannot be null"); Preconditions.checkArgument(newValue != null, "GameRule value cannot be null"); + GameRule<@NotNull T> nms = CraftGameRule.bukkitToMinecraft(rule); if (!this.getHandle().getGameRules().rules.has(nms)) { return false; } + if (rule instanceof CraftGameRule.LegacyGameRuleWrapper legacyGameRuleWrapper) { newValue = (T) legacyGameRuleWrapper.getFromLegacyToModern().apply(newValue); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index e40a6c4a9db2..14e7657c04a6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -2216,13 +2216,17 @@ public static boolean callTransporterValidateTarget(final PathfinderMob mob, fin } public static GameRuleSetResult handleGameRuleSet(GameRule<@NotNull T> rule, T value, ServerLevel level, @Nullable CommandSender sender) { - final var event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent( - level.getWorld(), - sender, - CraftGameRule.minecraftToBukkit(rule), - String.valueOf(value) + String valueStr = rule.serialize(value); + final var event = new io.papermc.paper.event.world.PaperWorldGameRuleChangeEvent( + level.getWorld(), + sender, + CraftGameRule.minecraftToBukkit(rule), + valueStr ); if (event.callEvent()) { + if (!event.getValue().equals(valueStr)) { + value = rule.deserialize(event.getValue()).getOrThrow(); // should never throw value is checked in the event + } level.getGameRules().set(rule, value, level); return new GameRuleSetResult<>(value, false); } else { diff --git a/paper-server/src/test/java/org/bukkit/GameRuleTest.java b/paper-server/src/test/java/org/bukkit/GameRuleTest.java index 2d0c87f6fc9d..aa60c2ea0a20 100644 --- a/paper-server/src/test/java/org/bukkit/GameRuleTest.java +++ b/paper-server/src/test/java/org/bukkit/GameRuleTest.java @@ -8,13 +8,12 @@ import org.junit.jupiter.api.Test; @Normal +@Deprecated public class GameRuleTest { @Test public void testBukkitRules() { - GameRule[] rules = GameRule.values(); - - for (GameRule rule : rules) { + for (GameRule rule : Registry.GAME_RULE) { GameRule registeredRule = GameRule.getByName(rule.getName()); assertNotNull(registeredRule, "Null GameRule"); assertEquals(rule, registeredRule, "Invalid GameRule equality"); @@ -23,7 +22,7 @@ public void testBukkitRules() { @Test public void nullGameRuleName() { - assertThrows(NullPointerException.class, () -> GameRule.getByName(null)); + assertThrows(IllegalArgumentException.class, () -> GameRule.getByName(null)); } @Test From ad0159f2171cfd363ba4c36947973171f33ee6e1 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 8 Nov 2025 18:30:07 +0100 Subject: [PATCH 063/112] fix allowFireTicksAwayFromPlayer backward compat --- .../src/main/java/io/papermc/paper/InternalAPIBridge.java | 3 +-- paper-api/src/main/java/org/bukkit/GameRule.java | 6 +++--- paper-api/src/main/java/org/bukkit/command/Command.java | 1 - paper-api/src/main/java/org/bukkit/entity/Minecart.java | 1 - .../src/main/java/org/bukkit/craftbukkit/CraftGameRule.java | 2 +- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java b/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java index d40229a39cad..609b4b1c7d97 100644 --- a/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java +++ b/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java @@ -99,6 +99,5 @@ class Holder { Component defaultMannequinDescription(); - GameRule legacyGameRuleBridge(GameRule rule, @Nullable Function fromLegacyToModern, @Nullable Function toLegacyFromModern, Class legacyClass); + GameRule legacyGameRuleBridge(GameRule rule, Function fromLegacyToModern, Function toLegacyFromModern, Class legacyClass); } - diff --git a/paper-api/src/main/java/org/bukkit/GameRule.java b/paper-api/src/main/java/org/bukkit/GameRule.java index 07a3cfe00cd1..032c64831f79 100644 --- a/paper-api/src/main/java/org/bukkit/GameRule.java +++ b/paper-api/src/main/java/org/bukkit/GameRule.java @@ -42,7 +42,7 @@ public abstract class GameRule implements net.kyori.adventure.translation.Tra * @deprecated renamed to {@link GameRules#PLAYER_MOVEMENT_CHECK} (inverted) */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DISABLE_PLAYER_MOVEMENT_CHECK = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.PLAYER_MOVEMENT_CHECK, inverseBool(), inverseBool(), Boolean.class); + public static final GameRule DISABLE_PLAYER_MOVEMENT_CHECK = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.PLAYER_MOVEMENT_CHECK, inverseBool(), inverseBool(), Boolean.class); /** * Whether the server should skip checking player speed when the player is * wearing elytra. @@ -50,7 +50,7 @@ public abstract class GameRule implements net.kyori.adventure.translation.Tra * @deprecated renamed to {@link GameRules#ELYTRA_MOVEMENT_CHECK} (inverted) */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule DISABLE_ELYTRA_MOVEMENT_CHECK = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.ELYTRA_MOVEMENT_CHECK, inverseBool(), inverseBool(), Boolean.class); + public static final GameRule DISABLE_ELYTRA_MOVEMENT_CHECK = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.ELYTRA_MOVEMENT_CHECK, inverseBool(), inverseBool(), Boolean.class); /** * Whether time progresses from the current moment. * @@ -320,7 +320,7 @@ public abstract class GameRule implements net.kyori.adventure.translation.Tra * @deprecated use {@link GameRules#FIRE_SPREAD_RADIUS_AROUND_PLAYER} */ @Deprecated(forRemoval = true, since = "1.21.11") - public static final GameRule ALLOW_FIRE_TICKS_AWAY_FROM_PLAYER = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.FIRE_SPREAD_RADIUS_AROUND_PLAYER, (value) -> value ? 128 : 0, (value) -> value != 0, Boolean.class); + public static final GameRule ALLOW_FIRE_TICKS_AWAY_FROM_PLAYER = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.FIRE_SPREAD_RADIUS_AROUND_PLAYER, (value) -> value ? -1 : 128, (value) -> value == -1, Boolean.class); /** * Whether primed tnt explodes. * diff --git a/paper-api/src/main/java/org/bukkit/command/Command.java b/paper-api/src/main/java/org/bukkit/command/Command.java index 2bc493846bd8..3171a20c8fcf 100644 --- a/paper-api/src/main/java/org/bukkit/command/Command.java +++ b/paper-api/src/main/java/org/bukkit/command/Command.java @@ -7,7 +7,6 @@ import java.util.List; import java.util.Set; import org.bukkit.Bukkit; -import org.bukkit.GameRule; import org.bukkit.GameRules; import org.bukkit.Location; import org.bukkit.Server; diff --git a/paper-api/src/main/java/org/bukkit/entity/Minecart.java b/paper-api/src/main/java/org/bukkit/entity/Minecart.java index 160a083c1b3b..86980343461b 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Minecart.java +++ b/paper-api/src/main/java/org/bukkit/entity/Minecart.java @@ -1,6 +1,5 @@ package org.bukkit.entity; -import org.bukkit.GameRule; import org.bukkit.GameRules; import org.bukkit.Material; import org.bukkit.block.data.BlockData; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java index 72992fc61410..ec72b7e6c71b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java @@ -11,7 +11,7 @@ @NullMarked public class CraftGameRule extends GameRule implements Holderable> { - public static GameRule minecraftToBukkit(net.minecraft.world.level.gamerules.GameRule minecraft) { + public static GameRule minecraftToBukkit(net.minecraft.world.level.gamerules.GameRule minecraft) { return CraftRegistry.minecraftToBukkit(minecraft, Registries.GAME_RULE); } From b3628c41754b1349e6b164982301ec1f637865ce Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 8 Nov 2025 18:55:20 +0100 Subject: [PATCH 064/112] use the right class holder in the generator for zombie nautilus variant --- .../java/io/papermc/generator/registry/RegistryEntries.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java index 87570724f4b6..36965af585e0 100644 --- a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java +++ b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java @@ -47,7 +47,7 @@ import net.minecraft.world.entity.animal.ChickenVariants; import net.minecraft.world.entity.animal.CowVariants; import net.minecraft.world.entity.animal.PigVariants; -import net.minecraft.world.entity.animal.ZombieNautilusVariant; +import net.minecraft.world.entity.animal.ZombieNautilusVariants; import net.minecraft.world.entity.animal.frog.FrogVariants; import net.minecraft.world.entity.animal.wolf.WolfSoundVariants; import net.minecraft.world.entity.animal.wolf.WolfVariants; @@ -191,7 +191,7 @@ private static RegistryEntry inconsistentEntry(ResourceKey Date: Sat, 8 Nov 2025 19:09:22 +0100 Subject: [PATCH 065/112] update material tags --- .../com/destroystokyo/paper/MaterialTags.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java b/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java index 96e92f3760ef..6b7ae470cf37 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java @@ -739,49 +739,49 @@ private static MaterialSetTag replacedBy(Tag vanillaTag, String legacy * Covers all Wooden Tools. */ public static final MaterialSetTag WOODEN_TOOLS = new MaterialSetTag(keyFor("wooden_tools")) - .add(Material.WOODEN_AXE, Material.WOODEN_HOE, Material.WOODEN_PICKAXE, Material.WOODEN_SHOVEL, Material.WOODEN_SWORD) - .ensureSize("WOODEN_TOOLS", 5).lock(); + .add(Material.WOODEN_AXE, Material.WOODEN_HOE, Material.WOODEN_PICKAXE, Material.WOODEN_SHOVEL, Material.WOODEN_SWORD, Material.WOODEN_SPEAR) + .lock(); /** * Covers all Stone Tools. */ public static final MaterialSetTag STONE_TOOLS = new MaterialSetTag(keyFor("stone_tools")) - .add(Material.STONE_AXE, Material.STONE_HOE, Material.STONE_PICKAXE, Material.STONE_SHOVEL, Material.STONE_SWORD) - .ensureSize("STONE_TOOLS", 5).lock(); + .add(Material.STONE_AXE, Material.STONE_HOE, Material.STONE_PICKAXE, Material.STONE_SHOVEL, Material.STONE_SWORD, Material.STONE_SPEAR) + .lock(); /** * Covers all copper Tools. */ public static final MaterialSetTag COPPER_TOOLS = new MaterialSetTag(keyFor("copper_tools")) - .add(Material.COPPER_AXE, Material.COPPER_HOE, Material.COPPER_PICKAXE, Material.COPPER_SHOVEL, Material.COPPER_SWORD) - .ensureSize("COPPER_TOOLS", 5).lock(); + .add(Material.COPPER_AXE, Material.COPPER_HOE, Material.COPPER_PICKAXE, Material.COPPER_SHOVEL, Material.COPPER_SWORD, Material.COPPER_SPEAR) + .lock(); /** * Covers all Iron Tools. */ public static final MaterialSetTag IRON_TOOLS = new MaterialSetTag(keyFor("iron_tools")) - .add(Material.IRON_AXE, Material.IRON_HOE, Material.IRON_PICKAXE, Material.IRON_SHOVEL, Material.IRON_SWORD) - .ensureSize("IRON_TOOLS", 5).lock(); + .add(Material.IRON_AXE, Material.IRON_HOE, Material.IRON_PICKAXE, Material.IRON_SHOVEL, Material.IRON_SWORD, Material.IRON_SPEAR) + .lock(); /** * Covers all Gold Tools. */ public static final MaterialSetTag GOLDEN_TOOLS = new MaterialSetTag(keyFor("golden_tools")) - .add(Material.GOLDEN_AXE, Material.GOLDEN_HOE, Material.GOLDEN_PICKAXE, Material.GOLDEN_SHOVEL, Material.GOLDEN_SWORD) - .ensureSize("GOLDEN_TOOLS", 5).lock(); + .add(Material.GOLDEN_AXE, Material.GOLDEN_HOE, Material.GOLDEN_PICKAXE, Material.GOLDEN_SHOVEL, Material.GOLDEN_SWORD, Material.GOLDEN_SPEAR) + .lock(); /** * Covers all Diamond Tools. */ public static final MaterialSetTag DIAMOND_TOOLS = new MaterialSetTag(keyFor("diamond_tools")) - .add(Material.DIAMOND_AXE, Material.DIAMOND_HOE, Material.DIAMOND_PICKAXE, Material.DIAMOND_SHOVEL, Material.DIAMOND_SWORD) - .ensureSize("DIAMOND_TOOLS", 5).lock(); + .add(Material.DIAMOND_AXE, Material.DIAMOND_HOE, Material.DIAMOND_PICKAXE, Material.DIAMOND_SHOVEL, Material.DIAMOND_SWORD, Material.DIAMOND_SPEAR) + .lock(); /** * Covers all Netherite Tools. */ public static final MaterialSetTag NETHERITE_TOOLS = new MaterialSetTag(keyFor("netherite_tools")) - .add(Material.NETHERITE_AXE, Material.NETHERITE_HOE, Material.NETHERITE_PICKAXE, Material.NETHERITE_SHOVEL, Material.NETHERITE_SWORD) - .ensureSize("NETHERITE_TOOLS", 5).lock(); + .add(Material.NETHERITE_AXE, Material.NETHERITE_HOE, Material.NETHERITE_PICKAXE, Material.NETHERITE_SHOVEL, Material.NETHERITE_SWORD, Material.NETHERITE_SPEAR) + .lock(); } From 0196386152dc2643e2ae11b41295ed14b290a991 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 8 Nov 2025 19:15:08 +0100 Subject: [PATCH 066/112] add missing enchantment --- .../src/main/java/org/bukkit/enchantments/Enchantment.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java b/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java index 4a6c44c65fa7..2f995a77e876 100644 --- a/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java +++ b/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java @@ -229,6 +229,11 @@ public abstract class Enchantment implements Keyed, Translatable, net.kyori.adve */ public static final Enchantment SWIFT_SNEAK = getEnchantment("swift_sneak"); + /** + * Causes a jab attack from a spear to propel the user into the air + */ + public static final Enchantment LUNGE = getEnchantment("lunge"); + @NotNull private static Enchantment getEnchantment(@NotNull String key) { return RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT).getOrThrow(NamespacedKey.minecraft(key)); From f6fb7b6dcc9d27ba9575db2f06ac1d2a9fb97382 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 8 Nov 2025 19:43:40 +0100 Subject: [PATCH 067/112] skip some stats update for PlayerStatisticIncrementEvent --- .../src/main/java/org/bukkit/inventory/EquipmentSlot.java | 4 ++-- .../java/org/bukkit/craftbukkit/event/CraftEventFactory.java | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlot.java b/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlot.java index d90159f41648..297ae0047857 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlot.java +++ b/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlot.java @@ -13,11 +13,11 @@ public enum EquipmentSlot { CHEST(() -> EquipmentSlotGroup.CHEST), HEAD(() -> EquipmentSlotGroup.HEAD), /** - * Only for certain entities such as horses, happy ghasts and wolves. + * Only for certain entities such as horses, wolves, happy ghasts and nautiluses. */ BODY(() -> EquipmentSlotGroup.BODY), /** - * Only for certain entities such as pigs, horses, striders and copper golems. + * Only for certain entities such as pigs, horses, striders, copper golems and nautiluses. */ SADDLE(() -> EquipmentSlotGroup.SADDLE); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 14e7657c04a6..9f0a7cd6e046 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1630,6 +1630,8 @@ public static Cancellable handleStatisticsIncrease(net.minecraft.world.entity.pl case TIME_SINCE_REST: case AVIATE_ONE_CM: case STRIDER_ONE_CM: + case HAPPY_GHAST_ONE_CM: + case NAUTILUS_ONE_CM: // Do not process event for these - too spammy return null; default: From c3eae73a8d25041fc2d6671c0863a921eaa87abe Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 8 Nov 2025 20:03:50 +0100 Subject: [PATCH 068/112] add missing potion effect --- paper-api/src/main/java/org/bukkit/entity/Skeleton.java | 2 +- .../src/main/java/org/bukkit/potion/PotionEffectType.java | 5 +++++ .../java/org/bukkit/craftbukkit/entity/CraftParched.java | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/entity/Skeleton.java b/paper-api/src/main/java/org/bukkit/entity/Skeleton.java index 11051b20ac21..e738e87c81a2 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Skeleton.java +++ b/paper-api/src/main/java/org/bukkit/entity/Skeleton.java @@ -76,7 +76,7 @@ public enum SkeletonType { */ BOGGED, /** - * Parched skeleton + * Parched skeleton. */ PARCHED; } diff --git a/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java b/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java index 463093fc0c48..eddda8e149b8 100644 --- a/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java +++ b/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java @@ -220,6 +220,11 @@ public abstract class PotionEffectType implements Keyed, Translatable, net.kyori */ public static final PotionEffectType INFESTED = getPotionEffectType(39, "infested"); + /** + * Prevent the oxygen bar from depleting underwater. + */ + public static final PotionEffectType BREATH_OF_THE_NAUTILUS = getPotionEffectType(40, "breath_of_the_nautilus"); + @NotNull private static PotionEffectType getPotionEffectType(int typeId, @NotNull String key) { PotionEffectType potionEffectType = Registry.EFFECT.getOrThrow(NamespacedKey.minecraft(key)); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java index cb179f1143a5..6154c4e3c977 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java @@ -3,7 +3,6 @@ import net.minecraft.world.entity.monster.Parched; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Skeleton; -import org.jetbrains.annotations.NotNull; public class CraftParched extends CraftAbstractSkeleton implements org.bukkit.entity.Parched { public CraftParched(final CraftServer server, final Parched entity) { @@ -16,7 +15,7 @@ public Parched getHandle() { } @Override - public Skeleton.@NotNull SkeletonType getSkeletonType() { + public Skeleton.SkeletonType getSkeletonType() { return Skeleton.SkeletonType.PARCHED; } } From 707ab9f2ee9e9c730478c9e866d283145ebe22fd Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 8 Nov 2025 20:41:23 +0100 Subject: [PATCH 069/112] enforce gamerule limit from the api --- .../world/PaperWorldGameRuleChangeEvent.java | 2 +- .../org/bukkit/craftbukkit/CraftGameRule.java | 6 +++++ .../org/bukkit/craftbukkit/CraftWorld.java | 23 +++++++++++-------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/paper-server/src/main/java/io/papermc/paper/event/world/PaperWorldGameRuleChangeEvent.java b/paper-server/src/main/java/io/papermc/paper/event/world/PaperWorldGameRuleChangeEvent.java index 62f3e7a4df19..917ebc6c9083 100644 --- a/paper-server/src/main/java/io/papermc/paper/event/world/PaperWorldGameRuleChangeEvent.java +++ b/paper-server/src/main/java/io/papermc/paper/event/world/PaperWorldGameRuleChangeEvent.java @@ -17,7 +17,7 @@ public PaperWorldGameRuleChangeEvent(final World world, final @Nullable CommandS @Override public void setValue(final String value) { ((CraftGameRule) this.gameRule).getHandle().deserialize(value).ifError(error -> { - throw new IllegalArgumentException("Invalid value: %s (%s)".formatted(value, error.message())); + throw CraftGameRule.INVALID_VALUE.apply(value, error); }); super.setValue(value); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java index ec72b7e6c71b..16c4ea13563c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java @@ -1,6 +1,8 @@ package org.bukkit.craftbukkit; +import com.mojang.serialization.DataResult; import io.papermc.paper.util.Holderable; +import java.util.function.BiFunction; import java.util.function.Function; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; @@ -11,6 +13,10 @@ @NullMarked public class CraftGameRule extends GameRule implements Holderable> { + public static final BiFunction, IllegalArgumentException> INVALID_VALUE = (value, error) -> { + return new IllegalArgumentException("Invalid value: %s (%s)".formatted(value, error.message())); + }; + public static GameRule minecraftToBukkit(net.minecraft.world.level.gamerules.GameRule minecraft) { return CraftRegistry.minecraftToBukkit(minecraft, Registries.GAME_RULE); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 9e7c294e9ef5..47ee0fca3f7b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -6,19 +6,19 @@ import com.google.common.base.Predicates; import com.google.common.collect.Lists; import com.mojang.datafixers.util.Pair; +import com.mojang.serialization.JavaOps; import io.papermc.paper.FeatureHooks; +import io.papermc.paper.raytracing.PositionedRayTraceConfigurationBuilder; +import io.papermc.paper.raytracing.PositionedRayTraceConfigurationBuilderImpl; import io.papermc.paper.raytracing.RayTraceTarget; import io.papermc.paper.registry.RegistryAccess; import io.papermc.paper.registry.RegistryKey; -import io.papermc.paper.raytracing.PositionedRayTraceConfigurationBuilder; -import io.papermc.paper.raytracing.PositionedRayTraceConfigurationBuilderImpl; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -27,7 +27,6 @@ import java.util.Random; import java.util.Set; import java.util.UUID; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -46,8 +45,8 @@ import net.minecraft.network.protocol.game.ClientboundSetTimePacket; import net.minecraft.network.protocol.game.ClientboundSoundEntityPacket; import net.minecraft.network.protocol.game.ClientboundSoundPacket; -import net.minecraft.resources.ResourceKey; import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.DistanceManager; @@ -69,14 +68,14 @@ import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.gamerules.GameRule; -import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.Climate; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ImposterProtoChunk; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.status.ChunkStatus; +import net.minecraft.world.level.gamerules.GameRule; +import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.levelgen.structure.StructureStart; import net.minecraft.world.level.storage.LevelData; import net.minecraft.world.level.storage.LevelResource; @@ -1739,11 +1738,17 @@ public boolean setGameRule(org.bukkit.@NotNull GameRule rule, @NotNull T return false; } + final T convertedValue; if (rule instanceof CraftGameRule.LegacyGameRuleWrapper legacyGameRuleWrapper) { - newValue = (T) legacyGameRuleWrapper.getFromLegacyToModern().apply(newValue); + convertedValue = (T) legacyGameRuleWrapper.getFromLegacyToModern().apply(newValue); + } else { + nms.valueCodec().encodeStart(JavaOps.INSTANCE, newValue).ifError(error -> { + throw CraftGameRule.INVALID_VALUE.apply(newValue.toString(), error); + }); + convertedValue = newValue; } - return !CraftEventFactory.handleGameRuleSet(nms, newValue, this.getHandle(), null).cancelled(); + return !CraftEventFactory.handleGameRuleSet(nms, convertedValue, this.getHandle(), null).cancelled(); } @Override From a121fb9e8a925df319579b67609972a33a32a643 Mon Sep 17 00:00:00 2001 From: Doc Date: Wed, 5 Nov 2025 23:25:37 -0300 Subject: [PATCH 070/112] Update KineticWeapon and PiercingWeapon bounds --- .../paper/datacomponent/item/KineticWeapon.java | 13 +++++++------ .../paper/datacomponent/item/PiercingWeapon.java | 14 +++++++------- .../datacomponent/item/PaperKineticWeapon.java | 6 +++--- .../datacomponent/item/PaperPiercingWeapon.java | 7 +++---- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java index a0b45bdd4ab2..14947936288a 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java @@ -5,6 +5,7 @@ import org.checkerframework.checker.index.qual.NonNegative; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Range; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -32,13 +33,13 @@ static Condition condition(final @NonNegative int maxDurationTicks, final float } @Contract(pure = true) - @NonNegative float minReach(); + @Range(from = 0, to = 128) float minReach(); @Contract(pure = true) - @NonNegative float maxReach(); + @Range(from = 0, to = 128) float maxReach(); @Contract(pure = true) - @NonNegative float hitboxMargin(); + @Range(from = 0, to = 1) float hitboxMargin(); @Contract(pure = true) @NonNegative int contactCooldownTicks(); @@ -85,13 +86,13 @@ interface Condition { interface Builder extends DataComponentBuilder { @Contract(value = "_ -> this", mutates = "this") - Builder minReach(@NonNegative float minReach); + Builder minReach(@Range(from = 0, to = 128) float minReach); @Contract(value = "_ -> this", mutates = "this") - Builder maxReach(@NonNegative float maxReach); + Builder maxReach(@Range(from = 0, to = 128) float maxReach); @Contract(value = "_ -> this", mutates = "this") - Builder hitboxMargin(@NonNegative float hitboxMargin); + Builder hitboxMargin(@Range(from = 0, to = 1) float hitboxMargin); @Contract(value = "_ -> this", mutates = "this") Builder contactCooldownTicks(@NonNegative int ticks); diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java index 18bb6f9692bf..5338b772ed80 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java @@ -2,9 +2,9 @@ import io.papermc.paper.datacomponent.DataComponentBuilder; import net.kyori.adventure.key.Key; -import org.checkerframework.checker.index.qual.NonNegative; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Range; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -22,11 +22,11 @@ static Builder piercingWeapon() { return ItemComponentTypesBridge.bridge().piercingWeapon(); } - @NonNegative float minReach(); + @Range(from = 0, to = 128) float minReach(); - @NonNegative float maxReach(); + @Range(from = 0, to = 128) float maxReach(); - @NonNegative float hitboxMargin(); + @Range(from = 0, to = 1) float hitboxMargin(); boolean dealsKnockback(); @@ -44,13 +44,13 @@ static Builder piercingWeapon() { interface Builder extends DataComponentBuilder { @Contract(value = "_ -> this", mutates = "this") - Builder minReach(@NonNegative float minReach); + Builder minReach(@Range(from = 0, to = 128) float minReach); @Contract(value = "_ -> this", mutates = "this") - Builder maxReach(@NonNegative float maxReach); + Builder maxReach(@Range(from = 0, to = 128) float maxReach); @Contract(value = "_ -> this", mutates = "this") - Builder hitboxMargin(@NonNegative float hitboxMargin); + Builder hitboxMargin(@Range(from = 0, to = 1) float hitboxMargin); @Contract(value = "_ -> this", mutates = "this") Builder dealsKnockback(boolean dealsKnockback); diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java index 2590467c009b..638fc39bb887 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java @@ -144,21 +144,21 @@ static final class BuilderImpl implements KineticWeapon.Builder { @Override public KineticWeapon.Builder minReach(final float minReach) { - Preconditions.checkArgument(minReach >= 0.0F, "minReach must be non-negative"); + Preconditions.checkArgument(minReach >= 0.0F && minReach <= 128.0F, "minReach must be in range [0,128] was %s", minReach); this.minReach = minReach; return this; } @Override public KineticWeapon.Builder maxReach(final float maxReach) { - Preconditions.checkArgument(maxReach >= 0.0F, "maxReach must be non-negative"); + Preconditions.checkArgument(maxReach >= 0.0F && maxReach <= 128.0F, "maxReach must be in range [0,128] was %s", maxReach); this.maxReach = maxReach; return this; } @Override public KineticWeapon.Builder hitboxMargin(final float hitboxMargin) { - Preconditions.checkArgument(hitboxMargin >= 0.0F, "hitboxMargin must be non-negative"); + Preconditions.checkArgument(hitboxMargin >= 0.0F && hitboxMargin <= 1.0F, "hitboxMargin must be in range [0,1] was %s", hitboxMargin); this.hitboxMargin = hitboxMargin; return this; } diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java index a7ee81f23006..084b394e1417 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java @@ -61,7 +61,6 @@ public boolean dismounts() { .orElse(null); } - static final class BuilderImpl implements PiercingWeapon.Builder { private float minReach = 0.0F; @@ -76,21 +75,21 @@ static final class BuilderImpl implements PiercingWeapon.Builder { @Override public PiercingWeapon.Builder minReach(final float minReach) { - Preconditions.checkArgument(minReach >= 0.0F, "minReach must be non-negative"); + Preconditions.checkArgument(minReach >= 0.0F && minReach <= 128.0F, "minReach must be in range [0,128] was %s", minReach); this.minReach = minReach; return this; } @Override public PiercingWeapon.Builder maxReach(final float maxReach) { - Preconditions.checkArgument(maxReach >= 0.0F, "maxReach must be non-negative"); + Preconditions.checkArgument(maxReach >= 0.0F && maxReach <= 128.0F, "maxReach must be in range [0,128] was %s", maxReach); this.maxReach = maxReach; return this; } @Override public PiercingWeapon.Builder hitboxMargin(final float hitboxMargin) { - Preconditions.checkArgument(hitboxMargin >= 0.0F, "hitboxMargin must be non-negative"); + Preconditions.checkArgument(hitboxMargin >= 0.0F && hitboxMargin <= 1.0F, "hitboxMargin must be in range [0,1] was %s", hitboxMargin); this.hitboxMargin = hitboxMargin; return this; } From 162f786d78ad43cc8aba1869266b6eac1ba05685 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 11 Nov 2025 12:00:38 -0700 Subject: [PATCH 071/112] 25w46a init --- gradle.properties | 4 +- paper-server/build.gradle.kts | 4 +- .../mojang/math/OctahedralGroup.java.patch | 10 +- .../net/minecraft/core/BlockPos.java.patch | 6 +- .../server/MinecraftServer.java.patch | 138 +++++++++-------- .../dedicated/DedicatedServer.java.patch | 8 +- .../server/level/ServerPlayer.java.patch | 146 +++++++++--------- .../server/players/StoredUserList.java.patch | 9 -- .../util/datafix/DataFixers.java.patch | 2 +- .../world/effect/MobEffectUtil.java.patch | 2 +- .../world/entity/LivingEntity.java.patch | 2 +- .../world/entity/animal/Pig.java.patch | 6 +- .../entity/animal/frog/ShootTongue.java.patch | 2 +- .../animal/horse/AbstractHorse.java.patch | 22 +-- .../nautilus/AbstractNautilus.java.patch | 10 +- .../world/entity/monster/Drowned.java.patch | 2 +- .../world/entity/player/Player.java.patch | 69 +++++---- .../AbstractMountInventoryMenu.java.patch | 26 ++++ .../inventory/HorseInventoryMenu.java.patch | 26 ---- .../world/item/BoneMealItem.java.patch | 17 +- .../world/item/FishingRodItem.java.patch | 2 +- .../world/item/HoneycombItem.java.patch | 2 +- .../minecraft/world/item/ItemStack.java.patch | 18 +-- .../world/level/block/BedBlock.java.patch | 6 +- .../world/level/block/ShelfBlock.java.patch | 2 +- .../level/block/ShulkerBoxBlock.java.patch | 4 +- .../block/entity/ShelfBlockEntity.java.patch | 2 +- .../level/gamerules/GameRules.java.patch | 6 +- .../storage/PlayerDataStorage.java.patch | 2 +- 29 files changed, 275 insertions(+), 280 deletions(-) create mode 100644 paper-server/patches/sources/net/minecraft/world/inventory/AbstractMountInventoryMenu.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/world/inventory/HorseInventoryMenu.java.patch diff --git a/gradle.properties b/gradle.properties index 5610727339b4..f9b4822374ac 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group=io.papermc.paper -version=25w45a-R0.1-SNAPSHOT -mcVersion=25w45a +version=25w46a-R0.1-SNAPSHOT +mcVersion=25w46a # This is the current API version for use in (paper-)plugin.yml files # During snapshot cycles this should be the anticipated version of the release target apiVersion=1.21.11 diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index afd7809f78bf..a0261f5ffc4a 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:25w45a+build.7") + mache("io.papermc:mache:25w46a+build.3") paperclip("io.papermc:paperclip:3.0.3") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } @@ -42,7 +42,7 @@ paperweight { ) updatingMinecraft { - // oldPaperCommit = "9b58b6ab0f5856c15502cd644e4ee95b76266b88" + // oldPaperCommit = "a121fb9e8a925df319579b67609972a33a32a643" } } diff --git a/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch b/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch index d88e9f4da8a0..fa336bf0640a 100644 --- a/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch +++ b/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch @@ -1,8 +1,8 @@ --- a/com/mojang/math/OctahedralGroup.java +++ b/com/mojang/math/OctahedralGroup.java -@@ -115,6 +_,12 @@ - } - ); +@@ -105,6 +_,12 @@ + .map(group -> Arrays.stream(values()).filter(octahedralGroup -> group.compose(octahedralGroup) == IDENTITY).findAny().get()) + .toArray(OctahedralGroup[]::new); + static { + for (OctahedralGroup octahedralGroup : values()) { @@ -13,7 +13,7 @@ private OctahedralGroup(final String name, final SymmetricGroup3 permutation, final boolean invertX, final boolean invertY, final boolean invertZ) { this.name = name; this.invertX = invertX; -@@ -155,7 +_,7 @@ +@@ -145,7 +_,7 @@ return this.name; } @@ -22,7 +22,7 @@ if (this.rotatedDirections == null) { this.rotatedDirections = Util.makeEnumMap(Direction.class, direction1 -> { Direction.Axis axis = direction1.getAxis(); -@@ -166,6 +_,11 @@ +@@ -156,6 +_,11 @@ }); } diff --git a/paper-server/patches/sources/net/minecraft/core/BlockPos.java.patch b/paper-server/patches/sources/net/minecraft/core/BlockPos.java.patch index d8a0bc922e48..0738cd2b3dc0 100644 --- a/paper-server/patches/sources/net/minecraft/core/BlockPos.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/BlockPos.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/BlockPos.java +++ b/net/minecraft/core/BlockPos.java -@@ -159,67 +_,84 @@ +@@ -156,67 +_,84 @@ @Override public BlockPos above() { @@ -98,7 +98,7 @@ } @Override -@@ -659,9 +_,9 @@ +@@ -651,9 +_,9 @@ } public BlockPos.MutableBlockPos set(int x, int y, int z) { @@ -111,7 +111,7 @@ return this; } -@@ -724,19 +_,19 @@ +@@ -711,19 +_,19 @@ @Override public BlockPos.MutableBlockPos setX(int x) { diff --git a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch index 2fee7cb29144..9accb9289b3b 100644 --- a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -185,11 +_,13 @@ +@@ -186,11 +_,13 @@ import org.slf4j.Logger; public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ServerInfo, CommandSource, ChunkIOErrorReporter { @@ -15,7 +15,7 @@ private static final int OVERLOADED_TICKS_THRESHOLD = 20; private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeUtil.NANOSECONDS_PER_SECOND; private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100; -@@ -216,7 +_,7 @@ +@@ -217,7 +_,7 @@ private MinecraftServer.@Nullable TimeProfiler debugCommandProfiler; private boolean debugCommandProfilerDelayStart; private ServerConnectionListener connection; @@ -24,7 +24,7 @@ private @Nullable ServerStatus status; private ServerStatus.@Nullable Favicon statusIcon; private final RandomSource random = RandomSource.create(); -@@ -227,13 +_,14 @@ +@@ -228,13 +_,14 @@ private Map, ServerLevel> levels = Maps.newLinkedHashMap(); private PlayerList playerList; private volatile boolean running = true; @@ -40,7 +40,7 @@ private int playerIdleTimeout; private final long[] tickTimesNanos = new long[100]; private long aggregatedTickTimesNanos = 0L; -@@ -280,10 +_,109 @@ +@@ -281,10 +_,109 @@ private final DiscontinuousFrame tickFrame; private final PacketProcessor packetProcessor; @@ -151,7 +151,7 @@ if (Runtime.getRuntime().availableProcessors() > 4) { thread.setPriority(8); } -@@ -295,6 +_,10 @@ +@@ -296,6 +_,10 @@ } public MinecraftServer( @@ -162,7 +162,7 @@ Thread serverThread, LevelStorageSource.LevelStorageAccess storageSource, PackRepository packRepository, -@@ -305,18 +_,19 @@ +@@ -306,18 +_,19 @@ LevelLoadListener levelLoadListener ) { super("Server"); @@ -185,7 +185,7 @@ this.storageSource = storageSource; this.playerDataStorage = storageSource.createPlayerStorage(); this.fixerUpper = fixerUpper; -@@ -336,6 +_,38 @@ +@@ -337,6 +_,38 @@ this.serverActivityMonitor = new ServerActivityMonitor(this.notificationManager, 30); this.packetProcessor = new PacketProcessor(serverThread); } @@ -224,7 +224,7 @@ } protected abstract boolean initServer() throws IOException; -@@ -368,15 +_,15 @@ +@@ -369,15 +_,15 @@ }; } @@ -245,7 +245,7 @@ if (profiledDuration != null) { profiledDuration.finish(true); } -@@ -390,31 +_,127 @@ +@@ -391,31 +_,127 @@ } } @@ -383,7 +383,7 @@ serverLevelData.setInitialized(true); if (isDebugWorld) { this.setupDebugLevel(this.worldData); -@@ -434,38 +_,16 @@ +@@ -435,38 +_,16 @@ } GlobalPos globalPos = this.selectLevelLoadFocusPos(); @@ -430,7 +430,7 @@ Optional legacyWorldBorderSettings = serverLevelData.getLegacyWorldBorderSettings(); if (legacyWorldBorderSettings.isPresent()) { WorldBorder.Settings settings = legacyWorldBorderSettings.get(); -@@ -488,16 +_,14 @@ +@@ -489,16 +_,14 @@ dataStorage1.set(WorldBorder.TYPE, worldBorder); } @@ -453,7 +453,7 @@ } private static void setInitialSpawn( -@@ -509,6 +_,30 @@ +@@ -510,6 +_,30 @@ levelData.setSpawn(LevelData.RespawnData.of(level.dimension(), BlockPos.ZERO.above(80), 0.0F, 0.0F)); } else { ServerChunkCache chunkSource = level.getChunkSource(); @@ -484,7 +484,7 @@ ChunkPos chunkPos = new ChunkPos(chunkSource.randomState().sampler().findSpawnPosition()); levelLoadListener.start(LevelLoadListener.Stage.PREPARE_GLOBAL_SPAWN, 0); levelLoadListener.updateFocus(level.dimension(), chunkPos); -@@ -565,10 +_,13 @@ +@@ -566,10 +_,13 @@ serverLevelData.setGameType(GameType.SPECTATOR); } @@ -500,7 +500,7 @@ chunkLoadCounter.track(serverLevel, () -> { TicketStorage ticketStorage = serverLevel.getDataStorage().get(TicketStorage.TYPE); if (ticketStorage != null) { -@@ -577,17 +_,19 @@ +@@ -578,17 +_,19 @@ }); } @@ -526,7 +526,7 @@ } protected GlobalPos selectLevelLoadFocusPos() { -@@ -621,8 +_,10 @@ +@@ -622,8 +_,10 @@ flag = true; } @@ -539,7 +539,7 @@ if (flush) { for (ServerLevel serverLevel : this.getAllLevels()) { LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", serverLevel.getChunkSource().chunkMap.getStorageName()); -@@ -652,19 +_,49 @@ +@@ -653,19 +_,49 @@ this.stopServer(); } @@ -590,7 +590,7 @@ } LOGGER.info("Saving worlds"); -@@ -706,6 +_,25 @@ +@@ -707,6 +_,25 @@ } catch (IOException var4) { LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), var4); } @@ -616,7 +616,7 @@ } public String getLocalIp() { -@@ -721,6 +_,14 @@ +@@ -722,6 +_,14 @@ } public void halt(boolean waitForShutdown) { @@ -631,7 +631,7 @@ this.running = false; if (waitForShutdown) { try { -@@ -731,6 +_,118 @@ +@@ -732,6 +_,118 @@ } } @@ -750,7 +750,7 @@ protected void runServer() { try { if (!this.initServer()) { -@@ -738,26 +_,68 @@ +@@ -739,26 +_,68 @@ } this.nextTickTimeNanos = Util.getNanos(); @@ -829,7 +829,7 @@ boolean flag = l == 0L; if (this.debugCommandProfilerDelayStart) { -@@ -765,22 +_,22 @@ +@@ -766,7 +_,7 @@ this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount); } @@ -837,18 +837,8 @@ + // Paper - improve tick loop - done above try (Profiler.Scope scope = Profiler.use(this.createProfiler())) { - ProfilerFiller profilerFiller = Profiler.get(); - profilerFiller.push("tick"); - this.tickFrame.start(); -- profilerFiller.push("scheduledPacketProcessing"); -- this.packetProcessor.processQueuedPackets(); -- profilerFiller.pop(); -+ // Paper - improve tick loop - moved into runAllTasksAtTickStart -+ this.runAllTasksAtTickStart(); // Paper - improve tick loop - this.tickServer(flag ? () -> false : this::haveTime); - this.tickFrame.end(); -+ this.recordEndOfTick(); // Paper - improve tick loop - profilerFiller.popPush("nextTickWait"); + this.processPacketsAndTick(flag); +@@ -775,7 +_,7 @@ this.mayHaveDelayedTasks = true; this.delayedTasksMaxNextTickTimeNanos = Math.max(Util.getNanos() + l, this.nextTickTimeNanos); this.startMeasuringTaskExecutionTime(); @@ -857,7 +847,7 @@ this.finishMeasuringTaskExecutionTime(); if (flag) { this.tickRateManager.endTickWork(); -@@ -814,7 +_,7 @@ +@@ -809,7 +_,7 @@ } catch (Throwable var64) { LOGGER.error("Exception stopping the server", var64); } finally { @@ -866,7 +856,7 @@ } } } -@@ -866,7 +_,14 @@ +@@ -861,7 +_,14 @@ } private boolean haveTime() { @@ -882,7 +872,7 @@ } public static boolean throwIfFatalException() { -@@ -892,11 +_,11 @@ +@@ -887,11 +_,11 @@ } protected void waitUntilNextTick() { @@ -896,7 +886,7 @@ } finally { this.waitingForNextTick = false; } -@@ -915,17 +_,23 @@ +@@ -910,17 +_,23 @@ @Override public TickTask wrapRunnable(Runnable runnable) { @@ -922,7 +912,7 @@ this.mayHaveDelayedTasks = flag; return flag; } -@@ -934,15 +_,16 @@ +@@ -929,15 +_,16 @@ if (super.pollTask()) { return true; } else { @@ -941,7 +931,7 @@ } } -@@ -995,26 +_,44 @@ +@@ -990,26 +_,44 @@ } public void tickServer(BooleanSupplier hasTimeLeft) { @@ -987,7 +977,7 @@ this.tickCount++; this.tickRateManager.tick(); this.tickChildren(hasTimeLeft); -@@ -1024,11 +_,18 @@ +@@ -1019,11 +_,18 @@ } this.ticksUntilAutosave--; @@ -1007,7 +997,19 @@ profilerFiller.push("tallying"); long l = Util.getNanos() - nanos; int i1 = this.tickCount % 100; -@@ -1041,7 +_,7 @@ +@@ -1039,16 +_,16 @@ + ProfilerFiller profilerFiller = Profiler.get(); + profilerFiller.push("tick"); + this.tickFrame.start(); +- profilerFiller.push("scheduledPacketProcessing"); +- this.packetProcessor.processQueuedPackets(); +- profilerFiller.pop(); ++ // Paper - improve tick loop - moved into runAllTasksAtTickStart ++ this.runAllTasksAtTickStart(); // Paper - improve tick loop + this.tickServer(sprinting ? () -> false : this::haveTime); + this.tickFrame.end(); ++ this.recordEndOfTick(); // Paper - improve tick loop + profilerFiller.pop(); } private void autoSave() { @@ -1016,7 +1018,7 @@ LOGGER.debug("Autosave started"); ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("save"); -@@ -1083,7 +_,7 @@ +@@ -1090,7 +_,7 @@ private ServerStatus buildServerStatus() { ServerStatus.Players players = this.buildPlayerStatus(); return new ServerStatus( @@ -1025,7 +1027,7 @@ Optional.of(players), Optional.of(ServerStatus.Version.current()), Optional.ofNullable(this.statusIcon), -@@ -1097,7 +_,7 @@ +@@ -1104,7 +_,7 @@ if (this.hidesOnlinePlayers()) { return new ServerStatus.Players(maxPlayers, players.size(), List.of()); } else { @@ -1034,7 +1036,7 @@ ObjectArrayList list = new ObjectArrayList<>(min); int randomInt = Mth.nextInt(this.random, 0, players.size() - min); -@@ -1114,18 +_,77 @@ +@@ -1121,18 +_,77 @@ protected void tickChildren(BooleanSupplier hasTimeLeft) { ProfilerFiller profilerFiller = Profiler.get(); this.getPlayerList().getPlayers().forEach(serverPlayer1 -> serverPlayer1.connection.suspendFlushing()); @@ -1112,7 +1114,7 @@ profilerFiller.push("tick"); -@@ -1139,7 +_,9 @@ +@@ -1146,7 +_,9 @@ profilerFiller.pop(); profilerFiller.pop(); @@ -1122,7 +1124,7 @@ profilerFiller.popPush("connection"); this.tickConnection(); -@@ -1169,9 +_,12 @@ +@@ -1176,9 +_,12 @@ this.serverActivityMonitor.tick(); } @@ -1137,7 +1139,7 @@ this.effectiveRespawnData = serverLevel.getWorldBorderAdjustedRespawnData(respawnData); } -@@ -1221,6 +_,22 @@ +@@ -1228,6 +_,22 @@ return this.levels.get(dimension); } @@ -1160,7 +1162,7 @@ public Set> levelKeys() { return this.levels.keySet(); } -@@ -1245,7 +_,7 @@ +@@ -1252,7 +_,7 @@ @DontObfuscate public String getServerModName() { @@ -1169,7 +1171,7 @@ } public SystemReport fillSystemReport(SystemReport systemReport) { -@@ -1280,7 +_,7 @@ +@@ -1287,7 +_,7 @@ @Override public void sendSystemMessage(Component message) { @@ -1178,7 +1180,7 @@ } public KeyPair getKeyPair() { -@@ -1317,11 +_,17 @@ +@@ -1324,11 +_,17 @@ } } @@ -1201,7 +1203,7 @@ } } -@@ -1393,10 +_,20 @@ +@@ -1400,10 +_,20 @@ @Override public String getMotd() { @@ -1223,7 +1225,7 @@ this.motd = motd; } -@@ -1425,9 +_,13 @@ +@@ -1432,9 +_,13 @@ int i = 0; for (ServerPlayer serverPlayer : this.getPlayerList().getPlayers()) { @@ -1239,7 +1241,7 @@ } return i; -@@ -1435,7 +_,7 @@ +@@ -1442,7 +_,7 @@ } public ServerConnectionListener getConnection() { @@ -1248,7 +1250,7 @@ } public boolean isReady() { -@@ -1502,7 +_,7 @@ +@@ -1505,7 +_,7 @@ @Override public void executeIfPossible(Runnable task) { if (this.isStopped()) { @@ -1257,7 +1259,7 @@ } else { super.executeIfPossible(task); } -@@ -1537,7 +_,14 @@ +@@ -1540,7 +_,14 @@ return this.functionManager; } @@ -1272,7 +1274,7 @@ CompletableFuture completableFuture = CompletableFuture.supplyAsync( () -> selectedIds.stream().map(this.packRepository::getPack).filter(Objects::nonNull).map(Pack::open).collect(ImmutableList.toImmutableList()), this -@@ -1545,7 +_,7 @@ +@@ -1548,7 +_,7 @@ .thenCompose( list -> { CloseableResourceManager closeableResourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, list); @@ -1281,7 +1283,7 @@ return ReloadableServerResources.loadResources( closeableResourceManager, this.registries, -@@ -1566,20 +_,39 @@ +@@ -1569,20 +_,39 @@ ) .thenAcceptAsync( reloadableResources -> { @@ -1323,7 +1325,7 @@ }, this ); -@@ -1596,7 +_,7 @@ +@@ -1599,7 +_,7 @@ DataPackConfig dataPackConfig = initialDataConfig.dataPacks(); FeatureFlagSet featureFlagSet = initMode ? FeatureFlagSet.of() : initialDataConfig.enabledFeatures(); FeatureFlagSet featureFlagSet1 = initMode ? FeatureFlags.REGISTRY.allFlags() : initialDataConfig.enabledFeatures(); @@ -1332,7 +1334,7 @@ if (safeMode) { return configureRepositoryWithSelection(packRepository, List.of("vanilla"), featureFlagSet, false); } else { -@@ -1651,7 +_,7 @@ +@@ -1654,7 +_,7 @@ private static WorldDataConfiguration configureRepositoryWithSelection( PackRepository packRepository, Collection selectedPacks, FeatureFlagSet enabledFeatures, boolean safeMode ) { @@ -1341,7 +1343,7 @@ enableForcedFeaturePacks(packRepository, enabledFeatures); DataPackConfig selectedPacks1 = getSelectedPacks(packRepository, safeMode); FeatureFlagSet featureFlagSet = packRepository.getRequestedFeatureFlags().join(enabledFeatures); -@@ -1683,7 +_,7 @@ +@@ -1686,7 +_,7 @@ } } @@ -1350,7 +1352,7 @@ } } -@@ -1700,8 +_,8 @@ +@@ -1703,8 +_,8 @@ UserWhiteList whiteList = playerList.getWhiteList(); for (ServerPlayer serverPlayer : Lists.newArrayList(playerList.getPlayers())) { @@ -1361,7 +1363,7 @@ } } } -@@ -1731,12 +_,12 @@ +@@ -1734,12 +_,12 @@ } public ServerLevel findRespawnDimension() { @@ -1376,7 +1378,7 @@ public void setRespawnData(LevelData.RespawnData respawnData) { ServerLevelData serverLevelData = this.worldData.overworldData(); LevelData.RespawnData respawnData1 = serverLevelData.getRespawnData(); -@@ -1938,6 +_,17 @@ +@@ -1941,6 +_,17 @@ } } @@ -1394,7 +1396,7 @@ private ProfilerFiller createProfiler() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted( -@@ -2058,16 +_,22 @@ +@@ -2061,16 +_,22 @@ } public void logChatMessage(Component content, ChatType.Bound boundChatType, @Nullable String header) { @@ -1421,7 +1423,7 @@ } public boolean logIPs() { -@@ -2078,8 +_,9 @@ +@@ -2081,8 +_,9 @@ LOGGER.debug("Received custom click action {} with payload {}", id, payload.orElse(null)); } @@ -1432,7 +1434,7 @@ } public boolean setAutoSave(boolean autoSave) { -@@ -2105,12 +_,14 @@ +@@ -2108,12 +_,14 @@ return false; } @@ -1450,7 +1452,7 @@ serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, b)); } } else if (rule == GameRules.LIMITED_CRAFTING || rule == GameRules.IMMEDIATE_RESPAWN) { -@@ -2118,18 +_,18 @@ +@@ -2121,18 +_,18 @@ ? ClientboundGameEventPacket.LIMITED_CRAFTING : ClientboundGameEventPacket.IMMEDIATE_RESPAWN; ClientboundGameEventPacket clientboundGameEventPacket = new ClientboundGameEventPacket(type, (Boolean)value ? 1.0F : 0.0F); @@ -1473,7 +1475,7 @@ } } -@@ -2264,4 +_,53 @@ +@@ -2267,4 +_,53 @@ }; } } diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch index f26eae182477..c8cd84714454 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -304,7 +304,7 @@ this.getCommands().performPrefixedCommand(consoleInput.source, consoleInput.msg); } } -@@ -597,12 +_,15 @@ +@@ -592,12 +_,15 @@ @Override public String getMotd() { @@ -322,7 +322,7 @@ } @Override -@@ -628,7 +_,11 @@ +@@ -623,7 +_,11 @@ @Override public boolean enforceSecureProfile() { DedicatedServerProperties properties = this.getProperties(); @@ -335,7 +335,7 @@ } @Override -@@ -713,21 +_,60 @@ +@@ -708,21 +_,60 @@ @Override public String getPluginNames() { @@ -401,7 +401,7 @@ } @Override -@@ -858,4 +_,15 @@ +@@ -853,4 +_,15 @@ public Map getCodeOfConducts() { return this.codeOfConductTexts; } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index ddb50de9c809..0e6abbc7edb9 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -254,7 +_,8 @@ +@@ -255,7 +_,8 @@ private int levitationStartTime; private boolean disconnected; private int requestedViewDistance = 2; @@ -10,7 +10,7 @@ private @Nullable Vec3 startingToFallPosition; private @Nullable Vec3 enteredNetherPosition; private @Nullable Vec3 enteredLavaOnVehiclePosition; -@@ -298,6 +_,13 @@ +@@ -299,6 +_,13 @@ } } @@ -24,7 +24,7 @@ @Override public void sendSlotChange(AbstractContainerMenu container, int slot, ItemStack stack) { ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(container.containerId, container.incrementStateId(), slot, stack)); -@@ -333,6 +_,32 @@ +@@ -334,6 +_,32 @@ } } @@ -57,7 +57,7 @@ @Override public void dataChanged(AbstractContainerMenu containerMenu, int dataSlotIndex, int value) { } -@@ -359,10 +_,43 @@ +@@ -360,10 +_,43 @@ public void sendSystemMessage(Component message) { ServerPlayer.this.sendSystemMessage(message); } @@ -101,7 +101,7 @@ public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) { super(level, gameProfile); -@@ -373,8 +_,14 @@ +@@ -374,8 +_,14 @@ this.recipeBook = new ServerRecipeBook((recipe, output) -> server.getRecipeManager().listDisplaysForRecipe(recipe, output)); this.stats = server.getPlayerList().getPlayerStats(this); this.advancements = server.getPlayerList().getPlayerAdvancements(this); @@ -117,7 +117,7 @@ } @Override -@@ -392,6 +_,7 @@ +@@ -393,6 +_,7 @@ this.seenCredits = input.getBooleanOr("seenCredits", false); input.read("recipeBook", ServerRecipeBook.Packed.CODEC) .ifPresent(packed -> this.recipeBook.loadUntrusted(packed, key -> this.server.getRecipeManager().byKey(key).isPresent())); @@ -125,7 +125,7 @@ if (this.isSleeping()) { this.stopSleeping(); } -@@ -399,6 +_,19 @@ +@@ -400,6 +_,19 @@ this.respawnConfig = input.read("respawn", ServerPlayer.RespawnConfig.CODEC).orElse(null); this.spawnExtraParticlesOnFall = input.getBooleanOr("spawn_extra_particles_on_fall", false); this.raidOmenPosition = input.read("raid_omen_position", BlockPos.CODEC).orElse(null); @@ -145,7 +145,7 @@ this.gameMode .setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(input, "playerGameType")), readPlayerMode(input, "previousPlayerGameType")); this.setShoulderEntityLeft(input.read("ShoulderEntityLeft", CompoundTag.CODEC).orElseGet(CompoundTag::new)); -@@ -426,12 +_,24 @@ +@@ -427,12 +_,24 @@ if (!this.getShoulderEntityRight().isEmpty()) { output.store("ShoulderEntityRight", CompoundTag.CODEC, this.getShoulderEntityRight()); } @@ -171,7 +171,7 @@ ValueOutput valueOutput = output.child("RootVehicle"); valueOutput.store("Attach", UUIDUtil.CODEC, vehicle.getUUID()); rootVehicle.save(valueOutput.child("Entity")); -@@ -443,7 +_,7 @@ +@@ -444,7 +_,7 @@ if (!optional.isEmpty()) { ServerLevel serverLevel = this.level(); Entity entity = EntityType.loadEntityRecursive( @@ -180,7 +180,7 @@ ); if (entity != null) { UUID uuid = optional.get().read("Attach", UUIDUtil.CODEC).orElse(null); -@@ -460,10 +_,10 @@ +@@ -461,10 +_,10 @@ if (!this.isPassenger()) { LOGGER.warn("Couldn't reattach entity to player"); @@ -193,7 +193,7 @@ } } } -@@ -475,6 +_,7 @@ +@@ -476,6 +_,7 @@ ValueOutput.ValueOutputList valueOutputList = output.childrenList("ender_pearls"); for (ThrownEnderpearl thrownEnderpearl : this.enderPearls) { @@ -201,7 +201,7 @@ if (thrownEnderpearl.isRemoved()) { LOGGER.warn("Trying to save removed ender pearl, skipping"); } else { -@@ -507,6 +_,16 @@ +@@ -508,6 +_,16 @@ } } @@ -218,7 +218,7 @@ public void setExperiencePoints(int experiencePoints) { float f = this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -571,6 +_,11 @@ +@@ -572,6 +_,11 @@ @Override public void tick() { @@ -230,7 +230,7 @@ this.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); -@@ -578,9 +_,18 @@ +@@ -579,9 +_,18 @@ this.invulnerableTime--; } @@ -252,7 +252,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -639,10 +_,10 @@ +@@ -640,10 +_,10 @@ public void doTick() { try { @@ -265,7 +265,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -672,7 +_,7 @@ +@@ -673,7 +_,7 @@ if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -274,7 +274,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -703,6 +_,12 @@ +@@ -704,6 +_,12 @@ this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float)this.lastRecordedExperience)); } @@ -287,7 +287,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float)this.lastRecordedLevel)); -@@ -716,6 +_,21 @@ +@@ -717,6 +_,21 @@ if (this.tickCount % 20 == 0) { CriteriaTriggers.LOCATION.trigger(this); } @@ -309,7 +309,7 @@ } catch (Throwable var4) { CrashReport crashReport = CrashReport.forThrowable(var4, "Ticking player"); CrashReportCategory crashReportCategory = crashReport.addCategory("Player being ticked"); -@@ -740,7 +_,7 @@ +@@ -741,7 +_,7 @@ if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.level().getGameRules().get(GameRules.NATURAL_HEALTH_REGENERATION)) { if (this.tickCount % 20 == 0) { if (this.getHealth() < this.getMaxHealth()) { @@ -318,7 +318,7 @@ } float saturationLevel = this.foodData.getSaturationLevel(); -@@ -760,6 +_,7 @@ +@@ -761,6 +_,7 @@ this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft()); this.playShoulderEntityAmbientSound(this.getShoulderEntityRight()); if (this.fallDistance > 0.5 || this.isInWater() || this.getAbilities().flying || this.isSleeping() || this.isInPowderSnow) { @@ -326,7 +326,7 @@ this.removeEntitiesOnShoulder(); } } -@@ -804,35 +_,64 @@ +@@ -805,35 +_,64 @@ @Override public void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { @@ -398,7 +398,7 @@ } @Override -@@ -869,15 +_,36 @@ +@@ -870,15 +_,36 @@ } private void updateScoreForCriteria(ObjectiveCriteria criteria, int points) { @@ -444,7 +444,7 @@ this.connection .send( new ClientboundPlayerCombatKillPacket(this.getId(), deathMessage), -@@ -894,6 +_,65 @@ +@@ -895,6 +_,65 @@ } ) ); @@ -510,7 +510,7 @@ Team team = this.getTeam(); if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) { this.server.getPlayerList().broadcastSystemMessage(deathMessage, false); -@@ -903,7 +_,7 @@ +@@ -904,7 +_,7 @@ this.server.getPlayerList().broadcastSystemToAllExceptTeam(this, deathMessage); } } else { @@ -519,7 +519,7 @@ } this.removeEntitiesOnShoulder(); -@@ -911,11 +_,35 @@ +@@ -912,11 +_,35 @@ this.tellNeutralMobsThatIDied(); } @@ -558,7 +558,7 @@ LivingEntity killCredit = this.getKillCredit(); if (killCredit != null) { this.awardStat(Stats.ENTITY_KILLED_BY.get(killCredit.getType())); -@@ -949,10 +_,10 @@ +@@ -950,10 +_,10 @@ if (entity != this) { super.awardKillScore(entity, damageSource); Scoreboard scoreboard = this.level().getScoreboard(); @@ -571,7 +571,7 @@ } else { this.awardStat(Stats.MOB_KILLS); } -@@ -964,12 +_,11 @@ +@@ -965,12 +_,11 @@ } private void handleTeamKill(ScoreHolder scoreHolder, ScoreHolder teamMember, ObjectiveCriteria[] criteria) { @@ -586,7 +586,7 @@ } } } -@@ -980,9 +_,20 @@ +@@ -981,9 +_,20 @@ return false; } else { Entity entity = damageSource.getEntity(); @@ -609,7 +609,7 @@ } } -@@ -992,25 +_,95 @@ +@@ -993,25 +_,95 @@ } private boolean isPvpAllowed() { @@ -713,7 +713,7 @@ } public boolean isReceivingWaypoints() { -@@ -1045,14 +_,16 @@ +@@ -1046,14 +_,16 @@ && (flag || blockState.getValue(RespawnAnchorBlock.CHARGE) > 0) && RespawnAnchorBlock.canSetSpawn(level, blockPos)) { Optional optional = RespawnAnchorBlock.findStandUpPosition(EntityType.PLAYER, level, blockPos); @@ -733,7 +733,7 @@ } else if (!flag) { return Optional.empty(); } else { -@@ -1060,7 +_,7 @@ +@@ -1061,7 +_,7 @@ BlockState blockState1 = level.getBlockState(blockPos.above()); boolean isPossibleToRespawnInThis1 = blockState1.getBlock().isPossibleToRespawnInThis(blockState1); return isPossibleToRespawnInThis && isPossibleToRespawnInThis1 @@ -742,7 +742,7 @@ : Optional.empty(); } } -@@ -1077,6 +_,7 @@ +@@ -1078,6 +_,7 @@ @Override public @Nullable ServerPlayer teleport(TeleportTransition teleportTransition) { @@ -750,7 +750,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1086,13 +_,48 @@ +@@ -1087,13 +_,48 @@ ServerLevel level = teleportTransition.newLevel(); ServerLevel serverLevel = this.level(); @@ -802,7 +802,7 @@ this.connection.resetPosition(); teleportTransition.postTeleportTransition().onTransition(this); return this; -@@ -1103,18 +_,19 @@ +@@ -1104,18 +_,19 @@ this.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); PlayerList playerList = this.server.getPlayerList(); playerList.sendPlayerPermissionLevel(this); @@ -824,7 +824,7 @@ this.connection.resetPosition(); level.addDuringTeleport(this); profilerFiller.pop(); -@@ -1129,6 +_,15 @@ +@@ -1130,6 +_,15 @@ this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(teleportTransition, serverLevel); @@ -840,7 +840,7 @@ return this; } } -@@ -1143,12 +_,26 @@ +@@ -1144,12 +_,26 @@ public void triggerDimensionChangeTriggers(ServerLevel level) { ResourceKey resourceKey = level.dimension(); ResourceKey resourceKey1 = this.level().dimension(); @@ -870,7 +870,7 @@ this.enteredNetherPosition = null; } } -@@ -1164,9 +_,8 @@ +@@ -1165,9 +_,8 @@ this.containerMenu.broadcastChanges(); } @@ -882,7 +882,7 @@ if (!this.isSleeping() && this.isAlive()) { BedRule bedRule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, bedPos); boolean canSleep = bedRule.canSleep(this.level()); -@@ -1180,7 +_,7 @@ +@@ -1181,7 +_,7 @@ } else { if (canSetSpawn) { this.setRespawnPosition( @@ -891,7 +891,7 @@ ); } -@@ -1202,7 +_,37 @@ +@@ -1203,7 +_,37 @@ } } @@ -930,7 +930,7 @@ this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1212,10 +_,7 @@ +@@ -1213,10 +_,7 @@ this.level().updateSleepingPlayerList(); return either; @@ -941,7 +941,7 @@ } } -@@ -1241,21 +_,29 @@ +@@ -1242,21 +_,29 @@ @Override public void stopSleepInBed(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) { @@ -974,7 +974,7 @@ } @Override -@@ -1303,8 +_,9 @@ +@@ -1304,8 +_,9 @@ this.connection.send(new ClientboundShowDialogPacket(dialog)); } @@ -985,7 +985,7 @@ } @Override -@@ -1312,12 +_,39 @@ +@@ -1313,12 +_,39 @@ if (menu == null) { return OptionalInt.empty(); } else { @@ -1026,7 +1026,7 @@ if (abstractContainerMenu == null) { if (this.isSpectator()) { this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true); -@@ -1325,10 +_,14 @@ +@@ -1326,10 +_,14 @@ return OptionalInt.empty(); } else { @@ -1043,7 +1043,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1341,14 +_,25 @@ +@@ -1342,14 +_,25 @@ @Override public void openHorseInventory(AbstractHorse horse, Container inventory) { @@ -1066,13 +1066,13 @@ - this.nextContainerCounter(); + // this.nextContainerCounter(); // CraftBukkit - moved up int inventoryColumns = horse.getInventoryColumns(); - this.connection.send(new ClientboundHorseScreenOpenPacket(this.containerCounter, inventoryColumns, horse.getId())); + this.connection.send(new ClientboundMountScreenOpenPacket(this.containerCounter, inventoryColumns, horse.getId())); - this.containerMenu = new HorseInventoryMenu(this.containerCounter, this.getInventory(), inventory, horse, inventoryColumns); + this.containerMenu = container; // CraftBukkit this.initMenu(this.containerMenu); } -@@ -1370,10 +_,30 @@ +@@ -1384,10 +_,30 @@ @Override public void closeContainer() { @@ -1103,7 +1103,7 @@ @Override public void doCloseContainer() { this.containerMenu.removed(this); -@@ -1396,19 +_,19 @@ +@@ -1410,19 +_,19 @@ int rounded = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); if (rounded > 0) { this.awardStat(Stats.SWIM_ONE_CM, rounded); @@ -1126,7 +1126,7 @@ } } else if (this.onClimbable()) { if (dy > 0.0) { -@@ -1419,13 +_,13 @@ +@@ -1433,13 +_,13 @@ if (rounded > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, rounded); @@ -1143,7 +1143,7 @@ } } } else if (this.isFallFlying()) { -@@ -1469,13 +_,13 @@ +@@ -1483,13 +_,13 @@ @Override public void awardStat(Stat stat, int amount) { this.stats.increment(this, stat, amount); @@ -1159,7 +1159,7 @@ } @Override -@@ -1506,9 +_,9 @@ +@@ -1520,9 +_,9 @@ super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1171,7 +1171,7 @@ } } -@@ -1523,6 +_,13 @@ +@@ -1537,6 +_,13 @@ public void disconnect() { this.disconnected = true; this.ejectPassengers(); @@ -1185,7 +1185,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, false); } -@@ -1534,6 +_,7 @@ +@@ -1548,6 +_,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1193,7 +1193,7 @@ } @Override -@@ -1568,12 +_,12 @@ +@@ -1582,12 +_,12 @@ this.onUpdateAbilities(); if (keepEverything) { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1208,7 +1208,7 @@ } this.getInventory().replaceWith(that.getInventory()); -@@ -1584,7 +_,7 @@ +@@ -1598,7 +_,7 @@ this.portalProcess = that.portalProcess; } else { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1217,7 +1217,7 @@ if (this.level().getGameRules().get(GameRules.KEEP_INVENTORY) || that.isSpectator()) { this.getInventory().replaceWith(that.getInventory()); this.experienceLevel = that.experienceLevel; -@@ -1600,7 +_,7 @@ +@@ -1614,7 +_,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1226,7 +1226,7 @@ this.seenCredits = that.seenCredits; this.enteredNetherPosition = that.enteredNetherPosition; this.chunkTrackingView = that.chunkTrackingView; -@@ -1643,9 +_,22 @@ +@@ -1657,9 +_,22 @@ CriteriaTriggers.EFFECTS_CHANGED.trigger(this, null); } @@ -1250,7 +1250,7 @@ } @Override -@@ -1654,7 +_,7 @@ +@@ -1668,7 +_,7 @@ } @Override @@ -1259,7 +1259,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, true); } -@@ -1663,7 +_,7 @@ +@@ -1677,7 +_,7 @@ this.setCamera(this); } @@ -1268,7 +1268,7 @@ if (flag) { this.setYHeadRot(relativeMovements.contains(Relative.Y_ROT) ? this.getYHeadRot() + yaw : yaw); this.connection.resetFlyingTicks(); -@@ -1702,9 +_,18 @@ +@@ -1716,9 +_,18 @@ } public boolean setGameMode(GameType gameMode) { @@ -1289,7 +1289,7 @@ } else { this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, gameMode.getId())); if (gameMode == GameType.SPECTATOR) { -@@ -1720,7 +_,7 @@ +@@ -1735,7 +_,7 @@ this.onUpdateAbilities(); this.updateEffectVisibility(); @@ -1298,7 +1298,7 @@ } } -@@ -1775,8 +_,13 @@ +@@ -1790,8 +_,13 @@ } public void sendChatMessage(OutgoingChatMessage message, boolean filtered, ChatType.Bound boundChatType) { @@ -1313,7 +1313,7 @@ } } -@@ -1787,7 +_,42 @@ +@@ -1802,7 +_,42 @@ } public void updateOptions(ClientInformation clientInformation) { @@ -1356,7 +1356,7 @@ this.requestedViewDistance = clientInformation.viewDistance(); this.chatVisibility = clientInformation.chatVisibility(); this.canChatColor = clientInformation.chatColors(); -@@ -1872,8 +_,23 @@ +@@ -1887,8 +_,23 @@ Entity camera = this.getCamera(); this.camera = (Entity)(entityToSpectate == null ? this : entityToSpectate); if (camera != this.camera) { @@ -1381,7 +1381,7 @@ } if (entityToSpectate != null) { -@@ -1906,11 +_,11 @@ +@@ -1921,11 +_,11 @@ } public @Nullable Component getTabListDisplayName() { @@ -1395,7 +1395,7 @@ } @Override -@@ -1940,11 +_,62 @@ +@@ -1955,11 +_,62 @@ } public void setRespawnPosition(ServerPlayer.@Nullable RespawnConfig respawnConfig, boolean displayInChat) { @@ -1460,7 +1460,7 @@ } public SectionPos getLastSectionPos() { -@@ -1974,16 +_,23 @@ +@@ -1989,16 +_,23 @@ } @Override @@ -1489,7 +1489,7 @@ return itemEntity; } -@@ -2035,7 +_,7 @@ +@@ -2050,7 +_,7 @@ super.updateUsingItem(usingItem); } @@ -1498,7 +1498,7 @@ Inventory inventory = this.getInventory(); ItemStack itemStack = inventory.removeFromSelected(dropStack); this.containerMenu -@@ -2045,7 +_,7 @@ +@@ -2060,7 +_,7 @@ this.stopUsingItem(); } @@ -1507,7 +1507,7 @@ } @Override -@@ -2108,9 +_,9 @@ +@@ -2123,9 +_,9 @@ } @Override @@ -1519,7 +1519,7 @@ if (vehicle instanceof LivingEntity livingEntity) { for (MobEffectInstance mobEffectInstance : livingEntity.getActiveEffects()) { this.connection.send(new ClientboundRemoveMobEffectPacket(vehicle.getId(), mobEffectInstance.getEffect())); -@@ -2232,7 +_,7 @@ +@@ -2247,7 +_,7 @@ } public static long placeEnderPearlTicket(ServerLevel level, ChunkPos pos) { @@ -1528,7 +1528,7 @@ return TicketType.ENDER_PEARL.timeout(); } -@@ -2262,9 +_,11 @@ +@@ -2277,9 +_,11 @@ } } @@ -1543,7 +1543,7 @@ } private static float calculateLookAtYaw(Vec3 position, BlockPos towardsPos) { -@@ -2284,4 +_,135 @@ +@@ -2299,4 +_,135 @@ ); public static final ServerPlayer.SavedPosition EMPTY = new ServerPlayer.SavedPosition(Optional.empty(), Optional.empty(), Optional.empty()); } diff --git a/paper-server/patches/sources/net/minecraft/server/players/StoredUserList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/StoredUserList.java.patch index 939fcbdb3ad3..b0d0b8a25fb1 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/StoredUserList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/StoredUserList.java.patch @@ -23,15 +23,6 @@ } public boolean remove(K user) { -@@ -97,7 +_,7 @@ - } - - public boolean isEmpty() { -- return this.map.size() < 1; -+ return this.map.isEmpty(); // Paper - Use ConcurrentHashMap in StoredUserList - } - - protected String getKeyForUser(K user) { @@ -105,21 +_,12 @@ } diff --git a/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch b/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch index f49aaf7f2381..d89f25336169 100644 --- a/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/datafix/DataFixers.java +++ b/net/minecraft/util/datafix/DataFixers.java -@@ -533,6 +_,24 @@ +@@ -534,6 +_,24 @@ Schema schema44 = builder.addSchema(1456, SAME_NAMESPACED); builder.addFixer(new EntityItemFrameDirectionFix(schema44, false)); Schema schema45 = builder.addSchema(1458, V1458::new); diff --git a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch index c0642b162e3d..54b2f1ba668e 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffectUtil.java +++ b/net/minecraft/world/effect/MobEffectUtil.java -@@ -49,18 +_,38 @@ +@@ -55,18 +_,38 @@ public static List addEffectToPlayersAround( ServerLevel level, @Nullable Entity source, Vec3 pos, double radius, MobEffectInstance effect, int duration ) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index c54ba95ebd05..21a473d062e9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -782,7 +782,7 @@ + // CraftBukkit end serverPlayer.awardStat(Stats.ITEM_USED.get(itemStack.getItem())); CriteriaTriggers.USED_TOTEM.trigger(serverPlayer, itemStack); - this.gameEvent(GameEvent.ITEM_INTERACT_FINISH); + itemStack.causeUseVibration(this, GameEvent.ITEM_INTERACT_FINISH); @@ -1429,6 +_,7 @@ if (!this.isRemoved() && !this.dead) { Entity entity = damageSource.getEntity(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch index 31833a858436..3adf91fc4fa5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/animal/Pig.java +++ b/net/minecraft/world/entity/animal/Pig.java -@@ -214,7 +_,14 @@ - } - +@@ -211,7 +_,14 @@ + ZombifiedPiglin zombifiedPiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, false, true), mob -> { + mob.populateDefaultEquipmentSlots(this.getRandom(), level.getCurrentDifficultyAt(this.blockPosition())); mob.setPersistenceRequired(); - }); + // CraftBukkit start diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/ShootTongue.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/ShootTongue.java.patch index f503b6b31023..3b1480d7f079 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/ShootTongue.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/ShootTongue.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/frog/ShootTongue.java +++ b/net/minecraft/world/entity/animal/frog/ShootTongue.java -@@ -96,7 +_,7 @@ +@@ -94,7 +_,7 @@ if (entity.isAlive()) { frog.doHurtTarget(level, entity); if (!entity.isAlive()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch index a2d2806b86d7..b586611ed9d9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java -@@ -123,6 +_,7 @@ +@@ -124,6 +_,7 @@ protected boolean canGallop = true; protected int gallopSoundCounter; public @Nullable EntityReference owner; @@ -8,7 +8,7 @@ protected AbstractHorse(EntityType type, Level level) { super(type, level); -@@ -251,7 +_,7 @@ +@@ -252,7 +_,7 @@ } @Override @@ -17,7 +17,7 @@ return !this.isVehicle(); } -@@ -302,7 +_,7 @@ +@@ -299,7 +_,7 @@ public void createInventory() { SimpleContainer simpleContainer = this.inventory; @@ -26,7 +26,7 @@ if (simpleContainer != null) { int min = Math.min(simpleContainer.getContainerSize(), this.inventory.getContainerSize()); -@@ -394,7 +_,7 @@ +@@ -391,7 +_,7 @@ } public int getMaxTemper() { @@ -35,7 +35,7 @@ } @Override -@@ -457,7 +_,7 @@ +@@ -454,7 +_,7 @@ i1 = 5; if (!this.level().isClientSide() && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { flag = true; @@ -44,7 +44,7 @@ } } else if (stack.is(Items.GOLDEN_APPLE) || stack.is(Items.ENCHANTED_GOLDEN_APPLE)) { f = 10.0F; -@@ -465,12 +_,12 @@ +@@ -462,12 +_,12 @@ i1 = 10; if (!this.level().isClientSide() && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { flag = true; @@ -59,7 +59,7 @@ flag = true; } -@@ -541,7 +_,7 @@ +@@ -538,7 +_,7 @@ super.aiStep(); if (this.level() instanceof ServerLevel serverLevel && this.isAlive()) { if (this.random.nextInt(900) == 0 && this.deathTime == 0) { @@ -68,7 +68,7 @@ } if (this.canEatGrass()) { -@@ -643,6 +_,16 @@ +@@ -640,6 +_,16 @@ } } @@ -85,7 +85,7 @@ @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { if (this.isVehicle() || this.isBaby()) { -@@ -794,6 +_,7 @@ +@@ -791,6 +_,7 @@ output.putInt("Temper", this.getTemper()); output.putBoolean("Tame", this.isTamed()); EntityReference.store(this.owner, output, "Owner"); @@ -93,7 +93,7 @@ } @Override -@@ -804,6 +_,7 @@ +@@ -801,6 +_,7 @@ this.setTemper(input.getIntOr("Temper", 0)); this.setTamed(input.getBooleanOr("Tame", false)); this.owner = EntityReference.readWithOldOwnerConversion(input, "Owner", this.level()); @@ -101,7 +101,7 @@ } @Override -@@ -891,6 +_,17 @@ +@@ -888,6 +_,17 @@ @Override public void handleStartJump(int jumpPower) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch index 3ff93cb0e3cc..b09f144f8b61 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java +++ b/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java -@@ -247,7 +_,7 @@ +@@ -256,7 +_,7 @@ boolean hasEffect = player.hasEffect(MobEffects.BREATH_OF_THE_NAUTILUS); boolean flag = level.getGameTime() % 40L == 0L; if (!hasEffect || flag) { @@ -9,16 +9,16 @@ } } } -@@ -387,7 +_,7 @@ +@@ -398,7 +_,7 @@ + if (this.isFood(itemInHand) && this.getHealth() < this.getMaxHealth()) { - this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); - this.heal(foodProperties != null ? 2 * foodProperties.nutrition() : 1.0F); + this.heal(foodProperties != null ? 2 * foodProperties.nutrition() : 1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper - Add regain reason + this.usePlayerItem(player, hand, itemInHand); this.playEatingSound(); return InteractionResult.SUCCESS; - } -@@ -408,7 +_,7 @@ +@@ -426,7 +_,7 @@ } private void tryToTame(Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch index 75ed4eb61e6e..28b883945a16 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Drowned.java +++ b/net/minecraft/world/entity/monster/Drowned.java -@@ -89,7 +_,7 @@ +@@ -88,7 +_,7 @@ this.goalSelector.addGoal(7, new RandomStrollGoal(this, 1.0)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this, Drowned.class).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, (entity, level) -> this.okTarget(entity))); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index 175af9b04800..2319957df4f5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -150,7 +_,7 @@ +@@ -151,7 +_,7 @@ private static final boolean DEFAULT_IGNORE_FALL_DAMAGE_FROM_CURRENT_IMPULSE = false; private static final int DEFAULT_CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME = 0; final Inventory inventory; @@ -9,7 +9,7 @@ public final InventoryMenu inventoryMenu; public AbstractContainerMenu containerMenu; protected FoodData foodData = new FoodData(); -@@ -178,6 +_,18 @@ +@@ -179,6 +_,18 @@ public @Nullable Entity currentExplosionCause; private boolean ignoreFallDamageFromCurrentImpulse = false; private int currentImpulseContextResetGraceTime = 0; @@ -28,7 +28,7 @@ public Player(Level level, GameProfile gameProfile) { super(EntityType.PLAYER, level); -@@ -245,6 +_,13 @@ +@@ -246,6 +_,13 @@ if (this.isSleeping()) { this.sleepCounter++; @@ -42,7 +42,7 @@ if (this.sleepCounter > 100) { this.sleepCounter = 100; } -@@ -328,7 +_,7 @@ +@@ -329,7 +_,7 @@ } private void turtleHelmetTick() { @@ -51,7 +51,7 @@ } private boolean isEquipped(Item item) { -@@ -432,6 +_,18 @@ +@@ -433,6 +_,18 @@ } } @@ -70,7 +70,7 @@ public void closeContainer() { this.containerMenu = this.inventoryMenu; } -@@ -443,8 +_,14 @@ +@@ -444,8 +_,14 @@ public void rideTick() { if (!this.level().isClientSide() && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -87,7 +87,7 @@ super.rideTick(); } } -@@ -703,10 +_,10 @@ +@@ -704,10 +_,10 @@ if (this.isDeadOrDying()) { return false; } else { @@ -100,7 +100,7 @@ } if (level.getDifficulty() == Difficulty.EASY) { -@@ -718,7 +_,14 @@ +@@ -719,7 +_,14 @@ } } @@ -116,7 +116,7 @@ } } } -@@ -730,7 +_,7 @@ +@@ -731,7 +_,7 @@ BlocksAttacks blocksAttacks = itemBlockingWith != null ? itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS) : null; float secondsToDisableBlocking = entity.getSecondsToDisableBlocking(); if (secondsToDisableBlocking > 0.0F && blocksAttacks != null) { @@ -125,7 +125,7 @@ } } -@@ -740,9 +_,29 @@ +@@ -741,9 +_,29 @@ } public boolean canHarmPlayer(Player other) { @@ -158,7 +158,7 @@ } @Override -@@ -756,7 +_,12 @@ +@@ -757,7 +_,12 @@ } @Override @@ -172,7 +172,7 @@ if (!this.isInvulnerableTo(level, damageSource)) { amount = this.getDamageAfterArmorAbsorb(damageSource, amount); amount = this.getDamageAfterMagicAbsorb(damageSource, amount); -@@ -768,7 +_,7 @@ +@@ -769,7 +_,7 @@ } if (var8 != 0.0F) { @@ -181,7 +181,7 @@ this.getCombatTracker().recordDamage(damageSource, var8); this.setHealth(this.getHealth() - var8); if (var8 < 3.4028235E37F) { -@@ -778,6 +_,7 @@ +@@ -779,6 +_,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -189,7 +189,7 @@ } public boolean isTextFilteringEnabled() { -@@ -861,14 +_,16 @@ +@@ -865,14 +_,16 @@ } @Override @@ -209,7 +209,7 @@ } @Override -@@ -947,15 +_,25 @@ +@@ -951,15 +_,25 @@ } public void attack(Entity target) { @@ -238,7 +238,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = attackStrengthScale > 0.9F; boolean flag1; -@@ -968,7 +_,9 @@ +@@ -972,7 +_,9 @@ f += weaponItem.getItem().getAttackDamageBonus(target, f, damageSource); boolean flag2 = flag && this.canCriticalAttack(target); @@ -248,7 +248,7 @@ f *= 1.5F; } -@@ -1014,11 +_,12 @@ +@@ -1018,11 +_,12 @@ return !target.isAttackable() || target.skipAttackInteraction(this); } @@ -263,7 +263,7 @@ return true; } else { return false; -@@ -1111,21 +_,43 @@ +@@ -1115,21 +_,43 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F) { if (target instanceof LivingEntity livingEntity) { @@ -308,7 +308,7 @@ } } -@@ -1146,7 +_,10 @@ +@@ -1150,7 +_,10 @@ && !(livingEntity instanceof ArmorStand armorStand && armorStand.isMarker()) && this.distanceToSqr(livingEntity) < 9.0) { float f1 = this.getEnchantedDamage(livingEntity, var12, damageSource) * strengthScale; @@ -320,7 +320,7 @@ livingEntity.knockback(0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity, damageSource); } -@@ -1178,14 +_,23 @@ +@@ -1182,7 +_,16 @@ @Override public boolean stabAttack(EquipmentSlot slot, Entity target, float damageAmount, boolean damage, boolean knockback, boolean dismount) { @@ -338,15 +338,16 @@ return false; } else { ItemStack itemBySlot = this.getItemBySlot(slot); - DamageSource damageSource = this.createAttackSource(itemBySlot); - float f = this.getAttackStrengthScale(0.5F) * (this.getEnchantedDamage(target, damageAmount, damageSource) - damageAmount); - damageAmount *= this.baseDamageScaleFactor(); +@@ -1193,7 +_,7 @@ + damageAmount *= this.baseDamageScaleFactor(); + } + - if (knockback && this.deflectProjectile(target)) { + if (knockback && this.deflectProjectile(target, () -> !org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(target, damageSource, f, false))) { // Paper - damage events return true; } else { float f1 = damage ? damageAmount + f : 0.0F; -@@ -1213,7 +_,7 @@ +@@ -1221,7 +_,7 @@ this.setLastHurtMob(target); this.itemAttackInteraction(target, itemBySlot, damageSource, flag); this.damageStatsAndHearts(target, f2); @@ -355,7 +356,7 @@ return true; } } -@@ -1224,8 +_,8 @@ +@@ -1232,8 +_,8 @@ } @Override @@ -366,7 +367,7 @@ this.inventoryMenu.removed(this); if (this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1293,6 +_,12 @@ +@@ -1301,6 +_,12 @@ } public Either startSleepInBed(BlockPos bedPos) { @@ -379,7 +380,7 @@ this.startSleeping(bedPos); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1404,7 +_,7 @@ +@@ -1412,7 +_,7 @@ @Override public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) { @@ -388,7 +389,7 @@ return false; } else { if (fallDistance >= 2.0) { -@@ -1445,7 +_,15 @@ +@@ -1453,7 +_,15 @@ } public void startFallFlying() { @@ -405,7 +406,7 @@ } @Override -@@ -1543,7 +_,7 @@ +@@ -1551,7 +_,7 @@ if (levels > 0 && this.experienceLevel % 5 == 0 && this.lastLevelUpTime < this.tickCount - 100.0F) { float f = this.experienceLevel > 30 ? 1.0F : this.experienceLevel / 30.0F; @@ -414,7 +415,7 @@ this.lastLevelUpTime = this.tickCount; } } -@@ -1551,15 +_,35 @@ +@@ -1559,15 +_,35 @@ public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { return 112 + (this.experienceLevel - 30) * 9; @@ -452,7 +453,7 @@ } } } -@@ -1818,7 +_,7 @@ +@@ -1826,7 +_,7 @@ @Override public void onAttack() { @@ -461,7 +462,7 @@ super.onAttack(); } -@@ -1853,17 +_,32 @@ +@@ -1861,17 +_,32 @@ return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } @@ -496,7 +497,7 @@ for (int i = 0; i < this.inventory.getContainerSize(); i++) { ItemStack item = this.inventory.getItem(i); -@@ -1872,6 +_,7 @@ +@@ -1880,6 +_,7 @@ } } @@ -504,7 +505,7 @@ return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; } } -@@ -1958,12 +_,20 @@ +@@ -1966,12 +_,20 @@ } public boolean hasClientLoaded() { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractMountInventoryMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractMountInventoryMenu.java.patch new file mode 100644 index 000000000000..209032c2f1d4 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractMountInventoryMenu.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/world/inventory/AbstractMountInventoryMenu.java ++++ b/net/minecraft/world/inventory/AbstractMountInventoryMenu.java +@@ -14,8 +_,23 @@ + protected final int SLOT_INVENTORY_START = 2; + protected static final int INVENTORY_ROWS = 3; + ++ // CraftBukkit start ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view; ++ private final Inventory inventory; ++ ++ @Override ++ public org.bukkit.inventory.InventoryView getBukkitView() { ++ if (this.view != null) { ++ return this.view; ++ } ++ ++ return this.view = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.inventory.player.getBukkitEntity(), this.mountContainer.getOwner().getInventory(), this); ++ } ++ // CraftBukkit end ++ + protected AbstractMountInventoryMenu(int containerId, Inventory playerInventory, Container mountContainer, LivingEntity mount) { + super(null, containerId); ++ this.inventory = playerInventory; // CraftBukkit + this.mountContainer = mountContainer; + this.mount = mount; + mountContainer.startOpen(playerInventory.player); diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/HorseInventoryMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/HorseInventoryMenu.java.patch deleted file mode 100644 index 1526896b913f..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/inventory/HorseInventoryMenu.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/world/inventory/HorseInventoryMenu.java -+++ b/net/minecraft/world/inventory/HorseInventoryMenu.java -@@ -19,9 +_,23 @@ - public static final int SLOT_SADDLE = 0; - public static final int SLOT_BODY_ARMOR = 1; - public static final int SLOT_HORSE_INVENTORY_START = 2; -+ // CraftBukkit start -+ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view; -+ private final Inventory inventory; -+ -+ @Override -+ public org.bukkit.inventory.InventoryView getBukkitView() { -+ if (this.view != null) { -+ return this.view; -+ } -+ -+ return this.view = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.inventory.player.getBukkitEntity(), this.horseContainer.getOwner().getInventory(), this); -+ } -+ // CraftBukkit end - - public HorseInventoryMenu(int containerId, Inventory inventory, Container horseContainer, final AbstractHorse horse, int columns) { - super(null, containerId); -+ this.inventory = inventory; // CraftBukkit - this.horseContainer = horseContainer; - this.horse = horse; - horseContainer.startOpen(inventory.player); diff --git a/paper-server/patches/sources/net/minecraft/world/item/BoneMealItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/BoneMealItem.java.patch index a286e29b55e2..71411b0ac61e 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BoneMealItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/BoneMealItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BoneMealItem.java +++ b/net/minecraft/world/item/BoneMealItem.java -@@ -35,12 +_,17 @@ +@@ -35,13 +_,18 @@ @Override public InteractionResult useOn(UseOnContext context) { @@ -12,19 +12,20 @@ Level level = context.getLevel(); BlockPos clickedPos = context.getClickedPos(); BlockPos blockPos = clickedPos.relative(context.getClickedFace()); - if (growCrop(context.getItemInHand(), level, clickedPos)) { + ItemStack itemInHand = context.getItemInHand(); + if (growCrop(itemInHand, level, clickedPos)) { if (!level.isClientSide()) { -- context.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); -+ if (context.getPlayer() != null) context.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518 +- itemInHand.causeUseVibration(context.getPlayer(), GameEvent.ITEM_INTERACT_FINISH); ++ if (context.getPlayer() != null) itemInHand.causeUseVibration(context.getPlayer(), GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518 level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, clickedPos, 15); } -@@ -50,7 +_,7 @@ +@@ -51,7 +_,7 @@ boolean isFaceSturdy = blockState.isFaceSturdy(level, clickedPos, context.getClickedFace()); - if (isFaceSturdy && growWaterPlant(context.getItemInHand(), level, blockPos, context.getClickedFace())) { + if (isFaceSturdy && growWaterPlant(itemInHand, level, blockPos, context.getClickedFace())) { if (!level.isClientSide()) { -- context.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); -+ if (context.getPlayer() != null) context.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518 +- itemInHand.causeUseVibration(context.getPlayer(), GameEvent.ITEM_INTERACT_FINISH); ++ if (context.getPlayer() != null) itemInHand.causeUseVibration(context.getPlayer(), GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518 level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, blockPos, 15); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch index 201431097b2a..16bc842d8e84 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch @@ -11,7 +11,7 @@ @@ -39,20 +_,31 @@ ); - player.gameEvent(GameEvent.ITEM_INTERACT_FINISH); + itemInHand.causeUseVibration(player, GameEvent.ITEM_INTERACT_FINISH); } else { - level.playSound( - null, diff --git a/paper-server/patches/sources/net/minecraft/world/item/HoneycombItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/HoneycombItem.java.patch index 5c696fc98097..1710d50a1cac 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/HoneycombItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/HoneycombItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/HoneycombItem.java +++ b/net/minecraft/world/item/HoneycombItem.java -@@ -92,6 +_,14 @@ +@@ -146,6 +_,14 @@ return getWaxed(blockState).map(blockState1 -> { Player player = context.getPlayer(); ItemStack itemInHand = context.getItemInHand(); diff --git a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch index aa5f6cfa28cb..45bed600d1d6 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -200,12 +_,20 @@ +@@ -202,12 +_,20 @@ @Override public void encode(RegistryFriendlyByteBuf buffer, ItemStack value) { @@ -23,7 +23,7 @@ } } }; -@@ -369,10 +_,166 @@ +@@ -371,10 +_,166 @@ return InteractionResult.PASS; } else { Item item = this.getItem(); @@ -192,7 +192,7 @@ return interactionResult; } -@@ -453,31 +_,67 @@ +@@ -455,31 +_,67 @@ return this.isDamageableItem() && this.getDamageValue() >= this.getMaxDamage() - 1; } @@ -268,7 +268,7 @@ this.shrink(1); onBreak.accept(item); } -@@ -490,7 +_,26 @@ +@@ -492,7 +_,26 @@ return; } @@ -296,7 +296,7 @@ this.applyDamage(min, serverPlayer, item -> {}); } } -@@ -500,9 +_,14 @@ +@@ -502,9 +_,14 @@ } public void hurtAndBreak(int amount, LivingEntity entity, EquipmentSlot slot) { @@ -312,7 +312,7 @@ ); } } -@@ -744,6 +_,12 @@ +@@ -753,6 +_,12 @@ return this.getItem().useOnRelease(this); } @@ -325,7 +325,7 @@ public @Nullable T set(DataComponentType component, @Nullable T value) { return this.components.set(component, value); } -@@ -787,6 +_,28 @@ +@@ -796,6 +_,28 @@ this.components.setAll(components); } @@ -354,7 +354,7 @@ public Component getHoverName() { Component customName = this.getCustomName(); return customName != null ? customName : this.getItemName(); -@@ -1017,6 +_,19 @@ +@@ -1026,6 +_,19 @@ EnchantmentHelper.forEachModifier(this, slot, action); } @@ -374,7 +374,7 @@ public Component getDisplayName() { MutableComponent mutableComponent = Component.empty().append(this.getHoverName()); if (this.has(DataComponents.CUSTOM_NAME)) { -@@ -1076,7 +_,7 @@ +@@ -1085,7 +_,7 @@ } public void consume(int amount, @Nullable LivingEntity entity) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch index 0019708d387c..416739da623a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BedBlock.java +++ b/net/minecraft/world/level/block/BedBlock.java -@@ -92,7 +_,7 @@ +@@ -91,7 +_,7 @@ } BedRule bedRule = level.environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos); @@ -9,7 +9,7 @@ bedRule.errorMessage().ifPresent(component -> player.displayClientMessage(component, true)); level.removeBlock(pos, false); BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); -@@ -104,22 +_,56 @@ +@@ -103,22 +_,56 @@ level.explode(null, level.damageSources().badRespawnPointExplosion(center), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); return InteractionResult.SUCCESS_SERVER; } else if (state.getValue(OCCUPIED)) { @@ -67,7 +67,7 @@ private boolean kickVillagerOutOfBed(Level level, BlockPos pos) { List entitiesOfClass = level.getEntitiesOfClass(Villager.class, new AABB(pos), LivingEntity::isSleeping); if (entitiesOfClass.isEmpty()) { -@@ -297,6 +_,11 @@ +@@ -296,6 +_,11 @@ if (!level.isClientSide()) { BlockPos blockPos = pos.relative(state.getValue(FACING)); level.setBlock(blockPos, state.setValue(PART, BedPart.HEAD), Block.UPDATE_ALL); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ShelfBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ShelfBlock.java.patch index 5ce61082d8a7..67623f8446d0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ShelfBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ShelfBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ShelfBlock.java +++ b/net/minecraft/world/level/block/ShelfBlock.java -@@ -108,6 +_,11 @@ +@@ -109,6 +_,11 @@ if (!level.isClientSide()) { boolean hasNeighborSignal = level.hasNeighborSignal(pos); if (state.getValue(POWERED) != hasNeighborSignal) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch index 0edf671ca59d..f7dd0ba9f20a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ShulkerBoxBlock.java +++ b/net/minecraft/world/level/block/ShulkerBoxBlock.java -@@ -71,8 +_,8 @@ +@@ -76,8 +_,8 @@ protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { if (level instanceof ServerLevel serverLevel && level.getBlockEntity(pos) instanceof ShulkerBoxBlockEntity shulkerBoxBlockEntity @@ -11,7 +11,7 @@ player.awardStat(Stats.OPEN_SHULKER_BOX); PiglinAi.angerNearbyPiglins(serverLevel, player, true); } -@@ -110,7 +_,7 @@ +@@ -115,7 +_,7 @@ itemEntity.setDefaultPickUpDelay(); level.addFreshEntity(itemEntity); } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShelfBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShelfBlockEntity.java.patch index cce435d19b5a..ca4946a67577 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShelfBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShelfBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ShelfBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ShelfBlockEntity.java -@@ -35,6 +_,47 @@ +@@ -36,6 +_,47 @@ private final NonNullList items = NonNullList.withSize(3, ItemStack.EMPTY); private boolean alignItemsToBottom; diff --git a/paper-server/patches/sources/net/minecraft/world/level/gamerules/GameRules.java.patch b/paper-server/patches/sources/net/minecraft/world/level/gamerules/GameRules.java.patch index 43016612fa34..afb8178f0114 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/gamerules/GameRules.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/gamerules/GameRules.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/gamerules/GameRules.java +++ b/net/minecraft/world/level/gamerules/GameRules.java -@@ -16,6 +_,14 @@ +@@ -17,6 +_,14 @@ import org.jspecify.annotations.Nullable; public class GameRules { @@ -15,7 +15,7 @@ public static final GameRule ADVANCE_TIME = registerBoolean("advance_time", GameRuleCategory.UPDATES, !SharedConstants.DEBUG_WORLD_RECREATE); public static final GameRule ADVANCE_WEATHER = registerBoolean("advance_weather", GameRuleCategory.UPDATES, !SharedConstants.DEBUG_WORLD_RECREATE); public static final GameRule ALLOW_ENTERING_NETHER_USING_PORTALS = registerBoolean( -@@ -113,13 +_,15 @@ +@@ -114,13 +_,15 @@ } } @@ -34,7 +34,7 @@ } } } -@@ -128,16 +_,22 @@ +@@ -129,16 +_,22 @@ return new GameRules(enabledFeatures, this.rules); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch index 3a9a49e7ff97..ec0dfb0392aa 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch @@ -20,7 +20,7 @@ @@ -62,9 +_,25 @@ private Optional load(NameAndId nameAndId, String suffix) { - File file = new File(this.playerDir, nameAndId.id().toString() + suffix); + File file = new File(this.playerDir, nameAndId.id() + suffix); + // Spigot start + boolean usingWrongFile = false; + if (org.bukkit.Bukkit.getOnlineMode() && !file.exists()) { // Paper - Check online mode first From b98e00c7630358a81c81c2262f0ee26c77020f5f Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 11 Nov 2025 12:37:24 -0700 Subject: [PATCH 072/112] Misc. 25w46a fixes --- build-data/paper.at | 8 ++++---- .../paper/datacomponent/item/UseEffects.java | 13 +++++++++++++ .../world/entity/player/Player.java.patch | 5 +++-- .../AbstractMountInventoryMenu.java.patch | 12 ++++++++++-- .../datacomponent/item/PaperUseEffects.java | 13 +++++++++++++ .../craftbukkit/entity/CraftHumanEntity.java | 19 +++++++++++++++---- .../CraftInventoryAbstractHorse.java | 8 ++++---- 7 files changed, 62 insertions(+), 16 deletions(-) diff --git a/build-data/paper.at b/build-data/paper.at index 9e232519d842..ab88ea8c922a 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -520,16 +520,16 @@ public net.minecraft.world.inventory.AbstractContainerMenu synchronizeSlotToRemo public net.minecraft.world.inventory.AbstractContainerMenu triggerSlotListeners(ILnet/minecraft/world/item/ItemStack;Ljava/util/function/Supplier;)V public net.minecraft.world.inventory.AbstractCraftingMenu craftSlots public net.minecraft.world.inventory.AbstractCraftingMenu resultSlots +public net.minecraft.world.inventory.AbstractMountInventoryMenu SLOT_BODY_ARMOR +public net.minecraft.world.inventory.AbstractMountInventoryMenu SLOT_INVENTORY_START +public net.minecraft.world.inventory.AbstractMountInventoryMenu SLOT_SADDLE +public net.minecraft.world.inventory.AbstractMountInventoryMenu mount public net.minecraft.world.inventory.AnvilMenu cost public net.minecraft.world.inventory.AnvilMenu itemName public net.minecraft.world.inventory.AnvilMenu repairItemCountCost public net.minecraft.world.inventory.BrewingStandMenu brewingStandData public net.minecraft.world.inventory.CraftingMenu access public net.minecraft.world.inventory.DispenserMenu dispenser -public net.minecraft.world.inventory.HorseInventoryMenu SLOT_BODY_ARMOR -public net.minecraft.world.inventory.HorseInventoryMenu SLOT_HORSE_INVENTORY_START -public net.minecraft.world.inventory.HorseInventoryMenu SLOT_SADDLE -public net.minecraft.world.inventory.HorseInventoryMenu horse public net.minecraft.world.inventory.MerchantContainer selectionHint public net.minecraft.world.inventory.Slot slot public net.minecraft.world.item.AdventureModePredicate predicates diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java index a0f4aa455424..31af577bda64 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java @@ -22,6 +22,9 @@ static Builder useEffects() { @Contract(pure = true) boolean canSprint(); + @Contract(pure = true) + boolean interactVibrations(); + @Contract(pure = true) float speedMultiplier(); @@ -42,6 +45,16 @@ interface Builder extends DataComponentBuilder { @Contract(value = "_ -> this", mutates = "this") Builder canSprint(boolean canSprint); + /** + * Sets whether using the item generates interaction vibrations. + * + * @param interactVibrations true to generate vibrations + * @return the builder for chaining + * @see #interactVibrations() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder interactVibrations(boolean interactVibrations); + /** * Sets the speed multiplier while using the item. * diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index 2319957df4f5..e61a241d39ca 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -338,12 +338,13 @@ return false; } else { ItemStack itemBySlot = this.getItemBySlot(slot); -@@ -1193,7 +_,7 @@ +@@ -1193,7 +_,8 @@ damageAmount *= this.baseDamageScaleFactor(); } - if (knockback && this.deflectProjectile(target)) { -+ if (knockback && this.deflectProjectile(target, () -> !org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(target, damageSource, f, false))) { // Paper - damage events ++ final float dmgFinal = f; // Paper - damage events ++ if (knockback && this.deflectProjectile(target, () -> !org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(target, damageSource, dmgFinal, false))) { // Paper - damage events return true; } else { float f1 = damage ? damageAmount + f : 0.0F; diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractMountInventoryMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractMountInventoryMenu.java.patch index 209032c2f1d4..55a058461158 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractMountInventoryMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractMountInventoryMenu.java.patch @@ -1,7 +1,15 @@ --- a/net/minecraft/world/inventory/AbstractMountInventoryMenu.java +++ b/net/minecraft/world/inventory/AbstractMountInventoryMenu.java -@@ -14,8 +_,23 @@ - protected final int SLOT_INVENTORY_START = 2; +@@ -9,13 +_,28 @@ + public abstract class AbstractMountInventoryMenu extends AbstractContainerMenu { + protected final Container mountContainer; + public final LivingEntity mount; +- public final int SLOT_SADDLE = 0; +- public final int SLOT_BODY_ARMOR = 1; +- public final int SLOT_INVENTORY_START = 2; ++ public static final int SLOT_SADDLE = 0; // Paper - fix missing static ++ public static final int SLOT_BODY_ARMOR = 1; // Paper - fix missing static ++ public static final int SLOT_INVENTORY_START = 2; // Paper - fix missing static protected static final int INVENTORY_ROWS = 3; + // CraftBukkit start diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java index 46f0b0350aa1..8b3ad2095296 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java @@ -17,6 +17,11 @@ public boolean canSprint() { return this.impl.canSprint(); } + @Override + public boolean interactVibrations() { + return this.impl.interactVibrations(); + } + @Override public float speedMultiplier() { return this.impl.speedMultiplier(); @@ -25,6 +30,7 @@ public float speedMultiplier() { static final class BuilderImpl implements UseEffects.Builder { private boolean canSprint = net.minecraft.world.item.component.UseEffects.DEFAULT.canSprint(); + private boolean interactVibrations = net.minecraft.world.item.component.UseEffects.DEFAULT.interactVibrations(); private float speedMultiplier = net.minecraft.world.item.component.UseEffects.DEFAULT.speedMultiplier(); @Override @@ -33,6 +39,12 @@ public UseEffects.Builder canSprint(final boolean canSprint) { return this; } + @Override + public UseEffects.Builder interactVibrations(final boolean interactVibrations) { + this.interactVibrations = interactVibrations; + return this; + } + @Override public UseEffects.Builder speedMultiplier(final float speedMultiplier) { Preconditions.checkArgument(speedMultiplier >= 0.0F && speedMultiplier <= 1.0F, "speedMultiplier must be between 0.0 and 1.0 (inclusive)"); @@ -45,6 +57,7 @@ public UseEffects build() { return new PaperUseEffects( new net.minecraft.world.item.component.UseEffects( this.canSprint, + this.interactVibrations, this.speedMultiplier ) ); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 8b04c7a86ab7..8d7dc27c09a0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -11,18 +11,20 @@ import net.kyori.adventure.key.Key; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; -import net.minecraft.network.protocol.game.ClientboundHorseScreenOpenPacket; +import net.minecraft.network.protocol.game.ClientboundMountScreenOpenPacket; import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; import net.minecraft.network.protocol.game.ServerboundContainerClosePacket; import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.world.entity.animal.horse.AbstractHorse; +import net.minecraft.world.entity.animal.nautilus.AbstractNautilus; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.FireworkRocketEntity; import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.HorseInventoryMenu; +import net.minecraft.world.inventory.AbstractMountInventoryMenu; import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.inventory.MenuType; import net.minecraft.world.inventory.MerchantMenu; @@ -473,8 +475,8 @@ public void openInventory(InventoryView inventory) { if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(inventory.getTitle()); // Paper if (result.getFirst() != null) adventure$title = result.getFirst(); // Paper - Add titleOverride to InventoryOpenEvent if (!player.isImmobile()) { - if (container instanceof HorseInventoryMenu horse) { - player.connection.send(new ClientboundHorseScreenOpenPacket(horse.containerId, horse.horse.getInventoryColumns(), horse.horse.getId())); + if (container instanceof AbstractMountInventoryMenu mountMenu) { + player.connection.send(new ClientboundMountScreenOpenPacket(mountMenu.containerId, getMountInventoryColumns(mountMenu), mountMenu.mount.getId())); } else { player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); } @@ -483,6 +485,15 @@ public void openInventory(InventoryView inventory) { player.initMenu(container); } + private static int getMountInventoryColumns(final AbstractMountInventoryMenu mountMenu) { + if (mountMenu.mount instanceof AbstractHorse horse) { + return horse.getInventoryColumns(); + } else if (mountMenu.mount instanceof AbstractNautilus nautilus) { + return nautilus.getInventoryColumns(); + } + throw new UnsupportedOperationException("Cannot get inventory columns for " + mountMenu.mount.getType().getDescriptionId()); + } + @Override public InventoryView openMerchant(Merchant merchant, boolean force) { Preconditions.checkNotNull(merchant, "merchant cannot be null"); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java index 167c2c9a07ad..5351ac33dee5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java @@ -65,8 +65,8 @@ public ItemStack[] getContents() { items[HorseInventoryMenu.SLOT_SADDLE] = this.getSaddle(); items[HorseInventoryMenu.SLOT_BODY_ARMOR] = this.getArmor(); - for (int i = HorseInventoryMenu.SLOT_HORSE_INVENTORY_START; i < items.length; i++) { - net.minecraft.world.item.ItemStack item = this.getMainInventory().getItem(i - HorseInventoryMenu.SLOT_HORSE_INVENTORY_START); + for (int i = HorseInventoryMenu.SLOT_INVENTORY_START; i < items.length; i++) { + net.minecraft.world.item.ItemStack item = this.getMainInventory().getItem(i - HorseInventoryMenu.SLOT_INVENTORY_START); items[i] = item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); } @@ -80,9 +80,9 @@ public void setContents(ItemStack[] items) { this.setSaddle(ArrayUtils.get(items, HorseInventoryMenu.SLOT_SADDLE)); this.setArmor(ArrayUtils.get(items, HorseInventoryMenu.SLOT_BODY_ARMOR)); - for (int i = HorseInventoryMenu.SLOT_HORSE_INVENTORY_START; i < this.getSize(); i++) { + for (int i = HorseInventoryMenu.SLOT_INVENTORY_START; i < this.getSize(); i++) { net.minecraft.world.item.ItemStack item = i >= items.length ? net.minecraft.world.item.ItemStack.EMPTY : CraftItemStack.asNMSCopy(items[i]); - this.getMainInventory().setItem(i - HorseInventoryMenu.SLOT_HORSE_INVENTORY_START, item); + this.getMainInventory().setItem(i - HorseInventoryMenu.SLOT_INVENTORY_START, item); } } From cf2f7c2d73a1a369617e5e37ff7e6040909af7f8 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 11 Nov 2025 12:38:20 -0700 Subject: [PATCH 073/112] Run generators --- .../com/destroystokyo/paper/entity/ai/VanillaGoal.java | 2 ++ .../io/papermc/paper/registry/keys/SoundEventKeys.java | 7 +++++++ paper-api/src/main/java/org/bukkit/Sound.java | 2 ++ 3 files changed, 11 insertions(+) diff --git a/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java index 1cde924756ae..50f6443b5af0 100644 --- a/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java +++ b/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java @@ -70,6 +70,8 @@ @NullMarked @GeneratedClass public interface VanillaGoal extends Goal { + GoalKey HORSE_MOUNT_PANIC = create("horse_mount_panic", AbstractHorse.class); + GoalKey HORSE_RANDOM_STAND = create("horse_random_stand", AbstractHorse.class); GoalKey HORSE_RUN_AROUND_LIKE_CRAZY = create("horse_run_around_like_crazy", AbstractHorse.class); diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java index aaa7abd93bb3..1e94d5a361f5 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java @@ -11379,6 +11379,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_ZOMBIE_HORSE_DEATH = create(key("entity.zombie_horse.death")); + /** + * {@code minecraft:entity.zombie_horse.eat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_HORSE_EAT = create(key("entity.zombie_horse.eat")); + /** * {@code minecraft:entity.zombie_horse.hurt} * diff --git a/paper-api/src/main/java/org/bukkit/Sound.java b/paper-api/src/main/java/org/bukkit/Sound.java index b67cecbf538a..8820c2664eb1 100644 --- a/paper-api/src/main/java/org/bukkit/Sound.java +++ b/paper-api/src/main/java/org/bukkit/Sound.java @@ -3267,6 +3267,8 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_ZOMBIE_HORSE_DEATH = getSound("entity.zombie_horse.death"); + Sound ENTITY_ZOMBIE_HORSE_EAT = getSound("entity.zombie_horse.eat"); + Sound ENTITY_ZOMBIE_HORSE_HURT = getSound("entity.zombie_horse.hurt"); Sound ENTITY_ZOMBIE_NAUTILUS_AMBIENT = getSound("entity.zombie_nautilus.ambient"); From 2aba18ecd59c2d897df999bdbb731f70df33c2bb Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Tue, 11 Nov 2025 22:25:51 +0100 Subject: [PATCH 074/112] drop gamerule hack --- .../types/registry/RegistryFieldRewriter.java | 13 +------------ .../generator/types/registry/GeneratedKeyType.java | 12 +----------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java index cff345a48c2f..c258717d961e 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java @@ -20,11 +20,9 @@ import java.util.function.Supplier; import net.minecraft.core.Holder; import net.minecraft.core.Registry; -import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.world.flag.FeatureElement; import net.minecraft.world.flag.FeatureFlags; -import net.minecraft.world.level.gamerules.GameRule; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -49,7 +47,7 @@ public class RegistryFieldRewriter extends SearchReplaceRewriter { public RegistryFieldRewriter(ResourceKey> registryKey, @Nullable String fetchMethod) { this.registryEntry = RegistryEntries.byRegistryKey(registryKey); - this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(registryKey) || registryKey.equals(Registries.GAME_RULE); // TODO: GAME RULE SUCKS - SNAPSHOT + this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(registryKey); this.fetchMethod = fetchMethod; } @@ -129,15 +127,6 @@ protected String rewriteFieldValue(Holder.Reference reference) { protected @Nullable SingleFlagHolder getRequiredFeature(Holder.Reference reference) { if (this.isFilteredRegistry) { - // TODO: GAME RULE SUCKS - SNAPSHOT - if (reference.value() instanceof GameRule gameRule) { - if (FeatureFlags.isExperimental(gameRule.requiredFeatures())) { - return SingleFlagHolder.fromSet(gameRule.requiredFeatures()); - } - return null; - } - // TODO: GAME RULE SUCKS - SNAPSHOT - // built-in registry FeatureElement element = (FeatureElement) reference.value(); if (FeatureFlags.isExperimental(element.requiredFeatures())) { diff --git a/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java index ba6301cecf10..a69ac7e3afad 100644 --- a/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java @@ -24,11 +24,9 @@ import javax.lang.model.SourceVersion; import net.kyori.adventure.key.Key; import net.minecraft.core.Holder; -import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.world.flag.FeatureElement; import net.minecraft.world.flag.FeatureFlags; -import net.minecraft.world.level.gamerules.GameRule; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -51,7 +49,7 @@ public GeneratedKeyType(String packageName, RegistryEntry entry) { super(entry.keyClassName().concat("Keys"), packageName); this.entry = entry; this.experimentalKeys = Suppliers.memoize(() -> ExperimentalCollector.collectDataDrivenElementIds(entry.registry())); - this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(entry.registryKey()) || entry.registryKey().equals(Registries.GAME_RULE); // TODO: GAME RULE SUCKS - SNAPSHOT + this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(entry.registryKey()); } private MethodSpec.Builder createMethod(TypeName returnType) { @@ -133,14 +131,6 @@ protected JavaFile.Builder file(JavaFile.Builder builder) { protected @Nullable SingleFlagHolder getRequiredFeature(Holder.Reference reference) { if (this.isFilteredRegistry) { - // TODO: GAME RULE SUCKS - SNAPSHOT - if (reference.value() instanceof GameRule gameRule) { - if (FeatureFlags.isExperimental(gameRule.requiredFeatures())) { - return SingleFlagHolder.fromSet(gameRule.requiredFeatures()); - } - return null; - } - // TODO: GAME RULE SUCKS - SNAPSHOT // built-in registry FeatureElement element = (FeatureElement) reference.value(); if (FeatureFlags.isExperimental(element.requiredFeatures())) { From a6b7467552e1d8adf3caa5e7743465c2f8567d68 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Tue, 11 Nov 2025 22:38:33 +0100 Subject: [PATCH 075/112] remove special case for gamerule in feature flag tests --- .../io/papermc/paper/world/flag/FeatureFlagTest.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java b/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java index b35d5ef407e3..3d8d39205074 100644 --- a/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java +++ b/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java @@ -9,9 +9,8 @@ import java.util.Set; import java.util.stream.Stream; import net.kyori.adventure.key.Key; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; import net.minecraft.world.flag.FeatureElement; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; @@ -83,18 +82,12 @@ void testApiImplementsFeatureDependant(final RegistryKey re static Stream> nonFeatureFilteredRegistries() { return RegistryHelper.getRegistry().registries().filter(r -> { - // TODO: Game rule does not properly support the feature flag system. - if (r.key().equals(Registries.GAME_RULE)) { - return false; - } - final RegistryEntry entry = PaperRegistries.getEntry(r.key()); // has an API registry and isn't a filtered registry return entry != null && !FeatureElement.FILTERED_REGISTRIES.contains(r.key()); }).map(r -> PaperRegistries.getEntry(r.key()).apiKey()); } - @MethodSource("nonFeatureFilteredRegistries") @ParameterizedTest void testApiDoesntImplementFeatureDependant(final RegistryKey registryKey) { From 19ed6da2e5b04499565ff276a181adec8f86f71a Mon Sep 17 00:00:00 2001 From: Miles <81843550+Y2Kwastaken@users.noreply.github.com> Date: Wed, 12 Nov 2025 16:09:18 +0000 Subject: [PATCH 076/112] Fix Failing to Open Nautilus Inventory (#13297) --- build-data/paper.at | 1 + .../org/bukkit/entity/AbstractNautilus.java | 4 ++- .../server/level/ServerPlayer.java.patch | 28 ++++++++++++++++++- .../nautilus/AbstractNautilus.java.patch | 9 ++++++ .../entity/CraftAbstractNautilus.java | 12 ++++++++ 5 files changed, 52 insertions(+), 2 deletions(-) diff --git a/build-data/paper.at b/build-data/paper.at index ab88ea8c922a..ea513cb57c3b 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -319,6 +319,7 @@ public net.minecraft.world.entity.animal.horse.AbstractHorse owner public net.minecraft.world.entity.animal.horse.Horse setVariantAndMarkings(Lnet/minecraft/world/entity/animal/horse/Variant;Lnet/minecraft/world/entity/animal/horse/Markings;)V public net.minecraft.world.entity.animal.horse.Llama setVariant(Lnet/minecraft/world/entity/animal/horse/Llama$Variant;)V public net.minecraft.world.entity.animal.horse.SkeletonHorse trapTime +public net.minecraft.world.entity.animal.nautilus.AbstractNautilus inventory public net.minecraft.world.entity.animal.sniffer.Sniffer calculateDigPosition()Ljava/util/Optional; public net.minecraft.world.entity.animal.sniffer.Sniffer canDig()Z public net.minecraft.world.entity.animal.sniffer.Sniffer getExploredPositions()Ljava/util/stream/Stream; diff --git a/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java b/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java index 7d700fe1f9d6..e155d9743da9 100644 --- a/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java +++ b/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java @@ -1,4 +1,6 @@ package org.bukkit.entity; -public interface AbstractNautilus extends Animals, Tameable { +import org.bukkit.inventory.InventoryHolder; + +public interface AbstractNautilus extends Animals, InventoryHolder, Tameable { } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index 0e6abbc7edb9..ae7c227be791 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -1043,7 +1043,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1342,14 +_,25 @@ +@@ -1342,27 +_,49 @@ @Override public void openHorseInventory(AbstractHorse horse, Container inventory) { @@ -1072,6 +1072,32 @@ this.initMenu(this.containerMenu); } + @Override + public void openNautilusInventory(AbstractNautilus nautilus, Container inventory) { ++ // Paper start - Inventory open hook ++ this.nextContainerCounter(); // moved up from below ++ AbstractContainerMenu menu = new NautilusInventoryMenu(this.containerCounter, this.getInventory(), inventory, nautilus, nautilus.getInventoryColumns()); ++ menu.setTitle(nautilus.getDisplayName()); ++ menu = org.bukkit.craftbukkit.event.CraftEventFactory.callInventoryOpenEvent(this, containerMenu); ++ ++ if (menu == null) { ++ inventory.stopOpen(this); ++ return; ++ } ++ // Paper end + if (this.containerMenu != this.inventoryMenu) { + this.closeContainer(); + } + +- this.nextContainerCounter(); ++ // this.nextContainerCounter(); Paper - Move Up + int inventoryColumns = nautilus.getInventoryColumns(); + this.connection.send(new ClientboundMountScreenOpenPacket(this.containerCounter, inventoryColumns, nautilus.getId())); +- this.containerMenu = new NautilusInventoryMenu(this.containerCounter, this.getInventory(), inventory, nautilus, inventoryColumns); ++ this.containerMenu = menu; // Paper - Moved up declaration + this.initMenu(this.containerMenu); + } + @@ -1384,10 +_,30 @@ @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch index b09f144f8b61..107019494fd8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch @@ -27,3 +27,12 @@ this.tame(player); this.navigation.stop(); this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); +@@ -481,7 +_,7 @@ + + protected void createInventory() { + SimpleContainer simpleContainer = this.inventory; +- this.inventory = new SimpleContainer(this.getInventorySize()); ++ this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.craftbukkit.entity.CraftAbstractNautilus) getBukkitEntity()); // Paper - add inv owner + if (simpleContainer != null) { + int min = Math.min(simpleContainer.getContainerSize(), this.inventory.getContainerSize()); + diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java index e6c0134bc58b..7afd8e23ff2f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java @@ -1,7 +1,10 @@ package org.bukkit.craftbukkit.entity; +import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.animal.nautilus.AbstractNautilus; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.inventory.CraftSaddledInventory; +import org.bukkit.inventory.Inventory; public class CraftAbstractNautilus extends CraftTameableAnimal implements org.bukkit.entity.AbstractNautilus { public CraftAbstractNautilus(final CraftServer server, final AbstractNautilus entity) { @@ -12,4 +15,13 @@ public CraftAbstractNautilus(final CraftServer server, final AbstractNautilus en public AbstractNautilus getHandle() { return (AbstractNautilus) this.entity; } + + @Override + public Inventory getInventory() { + return new CraftSaddledInventory( + getHandle().inventory, + this.getHandle().createEquipmentSlotContainer(EquipmentSlot.BODY), + this.getHandle().createEquipmentSlotContainer(EquipmentSlot.SADDLE) + ); + } } From 8c18ca3b3cded3dc7b53c14b9a5f6f9be9c16c3d Mon Sep 17 00:00:00 2001 From: Pedro <3602279+Doc94@users.noreply.github.com> Date: Wed, 12 Nov 2025 17:46:00 -0300 Subject: [PATCH 077/112] Migrate WorldBorder API to use ticks (#13223) --- .../border/WorldBorderBoundsChangeEvent.java | 37 ++++++-- .../src/main/java/org/bukkit/WorldBorder.java | 92 ++++++++++++++----- .../world/level/border/WorldBorder.java.patch | 13 +-- .../bukkit/craftbukkit/CraftWorldBorder.java | 26 +++--- 4 files changed, 118 insertions(+), 50 deletions(-) diff --git a/paper-api/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java b/paper-api/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java index 3c168b3522c5..fdcc3c19731a 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java @@ -1,11 +1,14 @@ package io.papermc.paper.event.world.border; +import io.papermc.paper.util.Tick; import org.bukkit.World; import org.bukkit.WorldBorder; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Range; import org.jspecify.annotations.NullMarked; +import java.time.Duration; /** * Called when a world border changes its bounds, either over time, or instantly. @@ -66,13 +69,37 @@ public void setNewSize(final double newSize) { this.newSize = Math.min(this.worldBorder.getMaxSize(), Math.max(1.0D, newSize)); } + /** + * Gets the time in ticks for the change. Will be 0 if instant. + * + * @return the time in ticks for the change + */ + public long getDurationTicks() { + return this.duration; + } + /** * Gets the time in milliseconds for the change. Will be 0 if instant. * * @return the time in milliseconds for the change + * @deprecated in favor of {@link #getDurationTicks()} */ + @Deprecated(forRemoval = true, since = "1.21.11") public long getDuration() { - return this.duration; + return Tick.of(this.duration).toMillis(); + } + + /** + * Sets the time in ticks for the change. Will change {@link #getType()} to return + * {@link Type#STARTED_MOVE}. + * + * @param duration the time in ticks for the change + */ + public void setDurationTicks(@Range(from = 0, to = Integer.MAX_VALUE) final long duration) { + this.duration = Math.clamp(duration, 0L, Integer.MAX_VALUE); + if (this.type == Type.INSTANT_MOVE) { + this.type = Type.STARTED_MOVE; + } } /** @@ -80,13 +107,11 @@ public long getDuration() { * {@link Type#STARTED_MOVE}. * * @param duration the time in milliseconds for the change + * @deprecated in favor of {@link #setDurationTicks(long)} */ + @Deprecated(forRemoval = true, since = "1.21.11") public void setDuration(final long duration) { - // PAIL: TODO: Magic Values - this.duration = Math.min(9223372036854775L, Math.max(0L, duration)); - if (duration >= 0 && this.type == Type.INSTANT_MOVE) { - this.type = Type.STARTED_MOVE; - } + this.setDurationTicks(Tick.tick().fromDuration(Duration.ofMillis(Math.clamp(duration, 0L, Integer.MAX_VALUE)))); } @Override diff --git a/paper-api/src/main/java/org/bukkit/WorldBorder.java b/paper-api/src/main/java/org/bukkit/WorldBorder.java index b1c08a7fc585..e777291b9dcd 100644 --- a/paper-api/src/main/java/org/bukkit/WorldBorder.java +++ b/paper-api/src/main/java/org/bukkit/WorldBorder.java @@ -1,6 +1,9 @@ package org.bukkit; +import java.time.Duration; import java.util.concurrent.TimeUnit; +import com.google.common.base.Preconditions; +import io.papermc.paper.util.Tick; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -12,20 +15,19 @@ public interface WorldBorder { * @return the associated world, or null if this world border is not associated * with any specific world, such as those created via {@link Server#createWorldBorder()} */ - @Nullable - public World getWorld(); + @Nullable World getWorld(); /** * Resets the border to default values. */ - public void reset(); + void reset(); /** * Gets the current side length of the border. * * @return The current side length of the border. */ - public double getSize(); + double getSize(); /** * Sets the border to a square region with the specified side length in blocks. @@ -34,7 +36,7 @@ public interface WorldBorder { * * @throws IllegalArgumentException if newSize is less than 1.0D or greater than {@link #getMaxSize()} */ - public void setSize(double newSize); + void setSize(double newSize); /** * Sets the border to a square region with the specified side length in blocks. @@ -43,8 +45,24 @@ public interface WorldBorder { * @param seconds The time in seconds in which the border grows or shrinks from the previous size to that being set. * * @throws IllegalArgumentException if newSize is less than 1.0D or greater than {@link #getMaxSize()} + * @see #setSize(double, TimeUnit, long) + * @deprecated Use {@link #changeSize(double, long)} instead */ - public void setSize(double newSize, long seconds); + @Deprecated(since = "1.21.11", forRemoval = true) + default void setSize(double newSize, long seconds) { + this.setSize(Math.min(this.getMaxSize(), Math.max(1.0D, newSize)), TimeUnit.SECONDS, Math.clamp(seconds, 0L, Integer.MAX_VALUE)); + } + + /** + * Sets the border to a square region with the specified side length in blocks. + * + * @param newSize The new side length of the border. + * @param ticks The time in ticks in which the border grows or shrinks from the previous size to that being set. + * + * @throws IllegalArgumentException if newSize is less than 1.0D or greater than {@link #getMaxSize()} + * @throws IllegalArgumentException if ticks are less than 0 + */ + void changeSize(double newSize, long ticks); /** * Sets the border to a square region with the specified side length in blocks. @@ -54,16 +72,22 @@ public interface WorldBorder { * @param time The time in which the border grows or shrinks from the previous size to that being set. * * @throws IllegalArgumentException if unit is null or newSize is less than 1.0D or greater than {@link #getMaxSize()} + * + * @see Tick + * @deprecated Use {@link #changeSize(double, long)} instead */ - public void setSize(double newSize, @NotNull TimeUnit unit, long time); + @Deprecated(since = "1.21.11", forRemoval = true) + default void setSize(double newSize, @NotNull TimeUnit unit, long time) { + Preconditions.checkArgument(unit != null, "TimeUnit cannot be null."); + this.changeSize(newSize, Tick.tick().fromDuration(Duration.of(time, unit.toChronoUnit()))); + } /** * Gets the current border center. * * @return The current border center. */ - @NotNull - public Location getCenter(); + @NotNull Location getCenter(); /** * Sets the new border center. @@ -73,7 +97,7 @@ public interface WorldBorder { * * @throws IllegalArgumentException if the absolute value of x or z is higher than {@link #getMaxCenterCoordinate()} */ - public void setCenter(double x, double z); + void setCenter(double x, double z); /** * Sets the new border center. @@ -82,63 +106,85 @@ public interface WorldBorder { * * @throws IllegalArgumentException if location is null or the absolute value of {@link Location#getX()} or {@link Location#getZ()} is higher than {@link #getMaxCenterCoordinate()} */ - public void setCenter(@NotNull Location location); + void setCenter(@NotNull Location location); /** * Gets the current border damage buffer. * * @return The current border damage buffer. */ - public double getDamageBuffer(); + double getDamageBuffer(); /** * Sets the amount of blocks a player may safely be outside the border before taking damage. * * @param blocks The amount of blocks. (The default is 5 blocks.) */ - public void setDamageBuffer(double blocks); + void setDamageBuffer(double blocks); /** * Gets the current border damage amount. * * @return The current border damage amount. */ - public double getDamageAmount(); + double getDamageAmount(); /** * Sets the amount of damage a player takes when outside the border plus the border buffer. * * @param damage The amount of damage. (The default is 0.2 damage per second per block.) */ - public void setDamageAmount(double damage); + void setDamageAmount(double damage); /** * Gets the current border warning time in seconds. * * @return The current border warning time in seconds. + * @deprecated Use {@link #getWarningTimeTicks()} instead + */ + @Deprecated(since = "1.21.11", forRemoval = true) + default int getWarningTime() { + return (int) Tick.of(this.getWarningTimeTicks()).toSeconds(); + } + + /** + * Gets the current border warning time in ticks. + * + * @return The current border warning time in ticks. + */ + int getWarningTimeTicks(); + + /** + * Sets the warning time that causes the screen to be tinted red when a contracting border will reach the player within the specified time. + * + * @param seconds The amount of time in seconds. + * @deprecated Use {@link #setWarningTimeTicks(int)} instead */ - public int getWarningTime(); + @Deprecated(since = "1.21.11", forRemoval = true) + default void setWarningTime(int seconds) { + this.setWarningTimeTicks(Tick.tick().fromDuration(Duration.ofSeconds(seconds))); + } /** * Sets the warning time that causes the screen to be tinted red when a contracting border will reach the player within the specified time. * - * @param seconds The amount of time in seconds. (The default is 15 seconds.) + * @param ticks The number of ticks. */ - public void setWarningTime(int seconds); + void setWarningTimeTicks(int ticks); /** * Gets the current border warning distance. * * @return The current border warning distance. */ - public int getWarningDistance(); + int getWarningDistance(); /** * Sets the warning distance that causes the screen to be tinted red when the player is within the specified number of blocks from the border. * * @param distance The distance in blocks. (The default is 5 blocks.) */ - public void setWarningDistance(int distance); + void setWarningDistance(int distance); /** * Check if the specified location is inside this border. @@ -146,14 +192,14 @@ public interface WorldBorder { * @param location the location to check * @return if this location is inside the border or not */ - public boolean isInside(@NotNull Location location); + boolean isInside(@NotNull Location location); /** * Gets the maximum possible size of a WorldBorder. * * @return The maximum size the WorldBorder */ - public double getMaxSize(); + double getMaxSize(); /** * Gets the absolute value of the maximum x/z center coordinate of a @@ -161,5 +207,5 @@ public interface WorldBorder { * * @return The absolute maximum center coordinate of the WorldBorder */ - public double getMaxCenterCoordinate(); + double getMaxCenterCoordinate(); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch b/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch index 5cf15a163f16..649fae49b6eb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch @@ -4,7 +4,7 @@ double centerZ; int absoluteMaxSize = 29999984; WorldBorder.BorderExtent extent = new WorldBorder.StaticBorderExtent(5.999997E7F); -+ public net.minecraft.server.level.ServerLevel world; // CraftBukkit ++ public net.minecraft.server.level.@org.jspecify.annotations.Nullable ServerLevel world; // CraftBukkit public WorldBorder() { this(WorldBorder.Settings.DEFAULT); @@ -52,8 +52,8 @@ + if (this.world != null) { + io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent event = new io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type.INSTANT_MOVE, getSize(), size, 0); + if (!event.callEvent()) return; -+ if (event.getType() == io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type.STARTED_MOVE && event.getDuration() > 0) { // If changed to a timed transition -+ lerpSizeBetween(event.getOldSize(), event.getNewSize(), event.getDuration(), this.world.getGameTime()); ++ if (event.getType() == io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type.STARTED_MOVE && event.getDurationTicks() > 0) { // If changed to a timed transition ++ lerpSizeBetween(event.getOldSize(), event.getNewSize(), event.getDurationTicks(), this.world.getGameTime()); + return; + } + size = event.getNewSize(); @@ -77,7 +77,7 @@ + io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent event = new io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), type, oldSize, newSize, time); + if (!event.callEvent()) return; + newSize = event.getNewSize(); -+ time = event.getDuration(); ++ time = event.getDurationTicks(); + } + // Paper end - Add worldborder events this.extent = (WorldBorder.BorderExtent)(oldSize == newSize @@ -91,7 +91,7 @@ this.listeners.add(listener); } -@@ -298,6 +_,21 @@ +@@ -298,6 +_,22 @@ } } @@ -103,7 +103,8 @@ + this.setWarningBlocks(settings.warningBlocks()); + this.setWarningTime(settings.warningTime()); + if (settings.lerpTime() > 0L) { -+ this.lerpSizeBetween(settings.size(), settings.lerpTarget(), settings.lerpTime(), this.world.getGameTime()); ++ final long startTime = (this.world != null) ? this.world.getGameTime() : 0; // Virtual Borders don't have a World ++ this.lerpSizeBetween(settings.size(), settings.lerpTarget(), settings.lerpTime(), startTime); + } else { + this.setSize(settings.size()); + } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java index c9da9c271af2..693a6102cedf 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java @@ -1,7 +1,6 @@ package org.bukkit.craftbukkit; import com.google.common.base.Preconditions; -import java.util.concurrent.TimeUnit; import net.minecraft.core.BlockPos; import org.bukkit.Location; import org.bukkit.World; @@ -39,22 +38,17 @@ public double getSize() { @Override public void setSize(double newSize) { - this.setSize(newSize, 0L); + this.changeSize(newSize, 0); } @Override - public void setSize(double newSize, long time) { - this.setSize(Math.min(this.getMaxSize(), Math.max(1.0D, newSize)), TimeUnit.SECONDS, Math.min(9223372036854775L, Math.max(0L, time))); - } - - @Override - public void setSize(double newSize, TimeUnit unit, long time) { - Preconditions.checkArgument(unit != null, "TimeUnit cannot be null."); - Preconditions.checkArgument(time >= 0, "time cannot be lower than 0"); + public void changeSize(double newSize, long ticks) { + Preconditions.checkArgument(ticks >= 0, "ticks cannot be lower than 0"); Preconditions.checkArgument(newSize >= 1.0D && newSize <= this.getMaxSize(), "newSize must be between 1.0D and %s", this.getMaxSize()); - if (time > 0L) { - this.handle.lerpSizeBetween(this.handle.getSize(), newSize, unit.toMillis(time), this.getWorld().getGameTime()); + if (ticks > 0L) { + final long startTime = (this.getWorld() != null) ? this.getWorld().getGameTime() : 0; // Virtual Borders don't have a World + this.handle.lerpSizeBetween(this.handle.getSize(), newSize, ticks, startTime); } else { this.handle.setSize(newSize); } @@ -102,13 +96,15 @@ public void setDamageAmount(double damage) { } @Override - public int getWarningTime() { + public int getWarningTimeTicks() { return this.handle.getWarningTime(); } @Override - public void setWarningTime(int time) { - this.handle.setWarningTime(time); + public void setWarningTimeTicks(final int ticks) { + Preconditions.checkArgument(ticks >= 0, "ticks cannot be lower than 0"); + + this.handle.setWarningTime(ticks); } @Override From a6b5dcb222a182f257affccf691698eb450d98e9 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Thu, 13 Nov 2025 21:14:55 +0100 Subject: [PATCH 078/112] fixup previous commits --- .../border/WorldBorderBoundsChangeEvent.java | 39 +++++++------ .../src/main/java/org/bukkit/WorldBorder.java | 58 ++++++++++--------- .../java/io/papermc/generator/Rewriters.java | 1 - .../org/bukkit/craftbukkit/CraftServer.java | 4 +- .../org/bukkit/craftbukkit/CraftWorld.java | 4 +- .../bukkit/craftbukkit/CraftWorldBorder.java | 4 +- .../entity/CraftAbstractNautilus.java | 6 +- 7 files changed, 62 insertions(+), 54 deletions(-) diff --git a/paper-api/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java b/paper-api/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java index fdcc3c19731a..906f3912f9ba 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java @@ -1,14 +1,16 @@ package io.papermc.paper.event.world.border; +import com.google.common.base.Preconditions; import io.papermc.paper.util.Tick; +import java.time.Duration; import org.bukkit.World; import org.bukkit.WorldBorder; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.checkerframework.checker.index.qual.NonNegative; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Range; import org.jspecify.annotations.NullMarked; -import java.time.Duration; /** * Called when a world border changes its bounds, either over time, or instantly. @@ -66,7 +68,7 @@ public double getNewSize() { * @param newSize the new size */ public void setNewSize(final double newSize) { - this.newSize = Math.min(this.worldBorder.getMaxSize(), Math.max(1.0D, newSize)); + this.newSize = Math.clamp(newSize, 1.0D, this.worldBorder.getMaxSize()); } /** @@ -74,34 +76,35 @@ public void setNewSize(final double newSize) { * * @return the time in ticks for the change */ - public long getDurationTicks() { + public @Range(from = 0, to = Integer.MAX_VALUE) long getDurationTicks() { return this.duration; } - /** - * Gets the time in milliseconds for the change. Will be 0 if instant. - * - * @return the time in milliseconds for the change - * @deprecated in favor of {@link #getDurationTicks()} - */ - @Deprecated(forRemoval = true, since = "1.21.11") - public long getDuration() { - return Tick.of(this.duration).toMillis(); - } - /** * Sets the time in ticks for the change. Will change {@link #getType()} to return * {@link Type#STARTED_MOVE}. * * @param duration the time in ticks for the change */ - public void setDurationTicks(@Range(from = 0, to = Integer.MAX_VALUE) final long duration) { - this.duration = Math.clamp(duration, 0L, Integer.MAX_VALUE); + public void setDurationTicks(final @Range(from = 0, to = Integer.MAX_VALUE) long duration) { + Preconditions.checkArgument(duration >= 0 && duration <= Integer.MAX_VALUE, "duration must be between 0-%s", Integer.MAX_VALUE); + this.duration = duration; if (this.type == Type.INSTANT_MOVE) { this.type = Type.STARTED_MOVE; } } + /** + * Gets the time in milliseconds for the change. Will be 0 if instant. + * + * @return the time in milliseconds for the change + * @deprecated in favor of {@link #getDurationTicks()} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public @NonNegative long getDuration() { + return Tick.of(this.getDurationTicks()).toMillis(); + } + /** * Sets the time in milliseconds for the change. Will change {@link #getType()} to return * {@link Type#STARTED_MOVE}. @@ -110,8 +113,8 @@ public void setDurationTicks(@Range(from = 0, to = Integer.MAX_VALUE) final long * @deprecated in favor of {@link #setDurationTicks(long)} */ @Deprecated(forRemoval = true, since = "1.21.11") - public void setDuration(final long duration) { - this.setDurationTicks(Tick.tick().fromDuration(Duration.ofMillis(Math.clamp(duration, 0L, Integer.MAX_VALUE)))); + public void setDuration(final @NonNegative long duration) { + this.setDurationTicks(Tick.tick().fromDuration(Duration.ofMillis(duration))); } @Override diff --git a/paper-api/src/main/java/org/bukkit/WorldBorder.java b/paper-api/src/main/java/org/bukkit/WorldBorder.java index e777291b9dcd..10e69cab2068 100644 --- a/paper-api/src/main/java/org/bukkit/WorldBorder.java +++ b/paper-api/src/main/java/org/bukkit/WorldBorder.java @@ -1,11 +1,13 @@ package org.bukkit; -import java.time.Duration; -import java.util.concurrent.TimeUnit; import com.google.common.base.Preconditions; import io.papermc.paper.util.Tick; +import java.time.Duration; +import java.util.concurrent.TimeUnit; +import org.checkerframework.checker.index.qual.NonNegative; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Range; public interface WorldBorder { @@ -35,6 +37,7 @@ public interface WorldBorder { * @param newSize The new size of the border. * * @throws IllegalArgumentException if newSize is less than 1.0D or greater than {@link #getMaxSize()} + * @see #changeSize(double, long) */ void setSize(double newSize); @@ -42,27 +45,27 @@ public interface WorldBorder { * Sets the border to a square region with the specified side length in blocks. * * @param newSize The new side length of the border. - * @param seconds The time in seconds in which the border grows or shrinks from the previous size to that being set. + * @param ticks The time in ticks in which the border grows or shrinks from the previous size to that being set. * * @throws IllegalArgumentException if newSize is less than 1.0D or greater than {@link #getMaxSize()} - * @see #setSize(double, TimeUnit, long) - * @deprecated Use {@link #changeSize(double, long)} instead + * @throws IllegalArgumentException if ticks is out of range + * @see #setSize(double) */ - @Deprecated(since = "1.21.11", forRemoval = true) - default void setSize(double newSize, long seconds) { - this.setSize(Math.min(this.getMaxSize(), Math.max(1.0D, newSize)), TimeUnit.SECONDS, Math.clamp(seconds, 0L, Integer.MAX_VALUE)); - } + void changeSize(double newSize, @Range(from = 0, to = Integer.MAX_VALUE) long ticks); /** * Sets the border to a square region with the specified side length in blocks. * * @param newSize The new side length of the border. - * @param ticks The time in ticks in which the border grows or shrinks from the previous size to that being set. + * @param seconds The time in seconds in which the border grows or shrinks from the previous size to that being set. * - * @throws IllegalArgumentException if newSize is less than 1.0D or greater than {@link #getMaxSize()} - * @throws IllegalArgumentException if ticks are less than 0 + * @throws IllegalArgumentException if seconds is out of range once converted in ticks + * @deprecated Use {@link #changeSize(double, long)} instead */ - void changeSize(double newSize, long ticks); + @Deprecated(since = "1.21.11", forRemoval = true) + default void setSize(double newSize, long seconds) { + this.changeSize(Math.clamp(newSize, 1.0D, this.getMaxSize()), Tick.tick().fromDuration(Duration.ofSeconds(seconds))); + } /** * Sets the border to a square region with the specified side length in blocks. @@ -71,13 +74,12 @@ default void setSize(double newSize, long seconds) { * @param unit The time unit. * @param time The time in which the border grows or shrinks from the previous size to that being set. * - * @throws IllegalArgumentException if unit is null or newSize is less than 1.0D or greater than {@link #getMaxSize()} - * - * @see Tick + * @throws IllegalArgumentException if newSize is less than 1.0D or greater than {@link #getMaxSize()} + * @throws IllegalArgumentException if time is out of range once converted in ticks * @deprecated Use {@link #changeSize(double, long)} instead */ @Deprecated(since = "1.21.11", forRemoval = true) - default void setSize(double newSize, @NotNull TimeUnit unit, long time) { + default void setSize(double newSize, @NotNull TimeUnit unit, @NonNegative long time) { Preconditions.checkArgument(unit != null, "TimeUnit cannot be null."); this.changeSize(newSize, Tick.tick().fromDuration(Duration.of(time, unit.toChronoUnit()))); } @@ -143,17 +145,10 @@ default void setSize(double newSize, @NotNull TimeUnit unit, long time) { * @deprecated Use {@link #getWarningTimeTicks()} instead */ @Deprecated(since = "1.21.11", forRemoval = true) - default int getWarningTime() { + default @NonNegative int getWarningTime() { return (int) Tick.of(this.getWarningTimeTicks()).toSeconds(); } - /** - * Gets the current border warning time in ticks. - * - * @return The current border warning time in ticks. - */ - int getWarningTimeTicks(); - /** * Sets the warning time that causes the screen to be tinted red when a contracting border will reach the player within the specified time. * @@ -161,16 +156,25 @@ default int getWarningTime() { * @deprecated Use {@link #setWarningTimeTicks(int)} instead */ @Deprecated(since = "1.21.11", forRemoval = true) - default void setWarningTime(int seconds) { + default void setWarningTime(@NonNegative int seconds) { + Preconditions.checkArgument(seconds >= 0, "seconds cannot be lower than 0"); + this.setWarningTimeTicks(Tick.tick().fromDuration(Duration.ofSeconds(seconds))); } + /** + * Gets the current border warning time in ticks. + * + * @return The current border warning time in ticks. + */ + @NonNegative int getWarningTimeTicks(); + /** * Sets the warning time that causes the screen to be tinted red when a contracting border will reach the player within the specified time. * * @param ticks The number of ticks. */ - void setWarningTimeTicks(int ticks); + void setWarningTimeTicks(@NonNegative int ticks); /** * Gets the current border warning distance. diff --git a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java index d505ca8a76dd..c957260d1fcb 100644 --- a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java +++ b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java @@ -49,7 +49,6 @@ import org.bukkit.FeatureFlag; import org.bukkit.Fluid; import org.bukkit.GameEvent; -import org.bukkit.GameRule; import org.bukkit.GameRules; import org.bukkit.JukeboxSong; import org.bukkit.Material; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 0004be40fb33..25e2a85f047b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1416,7 +1416,9 @@ public void addWorld(World world) { @Override public WorldBorder createWorldBorder() { - return new CraftWorldBorder(new net.minecraft.world.level.border.WorldBorder()); + net.minecraft.world.level.border.WorldBorder border = new net.minecraft.world.level.border.WorldBorder(); + border.setWarningTime(net.minecraft.world.level.border.WorldBorder.Settings.DEFAULT.warningTime()); // TODO remove once MC-304061 is truly fixed + return new CraftWorldBorder(border); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 47ee0fca3f7b..7858356919dc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -6,7 +6,6 @@ import com.google.common.base.Predicates; import com.google.common.collect.Lists; import com.mojang.datafixers.util.Pair; -import com.mojang.serialization.JavaOps; import io.papermc.paper.FeatureHooks; import io.papermc.paper.raytracing.PositionedRayTraceConfigurationBuilder; import io.papermc.paper.raytracing.PositionedRayTraceConfigurationBuilderImpl; @@ -58,6 +57,7 @@ import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; +import net.minecraft.util.NullOps; import net.minecraft.world.attribute.EnvironmentAttributes; import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.EntityType; @@ -1742,7 +1742,7 @@ public boolean setGameRule(org.bukkit.@NotNull GameRule rule, @NotNull T if (rule instanceof CraftGameRule.LegacyGameRuleWrapper legacyGameRuleWrapper) { convertedValue = (T) legacyGameRuleWrapper.getFromLegacyToModern().apply(newValue); } else { - nms.valueCodec().encodeStart(JavaOps.INSTANCE, newValue).ifError(error -> { + nms.valueCodec().encodeStart(NullOps.INSTANCE, newValue).ifError(error -> { throw CraftGameRule.INVALID_VALUE.apply(newValue.toString(), error); }); convertedValue = newValue; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java index 693a6102cedf..de9af4fc1593 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java @@ -38,12 +38,12 @@ public double getSize() { @Override public void setSize(double newSize) { - this.changeSize(newSize, 0); + this.handle.setSize(newSize); } @Override public void changeSize(double newSize, long ticks) { - Preconditions.checkArgument(ticks >= 0, "ticks cannot be lower than 0"); + Preconditions.checkArgument(ticks >= 0 && ticks <= Integer.MAX_VALUE, "ticks must be between 0-%s", Integer.MAX_VALUE); Preconditions.checkArgument(newSize >= 1.0D && newSize <= this.getMaxSize(), "newSize must be between 1.0D and %s", this.getMaxSize()); if (ticks > 0L) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java index 7afd8e23ff2f..a789edaaa739 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java @@ -3,7 +3,7 @@ import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.animal.nautilus.AbstractNautilus; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.inventory.CraftSaddledInventory; +import org.bukkit.craftbukkit.inventory.CraftInventoryHorse; import org.bukkit.inventory.Inventory; public class CraftAbstractNautilus extends CraftTameableAnimal implements org.bukkit.entity.AbstractNautilus { @@ -18,8 +18,8 @@ public AbstractNautilus getHandle() { @Override public Inventory getInventory() { - return new CraftSaddledInventory( - getHandle().inventory, + return new CraftInventoryHorse( + this.getHandle().inventory, this.getHandle().createEquipmentSlotContainer(EquipmentSlot.BODY), this.getHandle().createEquipmentSlotContainer(EquipmentSlot.SADDLE) ); From 862d2e6d6ab83d4e3139c0be39d3b9f13ad4a5bd Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 14 Nov 2025 10:51:58 -0700 Subject: [PATCH 079/112] Add MountInventory, SaddledMountInventory, ArmoredMountInventory, ArmoredSaddledMountInventory (#13305) --- .../org/bukkit/entity/AbstractNautilus.java | 6 +++++ .../main/java/org/bukkit/entity/Nautilus.java | 3 +++ .../inventory/AbstractHorseInventory.java | 17 ++++---------- .../inventory/ArmoredHorseInventory.java | 14 +++--------- .../inventory/ArmoredMountInventory.java | 22 +++++++++++++++++++ .../ArmoredSaddledMountInventory.java | 4 ++++ .../org/bukkit/inventory/MountInventory.java | 7 ++++++ .../inventory/SaddledMountInventory.java | 22 +++++++++++++++++++ .../CraftInventoryArmoredSaddledMount.java | 12 ++++++++++ .../entity/CraftAbstractHorse.java | 4 ++-- .../entity/CraftAbstractNautilus.java | 10 +++++---- .../craftbukkit/entity/CraftHumanEntity.java | 6 +++-- .../craftbukkit/entity/CraftNautilus.java | 2 ++ .../inventory/CraftInventoryHorse.java | 3 +-- .../inventory/CraftInventoryLlama.java | 2 +- .../inventory/CraftInventorySaddledHorse.java | 12 ++++++++++ ...e.java => CraftInventorySaddledMount.java} | 4 ++-- .../inventory/CraftSaddledInventory.java | 12 ---------- 18 files changed, 113 insertions(+), 49 deletions(-) create mode 100644 paper-api/src/main/java/org/bukkit/inventory/ArmoredMountInventory.java create mode 100644 paper-api/src/main/java/org/bukkit/inventory/ArmoredSaddledMountInventory.java create mode 100644 paper-api/src/main/java/org/bukkit/inventory/MountInventory.java create mode 100644 paper-api/src/main/java/org/bukkit/inventory/SaddledMountInventory.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/CraftInventoryArmoredSaddledMount.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledHorse.java rename paper-server/src/main/java/org/bukkit/craftbukkit/inventory/{CraftInventoryAbstractHorse.java => CraftInventorySaddledMount.java} (95%) delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSaddledInventory.java diff --git a/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java b/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java index e155d9743da9..266e91b75521 100644 --- a/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java +++ b/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java @@ -1,6 +1,12 @@ package org.bukkit.entity; +import org.bukkit.inventory.ArmoredSaddledMountInventory; import org.bukkit.inventory.InventoryHolder; +import org.jspecify.annotations.NullMarked; +@NullMarked public interface AbstractNautilus extends Animals, InventoryHolder, Tameable { + + @Override + ArmoredSaddledMountInventory getInventory(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Nautilus.java b/paper-api/src/main/java/org/bukkit/entity/Nautilus.java index 94232fd4cb92..667a1230e7ef 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Nautilus.java +++ b/paper-api/src/main/java/org/bukkit/entity/Nautilus.java @@ -1,4 +1,7 @@ package org.bukkit.entity; +import org.jspecify.annotations.NullMarked; + +@NullMarked public interface Nautilus extends AbstractNautilus { } diff --git a/paper-api/src/main/java/org/bukkit/inventory/AbstractHorseInventory.java b/paper-api/src/main/java/org/bukkit/inventory/AbstractHorseInventory.java index 93c1158f8d2e..c0dd0c7ed6f8 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/AbstractHorseInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/AbstractHorseInventory.java @@ -6,20 +6,11 @@ /** * An interface to the inventory of an {@link AbstractHorse}. */ -public interface AbstractHorseInventory extends Inventory { +public interface AbstractHorseInventory extends SaddledMountInventory { - /** - * Gets the item in the horse's saddle slot. - * - * @return the saddle item - */ - @Nullable - ItemStack getSaddle(); + @Override + @Nullable ItemStack getSaddle(); - /** - * Sets the item in the horse's saddle slot. - * - * @param stack the new item - */ + @Override void setSaddle(@Nullable ItemStack stack); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/ArmoredHorseInventory.java b/paper-api/src/main/java/org/bukkit/inventory/ArmoredHorseInventory.java index 994f34ac2062..3fa6a2a544bb 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ArmoredHorseInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ArmoredHorseInventory.java @@ -4,19 +4,11 @@ import org.jspecify.annotations.Nullable; @NullMarked -public interface ArmoredHorseInventory extends AbstractHorseInventory { +public interface ArmoredHorseInventory extends AbstractHorseInventory, ArmoredSaddledMountInventory { - /** - * Gets the item in the horse's armor slot. - * - * @return the armor item - */ + @Override @Nullable ItemStack getArmor(); - /** - * Sets the item in the horse's armor slot. - * - * @param stack the new item - */ + @Override void setArmor(@Nullable ItemStack stack); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/ArmoredMountInventory.java b/paper-api/src/main/java/org/bukkit/inventory/ArmoredMountInventory.java new file mode 100644 index 000000000000..d3ae959533a2 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/inventory/ArmoredMountInventory.java @@ -0,0 +1,22 @@ +package org.bukkit.inventory; + +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +public interface ArmoredMountInventory extends MountInventory { + + /** + * Gets the item in the mount's armor slot. + * + * @return the armor item + */ + @Nullable ItemStack getArmor(); + + /** + * Sets the item in the mount's armor slot. + * + * @param stack the new item + */ + void setArmor(@Nullable ItemStack stack); +} diff --git a/paper-api/src/main/java/org/bukkit/inventory/ArmoredSaddledMountInventory.java b/paper-api/src/main/java/org/bukkit/inventory/ArmoredSaddledMountInventory.java new file mode 100644 index 000000000000..fd8295ebeab1 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/inventory/ArmoredSaddledMountInventory.java @@ -0,0 +1,4 @@ +package org.bukkit.inventory; + +public interface ArmoredSaddledMountInventory extends ArmoredMountInventory, SaddledMountInventory { +} diff --git a/paper-api/src/main/java/org/bukkit/inventory/MountInventory.java b/paper-api/src/main/java/org/bukkit/inventory/MountInventory.java new file mode 100644 index 000000000000..10ebabb9ff8c --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/inventory/MountInventory.java @@ -0,0 +1,7 @@ +package org.bukkit.inventory; + +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface MountInventory extends Inventory { +} diff --git a/paper-api/src/main/java/org/bukkit/inventory/SaddledMountInventory.java b/paper-api/src/main/java/org/bukkit/inventory/SaddledMountInventory.java new file mode 100644 index 000000000000..eb883bc01bd5 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/inventory/SaddledMountInventory.java @@ -0,0 +1,22 @@ +package org.bukkit.inventory; + +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +public interface SaddledMountInventory extends MountInventory { + + /** + * Gets the item in the mount's saddle slot. + * + * @return the saddle item + */ + @Nullable ItemStack getSaddle(); + + /** + * Sets the item in the mount's saddle slot. + * + * @param stack the new item + */ + void setSaddle(@Nullable ItemStack stack); +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftInventoryArmoredSaddledMount.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftInventoryArmoredSaddledMount.java new file mode 100644 index 000000000000..c86f9255f21e --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftInventoryArmoredSaddledMount.java @@ -0,0 +1,12 @@ +package org.bukkit.craftbukkit; + +import net.minecraft.world.Container; +import org.bukkit.craftbukkit.inventory.CraftInventorySaddledMount; +import org.bukkit.inventory.ArmoredSaddledMountInventory; + +public class CraftInventoryArmoredSaddledMount extends CraftInventorySaddledMount implements ArmoredSaddledMountInventory { + + public CraftInventoryArmoredSaddledMount(final Container inventory, final Container bodyArmorInventory, final Container saddleInventory) { + super(inventory, bodyArmorInventory, saddleInventory); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java index fb7ee85ac2e7..984dc57a2f2c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java @@ -7,7 +7,7 @@ import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.ai.attributes.Attributes; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.inventory.CraftSaddledInventory; +import org.bukkit.craftbukkit.inventory.CraftInventorySaddledHorse; import org.bukkit.entity.AbstractHorse; import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.Horse; @@ -115,7 +115,7 @@ public void setEatingHaystack(boolean eatingHaystack) { @Override public AbstractHorseInventory getInventory() { - return new CraftSaddledInventory( + return new CraftInventorySaddledHorse( this.getHandle().inventory, this.getHandle().createEquipmentSlotContainer(EquipmentSlot.BODY), this.getHandle().createEquipmentSlotContainer(EquipmentSlot.SADDLE) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java index a789edaaa739..600d59ceebf1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractNautilus.java @@ -2,10 +2,12 @@ import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.animal.nautilus.AbstractNautilus; +import org.bukkit.craftbukkit.CraftInventoryArmoredSaddledMount; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.inventory.CraftInventoryHorse; -import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ArmoredSaddledMountInventory; +import org.jspecify.annotations.NullMarked; +@NullMarked public class CraftAbstractNautilus extends CraftTameableAnimal implements org.bukkit.entity.AbstractNautilus { public CraftAbstractNautilus(final CraftServer server, final AbstractNautilus entity) { super(server, entity); @@ -17,8 +19,8 @@ public AbstractNautilus getHandle() { } @Override - public Inventory getInventory() { - return new CraftInventoryHorse( + public ArmoredSaddledMountInventory getInventory() { + return new CraftInventoryArmoredSaddledMount( this.getHandle().inventory, this.getHandle().createEquipmentSlotContainer(EquipmentSlot.BODY), this.getHandle().createEquipmentSlotContainer(EquipmentSlot.SADDLE) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 8d7dc27c09a0..c5e66fda31a9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -45,7 +45,7 @@ import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.inventory.CraftContainer; import org.bukkit.craftbukkit.inventory.CraftInventory; -import org.bukkit.craftbukkit.inventory.CraftInventoryAbstractHorse; +import org.bukkit.craftbukkit.inventory.CraftInventorySaddledMount; import org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest; import org.bukkit.craftbukkit.inventory.CraftInventoryLectern; import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer; @@ -349,8 +349,10 @@ public InventoryView openInventory(Inventory inventory) { if (menuProvider != null) { this.getHandle().openMenu(menuProvider); - } else if (inventory instanceof CraftInventoryAbstractHorse craft && craft.getInventory().getOwner() instanceof CraftAbstractHorse horse) { + } else if (inventory instanceof CraftInventorySaddledMount craft && craft.getInventory().getOwner() instanceof CraftAbstractHorse horse) { this.getHandle().openHorseInventory(horse.getHandle(), craft.getInventory()); + } else if (inventory instanceof CraftInventorySaddledMount craft && craft.getInventory().getOwner() instanceof CraftAbstractNautilus nautilus) { + this.getHandle().openNautilusInventory(nautilus.getHandle(), craft.getInventory()); } else { MenuType container = CraftContainer.getNotchInventoryType(inventory); CraftHumanEntity.openCustomInventory(inventory, player, container); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftNautilus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftNautilus.java index 53ae1f30ce68..53a436a4feb6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftNautilus.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftNautilus.java @@ -2,7 +2,9 @@ import net.minecraft.world.entity.animal.nautilus.Nautilus; import org.bukkit.craftbukkit.CraftServer; +import org.jspecify.annotations.NullMarked; +@NullMarked public class CraftNautilus extends CraftAbstractNautilus implements org.bukkit.entity.Nautilus { public CraftNautilus(final CraftServer server, final Nautilus entity) { super(server, entity); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java index 3f7f9e479d31..ea0a6fc1798a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java @@ -2,9 +2,8 @@ import net.minecraft.world.Container; import org.bukkit.inventory.HorseInventory; -import org.bukkit.inventory.ItemStack; -public class CraftInventoryHorse extends CraftSaddledInventory implements HorseInventory { +public class CraftInventoryHorse extends CraftInventorySaddledHorse implements HorseInventory { public CraftInventoryHorse(Container inventory, Container bodyArmorInventory, Container saddleInventory) { super(inventory, bodyArmorInventory, saddleInventory); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java index 8eb2677d46f9..c526ab5bec73 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java @@ -4,7 +4,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.LlamaInventory; -public class CraftInventoryLlama extends CraftInventoryAbstractHorse implements LlamaInventory { +public class CraftInventoryLlama extends CraftInventorySaddledMount implements LlamaInventory { public CraftInventoryLlama(Container inventory, Container bodyArmorInventory, Container saddleInventory) { super(inventory, bodyArmorInventory, saddleInventory); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledHorse.java new file mode 100644 index 000000000000..cc2a7c0621f8 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledHorse.java @@ -0,0 +1,12 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.world.Container; +import org.bukkit.inventory.SaddledHorseInventory; + +public class CraftInventorySaddledHorse extends CraftInventorySaddledMount implements SaddledHorseInventory { + + public CraftInventorySaddledHorse(Container inventory, final Container bodyArmorInventory, final Container saddleInventory) { + super(inventory, bodyArmorInventory, saddleInventory); + } + +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledMount.java similarity index 95% rename from paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java rename to paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledMount.java index 5351ac33dee5..7d3657795710 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledMount.java @@ -7,12 +7,12 @@ import org.bukkit.inventory.AbstractHorseInventory; import org.bukkit.inventory.ItemStack; -public class CraftInventoryAbstractHorse extends CraftInventory implements AbstractHorseInventory { +public class CraftInventorySaddledMount extends CraftInventory implements AbstractHorseInventory { private final Container bodyArmorInventory; private final Container saddleInventory; - public CraftInventoryAbstractHorse(Container inventory, final Container bodyArmorInventory, final Container saddleInventory) { + public CraftInventorySaddledMount(Container inventory, final Container bodyArmorInventory, final Container saddleInventory) { super(inventory); this.bodyArmorInventory = bodyArmorInventory; this.saddleInventory = saddleInventory; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSaddledInventory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSaddledInventory.java deleted file mode 100644 index 94364ec22058..000000000000 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSaddledInventory.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.bukkit.craftbukkit.inventory; - -import net.minecraft.world.Container; -import org.bukkit.inventory.SaddledHorseInventory; - -public class CraftSaddledInventory extends CraftInventoryAbstractHorse implements SaddledHorseInventory { - - public CraftSaddledInventory(Container inventory, final Container bodyArmorInventory, final Container saddleInventory) { - super(inventory, bodyArmorInventory, saddleInventory); - } - -} From 7d781aac667c7a2ae889ec6b21a8b36ed9a54129 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:35:32 +0100 Subject: [PATCH 080/112] simplify registry tests should prevent https://github.com/PaperMC/Paper/commit/c3eae73a8d25041fc2d6671c0863a921eaa87abe and https://github.com/PaperMC/Paper/commit/0196386152dc2643e2ae11b41295ed14b290a991 from ever happening --- .../src/main/java/org/bukkit/Effect.java | 17 +- .../src/main/java/org/bukkit/Registry.java | 1 - .../src/test/java/org/bukkit/EffectTest.java | 28 -- .../level/chunk/ChunkGenerator.java.patch | 2 +- .../gameevent/GameEventDispatcher.java.patch | 2 +- .../vibrations/VibrationSystem.java.patch | 2 +- .../io/papermc/paper/dialog/PaperDialog.java | 8 - .../java/org/bukkit/craftbukkit/CraftArt.java | 8 - .../bukkit/craftbukkit/CraftGameEvent.java | 8 +- .../org/bukkit/craftbukkit/CraftGameRule.java | 4 - .../bukkit/craftbukkit/CraftJukeboxSong.java | 8 - .../craftbukkit/CraftMusicInstrument.java | 8 - .../org/bukkit/craftbukkit/CraftWorld.java | 2 +- .../craftbukkit/attribute/CraftAttribute.java | 8 - .../bukkit/craftbukkit/block/CraftBiome.java | 16 +- .../block/banner/CraftPatternType.java | 8 - .../craftbukkit/damage/CraftDamageType.java | 8 - .../enchantments/CraftEnchantment.java | 10 +- .../bukkit/craftbukkit/entity/CraftCat.java | 8 - .../craftbukkit/entity/CraftChicken.java | 8 - .../bukkit/craftbukkit/entity/CraftCow.java | 8 - .../bukkit/craftbukkit/entity/CraftFrog.java | 8 - .../bukkit/craftbukkit/entity/CraftPig.java | 8 - .../craftbukkit/entity/CraftVillager.java | 16 - .../bukkit/craftbukkit/entity/CraftWolf.java | 16 - .../entity/CraftZombieNautilus.java | 8 - .../generator/structure/CraftStructure.java | 8 + .../craftbukkit/inventory/CraftItemMetas.java | 7 - .../craftbukkit/inventory/CraftMenuType.java | 6 +- .../inventory/trim/CraftTrimMaterial.java | 8 - .../inventory/trim/CraftTrimPattern.java | 8 - .../craftbukkit/map/CraftMapCursor.java | 8 - .../potion/CraftPotionEffectType.java | 2 +- .../craftbukkit/tag/CraftDamageTag.java | 2 +- .../paper/adventure/AdventureCodecsTest.java | 2 +- .../adventure/ComponentServicesTest.java | 4 +- .../block/CraftBlockDataDestroySpeedTest.java | 4 +- .../paper/block/InstrumentSoundTest.java | 4 +- .../BukkitCommandConversionTest.java | 3 +- .../StepBasedCollectorRunBeforeTest.java | 6 +- .../datacomponent/DataComponentTypesTest.java | 59 ---- .../paper/effects/EffectCategoryTest.java | 4 +- .../CraftMetaTropicalFishBucketTest.java | 4 +- .../item/ArmorSlotTypeMaterialTest.java | 18 +- .../item/ItemStackDataComponentTest.java | 2 +- .../paper/item/MetaComparisonTest.java | 4 +- .../MinecraftCommandPermissionsTest.java | 2 +- .../paper/registry/RegistryBuilderTest.java | 4 +- .../paper/registry/RegistryKeyTest.java | 2 +- .../paper/world/TranslationKeyTest.java | 30 +- .../paper/world/flag/FeatureFlagTest.java | 2 +- .../structure/StructureSeedConfigTest.java | 2 +- .../src/test/java/org/bukkit/EffectTest.java | 73 ++--- .../test/java/org/bukkit/InstrumentTest.java | 4 +- .../test/java/org/bukkit/ParticleTest.java | 12 +- .../src/test/java/org/bukkit/SoundTest.java | 8 +- .../craftbukkit/generator/ChunkDataTest.java | 8 +- .../inventory/CompositeSerializationTest.java | 10 +- .../craftbukkit/inventory/ItemMetaTest.java | 15 - .../java/org/bukkit/potion/PotionTest.java | 23 +- .../org/bukkit/registry/PerRegistryTest.java | 23 +- .../registry/RegistryArgumentAddedTest.java | 14 +- .../bukkit/registry/RegistryClassTest.java | 23 +- .../registry/RegistryConstantsTest.java | 120 +++---- .../registry/RegistryConversionTest.java | 302 +++--------------- .../registry/RegistryLoadOrderTest.java | 42 +-- .../org/bukkit/support/DummyServerHelper.java | 6 +- .../org/bukkit/support/RegistryHelper.java | 155 ++++----- .../extension/AllFeaturesExtension.java | 3 +- .../support/extension/LegacyExtension.java | 3 +- .../support/extension/NormalExtension.java | 14 +- .../support/extension/SlowExtension.java | 3 +- .../extension/VanillaFeatureExtension.java | 3 +- .../provider/RegistriesArgumentProvider.java | 111 ++++--- .../bukkit/support/test/RegistriesTest.java | 6 +- 75 files changed, 457 insertions(+), 957 deletions(-) delete mode 100644 paper-api/src/test/java/org/bukkit/EffectTest.java delete mode 100644 paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java diff --git a/paper-api/src/main/java/org/bukkit/Effect.java b/paper-api/src/main/java/org/bukkit/Effect.java index b044a45661cc..d2952c7750af 100644 --- a/paper-api/src/main/java/org/bukkit/Effect.java +++ b/paper-api/src/main/java/org/bukkit/Effect.java @@ -1,5 +1,6 @@ package org.bukkit; +import com.google.common.base.Enums; import com.google.common.collect.Maps; import java.util.Map; import org.bukkit.block.BlockFace; @@ -442,7 +443,6 @@ public enum Effect { SOUND_WITH_CHARGE_SHOT(1051, Type.SOUND), ; - private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); // Paper end private final int id; @@ -512,22 +512,13 @@ public static Effect getById(int id) { static { for (Effect effect : values()) { - if (!isDeprecated(effect)) // Paper + if (Enums.getField(effect).isAnnotationPresent(Deprecated.class)) { + continue; + } BY_ID.put(effect.id, effect); } } - // Paper start - private static boolean isDeprecated(Effect effect) { - try { - return Effect.class.getDeclaredField(effect.name()).isAnnotationPresent(Deprecated.class); - } catch (NoSuchFieldException e) { - LOGGER.error("Error getting effect enum field {}", effect.name(), e); - return false; - } - } - // Paper end - /** * Represents the type of an effect. * @deprecated not representative of what Effect does diff --git a/paper-api/src/main/java/org/bukkit/Registry.java b/paper-api/src/main/java/org/bukkit/Registry.java index d3aef5ebe9c8..0859653089ac 100644 --- a/paper-api/src/main/java/org/bukkit/Registry.java +++ b/paper-api/src/main/java/org/bukkit/Registry.java @@ -563,7 +563,6 @@ default T getOrThrow(final NamespacedKey key) { * @deprecated this method's behavior is broken and not useful. If you want to get an object * based on its vanilla name, or a key, wrap it in a {@link NamespacedKey} object and use {@link #get(NamespacedKey)} */ - // Paper @Deprecated(forRemoval = true) default @Nullable T match(final String input) { Preconditions.checkArgument(input != null, "input must not be null"); diff --git a/paper-api/src/test/java/org/bukkit/EffectTest.java b/paper-api/src/test/java/org/bukkit/EffectTest.java deleted file mode 100644 index 615a4583ef8e..000000000000 --- a/paper-api/src/test/java/org/bukkit/EffectTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.bukkit; - -import static org.bukkit.support.MatcherAssert.*; -import static org.hamcrest.CoreMatchers.*; -import org.junit.jupiter.api.Test; - -public class EffectTest { - private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); // Paper - - @Test - public void getById() { - for (Effect effect : Effect.values()) { - if (!isDeprecated(effect)) // Paper - assertThat(Effect.getById(effect.getId()), is(effect)); - } - } - - // Paper start - private static boolean isDeprecated(Effect effect) { - try { - return Effect.class.getDeclaredField(effect.name()).isAnnotationPresent(Deprecated.class); - } catch (NoSuchFieldException e) { - LOGGER.error("Error getting effect enum field {}", effect.name(), e); - return false; - } - } - // Paper end -} diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch index 80080c75bec3..468cd148d15c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch @@ -18,7 +18,7 @@ + // Paper start - StructuresLocateEvent + final org.bukkit.World bukkitWorld = level.getWorld(); + final org.bukkit.Location origin = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level); -+ final List apiStructures = structure.stream().map(Holder::value).map(nms -> org.bukkit.craftbukkit.generator.structure.CraftStructure.minecraftToBukkit(nms)).toList(); ++ final List apiStructures = structure.stream().map(org.bukkit.craftbukkit.generator.structure.CraftStructure::minecraftHolderToBukkit).toList(); + if (!apiStructures.isEmpty()) { + final io.papermc.paper.event.world.StructuresLocateEvent event = new io.papermc.paper.event.world.StructuresLocateEvent(bukkitWorld, origin, apiStructures, radius, skipKnownStructures); + if (!event.callEvent()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch b/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch index 48fcd72e8e62..043949fc6716 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch @@ -6,7 +6,7 @@ BlockPos blockPos = BlockPos.containing(pos); + // CraftBukkit start + org.bukkit.event.world.GenericGameEvent apiEvent = new org.bukkit.event.world.GenericGameEvent( -+ org.bukkit.craftbukkit.CraftGameEvent.minecraftToBukkit(gameEvent.value()), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(blockPos, this.level), ++ org.bukkit.craftbukkit.CraftGameEvent.minecraftHolderToBukkit(gameEvent), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(blockPos, this.level), + (context.sourceEntity() == null) ? null : context.sourceEntity().getBukkitEntity(), notificationRadius, !org.bukkit.Bukkit.isPrimaryThread()); + if (!apiEvent.callEvent()) { + return; diff --git a/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch b/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch index e011a54caf62..c56f5cbcf66d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch @@ -17,7 +17,7 @@ + // CraftBukkit start + boolean defaultCancel = !vibrationUser.canReceiveVibration(level, BlockPos.containing(pos), gameEvent, context); + Entity entity = context.sourceEntity(); -+ org.bukkit.event.block.BlockReceiveGameEvent event1 = new org.bukkit.event.block.BlockReceiveGameEvent(org.bukkit.craftbukkit.CraftGameEvent.minecraftToBukkit(gameEvent.value()), org.bukkit.craftbukkit.block.CraftBlock.at(level, BlockPos.containing(vec3)), (entity == null) ? null : entity.getBukkitEntity()); ++ org.bukkit.event.block.BlockReceiveGameEvent event1 = new org.bukkit.event.block.BlockReceiveGameEvent(org.bukkit.craftbukkit.CraftGameEvent.minecraftHolderToBukkit(gameEvent), org.bukkit.craftbukkit.block.CraftBlock.at(level, BlockPos.containing(vec3)), (entity == null) ? null : entity.getBukkitEntity()); + event1.setCancelled(defaultCancel); + level.getCraftServer().getPluginManager().callEvent(event1); + if (event1.isCancelled()) { diff --git a/paper-server/src/main/java/io/papermc/paper/dialog/PaperDialog.java b/paper-server/src/main/java/io/papermc/paper/dialog/PaperDialog.java index 7857853c5280..ef42f1b74366 100644 --- a/paper-server/src/main/java/io/papermc/paper/dialog/PaperDialog.java +++ b/paper-server/src/main/java/io/papermc/paper/dialog/PaperDialog.java @@ -7,18 +7,10 @@ public final class PaperDialog extends HolderableBase implements Dialog { - public static net.minecraft.server.dialog.Dialog bukkitToMinecraft(final Dialog bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(final Dialog bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } - public static Dialog minecraftToBukkit(final net.minecraft.server.dialog.Dialog minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.DIALOG); - } - public static Dialog minecraftHolderToBukkit(final Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.DIALOG); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java index d837b95337c3..b96522330eaa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java @@ -12,18 +12,10 @@ public class CraftArt extends OldEnumHolderable implements private static int count = 0; - public static Art minecraftToBukkit(PaintingVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.PAINTING_VARIANT); - } - public static Art minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.PAINTING_VARIANT); } - public static PaintingVariant bukkitToMinecraft(Art bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Art bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameEvent.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameEvent.java index 636c46b61293..4a05855086bb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameEvent.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameEvent.java @@ -8,12 +8,12 @@ public class CraftGameEvent extends GameEvent implements Holderable { - public static GameEvent minecraftToBukkit(net.minecraft.world.level.gameevent.GameEvent minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.GAME_EVENT); + public static GameEvent minecraftHolderToBukkit(Holder minecraft) { + return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.GAME_EVENT); } - public static net.minecraft.world.level.gameevent.GameEvent bukkitToMinecraft(GameEvent bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); + public static Holder bukkitToMinecraftHolder(GameEvent bukkit) { + return CraftRegistry.bukkitToMinecraftHolder(bukkit); } private final Holder holder; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java index 16c4ea13563c..5d42203a9079 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java @@ -25,10 +25,6 @@ public static net.minecraft.world.level.gamerules.GameRule bukkitToMinecr return CraftRegistry.bukkitToMinecraft(bukkit); } - public static Holder> bukkitToMinecraftHolder(GameRule bukkit) { - return CraftRegistry.bukkitToMinecraftHolder(bukkit); - } - private final Holder> holder; @SuppressWarnings("unchecked") diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java index d601352135ff..5f8868b2350e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java @@ -13,18 +13,10 @@ @NullMarked public class CraftJukeboxSong extends HolderableBase implements JukeboxSong { - public static JukeboxSong minecraftToBukkit(net.minecraft.world.item.JukeboxSong minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.JUKEBOX_SONG); - } - public static JukeboxSong minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.JUKEBOX_SONG); } - public static net.minecraft.world.item.JukeboxSong bukkitToMinecraft(JukeboxSong bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(JukeboxSong bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftMusicInstrument.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftMusicInstrument.java index ba1bc2ff7072..610bebdf860a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftMusicInstrument.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftMusicInstrument.java @@ -15,18 +15,10 @@ public class CraftMusicInstrument extends MusicInstrument implements io.papermc.paper.util.Holderable { - public static MusicInstrument minecraftToBukkit(Instrument minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.INSTRUMENT); - } - public static MusicInstrument minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.INSTRUMENT); // Paper - switch to Holder } - public static Instrument bukkitToMinecraft(MusicInstrument bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(MusicInstrument bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 7858356919dc..356b692c5022 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1862,7 +1862,7 @@ private StructureSearchResult locateNearestStructure(Location origin, List minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.ATTRIBUTE); } @@ -38,10 +34,6 @@ public static Attribute stringToBukkit(String string) { return CraftRegistry.get(RegistryKey.ATTRIBUTE, key, ApiVersion.CURRENT); } - public static net.minecraft.world.entity.ai.attributes.Attribute bukkitToMinecraft(Attribute bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Attribute bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java index 7dd35a6d0c08..14e6fb69e9af 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.block; import io.papermc.paper.util.OldEnumHolderable; +import java.util.Objects; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; import org.bukkit.NamespacedKey; @@ -9,29 +10,16 @@ import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; -import java.util.Objects; @NullMarked public class CraftBiome extends OldEnumHolderable implements Biome { private static int count = 0; - public static Biome minecraftToBukkit(net.minecraft.world.level.biome.Biome minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.BIOME); - } - public static Biome minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.BIOME); } - public static net.minecraft.world.level.biome.@Nullable Biome bukkitToMinecraft(Biome bukkit) { - if (bukkit == Biome.CUSTOM) { - return null; - } - - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static @Nullable Holder bukkitToMinecraftHolder(Biome bukkit) { if (bukkit == Biome.CUSTOM) { return null; @@ -45,7 +33,7 @@ public CraftBiome(final Holder holder) { /** * Implementation for the deprecated, API only, CUSTOM biome. - * As per {@link #bukkitToMinecraft(Biome)} and {@link #bukkitToMinecraftHolder(Biome)} it cannot be + * As per {@link #bukkitToMinecraftHolder(Biome)} it cannot be * converted into an internal biome and only serves backwards compatibility reasons. */ @Deprecated(forRemoval = true, since = "1.21.5") diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/banner/CraftPatternType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/banner/CraftPatternType.java index fd6acd6acf4e..f265a266d988 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/banner/CraftPatternType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/banner/CraftPatternType.java @@ -11,18 +11,10 @@ public class CraftPatternType extends OldEnumHolderable minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.BANNER_PATTERN); } - public static BannerPattern bukkitToMinecraft(PatternType bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(PatternType bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageType.java index ecd0ef7abc5d..1f3f7f83fd24 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageType.java @@ -81,12 +81,4 @@ public static DamageType minecraftHolderToBukkit(Holder bukkitToMinecraftHolder(DamageType bukkitDamageType) { return CraftRegistry.bukkitToMinecraftHolder(bukkitDamageType); } - - public static net.minecraft.world.damagesource.DamageType bukkitToMinecraft(DamageType bukkitDamageType) { - return CraftRegistry.bukkitToMinecraft(bukkitDamageType); - } - - public static DamageType minecraftToBukkit(net.minecraft.world.damagesource.DamageType minecraftDamageType) { - return CraftRegistry.minecraftToBukkit(minecraftDamageType, Registries.DAMAGE_TYPE); - } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index dbe3e37fcd9c..45b70a28e0c3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -20,16 +20,8 @@ public class CraftEnchantment extends Enchantment implements Holderable { - public static Enchantment minecraftToBukkit(net.minecraft.world.item.enchantment.Enchantment minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.ENCHANTMENT); - } - public static Enchantment minecraftHolderToBukkit(Holder minecraft) { - return CraftEnchantment.minecraftToBukkit(minecraft.value()); - } - - public static net.minecraft.world.item.enchantment.Enchantment bukkitToMinecraft(Enchantment bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); + return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.ENCHANTMENT); } public static Holder bukkitToMinecraftHolder(Enchantment bukkit) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java index c3e28e291e7c..22f6a08426d4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java @@ -46,18 +46,10 @@ public void setCollarColor(DyeColor color) { public static class CraftType extends OldEnumHolderable implements Type { private static int count = 0; - public static Type minecraftToBukkit(CatVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.CAT_VARIANT); - } - public static Type minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.CAT_VARIANT); } - public static CatVariant bukkitToMinecraft(Type bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Type bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java index 5b1353d87a11..677165bee7f4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java @@ -36,18 +36,10 @@ public void setVariant(Variant variant) { public static class CraftVariant extends HolderableBase implements Variant { - public static Variant minecraftToBukkit(ChickenVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.CHICKEN_VARIANT); - } - public static Variant minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.CHICKEN_VARIANT); } - public static ChickenVariant bukkitToMinecraft(Variant bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Variant bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java index c93885fdd01e..81aaf5c979ef 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java @@ -36,18 +36,10 @@ public void setVariant(Variant variant) { public static class CraftVariant extends HolderableBase implements Variant { - public static Variant minecraftToBukkit(CowVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.COW_VARIANT); - } - public static Variant minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.COW_VARIANT); } - public static CowVariant bukkitToMinecraft(Variant bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Variant bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java index 08df77201f0f..553431428e8a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java @@ -50,18 +50,10 @@ public void setVariant(Variant variant) { public static class CraftVariant extends OldEnumHolderable implements Variant { private static int count = 0; - public static Variant minecraftToBukkit(FrogVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.FROG_VARIANT); - } - public static Variant minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.FROG_VARIANT); } - public static FrogVariant bukkitToMinecraft(Variant bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Variant bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java index 387eed77223a..85a5fd1ef890 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java @@ -84,18 +84,10 @@ public void setVariant(Variant variant) { public static class CraftVariant extends HolderableBase implements Variant { - public static Variant minecraftToBukkit(PigVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.PIG_VARIANT); - } - public static Variant minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.PIG_VARIANT); } - public static PigVariant bukkitToMinecraft(Variant bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Variant bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index e823f362af9b..290f101be698 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -166,18 +166,10 @@ public ZombieVillager zombify() { public static class CraftType extends OldEnumHolderable implements Type { private static int count = 0; - public static Type minecraftToBukkit(VillagerType minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.VILLAGER_TYPE); - } - public static Type minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.VILLAGER_TYPE); } - public static VillagerType bukkitToMinecraft(Type bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Type bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } @@ -198,14 +190,6 @@ public static Holder bukkitToMinecraftHolder(Profession bukk return CraftRegistry.bukkitToMinecraftHolder(bukkit); } - public static Profession minecraftToBukkit(VillagerProfession minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.VILLAGER_PROFESSION); - } - - public static VillagerProfession bukkitToMinecraft(Profession bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public CraftProfession(final Holder holder) { super(holder, count++); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java index 723a8e659485..1e24ae852691 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java @@ -92,18 +92,10 @@ public void setSoundVariant(SoundVariant soundVariant) { public static class CraftVariant extends HolderableBase implements Variant { - public static Variant minecraftToBukkit(WolfVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.WOLF_VARIANT); - } - public static Variant minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.WOLF_VARIANT); } - public static WolfVariant bukkitToMinecraft(Variant bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Variant bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } @@ -115,18 +107,10 @@ public CraftVariant(final Holder holder) { public static class CraftSoundVariant extends HolderableBase implements SoundVariant { - public static SoundVariant minecraftToBukkit(WolfSoundVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.WOLF_SOUND_VARIANT); - } - public static SoundVariant minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.WOLF_SOUND_VARIANT); } - public static WolfSoundVariant bukkitToMinecraft(SoundVariant bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(SoundVariant bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java index 9f342e2e3863..0cf3b0c7a88c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java @@ -35,18 +35,10 @@ public void setVariant(org.bukkit.entity.ZombieNautilus.Variant variant) { public static class CraftVariant extends HolderableBase implements org.bukkit.entity.ZombieNautilus.Variant { - public static org.bukkit.entity.ZombieNautilus.Variant minecraftToBukkit(ZombieNautilusVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.ZOMBIE_NAUTILUS_VARIANT); - } - public static org.bukkit.entity.ZombieNautilus.Variant minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.ZOMBIE_NAUTILUS_VARIANT); } - public static ZombieNautilusVariant bukkitToMinecraft(Variant bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Variant bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/structure/CraftStructure.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/structure/CraftStructure.java index fc848f288363..524c28b4c876 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/structure/CraftStructure.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/structure/CraftStructure.java @@ -18,6 +18,14 @@ public static net.minecraft.world.level.levelgen.structure.Structure bukkitToMin return CraftRegistry.bukkitToMinecraft(bukkit); } + public static Structure minecraftHolderToBukkit(Holder minecraft) { + return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.STRUCTURE); + } + + public static Holder bukkitToMinecraftHolder(Structure bukkit) { + return CraftRegistry.bukkitToMinecraftHolder(bukkit); + } + private final Holder holder; public CraftStructure(Holder holder) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java index 905f04654842..546b7aa1055c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java @@ -3,20 +3,13 @@ import com.destroystokyo.paper.inventory.meta.ArmorStandMeta; import java.util.function.BiFunction; import net.minecraft.world.item.BannerItem; -import net.minecraft.world.item.BedItem; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BundleItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.SignItem; import net.minecraft.world.item.SpawnEggItem; -import net.minecraft.world.level.block.AbstractChestBlock; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.ChestBlock; -import net.minecraft.world.level.block.CopperGolemStatueBlock; import net.minecraft.world.level.block.EntityBlock; -import net.minecraft.world.level.block.ShelfBlock; -import net.minecraft.world.level.block.ShulkerBoxBlock; import org.bukkit.inventory.ItemType; import org.bukkit.inventory.meta.ArmorMeta; import org.bukkit.inventory.meta.AxolotlBucketMeta; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMenuType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMenuType.java index a90d0d5e95b3..065309bf3e41 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMenuType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMenuType.java @@ -61,15 +61,11 @@ public Class getInventoryViewClass() { return this.typeData.get().viewClass(); } - public static net.minecraft.world.inventory.MenuType bukkitToMinecraft(MenuType bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static MenuType minecraftToBukkit(net.minecraft.world.inventory.MenuType minecraft) { return CraftRegistry.minecraftToBukkit(minecraft, Registries.MENU); } public static MenuType minecraftHolderToBukkit(Holder> minecraft) { - return CraftMenuType.minecraftToBukkit(minecraft.value()); + return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.MENU); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimMaterial.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimMaterial.java index 5a7a0520f513..1df7df13a602 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimMaterial.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimMaterial.java @@ -12,18 +12,10 @@ public class CraftTrimMaterial extends HolderableBase implements TrimMaterial { - public static TrimMaterial minecraftToBukkit(net.minecraft.world.item.equipment.trim.TrimMaterial minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.TRIM_MATERIAL); - } - public static TrimMaterial minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.TRIM_MATERIAL); } - public static net.minecraft.world.item.equipment.trim.TrimMaterial bukkitToMinecraft(TrimMaterial bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(TrimMaterial bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimPattern.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimPattern.java index 89925377dcad..5bb67269b055 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimPattern.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimPattern.java @@ -12,18 +12,10 @@ public class CraftTrimPattern extends HolderableBase implements TrimPattern { - public static TrimPattern minecraftToBukkit(net.minecraft.world.item.equipment.trim.TrimPattern minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.TRIM_PATTERN); - } - public static TrimPattern minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.TRIM_PATTERN); } - public static net.minecraft.world.item.equipment.trim.TrimPattern bukkitToMinecraft(TrimPattern bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(TrimPattern bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCursor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCursor.java index c0cf9065decb..f8313826f604 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCursor.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCursor.java @@ -13,18 +13,10 @@ public static final class CraftType extends OldEnumHolderable minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.MAP_DECORATION_TYPE); } - public static MapDecorationType bukkitToMinecraft(MapCursor.Type bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(MapCursor.Type bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java index add1575ef432..4881e366c8d4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java @@ -26,7 +26,7 @@ public class CraftPotionEffectType extends PotionEffectType implements Holderable, io.papermc.paper.world.flag.PaperFeatureDependent { public static PotionEffectType minecraftHolderToBukkit(Holder minecraft) { - return CraftPotionEffectType.minecraftToBukkit(minecraft.value()); + return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.MOB_EFFECT); } public static PotionEffectType minecraftToBukkit(MobEffect minecraft) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftDamageTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftDamageTag.java index ee97ff023f9d..e3c92ae2bd71 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftDamageTag.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftDamageTag.java @@ -21,6 +21,6 @@ public boolean isTagged(DamageType type) { @Override public Set getValues() { - return this.getHandle().stream().map(Holder::value).map(CraftDamageType::minecraftToBukkit).collect(Collectors.toUnmodifiableSet()); + return this.getHandle().stream().map(CraftDamageType::minecraftHolderToBukkit).collect(Collectors.toUnmodifiableSet()); } } diff --git a/paper-server/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java b/paper-server/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java index 4e7f7f043a6d..ea59a360732a 100644 --- a/paper-server/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java +++ b/paper-server/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java @@ -237,7 +237,7 @@ static List> dynamicOps() { JavaOps.INSTANCE, JsonOps.INSTANCE ) - .map(ops -> RegistryHelper.getRegistry().createSerializationContext(ops)) + .map(ops -> RegistryHelper.registryAccess().createSerializationContext(ops)) .toList(); } diff --git a/paper-server/src/test/java/io/papermc/paper/adventure/ComponentServicesTest.java b/paper-server/src/test/java/io/papermc/paper/adventure/ComponentServicesTest.java index 9d37c0e2bd37..4305540893b5 100644 --- a/paper-server/src/test/java/io/papermc/paper/adventure/ComponentServicesTest.java +++ b/paper-server/src/test/java/io/papermc/paper/adventure/ComponentServicesTest.java @@ -4,12 +4,12 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -@AllFeatures +@Normal public class ComponentServicesTest { @Test diff --git a/paper-server/src/test/java/io/papermc/paper/block/CraftBlockDataDestroySpeedTest.java b/paper-server/src/test/java/io/papermc/paper/block/CraftBlockDataDestroySpeedTest.java index e83c38c74898..f70985a8e222 100644 --- a/paper-server/src/test/java/io/papermc/paper/block/CraftBlockDataDestroySpeedTest.java +++ b/paper-server/src/test/java/io/papermc/paper/block/CraftBlockDataDestroySpeedTest.java @@ -24,7 +24,7 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.VanillaFeature; import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Assertions; @@ -40,7 +40,7 @@ * This test is responsible for ensuring that said logic emits the expected destroy speed under heavy attribute * modifier use. */ -@AllFeatures +@VanillaFeature public class CraftBlockDataDestroySpeedTest { @Test diff --git a/paper-server/src/test/java/io/papermc/paper/block/InstrumentSoundTest.java b/paper-server/src/test/java/io/papermc/paper/block/InstrumentSoundTest.java index cd718ed01ba5..bf4365c607b0 100644 --- a/paper-server/src/test/java/io/papermc/paper/block/InstrumentSoundTest.java +++ b/paper-server/src/test/java/io/papermc/paper/block/InstrumentSoundTest.java @@ -6,13 +6,13 @@ import org.bukkit.Instrument; import org.bukkit.craftbukkit.CraftSound; import org.bukkit.craftbukkit.block.data.CraftBlockData; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.VanillaFeature; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import static org.junit.jupiter.api.Assertions.assertEquals; -@AllFeatures +@VanillaFeature class InstrumentSoundTest { static Stream bukkitInstruments() { diff --git a/paper-server/src/test/java/io/papermc/paper/command/brigadier/BukkitCommandConversionTest.java b/paper-server/src/test/java/io/papermc/paper/command/brigadier/BukkitCommandConversionTest.java index 4b419ce023f6..7524ee0de782 100644 --- a/paper-server/src/test/java/io/papermc/paper/command/brigadier/BukkitCommandConversionTest.java +++ b/paper-server/src/test/java/io/papermc/paper/command/brigadier/BukkitCommandConversionTest.java @@ -13,7 +13,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.SimpleCommandMap; import org.bukkit.support.RegistryHelper; -import org.bukkit.support.environment.AllFeatures; import org.bukkit.support.environment.Normal; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Assertions; @@ -33,7 +32,7 @@ public void test() throws CommandSyntaxException { CommandSourceStack object = Mockito.mock(CommandSourceStack.class); Mockito.when(object.getLocation()).thenReturn(new Location(null, 0, 0, 0));; - CommandDispatcher dispatcher = RegistryHelper.getDataPack().commands.getDispatcher(); + CommandDispatcher dispatcher = RegistryHelper.context().datapack().commands.getDispatcher(); dispatcher.setConsumer((context, success, result) -> {}); CommandMap commandMap = new SimpleCommandMap(Bukkit.getServer(), new BukkitBrigForwardingMap()); Map stringCommandMap = commandMap.getKnownCommands(); diff --git a/paper-server/src/test/java/io/papermc/paper/contract/StepBasedCollectorRunBeforeTest.java b/paper-server/src/test/java/io/papermc/paper/contract/StepBasedCollectorRunBeforeTest.java index 8c6292ea1716..4a4acf215163 100644 --- a/paper-server/src/test/java/io/papermc/paper/contract/StepBasedCollectorRunBeforeTest.java +++ b/paper-server/src/test/java/io/papermc/paper/contract/StepBasedCollectorRunBeforeTest.java @@ -3,11 +3,9 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.InsideBlockEffectApplier.StepBasedCollector; import net.minecraft.world.entity.InsideBlockEffectType; -import net.minecraft.world.entity.animal.Pig; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -19,7 +17,7 @@ * Paper relies on this implementation detail to perform some events, specifically * - net.minecraft.world.level.block.LayeredCauldronBlock#entityInside */ -@AllFeatures +@Normal public class StepBasedCollectorRunBeforeTest { @Test diff --git a/paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java b/paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java deleted file mode 100644 index 02bb41e1c535..000000000000 --- a/paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package io.papermc.paper.datacomponent; - -import com.google.common.collect.Collections2; -import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.Identifier; -import org.bukkit.craftbukkit.util.CraftNamespacedKey; -import org.bukkit.support.RegistryHelper; -import org.bukkit.support.environment.AllFeatures; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import java.lang.reflect.Field; -import java.util.Set; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -@AllFeatures -public class DataComponentTypesTest { - - private static final Set NOT_IN_API = Set.of( - Identifier.parse("custom_data"), - Identifier.parse("entity_data"), - Identifier.parse("bees"), - Identifier.parse("debug_stick_state"), - Identifier.parse("block_entity_data"), - Identifier.parse("bucket_entity_data"), - Identifier.parse("lock"), - Identifier.parse("creative_slot_lock") - ); - - @Test - public void testAllDataComponentsAreMapped() throws IllegalAccessException { - final Set vanillaDataComponentTypes = new ObjectOpenHashSet<>( - RegistryHelper.getRegistry() - .lookupOrThrow(Registries.DATA_COMPONENT_TYPE) - .keySet() - ); - - for (final Field declaredField : DataComponentTypes.class.getDeclaredFields()) { - if (!DataComponentType.class.isAssignableFrom(declaredField.getType())) continue; - - final DataComponentType dataComponentType = (DataComponentType) declaredField.get(null); - if (!vanillaDataComponentTypes.remove(CraftNamespacedKey.toMinecraft(dataComponentType.getKey()))) { - Assertions.fail("API defined component type " + dataComponentType.key().asMinimalString() + " is unknown to vanilla registry"); - } - } - - if (!vanillaDataComponentTypes.containsAll(NOT_IN_API)) { - Assertions.fail("API defined data components that were marked as not-yet-implemented: " + NOT_IN_API.stream().filter(Predicate.not(vanillaDataComponentTypes::contains)).map(Identifier::toString).collect(Collectors.joining(", "))); - } - - vanillaDataComponentTypes.removeAll(NOT_IN_API); - if (!vanillaDataComponentTypes.isEmpty()) { - Assertions.fail("API did not define following vanilla data component types: " + String.join(", ", Collections2.transform(vanillaDataComponentTypes, Identifier::toString))); - } - } - -} diff --git a/paper-server/src/test/java/io/papermc/paper/effects/EffectCategoryTest.java b/paper-server/src/test/java/io/papermc/paper/effects/EffectCategoryTest.java index a57e8fdc35ef..1beaa37015e0 100644 --- a/paper-server/src/test/java/io/papermc/paper/effects/EffectCategoryTest.java +++ b/paper-server/src/test/java/io/papermc/paper/effects/EffectCategoryTest.java @@ -4,13 +4,13 @@ import net.minecraft.world.effect.MobEffectCategory; import org.bukkit.craftbukkit.potion.CraftPotionEffectType; import org.bukkit.potion.PotionEffectType; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -@AllFeatures +@Normal public class EffectCategoryTest { @Test diff --git a/paper-server/src/test/java/io/papermc/paper/inventory/CraftMetaTropicalFishBucketTest.java b/paper-server/src/test/java/io/papermc/paper/inventory/CraftMetaTropicalFishBucketTest.java index 68a557cedbff..54b66871c48c 100644 --- a/paper-server/src/test/java/io/papermc/paper/inventory/CraftMetaTropicalFishBucketTest.java +++ b/paper-server/src/test/java/io/papermc/paper/inventory/CraftMetaTropicalFishBucketTest.java @@ -5,11 +5,11 @@ import org.bukkit.entity.TropicalFish; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.TropicalFishBucketMeta; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.VanillaFeature; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -@AllFeatures +@VanillaFeature public class CraftMetaTropicalFishBucketTest { @Test diff --git a/paper-server/src/test/java/io/papermc/paper/inventory/item/ArmorSlotTypeMaterialTest.java b/paper-server/src/test/java/io/papermc/paper/inventory/item/ArmorSlotTypeMaterialTest.java index 1431b3faf081..a5a48f8bbead 100644 --- a/paper-server/src/test/java/io/papermc/paper/inventory/item/ArmorSlotTypeMaterialTest.java +++ b/paper-server/src/test/java/io/papermc/paper/inventory/item/ArmorSlotTypeMaterialTest.java @@ -3,7 +3,6 @@ import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent; import java.util.ArrayList; import java.util.List; -import java.util.stream.Stream; import net.minecraft.core.component.DataComponents; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.Item; @@ -12,6 +11,7 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.support.environment.AllFeatures; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -21,14 +21,14 @@ @AllFeatures public class ArmorSlotTypeMaterialTest { - public static Stream slotTypeParams() { - final List parameters = new ArrayList<>(); + public static List slotTypeParams() { + final List parameters = new ArrayList<>(); for (final PlayerArmorChangeEvent.SlotType slotType : PlayerArmorChangeEvent.SlotType.values()) { for (final Material item : slotType.getTypes()) { - parameters.add(new Object[]{ slotType, item }); + parameters.add(Arguments.of(slotType, item)); } } - return parameters.stream(); + return parameters; } @ParameterizedTest(name = "{argumentsWithNames}") @@ -46,15 +46,15 @@ public void testSlotType(PlayerArmorChangeEvent.SlotType slotType, Material item assertEquals(equippable.slot(), slot, item + " isn't set to the right slot"); } - public static Stream equipableParams() { - final List parameters = new ArrayList<>(); + public static List equipableParams() { + final List parameters = new ArrayList<>(); for (final Item item : net.minecraft.core.registries.BuiltInRegistries.ITEM) { final Equippable equippable = item.components().get(DataComponents.EQUIPPABLE); if (equippable != null) { - parameters.add(new Object[]{equippable, item}); + parameters.add(Arguments.of(equippable, item)); } } - return parameters.stream(); + return parameters; } @ParameterizedTest(name = "{argumentsWithNames}") diff --git a/paper-server/src/test/java/io/papermc/paper/item/ItemStackDataComponentTest.java b/paper-server/src/test/java/io/papermc/paper/item/ItemStackDataComponentTest.java index ae5e90c66aa2..8a83468ec2f4 100644 --- a/paper-server/src/test/java/io/papermc/paper/item/ItemStackDataComponentTest.java +++ b/paper-server/src/test/java/io/papermc/paper/item/ItemStackDataComponentTest.java @@ -369,7 +369,7 @@ void testJukeboxWithEitherKey() { void testJukeboxWithEitherHolder() { final net.minecraft.world.item.ItemStack internalStack = new net.minecraft.world.item.ItemStack(Items.STONE); internalStack.set(DataComponents.JUKEBOX_PLAYABLE, new net.minecraft.world.item.JukeboxPlayable( - new EitherHolder<>(RegistryHelper.getRegistry().lookupOrThrow(Registries.JUKEBOX_SONG).getOrThrow(JukeboxSongs.FIVE)) + new EitherHolder<>(RegistryHelper.registryAccess().lookupOrThrow(Registries.JUKEBOX_SONG).getOrThrow(JukeboxSongs.FIVE)) )); final ItemStack apiStack = CraftItemStack.asBukkitCopy(internalStack); diff --git a/paper-server/src/test/java/io/papermc/paper/item/MetaComparisonTest.java b/paper-server/src/test/java/io/papermc/paper/item/MetaComparisonTest.java index 7cda79980729..0c39216d75f1 100644 --- a/paper-server/src/test/java/io/papermc/paper/item/MetaComparisonTest.java +++ b/paper-server/src/test/java/io/papermc/paper/item/MetaComparisonTest.java @@ -22,13 +22,13 @@ import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.VanillaFeature; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; // TODO: This should technically be used to compare legacy meta vs the newly implemented -@AllFeatures +@VanillaFeature public class MetaComparisonTest { private static final ItemFactory FACTORY = CraftItemFactory.instance(); diff --git a/paper-server/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java b/paper-server/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java index fe08e446e86d..b9ce8c1a98ea 100644 --- a/paper-server/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java +++ b/paper-server/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java @@ -40,7 +40,7 @@ public void test() { CraftDefaultPermissions.registerCorePermissions(); Set perms = collectMinecraftCommandPerms(); - Commands commands = new Commands(Commands.CommandSelection.DEDICATED, CommandBuildContext.simple(RegistryHelper.getRegistry(), FeatureFlags.VANILLA_SET), true); + Commands commands = new Commands(Commands.CommandSelection.DEDICATED, CommandBuildContext.simple(RegistryHelper.registryAccess(), FeatureFlags.VANILLA_SET), true); RootCommandNode root = commands.getDispatcher().getRoot(); Set missing = new LinkedHashSet<>(); Set foundPerms = new HashSet<>(); diff --git a/paper-server/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java b/paper-server/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java index 8df17d82a37f..faadfafd776e 100644 --- a/paper-server/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java +++ b/paper-server/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java @@ -28,8 +28,8 @@ static Stream registries() { @ParameterizedTest @MethodSource("registries") - void testEquality(final RegistryEntryMeta.Buildable registryEntry) { // TODO remove Keyed - final Registry registry = RegistryHelper.getRegistry().lookupOrThrow(registryEntry.mcKey()); + void testEquality(final RegistryEntryMeta.Buildable registryEntry) { // TODO remove Keyed + final Registry registry = RegistryHelper.registryAccess().lookupOrThrow(registryEntry.mcKey()); for (final Map.Entry, M> entry : registry.entrySet()) { final M built = registryEntry.builderFiller().fill(Conversions.global(), entry.getValue()).build(); assertEquals(entry.getValue(), built); diff --git a/paper-server/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java b/paper-server/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java index fcf52e47c76e..cd26f63f6c89 100644 --- a/paper-server/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java +++ b/paper-server/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java @@ -31,7 +31,7 @@ static Stream> data() { @ParameterizedTest @MethodSource("data") void testApiRegistryKeysExist(final RegistryKey key) { - final Optional> registry = RegistryHelper.getRegistry().lookup(ResourceKey.createRegistryKey(Identifier.parse(key.key().asString()))); + final Optional> registry = RegistryHelper.registryAccess().lookup(ResourceKey.createRegistryKey(Identifier.parse(key.key().asString()))); assertTrue(registry.isPresent(), "Missing vanilla registry for " + key.key().asString()); } diff --git a/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java b/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java index 0fc19c8da251..282ead960273 100644 --- a/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java +++ b/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java @@ -1,24 +1,15 @@ package io.papermc.paper.world; -import java.util.Locale; -import java.util.Map; import net.minecraft.network.chat.contents.TranslatableContents; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.level.GameType; -import net.minecraft.world.level.biome.Biome; import org.bukkit.Difficulty; import org.bukkit.FireworkEffect; import org.bukkit.GameMode; -import org.bukkit.GameRule; -import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.support.RegistryHelper; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -@AllFeatures +@Normal public class TranslationKeyTest { @Test @@ -37,15 +28,6 @@ public void testFireworkEffectType() { } } - @Test - @Disabled // TODO fix - public void testCreativeCategory() { - // for (CreativeModeTab tab : CreativeModeTabs.tabs()) { - // CreativeCategory category = Objects.requireNonNull(CraftCreativeCategory.fromNMS(tab)); - // Assertions.assertEquals("translation key mismatch for " + category, ((TranslatableContents) tab.getDisplayName().getContents()).getKey(), category.translationKey()); - // } - } - @Test public void testGameMode() { for (GameType nms : GameType.values()) { @@ -54,12 +36,4 @@ public void testGameMode() { Assertions.assertEquals(((TranslatableContents) nms.getLongDisplayName().getContents()).getKey(), bukkit.translationKey(), "translation key mismatch for " + bukkit); } } - - @Test - public void testBiome() { - for (Map.Entry, Biome> nms : RegistryHelper.getBiomes().entrySet()) { - org.bukkit.block.Biome bukkit = org.bukkit.block.Biome.valueOf(nms.getKey().identifier().getPath().toUpperCase(Locale.ROOT)); - Assertions.assertEquals(nms.getKey().identifier().toLanguageKey("biome"), bukkit.translationKey(), "translation key mismatch for " + bukkit); - } - } } diff --git a/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java b/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java index 3d8d39205074..df2f4919eb89 100644 --- a/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java +++ b/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java @@ -81,7 +81,7 @@ void testApiImplementsFeatureDependant(final RegistryKey re } static Stream> nonFeatureFilteredRegistries() { - return RegistryHelper.getRegistry().registries().filter(r -> { + return RegistryHelper.registryAccess().registries().filter(r -> { final RegistryEntry entry = PaperRegistries.getEntry(r.key()); // has an API registry and isn't a filtered registry return entry != null && !FeatureElement.FILTERED_REGISTRIES.contains(r.key()); diff --git a/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java b/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java index a6493b17607d..0934c184eeef 100644 --- a/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java +++ b/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java @@ -34,7 +34,7 @@ public void save(final @NotNull File file) { final SpigotWorldConfig config = PaperConfigurations.SPIGOT_WORLD_DEFAULTS.get(); - final Registry structureSets = RegistryHelper.getRegistry().lookupOrThrow(Registries.STRUCTURE_SET); + final Registry structureSets = RegistryHelper.registryAccess().lookupOrThrow(Registries.STRUCTURE_SET); for (final ResourceKey setKey : structureSets.registryKeySet()) { assertEquals(Identifier.DEFAULT_NAMESPACE, setKey.identifier().getNamespace()); final StructureSet set = structureSets.getValueOrThrow(setKey); diff --git a/paper-server/src/test/java/org/bukkit/EffectTest.java b/paper-server/src/test/java/org/bukkit/EffectTest.java index 5eaa832abbe9..b54401f30a17 100644 --- a/paper-server/src/test/java/org/bukkit/EffectTest.java +++ b/paper-server/src/test/java/org/bukkit/EffectTest.java @@ -1,49 +1,52 @@ package org.bukkit; import com.google.common.base.Joiner; +import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; +import it.unimi.dsi.fastutil.ints.IntArraySet; +import it.unimi.dsi.fastutil.ints.IntSet; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; -import java.util.List; -import java.util.Map; import java.util.Set; import net.minecraft.world.level.block.LevelEvent; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import static org.bukkit.support.MatcherAssert.assertThat; +import static org.hamcrest.CoreMatchers.is; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.fail; public class EffectTest { - private static List collectNmsLevelEvents() throws ReflectiveOperationException { - final List events = new ArrayList<>(); - for (final Field field : LevelEvent.class.getFields()) { - if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && field.getType() == int.class) { - events.add((int) field.get(null)); - } - } - return events; - } - private static boolean isNotDeprecated(Effect effect) throws ReflectiveOperationException { return !Effect.class.getDeclaredField(effect.name()).isAnnotationPresent(Deprecated.class); } - @Test - public void checkAllApiExists() throws ReflectiveOperationException { - Map toId = new HashMap<>(); + private static final Int2ObjectArrayMap ID_TO_EFFECT = new Int2ObjectArrayMap<>(); // api + private static final IntSet LEVEL_EVENTS = new IntArraySet(); // internal + + @BeforeAll + public static void init() throws ReflectiveOperationException { for (final Effect effect : Effect.values()) { if (isNotDeprecated(effect)) { - final Effect put = toId.put(effect.getId(), effect); - assertNull(put, "duplicate API effect: " + put); + final Effect put = ID_TO_EFFECT.put(effect.getId(), effect); + assertNull(put, "Duplicate API effect: " + put); + } + } + + for (final Field field : LevelEvent.class.getFields()) { + if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && field.getType() == int.class) { + LEVEL_EVENTS.add((int) field.get(null)); } } + } - final Set missingEvents = new HashSet<>(); - for (final Integer event : collectNmsLevelEvents()) { - if (toId.get(event) == null) { + @Test + public void checkAllApiExists() { + final IntSet missingEvents = new IntArraySet(); + for (final int event : LEVEL_EVENTS) { + if (!ID_TO_EFFECT.containsKey(event)) { missingEvents.add(event); } } @@ -53,24 +56,22 @@ public void checkAllApiExists() throws ReflectiveOperationException { } @Test - public void checkNoExtraApi() throws ReflectiveOperationException { - Map toId = new HashMap<>(); - for (final Effect effect : Effect.values()) { - if (isNotDeprecated(effect)) { - final Effect put = toId.put(effect.getId(), effect); - assertNull(put, "duplicate API effect: " + put); - } - } - - final List nmsEvents = collectNmsLevelEvents(); + public void checkNoExtraApi() { final Set extraApiEffects = new HashSet<>(); - for (final Map.Entry entry : toId.entrySet()) { - if (!nmsEvents.contains(entry.getKey())) { - extraApiEffects.add(entry.getValue()); + ID_TO_EFFECT.forEach((key, value) -> { + if (!LEVEL_EVENTS.contains(key)) { + extraApiEffects.add(value); } - } + }); if (!extraApiEffects.isEmpty()) { fail("Extra API Effects:\n" + Joiner.on("\n").join(extraApiEffects)); } } + + @Test + public void testByIdRoundTrip() { + ID_TO_EFFECT.forEach((key, value) -> { + assertThat(Effect.getById(key), is(value)); + }); + } } diff --git a/paper-server/src/test/java/org/bukkit/InstrumentTest.java b/paper-server/src/test/java/org/bukkit/InstrumentTest.java index 5da6b5c996c9..0363b615f3a7 100644 --- a/paper-server/src/test/java/org/bukkit/InstrumentTest.java +++ b/paper-server/src/test/java/org/bukkit/InstrumentTest.java @@ -1,12 +1,12 @@ package org.bukkit; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Test; import static org.bukkit.support.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.is; -@AllFeatures +@Normal public class InstrumentTest { // Paper - moved to internals as this test now access the sound registry. @Test diff --git a/paper-server/src/test/java/org/bukkit/ParticleTest.java b/paper-server/src/test/java/org/bukkit/ParticleTest.java index fd00c0d8a100..414586df882d 100644 --- a/paper-server/src/test/java/org/bukkit/ParticleTest.java +++ b/paper-server/src/test/java/org/bukkit/ParticleTest.java @@ -1,6 +1,5 @@ package org.bukkit; -import static org.junit.jupiter.api.Assertions.*; import com.mojang.serialization.DataResult; import java.util.Optional; import java.util.stream.Stream; @@ -29,7 +28,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.inventory.ItemStack; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.VanillaFeature; import org.joml.Vector3f; import org.joml.Vector4f; import org.junit.jupiter.params.ParameterizedTest; @@ -37,7 +36,14 @@ import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.MethodSource; -@AllFeatures +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +@VanillaFeature public class ParticleTest { public static Stream data() { diff --git a/paper-server/src/test/java/org/bukkit/SoundTest.java b/paper-server/src/test/java/org/bukkit/SoundTest.java index ef268c04368a..dd0362b5e4a7 100644 --- a/paper-server/src/test/java/org/bukkit/SoundTest.java +++ b/paper-server/src/test/java/org/bukkit/SoundTest.java @@ -1,11 +1,11 @@ package org.bukkit; -import static org.junit.jupiter.api.Assertions.*; - -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Test; -@AllFeatures +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@Normal public class SoundTest { @Test diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java index db0d1e1b993e..d484d1de01bc 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java @@ -36,21 +36,21 @@ private void testSetRegion(OldCraftChunkData data, int minx, int miny, int minz, @Test public void testMinHeight() { - OldCraftChunkData data = new OldCraftChunkData(-128, 128, RegistryHelper.palettedContainerFactory()); + OldCraftChunkData data = new OldCraftChunkData(-128, 128, RegistryHelper.context().palettedContainerFactory().get()); assertTrue(this.testSetBlock(data, 0, -256, 0, ChunkDataTest.RED_WOOL, ChunkDataTest.AIR), "Could not set block below min height"); assertTrue(this.testSetBlock(data, 0, -64, 0, ChunkDataTest.RED_WOOL, ChunkDataTest.RED_WOOL), "Could set block above min height"); } @Test public void testMaxHeight() { - OldCraftChunkData data = new OldCraftChunkData(0, 128, RegistryHelper.palettedContainerFactory()); + OldCraftChunkData data = new OldCraftChunkData(0, 128, RegistryHelper.context().palettedContainerFactory().get()); assertTrue(this.testSetBlock(data, 0, 128, 0, ChunkDataTest.RED_WOOL, ChunkDataTest.AIR), "Could not set block above max height"); assertTrue(this.testSetBlock(data, 0, 127, 0, ChunkDataTest.RED_WOOL, ChunkDataTest.RED_WOOL), "Could set block below max height"); } @Test public void testBoundsCheckingSingle() { - OldCraftChunkData data = new OldCraftChunkData(0, 256, RegistryHelper.palettedContainerFactory()); + OldCraftChunkData data = new OldCraftChunkData(0, 256, RegistryHelper.context().palettedContainerFactory().get()); assertTrue(this.testSetBlock(data, 0, 0, 0, ChunkDataTest.RED_WOOL, ChunkDataTest.RED_WOOL), "Can set block inside chunk bounds"); assertTrue(this.testSetBlock(data, 15, 255, 15, ChunkDataTest.RED_WOOL, ChunkDataTest.RED_WOOL), "Can set block inside chunk bounds"); assertTrue(this.testSetBlock(data, -1, 0, 0, ChunkDataTest.RED_WOOL, ChunkDataTest.AIR), "Can no set block outside chunk bounds"); @@ -63,7 +63,7 @@ public void testBoundsCheckingSingle() { @Test public void testSetRegion() { - OldCraftChunkData data = new OldCraftChunkData(0, 256, RegistryHelper.palettedContainerFactory()); + OldCraftChunkData data = new OldCraftChunkData(0, 256, RegistryHelper.context().palettedContainerFactory().get()); this.testSetRegion(data, -100, 0, -100, 0, 256, 0, ChunkDataTest.RED_WOOL); // exclusively outside this.testSetRegion(data, 16, 256, 16, 0, 0, 0, ChunkDataTest.RED_WOOL); // minimum >= maximum this.testSetRegion(data, 0, 0, 0, 0, 0, 0, ChunkDataTest.RED_WOOL); // minimum == maximum diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/CompositeSerializationTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/CompositeSerializationTest.java index 7faccf79b336..50ae0e76b4a7 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/CompositeSerializationTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/CompositeSerializationTest.java @@ -1,7 +1,5 @@ package org.bukkit.craftbukkit.inventory; -import static org.bukkit.support.MatcherAssert.*; -import static org.hamcrest.Matchers.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -12,10 +10,14 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.VanillaFeature; import org.junit.jupiter.api.Test; -@AllFeatures +import static org.bukkit.support.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; + +@VanillaFeature public class CompositeSerializationTest { public YamlConfiguration getConfig() { diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java index 1f7f0fe930f6..cd783d3de3e4 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java @@ -156,21 +156,6 @@ public void testCrazyEquality() { assertThat(bukkit, is(craft)); } - @Test - public void testSpawnEggsHasMeta() { - for (Item item : BuiltInRegistries.ITEM) { - if (item instanceof net.minecraft.world.item.SpawnEggItem) { - Material material = CraftItemType.minecraftToBukkit(item); - CraftMetaItem baseMeta = (CraftMetaItem) Bukkit.getItemFactory().getItemMeta(material); - ItemMeta baseMetaItem = CraftItemStack.getItemMeta(item.getDefaultInstance()); - - assertTrue(baseMeta instanceof CraftMetaSpawnEgg, material + " is not handled in CraftItemFactory"); - assertTrue(baseMeta.applicableTo(material), material + " is not applicable to CraftMetaSpawnEgg"); - assertTrue(baseMetaItem instanceof SpawnEggMeta, material + " is not handled in CraftItemStack"); - } - } - } - // Paper start - check entity tag metas private static final java.util.Set> ENTITY_TAG_METAS = java.util.Set.of( CraftMetaEntityTag.class, diff --git a/paper-server/src/test/java/org/bukkit/potion/PotionTest.java b/paper-server/src/test/java/org/bukkit/potion/PotionTest.java index de7295459fe9..5e0e55f11410 100644 --- a/paper-server/src/test/java/org/bukkit/potion/PotionTest.java +++ b/paper-server/src/test/java/org/bukkit/potion/PotionTest.java @@ -1,33 +1,26 @@ package org.bukkit.potion; -import static org.junit.jupiter.api.Assertions.*; -import java.util.EnumMap; -import java.util.List; -import java.util.Map; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.Identifier; -import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.item.alchemy.Potion; import org.bukkit.craftbukkit.legacy.FieldRename; import org.bukkit.craftbukkit.potion.CraftPotionEffectType; import org.bukkit.support.environment.AllFeatures; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + @AllFeatures public class PotionTest { @Test public void testEffectType() { - for (MobEffect nms : BuiltInRegistries.MOB_EFFECT) { - Identifier key = BuiltInRegistries.MOB_EFFECT.getKey(nms); - - PotionEffectType bukkit = CraftPotionEffectType.minecraftToBukkit(nms); + BuiltInRegistries.MOB_EFFECT.listElements().forEach(reference -> { + PotionEffectType bukkit = CraftPotionEffectType.minecraftHolderToBukkit(reference); - assertNotNull(bukkit, "No Bukkit type for " + key); + assertNotNull(bukkit, "No Bukkit type for " + reference.key()); PotionEffectType byName = FieldRename.getByName_PotionEffectType(bukkit.getName()); - assertEquals(bukkit, byName, "Same type not returned by name " + key); - } + assertEquals(bukkit, byName, "Same type not returned by name " + reference.key()); + }); } } diff --git a/paper-server/src/test/java/org/bukkit/registry/PerRegistryTest.java b/paper-server/src/test/java/org/bukkit/registry/PerRegistryTest.java index 0ce4001665b8..1a743ea97267 100644 --- a/paper-server/src/test/java/org/bukkit/registry/PerRegistryTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/PerRegistryTest.java @@ -1,6 +1,5 @@ package org.bukkit.registry; -import static org.junit.jupiter.api.Assertions.*; import com.google.common.collect.Lists; import java.lang.reflect.Field; import java.util.List; @@ -9,13 +8,15 @@ import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.Registry; -import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.support.environment.AllFeatures; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; + @AllFeatures public class PerRegistryTest { @@ -26,22 +27,18 @@ public static void init() { PerRegistryTest.random = new Random(); } - public static Stream data() { + public static Stream data() throws IllegalAccessException { List data = Lists.newArrayList(); Field[] registryFields = Registry.class.getFields(); for (Field registryField : registryFields) { - try { - Object object = registryField.get(null); - // Ignore Bukkit's default SimpleRegistry. It cannot be tested correctly - if (object instanceof Registry.NotARegistry) { - continue; - } - - data.add(Arguments.of(object)); - } catch (ReflectiveOperationException e) { - e.printStackTrace(); + Object object = registryField.get(null); + // Ignore Bukkit's default NotARegistry. It cannot be tested correctly + if (object instanceof Registry.NotARegistry) { + continue; } + + data.add(Arguments.of(object)); } return data.stream(); diff --git a/paper-server/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java b/paper-server/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java index 677697409dcf..25434c37724d 100644 --- a/paper-server/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java @@ -1,6 +1,5 @@ package org.bukkit.registry; -import static org.junit.jupiter.api.Assertions.*; import com.google.common.base.Joiner; import java.util.HashSet; import java.util.Set; @@ -8,7 +7,8 @@ import org.bukkit.support.environment.AllFeatures; import org.bukkit.support.provider.RegistriesArgumentProvider; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.provider.Arguments; + +import static org.junit.jupiter.api.Assertions.assertTrue; /** * This class tests, if all default registries present in {@link Registry} are added to {@link RegistriesArgumentProvider} @@ -29,12 +29,10 @@ public void testPresent() throws ClassNotFoundException { RegistriesArgumentProvider .getData() - .map(Arguments::get) - .map(array -> array[0]) - .map(clazz -> (io.papermc.paper.registry.RegistryKey) clazz) // Paper - .forEach(clazz -> { - if (!loadedRegistries.remove(clazz)) { - notFound.add(clazz); + .map(RegistriesArgumentProvider.RegistryArgument::apiRegistryKey) + .forEach(key -> { + if (!loadedRegistries.remove(key)) { + notFound.add(key); } }); diff --git a/paper-server/src/test/java/org/bukkit/registry/RegistryClassTest.java b/paper-server/src/test/java/org/bukkit/registry/RegistryClassTest.java index 279307c7afc3..04caee19bd69 100644 --- a/paper-server/src/test/java/org/bukkit/registry/RegistryClassTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/RegistryClassTest.java @@ -62,7 +62,7 @@ public class RegistryClassTest { private static final Map, Data> INIT_DATA = new HashMap<>(); private static final List FIELD_DATA_CACHE = new ArrayList<>(); - private static RegistryAccess.Frozen vanilla_registry; + private static RegistryAccess vanilla_registry; public static Stream fieldData() { return RegistryClassTest.FIELD_DATA_CACHE.stream(); @@ -81,14 +81,13 @@ public static void cleanUp() { } private static void initValueClasses() { - RegistryClassTest.vanilla_registry = RegistryHelper.createRegistry(FeatureFlags.VANILLA_SET); + RegistryClassTest.vanilla_registry = RegistryHelper.createRegistries(FeatureFlags.VANILLA_SET).access(); Map, List> outsideRequest = new LinkedHashMap<>(); // First init listening for outside requests RegistriesArgumentProvider.getData() - .map(Arguments::get).map(args -> args[0]) - .map(type -> (Class) type) + .map(RegistriesArgumentProvider.RegistryArgument::api) .forEach(type -> { Registry spyRegistry = Bukkit.getRegistry(type); spyOutsideRequests(outsideRequest, type, spyRegistry); @@ -96,9 +95,7 @@ private static void initValueClasses() { // Init all registries and recorde the outcome RegistriesArgumentProvider.getData() - .map(Arguments::get) - .map(args -> args[0]) - .map(type -> (Class) type) + .map(RegistriesArgumentProvider.RegistryArgument::api) .forEachOrdered(type -> { try { Registry spyRegistry = Bukkit.getRegistry(type); @@ -160,9 +157,7 @@ private static void initValueClasses() { // Cleanup RegistriesArgumentProvider.getData() - .map(Arguments::get) - .map(args -> args[0]) - .map(type -> (Class) type) + .map(RegistriesArgumentProvider.RegistryArgument::api) .forEach(type -> MockUtil.resetMock(Bukkit.getRegistry(type))); } @@ -181,8 +176,8 @@ private static void spyOutsideRequests(Map, List { - Class type = (Class) arguments.get()[0]; + RegistriesArgumentProvider.getData().map(args -> { + Class type = args.api(); Map>> annotations = RegistryClassTest.getFieldAnnotations(type); List fields = new ArrayList<>(); @@ -218,7 +213,7 @@ private static void initFieldDataCache() { fields.add(new FieldData(field, annotations.computeIfAbsent(field.getName(), k -> new ArrayList<>()))); } - return Arguments.arguments(arguments.get()[0], arguments.get()[1], fields); + return Arguments.arguments(args.api(), args.registryKey(), fields); }).forEach(FIELD_DATA_CACHE::add); } @@ -491,7 +486,7 @@ public void testMatchingFieldNames(Class type, ResourceKey< @ParameterizedTest @MethodSource("fieldData") public void testMissingConstants(Class type, ResourceKey> registryKey) throws IllegalAccessException { - net.minecraft.core.Registry registry = RegistryHelper.getRegistry().lookupOrThrow(registryKey); + net.minecraft.core.Registry registry = RegistryHelper.registryAccess().lookupOrThrow(registryKey); List missingKeys = new ArrayList<>(); for (Object nmsObject : registry) { diff --git a/paper-server/src/test/java/org/bukkit/registry/RegistryConstantsTest.java b/paper-server/src/test/java/org/bukkit/registry/RegistryConstantsTest.java index 886e52f7f680..2718c82e0b6b 100644 --- a/paper-server/src/test/java/org/bukkit/registry/RegistryConstantsTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/RegistryConstantsTest.java @@ -1,84 +1,96 @@ package org.bukkit.registry; -import static org.junit.jupiter.api.Assertions.*; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; +import java.util.Collection; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; import org.bukkit.Keyed; -import org.bukkit.NamespacedKey; -import org.bukkit.Registry; import org.bukkit.craftbukkit.util.CraftNamespacedKey; -import org.bukkit.damage.DamageType; -import org.bukkit.inventory.meta.trim.TrimMaterial; -import org.bukkit.inventory.meta.trim.TrimPattern; import org.bukkit.support.RegistryHelper; import org.bukkit.support.environment.AllFeatures; -import org.junit.jupiter.api.Test; +import org.bukkit.support.provider.RegistriesArgumentProvider; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; @AllFeatures public class RegistryConstantsTest { - @Test - public void testDamageType() { - this.testExcessConstants(DamageType.class, Registry.DAMAGE_TYPE); - this.testMissingConstants(DamageType.class, Registries.DAMAGE_TYPE); // Paper - re-enable this one - } + private static final Multimap>, Identifier> IGNORED_KEYS = HashMultimap.create(); - @Test - public void testTrimMaterial() { - this.testExcessConstants(TrimMaterial.class, org.bukkit.Registry.TRIM_MATERIAL); // Paper - remap fix - this.testMissingConstants(TrimMaterial.class, Registries.TRIM_MATERIAL); + private static void ignore(ResourceKey> registryKey, Set elements) { + Registry registry = RegistryHelper.registryAccess().lookupOrThrow(registryKey); + IGNORED_KEYS.putAll(registryKey, elements.stream().map(registry::getKey).toList()); } - @Test - public void testTrimPattern() { - this.testExcessConstants(TrimPattern.class, org.bukkit.Registry.TRIM_PATTERN); // Paper - remap fix - this.testMissingConstants(TrimPattern.class, Registries.TRIM_PATTERN); + private static void ignoreKeys(ResourceKey> registryKey, Set> keys) { + IGNORED_KEYS.putAll(registryKey, keys.stream().map(ResourceKey::identifier).toList()); } - private void testExcessConstants(Class clazz, org.bukkit.Registry registry) { // Paper - remap fix - List excessKeys = new ArrayList<>(); - - for (Field field : clazz.getFields()) { - if (field.getType() != clazz || !Modifier.isStatic(field.getModifiers())) { - continue; - } - - String name = field.getName(); - NamespacedKey key = NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)); - if (registry.get(key) == null) { - excessKeys.add(key); - } + private static void ignoreReferences(ResourceKey> registryKey, Set> references) { + IGNORED_KEYS.putAll(registryKey, references.stream().map(holder -> holder.key().identifier()).toList()); + } - } + @BeforeAll + public static void populateIgnored() { + ignore(Registries.DATA_COMPONENT_TYPE, Set.of( + DataComponents.CUSTOM_DATA, + DataComponents.ENTITY_DATA, + DataComponents.BEES, + DataComponents.DEBUG_STICK_STATE, + DataComponents.BLOCK_ENTITY_DATA, + DataComponents.BUCKET_ENTITY_DATA, + DataComponents.LOCK, + DataComponents.CREATIVE_SLOT_LOCK + )); + } - assertTrue(excessKeys.isEmpty(), excessKeys.size() + " excess constants(s) in " + clazz.getSimpleName() + " that do not exist: " + excessKeys); + public static Stream registries() { + return RegistriesArgumentProvider.getData() + .map(args -> Arguments.of(args.api(), args.apiHolder(), args.registryKey())); } - private void testMissingConstants(Class clazz, ResourceKey> nmsRegistryKey) { - List missingKeys = new ArrayList<>(); + @MethodSource("registries") + @ParameterizedTest + public void testConstants(Class api, Class apiHolder, ResourceKey> registryKey) throws IllegalAccessException { + final Set keys = new ObjectOpenHashSet<>( + RegistryHelper.registryAccess().lookupOrThrow(registryKey).keySet() + ); - net.minecraft.core.Registry nmsRegistry = RegistryHelper.getRegistry().lookupOrThrow(nmsRegistryKey); - for (M nmsObject : nmsRegistry) { - Identifier minecraftKey = nmsRegistry.getKey(nmsObject); + for (final Field field : apiHolder.getDeclaredFields()) { + if (!api.isAssignableFrom(field.getType())) continue; + if (field.isAnnotationPresent(Deprecated.class)) continue; - try { - @SuppressWarnings("unchecked") - T bukkitObject = (T) clazz.getField(minecraftKey.getPath().toUpperCase(Locale.ROOT)).get(null); + final B element = api.cast(field.get(null)); + if (!keys.remove(CraftNamespacedKey.toMinecraft(element.getKey()))) { + fail("Constant " + apiHolder.getSimpleName() + " / " + field.getName() + " is unknown to vanilla registry"); + } + } - assertEquals(minecraftKey, CraftNamespacedKey.toMinecraft(bukkitObject.getKey()), "Keys are not the same for " + minecraftKey); - } catch (NoSuchFieldException e) { - missingKeys.add(minecraftKey); - } catch (Exception e) { - fail(e.getMessage()); + final Collection ignoredKeys = IGNORED_KEYS.get(registryKey); + if (!ignoredKeys.isEmpty()) { + if (!keys.containsAll(ignoredKeys)) { + Set extraKeys = ignoredKeys.stream().filter(Predicate.not(keys::contains)).collect(Collectors.toCollection(ObjectOpenHashSet::new)); + fail("Constants that should be ignored in " + apiHolder.getSimpleName() + ": " + extraKeys); } + keys.removeAll(ignoredKeys); } - assertTrue(missingKeys.isEmpty(), "Missing (" + missingKeys.size() + ") constants in " + clazz.getSimpleName() + ": " + missingKeys); + assertTrue(keys.isEmpty(), "Missing (" + keys.size() + ") constants in " + apiHolder.getSimpleName() + ": " + keys); } } diff --git a/paper-server/src/test/java/org/bukkit/registry/RegistryConversionTest.java b/paper-server/src/test/java/org/bukkit/registry/RegistryConversionTest.java index 87396938f890..d242e9fbfab2 100644 --- a/paper-server/src/test/java/org/bukkit/registry/RegistryConversionTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/RegistryConversionTest.java @@ -3,9 +3,7 @@ import com.google.common.base.Joiner; import io.papermc.paper.registry.RegistryAccess; import io.papermc.paper.registry.RegistryKey; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; +import io.papermc.paper.util.Holderable; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -14,17 +12,15 @@ import net.minecraft.resources.ResourceKey; import org.bukkit.Keyed; import org.bukkit.Registry; -import org.bukkit.craftbukkit.util.Handleable; +import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.support.environment.AllFeatures; import org.bukkit.support.test.RegistriesTest; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.params.provider.Arguments; -import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assumptions.assumeFalse; import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.mockito.Mockito.mock; @@ -33,293 +29,99 @@ @TestMethodOrder(MethodOrderer.OrderAnnotation.class) public class RegistryConversionTest { - private static final String MINECRAFT_TO_BUKKIT = "minecraftToBukkit"; - private static final String BUKKIT_TO_MINECRAFT = "bukkitToMinecraft"; + private static final Set> IMPLEMENT_HOLDERABLE = new HashSet<>(); - private static final String MINECRAFT_TO_BUKKIT_NEW = "minecraftToBukkitNew"; - private static final String BUKKIT_TO_MINECRAFT_NEW = "bukkitToMinecraftNew"; - - private static final Map, Method> MINECRAFT_TO_BUKKIT_METHODS = new HashMap<>(); - private static final Map, Method> BUKKIT_TO_MINECRAFT_METHODS = new HashMap<>(); - - private static final Set> IMPLEMENT_HANDLE_ABLE = new HashSet<>(); - - public static Stream getValues(RegistryKey registryType) { // Paper - Registry registry = RegistryAccess.registryAccess().getRegistry(registryType); // Paper - return registry.stream().map(keyed -> (Handleable) keyed) - .map(handleAble -> Arguments.of(handleAble, handleAble.getHandle())); + public static Stream> getValues(RegistryKey registryKey) { + Registry registry = RegistryAccess.registryAccess().getRegistry(registryKey); + return registry.stream().map(keyed -> (Holderable) keyed); } @Order(1) @RegistriesTest - public void testHandleableImplementation(io.papermc.paper.registry.RegistryKey type, Class clazz) { // Paper + public void testHolderableImplementation(RegistryKey apiRegistryKey, Class clazz) { Set> notImplemented = new HashSet<>(); - Registry registry = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(type); // Paper + Registry registry = RegistryAccess.registryAccess().getRegistry(apiRegistryKey); for (Keyed item : registry) { - if (!(item instanceof Handleable)) { + if (!(item instanceof Holderable)) { notImplemented.add(item.getClass()); } } assertTrue(notImplemented.isEmpty(), String.format(""" - Not all implementations of the registry from the class %s have the Handleable interface implemented. - Every Implementation should implement the Handleable interface. - - The following implementation do not implement Handleable: - %s""", clazz.getName(), Joiner.on('\n').join(notImplemented))); - - RegistryConversionTest.IMPLEMENT_HANDLE_ABLE.add(clazz); + Not all implementations of the registry from the class %s have the Holderable interface implemented. + Every Implementation should implement the Holderable interface. + + The following implementation do not implement Holderable: + %s""", clazz.getName(), Joiner.on('\n').join(notImplemented))); + RegistryConversionTest.IMPLEMENT_HOLDERABLE.add(clazz); } @Order(2) @RegistriesTest - public void testMinecraftToBukkitPresent(io.papermc.paper.registry.RegistryKey type, Class clazz, ResourceKey> registryKey, - Class craftClazz, Class minecraftClazz, boolean newMethod) { - String methodName = (newMethod) ? RegistryConversionTest.MINECRAFT_TO_BUKKIT_NEW : RegistryConversionTest.MINECRAFT_TO_BUKKIT; - Method method = null; - try { - method = craftClazz.getDeclaredMethod(methodName, minecraftClazz); - } catch (NoSuchMethodException e) { - fail(String.format(""" - The class %s does not have a public static method to convert a minecraft value to a bukkit value. - - Following method should be add which, returns the bukkit value based on the minecraft value. - %s - """, craftClazz, this.buildMinecraftToBukkitMethod(clazz, methodName, minecraftClazz))); - } - - assertTrue(Modifier.isPublic(method.getModifiers()), String.format(""" - The method %s in class %s is not public. - - The method should be made public, method structure: - %s - """, methodName, craftClazz, this.buildMinecraftToBukkitMethod(clazz, methodName, minecraftClazz))); - - assertTrue(Modifier.isStatic(method.getModifiers()), String.format(""" - The method %s in class %s is not static. - - The method should be made static, method structure: - %s - """, methodName, craftClazz, this.buildMinecraftToBukkitMethod(clazz, methodName, minecraftClazz))); - - assertSame(clazz, method.getReturnType(), String.format(""" - The method %s in class %s has the wrong return value. - - The method should have the correct return value, method structure: - %s - """, methodName, craftClazz, this.buildMinecraftToBukkitMethod(clazz, methodName, minecraftClazz))); - - RegistryConversionTest.MINECRAFT_TO_BUKKIT_METHODS.put(clazz, method); - } - - private String buildMinecraftToBukkitMethod(Class clazz, String methodName, Class minecraftClazz) { - return String.format(""" - public static %s %s(%s minecraft) { - [...] - } - """, clazz.getSimpleName(), methodName, minecraftClazz.getName()); - } - - @Order(2) - @RegistriesTest - public void testBukkitToMinecraftPresent(io.papermc.paper.registry.RegistryKey type, Class clazz, ResourceKey> registryKey, - Class craftClazz, Class minecraftClazz, boolean newMethod) { - String methodName = (newMethod) ? RegistryConversionTest.BUKKIT_TO_MINECRAFT_NEW : RegistryConversionTest.BUKKIT_TO_MINECRAFT; - Method method = null; - try { - method = craftClazz.getDeclaredMethod(methodName, clazz); - } catch (NoSuchMethodException e) { - fail(String.format(""" - The class %s does not have a public static method to convert a bukkit value to a minecraft value. - - Following method should be add which, returns the minecraft value based on the bukkit value. - %s - """, craftClazz, this.buildBukkitToMinecraftMethod(clazz, methodName, minecraftClazz))); - } - - assertTrue(Modifier.isPublic(method.getModifiers()), String.format(""" - The method %s in class %s is not public. - - The method should be made public, method structure: - %s - """, methodName, craftClazz, this.buildBukkitToMinecraftMethod(clazz, methodName, minecraftClazz))); - - assertTrue(Modifier.isStatic(method.getModifiers()), String.format(""" - The method %s in class %s is not static. - - The method should be made static, method structure: - %s - """, methodName, craftClazz, this.buildBukkitToMinecraftMethod(clazz, methodName, minecraftClazz))); - - assertSame(minecraftClazz, method.getReturnType(), String.format(""" - The method %s in class %s has the wrong return value. - - The method should have the correct return value, method structure: - %s - """, methodName, craftClazz, this.buildBukkitToMinecraftMethod(clazz, methodName, minecraftClazz))); - - RegistryConversionTest.BUKKIT_TO_MINECRAFT_METHODS.put(clazz, method); - } - - private String buildBukkitToMinecraftMethod(Class clazz, String methodName, Class minecraftClazz) { - return String.format(""" - public static %s %s(%s bukkit) { - [...] - } - """, minecraftClazz.getName(), methodName, clazz.getSimpleName()); - } - - @Order(3) - @RegistriesTest - public void testMinecraftToBukkitNullValue(io.papermc.paper.registry.RegistryKey type, Class clazz) throws IllegalAccessException { // Paper - this.checkValidMinecraftToBukkit(clazz); - - try { - Object result = RegistryConversionTest.MINECRAFT_TO_BUKKIT_METHODS.get(clazz).invoke(null, (Object) null); - fail(String.format(""" - Method %s in class %s should not accept null values and should throw a IllegalArgumentException. - Got '%s' as return object. - """, RegistryConversionTest.MINECRAFT_TO_BUKKIT, clazz.getName(), result)); - } catch (InvocationTargetException e) { - // #invoke wraps the error in a InvocationTargetException, so we need to check it this way - assertSame(IllegalArgumentException.class, e.getCause().getClass(), String.format(""" - Method %s in class %s should not accept null values and should throw a IllegalArgumentException. - """, RegistryConversionTest.MINECRAFT_TO_BUKKIT, clazz.getName())); - } - } - - @Order(3) - @RegistriesTest - public void testBukkitToMinecraftNullValue(io.papermc.paper.registry.RegistryKey type, Class clazz) throws IllegalAccessException { // Paper - this.checkValidBukkitToMinecraft(clazz); - - try { - Object result = RegistryConversionTest.BUKKIT_TO_MINECRAFT_METHODS.get(clazz).invoke(null, (Object) null); - fail(String.format(""" - Method %s in class %s should not accept null values and should throw a IllegalArgumentException. - Got '%s' as return object. - """, RegistryConversionTest.BUKKIT_TO_MINECRAFT, clazz.getName(), result)); - } catch (InvocationTargetException e) { - // #invoke wraps the error in a InvocationTargetException, so we need to check it this way - assertSame(IllegalArgumentException.class, e.getCause().getClass(), String.format(""" - Method %s in class %s should not accept null values and should throw a IllegalArgumentException. - """, RegistryConversionTest.BUKKIT_TO_MINECRAFT, clazz.getName())); - } - } - - @Order(3) - @RegistriesTest - public void testMinecraftToBukkit(io.papermc.paper.registry.RegistryKey type, Class clazz) { // Paper - this.checkValidMinecraftToBukkit(clazz); + public void testMinecraftHolderToBukkit(RegistryKey apiRegistryKey, Class clazz, ResourceKey> registryKey) { this.checkValidHandle(clazz); Map notMatching = new HashMap<>(); - Method method = RegistryConversionTest.MINECRAFT_TO_BUKKIT_METHODS.get(clazz); - - getValues(type).map(Arguments::get).forEach(arguments -> { // Paper - Keyed bukkit = (Keyed) arguments[0]; - Object minecraft = arguments[1]; - - try { - Object otherBukkit = method.invoke(null, minecraft); - if (bukkit != otherBukkit) { - notMatching.put(bukkit, otherBukkit); - } - } catch (IllegalAccessException | InvocationTargetException e) { - throw new RuntimeException(e); + getValues(apiRegistryKey).forEach(bukkit -> { + Object otherBukkit = CraftRegistry.minecraftHolderToBukkit(bukkit.getHolder(), (ResourceKey) registryKey); + if (bukkit != otherBukkit) { + notMatching.put(bukkit, otherBukkit); } }); assertTrue(notMatching.isEmpty(), String.format(""" - The method %s in class %s does not match all registry items correctly. - - Following registry items where match not correctly: - %s""", RegistryConversionTest.MINECRAFT_TO_BUKKIT, clazz.getName(), - Joiner.on('\n').withKeyValueSeparator(" got: ").join(notMatching))); + The conversion method does not match all registry items correctly. + + Following registry items where match not correctly: + %s""", + Joiner.on('\n').withKeyValueSeparator(" got: ").join(notMatching))); } - @Order(3) + @Order(2) @RegistriesTest - public void testBukkitToMinecraft(io.papermc.paper.registry.RegistryKey type, Class clazz) { // Paper - this.checkValidBukkitToMinecraft(clazz); + public void testBukkitToMinecraftHolder(RegistryKey apiRegistryKey, Class clazz) { this.checkValidHandle(clazz); Map notMatching = new HashMap<>(); - Method method = RegistryConversionTest.BUKKIT_TO_MINECRAFT_METHODS.get(clazz); - - getValues(type).map(Arguments::get).forEach(arguments -> { // Paper - Keyed bukkit = (Keyed) arguments[0]; - Object minecraft = arguments[1]; - try { - Object otherMinecraft = method.invoke(null, bukkit); - if (minecraft != otherMinecraft) { - notMatching.put(minecraft, otherMinecraft); - } - } catch (IllegalAccessException | InvocationTargetException e) { - throw new RuntimeException(e); + getValues(apiRegistryKey).forEach(bukkit -> { + Object minecraft = bukkit.getHolder(); + Object otherMinecraft = CraftRegistry.bukkitToMinecraftHolder((Keyed) bukkit); + if (minecraft != otherMinecraft) { + notMatching.put(minecraft, otherMinecraft); } }); assertTrue(notMatching.isEmpty(), String.format(""" - The method %s in class %s does not match all registry items correctly. - - Following registry items where match not correctly: - %s""", RegistryConversionTest.BUKKIT_TO_MINECRAFT, clazz.getName(), - Joiner.on('\n').withKeyValueSeparator(" got: ").join(notMatching))); + The conversion method does not match all registry items correctly. + + Following registry items where match not correctly: + %s""", Joiner.on('\n').withKeyValueSeparator(" got: ").join(notMatching))); } - static final Set> IGNORE_FOR_DIRECT_HOLDER = Set.of(RegistryKey.TRIM_MATERIAL, RegistryKey.TRIM_PATTERN, RegistryKey.INSTRUMENT, RegistryKey.BANNER_PATTERN, RegistryKey.SOUND_EVENT, RegistryKey.DIALOG); // Paper - /** * Minecraft registry can return a default key / value * when the passed minecraft value is not registry in this case, we want it to throw an error. */ - @Order(3) + @Order(2) @RegistriesTest - public void testMinecraftToBukkitNoValidMinecraft(io.papermc.paper.registry.RegistryKey type, Class clazz, ResourceKey> registryKey, // Paper - Class craftClazz, Class minecraftClazz) throws IllegalAccessException { - this.checkValidMinecraftToBukkit(clazz); - - assumeFalse(IGNORE_FOR_DIRECT_HOLDER.contains(type), "skipped because these types support direct holders"); // Paper - manually skip for now - try { - - Object minecraft = mock(minecraftClazz); - Object result = RegistryConversionTest.MINECRAFT_TO_BUKKIT_METHODS.get(clazz).invoke(null, minecraft); - fail(String.format(""" - Method %s in class %s should not accept a none registered value and should throw a IllegalStateException. - Got '%s' as return object. - """, RegistryConversionTest.MINECRAFT_TO_BUKKIT, clazz.getName(), result)); - } catch (InvocationTargetException e) { - // #invoke wraps the error in a InvocationTargetException, so we need to check it this way - assertSame(IllegalStateException.class, e.getCause().getClass(), String.format(""" - Method %s in class %s should not accept a none registered value and should throw a IllegalStateException. - """, RegistryConversionTest.MINECRAFT_TO_BUKKIT, clazz.getName())); - } - } - - private void checkValidBukkitToMinecraft(Class clazz) { - assumeTrue(RegistryConversionTest.BUKKIT_TO_MINECRAFT_METHODS.containsKey(clazz), String.format(""" - Cannot test class %s, because it does not have a valid %s method. - - Check test results of testBukkitToMinecraftPresent for more information. - """, clazz.getName(), RegistryConversionTest.BUKKIT_TO_MINECRAFT)); - } - - private void checkValidMinecraftToBukkit(Class clazz) { - assumeTrue(RegistryConversionTest.MINECRAFT_TO_BUKKIT_METHODS.containsKey(clazz), String.format(""" - Cannot test class %s, because it does not have a valid %s method. - - Check test results of testMinecraftToBukkitPresent for more information. - """, clazz.getName(), RegistryConversionTest.MINECRAFT_TO_BUKKIT)); + public void testMinecraftToBukkitNoValidMinecraft( + RegistryKey apiRegistryKey, Class clazz, ResourceKey> registryKey, + Class craftClazz, Class minecraftClazz + ) { + final Registry bukkitRegistry = RegistryAccess.registryAccess().getRegistry(apiRegistryKey); + assumeFalse(((CraftRegistry) bukkitRegistry).supportsDirectHolders(), "skipped because these types support direct holders"); + Object minecraft = mock(minecraftClazz); + assertThrows(IllegalStateException.class, () -> CraftRegistry.minecraftToBukkit(minecraft, (ResourceKey) registryKey), + "Conversion method should not accept a none registered value and should throw a IllegalStateException."); } private void checkValidHandle(Class clazz) { - assumeTrue(RegistryConversionTest.IMPLEMENT_HANDLE_ABLE.contains(clazz), String.format(""" - Cannot test class %s, because it does not implement Handleable. - - Check test results of testHandleableImplementation for more information. - """, clazz.getName())); + assumeTrue(RegistryConversionTest.IMPLEMENT_HOLDERABLE.contains(clazz), String.format(""" + Cannot test class %s, because it does not implement Holderable. + + Check test results of testHolderableImplementation for more information. + """, clazz.getName())); } } diff --git a/paper-server/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java b/paper-server/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java index cffef2022a2a..f14573e66c86 100644 --- a/paper-server/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java @@ -29,20 +29,20 @@ public class RegistryLoadOrderTest { public static Stream data() { return Stream.of( - Arguments.of( - (Supplier) () -> RegistryLoadOrderTest.initInterface, - BukkitInterfaceTestType.class, - (BiFunction) CraftBukkitInterfaceTestType::new, - (Supplier) () -> BukkitInterfaceTestType.TEST_ONE, - (Supplier) () -> BukkitInterfaceTestType.TEST_TWO - ), - Arguments.of( - (Supplier) () -> RegistryLoadOrderTest.initAbstract, - BukkitAbstractTestType.class, - (BiFunction) CraftBukkitAbstractTestType::new, - (Supplier) () -> BukkitAbstractTestType.TEST_ONE, - (Supplier) () -> BukkitAbstractTestType.TEST_TWO - ) + Arguments.of( + (Supplier) () -> RegistryLoadOrderTest.initInterface, + BukkitInterfaceTestType.class, + (BiFunction) CraftBukkitInterfaceTestType::new, + (Supplier) () -> BukkitInterfaceTestType.TEST_ONE, + (Supplier) () -> BukkitInterfaceTestType.TEST_TWO + ), + Arguments.of( + (Supplier) () -> RegistryLoadOrderTest.initAbstract, + BukkitAbstractTestType.class, + (BiFunction) CraftBukkitAbstractTestType::new, + (Supplier) () -> BukkitAbstractTestType.TEST_ONE, + (Supplier) () -> BukkitAbstractTestType.TEST_TWO + ) ); } @@ -51,11 +51,11 @@ public static Stream data() { public void testRegistryLoadOrder(Supplier init, Class keyedClass, BiFunction minecraftToBukkit, Supplier first, Supplier second) { this.testClassNotLoaded(init.get()); - ResourceKey> resourceKey = ResourceKey.createRegistryKey(Identifier.tryBuild("bukkit", "test-registry")); + ResourceKey> resourceKey = ResourceKey.createRegistryKey(Identifier.fromNamespaceAndPath("bukkit", "test-registry")); MappedRegistry minecraftRegistry = new MappedRegistry<>(resourceKey, Lifecycle.experimental()); - minecraftRegistry.register(ResourceKey.create(resourceKey, Identifier.tryBuild("bukkit", "test-one")), new MinecraftTestType(), new RegistrationInfo(Optional.empty(), Lifecycle.experimental())); - minecraftRegistry.register(ResourceKey.create(resourceKey, Identifier.tryBuild("bukkit", "test-two")), new MinecraftTestType(), new RegistrationInfo(Optional.empty(), Lifecycle.experimental())); + minecraftRegistry.register(ResourceKey.create(resourceKey, Identifier.fromNamespaceAndPath("bukkit", "test-one")), new MinecraftTestType(), new RegistrationInfo(Optional.empty(), Lifecycle.experimental())); + minecraftRegistry.register(ResourceKey.create(resourceKey, Identifier.fromNamespaceAndPath("bukkit", "test-two")), new MinecraftTestType(), new RegistrationInfo(Optional.empty(), Lifecycle.experimental())); minecraftRegistry.freeze(); RegistryLoadOrderTest.registry = new CraftRegistry<>(keyedClass, minecraftRegistry, minecraftToBukkit, (namespacedKey, apiVersion) -> namespacedKey); @@ -82,10 +82,10 @@ public void testRegistryLoadOrder(Supplier init, Class keyedClas private void testClassNotLoaded(boolean init) { assertFalse(init, """ - TestType class is already loaded, this test however tests the behavior when the class is not loaded. - This should normally not happen with how classes should be loaded. - Something has changed how classes are loaded and a more manual deeper look is required. - """); + TestType class is already loaded, this test however tests the behavior when the class is not loaded. + This should normally not happen with how classes should be loaded. + Something has changed how classes are loaded and a more manual deeper look is required. + """); } public interface BukkitInterfaceTestType extends Keyed { diff --git a/paper-server/src/test/java/org/bukkit/support/DummyServerHelper.java b/paper-server/src/test/java/org/bukkit/support/DummyServerHelper.java index ea10b443dfa1..c6e49a553c30 100644 --- a/paper-server/src/test/java/org/bukkit/support/DummyServerHelper.java +++ b/paper-server/src/test/java/org/bukkit/support/DummyServerHelper.java @@ -43,7 +43,7 @@ public static Server setup() { when(instance.createBlockData(any(Material.class))).then(mock -> CraftBlockData.newData(((Material) mock.getArgument(0)).asBlockType(), null)); when(instance.getLootTable(any())).then(mock -> new CraftLootTable(mock.getArgument(0), - RegistryHelper.getDataPack().fullRegistries().getLootTable(ResourceKey.create(Registries.LOOT_TABLE, CraftNamespacedKey.toMinecraft(mock.getArgument(0)))))); + RegistryHelper.context().datapack().fullRegistries().getLootTable(ResourceKey.create(Registries.LOOT_TABLE, CraftNamespacedKey.toMinecraft(mock.getArgument(0)))))); when(instance.getTag(any(), any(), any())).then(mock -> { String registry = mock.getArgument(0); @@ -99,12 +99,12 @@ public static Server setup() { when(instance.getPluginManager()).thenReturn(pluginManager); // Paper end - testing additions - io.papermc.paper.configuration.GlobalConfigTestingBase.setupGlobalConfigForTest(RegistryHelper.getRegistry()); // Paper - configuration files - setup global configuration test base + io.papermc.paper.configuration.GlobalConfigTestingBase.setupGlobalConfigForTest(RegistryHelper.registryAccess()); // Paper - configuration files - setup global configuration test base // Paper start - add test for recipe conversion when(instance.recipeIterator()).thenAnswer(ignored -> com.google.common.collect.Iterators.transform( - RegistryHelper.getDataPack().getRecipeManager().recipes.byType.entries().iterator(), + RegistryHelper.context().datapack().getRecipeManager().recipes.byType.entries().iterator(), input -> input.getValue().toBukkitRecipe() ) ); diff --git a/paper-server/src/test/java/org/bukkit/support/RegistryHelper.java b/paper-server/src/test/java/org/bukkit/support/RegistryHelper.java index 0fb62211dbae..8bf9b94d0bb6 100644 --- a/paper-server/src/test/java/org/bukkit/support/RegistryHelper.java +++ b/paper-server/src/test/java/org/bukkit/support/RegistryHelper.java @@ -1,143 +1,144 @@ package org.bukkit.support; -import com.google.common.util.concurrent.MoreExecutors; import java.util.List; import java.util.Locale; +import java.util.function.Supplier; +import java.util.regex.Pattern; +import java.util.stream.Stream; import net.minecraft.SharedConstants; import net.minecraft.commands.Commands; import net.minecraft.core.HolderLookup; import net.minecraft.core.LayeredRegistryAccess; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; -import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; import net.minecraft.resources.RegistryDataLoader; import net.minecraft.server.Bootstrap; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.RegistryLayer; import net.minecraft.server.ReloadableServerResources; import net.minecraft.server.packs.PackType; -import net.minecraft.server.packs.repository.Pack; import net.minecraft.server.packs.repository.PackRepository; import net.minecraft.server.packs.repository.ServerPacksSource; import net.minecraft.server.packs.resources.MultiPackResourceManager; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.permissions.LevelBasedPermissionSet; import net.minecraft.tags.TagLoader; +import net.minecraft.util.Util; import net.minecraft.world.flag.FeatureFlagSet; -import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.flag.FeatureFlags; +import net.minecraft.world.level.DataPackConfig; +import net.minecraft.world.level.WorldDataConfiguration; import net.minecraft.world.level.chunk.PalettedContainerFactory; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; public final class RegistryHelper { - private static ReloadableServerResources dataPack; - private static RegistryAccess.Frozen registry; - private static Registry biomes; - private static PalettedContainerFactory palettedContainerFactory; + private static SetupContext setupContext; private RegistryHelper() { } - public static ReloadableServerResources getDataPack() { - if (RegistryHelper.dataPack == null) { - RegistryHelper.throwError("dataPack"); - } - return RegistryHelper.dataPack; + public static RegistryAccess registryAccess() { + return context().registries(); } - public static RegistryAccess.Frozen getRegistry() { - if (RegistryHelper.registry == null) { - RegistryHelper.throwError("registry"); + public static SetupContext context() { + if (setupContext == null) { + throw new IllegalStateException(""" + Trying to access shared context while it is not setup. + Make sure that either the class or method you test has the right test environment annotation present. + You can find them in the package src/test/java/org.bukkit.support.environment"""); } - return RegistryHelper.registry; + return setupContext; } - public static Registry getBiomes() { - if (RegistryHelper.biomes == null) { - RegistryHelper.throwError("biomes"); - } - return RegistryHelper.biomes; + public record SetupContext( + ReloadableServerResources datapack, + RegistryAccess registries, + Supplier palettedContainerFactory + ) { } - public static PalettedContainerFactory palettedContainerFactory() { - if (RegistryHelper.palettedContainerFactory == null) { - RegistryHelper.throwError("palettedContainerFactory"); + public record PackedRegistries(LayeredRegistryAccess layers, List> pendingTags) { + + public RegistryAccess access() { + return this.layers.compositeAccess().freeze(); } - return RegistryHelper.palettedContainerFactory; } - public static RegistryAccess.Frozen createRegistry(FeatureFlagSet featureFlagSet) { - MultiPackResourceManager ireloadableresourcemanager = RegistryHelper.createResourceManager(featureFlagSet); + public static PackedRegistries createRegistries(FeatureFlagSet enabledFeatures) { + return createRegistries(RegistryHelper.createResourceManager(enabledFeatures)); + } + + public static PackedRegistries createRegistries(ResourceManager resourceManager) { // add tags and loot tables for unit tests - LayeredRegistryAccess layeredregistryaccess = RegistryLayer.createRegistryAccess(); - List> list = TagLoader.loadTagsForExistingRegistries(ireloadableresourcemanager, layeredregistryaccess.getLayer(RegistryLayer.STATIC)); - RegistryAccess.Frozen iregistrycustom_dimension = layeredregistryaccess.getAccessForLoading(RegistryLayer.WORLDGEN); - List> list1 = TagLoader.buildUpdatedLookups(iregistrycustom_dimension, list); - RegistryAccess.Frozen iregistrycustom_dimension1 = RegistryDataLoader.load((ResourceManager) ireloadableresourcemanager, list1, RegistryDataLoader.WORLDGEN_REGISTRIES); - LayeredRegistryAccess layers = layeredregistryaccess.replaceFrom(RegistryLayer.WORLDGEN, iregistrycustom_dimension1); - // Paper start - load registry here to ensure bukkit object registry are correctly delayed if needed + LayeredRegistryAccess layers = RegistryLayer.createRegistryAccess(); + List> pendingTags = TagLoader.loadTagsForExistingRegistries(resourceManager, layers.getLayer(RegistryLayer.STATIC)); + + List> lookupsWithPendingTags = TagLoader.buildUpdatedLookups(layers.getAccessForLoading(RegistryLayer.WORLDGEN), pendingTags); + RegistryAccess.Frozen worldGenRegistries = RegistryDataLoader.load(resourceManager, lookupsWithPendingTags, RegistryDataLoader.WORLDGEN_REGISTRIES); + layers = layers.replaceFrom(RegistryLayer.WORLDGEN, worldGenRegistries); + + List> staticAndWorldgenLookups = Stream.concat(lookupsWithPendingTags.stream(), worldGenRegistries.listRegistries()).toList(); + RegistryAccess.Frozen dimensionRegistries = RegistryDataLoader.load(resourceManager, staticAndWorldgenLookups, RegistryDataLoader.DIMENSION_REGISTRIES); + layers = layers.replaceFrom(RegistryLayer.DIMENSIONS, dimensionRegistries); + // load registry here to ensure bukkit object registry are correctly delayed if needed try { - Class.forName("org.bukkit.Registry"); - } catch (final ClassNotFoundException ignored) {} - // Paper end - load registry here to ensure bukkit object registry are correctly delayed if needed + Class.forName(org.bukkit.Registry.class.getName()); + } catch (final ClassNotFoundException ignored) { + } - return layers.compositeAccess().freeze(); + return new PackedRegistries(layers, pendingTags); } - public static void setup(FeatureFlagSet featureFlagSet) { + public static void setup(FeatureFlagSet enabledFeatures) { SharedConstants.tryDetectVersion(); Bootstrap.bootStrap(); + Bootstrap.validate(); - MultiPackResourceManager ireloadableresourcemanager = RegistryHelper.createResourceManager(featureFlagSet); - // add tags and loot tables for unit tests - LayeredRegistryAccess layeredregistryaccess = RegistryLayer.createRegistryAccess(); - List> list = TagLoader.loadTagsForExistingRegistries(ireloadableresourcemanager, layeredregistryaccess.getLayer(RegistryLayer.STATIC)); - RegistryAccess.Frozen iregistrycustom_dimension = layeredregistryaccess.getAccessForLoading(RegistryLayer.WORLDGEN); - List> list1 = TagLoader.buildUpdatedLookups(iregistrycustom_dimension, list); - RegistryAccess.Frozen iregistrycustom_dimension1 = RegistryDataLoader.load((ResourceManager) ireloadableresourcemanager, list1, RegistryDataLoader.WORLDGEN_REGISTRIES); - LayeredRegistryAccess layers = layeredregistryaccess.replaceFrom(RegistryLayer.WORLDGEN, iregistrycustom_dimension1); - // Paper start - load registry here to ensure bukkit object registry are correctly delayed if needed - try { - Class.forName("org.bukkit.Registry"); - } catch (final ClassNotFoundException ignored) {} - // Paper end - load registry here to ensure bukkit object registry are correctly delayed if needed - RegistryHelper.registry = layers.compositeAccess().freeze(); - // Register vanilla pack - RegistryHelper.dataPack = ReloadableServerResources.loadResources(ireloadableresourcemanager, layers, list, featureFlagSet, Commands.CommandSelection.DEDICATED, LevelBasedPermissionSet.ALL_PERMISSIONS, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join(); + ResourceManager resourceManager = RegistryHelper.createResourceManager(enabledFeatures); + PackedRegistries registries = createRegistries(resourceManager); + + // Register vanilla packs + ReloadableServerResources datapack = ReloadableServerResources.loadResources(resourceManager, registries.layers(), registries.pendingTags(), enabledFeatures, Commands.CommandSelection.DEDICATED, LevelBasedPermissionSet.ALL_PERMISSIONS, Util.backgroundExecutor(), Runnable::run).join(); // Bind tags - RegistryHelper.dataPack.updateStaticRegistryTags(); - // Biome shortcut - RegistryHelper.biomes = RegistryHelper.registry.lookupOrThrow(Registries.BIOME); - // PalettedContainerFactory shortcut - RegistryHelper.palettedContainerFactory = PalettedContainerFactory.create(RegistryHelper.registry); + datapack.updateStaticRegistryTags(); + + RegistryAccess registryAccess = registries.access(); + setupContext = new SetupContext( + datapack, + registryAccess, + () -> PalettedContainerFactory.create(registryAccess) + ); } - public static Class updateClass(Class aClass, NamespacedKey key) { - Class theClass; + public static Class getFieldType(Class apiClass, NamespacedKey key) { + Class fieldType = apiClass; // Some registries have extra Typed classes such as BlockType and ItemType. // To avoid class cast exceptions during init mock the Typed class. // To get the correct class, we just use the field type. try { - theClass = (Class) aClass.getField(key.getKey().toUpperCase(Locale.ROOT).replace('.', '_')).getType(); - } catch (ClassCastException | NoSuchFieldException e) { + fieldType = (Class) apiClass.getField(formatKeyAsField(key.getKey())).getType(); + } catch (NoSuchFieldException e) { + // continue with the less accurate type + } catch (ClassCastException e) { throw new RuntimeException(e); } - return theClass; + return fieldType; } - private static MultiPackResourceManager createResourceManager(FeatureFlagSet featureFlagSet) { - // Populate available packs - PackRepository resourceRepository = ServerPacksSource.createVanillaTrustedRepository(); - resourceRepository.reload(); - // Set up resource manager - return new MultiPackResourceManager(PackType.SERVER_DATA, resourceRepository.getAvailablePacks().stream().filter(pack -> pack.getRequestedFeatures().isSubsetOf(featureFlagSet)).map(Pack::open).toList()); + private static MultiPackResourceManager createResourceManager(FeatureFlagSet enabledFeatures) { + PackRepository packRepository = ServerPacksSource.createVanillaTrustedRepository(); + MinecraftServer.configurePackRepository(packRepository, new WorldDataConfiguration(new DataPackConfig(FeatureFlags.REGISTRY.toNames(enabledFeatures).stream().map(Identifier::getPath).toList(), List.of()), enabledFeatures), true, false); + return new MultiPackResourceManager(PackType.SERVER_DATA, packRepository.openAllSelected()); } - private static void throwError(String field) { - throw new IllegalStateException(String.format(""" - Trying to access %s will it is not setup. - Make sure that either the class or method you test has the right test environment annotation present. - You can find them in the package src/test/java/org.bukkit.support.environment""", field)); + private static final Pattern ILLEGAL_FIELD_CHARACTERS = Pattern.compile("[.-/]"); + + public static String formatKeyAsField(String path) { + return ILLEGAL_FIELD_CHARACTERS.matcher(path.toUpperCase(Locale.ENGLISH)).replaceAll("_"); } } diff --git a/paper-server/src/test/java/org/bukkit/support/extension/AllFeaturesExtension.java b/paper-server/src/test/java/org/bukkit/support/extension/AllFeaturesExtension.java index a17f783d0c75..990b496716ee 100644 --- a/paper-server/src/test/java/org/bukkit/support/extension/AllFeaturesExtension.java +++ b/paper-server/src/test/java/org/bukkit/support/extension/AllFeaturesExtension.java @@ -33,12 +33,11 @@ public void init(ExtensionContext extensionContext) { RegistryHelper.setup(FeatureFlags.REGISTRY.allFlags()); Server server = DummyServerHelper.setup(); - Bukkit.setServer(server); // Paper - Add RegistryAccess for managing registries - replaced with registry access - CraftRegistry.setMinecraftRegistry(RegistryHelper.getRegistry()); + CraftRegistry.setMinecraftRegistry(RegistryHelper.registryAccess()); } @Override diff --git a/paper-server/src/test/java/org/bukkit/support/extension/LegacyExtension.java b/paper-server/src/test/java/org/bukkit/support/extension/LegacyExtension.java index ae8a16160b8f..ee39652e1500 100644 --- a/paper-server/src/test/java/org/bukkit/support/extension/LegacyExtension.java +++ b/paper-server/src/test/java/org/bukkit/support/extension/LegacyExtension.java @@ -19,12 +19,11 @@ public void init(ExtensionContext extensionContext) { RegistryHelper.setup(FeatureFlags.VANILLA_SET); Server server = DummyServerHelper.setup(); - Bukkit.setServer(server); // Paper - Add RegistryAccess for managing registries - replaced with registry access - CraftRegistry.setMinecraftRegistry(RegistryHelper.getRegistry()); + CraftRegistry.setMinecraftRegistry(RegistryHelper.registryAccess()); } @Override diff --git a/paper-server/src/test/java/org/bukkit/support/extension/NormalExtension.java b/paper-server/src/test/java/org/bukkit/support/extension/NormalExtension.java index a809ea2f0d2b..0d35cb4e8f3a 100644 --- a/paper-server/src/test/java/org/bukkit/support/extension/NormalExtension.java +++ b/paper-server/src/test/java/org/bukkit/support/extension/NormalExtension.java @@ -1,7 +1,5 @@ package org.bukkit.support.extension; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; import java.util.HashMap; import java.util.Map; import net.minecraft.core.RegistryAccess; @@ -17,6 +15,12 @@ import org.junit.jupiter.api.extension.ExtensionContext; import org.mockito.stubbing.Answer; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.withSettings; + public class NormalExtension extends BaseExtension { private static final Answer DEFAULT_ANSWER = invocation -> { @@ -38,7 +42,6 @@ public void init(ExtensionContext extensionContext) { RegistryHelper.setup(FeatureFlags.VANILLA_SET); Server server = DummyServerHelper.setup(); - Bukkit.setServer(server); when(server.getRegistry(any())) @@ -47,7 +50,6 @@ public void init(ExtensionContext extensionContext) { return registries.computeIfAbsent(keyed, k -> createMockBukkitRegistry(keyed)); }); - RegistryAccess registry = mock(withSettings().stubOnly().defaultAnswer(NormalExtension.DEFAULT_ANSWER)); CraftRegistry.setMinecraftRegistry(registry); } @@ -61,8 +63,8 @@ private Registry createMockBukkitRegistry(Class keyed) { Registry registry = mock(withSettings().stubOnly().defaultAnswer(NormalExtension.DEFAULT_ANSWER)); doAnswer(invocation -> - mocks.computeIfAbsent(invocation.getArgument(0), k -> mock(RegistryHelper.updateClass(keyed, invocation.getArgument(0)), withSettings().stubOnly().defaultAnswer(DEFAULT_ANSWER))) - ).when(registry).get((NamespacedKey) any()); // Allow static classes to fill there fields, so that it does not error out, just by loading them // Paper - registry modification api - specifically call namespaced key overload + mocks.computeIfAbsent(invocation.getArgument(0), k -> mock(RegistryHelper.getFieldType(keyed, invocation.getArgument(0)), withSettings().stubOnly().defaultAnswer(DEFAULT_ANSWER))) + ).when(registry).get((NamespacedKey) any()); // Allow static classes to fill their fields, so that it does not error out, just by loading them // Paper - registry modification api - specifically call namespaced key overload return registry; } diff --git a/paper-server/src/test/java/org/bukkit/support/extension/SlowExtension.java b/paper-server/src/test/java/org/bukkit/support/extension/SlowExtension.java index eb0960fa1169..44a64e8635df 100644 --- a/paper-server/src/test/java/org/bukkit/support/extension/SlowExtension.java +++ b/paper-server/src/test/java/org/bukkit/support/extension/SlowExtension.java @@ -19,12 +19,11 @@ public void init(ExtensionContext extensionContext) { RegistryHelper.setup(FeatureFlags.VANILLA_SET); Server server = DummyServerHelper.setup(); - Bukkit.setServer(server); // Paper - Add RegistryAccess for managing registries - replaced with registry access - CraftRegistry.setMinecraftRegistry(RegistryHelper.getRegistry()); + CraftRegistry.setMinecraftRegistry(RegistryHelper.registryAccess()); } @Override diff --git a/paper-server/src/test/java/org/bukkit/support/extension/VanillaFeatureExtension.java b/paper-server/src/test/java/org/bukkit/support/extension/VanillaFeatureExtension.java index 66db95cfcaaa..aabd9e5e4176 100644 --- a/paper-server/src/test/java/org/bukkit/support/extension/VanillaFeatureExtension.java +++ b/paper-server/src/test/java/org/bukkit/support/extension/VanillaFeatureExtension.java @@ -19,12 +19,11 @@ public void init(ExtensionContext extensionContext) { RegistryHelper.setup(FeatureFlags.VANILLA_SET); Server server = DummyServerHelper.setup(); - Bukkit.setServer(server); // Paper - Add RegistryAccess for managing registries - replaced with registry access - CraftRegistry.setMinecraftRegistry(RegistryHelper.getRegistry()); + CraftRegistry.setMinecraftRegistry(RegistryHelper.registryAccess()); } @Override diff --git a/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java b/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java index 8c06180b674d..ffec21232a87 100644 --- a/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java +++ b/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java @@ -1,11 +1,14 @@ package org.bukkit.support.provider; import com.google.common.collect.Lists; +import io.papermc.paper.datacomponent.DataComponentTypes; import io.papermc.paper.dialog.Dialog; import io.papermc.paper.dialog.PaperDialog; +import io.papermc.paper.registry.PaperRegistries; import io.papermc.paper.registry.RegistryKey; import java.util.List; import java.util.stream.Stream; +import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.sounds.SoundEvent; @@ -28,7 +31,9 @@ import org.bukkit.Fluid; import org.bukkit.GameEvent; import org.bukkit.GameRule; +import org.bukkit.GameRules; import org.bukkit.JukeboxSong; +import org.bukkit.Keyed; import org.bukkit.MusicInstrument; import org.bukkit.Sound; import org.bukkit.attribute.Attribute; @@ -82,65 +87,85 @@ import org.bukkit.inventory.meta.trim.TrimPattern; import org.bukkit.map.MapCursor; import org.bukkit.potion.PotionEffectType; +import org.jspecify.annotations.NullMarked; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.ArgumentsProvider; +@NullMarked public class RegistriesArgumentProvider implements ArgumentsProvider { - private static final List DATA = Lists.newArrayList(); + public record RegistryArgument(ResourceKey> registryKey, + RegistryKey apiRegistryKey, + Class api, Class apiHolder, + Class impl, + Class internal) implements Arguments { + @Override + public Object[] get() { + return new Object[]{ + this.apiRegistryKey, + this.api, + this.registryKey, + this.impl, + this.internal, + this.apiHolder + }; + } + } + + private static final List> DATA = Lists.newArrayList(); static { - // Order: RegistryKey, Bukkit class, Minecraft Registry key, CraftBukkit class, Minecraft class - register(RegistryKey.PAINTING_VARIANT, Art.class, Registries.PAINTING_VARIANT, CraftArt.class, PaintingVariant.class); - register(RegistryKey.ATTRIBUTE, Attribute.class, Registries.ATTRIBUTE, CraftAttribute.class, net.minecraft.world.entity.ai.attributes.Attribute.class); - register(RegistryKey.BIOME, Biome.class, Registries.BIOME, CraftBiome.class, net.minecraft.world.level.biome.Biome.class); - register(RegistryKey.ENCHANTMENT, Enchantment.class, Registries.ENCHANTMENT, CraftEnchantment.class, net.minecraft.world.item.enchantment.Enchantment.class); - register(RegistryKey.FLUID, Fluid.class, Registries.FLUID, CraftFluid.class, net.minecraft.world.level.material.Fluid.class); - register(RegistryKey.GAME_EVENT, GameEvent.class, Registries.GAME_EVENT, CraftGameEvent.class, net.minecraft.world.level.gameevent.GameEvent.class); - register(RegistryKey.INSTRUMENT, MusicInstrument.class, Registries.INSTRUMENT, CraftMusicInstrument.class, Instrument.class); - register(RegistryKey.MOB_EFFECT, PotionEffectType.class, Registries.MOB_EFFECT, CraftPotionEffectType.class, MobEffect.class); - register(RegistryKey.SOUND_EVENT, Sound.class, Registries.SOUND_EVENT, CraftSound.class, SoundEvent.class); - register(RegistryKey.STRUCTURE, Structure.class, Registries.STRUCTURE, CraftStructure.class, net.minecraft.world.level.levelgen.structure.Structure.class); - register(RegistryKey.STRUCTURE_TYPE, StructureType.class, Registries.STRUCTURE_TYPE, CraftStructureType.class, net.minecraft.world.level.levelgen.structure.StructureType.class); - register(RegistryKey.VILLAGER_TYPE, Villager.Type.class, Registries.VILLAGER_TYPE, CraftVillager.CraftType.class, VillagerType.class); - register(RegistryKey.VILLAGER_PROFESSION, Villager.Profession.class, Registries.VILLAGER_PROFESSION, CraftVillager.CraftProfession.class, VillagerProfession.class); - register(RegistryKey.TRIM_MATERIAL, TrimMaterial.class, Registries.TRIM_MATERIAL, CraftTrimMaterial.class, net.minecraft.world.item.equipment.trim.TrimMaterial.class); - register(RegistryKey.TRIM_PATTERN, TrimPattern.class, Registries.TRIM_PATTERN, CraftTrimPattern.class, net.minecraft.world.item.equipment.trim.TrimPattern.class); - register(RegistryKey.DAMAGE_TYPE, DamageType.class, Registries.DAMAGE_TYPE, CraftDamageType.class, net.minecraft.world.damagesource.DamageType.class); - register(RegistryKey.JUKEBOX_SONG, JukeboxSong.class, Registries.JUKEBOX_SONG, CraftJukeboxSong.class, net.minecraft.world.item.JukeboxSong.class); - register(RegistryKey.WOLF_VARIANT, Wolf.Variant.class, Registries.WOLF_VARIANT, CraftWolf.CraftVariant.class, WolfVariant.class); - register(RegistryKey.WOLF_SOUND_VARIANT, Wolf.SoundVariant.class, Registries.WOLF_SOUND_VARIANT, CraftWolf.CraftSoundVariant.class, WolfSoundVariant.class); - register(RegistryKey.ITEM, ItemType.class, Registries.ITEM, CraftItemType.class, net.minecraft.world.item.Item.class, true); - register(RegistryKey.BLOCK, BlockType.class, Registries.BLOCK, CraftBlockType.class, net.minecraft.world.level.block.Block.class, true); - register(RegistryKey.FROG_VARIANT, Frog.Variant.class, Registries.FROG_VARIANT, CraftFrog.CraftVariant.class, FrogVariant.class); - register(RegistryKey.CAT_VARIANT, Cat.Type.class, Registries.CAT_VARIANT, CraftCat.CraftType.class, CatVariant.class); - register(RegistryKey.MAP_DECORATION_TYPE, MapCursor.Type.class, Registries.MAP_DECORATION_TYPE, CraftMapCursor.CraftType.class, MapDecorationType.class); - register(RegistryKey.BANNER_PATTERN, PatternType.class, Registries.BANNER_PATTERN, CraftPatternType.class, BannerPattern.class); - register(RegistryKey.MENU, MenuType.class, Registries.MENU, CraftMenuType.class, net.minecraft.world.inventory.MenuType.class); - register(RegistryKey.DATA_COMPONENT_TYPE, io.papermc.paper.datacomponent.DataComponentType.class, Registries.DATA_COMPONENT_TYPE, io.papermc.paper.datacomponent.PaperDataComponentType.class, net.minecraft.core.component.DataComponentType.class); - register(RegistryKey.CHICKEN_VARIANT, Chicken.Variant.class, Registries.CHICKEN_VARIANT, CraftChicken.CraftVariant.class, ChickenVariant.class); - register(RegistryKey.COW_VARIANT, Cow.Variant.class, Registries.COW_VARIANT, CraftCow.CraftVariant.class, CowVariant.class); - register(RegistryKey.PIG_VARIANT, Pig.Variant.class, Registries.PIG_VARIANT, CraftPig.CraftVariant.class, PigVariant.class); - register(RegistryKey.ZOMBIE_NAUTILUS_VARIANT, ZombieNautilus.Variant.class, Registries.ZOMBIE_NAUTILUS_VARIANT, CraftZombieNautilus.CraftVariant.class, ZombieNautilusVariant.class); - register(RegistryKey.DIALOG, Dialog.class, Registries.DIALOG, PaperDialog.class, net.minecraft.server.dialog.Dialog.class); - register(RegistryKey.GAME_RULE, GameRule.class, Registries.GAME_RULE, CraftGameRule.class, net.minecraft.world.level.gamerules.GameRule.class); + register(Registries.PAINTING_VARIANT, Art.class, CraftArt.class, PaintingVariant.class); + register(Registries.ATTRIBUTE, Attribute.class, CraftAttribute.class, net.minecraft.world.entity.ai.attributes.Attribute.class); + register(Registries.BIOME, Biome.class, CraftBiome.class, net.minecraft.world.level.biome.Biome.class); + register(Registries.ENCHANTMENT, Enchantment.class, CraftEnchantment.class, net.minecraft.world.item.enchantment.Enchantment.class); + register(Registries.FLUID, Fluid.class, CraftFluid.class, net.minecraft.world.level.material.Fluid.class); + register(Registries.GAME_EVENT, GameEvent.class, CraftGameEvent.class, net.minecraft.world.level.gameevent.GameEvent.class); + register(Registries.INSTRUMENT, MusicInstrument.class, CraftMusicInstrument.class, Instrument.class); + register(Registries.MOB_EFFECT, PotionEffectType.class, CraftPotionEffectType.class, MobEffect.class); + register(Registries.SOUND_EVENT, Sound.class, CraftSound.class, SoundEvent.class); + register(Registries.STRUCTURE, Structure.class, CraftStructure.class, net.minecraft.world.level.levelgen.structure.Structure.class); + register(Registries.STRUCTURE_TYPE, StructureType.class, CraftStructureType.class, net.minecraft.world.level.levelgen.structure.StructureType.class); + register(Registries.VILLAGER_TYPE, Villager.Type.class, CraftVillager.CraftType.class, VillagerType.class); + register(Registries.VILLAGER_PROFESSION, Villager.Profession.class, CraftVillager.CraftProfession.class, VillagerProfession.class); + register(Registries.TRIM_MATERIAL, TrimMaterial.class, CraftTrimMaterial.class, net.minecraft.world.item.equipment.trim.TrimMaterial.class); + register(Registries.TRIM_PATTERN, TrimPattern.class, CraftTrimPattern.class, net.minecraft.world.item.equipment.trim.TrimPattern.class); + register(Registries.DAMAGE_TYPE, DamageType.class, CraftDamageType.class, net.minecraft.world.damagesource.DamageType.class); + register(Registries.JUKEBOX_SONG, JukeboxSong.class, CraftJukeboxSong.class, net.minecraft.world.item.JukeboxSong.class); + register(Registries.WOLF_VARIANT, Wolf.Variant.class, CraftWolf.CraftVariant.class, WolfVariant.class); + register(Registries.WOLF_SOUND_VARIANT, Wolf.SoundVariant.class, CraftWolf.CraftSoundVariant.class, WolfSoundVariant.class); + register(Registries.ITEM, ItemType.class, CraftItemType.class, net.minecraft.world.item.Item.class); + register(Registries.BLOCK, BlockType.class, CraftBlockType.class, net.minecraft.world.level.block.Block.class); + register(Registries.FROG_VARIANT, Frog.Variant.class, CraftFrog.CraftVariant.class, FrogVariant.class); + register(Registries.CAT_VARIANT, Cat.Type.class, CraftCat.CraftType.class, CatVariant.class); + register(Registries.MAP_DECORATION_TYPE, MapCursor.Type.class, CraftMapCursor.CraftType.class, MapDecorationType.class); + register(Registries.BANNER_PATTERN, PatternType.class, CraftPatternType.class, BannerPattern.class); + register(Registries.MENU, MenuType.class, CraftMenuType.class, net.minecraft.world.inventory.MenuType.class); + register(Registries.DATA_COMPONENT_TYPE, io.papermc.paper.datacomponent.DataComponentType.class, DataComponentTypes.class, io.papermc.paper.datacomponent.PaperDataComponentType.class, net.minecraft.core.component.DataComponentType.class); + register(Registries.CHICKEN_VARIANT, Chicken.Variant.class, CraftChicken.CraftVariant.class, ChickenVariant.class); + register(Registries.COW_VARIANT, Cow.Variant.class, CraftCow.CraftVariant.class, CowVariant.class); + register(Registries.PIG_VARIANT, Pig.Variant.class, CraftPig.CraftVariant.class, PigVariant.class); + register(Registries.ZOMBIE_NAUTILUS_VARIANT, ZombieNautilus.Variant.class, CraftZombieNautilus.CraftVariant.class, ZombieNautilusVariant.class); + register(Registries.DIALOG, Dialog.class, PaperDialog.class, net.minecraft.server.dialog.Dialog.class); + register(Registries.GAME_RULE, GameRule.class, GameRules.class, CraftGameRule.class, net.minecraft.world.level.gamerules.GameRule.class); } - private static void register(RegistryKey registryKey, Class bukkit, ResourceKey registry, Class craft, Class minecraft) { // Paper - RegistriesArgumentProvider.register(registryKey, bukkit, registry, craft, minecraft, false); + private static void register(ResourceKey> registryKey, Class api, Class impl, Class internal) { + register(registryKey, api, api, impl, internal); } - private static void register(RegistryKey registryKey, Class bukkit, ResourceKey registry, Class craft, Class minecraft, boolean newClass) { // Paper - RegistriesArgumentProvider.DATA.add(Arguments.of(registryKey, bukkit, registry, craft, minecraft, newClass)); + @SuppressWarnings({"rawtypes", "unchecked"}) + private static void register(ResourceKey> registryKey, Class api, Class apiHolder, Class impl, Class internal) { + DATA.add(new RegistryArgument<>(registryKey, PaperRegistries.registryFromNms((ResourceKey) registryKey), api, apiHolder, impl, internal)); } @Override - public Stream provideArguments(ExtensionContext extensionContext) throws Exception { - return RegistriesArgumentProvider.getData(); + public Stream provideArguments(ExtensionContext extensionContext) { + return getData(); } - public static Stream getData() { - return RegistriesArgumentProvider.DATA.stream(); + public static Stream> getData() { + return DATA.stream(); } } diff --git a/paper-server/src/test/java/org/bukkit/support/test/RegistriesTest.java b/paper-server/src/test/java/org/bukkit/support/test/RegistriesTest.java index c84f3807350f..24c67ff96d90 100644 --- a/paper-server/src/test/java/org/bukkit/support/test/RegistriesTest.java +++ b/paper-server/src/test/java/org/bukkit/support/test/RegistriesTest.java @@ -5,15 +5,13 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.bukkit.support.provider.RegistriesArgumentProvider; +import org.junit.jupiter.params.ArgumentCountValidationMode; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ArgumentsSource; -/** - * Order: Bukkit class, Minecraft Registry key, CraftBukkit class, Minecraft class - */ @Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE}) @Retention(RetentionPolicy.RUNTIME) @ArgumentsSource(RegistriesArgumentProvider.class) -@ParameterizedTest +@ParameterizedTest(argumentCountValidation = ArgumentCountValidationMode.NONE) public @interface RegistriesTest { } From 5513ee9dd1e09dcc6931aad85cd8920dbab0942e Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 15 Nov 2025 20:10:29 +0100 Subject: [PATCH 081/112] fix tests not running (for PaperSkinPartsTest and EffectTest) --- paper-server/src/test/java/org/bukkit/EffectTest.java | 2 ++ .../java/org/bukkit/support/suite/AllFeaturesTestSuite.java | 2 +- .../src/test/java/org/bukkit/support/suite/LegacyTestSuite.java | 2 +- .../src/test/java/org/bukkit/support/suite/NormalTestSuite.java | 2 +- .../src/test/java/org/bukkit/support/suite/SlowTestSuite.java | 2 +- .../java/org/bukkit/support/suite/VanillaFeatureTestSuite.java | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/paper-server/src/test/java/org/bukkit/EffectTest.java b/paper-server/src/test/java/org/bukkit/EffectTest.java index b54401f30a17..90fb1a6e97a6 100644 --- a/paper-server/src/test/java/org/bukkit/EffectTest.java +++ b/paper-server/src/test/java/org/bukkit/EffectTest.java @@ -9,6 +9,7 @@ import java.util.HashSet; import java.util.Set; import net.minecraft.world.level.block.LevelEvent; +import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -17,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.fail; +@Normal public class EffectTest { private static boolean isNotDeprecated(Effect effect) throws ReflectiveOperationException { diff --git a/paper-server/src/test/java/org/bukkit/support/suite/AllFeaturesTestSuite.java b/paper-server/src/test/java/org/bukkit/support/suite/AllFeaturesTestSuite.java index 2d268498b545..07274a08e05e 100644 --- a/paper-server/src/test/java/org/bukkit/support/suite/AllFeaturesTestSuite.java +++ b/paper-server/src/test/java/org/bukkit/support/suite/AllFeaturesTestSuite.java @@ -14,7 +14,7 @@ @Suite(failIfNoTests = false) @SuiteDisplayName("Test suite for test which need registry values present, with all feature flags set") @IncludeTags("AllFeatures") -@SelectPackages({"org.bukkit", "io.papermc"}) +@SelectPackages({"org.bukkit", "io.papermc.paper", "com.destroystokyo.paper"}) @SelectClasses({RegistryClassTest.class, PerRegistryTest.class, RegistryConversionTest.class}) // Make sure general registry tests are run first @ExcludeClassNamePatterns("org.bukkit.craftbukkit.inventory.ItemStack.*Test") @ConfigurationParameter(key = "TestSuite", value = "AllFeatures") diff --git a/paper-server/src/test/java/org/bukkit/support/suite/LegacyTestSuite.java b/paper-server/src/test/java/org/bukkit/support/suite/LegacyTestSuite.java index ac3c1c88ce5d..14acf9c9db27 100644 --- a/paper-server/src/test/java/org/bukkit/support/suite/LegacyTestSuite.java +++ b/paper-server/src/test/java/org/bukkit/support/suite/LegacyTestSuite.java @@ -9,7 +9,7 @@ @Suite(failIfNoTests = false) @SuiteDisplayName("Test suite for legacy tests") @IncludeTags("Legacy") -@SelectPackages({"org.bukkit", "io.papermc"}) +@SelectPackages({"org.bukkit", "io.papermc.paper", "com.destroystokyo.paper"}) @ConfigurationParameter(key = "TestSuite", value = "Legacy") public class LegacyTestSuite { } diff --git a/paper-server/src/test/java/org/bukkit/support/suite/NormalTestSuite.java b/paper-server/src/test/java/org/bukkit/support/suite/NormalTestSuite.java index 76f61fb60612..625d88420c9f 100644 --- a/paper-server/src/test/java/org/bukkit/support/suite/NormalTestSuite.java +++ b/paper-server/src/test/java/org/bukkit/support/suite/NormalTestSuite.java @@ -9,7 +9,7 @@ @Suite(failIfNoTests = false) @SuiteDisplayName("Test suite for standalone tests, which don't need any registry values present") @IncludeTags("Normal") -@SelectPackages({"org.bukkit", "io.papermc"}) +@SelectPackages({"org.bukkit", "io.papermc.paper", "com.destroystokyo.paper"}) @ConfigurationParameter(key = "TestSuite", value = "Normal") public class NormalTestSuite { } diff --git a/paper-server/src/test/java/org/bukkit/support/suite/SlowTestSuite.java b/paper-server/src/test/java/org/bukkit/support/suite/SlowTestSuite.java index 60be4c20101b..212607736d25 100644 --- a/paper-server/src/test/java/org/bukkit/support/suite/SlowTestSuite.java +++ b/paper-server/src/test/java/org/bukkit/support/suite/SlowTestSuite.java @@ -9,7 +9,7 @@ @Suite(failIfNoTests = false) @SuiteDisplayName("Test suite for slow tests, which don't need to run every time") @IncludeTags("Slow") -@SelectPackages({"org.bukkit", "io.papermc"}) +@SelectPackages({"org.bukkit", "io.papermc.paper", "com.destroystokyo.paper"}) @ConfigurationParameter(key = "TestSuite", value = "Slow") public class SlowTestSuite { } diff --git a/paper-server/src/test/java/org/bukkit/support/suite/VanillaFeatureTestSuite.java b/paper-server/src/test/java/org/bukkit/support/suite/VanillaFeatureTestSuite.java index d0e2eacfcd48..d06cf4b8131a 100644 --- a/paper-server/src/test/java/org/bukkit/support/suite/VanillaFeatureTestSuite.java +++ b/paper-server/src/test/java/org/bukkit/support/suite/VanillaFeatureTestSuite.java @@ -9,7 +9,7 @@ @Suite(failIfNoTests = false) @SuiteDisplayName("Test suite for test which need vanilla registry values present") @IncludeTags("VanillaFeature") -@SelectPackages({"org.bukkit", "io.papermc"}) +@SelectPackages({"org.bukkit", "io.papermc.paper", "com.destroystokyo.paper"}) @ConfigurationParameter(key = "TestSuite", value = "VanillaFeature") public class VanillaFeatureTestSuite { } From ac4791075fe9376a59a9bab6526c5fda09e80f54 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 15 Nov 2025 20:18:27 +0100 Subject: [PATCH 082/112] pass the right inventory to InventoryOpenEvent for the nautilus --- .../sources/net/minecraft/server/level/ServerPlayer.java.patch | 2 +- .../world/entity/animal/nautilus/AbstractNautilus.java.patch | 2 +- .../src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index ae7c227be791..a4f65f94f3c2 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -1078,7 +1078,7 @@ + this.nextContainerCounter(); // moved up from below + AbstractContainerMenu menu = new NautilusInventoryMenu(this.containerCounter, this.getInventory(), inventory, nautilus, nautilus.getInventoryColumns()); + menu.setTitle(nautilus.getDisplayName()); -+ menu = org.bukkit.craftbukkit.event.CraftEventFactory.callInventoryOpenEvent(this, containerMenu); ++ menu = org.bukkit.craftbukkit.event.CraftEventFactory.callInventoryOpenEvent(this, menu); + + if (menu == null) { + inventory.stopOpen(this); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch index 107019494fd8..398c8521c6fe 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch @@ -32,7 +32,7 @@ protected void createInventory() { SimpleContainer simpleContainer = this.inventory; - this.inventory = new SimpleContainer(this.getInventorySize()); -+ this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.craftbukkit.entity.CraftAbstractNautilus) getBukkitEntity()); // Paper - add inv owner ++ this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.entity.AbstractNautilus) this.getBukkitEntity()); // Paper - add owner if (simpleContainer != null) { int min = Math.min(simpleContainer.getContainerSize(), this.inventory.getContainerSize()); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java index de9af4fc1593..e52f412d01cf 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java @@ -38,6 +38,7 @@ public double getSize() { @Override public void setSize(double newSize) { + Preconditions.checkArgument(newSize >= 1.0D && newSize <= this.getMaxSize(), "newSize must be between 1.0D and %s", this.getMaxSize()); this.handle.setSize(newSize); } From 8b225e76bc248faf8e1ad623c370f85864ed92b5 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Sun, 16 Nov 2025 00:02:16 +0100 Subject: [PATCH 083/112] Update ItemType --- .../java/org/bukkit/inventory/ItemType.java | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/inventory/ItemType.java b/paper-api/src/main/java/org/bukkit/inventory/ItemType.java index cfcfd7d72ef1..228d11a6d2bb 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ItemType.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ItemType.java @@ -94,7 +94,6 @@ interface Typed extends ItemType { // // Start generate - ItemType - // @GeneratedFrom 25w34b ItemType.Typed ACACIA_BOAT = getItemType("acacia_boat"); ItemType.Typed ACACIA_BUTTON = getItemType("acacia_button"); @@ -483,6 +482,8 @@ interface Typed extends ItemType { ItemType.Typed CALIBRATED_SCULK_SENSOR = getItemType("calibrated_sculk_sensor"); + ItemType.Typed CAMEL_HUSK_SPAWN_EGG = getItemType("camel_husk_spawn_egg"); + ItemType.Typed CAMEL_SPAWN_EGG = getItemType("camel_spawn_egg"); ItemType.Typed CAMPFIRE = getItemType("campfire"); @@ -699,6 +700,8 @@ interface Typed extends ItemType { ItemType.Typed COPPER_LEGGINGS = getItemType("copper_leggings"); + ItemType.Typed COPPER_NAUTILUS_ARMOR = getItemType("copper_nautilus_armor"); + ItemType.Typed COPPER_NUGGET = getItemType("copper_nugget"); ItemType.Typed COPPER_ORE = getItemType("copper_ore"); @@ -707,6 +710,8 @@ interface Typed extends ItemType { ItemType.Typed COPPER_SHOVEL = getItemType("copper_shovel"); + ItemType.Typed COPPER_SPEAR = getItemType("copper_spear"); + ItemType.Typed COPPER_SWORD = getItemType("copper_sword"); ItemType.Typed COPPER_TORCH = getItemType("copper_torch"); @@ -963,12 +968,16 @@ interface Typed extends ItemType { ItemType.Typed DIAMOND_LEGGINGS = getItemType("diamond_leggings"); + ItemType.Typed DIAMOND_NAUTILUS_ARMOR = getItemType("diamond_nautilus_armor"); + ItemType.Typed DIAMOND_ORE = getItemType("diamond_ore"); ItemType.Typed DIAMOND_PICKAXE = getItemType("diamond_pickaxe"); ItemType.Typed DIAMOND_SHOVEL = getItemType("diamond_shovel"); + ItemType.Typed DIAMOND_SPEAR = getItemType("diamond_spear"); + ItemType.Typed DIAMOND_SWORD = getItemType("diamond_sword"); ItemType.Typed DIORITE = getItemType("diorite"); @@ -1217,10 +1226,14 @@ interface Typed extends ItemType { ItemType.Typed GOLDEN_LEGGINGS = getItemType("golden_leggings"); + ItemType.Typed GOLDEN_NAUTILUS_ARMOR = getItemType("golden_nautilus_armor"); + ItemType.Typed GOLDEN_PICKAXE = getItemType("golden_pickaxe"); ItemType.Typed GOLDEN_SHOVEL = getItemType("golden_shovel"); + ItemType.Typed GOLDEN_SPEAR = getItemType("golden_spear"); + ItemType.Typed GOLDEN_SWORD = getItemType("golden_sword"); ItemType.Typed GRANITE = getItemType("granite"); @@ -1373,10 +1386,10 @@ interface Typed extends ItemType { ItemType.Typed IRON_BLOCK = getItemType("iron_block"); - ItemType.Typed IRON_CHAIN = getItemType("iron_chain"); - ItemType.Typed IRON_BOOTS = getItemType("iron_boots"); + ItemType.Typed IRON_CHAIN = getItemType("iron_chain"); + ItemType.Typed IRON_CHESTPLATE = getItemType("iron_chestplate"); ItemType.Typed IRON_DOOR = getItemType("iron_door"); @@ -1393,6 +1406,8 @@ interface Typed extends ItemType { ItemType.Typed IRON_LEGGINGS = getItemType("iron_leggings"); + ItemType.Typed IRON_NAUTILUS_ARMOR = getItemType("iron_nautilus_armor"); + ItemType.Typed IRON_NUGGET = getItemType("iron_nugget"); ItemType.Typed IRON_ORE = getItemType("iron_ore"); @@ -1401,6 +1416,8 @@ interface Typed extends ItemType { ItemType.Typed IRON_SHOVEL = getItemType("iron_shovel"); + ItemType.Typed IRON_SPEAR = getItemType("iron_spear"); + ItemType.Typed IRON_SWORD = getItemType("iron_sword"); ItemType.Typed IRON_TRAPDOOR = getItemType("iron_trapdoor"); @@ -1785,6 +1802,8 @@ interface Typed extends ItemType { ItemType.Typed NAUTILUS_SHELL = getItemType("nautilus_shell"); + ItemType.Typed NAUTILUS_SPAWN_EGG = getItemType("nautilus_spawn_egg"); + ItemType.Typed NETHER_BRICK = getItemType("nether_brick"); ItemType.Typed NETHER_BRICK_FENCE = getItemType("nether_brick_fence"); @@ -1821,16 +1840,22 @@ interface Typed extends ItemType { ItemType.Typed NETHERITE_HOE = getItemType("netherite_hoe"); + ItemType.Typed NETHERITE_HORSE_ARMOR = getItemType("netherite_horse_armor"); + ItemType.Typed NETHERITE_INGOT = getItemType("netherite_ingot"); ItemType.Typed NETHERITE_LEGGINGS = getItemType("netherite_leggings"); + ItemType.Typed NETHERITE_NAUTILUS_ARMOR = getItemType("netherite_nautilus_armor"); + ItemType.Typed NETHERITE_PICKAXE = getItemType("netherite_pickaxe"); ItemType.Typed NETHERITE_SCRAP = getItemType("netherite_scrap"); ItemType.Typed NETHERITE_SHOVEL = getItemType("netherite_shovel"); + ItemType.Typed NETHERITE_SPEAR = getItemType("netherite_spear"); + ItemType.Typed NETHERITE_SWORD = getItemType("netherite_sword"); ItemType.Typed NETHERITE_UPGRADE_SMITHING_TEMPLATE = getItemType("netherite_upgrade_smithing_template"); @@ -2005,6 +2030,8 @@ interface Typed extends ItemType { ItemType.Typed PAPER = getItemType("paper"); + ItemType.Typed PARCHED_SPAWN_EGG = getItemType("parched_spawn_egg"); + ItemType.Typed PARROT_SPAWN_EGG = getItemType("parrot_spawn_egg"); ItemType.Typed PEARLESCENT_FROGLIGHT = getItemType("pearlescent_froglight"); @@ -2583,6 +2610,8 @@ interface Typed extends ItemType { ItemType.Typed STONE_SLAB = getItemType("stone_slab"); + ItemType.Typed STONE_SPEAR = getItemType("stone_spear"); + ItemType.Typed STONE_STAIRS = getItemType("stone_stairs"); ItemType.Typed STONE_SWORD = getItemType("stone_sword"); @@ -3023,6 +3052,8 @@ interface Typed extends ItemType { ItemType.Typed WOODEN_SHOVEL = getItemType("wooden_shovel"); + ItemType.Typed WOODEN_SPEAR = getItemType("wooden_spear"); + ItemType.Typed WOODEN_SWORD = getItemType("wooden_sword"); ItemType.Typed WRITABLE_BOOK = getItemType("writable_book"); @@ -3065,6 +3096,8 @@ interface Typed extends ItemType { ItemType.Typed ZOMBIE_HORSE_SPAWN_EGG = getItemType("zombie_horse_spawn_egg"); + ItemType.Typed ZOMBIE_NAUTILUS_SPAWN_EGG = getItemType("zombie_nautilus_spawn_egg"); + ItemType.Typed ZOMBIE_SPAWN_EGG = getItemType("zombie_spawn_egg"); ItemType.Typed ZOMBIE_VILLAGER_SPAWN_EGG = getItemType("zombie_villager_spawn_egg"); From 4d746b8019d208001b57114e7aeeab6168e4d37c Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sun, 16 Nov 2025 19:34:45 +0100 Subject: [PATCH 084/112] update titleOverride javadoc --- .../event/inventory/InventoryOpenEvent.java | 4 +- .../craftbukkit/event/CraftEventFactory.java | 8 ++-- .../inventory/CraftInventorySaddledMount.java | 42 +++++++++---------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java index 7641225bf430..4c05faf07f3e 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java @@ -50,8 +50,8 @@ public final HumanEntity getPlayer() { * This is only the title sent to the client in the open packet, this doesn't change * the title returned by {@link InventoryView#title()}, hence "override". *

- * NOTE: Horse inventories are a special case where setting this will - * have no effect. Horse inventory titles are set by the horse display name. + * NOTE: Horse and nautilus inventories are a special case where setting this will + * have no effect. These inventory titles are set by the entity's display name. * * @param titleOverride the title override or {@code null} */ diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 9f0a7cd6e046..e0f3ba43f90e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1283,17 +1283,17 @@ public static EntityBreakDoorEvent callEntityBreakDoorEvent(Entity entity, Block return event; } - public static AbstractContainerMenu callInventoryOpenEvent(ServerPlayer player, AbstractContainerMenu container) { + public static @Nullable AbstractContainerMenu callInventoryOpenEvent(ServerPlayer player, AbstractContainerMenu container) { // Paper start - Add titleOverride to InventoryOpenEvent return callInventoryOpenEventWithTitle(player, container).getSecond(); } - public static com.mojang.datafixers.util.Pair callInventoryOpenEventWithTitle(ServerPlayer player, AbstractContainerMenu container) { - return CraftEventFactory.callInventoryOpenEventWithTitle(player, container, false); + public static com.mojang.datafixers.util.Pair callInventoryOpenEventWithTitle(ServerPlayer player, AbstractContainerMenu container) { + return callInventoryOpenEventWithTitle(player, container, false); // Paper end - Add titleOverride to InventoryOpenEvent } - public static com.mojang.datafixers.util.Pair callInventoryOpenEventWithTitle(ServerPlayer player, AbstractContainerMenu container, boolean cancelled) { + public static com.mojang.datafixers.util.Pair callInventoryOpenEventWithTitle(ServerPlayer player, AbstractContainerMenu container, boolean cancelled) { container.startOpen(); // delegate start open logic to before InventoryOpenEvent is fired if (player.containerMenu != player.inventoryMenu) { // fire INVENTORY_CLOSE if one already open player.connection.handleContainerClose(new ServerboundContainerClosePacket(player.containerMenu.containerId), InventoryCloseEvent.Reason.OPEN_NEW); // Paper - Inventory close reason diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledMount.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledMount.java index 7d3657795710..979dad140730 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledMount.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledMount.java @@ -2,7 +2,7 @@ import com.google.common.base.Preconditions; import net.minecraft.world.Container; -import net.minecraft.world.inventory.HorseInventoryMenu; +import net.minecraft.world.inventory.AbstractMountInventoryMenu; import org.apache.commons.lang3.ArrayUtils; import org.bukkit.inventory.AbstractHorseInventory; import org.bukkit.inventory.ItemStack; @@ -20,12 +20,12 @@ public CraftInventorySaddledMount(Container inventory, final Container bodyArmor @Override public ItemStack getSaddle() { - return this.getItem(HorseInventoryMenu.SLOT_SADDLE); + return this.getItem(AbstractMountInventoryMenu.SLOT_SADDLE); } @Override public void setSaddle(ItemStack stack) { - this.setItem(HorseInventoryMenu.SLOT_SADDLE, stack); + this.setItem(AbstractMountInventoryMenu.SLOT_SADDLE, stack); } public Container getMainInventory() { @@ -41,11 +41,11 @@ public Container getSaddleInventory() { } public ItemStack getArmor() { - return this.getItem(HorseInventoryMenu.SLOT_BODY_ARMOR); + return this.getItem(AbstractMountInventoryMenu.SLOT_BODY_ARMOR); } public void setArmor(ItemStack armor) { - this.setItem(HorseInventoryMenu.SLOT_BODY_ARMOR, armor); + this.setItem(AbstractMountInventoryMenu.SLOT_BODY_ARMOR, armor); } @Override @@ -62,11 +62,11 @@ public boolean isEmpty() { public ItemStack[] getContents() { ItemStack[] items = new ItemStack[this.getSize()]; - items[HorseInventoryMenu.SLOT_SADDLE] = this.getSaddle(); - items[HorseInventoryMenu.SLOT_BODY_ARMOR] = this.getArmor(); + items[AbstractMountInventoryMenu.SLOT_SADDLE] = this.getSaddle(); + items[AbstractMountInventoryMenu.SLOT_BODY_ARMOR] = this.getArmor(); - for (int i = HorseInventoryMenu.SLOT_INVENTORY_START; i < items.length; i++) { - net.minecraft.world.item.ItemStack item = this.getMainInventory().getItem(i - HorseInventoryMenu.SLOT_INVENTORY_START); + for (int i = AbstractMountInventoryMenu.SLOT_INVENTORY_START; i < items.length; i++) { + net.minecraft.world.item.ItemStack item = this.getMainInventory().getItem(i - AbstractMountInventoryMenu.SLOT_INVENTORY_START); items[i] = item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); } @@ -77,29 +77,29 @@ public ItemStack[] getContents() { public void setContents(ItemStack[] items) { Preconditions.checkArgument(items.length <= this.getSize(), "Invalid inventory size (%s); expected %s or less", items.length, this.getSize()); - this.setSaddle(ArrayUtils.get(items, HorseInventoryMenu.SLOT_SADDLE)); - this.setArmor(ArrayUtils.get(items, HorseInventoryMenu.SLOT_BODY_ARMOR)); + this.setSaddle(ArrayUtils.get(items, AbstractMountInventoryMenu.SLOT_SADDLE)); + this.setArmor(ArrayUtils.get(items, AbstractMountInventoryMenu.SLOT_BODY_ARMOR)); - for (int i = HorseInventoryMenu.SLOT_INVENTORY_START; i < this.getSize(); i++) { + for (int i = AbstractMountInventoryMenu.SLOT_INVENTORY_START; i < this.getSize(); i++) { net.minecraft.world.item.ItemStack item = i >= items.length ? net.minecraft.world.item.ItemStack.EMPTY : CraftItemStack.asNMSCopy(items[i]); - this.getMainInventory().setItem(i - HorseInventoryMenu.SLOT_INVENTORY_START, item); + this.getMainInventory().setItem(i - AbstractMountInventoryMenu.SLOT_INVENTORY_START, item); } } @Override public ItemStack getItem(final int index) { - if (index == HorseInventoryMenu.SLOT_SADDLE) { + if (index == AbstractMountInventoryMenu.SLOT_SADDLE) { final net.minecraft.world.item.ItemStack item = this.getSaddleInventory().getItem(0); return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); - } else if (index == HorseInventoryMenu.SLOT_BODY_ARMOR) { + } else if (index == AbstractMountInventoryMenu.SLOT_BODY_ARMOR) { final net.minecraft.world.item.ItemStack item = this.getArmorInventory().getItem(0); return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); } else { int shiftedIndex = index; - if (index > HorseInventoryMenu.SLOT_SADDLE) { + if (index > AbstractMountInventoryMenu.SLOT_SADDLE) { shiftedIndex--; } - if (index > HorseInventoryMenu.SLOT_BODY_ARMOR) { + if (index > AbstractMountInventoryMenu.SLOT_BODY_ARMOR) { shiftedIndex--; } @@ -110,16 +110,16 @@ public ItemStack getItem(final int index) { @Override public void setItem(final int index, final ItemStack item) { - if (index == HorseInventoryMenu.SLOT_SADDLE) { + if (index == AbstractMountInventoryMenu.SLOT_SADDLE) { this.getSaddleInventory().setItem(0, CraftItemStack.asNMSCopy(item)); - } else if (index == HorseInventoryMenu.SLOT_BODY_ARMOR) { + } else if (index == AbstractMountInventoryMenu.SLOT_BODY_ARMOR) { this.getArmorInventory().setItem(0, CraftItemStack.asNMSCopy(item)); } else { int shiftedIndex = index; - if (index > HorseInventoryMenu.SLOT_SADDLE) { + if (index > AbstractMountInventoryMenu.SLOT_SADDLE) { shiftedIndex--; } - if (index > HorseInventoryMenu.SLOT_BODY_ARMOR) { + if (index > AbstractMountInventoryMenu.SLOT_BODY_ARMOR) { shiftedIndex--; } this.getMainInventory().setItem(shiftedIndex, CraftItemStack.asNMSCopy(item)); From 926d6304e09d05e451668ac1915248530165007b Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sun, 16 Nov 2025 11:58:18 -0700 Subject: [PATCH 085/112] CraftInventorySaddledMount implements SaddledMountInventory --- .../craftbukkit/inventory/CraftInventorySaddledMount.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledMount.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledMount.java index 979dad140730..261622a31241 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledMount.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledMount.java @@ -4,10 +4,10 @@ import net.minecraft.world.Container; import net.minecraft.world.inventory.AbstractMountInventoryMenu; import org.apache.commons.lang3.ArrayUtils; -import org.bukkit.inventory.AbstractHorseInventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.SaddledMountInventory; -public class CraftInventorySaddledMount extends CraftInventory implements AbstractHorseInventory { +public class CraftInventorySaddledMount extends CraftInventory implements SaddledMountInventory { private final Container bodyArmorInventory; private final Container saddleInventory; From 6d271a6bffde159163b76b910362b492837b1573 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Wed, 19 Nov 2025 19:45:00 -0700 Subject: [PATCH 086/112] Init 1.21.11-pre1 --- build-data/paper.at | 210 +++++++++--------- gradle.properties | 4 +- paper-server/build.gradle.kts | 6 +- .../core/component/DataComponents.java.patch | 4 +- .../network/FriendlyByteBuf.java.patch | 8 +- .../network/codec/ByteBufCodecs.java.patch | 2 +- .../game/ServerboundInteractPacket.java.patch | 2 +- .../commands/GameRuleCommand.java.patch | 4 +- .../server/level/ServerLevel.java.patch | 92 ++++---- .../server/level/ServerPlayer.java.patch | 6 +- .../level/ServerPlayerGameMode.java.patch | 2 +- .../ServerGamePacketListenerImpl.java.patch | 196 ++++++++-------- .../world/entity/EntityType.java.patch | 14 +- .../world/entity/LivingEntity.java.patch | 150 ++++++------- .../net/minecraft/world/entity/Mob.java.patch | 2 +- .../entity/animal/{ => bee}/Bee.java.patch | 24 +- .../animal/{ => chicken}/Chicken.java.patch | 6 +- .../animal/{ => cow}/AbstractCow.java.patch | 6 +- .../animal/{ => cow}/MushroomCow.java.patch | 4 +- .../animal/{ => dolphin}/Dolphin.java.patch | 16 +- .../AbstractChestedHorse.java.patch | 4 +- .../AbstractHorse.java.patch | 4 +- .../animal/{horse => equine}/Llama.java.patch | 4 +- .../SkeletonHorse.java.patch | 4 +- .../SkeletonTrapGoal.java.patch | 4 +- .../{horse => equine}/TraderLlama.java.patch | 4 +- .../entity/animal/{ => feline}/Cat.java.patch | 14 +- .../animal/{ => feline}/Ocelot.java.patch | 8 +- .../AbstractSchoolingFish.java.patch | 4 +- .../animal/{ => fish}/Pufferfish.java.patch | 4 +- .../animal/{ => fish}/WaterAnimal.java.patch | 4 +- .../entity/animal/{ => fox}/Fox.java.patch | 22 +- .../CopperGolem.java.patch | 16 +- .../animal/{ => golem}/IronGolem.java.patch | 4 +- .../animal/{ => golem}/SnowGolem.java.patch | 4 +- .../{ => happyghast}/HappyGhast.java.patch | 8 +- .../nautilus/AbstractNautilus.java.patch | 8 +- .../animal/nautilus/Nautilus.java.patch | 4 +- .../animal/{ => panda}/Panda.java.patch | 16 +- .../animal/{ => parrot}/Parrot.java.patch | 12 +- .../ShoulderRidingEntity.java.patch | 4 +- .../entity/animal/{ => pig}/Pig.java.patch | 6 +- .../animal/{ => rabbit}/Rabbit.java.patch | 8 +- .../animal/{ => squid}/Squid.java.patch | 6 +- .../animal/{ => turtle}/Turtle.java.patch | 16 +- .../boss/enderdragon/EnderDragon.java.patch | 32 +-- .../{ => painting}/Painting.java.patch | 6 +- .../world/entity/monster/Ravager.java.patch | 4 +- .../world/entity/monster/Strider.java.patch | 2 +- .../monster/{ => illager}/Evoker.java.patch | 6 +- .../{ => illager}/Illusioner.java.patch | 12 +- .../monster/{ => illager}/Pillager.java.patch | 6 +- .../SpellcasterIllager.java.patch | 4 +- .../{ => illager}/Vindicator.java.patch | 6 +- .../entity/monster/piglin/Piglin.java.patch | 16 +- .../entity/monster/piglin/PiglinAi.java.patch | 24 +- .../AbstractSkeleton.java.patch | 16 +- .../monster/{ => skeleton}/Bogged.java.patch | 4 +- .../{ => skeleton}/Skeleton.java.patch | 4 +- .../{ => skeleton}/WitherSkeleton.java.patch | 4 +- .../{ => spider}/CaveSpider.java.patch | 4 +- .../monster/{ => spider}/Spider.java.patch | 10 +- .../monster/{ => zombie}/Drowned.java.patch | 6 +- .../monster/{ => zombie}/Husk.java.patch | 6 +- .../monster/{ => zombie}/Zombie.java.patch | 32 +-- .../{ => zombie}/ZombieVillager.java.patch | 6 +- .../{ => zombie}/ZombifiedPiglin.java.patch | 4 +- .../AbstractVillager.java.patch | 12 +- .../npc/{ => villager}/Villager.java.patch | 30 +-- .../{ => villager}/VillagerTrades.java.patch | 4 +- .../WanderingTrader.java.patch | 14 +- .../WanderingTraderSpawner.java.patch | 4 +- .../world/entity/player/Player.java.patch | 84 +++---- .../entity/projectile/Projectile.java.patch | 22 +- .../{ => arrow}/AbstractArrow.java.patch | 34 +-- .../projectile/{ => arrow}/Arrow.java.patch | 4 +- .../{ => arrow}/SpectralArrow.java.patch | 4 +- .../{ => arrow}/ThrownTrident.java.patch | 12 +- .../AbstractHurtingProjectile.java.patch | 8 +- .../DragonFireball.java.patch | 4 +- .../LargeFireball.java.patch | 4 +- .../SmallFireball.java.patch | 4 +- .../WitherSkull.java.patch | 4 +- .../windcharge/AbstractWindCharge.java.patch | 4 +- .../windcharge/BreezeWindCharge.java.patch | 4 +- .../windcharge/WindCharge.java.patch | 4 +- .../AbstractThrownPotion.java.patch | 4 +- .../Snowball.java.patch | 4 +- .../ThrownEgg.java.patch | 4 +- .../ThrownEnderpearl.java.patch | 4 +- .../ThrownExperienceBottle.java.patch | 4 +- .../ThrownLingeringPotion.java.patch | 4 +- .../ThrownSplashPotion.java.patch | 12 +- .../entity/vehicle/ContainerEntity.java.patch | 2 +- .../{ => boat}/AbstractBoat.java.patch | 16 +- .../{ => boat}/AbstractChestBoat.java.patch | 12 +- .../AbstractMinecart.java.patch | 20 +- .../AbstractMinecartContainer.java.patch | 10 +- .../MinecartCommandBlock.java.patch | 4 +- .../{ => minecart}/MinecartTNT.java.patch | 4 +- .../NewMinecartBehavior.java.patch | 4 +- .../OldMinecartBehavior.java.patch | 4 +- .../inventory/ItemCombinerMenu.java.patch | 4 +- .../world/level/NaturalSpawner.java.patch | 28 +-- .../AbstractFurnaceBlockEntity.java.patch | 2 +- .../storage/LevelStorageSource.java.patch | 8 +- todo-snapshot.txt | 2 + 107 files changed, 781 insertions(+), 799 deletions(-) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => bee}/Bee.java.patch (95%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => chicken}/Chicken.java.patch (83%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => cow}/AbstractCow.java.patch (89%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => cow}/MushroomCow.java.patch (96%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => dolphin}/Dolphin.java.patch (92%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{horse => equine}/AbstractChestedHorse.java.patch (76%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{horse => equine}/AbstractHorse.java.patch (97%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{horse => equine}/Llama.java.patch (93%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{horse => equine}/SkeletonHorse.java.patch (69%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{horse => equine}/SkeletonTrapGoal.java.patch (95%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{horse => equine}/TraderLlama.java.patch (87%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => feline}/Cat.java.patch (94%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => feline}/Ocelot.java.patch (87%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => fish}/AbstractSchoolingFish.java.patch (66%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => fish}/Pufferfish.java.patch (96%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => fish}/WaterAnimal.java.patch (83%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => fox}/Fox.java.patch (96%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{coppergolem => golem}/CopperGolem.java.patch (95%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => golem}/IronGolem.java.patch (88%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => golem}/SnowGolem.java.patch (97%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => happyghast}/HappyGhast.java.patch (82%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => panda}/Panda.java.patch (95%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => parrot}/Parrot.java.patch (90%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => parrot}/ShoulderRidingEntity.java.patch (74%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => pig}/Pig.java.patch (88%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => rabbit}/Rabbit.java.patch (90%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => squid}/Squid.java.patch (72%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => turtle}/Turtle.java.patch (95%) rename paper-server/patches/sources/net/minecraft/world/entity/decoration/{ => painting}/Painting.java.patch (92%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => illager}/Evoker.java.patch (78%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => illager}/Illusioner.java.patch (92%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => illager}/Pillager.java.patch (73%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => illager}/SpellcasterIllager.java.patch (79%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => illager}/Vindicator.java.patch (79%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => skeleton}/AbstractSkeleton.java.patch (94%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => skeleton}/Bogged.java.patch (96%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => skeleton}/Skeleton.java.patch (88%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => skeleton}/WitherSkeleton.java.patch (86%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => spider}/CaveSpider.java.patch (76%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => spider}/Spider.java.patch (90%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => zombie}/Drowned.java.patch (88%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => zombie}/Husk.java.patch (82%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => zombie}/Zombie.java.patch (97%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => zombie}/ZombieVillager.java.patch (92%) rename paper-server/patches/sources/net/minecraft/world/entity/monster/{ => zombie}/ZombifiedPiglin.java.patch (95%) rename paper-server/patches/sources/net/minecraft/world/entity/npc/{ => villager}/AbstractVillager.java.patch (94%) rename paper-server/patches/sources/net/minecraft/world/entity/npc/{ => villager}/Villager.java.patch (95%) rename paper-server/patches/sources/net/minecraft/world/entity/npc/{ => villager}/VillagerTrades.java.patch (86%) rename paper-server/patches/sources/net/minecraft/world/entity/npc/{ => wanderingtrader}/WanderingTrader.java.patch (90%) rename paper-server/patches/sources/net/minecraft/world/entity/npc/{ => wanderingtrader}/WanderingTraderSpawner.java.patch (97%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => arrow}/AbstractArrow.java.patch (95%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => arrow}/Arrow.java.patch (82%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => arrow}/SpectralArrow.java.patch (77%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => arrow}/ThrownTrident.java.patch (90%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => hurtingprojectile}/AbstractHurtingProjectile.java.patch (81%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => hurtingprojectile}/DragonFireball.java.patch (86%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => hurtingprojectile}/LargeFireball.java.patch (93%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => hurtingprojectile}/SmallFireball.java.patch (94%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => hurtingprojectile}/WitherSkull.java.patch (93%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => hurtingprojectile}/windcharge/AbstractWindCharge.java.patch (87%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => hurtingprojectile}/windcharge/BreezeWindCharge.java.patch (83%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => hurtingprojectile}/windcharge/WindCharge.java.patch (84%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => throwableitemprojectile}/AbstractThrownPotion.java.patch (97%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => throwableitemprojectile}/Snowball.java.patch (67%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => throwableitemprojectile}/ThrownEgg.java.patch (96%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => throwableitemprojectile}/ThrownEnderpearl.java.patch (96%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => throwableitemprojectile}/ThrownExperienceBottle.java.patch (91%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => throwableitemprojectile}/ThrownLingeringPotion.java.patch (89%) rename paper-server/patches/sources/net/minecraft/world/entity/projectile/{ => throwableitemprojectile}/ThrownSplashPotion.java.patch (93%) rename paper-server/patches/sources/net/minecraft/world/entity/vehicle/{ => boat}/AbstractBoat.java.patch (94%) rename paper-server/patches/sources/net/minecraft/world/entity/vehicle/{ => boat}/AbstractChestBoat.java.patch (94%) rename paper-server/patches/sources/net/minecraft/world/entity/vehicle/{ => minecart}/AbstractMinecart.java.patch (95%) rename paper-server/patches/sources/net/minecraft/world/entity/vehicle/{ => minecart}/AbstractMinecartContainer.java.patch (93%) rename paper-server/patches/sources/net/minecraft/world/entity/vehicle/{ => minecart}/MinecartCommandBlock.java.patch (91%) rename paper-server/patches/sources/net/minecraft/world/entity/vehicle/{ => minecart}/MinecartTNT.java.patch (95%) rename paper-server/patches/sources/net/minecraft/world/entity/vehicle/{ => minecart}/NewMinecartBehavior.java.patch (95%) rename paper-server/patches/sources/net/minecraft/world/entity/vehicle/{ => minecart}/OldMinecartBehavior.java.patch (95%) diff --git a/build-data/paper.at b/build-data/paper.at index ea513cb57c3b..0f916b2b5112 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -209,7 +209,6 @@ public net.minecraft.world.entity.Entity unsetRemoved()V public net.minecraft.world.entity.Entity wasTouchingWater public net.minecraft.world.entity.ExperienceOrb count public net.minecraft.world.entity.ExperienceOrb setValue(I)V -public net.minecraft.world.entity.GlowSquid setDarkTicks(I)V public net.minecraft.world.entity.Interaction attack public net.minecraft.world.entity.Interaction getHeight()F public net.minecraft.world.entity.Interaction getResponse()Z @@ -260,71 +259,72 @@ public net.minecraft.world.entity.ai.gossip.GossipContainer$EntityGossips public net.minecraft.world.entity.ai.gossip.GossipContainer$EntityGossips ()V public net.minecraft.world.entity.ai.navigation.PathNavigation pathFinder public net.minecraft.world.entity.ambient.Bat targetPosition -public net.minecraft.world.entity.animal.AbstractSchoolingFish leader -public net.minecraft.world.entity.animal.AbstractSchoolingFish schoolSize public net.minecraft.world.entity.animal.Animal inLove public net.minecraft.world.entity.animal.Animal loveCause -public net.minecraft.world.entity.animal.Bee hivePos -public net.minecraft.world.entity.animal.Bee isRolling()Z -public net.minecraft.world.entity.animal.Bee numCropsGrownSincePollination -public net.minecraft.world.entity.animal.Bee setHasNectar(Z)V -public net.minecraft.world.entity.animal.Bee setHasStung(Z)V -public net.minecraft.world.entity.animal.Bee setRolling(Z)V -public net.minecraft.world.entity.animal.Bee stayOutOfHiveCountdown -public net.minecraft.world.entity.animal.Bee ticksWithoutNectarSinceExitingHive -public net.minecraft.world.entity.animal.Bee timeSinceSting -public net.minecraft.world.entity.animal.Cat isRelaxStateOne()Z -public net.minecraft.world.entity.animal.Cat setCollarColor(Lnet/minecraft/world/item/DyeColor;)V -public net.minecraft.world.entity.animal.Cat setRelaxStateOne(Z)V -public net.minecraft.world.entity.animal.Cat setVariant(Lnet/minecraft/core/Holder;)V -public net.minecraft.world.entity.animal.Dolphin treasurePos -public net.minecraft.world.entity.animal.Fox DATA_TRUSTED_ID_0 -public net.minecraft.world.entity.animal.Fox DATA_TRUSTED_ID_1 -public net.minecraft.world.entity.animal.Fox isDefending()Z -public net.minecraft.world.entity.animal.Fox setDefending(Z)V -public net.minecraft.world.entity.animal.Fox setFaceplanted(Z)V -public net.minecraft.world.entity.animal.Fox setSleeping(Z)V -public net.minecraft.world.entity.animal.Fox setVariant(Lnet/minecraft/world/entity/animal/Fox$Variant;)V -public net.minecraft.world.entity.animal.MushroomCow setVariant(Lnet/minecraft/world/entity/animal/MushroomCow$Variant;)V -public net.minecraft.world.entity.animal.MushroomCow stewEffects -public net.minecraft.world.entity.animal.Ocelot isTrusting()Z -public net.minecraft.world.entity.animal.Ocelot setTrusting(Z)V -public net.minecraft.world.entity.animal.Panda getEatCounter()I -public net.minecraft.world.entity.animal.Panda setEatCounter(I)V -public net.minecraft.world.entity.animal.Parrot setVariant(Lnet/minecraft/world/entity/animal/Parrot$Variant;)V -public net.minecraft.world.entity.animal.Pig setVariant(Lnet/minecraft/core/Holder;)V -public net.minecraft.world.entity.animal.Pig steering -public net.minecraft.world.entity.animal.Rabbit moreCarrotTicks -public net.minecraft.world.entity.animal.Rabbit registerGoals()V -public net.minecraft.world.entity.animal.Rabbit setVariant(Lnet/minecraft/world/entity/animal/Rabbit$Variant;)V -public net.minecraft.world.entity.animal.Salmon setVariant(Lnet/minecraft/world/entity/animal/Salmon$Variant;)V -public net.minecraft.world.entity.animal.TropicalFish getPackedVariant()I -public net.minecraft.world.entity.animal.TropicalFish setPackedVariant(I)V -public net.minecraft.world.entity.animal.Turtle goingHome -public net.minecraft.world.entity.animal.Turtle homePos -public net.minecraft.world.entity.animal.Turtle setHasEgg(Z)V public net.minecraft.world.entity.animal.allay.Allay canDuplicate()Z public net.minecraft.world.entity.animal.allay.Allay duplicateAllay()V public net.minecraft.world.entity.animal.allay.Allay duplicationCooldown public net.minecraft.world.entity.animal.allay.Allay jukeboxPos public net.minecraft.world.entity.animal.allay.Allay resetDuplicationCooldown()V public net.minecraft.world.entity.animal.axolotl.Axolotl setVariant(Lnet/minecraft/world/entity/animal/axolotl/Axolotl$Variant;)V +public net.minecraft.world.entity.animal.bee.Bee hivePos +public net.minecraft.world.entity.animal.bee.Bee isRolling()Z +public net.minecraft.world.entity.animal.bee.Bee numCropsGrownSincePollination +public net.minecraft.world.entity.animal.bee.Bee setHasNectar(Z)V +public net.minecraft.world.entity.animal.bee.Bee setHasStung(Z)V +public net.minecraft.world.entity.animal.bee.Bee setRolling(Z)V +public net.minecraft.world.entity.animal.bee.Bee stayOutOfHiveCountdown +public net.minecraft.world.entity.animal.bee.Bee ticksWithoutNectarSinceExitingHive +public net.minecraft.world.entity.animal.bee.Bee timeSinceSting +public net.minecraft.world.entity.animal.cow.MushroomCow setVariant(Lnet/minecraft/world/entity/animal/cow/MushroomCow$Variant;)V +public net.minecraft.world.entity.animal.cow.MushroomCow stewEffects +public net.minecraft.world.entity.animal.dolphin.Dolphin treasurePos +public net.minecraft.world.entity.animal.equine.AbstractHorse createInventory()V +public net.minecraft.world.entity.animal.equine.AbstractHorse inventory +public net.minecraft.world.entity.animal.equine.AbstractHorse owner +public net.minecraft.world.entity.animal.equine.Horse setVariantAndMarkings(Lnet/minecraft/world/entity/animal/equine/Variant;Lnet/minecraft/world/entity/animal/equine/Markings;)V +public net.minecraft.world.entity.animal.equine.Llama setVariant(Lnet/minecraft/world/entity/animal/equine/Llama$Variant;)V +public net.minecraft.world.entity.animal.equine.SkeletonHorse trapTime +public net.minecraft.world.entity.animal.feline.Cat isRelaxStateOne()Z +public net.minecraft.world.entity.animal.feline.Cat setCollarColor(Lnet/minecraft/world/item/DyeColor;)V +public net.minecraft.world.entity.animal.feline.Cat setRelaxStateOne(Z)V +public net.minecraft.world.entity.animal.feline.Cat setVariant(Lnet/minecraft/core/Holder;)V +public net.minecraft.world.entity.animal.feline.Ocelot isTrusting()Z +public net.minecraft.world.entity.animal.feline.Ocelot setTrusting(Z)V +public net.minecraft.world.entity.animal.fish.AbstractSchoolingFish leader +public net.minecraft.world.entity.animal.fish.AbstractSchoolingFish schoolSize +public net.minecraft.world.entity.animal.fish.Salmon setVariant(Lnet/minecraft/world/entity/animal/fish/Salmon$Variant;)V +public net.minecraft.world.entity.animal.fish.TropicalFish getPackedVariant()I +public net.minecraft.world.entity.animal.fish.TropicalFish setPackedVariant(I)V +public net.minecraft.world.entity.animal.fox.Fox DATA_TRUSTED_ID_0 +public net.minecraft.world.entity.animal.fox.Fox DATA_TRUSTED_ID_1 +public net.minecraft.world.entity.animal.fox.Fox isDefending()Z +public net.minecraft.world.entity.animal.fox.Fox setDefending(Z)V +public net.minecraft.world.entity.animal.fox.Fox setFaceplanted(Z)V +public net.minecraft.world.entity.animal.fox.Fox setSleeping(Z)V +public net.minecraft.world.entity.animal.fox.Fox setVariant(Lnet/minecraft/world/entity/animal/fox/Fox$Variant;)V public net.minecraft.world.entity.animal.frog.Frog setVariant(Lnet/minecraft/core/Holder;)V public net.minecraft.world.entity.animal.frog.Tadpole age public net.minecraft.world.entity.animal.goat.Goat DATA_HAS_LEFT_HORN public net.minecraft.world.entity.animal.goat.Goat DATA_HAS_RIGHT_HORN -public net.minecraft.world.entity.animal.horse.AbstractHorse createInventory()V -public net.minecraft.world.entity.animal.horse.AbstractHorse inventory -public net.minecraft.world.entity.animal.horse.AbstractHorse owner -public net.minecraft.world.entity.animal.horse.Horse setVariantAndMarkings(Lnet/minecraft/world/entity/animal/horse/Variant;Lnet/minecraft/world/entity/animal/horse/Markings;)V -public net.minecraft.world.entity.animal.horse.Llama setVariant(Lnet/minecraft/world/entity/animal/horse/Llama$Variant;)V -public net.minecraft.world.entity.animal.horse.SkeletonHorse trapTime public net.minecraft.world.entity.animal.nautilus.AbstractNautilus inventory +public net.minecraft.world.entity.animal.panda.Panda getEatCounter()I +public net.minecraft.world.entity.animal.panda.Panda setEatCounter(I)V +public net.minecraft.world.entity.animal.parrot.Parrot setVariant(Lnet/minecraft/world/entity/animal/parrot/Parrot$Variant;)V +public net.minecraft.world.entity.animal.pig.Pig setVariant(Lnet/minecraft/core/Holder;)V +public net.minecraft.world.entity.animal.pig.Pig steering +public net.minecraft.world.entity.animal.rabbit.Rabbit moreCarrotTicks +public net.minecraft.world.entity.animal.rabbit.Rabbit registerGoals()V +public net.minecraft.world.entity.animal.rabbit.Rabbit setVariant(Lnet/minecraft/world/entity/animal/rabbit/Rabbit$Variant;)V public net.minecraft.world.entity.animal.sniffer.Sniffer calculateDigPosition()Ljava/util/Optional; public net.minecraft.world.entity.animal.sniffer.Sniffer canDig()Z public net.minecraft.world.entity.animal.sniffer.Sniffer getExploredPositions()Ljava/util/stream/Stream; public net.minecraft.world.entity.animal.sniffer.Sniffer getState()Lnet/minecraft/world/entity/animal/sniffer/Sniffer$State; public net.minecraft.world.entity.animal.sniffer.Sniffer storeExploredPosition(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/entity/animal/sniffer/Sniffer; +public net.minecraft.world.entity.animal.squid.GlowSquid setDarkTicks(I)V +public net.minecraft.world.entity.animal.turtle.Turtle goingHome +public net.minecraft.world.entity.animal.turtle.Turtle homePos +public net.minecraft.world.entity.animal.turtle.Turtle setHasEgg(Z)V public net.minecraft.world.entity.animal.wolf.Wolf getSoundVariant()Lnet/minecraft/core/Holder; public net.minecraft.world.entity.animal.wolf.Wolf getVariant()Lnet/minecraft/core/Holder; public net.minecraft.world.entity.animal.wolf.Wolf isWet @@ -352,7 +352,7 @@ public net.minecraft.world.entity.decoration.Mannequin setDescription(Lnet/minec public net.minecraft.world.entity.decoration.Mannequin setHideDescription(Z)V public net.minecraft.world.entity.decoration.Mannequin setImmovable(Z)V public net.minecraft.world.entity.decoration.Mannequin setProfile(Lnet/minecraft/world/item/component/ResolvableProfile;)V -public net.minecraft.world.entity.decoration.Painting setVariant(Lnet/minecraft/core/Holder;)V +public net.minecraft.world.entity.decoration.painting.Painting setVariant(Lnet/minecraft/core/Holder;)V public net.minecraft.world.entity.item.FallingBlockEntity (Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/level/block/state/BlockState;)V public net.minecraft.world.entity.item.FallingBlockEntity blockState public net.minecraft.world.entity.item.FallingBlockEntity cancelDrop @@ -374,14 +374,11 @@ public net.minecraft.world.entity.monster.Creeper swell public net.minecraft.world.entity.monster.EnderMan teleport()Z public net.minecraft.world.entity.monster.EnderMan teleportTowards(Lnet/minecraft/world/entity/Entity;)Z public net.minecraft.world.entity.monster.Endermite life -public net.minecraft.world.entity.monster.Evoker getWololoTarget()Lnet/minecraft/world/entity/animal/sheep/Sheep; -public net.minecraft.world.entity.monster.Evoker setWololoTarget(Lnet/minecraft/world/entity/animal/sheep/Sheep;)V public net.minecraft.world.entity.monster.Guardian randomStrollGoal public net.minecraft.world.entity.monster.Guardian setActiveAttackTarget(I)V public net.minecraft.world.entity.monster.Guardian$GuardianAttackGoal public net.minecraft.world.entity.monster.Guardian$GuardianAttackGoal attackTime public net.minecraft.world.entity.monster.Phantom anchorPoint -public net.minecraft.world.entity.monster.Pillager inventory public net.minecraft.world.entity.monster.Ravager attackTick public net.minecraft.world.entity.monster.Ravager roarTick public net.minecraft.world.entity.monster.Ravager stunnedTick @@ -389,44 +386,47 @@ public net.minecraft.world.entity.monster.Shulker DATA_COLOR_ID public net.minecraft.world.entity.monster.Shulker getRawPeekAmount()I public net.minecraft.world.entity.monster.Shulker setAttachFace(Lnet/minecraft/core/Direction;)V public net.minecraft.world.entity.monster.Shulker setRawPeekAmount(I)V -public net.minecraft.world.entity.monster.Skeleton DATA_STRAY_CONVERSION_ID -public net.minecraft.world.entity.monster.Skeleton conversionTime -public net.minecraft.world.entity.monster.Skeleton inPowderSnowTime -public net.minecraft.world.entity.monster.SpellcasterIllager getCurrentSpell()Lnet/minecraft/world/entity/monster/SpellcasterIllager$IllagerSpell; -public net.minecraft.world.entity.monster.SpellcasterIllager$IllagerSpell public net.minecraft.world.entity.monster.Strider steering public net.minecraft.world.entity.monster.Vex hasLimitedLife public net.minecraft.world.entity.monster.Vex limitedLifeTicks public net.minecraft.world.entity.monster.Vex owner -public net.minecraft.world.entity.monster.Vindicator DOOR_BREAKING_PREDICATE -public net.minecraft.world.entity.monster.Vindicator isJohnny public net.minecraft.world.entity.monster.Witch usingTime -public net.minecraft.world.entity.monster.Zombie DATA_DROWNED_CONVERSION_ID -public net.minecraft.world.entity.monster.Zombie DOOR_BREAKING_PREDICATE -public net.minecraft.world.entity.monster.Zombie conversionTime -public net.minecraft.world.entity.monster.Zombie isSunSensitive()Z -public net.minecraft.world.entity.monster.Zombie startUnderWaterConversion(I)V -public net.minecraft.world.entity.monster.ZombieVillager DATA_CONVERTING_ID -public net.minecraft.world.entity.monster.ZombieVillager conversionStarter -public net.minecraft.world.entity.monster.ZombieVillager startConverting(Ljava/util/UUID;I)V -public net.minecraft.world.entity.monster.ZombieVillager villagerConversionTime public net.minecraft.world.entity.monster.hoglin.Hoglin cannotBeHunted public net.minecraft.world.entity.monster.hoglin.Hoglin isImmuneToZombification()Z public net.minecraft.world.entity.monster.hoglin.Hoglin timeInOverworld +public net.minecraft.world.entity.monster.illager.Evoker getWololoTarget()Lnet/minecraft/world/entity/animal/sheep/Sheep; +public net.minecraft.world.entity.monster.illager.Evoker setWololoTarget(Lnet/minecraft/world/entity/animal/sheep/Sheep;)V +public net.minecraft.world.entity.monster.illager.Pillager inventory +public net.minecraft.world.entity.monster.illager.SpellcasterIllager getCurrentSpell()Lnet/minecraft/world/entity/monster/illager/SpellcasterIllager$IllagerSpell; +public net.minecraft.world.entity.monster.illager.SpellcasterIllager$IllagerSpell +public net.minecraft.world.entity.monster.illager.Vindicator DOOR_BREAKING_PREDICATE +public net.minecraft.world.entity.monster.illager.Vindicator isJohnny public net.minecraft.world.entity.monster.piglin.AbstractPiglin isImmuneToZombification()Z public net.minecraft.world.entity.monster.piglin.AbstractPiglin timeInOverworld public net.minecraft.world.entity.monster.piglin.Piglin cannotHunt public net.minecraft.world.entity.monster.piglin.Piglin inventory public net.minecraft.world.entity.monster.piglin.Piglin isChargingCrossbow()Z +public net.minecraft.world.entity.monster.skeleton.Skeleton DATA_STRAY_CONVERSION_ID +public net.minecraft.world.entity.monster.skeleton.Skeleton conversionTime +public net.minecraft.world.entity.monster.skeleton.Skeleton inPowderSnowTime public net.minecraft.world.entity.monster.warden.WardenSpawnTracker cooldownTicks public net.minecraft.world.entity.monster.warden.WardenSpawnTracker increaseWarningLevel()V public net.minecraft.world.entity.monster.warden.WardenSpawnTracker ticksSinceLastWarning -public net.minecraft.world.entity.npc.Villager increaseMerchantCareer()V -public net.minecraft.world.entity.npc.Villager numberOfRestocksToday -public net.minecraft.world.entity.npc.Villager releaseAllPois()V -public net.minecraft.world.entity.npc.Villager setUnhappy()V -public net.minecraft.world.entity.npc.Villager updateDemand()V -public net.minecraft.world.entity.npc.WanderingTrader getWanderTarget()Lnet/minecraft/core/BlockPos; +public net.minecraft.world.entity.monster.zombie.Zombie DATA_DROWNED_CONVERSION_ID +public net.minecraft.world.entity.monster.zombie.Zombie DOOR_BREAKING_PREDICATE +public net.minecraft.world.entity.monster.zombie.Zombie conversionTime +public net.minecraft.world.entity.monster.zombie.Zombie isSunSensitive()Z +public net.minecraft.world.entity.monster.zombie.Zombie startUnderWaterConversion(I)V +public net.minecraft.world.entity.monster.zombie.ZombieVillager DATA_CONVERTING_ID +public net.minecraft.world.entity.monster.zombie.ZombieVillager conversionStarter +public net.minecraft.world.entity.monster.zombie.ZombieVillager startConverting(Ljava/util/UUID;I)V +public net.minecraft.world.entity.monster.zombie.ZombieVillager villagerConversionTime +public net.minecraft.world.entity.npc.villager.Villager increaseMerchantCareer()V +public net.minecraft.world.entity.npc.villager.Villager numberOfRestocksToday +public net.minecraft.world.entity.npc.villager.Villager releaseAllPois()V +public net.minecraft.world.entity.npc.villager.Villager setUnhappy()V +public net.minecraft.world.entity.npc.villager.Villager updateDemand()V +public net.minecraft.world.entity.npc.wanderingtrader.WanderingTrader getWanderTarget()Lnet/minecraft/core/BlockPos; public net.minecraft.world.entity.player.Abilities flyingSpeed public net.minecraft.world.entity.player.Abilities walkingSpeed public net.minecraft.world.entity.player.Inventory equipment @@ -436,20 +436,6 @@ public net.minecraft.world.entity.player.Player getFireImmuneTicks()I public net.minecraft.world.entity.player.Player hurtDir public net.minecraft.world.entity.player.Player removeEntitiesOnShoulder()V public net.minecraft.world.entity.player.Player sleepCounter -public net.minecraft.world.entity.projectile.AbstractArrow baseDamage -public net.minecraft.world.entity.projectile.AbstractArrow firedFromWeapon -public net.minecraft.world.entity.projectile.AbstractArrow getHitGroundSoundEvent()Lnet/minecraft/sounds/SoundEvent; -public net.minecraft.world.entity.projectile.AbstractArrow getPickupItem()Lnet/minecraft/world/item/ItemStack; -public net.minecraft.world.entity.projectile.AbstractArrow isInGround()Z -public net.minecraft.world.entity.projectile.AbstractArrow life -public net.minecraft.world.entity.projectile.AbstractArrow pickupItemStack -public net.minecraft.world.entity.projectile.AbstractArrow setPickupItemStack(Lnet/minecraft/world/item/ItemStack;)V -public net.minecraft.world.entity.projectile.AbstractArrow setPierceLevel(B)V -public net.minecraft.world.entity.projectile.AbstractHurtingProjectile assignDirectionalMovement(Lnet/minecraft/world/phys/Vec3;D)V -public net.minecraft.world.entity.projectile.Arrow NO_EFFECT_COLOR -public net.minecraft.world.entity.projectile.Arrow getPotionContents()Lnet/minecraft/world/item/alchemy/PotionContents; -public net.minecraft.world.entity.projectile.Arrow setPotionContents(Lnet/minecraft/world/item/alchemy/PotionContents;)V -public net.minecraft.world.entity.projectile.Arrow updateColor()V public net.minecraft.world.entity.projectile.EvokerFangs warmupDelayTicks public net.minecraft.world.entity.projectile.EyeOfEnder life public net.minecraft.world.entity.projectile.EyeOfEnder surviveAfterDeath @@ -472,7 +458,6 @@ public net.minecraft.world.entity.projectile.FishingHook setHookedEntity(Lnet/mi public net.minecraft.world.entity.projectile.FishingHook timeUntilHooked public net.minecraft.world.entity.projectile.FishingHook timeUntilLured public net.minecraft.world.entity.projectile.FishingHook$FishHookState -public net.minecraft.world.entity.projectile.LargeFireball explosionPower public net.minecraft.world.entity.projectile.Projectile hasBeenShot public net.minecraft.world.entity.projectile.Projectile leftOwner public net.minecraft.world.entity.projectile.Projectile owner @@ -481,12 +466,27 @@ public net.minecraft.world.entity.projectile.ShulkerBullet flightSteps public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaX public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaY public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaZ -public net.minecraft.world.entity.projectile.SpectralArrow duration -public net.minecraft.world.entity.projectile.ThrowableItemProjectile getDefaultItem()Lnet/minecraft/world/item/Item; -public net.minecraft.world.entity.projectile.ThrownTrident dealtDamage -public net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge explode(Lnet/minecraft/world/phys/Vec3;)V -public net.minecraft.world.entity.projectile.windcharge.BreezeWindCharge explode(Lnet/minecraft/world/phys/Vec3;)V -public net.minecraft.world.entity.projectile.windcharge.WindCharge explode(Lnet/minecraft/world/phys/Vec3;)V +public net.minecraft.world.entity.projectile.arrow.AbstractArrow baseDamage +public net.minecraft.world.entity.projectile.arrow.AbstractArrow firedFromWeapon +public net.minecraft.world.entity.projectile.arrow.AbstractArrow getHitGroundSoundEvent()Lnet/minecraft/sounds/SoundEvent; +public net.minecraft.world.entity.projectile.arrow.AbstractArrow getPickupItem()Lnet/minecraft/world/item/ItemStack; +public net.minecraft.world.entity.projectile.arrow.AbstractArrow isInGround()Z +public net.minecraft.world.entity.projectile.arrow.AbstractArrow life +public net.minecraft.world.entity.projectile.arrow.AbstractArrow pickupItemStack +public net.minecraft.world.entity.projectile.arrow.AbstractArrow setPickupItemStack(Lnet/minecraft/world/item/ItemStack;)V +public net.minecraft.world.entity.projectile.arrow.AbstractArrow setPierceLevel(B)V +public net.minecraft.world.entity.projectile.arrow.Arrow NO_EFFECT_COLOR +public net.minecraft.world.entity.projectile.arrow.Arrow getPotionContents()Lnet/minecraft/world/item/alchemy/PotionContents; +public net.minecraft.world.entity.projectile.arrow.Arrow setPotionContents(Lnet/minecraft/world/item/alchemy/PotionContents;)V +public net.minecraft.world.entity.projectile.arrow.Arrow updateColor()V +public net.minecraft.world.entity.projectile.arrow.SpectralArrow duration +public net.minecraft.world.entity.projectile.arrow.ThrownTrident dealtDamage +public net.minecraft.world.entity.projectile.hurtingprojectile.AbstractHurtingProjectile assignDirectionalMovement(Lnet/minecraft/world/phys/Vec3;D)V +public net.minecraft.world.entity.projectile.hurtingprojectile.LargeFireball explosionPower +public net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.AbstractWindCharge explode(Lnet/minecraft/world/phys/Vec3;)V +public net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.BreezeWindCharge explode(Lnet/minecraft/world/phys/Vec3;)V +public net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.WindCharge explode(Lnet/minecraft/world/phys/Vec3;)V +public net.minecraft.world.entity.projectile.throwableitemprojectile.ThrowableItemProjectile getDefaultItem()Lnet/minecraft/world/item/Item; public net.minecraft.world.entity.raid.Raid heroesOfTheVillage public net.minecraft.world.entity.raid.Raid numGroups public net.minecraft.world.entity.raid.Raid raidEvent @@ -495,17 +495,17 @@ public net.minecraft.world.entity.raid.Raid ticksActive public net.minecraft.world.entity.raid.Raid totalHealth public net.minecraft.world.entity.raid.Raider$HoldGroundAttackGoal public net.minecraft.world.entity.raid.Raids raidMap -public net.minecraft.world.entity.vehicle.AbstractBoat getStatus()Lnet/minecraft/world/entity/vehicle/AbstractBoat$Status; -public net.minecraft.world.entity.vehicle.AbstractBoat status -public net.minecraft.world.entity.vehicle.AbstractMinecartContainer lootTable -public net.minecraft.world.entity.vehicle.AbstractMinecartContainer lootTableSeed -public net.minecraft.world.entity.vehicle.MinecartCommandBlock DATA_ID_COMMAND_NAME -public net.minecraft.world.entity.vehicle.MinecartFurnace fuel -public net.minecraft.world.entity.vehicle.MinecartTNT explode(Lnet/minecraft/world/damagesource/DamageSource;D)V -public net.minecraft.world.entity.vehicle.MinecartTNT explosionPowerBase -public net.minecraft.world.entity.vehicle.MinecartTNT explosionSpeedFactor -public net.minecraft.world.entity.vehicle.MinecartTNT fuse public net.minecraft.world.entity.vehicle.VehicleEntity getDropItem()Lnet/minecraft/world/item/Item; +public net.minecraft.world.entity.vehicle.boat.AbstractBoat getStatus()Lnet/minecraft/world/entity/vehicle/boat/AbstractBoat$Status; +public net.minecraft.world.entity.vehicle.boat.AbstractBoat status +public net.minecraft.world.entity.vehicle.minecart.AbstractMinecartContainer lootTable +public net.minecraft.world.entity.vehicle.minecart.AbstractMinecartContainer lootTableSeed +public net.minecraft.world.entity.vehicle.minecart.MinecartCommandBlock DATA_ID_COMMAND_NAME +public net.minecraft.world.entity.vehicle.minecart.MinecartFurnace fuel +public net.minecraft.world.entity.vehicle.minecart.MinecartTNT explode(Lnet/minecraft/world/damagesource/DamageSource;D)V +public net.minecraft.world.entity.vehicle.minecart.MinecartTNT explosionPowerBase +public net.minecraft.world.entity.vehicle.minecart.MinecartTNT explosionSpeedFactor +public net.minecraft.world.entity.vehicle.minecart.MinecartTNT fuse public net.minecraft.world.flag.FeatureFlag mask public net.minecraft.world.flag.FeatureFlag universe public net.minecraft.world.flag.FeatureFlagRegistry names diff --git a/gradle.properties b/gradle.properties index f9b4822374ac..26c9ffea56ea 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group=io.papermc.paper -version=25w46a-R0.1-SNAPSHOT -mcVersion=25w46a +version=1.21.11-pre1-R0.1-SNAPSHOT +mcVersion=1.21.11-pre1 # This is the current API version for use in (paper-)plugin.yml files # During snapshot cycles this should be the anticipated version of the release target apiVersion=1.21.11 diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index a0261f5ffc4a..5bd8c816ef9a 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,9 +14,8 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:25w46a+build.3") + mache("io.papermc:mache:1.21.11-pre1+build.2") paperclip("io.papermc:paperclip:3.0.3") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } paperweight { @@ -42,7 +41,7 @@ paperweight { ) updatingMinecraft { - // oldPaperCommit = "a121fb9e8a925df319579b67609972a33a32a643" + oldPaperCommit = "926d6304e09d05e451668ac1915248530165007b" } } @@ -164,6 +163,7 @@ dependencies { } testImplementation("io.github.classgraph:classgraph:4.8.179") // For mob goal test + testRuntimeOnly("org.junit.platform:junit-platform-launcher") testImplementation("org.junit.jupiter:junit-jupiter:5.12.2") testImplementation("org.junit.platform:junit-platform-suite-engine:1.12.2") testImplementation("org.hamcrest:hamcrest:2.2") diff --git a/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch b/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch index 90983e700e4a..738c56efba60 100644 --- a/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/component/DataComponents.java +++ b/net/minecraft/core/component/DataComponents.java -@@ -232,10 +_,10 @@ +@@ -236,10 +_,10 @@ "map_post_processing", builder -> builder.networkSynchronized(MapPostProcessing.STREAM_CODEC) ); public static final DataComponentType CHARGED_PROJECTILES = register( @@ -13,7 +13,7 @@ ); public static final DataComponentType POTION_CONTENTS = register( "potion_contents", builder -> builder.persistent(PotionContents.CODEC).networkSynchronized(PotionContents.STREAM_CODEC).cacheEncoding() -@@ -318,7 +_,7 @@ +@@ -322,7 +_,7 @@ "pot_decorations", builder -> builder.persistent(PotDecorations.CODEC).networkSynchronized(PotDecorations.STREAM_CODEC).cacheEncoding() ); public static final DataComponentType CONTAINER = register( diff --git a/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch b/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch index 136c3096ffe6..c4e2ef021142 100644 --- a/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/network/FriendlyByteBuf.java +++ b/net/minecraft/network/FriendlyByteBuf.java -@@ -71,14 +_,20 @@ +@@ -70,14 +_,20 @@ + public class FriendlyByteBuf extends ByteBuf { - public static final int DEFAULT_NBT_QUOTA = 2097152; private final ByteBuf source; + public final java.util.@Nullable Locale adventure$locale; // Paper - track player's locale for server-side translations public static final short MAX_STRING_LENGTH = 32767; @@ -21,7 +21,7 @@ this.source = source; } -@@ -107,8 +_,13 @@ +@@ -106,8 +_,13 @@ } public void writeJsonWithCodec(Codec codec, T value) { @@ -36,7 +36,7 @@ } public static IntFunction limitValue(IntFunction function, int limit) { -@@ -553,7 +_,7 @@ +@@ -552,7 +_,7 @@ try { NbtIo.writeAnyTag(tag, new ByteBufOutputStream(buffer)); diff --git a/paper-server/patches/sources/net/minecraft/network/codec/ByteBufCodecs.java.patch b/paper-server/patches/sources/net/minecraft/network/codec/ByteBufCodecs.java.patch index 3492b4b64b0d..6d8633da13b2 100644 --- a/paper-server/patches/sources/net/minecraft/network/codec/ByteBufCodecs.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/codec/ByteBufCodecs.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/codec/ByteBufCodecs.java +++ b/net/minecraft/network/codec/ByteBufCodecs.java -@@ -423,6 +_,48 @@ +@@ -418,6 +_,48 @@ }; } diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch index aa80d580bf29..8d441064cbc2 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/game/ServerboundInteractPacket.java +++ b/net/minecraft/network/protocol/game/ServerboundInteractPacket.java -@@ -144,6 +_,15 @@ +@@ -152,6 +_,15 @@ buffer.writeEnum(this.hand); } } diff --git a/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch index 64f6c524bca6..c308208079fb 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/commands/GameRuleCommand.java +++ b/net/minecraft/server/commands/GameRuleCommand.java -@@ -33,8 +_,7 @@ +@@ -37,8 +_,7 @@ - static int setRule(CommandContext context, GameRule rule) { + private static int setRule(CommandContext context, GameRule rule) { CommandSourceStack commandSourceStack = context.getSource(); - T argument = context.getArgument("value", rule.valueClass()); - commandSourceStack.getLevel().getGameRules().set(rule, argument, context.getSource().getServer()); diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch index c48d3ffaa44f..aa4d31ec7361 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -194,7 +194,7 @@ flag, this.entityManager::updateChunkStatus, () -> server.overworld().getDataStorage() -@@ -280,7 +_,7 @@ +@@ -283,7 +_,7 @@ this.chunkSource.chunkScanner(), this.registryAccess(), server.getStructureManager(), @@ -203,7 +203,7 @@ chunkGenerator, this.chunkSource.randomState(), this, -@@ -288,9 +_,9 @@ +@@ -291,9 +_,9 @@ seed, fixerUpper ); @@ -216,7 +216,7 @@ } else { this.dragonFight = null; } -@@ -301,7 +_,15 @@ +@@ -304,7 +_,15 @@ this.waypointManager = new ServerWaypointManager(); this.environmentAttributes = EnvironmentAttributeSystem.builder().addDefaultLayers(this).build(); this.updateSkyBrightness(); @@ -233,7 +233,7 @@ @Deprecated @VisibleForTesting -@@ -313,8 +_,8 @@ +@@ -316,8 +_,8 @@ this.serverLevelData.setClearWeatherTime(clearTime); this.serverLevelData.setRainTime(weatherTime); this.serverLevelData.setThunderTime(weatherTime); @@ -244,7 +244,7 @@ } @Override -@@ -346,12 +_,25 @@ +@@ -349,12 +_,25 @@ int i = this.getGameRules().get(GameRules.PLAYERS_SLEEPING_PERCENTAGE); if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { @@ -273,7 +273,7 @@ if (this.getGameRules().get(GameRules.ADVANCE_WEATHER) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -366,9 +_,9 @@ +@@ -369,9 +_,9 @@ if (!this.isDebug() && runsNormally) { long l = this.getGameTime(); profilerFiller.push("blockTicks"); @@ -285,7 +285,7 @@ profilerFiller.pop(); } -@@ -386,7 +_,7 @@ +@@ -389,7 +_,7 @@ this.handlingTick = false; profilerFiller.pop(); @@ -294,7 +294,7 @@ if (hasActiveTickets) { this.resetEmptyTime(); } -@@ -495,11 +_,13 @@ +@@ -498,11 +_,13 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("iceandsnow"); @@ -308,7 +308,7 @@ profilerFiller.popPush("tickBlocks"); if (randomTickSpeed > 0) { -@@ -542,12 +_,12 @@ +@@ -545,12 +_,12 @@ int minBlockZ = pos.getMinBlockZ(); ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("thunder"); @@ -323,7 +323,7 @@ && !this.getBlockState(blockPos.below()).is(BlockTags.LIGHTNING_RODS); if (flag) { SkeletonHorse skeletonHorse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT); -@@ -555,7 +_,7 @@ +@@ -558,7 +_,7 @@ skeletonHorse.setTrap(true); skeletonHorse.setAge(0); skeletonHorse.setPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()); @@ -332,7 +332,7 @@ } } -@@ -563,7 +_,7 @@ +@@ -566,7 +_,7 @@ if (lightningBolt != null) { lightningBolt.snapTo(Vec3.atBottomCenterOf(blockPos)); lightningBolt.setVisualOnly(flag); @@ -341,7 +341,7 @@ } } } -@@ -577,7 +_,7 @@ +@@ -580,7 +_,7 @@ BlockPos blockPos = heightmapPos.below(); Biome biome = this.getBiome(heightmapPos).value(); if (biome.shouldFreeze(this, blockPos)) { @@ -350,7 +350,7 @@ } if (this.isRaining()) { -@@ -589,10 +_,10 @@ +@@ -592,10 +_,10 @@ if (layersValue < Math.min(i, 8)) { BlockState blockState1 = blockState.setValue(SnowLayerBlock.LAYERS, layersValue + 1); Block.pushEntitiesUp(blockState, blockState1, this, heightmapPos); @@ -363,7 +363,7 @@ } } -@@ -617,6 +_,12 @@ +@@ -620,6 +_,12 @@ } protected BlockPos findLightningTargetAround(BlockPos pos) { @@ -376,7 +376,7 @@ BlockPos heightmapPos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos); Optional optional = this.findLightningRod(heightmapPos); if (optional.isPresent()) { -@@ -624,11 +_,12 @@ +@@ -627,11 +_,12 @@ } else { AABB aabb = AABB.encapsulatingFullBlocks(heightmapPos, heightmapPos.atY(this.getMaxY() + 1)).inflate(3.0); List entitiesOfClass = this.getEntitiesOfClass( @@ -390,7 +390,7 @@ if (heightmapPos.getY() == this.getMinY() - 1) { heightmapPos = heightmapPos.above(2); } -@@ -737,8 +_,8 @@ +@@ -740,8 +_,8 @@ this.serverLevelData.setThunderTime(thunderTime); this.serverLevelData.setRainTime(rainTime); this.serverLevelData.setClearWeatherTime(clearWeatherTime); @@ -401,7 +401,7 @@ } this.oThunderLevel = this.thunderLevel; -@@ -759,6 +_,7 @@ +@@ -762,6 +_,7 @@ this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -409,7 +409,7 @@ if (this.oRainLevel != this.rainLevel) { this.server .getPlayerList() -@@ -781,14 +_,47 @@ +@@ -784,14 +_,47 @@ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -461,7 +461,7 @@ } public void resetEmptyTime() { -@@ -810,18 +_,46 @@ +@@ -813,18 +_,46 @@ } } @@ -508,7 +508,7 @@ } private void tickPassenger(Entity ridingEntity, Entity passengerEntity) { -@@ -830,10 +_,12 @@ +@@ -833,10 +_,12 @@ } else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) { passengerEntity.setOldPosAndRot(); passengerEntity.tickCount++; @@ -521,7 +521,7 @@ profilerFiller.pop(); for (Entity entity : passengerEntity.getPassengers()) { -@@ -864,6 +_,7 @@ +@@ -867,6 +_,7 @@ public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) { ServerChunkCache chunkSource = this.getChunkSource(); if (!skipSave) { @@ -529,7 +529,7 @@ if (progress != null) { progress.progressStartNoAbort(Component.translatable("menu.savingLevel")); } -@@ -880,11 +_,18 @@ +@@ -883,11 +_,18 @@ this.entityManager.autoSave(); } } @@ -549,7 +549,7 @@ } DimensionDataStorage dataStorage = this.getChunkSource().getDataStorage(); -@@ -948,18 +_,40 @@ +@@ -951,18 +_,40 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -593,7 +593,7 @@ } } -@@ -982,41 +_,120 @@ +@@ -985,41 +_,120 @@ this.entityManager.addNewEntity(player); } @@ -719,7 +719,7 @@ if (d * d + d1 * d1 + d2 * d2 < 1024.0) { serverPlayer.connection.send(new ClientboundBlockDestructionPacket(breakerId, pos, progress)); } -@@ -1091,7 +_,7 @@ +@@ -1094,7 +_,7 @@ pos.getX(), pos.getY(), pos.getZ(), @@ -728,7 +728,7 @@ this.dimension(), new ClientboundLevelEventPacket(type, pos, data, false) ); -@@ -1103,6 +_,11 @@ +@@ -1106,6 +_,11 @@ @Override public void gameEvent(Holder gameEvent, Vec3 pos, GameEvent.Context context) { @@ -740,7 +740,7 @@ this.gameEventDispatcher.post(gameEvent, pos, context); } -@@ -1115,17 +_,28 @@ +@@ -1118,17 +_,28 @@ this.getChunkSource().blockChanged(pos); this.pathTypesByPosCache.invalidate(pos); @@ -769,7 +769,7 @@ try { this.isUpdatingNavigations = true; -@@ -1137,15 +_,23 @@ +@@ -1140,15 +_,23 @@ this.isUpdatingNavigations = false; } } @@ -793,7 +793,7 @@ this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, block, null, orientation); } -@@ -1195,6 +_,44 @@ +@@ -1198,6 +_,44 @@ WeightedList blockParticles, Holder explosionSound ) { @@ -838,7 +838,7 @@ Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) { case NONE -> Explosion.BlockInteraction.KEEP; case BLOCK -> this.getDestroyType(GameRules.BLOCK_EXPLOSION_DROP_DECAY); -@@ -1203,10 +_,17 @@ +@@ -1206,10 +_,17 @@ : Explosion.BlockInteraction.KEEP; case TNT -> this.getDestroyType(GameRules.TNT_EXPLOSION_DROP_DECAY); case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; @@ -856,7 +856,7 @@ ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles; for (ServerPlayer serverPlayer : this.players) { -@@ -1215,6 +_,8 @@ +@@ -1218,6 +_,8 @@ serverPlayer.connection.send(new ClientboundExplodePacket(vec3, radius, i, optional, particleOptions, explosionSound, blockParticles)); } } @@ -865,7 +865,7 @@ } private Explosion.BlockInteraction getDestroyType(GameRule decayGameRule) { -@@ -1284,19 +_,55 @@ +@@ -1287,19 +_,55 @@ public int sendParticles( T options, double x, double y, double z, int count, double xDist, double yDist, double zDist, double speed ) { @@ -924,7 +924,7 @@ if (this.sendParticles(serverPlayer, overrideLimiter, x, y, z, clientboundLevelParticlesPacket)) { i++; } -@@ -1380,7 +_,7 @@ +@@ -1383,7 +_,7 @@ } public @Nullable BlockPos findNearestMapStructure(TagKey structureTag, BlockPos pos, int radius, boolean skipKnownStructures) { @@ -933,7 +933,7 @@ return null; } else { Optional> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag); -@@ -1432,10 +_,36 @@ +@@ -1435,10 +_,36 @@ @Override public @Nullable MapItemSavedData getMapData(MapId mapId) { @@ -971,7 +971,7 @@ this.getServer().overworld().getDataStorage().set(MapItemSavedData.type(mapId), data); } -@@ -1445,7 +_,19 @@ +@@ -1448,7 +_,19 @@ @Override public void setRespawnData(LevelData.RespawnData respawnData) { @@ -992,7 +992,7 @@ } @Override -@@ -1482,6 +_,11 @@ +@@ -1485,6 +_,11 @@ this.debugSynchronizers.dropPoi(blockPos); })); optional1.ifPresent(holder -> this.getServer().execute(() -> { @@ -1004,7 +1004,7 @@ PoiRecord poiRecord = this.getPoiManager().add(blockPos, (Holder)holder); if (poiRecord != null) { this.debugSynchronizers.registerPoi(poiRecord); -@@ -1635,12 +_,12 @@ +@@ -1638,12 +_,12 @@ } public boolean isFlat() { @@ -1019,7 +1019,7 @@ } public @Nullable EndDragonFight getDragonFight() { -@@ -1690,6 +_,7 @@ +@@ -1693,6 +_,7 @@ @Override public LevelEntityGetter getEntities() { @@ -1027,7 +1027,7 @@ return this.entityManager.getEntityGetter(); } -@@ -1805,6 +_,28 @@ +@@ -1808,6 +_,28 @@ return this.serverLevelData.getGameRules(); } @@ -1056,7 +1056,7 @@ @Override public CrashReportCategory fillReportDetails(CrashReport report) { CrashReportCategory crashReportCategory = super.fillReportDetails(report); -@@ -1849,6 +_,7 @@ +@@ -1852,6 +_,7 @@ if (entity instanceof WaypointTransmitter waypointTransmitter && waypointTransmitter.isTransmittingWaypoint()) { ServerLevel.this.getWaypointManager().trackWaypoint(waypointTransmitter); } @@ -1064,7 +1064,7 @@ } @Override -@@ -1862,17 +_,24 @@ +@@ -1865,17 +_,24 @@ @Override public void onTickingStart(Entity entity) { @@ -1090,7 +1090,7 @@ if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.add(serverPlayer); if (serverPlayer.isReceivingWaypoints()) { -@@ -1887,7 +_,7 @@ +@@ -1890,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1099,7 +1099,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1904,10 +_,52 @@ +@@ -1907,10 +_,52 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -1152,7 +1152,7 @@ ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); -@@ -1916,7 +_,7 @@ +@@ -1919,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1161,7 +1161,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1934,6 +_,15 @@ +@@ -1937,6 +_,15 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); ServerLevel.this.debugSynchronizers.dropEntity(entity); @@ -1177,7 +1177,7 @@ } @Override -@@ -1941,4 +_,24 @@ +@@ -1944,4 +_,24 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::move); } } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index a4f65f94f3c2..6176bf429b47 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -227,7 +227,7 @@ + this.joining = false; + } + // CraftBukkit end - this.tickClientLoadTimeout(); + this.connection.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); @@ -579,9 +_,18 @@ @@ -969,8 +969,8 @@ - return super.isInvulnerableTo(level, damageSource) + return (super.isInvulnerableTo(level, damageSource) // Paper - disable player cramming; || this.isChangingDimension() && !damageSource.is(DamageTypes.ENDER_PEARL) -- || !this.hasClientLoaded(); -+ || !this.hasClientLoaded()) || (!this.level().paperConfig().collisions.allowPlayerCrammingDamage && damageSource.is(DamageTypes.CRAMMING)); // Paper - disable player cramming; +- || !this.connection.hasClientLoaded(); ++ || !this.connection.hasClientLoaded()) || (!this.level().paperConfig().collisions.allowPlayerCrammingDamage && damageSource.is(DamageTypes.CRAMMING)); // Paper - disable player cramming; } @Override diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 4f580de70e15..6ca72d6b2ed8 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -88,7 +88,7 @@ @@ -149,6 +_,7 @@ public void handleBlockBreakAction(BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction face, int maxBuildHeight, int sequence) { - if (!this.player.canInteractWithBlock(pos, 1.0)) { + if (!this.player.isWithinBlockInteractionRange(pos, 1.0)) { + if (true) return; // Paper - Don't allow digging into unloaded chunks; Don't notify if unreasonably far away this.debugLogging(pos, false, sequence, "too far"); } else if (pos.getY() > maxBuildHeight) { diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 4e550a00dc5b..af52efdcb93f 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -39,7 +39,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements GameProtocols.Context, -@@ -233,7 +_,9 @@ +@@ -234,7 +_,9 @@ private int tickCount; private int ackBlockChangesUpTo = -1; private final TickThrottler chatSpamThrottler = new TickThrottler(20, 200); @@ -49,7 +49,7 @@ private double firstGoodX; private double firstGoodY; private double firstGoodZ; -@@ -257,13 +_,32 @@ +@@ -258,7 +_,23 @@ private int receivedMovePacketCount; private int knownMovePacketCount; private boolean receivedMovementThisTick; @@ -73,16 +73,17 @@ private SignedMessageChain.Decoder signedMessageDecoder; private final LastSeenMessagesValidator lastSeenMessages = new LastSeenMessagesValidator(20); private int nextChatIndex; - private final MessageSignatureCache messageSignatureCache = MessageSignatureCache.createDefault(); - private final FutureChain chatMessageChain; +@@ -267,6 +_,9 @@ private boolean waitingForSwitchToConfig; + private boolean waitingForRespawn; + private int clientLoadedTimeoutTimer; + private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80); // Paper - Limit client sign length + private final io.papermc.paper.event.packet.ClientTickEndEvent tickEndEvent; // Paper - add client tick end event + public final io.papermc.paper.connection.PaperPlayerGameConnection playerGameConnection; // Paper public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player, CommonListenerCookie cookie) { super(server, connection, cookie); -@@ -272,8 +_,22 @@ +@@ -276,8 +_,22 @@ player.connection = this; player.getTextFilter().join(); this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(player.getUUID(), server::enforceSecureProfile); @@ -107,7 +108,7 @@ @Override public void tick() { -@@ -286,11 +_,13 @@ +@@ -290,11 +_,13 @@ this.keepConnectionAlive(); this.chatSpamThrottler.tick(); this.dropSpamThrottler.tick(); @@ -122,7 +123,7 @@ } } } -@@ -306,8 +_,8 @@ +@@ -310,8 +_,8 @@ this.knownMovePacketCount = this.receivedMovePacketCount; if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger() && !this.player.isDeadOrDying()) { if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player)) { @@ -133,7 +134,7 @@ return true; } } else { -@@ -325,8 +_,8 @@ +@@ -329,8 +_,8 @@ this.vehicleLastGoodZ = this.lastVehicle.getZ(); if (this.clientVehicleIsFloating && this.lastVehicle.getControllingPassenger() == this.player) { if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle)) { @@ -144,7 +145,7 @@ return true; } } else { -@@ -339,6 +_,12 @@ +@@ -343,6 +_,12 @@ this.aboveGroundVehicleTickCount = 0; } @@ -157,7 +158,7 @@ return false; } -@@ -404,11 +_,37 @@ +@@ -408,11 +_,37 @@ @Override public void handlePlayerInput(ServerboundPlayerInputPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -182,7 +183,7 @@ + } + // Paper end - PlayerToggleSneakEvent this.player.setLastClientInput(packet.input()); - if (this.player.hasClientLoaded()) { + if (this.hasClientLoaded()) { this.player.resetLastActionTime(); - this.player.setShiftKeyDown(packet.input().shift()); - } @@ -197,13 +198,13 @@ } private static boolean containsInvalidValues(double x, double y, double z, float yRot, float xRot) { -@@ -427,17 +_,29 @@ +@@ -431,17 +_,29 @@ public void handleMoveVehicle(ServerboundMoveVehiclePacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (containsInvalidValues(packet.position().x(), packet.position().y(), packet.position().z(), packet.yRot(), packet.xRot())) { - this.disconnect(Component.translatable("multiplayer.disconnect.invalid_vehicle_movement")); + this.disconnect(Component.translatable("multiplayer.disconnect.invalid_vehicle_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_VEHICLE_MOVEMENT); // Paper - kick event cause - } else if (!this.updateAwaitingTeleport() && this.player.hasClientLoaded()) { + } else if (!this.updateAwaitingTeleport() && this.hasClientLoaded()) { Entity rootVehicle = this.player.getRootVehicle(); + // Paper start - Don't allow vehicle movement from players while teleporting + if (this.awaitingPositionFromClient != null || this.player.isImmobile() || rootVehicle.isRemoved()) { @@ -231,7 +232,7 @@ float f = Mth.wrapDegrees(packet.yRot()); float f1 = Mth.wrapDegrees(packet.xRot()); double d3 = d - this.vehicleFirstGoodX; -@@ -445,16 +_,61 @@ +@@ -449,16 +_,61 @@ double d5 = d2 - this.vehicleFirstGoodZ; double d6 = rootVehicle.getDeltaMovement().lengthSqr(); double d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -297,7 +298,7 @@ boolean flag = rootVehicle.verticalCollisionBelow; if (rootVehicle instanceof LivingEntity livingEntity && livingEntity.onClimbable()) { livingEntity.resetFallDistance(); -@@ -471,7 +_,7 @@ +@@ -475,7 +_,7 @@ d5 = d2 - rootVehicle.getZ(); d7 = d3 * d3 + d4 * d4 + d5 * d5; boolean flag1 = false; @@ -306,7 +307,7 @@ flag1 = true; LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", rootVehicle.getPlainTextName(), this.player.getPlainTextName(), Math.sqrt(d7)); } -@@ -485,6 +_,57 @@ +@@ -489,6 +_,57 @@ } rootVehicle.absSnapTo(d, d1, d2, f, f1); @@ -364,7 +365,7 @@ this.player.level().getChunkSource().move(this.player); Vec3 vec3 = new Vec3(rootVehicle.getX() - x, rootVehicle.getY() - y, rootVehicle.getZ() - z); this.handlePlayerKnownMovement(vec3); -@@ -515,7 +_,7 @@ +@@ -519,7 +_,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (packet.getId() == this.awaitingTeleport) { if (this.awaitingPositionFromClient == null) { @@ -373,7 +374,7 @@ return; } -@@ -532,12 +_,20 @@ +@@ -536,12 +_,20 @@ this.lastGoodZ = this.awaitingPositionFromClient.z; this.player.hasChangedDimension(); this.awaitingPositionFromClient = null; @@ -391,10 +392,10 @@ + final io.papermc.paper.event.player.PlayerClientLoadedWorldEvent event = new io.papermc.paper.event.player.PlayerClientLoadedWorldEvent(this.player.getBukkitEntity(), false); + event.callEvent(); + // Paper end - PlayerLoadedWorldEvent - this.player.setClientLoaded(true); + this.markClientLoaded(); } -@@ -559,6 +_,7 @@ +@@ -563,6 +_,7 @@ @Override public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -402,7 +403,7 @@ this.player.getRecipeBook().setBookSetting(packet.getBookType(), packet.isOpen(), packet.isFiltering()); } -@@ -574,25 +_,110 @@ +@@ -578,25 +_,110 @@ } } @@ -518,7 +519,7 @@ } ); } -@@ -600,7 +_,7 @@ +@@ -604,7 +_,7 @@ @Override public void handleSetCommandBlock(ServerboundSetCommandBlockPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -527,7 +528,7 @@ this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock baseCommandBlock = null; -@@ -661,7 +_,7 @@ +@@ -665,7 +_,7 @@ @Override public void handleSetCommandMinecart(ServerboundSetCommandMinecartPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -536,7 +537,7 @@ this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock commandBlock = packet.getCommandBlock(this.player.level()); -@@ -699,11 +_,11 @@ +@@ -703,11 +_,11 @@ boolean flag = this.player.hasInfiniteMaterials() && packet.includeData(); ItemStack cloneItemStack = blockState.getCloneItemStack(serverLevel, blockPos, flag); if (!cloneItemStack.isEmpty()) { @@ -550,8 +551,8 @@ } } } -@@ -730,27 +_,40 @@ - if (entityOrPart != null && this.player.canInteractWithEntity(entityOrPart, 3.0)) { +@@ -734,27 +_,40 @@ + if (entityOrPart != null && this.player.isWithinEntityInteractionRange(entityOrPart, 3.0)) { ItemStack pickResult = entityOrPart.getPickResult(); if (pickResult != null && !pickResult.isEmpty()) { - this.tryPickItem(pickResult); @@ -597,7 +598,7 @@ } } -@@ -928,6 +_,13 @@ +@@ -932,6 +_,13 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); int item = packet.getItem(); if (this.player.containerMenu instanceof MerchantMenu merchantMenu) { @@ -611,7 +612,7 @@ if (!merchantMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, merchantMenu); return; -@@ -940,6 +_,51 @@ +@@ -944,6 +_,51 @@ @Override public void handleEditBook(ServerboundEditBookPacket packet) { @@ -663,7 +664,7 @@ int slot = packet.slot(); if (Inventory.isHotbarSlot(slot) || slot == 40) { List list = Lists.newArrayList(); -@@ -954,10 +_,14 @@ +@@ -958,10 +_,14 @@ } private void updateBookContents(List pages, int index) { @@ -679,7 +680,7 @@ } } -@@ -970,7 +_,8 @@ +@@ -974,7 +_,8 @@ itemStack.set( DataComponents.WRITTEN_BOOK_CONTENT, new WrittenBookContent(this.filterableFromOutgoing(title), this.player.getPlainTextName(), 0, list, true) ); @@ -689,7 +690,7 @@ } } -@@ -1018,27 +_,35 @@ +@@ -1022,27 +_,35 @@ public void handleMovePlayer(ServerboundMovePlayerPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (containsInvalidValues(packet.getX(0.0), packet.getY(0.0), packet.getZ(0.0), packet.getYRot(0.0F), packet.getXRot(0.0F))) { @@ -703,7 +704,7 @@ this.resetPosition(); } - if (this.player.hasClientLoaded()) { + if (this.hasClientLoaded()) { - float f = Mth.wrapDegrees(packet.getYRot(this.player.getYRot())); - float f1 = Mth.wrapDegrees(packet.getXRot(this.player.getXRot())); + float f = Mth.wrapDegrees(packet.getYRot(this.player.getYRot())); final float toYaw = f; // Paper - OBFHELPER @@ -732,7 +733,7 @@ double x = this.player.getX(); double y = this.player.getY(); double z = this.player.getZ(); -@@ -1047,6 +_,16 @@ +@@ -1051,6 +_,16 @@ double d5 = d2 - this.firstGoodZ; double d6 = this.player.getDeltaMovement().lengthSqr(); double d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -749,7 +750,7 @@ if (this.player.isSleeping()) { if (d7 > 1.0) { this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); -@@ -1056,36 +_,108 @@ +@@ -1060,36 +_,108 @@ if (serverLevel.tickRateManager().runsNormally()) { this.receivedMovePacketCount++; int i = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -868,7 +869,7 @@ double verticalDelta = d4; d3 = d - this.player.getX(); d4 = d1 - this.player.getY(); -@@ -1095,20 +_,100 @@ +@@ -1099,21 +_,101 @@ d5 = d2 - this.player.getZ(); d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -879,7 +880,8 @@ + && d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold // Spigot && !this.player.isSleeping() && !this.player.isCreative() - && !this.player.isSpectator()) { + && !this.player.isSpectator() + && !this.player.isInPostImpulseGraceTime()) { - flag2 = true; + // Paper start - Add fail move event + io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_WRONGLY, @@ -978,7 +980,7 @@ this.player.absSnapTo(d, d1, d2, f, f1); boolean isAutoSpinAttack = this.player.isAutoSpinAttack(); this.clientIsFloating = verticalDelta >= -0.03125 -@@ -1143,7 +_,7 @@ +@@ -1148,7 +_,7 @@ this.lastGoodY = this.player.getY(); this.lastGoodZ = this.player.getZ(); } else { @@ -987,7 +989,7 @@ this.player.doCheckFallDamage(this.player.getX() - x, this.player.getY() - y, this.player.getZ() - z, packet.isOnGround()); this.player.removeLatestMovementRecording(); } -@@ -1178,6 +_,7 @@ +@@ -1183,6 +_,7 @@ this.player.getXRot() ); } @@ -995,7 +997,7 @@ return true; } else { -@@ -1201,10 +_,77 @@ +@@ -1206,10 +_,77 @@ } public void teleport(double x, double y, double z, float yRot, float xRot) { @@ -1074,7 +1076,7 @@ this.awaitingTeleportTime = this.tickCount; if (++this.awaitingTeleport == Integer.MAX_VALUE) { this.awaitingTeleport = 0; -@@ -1212,12 +_,20 @@ +@@ -1217,12 +_,20 @@ this.player.teleportSetPosition(posMoveRotation, relatives); this.awaitingPositionFromClient = this.player.position(); @@ -1092,10 +1094,10 @@ public void handlePlayerAction(ServerboundPlayerActionPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); + if (this.player.isImmobile()) return; // CraftBukkit - if (this.player.hasClientLoaded()) { + if (this.hasClientLoaded()) { BlockPos pos = packet.getPos(); this.player.resetLastActionTime(); -@@ -1242,32 +_,95 @@ +@@ -1247,32 +_,95 @@ case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { ItemStack itemInHand1 = this.player.getItemInHand(InteractionHand.OFF_HAND); @@ -1193,7 +1195,7 @@ return; default: throw new IllegalArgumentException("Invalid player action"); -@@ -1285,9 +_,31 @@ +@@ -1290,9 +_,31 @@ } } @@ -1222,10 +1224,10 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); + if (this.player.isImmobile()) return; // CraftBukkit + if (!this.checkLimit(packet.timestamp)) return; // Spigot - check limit - if (this.player.hasClientLoaded()) { + if (this.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel serverLevel = this.player.level(); -@@ -1296,6 +_,11 @@ +@@ -1301,6 +_,11 @@ if (itemInHand.isItemEnabled(serverLevel.enabledFeatures())) { BlockHitResult hitResult = packet.getHitResult(); Vec3 location = hitResult.getLocation(); @@ -1235,9 +1237,9 @@ + } + // Paper end - improve distance check BlockPos blockPos = hitResult.getBlockPos(); - if (this.player.canInteractWithBlock(blockPos, 1.0)) { + if (this.player.isWithinBlockInteractionRange(blockPos, 1.0)) { Vec3 vec3 = location.subtract(Vec3.atCenterOf(blockPos)); -@@ -1305,7 +_,8 @@ +@@ -1310,7 +_,8 @@ this.player.resetLastActionTime(); int maxY = this.player.level().getMaxY(); if (blockPos.getY() <= maxY) { @@ -1247,7 +1249,7 @@ InteractionResult interactionResult = this.player.gameMode.useItemOn(this.player, serverLevel, itemInHand, hand, hitResult); if (interactionResult.consumesAction()) { CriteriaTriggers.ANY_BLOCK_USE.trigger(this.player, hitResult.getBlockPos(), itemInHand.copy()); -@@ -1318,10 +_,10 @@ +@@ -1323,10 +_,10 @@ Component component = Component.translatable("build.tooHigh", maxY).withStyle(ChatFormatting.RED); this.player.sendSystemMessage(component, true); } else if (interactionResult instanceof InteractionResult.Success success @@ -1260,7 +1262,7 @@ } else { Component component1 = Component.translatable("build.tooHigh", maxY).withStyle(ChatFormatting.RED); this.player.sendSystemMessage(component1, true); -@@ -1329,13 +_,8 @@ +@@ -1334,13 +_,8 @@ this.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos)); this.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos.relative(direction))); @@ -1276,16 +1278,16 @@ } } } -@@ -1345,6 +_,8 @@ +@@ -1350,6 +_,8 @@ @Override public void handleUseItem(ServerboundUseItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); + if (this.player.isImmobile()) return; // CraftBukkit + if (!this.checkLimit(packet.timestamp)) return; // Spigot - check limit - if (this.player.hasClientLoaded()) { + if (this.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel serverLevel = this.player.level(); -@@ -1358,6 +_,48 @@ +@@ -1363,6 +_,48 @@ this.player.absSnapRotationTo(f, f1); } @@ -1334,7 +1336,7 @@ if (this.player.gameMode.useItem(this.player, serverLevel, itemInHand, hand) instanceof InteractionResult.Success success && success.swingSource() == InteractionResult.SwingSource.SERVER) { this.player.swing(hand, true); -@@ -1373,7 +_,7 @@ +@@ -1378,7 +_,7 @@ for (ServerLevel serverLevel : this.server.getAllLevels()) { Entity entity = packet.getEntity(serverLevel); if (entity != null) { @@ -1343,7 +1345,7 @@ return; } } -@@ -1390,24 +_,50 @@ +@@ -1395,24 +_,50 @@ @Override public void onDisconnect(DisconnectionDetails details) { @@ -1396,7 +1398,7 @@ throw new IllegalArgumentException("Expected packet sequence nr >= 0"); } else { this.ackBlockChangesUpTo = Math.max(sequence, this.ackBlockChangesUpTo); -@@ -1417,20 +_,38 @@ +@@ -1422,20 +_,38 @@ @Override public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1435,7 +1437,7 @@ Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { this.tryHandleChat(packet.message(), false, () -> { -@@ -1442,25 +_,45 @@ +@@ -1447,25 +_,45 @@ return; } @@ -1488,7 +1490,7 @@ ParseResults parseResults = this.parseCommand(command); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseResults)) { LOGGER.error( -@@ -1477,28 +_,57 @@ +@@ -1482,28 +_,57 @@ Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { this.tryHandleChat(packet.command(), true, () -> { @@ -1549,7 +1551,7 @@ } private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) { -@@ -1562,14 +_,20 @@ +@@ -1567,14 +_,20 @@ return dispatcher.parse(command, this.player.createCommandSourceStack()); } @@ -1574,7 +1576,7 @@ } } -@@ -1581,7 +_,7 @@ +@@ -1586,7 +_,7 @@ var10000 = Optional.of(lastSeenMessages); } catch (LastSeenMessagesValidator.ValidationException var5) { LOGGER.error("Failed to validate message acknowledgements from {}: {}", this.player.getPlainTextName(), var5.getMessage()); @@ -1583,7 +1585,7 @@ return Optional.empty(); } -@@ -1599,22 +_,81 @@ +@@ -1604,22 +_,81 @@ return false; } @@ -1671,7 +1673,7 @@ } } -@@ -1625,7 +_,7 @@ +@@ -1630,7 +_,7 @@ this.lastSeenMessages.applyOffset(packet.offset()); } catch (LastSeenMessagesValidator.ValidationException var5) { LOGGER.error("Failed to validate message acknowledgement offset from {}: {}", this.player.getPlainTextName(), var5.getMessage()); @@ -1680,7 +1682,7 @@ } } } -@@ -1633,7 +_,40 @@ +@@ -1638,7 +_,40 @@ @Override public void handleAnimate(ServerboundSwingPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1721,10 +1723,10 @@ this.player.swing(packet.getHand()); } -@@ -1641,6 +_,22 @@ +@@ -1646,6 +_,21 @@ public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); - if (this.player.hasClientLoaded()) { + if (this.hasClientLoaded()) { + // CraftBukkit start + if (this.player.isRemoved()) return; + switch (packet.getAction()) { @@ -1740,11 +1742,10 @@ + } + } + // CraftBukkit end -+ this.player.resetLastActionTime(); switch (packet.getAction()) { case START_SPRINTING: -@@ -1685,6 +_,14 @@ +@@ -1690,6 +_,14 @@ } public void sendPlayerChatMessage(PlayerChatMessage chatMessage, ChatType.Bound boundChatType) { @@ -1759,7 +1760,7 @@ this.send( new ClientboundPlayerChatPacket( this.nextChatIndex++, -@@ -1707,9 +_,11 @@ +@@ -1712,9 +_,11 @@ } if (i > 4096) { @@ -1772,7 +1773,7 @@ } public void sendDisguisedChatMessage(Component message, ChatType.Bound boundChatType) { -@@ -1720,6 +_,17 @@ +@@ -1725,6 +_,17 @@ return this.connection.getRemoteAddress(); } @@ -1790,12 +1791,12 @@ public void switchToConfig() { this.waitingForSwitchToConfig = true; this.removePlayerFromWorld(); -@@ -1735,9 +_,16 @@ +@@ -1740,9 +_,16 @@ @Override public void handleInteract(ServerboundInteractPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); + if (this.player.isImmobile()) return; // CraftBukkit - if (this.player.hasClientLoaded()) { + if (this.hasClientLoaded()) { final ServerLevel serverLevel = this.player.level(); final Entity target = packet.getTarget(serverLevel); + // Spigot start @@ -1807,12 +1808,12 @@ this.player.resetLastActionTime(); this.player.setShiftKeyDown(packet.isUsingSecondaryAction()); if (target != null) { -@@ -1746,16 +_,54 @@ +@@ -1751,16 +_,54 @@ } AABB boundingBox = target.getBoundingBox(); -- if (this.player.canInteractWithEntity(boundingBox, 3.0)) { -+ if (this.player.canInteractWithEntity(boundingBox, io.papermc.paper.configuration.GlobalConfiguration.get().misc.clientInteractionLeniencyDistance.or(3.0))) { // Paper - configurable lenience value for interact range +- if (packet.isWithinRange(this.player, boundingBox, 3.0)) { ++ if (packet.isWithinRange(this.player, boundingBox, io.papermc.paper.configuration.GlobalConfiguration.get().misc.clientInteractionLeniencyDistance.or(3.0))) { // Paper - configurable lenience value for interact range packet.dispatch( new ServerboundInteractPacket.Handler() { - private void performInteraction(InteractionHand hand, ServerGamePacketListenerImpl.EntityInteraction entityInteraction) { @@ -1867,7 +1868,7 @@ ItemStack itemStack1 = success.wasItemInteraction() ? itemStack : ItemStack.EMPTY; CriteriaTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(ServerGamePacketListenerImpl.this.player, itemStack1, target); if (success.swingSource() == InteractionResult.SwingSource.SERVER) { -@@ -1767,13 +_,13 @@ +@@ -1772,13 +_,13 @@ @Override public void onInteraction(InteractionHand hand) { @@ -1883,7 +1884,7 @@ ); } -@@ -1781,7 +_,7 @@ +@@ -1786,7 +_,7 @@ public void onAttack() { if (!(target instanceof ItemEntity) && !(target instanceof ExperienceOrb) @@ -1892,7 +1893,7 @@ && !(target instanceof AbstractArrow abstractArrow && !abstractArrow.isAttackable())) { ItemStack itemInHand = ServerGamePacketListenerImpl.this.player.getItemInHand(InteractionHand.MAIN_HAND); if (itemInHand.isItemEnabled(serverLevel.enabledFeatures())) { -@@ -1790,7 +_,7 @@ +@@ -1795,7 +_,7 @@ } } } else { @@ -1901,7 +1902,7 @@ ServerGamePacketListenerImpl.LOGGER .warn("Player {} tried to attack an invalid entity", ServerGamePacketListenerImpl.this.player.getPlainTextName()); } -@@ -1799,6 +_,27 @@ +@@ -1804,6 +_,27 @@ ); } } @@ -1929,22 +1930,23 @@ } } -@@ -1811,7 +_,7 @@ +@@ -1816,7 +_,7 @@ case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; - this.player = this.server.getPlayerList().respawn(this.player, true, Entity.RemovalReason.CHANGED_DIMENSION); + this.player = this.server.getPlayerList().respawn(this.player, true, Entity.RemovalReason.CHANGED_DIMENSION, RespawnReason.END_PORTAL); // CraftBukkit this.resetPosition(); + this.restartClientLoadTimerAfterRespawn(); CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); - } else { -@@ -1819,11 +_,11 @@ +@@ -1825,12 +_,12 @@ return; } - this.player = this.server.getPlayerList().respawn(this.player, false, Entity.RemovalReason.KILLED); + this.player = this.server.getPlayerList().respawn(this.player, false, Entity.RemovalReason.KILLED, RespawnReason.DEATH); // CraftBukkit this.resetPosition(); + this.restartClientLoadTimerAfterRespawn(); if (this.server.isHardcore()) { - this.player.setGameMode(GameType.SPECTATOR); - this.player.level().getGameRules().set(GameRules.SPECTATORS_GENERATE_CHUNKS, false, this.server); @@ -1953,7 +1955,7 @@ } } break; -@@ -1834,16 +_,27 @@ +@@ -1841,16 +_,27 @@ @Override public void handleContainerClose(ServerboundContainerClosePacket packet) { @@ -1983,7 +1985,7 @@ this.player.containerMenu.sendAllDataToRemote(); } else if (!this.player.containerMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); -@@ -1859,7 +_,298 @@ +@@ -1866,7 +_,298 @@ } else { boolean flag = packet.stateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -2283,7 +2285,7 @@ for (Entry entry : Int2ObjectMaps.fastIterable(packet.changedSlots())) { this.player.containerMenu.setRemoteSlotUnsafe(entry.getIntKey(), entry.getValue()); -@@ -1872,6 +_,8 @@ +@@ -1879,6 +_,8 @@ } else { this.player.containerMenu.broadcastChanges(); } @@ -2292,7 +2294,7 @@ } } } -@@ -1879,6 +_,14 @@ +@@ -1886,6 +_,14 @@ @Override public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) { @@ -2307,7 +2309,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); this.player.resetLastActionTime(); if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) { -@@ -1895,9 +_,44 @@ +@@ -1902,9 +_,44 @@ return; } @@ -2353,7 +2355,7 @@ if (postPlaceAction == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) { this.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, recipeFromDisplay.display().display())); } -@@ -1911,6 +_,7 @@ +@@ -1918,6 +_,7 @@ @Override public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2361,7 +2363,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -1920,6 +_,7 @@ +@@ -1927,6 +_,7 @@ if (flag) { this.player.containerMenu.broadcastChanges(); } @@ -2369,7 +2371,7 @@ } } } -@@ -1936,10 +_,48 @@ +@@ -1943,10 +_,48 @@ boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45; boolean flag2 = itemStack.isEmpty() || itemStack.getCount() <= itemStack.getMaxStackSize(); @@ -2418,7 +2420,7 @@ } else if (flag && flag2) { if (this.dropSpamThrottler.isUnderThreshold()) { this.dropSpamThrottler.increment(); -@@ -1953,15 +_,38 @@ +@@ -1960,15 +_,38 @@ @Override public void handleSignUpdate(ServerboundSignUpdatePacket packet) { @@ -2458,7 +2460,7 @@ if (!(serverLevel.getBlockEntity(pos) instanceof SignBlockEntity signBlockEntity)) { return; } -@@ -1973,14 +_,32 @@ +@@ -1980,14 +_,32 @@ @Override public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2492,7 +2494,7 @@ if (this.player.isModelPartShown(PlayerModelPart.HAT) != isModelPartShown) { this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player)); } -@@ -1996,7 +_,7 @@ +@@ -2003,7 +_,7 @@ packet.difficulty().getDisplayName() ); } else { @@ -2501,7 +2503,7 @@ } } -@@ -2010,7 +_,7 @@ +@@ -2017,7 +_,7 @@ packet.mode().getShortDisplayName().getString() ); } else { @@ -2510,7 +2512,7 @@ } } -@@ -2030,7 +_,7 @@ +@@ -2037,7 +_,7 @@ ProfilePublicKey.Data data2 = data.profilePublicKey(); if (!Objects.equals(data1, data2)) { if (data1 != null && data2.expiresAt().isBefore(data1.expiresAt())) { @@ -2519,7 +2521,7 @@ } else { try { SignatureValidator signatureValidator = this.server.services().profileKeySignatureValidator(); -@@ -2041,8 +_,8 @@ +@@ -2048,8 +_,8 @@ this.resetPlayerChatState(data.validate(this.player.getGameProfile(), signatureValidator)); } catch (ProfilePublicKey.ValidationException var6) { @@ -2530,7 +2532,7 @@ } } } -@@ -2053,11 +_,13 @@ +@@ -2060,11 +_,13 @@ if (!this.waitingForSwitchToConfig) { throw new IllegalStateException("Client acknowledged config, but none was requested"); } else { @@ -2545,7 +2547,7 @@ } } -@@ -2075,27 +_,32 @@ +@@ -2082,27 +_,32 @@ private void resetPlayerChatState(RemoteChatSession chatSession) { this.chatSession = chatSession; @@ -2579,7 +2581,7 @@ if (!this.receivedMovementThisTick) { this.player.setKnownMovement(Vec3.ZERO); } -@@ -2126,4 +_,80 @@ +@@ -2156,4 +_,80 @@ interface EntityInteraction { InteractionResult run(ServerPlayer player, Entity entity, InteractionHand hand); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch index 9ee538e79af1..54535b61d022 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -188,6 +_,7 @@ +@@ -189,6 +_,7 @@ import org.slf4j.Logger; public class EntityType implements FeatureElement, EntityTypeTest { @@ -8,7 +8,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); private final Holder.Reference> builtInRegistryHolder = BuiltInRegistries.ENTITY_TYPE.createIntrusiveHolder(this); public static final Codec> CODEC = BuiltInRegistries.ENTITY_TYPE.byNameCodec(); -@@ -1289,6 +_,22 @@ +@@ -1290,6 +_,22 @@ boolean shouldOffsetY, boolean shouldOffsetYMore ) { @@ -31,7 +31,7 @@ Consumer consumer; if (spawnedFrom != null) { consumer = createDefaultStackConfig(level, spawnedFrom, owner); -@@ -1296,7 +_,7 @@ +@@ -1297,7 +_,7 @@ consumer = entity -> {}; } @@ -40,7 +40,7 @@ } public static Consumer createDefaultStackConfig(Level level, ItemStack stack, @Nullable LivingEntity owner) { -@@ -1313,19 +_,54 @@ +@@ -1314,19 +_,54 @@ public static Consumer appendCustomEntityStackConfig(Consumer consumer, Level level, ItemStack stack, @Nullable LivingEntity owner) { TypedEntityData> typedEntityData = stack.get(DataComponents.ENTITY_DATA); @@ -98,7 +98,7 @@ if (entity instanceof Mob mob) { mob.playAmbientSound(); } -@@ -1381,6 +_,13 @@ +@@ -1382,6 +_,13 @@ if (level.isClientSide() || !entity.getType().onlyOpCanSetNbt() || owner instanceof Player player && server.getPlayerList().isOp(player.nameAndId())) { @@ -112,7 +112,7 @@ entityData.loadInto(entity); } } -@@ -1451,10 +_,28 @@ +@@ -1452,10 +_,28 @@ } public static Optional create(ValueInput input, Level level, EntitySpawnReason spawnReason) { @@ -143,7 +143,7 @@ ); } -@@ -1605,8 +_,23 @@ +@@ -1606,8 +_,23 @@ return this.builtInRegistryHolder; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index 21a473d062e9..ffbef27aa589 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -141,6 +_,17 @@ +@@ -142,6 +_,17 @@ import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -18,7 +18,7 @@ public abstract class LivingEntity extends Entity implements Attackable, WaypointTransmitter { private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; -@@ -266,11 +_,25 @@ +@@ -267,11 +_,25 @@ ); protected final EntityEquipment equipment; private Waypoint.Icon locatorBarIcon = new Waypoint.Icon(); @@ -45,7 +45,7 @@ this.equipment = this.createEquipment(); this.blocksBuilding = true; this.reapplyPosition(); -@@ -369,7 +_,13 @@ +@@ -370,7 +_,13 @@ double d1 = Math.min(0.2F + d / 15.0, 2.5); int i = (int)(150.0 * d1); @@ -60,7 +60,7 @@ } } -@@ -554,7 +_,7 @@ +@@ -555,7 +_,7 @@ this.deathTime++; if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { this.level().broadcastEntityEvent(this, EntityEvent.POOF); @@ -69,7 +69,7 @@ } } -@@ -656,7 +_,7 @@ +@@ -657,7 +_,7 @@ } public boolean shouldDiscardFriction() { @@ -78,7 +78,7 @@ } public void setDiscardFriction(boolean discardFriction) { -@@ -668,10 +_,15 @@ +@@ -669,10 +_,15 @@ } public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem) { @@ -95,7 +95,7 @@ this.level() .playSeededSound( null, -@@ -698,12 +_,12 @@ +@@ -699,12 +_,12 @@ } @Override @@ -110,7 +110,7 @@ this.brain.clearMemories(); } -@@ -720,11 +_,17 @@ +@@ -721,11 +_,17 @@ mobEffectInstance.onMobRemoved(level, this, removalReason); } @@ -128,7 +128,7 @@ output.putFloat("Health", this.getHealth()); output.putShort("HurtTime", (short)this.hurtTime); output.putInt("HurtByTimestamp", this.lastHurtByMobTimestamp); -@@ -758,7 +_,12 @@ +@@ -759,7 +_,12 @@ } } @@ -142,7 +142,7 @@ if (stack.isEmpty()) { return null; } else if (this.level().isClientSide()) { -@@ -767,6 +_,31 @@ +@@ -768,6 +_,31 @@ } else { ItemEntity itemEntity = this.createItemStackToDrop(stack, randomizeMotion, includeThrower); if (itemEntity != null) { @@ -174,7 +174,7 @@ this.level().addFreshEntity(itemEntity); } -@@ -776,7 +_,22 @@ +@@ -777,7 +_,22 @@ @Override protected void readAdditionalSaveData(ValueInput input) { @@ -198,7 +198,7 @@ if (this.level() != null && !this.level().isClientSide()) { input.read("attributes", AttributeInstance.Packed.LIST_CODEC).ifPresent(this.getAttributes()::apply); } -@@ -789,6 +_,11 @@ +@@ -790,6 +_,11 @@ this.effectsDirty = true; } @@ -210,7 +210,7 @@ this.setHealth(input.getFloatOr("Health", this.getMaxHealth())); this.hurtTime = input.getShortOr("HurtTime", (short)0); this.deathTime = input.getShortOr("DeathTime", (short)0); -@@ -796,6 +_,7 @@ +@@ -797,6 +_,7 @@ input.getString("Team").ifPresent(string -> { Scoreboard scoreboard = this.level().getScoreboard(); PlayerTeam playerTeam = scoreboard.getPlayerTeam(string); @@ -218,7 +218,7 @@ boolean flag = playerTeam != null && scoreboard.addPlayerToTeam(this.getStringUUID(), playerTeam); if (!flag) { LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", string); -@@ -803,11 +_,13 @@ +@@ -804,11 +_,13 @@ }); this.setSharedFlag(Entity.FLAG_FALL_FLYING, input.getBooleanOr("FallFlying", false)); input.read("sleeping_pos", BlockPos.CODEC).ifPresentOrElse(blockPos -> { @@ -232,7 +232,7 @@ }, this::clearSleepingPos); input.read("Brain", Codec.PASSTHROUGH).ifPresent(dynamic -> this.brain = this.makeBrain((Dynamic)dynamic)); this.lastHurtByPlayer = EntityReference.read(input, "last_hurt_by_player"); -@@ -824,15 +_,44 @@ +@@ -825,15 +_,44 @@ this.updateDirtyEffects(); } @@ -277,7 +277,7 @@ iterator.remove(); this.onEffectsRemoved(List.of(mobEffectInstance)); } else if (mobEffectInstance.getDuration() % 600 == 0) { -@@ -841,6 +_,18 @@ +@@ -842,6 +_,18 @@ } } catch (ConcurrentModificationException var6) { } @@ -296,7 +296,7 @@ } else { for (MobEffectInstance mobEffectInstance1 : this.activeEffects.values()) { mobEffectInstance1.tickClient(); -@@ -951,15 +_,33 @@ +@@ -952,15 +_,33 @@ } public boolean removeAllEffects() { @@ -334,7 +334,7 @@ } } -@@ -985,21 +_,57 @@ +@@ -986,21 +_,57 @@ } public final boolean addEffect(MobEffectInstance effectInstance) { @@ -394,7 +394,7 @@ this.onEffectUpdated(mobEffectInstance, true, entity); flag = true; } -@@ -1037,11 +_,35 @@ +@@ -1038,11 +_,35 @@ } public final @Nullable MobEffectInstance removeEffectNoUpdate(Holder effect) { @@ -431,7 +431,7 @@ if (mobEffectInstance != null) { this.onEffectsRemoved(List.of(mobEffectInstance)); return true; -@@ -1132,17 +_,62 @@ +@@ -1133,17 +_,62 @@ } public void heal(float amount) { @@ -495,7 +495,7 @@ this.entityData.set(DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth())); } -@@ -1154,7 +_,7 @@ +@@ -1155,7 +_,7 @@ public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { if (this.isInvulnerableTo(level, damageSource)) { return false; @@ -504,7 +504,7 @@ return false; } else if (damageSource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1170,35 +_,58 @@ +@@ -1171,35 +_,58 @@ ItemStack useItem = this.getUseItem(); float originAmount = amount; @@ -571,7 +571,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1213,7 +_,7 @@ +@@ -1214,7 +_,7 @@ level.broadcastDamageEvent(this, damageSource); } @@ -580,7 +580,7 @@ this.markHurt(); } -@@ -1228,8 +_,16 @@ +@@ -1229,8 +_,16 @@ d = damageSource.getSourcePosition().x() - this.getX(); d1 = damageSource.getSourcePosition().z() - this.getZ(); } @@ -598,7 +598,7 @@ if (!flag) { this.indicateDamage(d, d1); } -@@ -1238,19 +_,19 @@ +@@ -1239,19 +_,19 @@ if (this.isDeadOrDying()) { if (!this.checkTotemDeathProtection(damageSource)) { @@ -623,7 +623,7 @@ if (flag2) { this.lastDamageSource = damageSource; this.lastDamageStamp = this.level().getGameTime(); -@@ -1276,6 +_,12 @@ +@@ -1277,6 +_,12 @@ } public float applyItemBlocking(ServerLevel level, DamageSource damageSource, float damageAmount) { @@ -636,7 +636,7 @@ if (damageAmount <= 0.0F) { return 0.0F; } else { -@@ -1300,10 +_,12 @@ +@@ -1301,10 +_,12 @@ } float f = blocksAttacks.resolveBlockedDamage(damageSource, damageAmount, acos); @@ -650,7 +650,7 @@ return f; } -@@ -1314,6 +_,59 @@ +@@ -1315,6 +_,59 @@ } } @@ -710,7 +710,7 @@ public void playSecondaryHurtSound(DamageSource damageSource) { if (damageSource.is(DamageTypes.THORNS)) { SoundSource soundSource = this instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE; -@@ -1345,12 +_,24 @@ +@@ -1346,12 +_,24 @@ return EntityReference.getPlayer(this.lastHurtByPlayer, this.level()); } @@ -736,7 +736,7 @@ } private boolean checkTotemDeathProtection(DamageSource damageSource) { -@@ -1360,18 +_,39 @@ +@@ -1361,18 +_,39 @@ ItemStack itemStack = null; DeathProtection deathProtection = null; @@ -783,7 +783,7 @@ serverPlayer.awardStat(Stats.ITEM_USED.get(itemStack.getItem())); CriteriaTriggers.USED_TOTEM.trigger(serverPlayer, itemStack); itemStack.causeUseVibration(this, GameEvent.ITEM_INTERACT_FINISH); -@@ -1429,6 +_,7 @@ +@@ -1430,6 +_,7 @@ if (!this.isRemoved() && !this.dead) { Entity entity = damageSource.getEntity(); LivingEntity killCredit = this.getKillCredit(); @@ -791,7 +791,7 @@ if (killCredit != null) { killCredit.awardKillScore(this, damageSource); } -@@ -1439,68 +_,147 @@ +@@ -1440,68 +_,147 @@ this.stopUsingItem(); if (!this.level().isClientSide() && this.hasCustomName()) { @@ -952,7 +952,7 @@ } protected void dropCustomDeathLoot(ServerLevel level, DamageSource damageSource, boolean recentlyHit) { -@@ -1604,9 +_,14 @@ +@@ -1605,9 +_,14 @@ } public void knockback(double strength, double x, double z) { @@ -969,7 +969,7 @@ Vec3 deltaMovement = this.getDeltaMovement(); while (x * x + z * z < 1.0E-5F) { -@@ -1615,11 +_,22 @@ +@@ -1616,11 +_,22 @@ } Vec3 vec3 = new Vec3(x, 0.0, z).normalize().scale(strength); @@ -993,7 +993,7 @@ } } -@@ -1710,7 +_,7 @@ +@@ -1711,7 +_,7 @@ @Override public boolean isAlive() { @@ -1002,7 +1002,7 @@ } public boolean isLookingAtMe(LivingEntity entity, double tolerance, boolean scaleByDistance, boolean visual, double... yValues) { -@@ -1744,9 +_,14 @@ +@@ -1745,9 +_,14 @@ boolean flag = super.causeFallDamage(fallDistance, damageMultiplier, damageSource); int i = this.calculateFallDamage(fallDistance, damageMultiplier); if (i > 0) { @@ -1018,7 +1018,7 @@ return true; } else { return flag; -@@ -1811,7 +_,7 @@ +@@ -1812,7 +_,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damageSource, float damageAmount) { if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -1027,7 +1027,7 @@ damageAmount = CombatRules.getDamageAfterAbsorb( this, damageAmount, damageSource, this.getArmorValue(), (float)this.getAttributeValue(Attributes.ARMOR_TOUGHNESS) ); -@@ -1824,7 +_,8 @@ +@@ -1825,7 +_,8 @@ if (damageSource.is(DamageTypeTags.BYPASSES_EFFECTS)) { return damageAmount; } else { @@ -1037,7 +1037,7 @@ int i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int i1 = 25 - i; float f = damageAmount * i1; -@@ -1861,24 +_,201 @@ +@@ -1862,24 +_,201 @@ } } @@ -1249,7 +1249,7 @@ } public CombatTracker getCombatTracker() { -@@ -1906,7 +_,17 @@ +@@ -1907,7 +_,17 @@ } public final void setArrowCount(int count) { @@ -1268,7 +1268,7 @@ } public final int getStingerCount() { -@@ -1953,7 +_,7 @@ +@@ -1954,7 +_,7 @@ @Override public void handleDamageEvent(DamageSource damageSource) { this.walkAnimation.setSpeed(1.5F); @@ -1277,7 +1277,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; SoundEvent hurtSound = this.getHurtSound(damageSource); -@@ -2072,7 +_,7 @@ +@@ -2073,7 +_,7 @@ @Override protected void onBelowWorld() { @@ -1286,7 +1286,7 @@ } protected void updateSwingTime() { -@@ -2166,8 +_,15 @@ +@@ -2176,8 +_,15 @@ } public void setItemSlot(EquipmentSlot slot, ItemStack stack) { @@ -1304,7 +1304,7 @@ public float getArmorCoverPercentage() { int i = 0; -@@ -2259,14 +_,27 @@ +@@ -2269,14 +_,27 @@ return this.hasEffect(MobEffects.JUMP_BOOST) ? 0.1F * (this.getEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1.0F) : 0.0F; } @@ -1332,7 +1332,7 @@ this.addDeltaMovement(new Vec3(-Mth.sin(f) * 0.2, 0.0, Mth.cos(f) * 0.2)); } -@@ -2449,8 +_,10 @@ +@@ -2459,8 +_,10 @@ } public void stopFallFlying() { @@ -1343,7 +1343,7 @@ } private Vec3 updateFallFlyingMovement(Vec3 deltaMovement) { -@@ -2594,7 +_,7 @@ +@@ -2604,7 +_,7 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F && target instanceof LivingEntity livingEntity) { @@ -1352,7 +1352,7 @@ this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); } } -@@ -2670,37 +_,15 @@ +@@ -2680,37 +_,15 @@ profilerFiller.pop(); profilerFiller.push("rangeChecks"); @@ -1399,7 +1399,7 @@ profilerFiller.pop(); if (this.isFallFlying()) { -@@ -2785,16 +_,39 @@ +@@ -2795,16 +_,39 @@ private @Nullable Map collectEquipmentChanges() { Map map = null; @@ -1439,7 +1439,7 @@ AttributeMap attributes = this.getAttributes(); if (!itemStack.isEmpty()) { this.stopLocationBasedEffects(itemStack, equipmentSlot, attributes); -@@ -2819,6 +_,8 @@ +@@ -2829,6 +_,8 @@ } } } @@ -1448,7 +1448,7 @@ } return map; -@@ -2850,7 +_,7 @@ +@@ -2860,7 +_,7 @@ list.add(Pair.of(equipmentSlot, itemStack1)); this.lastEquipmentItems.put(equipmentSlot, itemStack1); }); @@ -1457,7 +1457,7 @@ } protected void tickHeadTurn(float yBodyRot) { -@@ -2936,8 +_,10 @@ +@@ -2946,8 +_,10 @@ if (!flag || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if (!this.isInLava() || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if ((this.onGround() || flag && fluidHeight <= fluidJumpThreshold) && this.noJumpDelay == 0) { @@ -1468,7 +1468,7 @@ } } else { this.jumpInLiquid(FluidTags.LAVA); -@@ -2978,7 +_,7 @@ +@@ -2988,7 +_,7 @@ profilerFiller.pop(); if (this.level() instanceof ServerLevel serverLevel) { profilerFiller.push("freezing"); @@ -1477,7 +1477,7 @@ this.setTicksFrozen(Math.max(0, this.getTicksFrozen() - 2)); } -@@ -2999,6 +_,20 @@ +@@ -3009,6 +_,20 @@ this.pushEntities(); profilerFiller.pop(); @@ -1498,7 +1498,7 @@ if (this.level() instanceof ServerLevel serverLevel && this.isSensitiveToWater() && this.isInWaterOrRain()) { this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F); } -@@ -3021,6 +_,7 @@ +@@ -3031,6 +_,7 @@ this.checkFallDistanceAccumulation(); if (!this.level().isClientSide()) { if (!this.canGlide()) { @@ -1506,7 +1506,7 @@ this.setSharedFlag(Entity.FLAG_FALL_FLYING, false); return; } -@@ -3060,10 +_,25 @@ +@@ -3070,10 +_,25 @@ } protected void pushEntities() { @@ -1533,7 +1533,7 @@ if (i > 0 && pushableEntities.size() > i - 1 && this.random.nextInt(4) == 0) { int i1 = 0; -@@ -3079,7 +_,16 @@ +@@ -3089,7 +_,16 @@ } } @@ -1550,7 +1550,7 @@ this.doPush(entity1); } } -@@ -3088,16 +_,32 @@ +@@ -3098,16 +_,32 @@ protected void checkAutoSpinAttack(AABB boundingBoxBeforeSpin, AABB boundingBoxAfterSpin) { AABB aabb = boundingBoxBeforeSpin.minmax(boundingBoxAfterSpin); List entities = this.level().getEntities(this, aabb); @@ -1584,7 +1584,7 @@ this.autoSpinAttackTicks = 0; } -@@ -3120,10 +_,10 @@ +@@ -3130,10 +_,10 @@ } @Override @@ -1598,7 +1598,7 @@ this.dismountVehicle(vehicle); } } -@@ -3150,7 +_,7 @@ +@@ -3160,7 +_,7 @@ } public void onItemPickup(ItemEntity itemEntity) { @@ -1607,7 +1607,7 @@ if (owner instanceof ServerPlayer) { CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer)owner, itemEntity.getItem(), this); } -@@ -3162,7 +_,7 @@ +@@ -3172,7 +_,7 @@ && (entity instanceof ItemEntity || entity instanceof AbstractArrow || entity instanceof ExperienceOrb)) { ((ServerLevel)this.level()) .getChunkSource() @@ -1616,7 +1616,7 @@ } } -@@ -3176,7 +_,8 @@ +@@ -3186,7 +_,8 @@ } else { Vec3 vec3 = new Vec3(this.getX(), this.getEyeY(), this.getZ()); Vec3 vec31 = new Vec3(entity.getX(), y, entity.getZ()); @@ -1626,7 +1626,7 @@ } } -@@ -3196,13 +_,27 @@ +@@ -3206,13 +_,27 @@ @Override public boolean isPickable() { @@ -1657,7 +1657,7 @@ @Override public float getYHeadRot() { -@@ -3233,7 +_,7 @@ +@@ -3243,7 +_,7 @@ } public final void setAbsorptionAmount(float absorptionAmount) { @@ -1666,7 +1666,7 @@ } protected void internalSetAbsorptionAmount(float absorptionAmount) { -@@ -3260,6 +_,15 @@ +@@ -3270,6 +_,15 @@ return (this.entityData.get(DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; } @@ -1682,7 +1682,7 @@ private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { -@@ -3276,6 +_,11 @@ +@@ -3286,6 +_,11 @@ return null; } else { double d = this.getEyeY() - 0.3F; @@ -1694,7 +1694,7 @@ ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), d, this.getZ(), stack); itemEntity.setPickUpDelay(40); if (includeThrower) { -@@ -3307,7 +_,12 @@ +@@ -3317,7 +_,12 @@ protected void updateUsingItem(ItemStack usingItem) { usingItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); @@ -1708,7 +1708,7 @@ this.completeUsingItem(); } } -@@ -3333,10 +_,19 @@ +@@ -3343,10 +_,19 @@ } public void startUsingItem(InteractionHand hand) { @@ -1730,7 +1730,7 @@ if (!this.level().isClientSide()) { this.setLivingEntityFlag(LIVING_ENTITY_FLAG_IS_USING, true); this.setLivingEntityFlag(LIVING_ENTITY_FLAG_OFF_HAND, hand == InteractionHand.OFF_HAND); -@@ -3363,7 +_,10 @@ +@@ -3373,7 +_,10 @@ } } else if (!this.isUsingItem() && !this.useItem.isEmpty()) { this.useItem = ItemStack.EMPTY; @@ -1742,7 +1742,7 @@ } } } -@@ -3402,7 +_,38 @@ +@@ -3412,7 +_,38 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1782,7 +1782,7 @@ if (itemStack != this.useItem) { this.setItemInHand(usedItemHand, itemStack); } -@@ -3436,6 +_,7 @@ +@@ -3446,6 +_,7 @@ ItemStack itemInHand = this.getItemInHand(this.getUsedItemHand()); if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemInHand, this.useItem)) { this.useItem = itemInHand; @@ -1790,7 +1790,7 @@ this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); if (this.useItem.useOnRelease()) { this.updatingUsingItem(); -@@ -3456,7 +_,10 @@ +@@ -3466,7 +_,10 @@ } this.useItem = ItemStack.EMPTY; @@ -1802,7 +1802,7 @@ } public boolean isBlocking() { -@@ -3479,6 +_,60 @@ +@@ -3489,6 +_,60 @@ } } @@ -1863,7 +1863,7 @@ public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); } -@@ -3497,6 +_,12 @@ +@@ -3507,6 +_,12 @@ } public boolean randomTeleport(double x, double y, double z, boolean broadcastTeleport) { @@ -1876,7 +1876,7 @@ double x1 = this.getX(); double y1 = this.getY(); double z1 = this.getZ(); -@@ -3519,16 +_,39 @@ +@@ -3529,16 +_,39 @@ } if (flag1) { @@ -1919,7 +1919,7 @@ } else { if (broadcastTeleport) { level.broadcastEntityEvent(this, EntityEvent.TELEPORT); -@@ -3538,7 +_,7 @@ +@@ -3548,7 +_,7 @@ pathfinderMob.getNavigation().stop(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch index 2421ffa5732c..29c973aa71df 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -259,7 +259,7 @@ this.sensing.tick(); @@ -853,14 +_,69 @@ public boolean stillValid(Player player) { - return player.getVehicle() == Mob.this || player.canInteractWithEntity(Mob.this, 4.0); + return player.getVehicle() == Mob.this || player.isWithinEntityInteractionRange(Mob.this, 4.0); } + + // Paper start diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch index 8fa87a270a5e..f215390a758b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Bee.java -+++ b/net/minecraft/world/entity/animal/Bee.java -@@ -147,10 +_,26 @@ +--- a/net/minecraft/world/entity/animal/bee/Bee.java ++++ b/net/minecraft/world/entity/animal/bee/Bee.java +@@ -149,10 +_,26 @@ Bee.BeeGoToHiveGoal goToHiveGoal; private Bee.BeeGoToKnownFlowerGoal goToKnownFlowerGoal; private int underWaterTicks; @@ -28,7 +28,7 @@ this.lookControl = new Bee.BeeLookControl(this); this.setPathfindingMalus(PathType.DANGER_FIRE, -1.0F); this.setPathfindingMalus(PathType.WATER, -1.0F); -@@ -197,9 +_,18 @@ +@@ -199,9 +_,18 @@ @Override protected void addAdditionalSaveData(ValueOutput output) { @@ -47,7 +47,7 @@ output.putBoolean("HasNectar", this.hasNectar()); output.putBoolean("HasStung", this.hasStung()); output.putInt("TicksSincePollination", this.ticksWithoutNectarSinceExitingHive); -@@ -237,7 +_,7 @@ +@@ -239,7 +_,7 @@ } if (i > 0) { @@ -56,7 +56,7 @@ } } -@@ -478,7 +_,11 @@ +@@ -480,7 +_,11 @@ if (this.hivePos == null) { return null; } else { @@ -69,7 +69,7 @@ } } -@@ -511,6 +_,7 @@ +@@ -513,6 +_,7 @@ } public void setRolling(boolean isRolling) { @@ -77,7 +77,7 @@ this.setFlag(FLAG_ROLL, isRolling); } -@@ -567,7 +_,7 @@ +@@ -569,7 +_,7 @@ if (beeInteractionEffect != null) { this.usePlayerItem(player, hand, itemInHand); if (!this.level().isClientSide()) { @@ -86,7 +86,7 @@ } return InteractionResult.SUCCESS; -@@ -635,8 +_,9 @@ +@@ -637,8 +_,9 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { @@ -97,7 +97,7 @@ } } -@@ -977,7 +_,7 @@ +@@ -979,7 +_,7 @@ } } @@ -106,7 +106,7 @@ Bee.this.level().levelEvent(LevelEvent.PARTICLES_BEE_GROWTH, blockPos, 15); Bee.this.level().setBlockAndUpdate(blockPos, blockState1); Bee.this.incrementNumCropsGrownSincePollination(); -@@ -1001,7 +_,7 @@ +@@ -1003,7 +_,7 @@ @Override protected void alertOther(Mob mob, LivingEntity target) { if (mob instanceof Bee && this.mob.hasLineOfSight(target)) { @@ -115,7 +115,7 @@ } } } -@@ -1158,7 +_,7 @@ +@@ -1160,7 +_,7 @@ Bee.this.dropFlower(); this.pollinating = false; Bee.this.remainingCooldownBeforeLocatingNewFlower = 200; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Chicken.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/chicken/Chicken.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Chicken.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/chicken/Chicken.java.patch index 7c745c39beb0..b462eb81c29d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Chicken.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/chicken/Chicken.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Chicken.java -+++ b/net/minecraft/world/entity/animal/Chicken.java -@@ -112,10 +_,12 @@ +--- a/net/minecraft/world/entity/animal/chicken/Chicken.java ++++ b/net/minecraft/world/entity/animal/chicken/Chicken.java +@@ -113,10 +_,12 @@ this.flap = this.flap + this.flapping * 2.0F; if (this.level() instanceof ServerLevel serverLevel && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractCow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/AbstractCow.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractCow.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/cow/AbstractCow.java.patch index b66d5d65f7a6..396d38adc60d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractCow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/AbstractCow.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/AbstractCow.java -+++ b/net/minecraft/world/entity/animal/AbstractCow.java -@@ -84,8 +_,15 @@ +--- a/net/minecraft/world/entity/animal/cow/AbstractCow.java ++++ b/net/minecraft/world/entity/animal/cow/AbstractCow.java +@@ -85,8 +_,15 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.BUCKET) && !this.isBaby()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/MushroomCow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/MushroomCow.java.patch similarity index 96% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/MushroomCow.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/cow/MushroomCow.java.patch index 507e7fd362e4..c0e2f6acbeff 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/MushroomCow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/MushroomCow.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/MushroomCow.java -+++ b/net/minecraft/world/entity/animal/MushroomCow.java +--- a/net/minecraft/world/entity/animal/cow/MushroomCow.java ++++ b/net/minecraft/world/entity/animal/cow/MushroomCow.java @@ -116,7 +_,17 @@ return InteractionResult.SUCCESS; } else if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/dolphin/Dolphin.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/dolphin/Dolphin.java.patch index 7cef37cbdf38..1fdf4e400bf8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/dolphin/Dolphin.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Dolphin.java -+++ b/net/minecraft/world/entity/animal/Dolphin.java -@@ -97,6 +_,13 @@ +--- a/net/minecraft/world/entity/animal/dolphin/Dolphin.java ++++ b/net/minecraft/world/entity/animal/dolphin/Dolphin.java +@@ -98,6 +_,13 @@ return EntityType.DOLPHIN.create(level, EntitySpawnReason.BREEDING); } @@ -14,7 +14,7 @@ @Override public float getAgeScale() { return this.isBaby() ? 0.65F : 1.0F; -@@ -181,7 +_,7 @@ +@@ -182,7 +_,7 @@ @Override public int getMaxAirSupply() { @@ -23,7 +23,7 @@ } @Override -@@ -214,11 +_,15 @@ +@@ -215,11 +_,15 @@ if (this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) { ItemStack item = entity.getItem(); if (this.canHoldItem(item)) { @@ -40,7 +40,7 @@ } } } -@@ -478,7 +_,7 @@ +@@ -479,7 +_,7 @@ @Override public void start() { @@ -49,7 +49,7 @@ } @Override -@@ -497,7 +_,7 @@ +@@ -498,7 +_,7 @@ } if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) { @@ -58,7 +58,7 @@ } } } -@@ -567,7 +_,7 @@ +@@ -568,7 +_,7 @@ 0.3F * Mth.cos(Dolphin.this.getYRot() * (float) (Math.PI / 180.0)) * Mth.cos(Dolphin.this.getXRot() * (float) (Math.PI / 180.0)) + Mth.sin(f1) * f2 ); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch similarity index 76% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch index c90ac1a05a3a..f0d60ff3e63d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java -+++ b/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java +--- a/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java ++++ b/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java @@ -74,6 +_,12 @@ super.dropEquipment(level); if (this.hasChest()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractHorse.java.patch similarity index 97% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractHorse.java.patch index b586611ed9d9..52883f8e6a3b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractHorse.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java -+++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java +--- a/net/minecraft/world/entity/animal/equine/AbstractHorse.java ++++ b/net/minecraft/world/entity/animal/equine/AbstractHorse.java @@ -124,6 +_,7 @@ protected boolean canGallop = true; protected int gallopSoundCounter; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/Llama.java.patch similarity index 93% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/equine/Llama.java.patch index 471cee49f3bc..514774700575 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/Llama.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/horse/Llama.java -+++ b/net/minecraft/world/entity/animal/horse/Llama.java +--- a/net/minecraft/world/entity/animal/equine/Llama.java ++++ b/net/minecraft/world/entity/animal/equine/Llama.java @@ -75,18 +_,19 @@ .scale(0.5F); boolean didSpit; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonHorse.java.patch similarity index 69% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonHorse.java.patch index c33ff9aea112..43ae42746bd0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonHorse.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/horse/SkeletonHorse.java -+++ b/net/minecraft/world/entity/animal/horse/SkeletonHorse.java +--- a/net/minecraft/world/entity/animal/equine/SkeletonHorse.java ++++ b/net/minecraft/world/entity/animal/equine/SkeletonHorse.java @@ -126,7 +_,7 @@ public void aiStep() { super.aiStep(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java.patch index bd666de5d378..0017eebc7c21 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java -+++ b/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java +--- a/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java ++++ b/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java @@ -18,6 +_,7 @@ public class SkeletonTrapGoal extends Goal { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/TraderLlama.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/equine/TraderLlama.java.patch index c7fe01d2930a..6fe1f4c67b78 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/TraderLlama.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/horse/TraderLlama.java -+++ b/net/minecraft/world/entity/animal/horse/TraderLlama.java +--- a/net/minecraft/world/entity/animal/equine/TraderLlama.java ++++ b/net/minecraft/world/entity/animal/equine/TraderLlama.java @@ -88,7 +_,7 @@ this.despawnDelay = this.isLeashedToWanderingTrader() ? ((WanderingTrader)this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1; if (this.despawnDelay <= 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Cat.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Cat.java.patch index c9d574ad6c3e..4f297d72d1fb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Cat.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Cat.java -+++ b/net/minecraft/world/entity/animal/Cat.java -@@ -369,6 +_,11 @@ +--- a/net/minecraft/world/entity/animal/feline/Cat.java ++++ b/net/minecraft/world/entity/animal/feline/Cat.java +@@ -372,6 +_,11 @@ if (item instanceof DyeItem dyeItem) { DyeColor dyeColor = dyeItem.getDyeColor(); if (dyeColor != this.getCollarColor()) { @@ -12,7 +12,7 @@ if (!this.level().isClientSide()) { this.setCollarColor(dyeColor); itemInHand.consume(1, player); -@@ -381,7 +_,7 @@ +@@ -384,7 +_,7 @@ if (!this.level().isClientSide()) { this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); @@ -21,7 +21,7 @@ this.playEatingSound(); } -@@ -443,7 +_,7 @@ +@@ -446,7 +_,7 @@ } private void tryToTame(Player player) { @@ -30,7 +30,7 @@ this.tame(player); this.setOrderedToSit(true); this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); -@@ -576,15 +_,20 @@ +@@ -579,15 +_,20 @@ .dropFromGiftLootTable( getServerLevel(this.cat), BuiltInLootTables.CAT_MORNING_GIFT, @@ -55,7 +55,7 @@ ); } -@@ -610,7 +_,7 @@ +@@ -613,7 +_,7 @@ } static class CatTemptGoal extends TemptGoal { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Ocelot.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Ocelot.java.patch index 039ed17d0233..0a20cf90d180 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Ocelot.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Ocelot.java -+++ b/net/minecraft/world/entity/animal/Ocelot.java -@@ -126,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/feline/Ocelot.java ++++ b/net/minecraft/world/entity/animal/feline/Ocelot.java +@@ -129,7 +_,7 @@ @Override public boolean removeWhenFarAway(double distanceToClosestPlayer) { @@ -9,7 +9,7 @@ } public static AttributeSupplier.Builder createAttributes() { -@@ -159,7 +_,7 @@ +@@ -162,7 +_,7 @@ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemInHand) && player.distanceToSqr(this) < 9.0) { this.usePlayerItem(player, hand, itemInHand); if (!this.level().isClientSide()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractSchoolingFish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/AbstractSchoolingFish.java.patch similarity index 66% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractSchoolingFish.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/fish/AbstractSchoolingFish.java.patch index 79bdc07a66e0..6663fc08d964 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractSchoolingFish.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/AbstractSchoolingFish.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/AbstractSchoolingFish.java -+++ b/net/minecraft/world/entity/animal/AbstractSchoolingFish.java +--- a/net/minecraft/world/entity/animal/fish/AbstractSchoolingFish.java ++++ b/net/minecraft/world/entity/animal/fish/AbstractSchoolingFish.java @@ -50,6 +_,7 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/Pufferfish.java.patch similarity index 96% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/fish/Pufferfish.java.patch index 8372769dbe9a..604051d9c6b6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/Pufferfish.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/Pufferfish.java -+++ b/net/minecraft/world/entity/animal/Pufferfish.java +--- a/net/minecraft/world/entity/animal/fish/Pufferfish.java ++++ b/net/minecraft/world/entity/animal/fish/Pufferfish.java @@ -97,24 +_,36 @@ public void tick() { if (!this.level().isClientSide() && this.isAlive() && this.isEffectiveAi()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/WaterAnimal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/WaterAnimal.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/WaterAnimal.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/fish/WaterAnimal.java.patch index d274fbeacd6d..a55197acb9e7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/WaterAnimal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/WaterAnimal.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/WaterAnimal.java -+++ b/net/minecraft/world/entity/animal/WaterAnimal.java +--- a/net/minecraft/world/entity/animal/fish/WaterAnimal.java ++++ b/net/minecraft/world/entity/animal/fish/WaterAnimal.java @@ -72,6 +_,10 @@ ) { int seaLevel = level.getSeaLevel(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/fox/Fox.java.patch similarity index 96% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/fox/Fox.java.patch index 2e1bf961290c..e9b25ee2248e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/fox/Fox.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Fox.java -+++ b/net/minecraft/world/entity/animal/Fox.java -@@ -429,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/fox/Fox.java ++++ b/net/minecraft/world/entity/animal/fox/Fox.java +@@ -440,7 +_,7 @@ input.read("Trusted", TRUSTED_LIST_CODEC).orElse(List.of()).forEach(this::addTrustedEntity); this.setSleeping(input.getBooleanOr("Sleeping", false)); this.setVariant(input.read("Type", Fox.Variant.CODEC).orElse(Fox.Variant.DEFAULT)); @@ -9,7 +9,7 @@ this.setIsCrouching(input.getBooleanOr("Crouching", false)); if (this.level() instanceof ServerLevel) { this.setTargetGoals(); -@@ -446,6 +_,12 @@ +@@ -457,6 +_,12 @@ } public void setSitting(boolean sitting) { @@ -22,7 +22,7 @@ this.setFlag(FLAG_SITTING, sitting); } -@@ -505,19 +_,20 @@ +@@ -516,19 +_,20 @@ itemEntity.setPickUpDelay(40); itemEntity.setThrower(this); this.playSound(SoundEvents.FOX_SPIT, 1.0F, 1.0F); @@ -46,7 +46,7 @@ int count = item.getCount(); if (count > 1) { this.dropItemStack(item.split(count - 1)); -@@ -528,7 +_,7 @@ +@@ -539,7 +_,7 @@ this.setItemSlot(EquipmentSlot.MAINHAND, item.split(1)); this.setGuaranteedDrop(EquipmentSlot.MAINHAND); this.take(entity, item.getCount()); @@ -55,7 +55,7 @@ this.ticksSinceEaten = 0; } } -@@ -619,12 +_,12 @@ +@@ -630,12 +_,12 @@ } @Override @@ -70,7 +70,7 @@ } void wakeUp() { -@@ -685,15 +_,33 @@ +@@ -696,15 +_,33 @@ return this.getTrustedEntities().anyMatch(entityReference -> entityReference.matches(entity)); } @@ -108,7 +108,7 @@ } public static boolean isPathClear(Fox fox, LivingEntity livingEntity) { -@@ -866,6 +_,19 @@ +@@ -877,6 +_,19 @@ fox.addTrustedEntity(loveCause1); } @@ -128,7 +128,7 @@ if (serverPlayer != null) { serverPlayer.awardStat(Stats.ANIMALS_BRED); CriteriaTriggers.BRED_ANIMALS.trigger(serverPlayer, this.animal, this.partner, fox); -@@ -875,14 +_,12 @@ +@@ -886,14 +_,12 @@ this.partner.setAge(6000); this.animal.resetLove(); this.partner.resetLove(); @@ -146,7 +146,7 @@ ); } } -@@ -946,6 +_,7 @@ +@@ -957,6 +_,7 @@ private void pickSweetBerries(BlockState state) { int ageValue = state.getValue(SweetBerryBushBlock.AGE); state.setValue(SweetBerryBushBlock.AGE, 1); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/CopperGolem.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/golem/CopperGolem.java.patch index f4186542dfdb..51f378361e74 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/CopperGolem.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java -+++ b/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java -@@ -58,8 +_,8 @@ +--- a/net/minecraft/world/entity/animal/golem/CopperGolem.java ++++ b/net/minecraft/world/entity/animal/golem/CopperGolem.java +@@ -57,8 +_,8 @@ import org.jspecify.annotations.Nullable; public class CopperGolem extends AbstractGolem implements ContainerUser, Shearable { @@ -11,7 +11,7 @@ private static final int WEATHERING_TICK_FROM = 504000; private static final int WEATHERING_TICK_TO = 552000; private static final int SPIN_ANIMATION_MIN_COOLDOWN = 200; -@@ -76,7 +_,7 @@ +@@ -75,7 +_,7 @@ ); private @Nullable BlockPos openedChestPos; private @Nullable UUID lastLightningBoltUUID; @@ -20,7 +20,7 @@ private int idleAnimationStartTick = 0; private final AnimationState idleAnimationState = new AnimationState(); private final AnimationState interactionGetItemAnimationState = new AnimationState(); -@@ -220,7 +_,15 @@ +@@ -219,7 +_,15 @@ Level level = this.level(); if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { if (level instanceof ServerLevel serverLevel) { @@ -37,7 +37,7 @@ this.gameEvent(GameEvent.SHEAR, player); itemInHand.hurtAndBreak(1, player, hand); } -@@ -283,20 +_,27 @@ +@@ -282,20 +_,27 @@ private void turnToStatue(ServerLevel level) { BlockPos blockPos = this.blockPosition(); @@ -71,7 +71,7 @@ this.playSound(SoundEvents.COPPER_GOLEM_BECOME_STATUE); if (this.isLeashed()) { if (level.getGameRules().get(GameRules.ENTITY_DROPS)) { -@@ -426,12 +_,32 @@ +@@ -425,12 +_,32 @@ } @Override @@ -108,7 +108,7 @@ @Override public boolean readyForShearing() { -@@ -445,9 +_,13 @@ +@@ -444,9 +_,13 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/IronGolem.java.patch similarity index 88% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/golem/IronGolem.java.patch index 7d4e5af15e11..9f6fe1934d89 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/IronGolem.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/IronGolem.java -+++ b/net/minecraft/world/entity/animal/IronGolem.java +--- a/net/minecraft/world/entity/animal/golem/IronGolem.java ++++ b/net/minecraft/world/entity/animal/golem/IronGolem.java @@ -106,7 +_,7 @@ @Override protected void doPush(Entity entity) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/SnowGolem.java.patch similarity index 97% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/golem/SnowGolem.java.patch index 0478047fca15..be61f67cc4f6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/SnowGolem.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/SnowGolem.java -+++ b/net/minecraft/world/entity/animal/SnowGolem.java +--- a/net/minecraft/world/entity/animal/golem/SnowGolem.java ++++ b/net/minecraft/world/entity/animal/golem/SnowGolem.java @@ -92,7 +_,7 @@ super.aiStep(); if (this.level() instanceof ServerLevel serverLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/HappyGhast.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/happyghast/HappyGhast.java.patch similarity index 82% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/HappyGhast.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/happyghast/HappyGhast.java.patch index 9f267abaf223..860f951bc384 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/HappyGhast.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/happyghast/HappyGhast.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/HappyGhast.java -+++ b/net/minecraft/world/entity/animal/HappyGhast.java -@@ -305,8 +_,12 @@ +--- a/net/minecraft/world/entity/animal/happyghast/HappyGhast.java ++++ b/net/minecraft/world/entity/animal/happyghast/HappyGhast.java +@@ -306,8 +_,12 @@ } @Override @@ -15,7 +15,7 @@ if (!this.level().isClientSide()) { this.setServerStillTimeout(10); } -@@ -315,6 +_,7 @@ +@@ -316,6 +_,7 @@ this.clearHome(); this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.HARNESS_GOGGLES_UP, this.getSoundSource(), 1.0F, 1.0F); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch index 398c8521c6fe..3e97ee09d173 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java +++ b/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java -@@ -256,7 +_,7 @@ +@@ -258,7 +_,7 @@ boolean hasEffect = player.hasEffect(MobEffects.BREATH_OF_THE_NAUTILUS); boolean flag = level.getGameTime() % 40L == 0L; if (!hasEffect || flag) { @@ -9,7 +9,7 @@ } } } -@@ -398,7 +_,7 @@ +@@ -400,7 +_,7 @@ if (this.isFood(itemInHand) && this.getHealth() < this.getMaxHealth()) { FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); @@ -18,7 +18,7 @@ this.usePlayerItem(player, hand, itemInHand); this.playEatingSound(); return InteractionResult.SUCCESS; -@@ -426,7 +_,7 @@ +@@ -422,7 +_,7 @@ } private void tryToTame(Player player) { @@ -27,7 +27,7 @@ this.tame(player); this.navigation.stop(); this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); -@@ -481,7 +_,7 @@ +@@ -477,7 +_,7 @@ protected void createInventory() { SimpleContainer simpleContainer = this.inventory; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch index 0d8ad115baec..cc0fc86f7522 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/nautilus/Nautilus.java +++ b/net/minecraft/world/entity/animal/nautilus/Nautilus.java -@@ -97,8 +_,14 @@ +@@ -109,8 +_,14 @@ @Override public int getMaxAirSupply() { @@ -17,7 +17,7 @@ protected void handleAirSupply(ServerLevel level, int airSupply) { if (this.isAlive() && !this.isInWater()) { -@@ -108,7 +_,7 @@ +@@ -120,7 +_,7 @@ this.hurtServer(level, this.damageSources().dryOut(), 2.0F); } } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/panda/Panda.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/panda/Panda.java.patch index 3e1e4eeea684..8df23114de3b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/panda/Panda.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Panda.java -+++ b/net/minecraft/world/entity/animal/Panda.java -@@ -129,6 +_,7 @@ +--- a/net/minecraft/world/entity/animal/panda/Panda.java ++++ b/net/minecraft/world/entity/animal/panda/Panda.java +@@ -130,6 +_,7 @@ } public void sit(boolean sitting) { @@ -8,7 +8,7 @@ this.setFlag(FLAG_SIT, sitting); } -@@ -517,24 +_,28 @@ +@@ -518,24 +_,28 @@ for (Panda panda : level.getEntitiesOfClass(Panda.class, this.getBoundingBox().inflate(10.0))) { if (!panda.isBaby() && panda.onGround() && !panda.isInWater() && panda.canPerformAction()) { @@ -39,7 +39,7 @@ } } -@@ -624,8 +_,9 @@ +@@ -625,8 +_,9 @@ this.usePlayerItem(player, hand, itemInHand); this.ageUp((int)(-this.getAge() / 20 * 0.1F), true); } else if (!this.level().isClientSide() && this.getAge() == 0 && this.canFallInLove()) { @@ -50,7 +50,7 @@ } else { if (!(this.level() instanceof ServerLevel serverLevel) || this.isSitting() || this.isInWater()) { return InteractionResult.PASS; -@@ -635,7 +_,9 @@ +@@ -636,7 +_,9 @@ this.eat(true); ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.MAINHAND); if (!itemBySlot.isEmpty() && !player.hasInfiniteMaterials()) { @@ -60,7 +60,7 @@ } this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(itemInHand.getItem(), 1)); -@@ -854,7 +_,7 @@ +@@ -855,7 +_,7 @@ @Override protected void alertOther(Mob mob, LivingEntity target) { if (mob instanceof Panda && mob.isAggressive()) { @@ -69,7 +69,7 @@ } } } -@@ -1083,7 +_,9 @@ +@@ -1084,7 +_,9 @@ public void stop() { ItemStack itemBySlot = Panda.this.getItemBySlot(EquipmentSlot.MAINHAND); if (!itemBySlot.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch index 35c882dfdb55..7db0b4f6b0e1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Parrot.java -+++ b/net/minecraft/world/entity/animal/Parrot.java -@@ -267,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/parrot/Parrot.java ++++ b/net/minecraft/world/entity/animal/parrot/Parrot.java +@@ -269,7 +_,7 @@ } if (!this.level().isClientSide()) { @@ -9,7 +9,7 @@ this.tame(player); this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); } else { -@@ -288,7 +_,7 @@ +@@ -290,7 +_,7 @@ } } else { this.usePlayerItem(player, hand, itemInHand); @@ -18,7 +18,7 @@ if (player.isCreative() || !this.isInvulnerable()) { this.hurt(this.damageSources().playerAttack(player), Float.MAX_VALUE); } -@@ -381,8 +_,8 @@ +@@ -383,8 +_,8 @@ } @Override @@ -29,7 +29,7 @@ } @Override -@@ -397,8 +_,13 @@ +@@ -399,8 +_,13 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/ShoulderRidingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/ShoulderRidingEntity.java.patch similarity index 74% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/ShoulderRidingEntity.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/ShoulderRidingEntity.java.patch index 1ad868188882..74075655549d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/ShoulderRidingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/ShoulderRidingEntity.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/ShoulderRidingEntity.java -+++ b/net/minecraft/world/entity/animal/ShoulderRidingEntity.java +--- a/net/minecraft/world/entity/animal/parrot/ShoulderRidingEntity.java ++++ b/net/minecraft/world/entity/animal/parrot/ShoulderRidingEntity.java @@ -24,7 +_,7 @@ this.saveWithoutId(tagValueOutput); tagValueOutput.putString("id", this.getEncodeId()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/pig/Pig.java.patch similarity index 88% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/pig/Pig.java.patch index 3adf91fc4fa5..c7a3748e36b4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/pig/Pig.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Pig.java -+++ b/net/minecraft/world/entity/animal/Pig.java -@@ -211,7 +_,14 @@ +--- a/net/minecraft/world/entity/animal/pig/Pig.java ++++ b/net/minecraft/world/entity/animal/pig/Pig.java +@@ -212,7 +_,14 @@ ZombifiedPiglin zombifiedPiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, false, true), mob -> { mob.populateDefaultEquipmentSlots(this.getRandom(), level.getCurrentDifficultyAt(this.blockPosition())); mob.setPersistenceRequired(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/rabbit/Rabbit.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/rabbit/Rabbit.java.patch index 37c997cffb94..6c26de099a9b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/rabbit/Rabbit.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Rabbit.java -+++ b/net/minecraft/world/entity/animal/Rabbit.java -@@ -98,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/rabbit/Rabbit.java ++++ b/net/minecraft/world/entity/animal/rabbit/Rabbit.java +@@ -99,7 +_,7 @@ super(type, level); this.jumpControl = new Rabbit.RabbitJumpControl(this); this.moveControl = new Rabbit.RabbitMoveControl(this); @@ -9,7 +9,7 @@ } @Override -@@ -588,9 +_,11 @@ +@@ -589,9 +_,11 @@ if (this.canRaid && block instanceof CarrotBlock) { int ageValue = blockState.getValue(CarrotBlock.AGE); if (ageValue == 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Squid.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/squid/Squid.java.patch similarity index 72% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Squid.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/squid/Squid.java.patch index e7d710d0d619..b6389c8fc3e5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Squid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/squid/Squid.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Squid.java -+++ b/net/minecraft/world/entity/animal/Squid.java -@@ -47,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/squid/Squid.java ++++ b/net/minecraft/world/entity/animal/squid/Squid.java +@@ -48,7 +_,7 @@ public Squid(EntityType type, Level level) { super(type, level); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/turtle/Turtle.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/turtle/Turtle.java.patch index 8b82dacb92db..f65385287f30 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/turtle/Turtle.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Turtle.java -+++ b/net/minecraft/world/entity/animal/Turtle.java -@@ -255,7 +_,9 @@ +--- a/net/minecraft/world/entity/animal/turtle/Turtle.java ++++ b/net/minecraft/world/entity/animal/turtle/Turtle.java +@@ -256,7 +_,9 @@ protected void ageBoundaryReached() { super.ageBoundaryReached(); if (!this.isBaby() && this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.MOB_DROPS)) { @@ -10,7 +10,7 @@ } } -@@ -276,7 +_,7 @@ +@@ -277,7 +_,7 @@ @Override public void thunderHit(ServerLevel level, LightningBolt lightning) { @@ -19,7 +19,7 @@ } @Override -@@ -303,6 +_,10 @@ +@@ -304,6 +_,10 @@ if (loveCause == null && this.partner.getLoveCause() != null) { loveCause = this.partner.getLoveCause(); } @@ -30,7 +30,7 @@ if (loveCause != null) { loveCause.awardStat(Stats.ANIMALS_BRED); -@@ -316,7 +_,7 @@ +@@ -317,7 +_,7 @@ this.partner.resetLove(); RandomSource random = this.animal.getRandom(); if (getServerLevel(this.level).getGameRules().get(GameRules.MOB_DROPS)) { @@ -39,7 +39,7 @@ } } } -@@ -339,7 +_,7 @@ +@@ -340,7 +_,7 @@ && ( this.turtle.hasEgg() || this.turtle.getRandom().nextInt(reducedTickDelay(700)) == 0 && !this.turtle.homePos.closerToCenterThan(this.turtle.position(), 64.0) @@ -48,7 +48,7 @@ } @Override -@@ -447,14 +_,20 @@ +@@ -448,14 +_,20 @@ BlockPos blockPos = this.turtle.blockPosition(); if (!this.turtle.isInWater() && this.isReachedTarget()) { if (this.turtle.layEggCounter < 1) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch index 27e7b473a0dc..5d79a91cff04 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -@@ -87,6 +_,10 @@ +@@ -86,6 +_,10 @@ private final Node[] nodes = new Node[24]; private final int[] nodeAdjacency = new int[24]; private final BinaryHeap openSet = new BinaryHeap(); @@ -11,7 +11,7 @@ public EnderDragon(EntityType type, Level level) { super(EntityType.ENDER_DRAGON, level); -@@ -102,6 +_,7 @@ +@@ -101,6 +_,7 @@ this.setHealth(this.getMaxHealth()); this.noPhysics = true; this.phaseManager = new EnderDragonPhaseManager(this); @@ -19,7 +19,7 @@ } public void setDragonFight(EndDragonFight dragonFight) { -@@ -120,6 +_,19 @@ +@@ -119,6 +_,19 @@ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 200.0).add(Attributes.CAMERA_DISTANCE, 16.0); } @@ -39,7 +39,7 @@ @Override public boolean isFlapping() { float cos = Mth.cos(this.flapTime * (float) (Math.PI * 2)); -@@ -211,7 +_,7 @@ +@@ -210,7 +_,7 @@ } Vec3 flyTargetLocation = currentPhase.getFlyTargetLocation(); @@ -48,7 +48,7 @@ double d = flyTargetLocation.x - this.getX(); double d1 = flyTargetLocation.y - this.getY(); double d2 = flyTargetLocation.z - this.getZ(); -@@ -366,7 +_,12 @@ +@@ -365,7 +_,12 @@ if (this.nearestCrystal.isRemoved()) { this.nearestCrystal = null; } else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -62,7 +62,7 @@ } } -@@ -396,7 +_,7 @@ +@@ -395,7 +_,7 @@ double d2 = entity.getX() - d; double d3 = entity.getZ() - d1; double max = Math.max(d2 * d2 + d3 * d3, 0.1); @@ -71,7 +71,7 @@ if (!this.phaseManager.getCurrentPhase().isSitting() && livingEntity.getLastHurtByMobTimestamp() < entity.tickCount - 2) { DamageSource damageSource = this.damageSources().mobAttack(this); entity.hurtServer(level, damageSource, 5.0F); -@@ -429,6 +_,7 @@ +@@ -428,6 +_,7 @@ int floor5 = Mth.floor(box.maxZ); boolean flag = false; boolean flag1 = false; @@ -79,7 +79,7 @@ for (int i = floor; i <= floor3; i++) { for (int i1 = floor1; i1 <= floor4; i1++) { -@@ -437,7 +_,11 @@ +@@ -436,7 +_,11 @@ BlockState blockState = level.getBlockState(blockPos); if (!blockState.isAir() && !blockState.is(BlockTags.DRAGON_TRANSPARENT)) { if (level.getGameRules().get(GameRules.MOB_GRIEFING) && !blockState.is(BlockTags.DRAGON_IMMUNE)) { @@ -92,7 +92,7 @@ } else { flag = true; } -@@ -446,6 +_,58 @@ +@@ -445,6 +_,58 @@ } } @@ -151,7 +151,7 @@ if (flag1) { BlockPos blockPos1 = new BlockPos( floor + this.random.nextInt(floor3 - floor + 1), -@@ -503,7 +_,15 @@ +@@ -502,7 +_,15 @@ @Override public void kill(ServerLevel level) { @@ -168,7 +168,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); if (this.dragonFight != null) { this.dragonFight.updateDragon(this); -@@ -525,18 +_,41 @@ +@@ -524,18 +_,41 @@ this.level().addParticle(ParticleTypes.EXPLOSION_EMITTER, this.getX() + f, this.getY() + 2.0 + f1, this.getZ() + f2, 0.0, 0.0, 0.0); } @@ -213,7 +213,7 @@ } } -@@ -549,15 +_,15 @@ +@@ -548,15 +_,15 @@ } if (this.dragonDeathTime == 200 && this.level() instanceof ServerLevel serverLevel1) { @@ -232,7 +232,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); } } -@@ -738,6 +_,7 @@ +@@ -737,6 +_,7 @@ super.addAdditionalSaveData(output); output.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId()); output.putInt("DragonDeathTime", this.dragonDeathTime); @@ -240,7 +240,7 @@ } @Override -@@ -745,6 +_,7 @@ +@@ -744,6 +_,7 @@ super.readAdditionalSaveData(input); input.getInt("DragonPhase").ifPresent(integer -> this.phaseManager.setPhase(EnderDragonPhase.getById(integer))); this.dragonDeathTime = input.getIntOr("DragonDeathTime", 0); @@ -248,7 +248,7 @@ } @Override -@@ -785,7 +_,7 @@ +@@ -784,7 +_,7 @@ EnderDragonPhase phase = currentPhase.getPhase(); Vec3 viewVector; if (phase == EnderDragonPhase.LANDING || phase == EnderDragonPhase.TAKEOFF) { @@ -257,7 +257,7 @@ float max = Math.max((float)Math.sqrt(heightmapPos.distToCenterSqr(this.position())) / 4.0F, 1.0F); float f = 6.0F / max; float xRot = this.getXRot(); -@@ -872,4 +_,19 @@ +@@ -871,4 +_,19 @@ protected float sanitizeScale(float scale) { return 1.0F; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/Painting.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/painting/Painting.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/entity/decoration/Painting.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/decoration/painting/Painting.java.patch index b4fe3f726bf7..d7108d5cf4ec 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/Painting.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/painting/Painting.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/decoration/Painting.java -+++ b/net/minecraft/world/entity/decoration/Painting.java -@@ -148,21 +_,31 @@ +--- a/net/minecraft/world/entity/decoration/painting/Painting.java ++++ b/net/minecraft/world/entity/decoration/painting/Painting.java +@@ -149,21 +_,31 @@ @Override protected AABB calculateBoundingBox(BlockPos pos, Direction direction) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch index 752755c85ffa..a0e52436cfed 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Ravager.java +++ b/net/minecraft/world/entity/monster/Ravager.java -@@ -154,12 +_,19 @@ +@@ -155,12 +_,19 @@ BlockState blockState = serverLevel.getBlockState(blockPos); Block block = blockState.getBlock(); if (block instanceof LeavesBlock) { @@ -20,7 +20,7 @@ } } -@@ -249,7 +_,7 @@ +@@ -250,7 +_,7 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double max = Math.max(d * d + d1 * d1, 0.001); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch index c2026f351255..7da583c2e8c5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Strider.java +++ b/net/minecraft/world/entity/monster/Strider.java -@@ -293,7 +_,14 @@ +@@ -294,7 +_,14 @@ || blockStateOnLegacy.is(BlockTags.STRIDER_WARM_BLOCKS) || this.getFluidHeight(FluidTags.LAVA) > 0.0; boolean flag1 = this.getVehicle() instanceof Strider strider && strider.isSuffocating(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Evoker.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Evoker.java.patch similarity index 78% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Evoker.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Evoker.java.patch index 9632f43aca78..1c8641669946 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Evoker.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Evoker.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/Evoker.java -+++ b/net/minecraft/world/entity/monster/Evoker.java -@@ -245,7 +_,7 @@ +--- a/net/minecraft/world/entity/monster/illager/Evoker.java ++++ b/net/minecraft/world/entity/monster/illager/Evoker.java +@@ -247,7 +_,7 @@ serverLevel.getScoreboard().addPlayerToTeam(vex.getScoreboardName(), team); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Illusioner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Illusioner.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Illusioner.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Illusioner.java.patch index 9108cd36f8fa..07a12f5fd228 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Illusioner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Illusioner.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/Illusioner.java -+++ b/net/minecraft/world/entity/monster/Illusioner.java -@@ -172,7 +_,8 @@ +--- a/net/minecraft/world/entity/monster/illager/Illusioner.java ++++ b/net/minecraft/world/entity/monster/illager/Illusioner.java +@@ -174,7 +_,8 @@ @Override public void performRangedAttack(LivingEntity target, float distanceFactor) { @@ -10,7 +10,7 @@ ItemStack projectile = this.getProjectile(itemInHand); AbstractArrow mobArrow = ProjectileUtil.getMobArrow(this, projectile, distanceFactor, itemInHand); double d = target.getX() - this.getX(); -@@ -180,9 +_,21 @@ +@@ -182,9 +_,21 @@ double d2 = target.getZ() - this.getZ(); double squareRoot = Math.sqrt(d * d + d2 * d2); if (this.level() instanceof ServerLevel serverLevel) { @@ -33,7 +33,7 @@ } this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); -@@ -229,7 +_,7 @@ +@@ -231,7 +_,7 @@ @Override protected void performSpellCasting() { @@ -42,7 +42,7 @@ } @Override -@@ -261,7 +_,7 @@ +@@ -263,7 +_,7 @@ @Override protected void performSpellCasting() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Pillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Pillager.java.patch similarity index 73% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Pillager.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Pillager.java.patch index baac9f090b12..575d644e7872 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Pillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Pillager.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/Pillager.java -+++ b/net/minecraft/world/entity/monster/Pillager.java -@@ -214,7 +_,7 @@ +--- a/net/minecraft/world/entity/monster/illager/Pillager.java ++++ b/net/minecraft/world/entity/monster/illager/Pillager.java +@@ -215,7 +_,7 @@ this.onItemPickup(entity); ItemStack itemStack = this.inventory.addItem(item); if (itemStack.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java.patch similarity index 79% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java.patch index b959b59a0e50..5eaaf1fba832 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/monster/SpellcasterIllager.java -+++ b/net/minecraft/world/entity/monster/SpellcasterIllager.java +--- a/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java ++++ b/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java @@ -210,6 +_,11 @@ public void tick() { this.attackWarmupDelay--; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vindicator.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Vindicator.java.patch similarity index 79% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Vindicator.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Vindicator.java.patch index 5aa541a68ac5..9e3dfa15dd41 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vindicator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Vindicator.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/Vindicator.java -+++ b/net/minecraft/world/entity/monster/Vindicator.java -@@ -182,7 +_,7 @@ +--- a/net/minecraft/world/entity/monster/illager/Vindicator.java ++++ b/net/minecraft/world/entity/monster/illager/Vindicator.java +@@ -183,7 +_,7 @@ static class VindicatorBreakDoorGoal extends BreakDoorGoal { public VindicatorBreakDoorGoal(Mob mob) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch index c79bd690da28..531622193478 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -124,6 +_,12 @@ - MemoryModuleType.ATE_RECENTLY, - MemoryModuleType.NEAREST_REPELLENT +@@ -129,6 +_,12 @@ + MemoryModuleType.SPEAR_ENGAGE_TIME, + MemoryModuleType.SPEAR_STATUS ); + // CraftBukkit start - Custom bartering and interest list + public java.util.Set allowedBarterItems = new java.util.HashSet<>(); @@ -13,7 +13,7 @@ public Piglin(EntityType type, Level level) { super(type, level); -@@ -136,6 +_,10 @@ +@@ -141,6 +_,10 @@ output.putBoolean("IsBaby", this.isBaby()); output.putBoolean("CannotHunt", this.cannotHunt); this.writeInventoryToTag(output); @@ -24,7 +24,7 @@ } @Override -@@ -144,6 +_,10 @@ +@@ -149,6 +_,10 @@ this.setBaby(input.getBooleanOr("IsBaby", false)); this.setCannotHunt(input.getBooleanOr("CannotHunt", false)); this.readInventoryFromTag(input); @@ -35,7 +35,7 @@ } @VisibleForDebug -@@ -309,7 +_,9 @@ +@@ -314,7 +_,9 @@ @Override protected void finishConversion(ServerLevel level) { PiglinAi.cancelAdmiring(level, this); @@ -45,7 +45,7 @@ super.finishConversion(level); } -@@ -386,7 +_,7 @@ +@@ -391,7 +_,7 @@ } protected void holdInOffHand(ItemStack stack) { @@ -54,7 +54,7 @@ this.setItemSlot(EquipmentSlot.OFFHAND, stack); this.setGuaranteedDrop(EquipmentSlot.OFFHAND); } else { -@@ -411,15 +_,15 @@ +@@ -416,15 +_,15 @@ return false; } else { TagKey preferredWeaponType = this.getPreferredWeaponType(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch index 72683033ecfc..6ed008f0f724 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/PiglinAi.java +++ b/net/minecraft/world/entity/monster/piglin/PiglinAi.java -@@ -330,23 +_,32 @@ +@@ -336,23 +_,32 @@ protected static void pickUpItem(ServerLevel level, Piglin piglin, ItemEntity itemEntity) { stopWalking(piglin); ItemStack item; @@ -38,7 +38,7 @@ if (!flag) { putInInventory(piglin, item); } -@@ -355,7 +_,9 @@ +@@ -361,7 +_,9 @@ private static void holdInOffhand(ServerLevel level, Piglin piglin, ItemStack stack) { if (isHoldingItemInOffHand(piglin)) { @@ -48,7 +48,7 @@ } piglin.holdInOffHand(stack); -@@ -365,7 +_,7 @@ +@@ -371,7 +_,7 @@ ItemStack item = itemEntity.getItem(); ItemStack itemStack = item.split(1); if (item.isEmpty()) { @@ -57,7 +57,7 @@ } else { itemEntity.setItem(item); } -@@ -377,9 +_,14 @@ +@@ -383,9 +_,14 @@ ItemStack itemInHand = piglin.getItemInHand(InteractionHand.OFF_HAND); piglin.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); if (piglin.isAdult()) { @@ -74,7 +74,7 @@ } else if (!isBarterCurrency) { boolean flag = !piglin.equipItemIfPossible(level, itemInHand).isEmpty(); if (!flag) { -@@ -390,7 +_,7 @@ +@@ -396,7 +_,7 @@ boolean isBarterCurrency = !piglin.equipItemIfPossible(level, itemInHand).isEmpty(); if (!isBarterCurrency) { ItemStack mainHandItem = piglin.getMainHandItem(); @@ -83,7 +83,7 @@ putInInventory(piglin, mainHandItem); } else { throwItems(piglin, Collections.singletonList(mainHandItem)); -@@ -403,7 +_,9 @@ +@@ -409,7 +_,9 @@ protected static void cancelAdmiring(ServerLevel level, Piglin piglin) { if (isAdmiringItem(piglin) && !piglin.getOffhandItem().isEmpty()) { @@ -93,7 +93,7 @@ piglin.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); } } -@@ -459,7 +_,7 @@ +@@ -465,7 +_,7 @@ return false; } else if (isAdmiringDisabled(piglin) && piglin.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) { return false; @@ -102,7 +102,7 @@ return isNotHoldingLovedItemInOffHand(piglin); } else { boolean canAddToInventory = piglin.canAddToInventory(stack); -@@ -468,11 +_,16 @@ +@@ -474,11 +_,16 @@ } else if (isFood(stack)) { return !hasEatenRecently(piglin) && canAddToInventory; } else { @@ -120,7 +120,7 @@ protected static boolean isLovedItem(ItemStack item) { return item.is(ItemTags.PIGLIN_LOVED); } -@@ -524,6 +_,7 @@ +@@ -530,6 +_,7 @@ } public static void angerNearbyPiglins(ServerLevel level, Player player, boolean requireLineOfSight) { @@ -128,7 +128,7 @@ List entitiesOfClass = player.level().getEntitiesOfClass(Piglin.class, player.getBoundingBox().inflate(16.0)); entitiesOfClass.stream().filter(PiglinAi::isIdle).filter(piglin -> !requireLineOfSight || BehaviorUtils.canSee(piglin, player)).forEach(piglin -> { if (level.getGameRules().get(GameRules.UNIVERSAL_ANGER)) { -@@ -548,7 +_,7 @@ +@@ -554,7 +_,7 @@ } protected static boolean canAdmire(Piglin piglin, ItemStack stack) { @@ -137,7 +137,7 @@ } protected static void wasHurtBy(ServerLevel level, Piglin piglin, LivingEntity entity) { -@@ -796,6 +_,11 @@ +@@ -802,6 +_,11 @@ return piglin.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM); } @@ -149,7 +149,7 @@ private static boolean isBarterCurrency(ItemStack stack) { return stack.is(BARTERING_ITEM); } -@@ -833,7 +_,7 @@ +@@ -839,7 +_,7 @@ } private static boolean isNotHoldingLovedItemInOffHand(Piglin piglin) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java.patch index adc766a54f6a..108bb28ad52d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/AbstractSkeleton.java -+++ b/net/minecraft/world/entity/monster/AbstractSkeleton.java -@@ -65,6 +_,7 @@ +--- a/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java ++++ b/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java +@@ -66,6 +_,7 @@ AbstractSkeleton.this.setAggressive(true); } }; @@ -8,7 +8,7 @@ protected AbstractSkeleton(EntityType type, Level level) { super(type, level); -@@ -89,6 +_,21 @@ +@@ -90,6 +_,21 @@ return Monster.createMonsterAttributes().add(Attributes.MOVEMENT_SPEED, 0.25); } @@ -30,7 +30,7 @@ @Override protected void playStepSound(BlockPos pos, BlockState block) { this.playSound(this.getStepSound(), 0.15F, 1.0F); -@@ -119,7 +_,7 @@ +@@ -120,7 +_,7 @@ this.populateDefaultEquipmentSlots(random, difficulty); this.populateDefaultEquipmentEnchantments(level, random, difficulty); this.reassessWeaponGoal(); @@ -39,7 +39,7 @@ if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty() && SpecialDates.isHalloween() && random.nextFloat() < 0.25F) { this.setItemSlot(EquipmentSlot.HEAD, new ItemStack(random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN)); this.setDropChance(EquipmentSlot.HEAD, 0.0F); -@@ -157,7 +_,8 @@ +@@ -158,7 +_,8 @@ @Override public void performRangedAttack(LivingEntity target, float distanceFactor) { @@ -49,7 +49,7 @@ ItemStack projectile = this.getProjectile(itemInHand); AbstractArrow arrow = this.getArrow(projectile, distanceFactor, itemInHand); double d = target.getX() - this.getX(); -@@ -165,9 +_,21 @@ +@@ -166,9 +_,21 @@ double d2 = target.getZ() - this.getZ(); double squareRoot = Math.sqrt(d * d + d2 * d2); if (this.level() instanceof ServerLevel serverLevel) { @@ -72,7 +72,7 @@ } this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); -@@ -191,11 +_,22 @@ +@@ -192,11 +_,22 @@ protected void readAdditionalSaveData(ValueInput input) { super.readAdditionalSaveData(input); this.reassessWeaponGoal(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Bogged.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Bogged.java.patch similarity index 96% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Bogged.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Bogged.java.patch index 6d7d6d459cc8..787f5c998ca1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Bogged.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Bogged.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/monster/Bogged.java -+++ b/net/minecraft/world/entity/monster/Bogged.java +--- a/net/minecraft/world/entity/monster/skeleton/Bogged.java ++++ b/net/minecraft/world/entity/monster/skeleton/Bogged.java @@ -72,7 +_,19 @@ ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Skeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Skeleton.java.patch similarity index 88% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Skeleton.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Skeleton.java.patch index 1176065314ba..828eee49ccaf 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Skeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Skeleton.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/monster/Skeleton.java -+++ b/net/minecraft/world/entity/monster/Skeleton.java +--- a/net/minecraft/world/entity/monster/skeleton/Skeleton.java ++++ b/net/minecraft/world/entity/monster/skeleton/Skeleton.java @@ -93,11 +_,17 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/WitherSkeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/WitherSkeleton.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch index 0dcfd955d3ea..aabf999cbe62 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/WitherSkeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/monster/WitherSkeleton.java -+++ b/net/minecraft/world/entity/monster/WitherSkeleton.java +--- a/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java ++++ b/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java @@ -95,7 +_,7 @@ return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/CaveSpider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/CaveSpider.java.patch similarity index 76% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/CaveSpider.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/spider/CaveSpider.java.patch index 8a80dbdffbd8..cf4e7adfc5c8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/CaveSpider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/CaveSpider.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/monster/CaveSpider.java -+++ b/net/minecraft/world/entity/monster/CaveSpider.java +--- a/net/minecraft/world/entity/monster/spider/CaveSpider.java ++++ b/net/minecraft/world/entity/monster/spider/CaveSpider.java @@ -38,7 +_,7 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/Spider.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/spider/Spider.java.patch index fd73c021d9ec..6448027f791a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/Spider.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/Spider.java -+++ b/net/minecraft/world/entity/monster/Spider.java -@@ -79,7 +_,7 @@ +--- a/net/minecraft/world/entity/monster/spider/Spider.java ++++ b/net/minecraft/world/entity/monster/spider/Spider.java +@@ -81,7 +_,7 @@ public void tick() { super.tick(); if (!this.level().isClientSide()) { @@ -9,7 +9,7 @@ } } -@@ -121,7 +_,7 @@ +@@ -123,7 +_,7 @@ @Override public boolean canBeAffected(MobEffectInstance effectInstance) { @@ -18,7 +18,7 @@ } public boolean isClimbing() { -@@ -164,7 +_,7 @@ +@@ -166,7 +_,7 @@ if (spawnGroupData instanceof Spider.SpiderEffectsGroupData spiderEffectsGroupData) { Holder holder = spiderEffectsGroupData.effect; if (holder != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Drowned.java.patch similarity index 88% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Drowned.java.patch index 28b883945a16..1aee8901a3a3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Drowned.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/Drowned.java -+++ b/net/minecraft/world/entity/monster/Drowned.java -@@ -88,7 +_,7 @@ +--- a/net/minecraft/world/entity/monster/zombie/Drowned.java ++++ b/net/minecraft/world/entity/monster/zombie/Drowned.java +@@ -89,7 +_,7 @@ this.goalSelector.addGoal(7, new RandomStrollGoal(this, 1.0)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this, Drowned.class).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, (entity, level) -> this.okTarget(entity))); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Husk.java.patch similarity index 82% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Husk.java.patch index 14b5a8c69208..1fa36a18b826 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Husk.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/Husk.java -+++ b/net/minecraft/world/entity/monster/Husk.java -@@ -58,7 +_,7 @@ +--- a/net/minecraft/world/entity/monster/zombie/Husk.java ++++ b/net/minecraft/world/entity/monster/zombie/Husk.java +@@ -59,7 +_,7 @@ boolean flag = super.doHurtTarget(level, target); if (flag && this.getMainHandItem().isEmpty() && target instanceof LivingEntity) { float effectiveDifficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch similarity index 97% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch index f41237a75717..2437917660cc 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/Zombie.java -+++ b/net/minecraft/world/entity/monster/Zombie.java -@@ -66,9 +_,7 @@ +--- a/net/minecraft/world/entity/monster/zombie/Zombie.java ++++ b/net/minecraft/world/entity/monster/zombie/Zombie.java +@@ -67,9 +_,7 @@ public class Zombie extends Monster { private static final Identifier SPEED_MODIFIER_BABY_ID = Identifier.withDefaultNamespace("baby"); @@ -11,7 +11,7 @@ private static final Identifier REINFORCEMENT_CALLER_CHARGE_ID = Identifier.withDefaultNamespace("reinforcement_caller_charge"); private static final AttributeModifier ZOMBIE_REINFORCEMENT_CALLEE_CHARGE = new AttributeModifier( Identifier.withDefaultNamespace("reinforcement_callee_charge"), -0.05F, AttributeModifier.Operation.ADD_VALUE -@@ -89,13 +_,15 @@ +@@ -90,13 +_,15 @@ private static final boolean DEFAULT_BABY = false; private static final boolean DEFAULT_CAN_BREAK_DOORS = false; private static final int DEFAULT_IN_WATER_TIME = 0; @@ -28,7 +28,7 @@ } public Zombie(Level level) { -@@ -104,7 +_,7 @@ +@@ -105,7 +_,7 @@ @Override protected void registerGoals() { @@ -37,7 +37,7 @@ this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F)); this.goalSelector.addGoal(8, new RandomLookAroundGoal(this)); this.addBehaviourGoals(); -@@ -117,7 +_,7 @@ +@@ -118,7 +_,7 @@ this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); @@ -46,7 +46,7 @@ this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true)); this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR)); } -@@ -171,11 +_,16 @@ +@@ -172,11 +_,16 @@ @Override protected int getBaseExperienceReward(ServerLevel level) { @@ -64,7 +64,7 @@ } @Override -@@ -183,9 +_,9 @@ +@@ -184,9 +_,9 @@ this.getEntityData().set(DATA_BABY_ID, childZombie); if (this.level() != null && !this.level().isClientSide()) { AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED); @@ -76,7 +76,7 @@ } } } -@@ -226,6 +_,13 @@ +@@ -227,6 +_,13 @@ super.tick(); } @@ -90,7 +90,7 @@ public void startUnderWaterConversion(int conversionTime) { this.conversionTime = conversionTime; this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, true); -@@ -239,31 +_,50 @@ +@@ -240,31 +_,50 @@ } protected void convertToZombieType(ServerLevel level, EntityType entityType) { @@ -150,7 +150,7 @@ @Override public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { -@@ -296,13 +_,13 @@ +@@ -297,13 +_,13 @@ if (SpawnPlacements.isSpawnPositionOk(type, level, blockPos) && SpawnPlacements.checkSpawnRules(type, level, EntitySpawnReason.REINFORCEMENT, blockPos, level.random)) { zombie.setPos(i1, i2, i3); @@ -167,7 +167,7 @@ AttributeInstance attribute = this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE); AttributeModifier modifier = attribute.getModifier(REINFORCEMENT_CALLER_CHARGE_ID); double d = modifier != null ? modifier.amount() : 0.0; -@@ -327,7 +_,12 @@ +@@ -328,7 +_,12 @@ if (flag) { float effectiveDifficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < effectiveDifficulty * 0.3F) { @@ -181,7 +181,7 @@ } } -@@ -389,6 +_,7 @@ +@@ -390,6 +_,7 @@ output.putBoolean("CanBreakDoors", this.canBreakDoors()); output.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1); output.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1); @@ -189,7 +189,7 @@ } @Override -@@ -403,13 +_,15 @@ +@@ -404,13 +_,15 @@ } else { this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, false); } @@ -207,7 +207,7 @@ return flag; } -@@ -444,7 +_,7 @@ +@@ -445,7 +_,7 @@ spawnGroupData = super.finalizeSpawn(level, difficulty, spawnReason, spawnGroupData); float specialMultiplier = difficulty.getSpecialMultiplier(); if (spawnReason != EntitySpawnReason.CONVERSION) { @@ -216,7 +216,7 @@ } if (spawnGroupData == null) { -@@ -471,7 +_,7 @@ +@@ -472,7 +_,7 @@ chicken1.finalizeSpawn(level, difficulty, EntitySpawnReason.JOCKEY, null); chicken1.setChickenJockey(true); this.startRiding(chicken1, false, false); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch index 948098620892..b761296a746a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/monster/ZombieVillager.java -+++ b/net/minecraft/world/entity/monster/ZombieVillager.java +--- a/net/minecraft/world/entity/monster/zombie/ZombieVillager.java ++++ b/net/minecraft/world/entity/monster/zombie/ZombieVillager.java @@ -167,12 +_,20 @@ } @@ -8,7 +8,7 @@ + this.startConverting(conversionStarter, villagerConversionTime, true); + } + -+ public void startConverting(@Nullable UUID conversionStarter, int villagerConversionTime, boolean broadcastEntityEvent) { ++ private void startConverting(@Nullable UUID conversionStarter, int villagerConversionTime, boolean broadcastEntityEvent) { + // Paper end - missing entity behaviour api - converting without entity event this.conversionStarter = conversionStarter; this.villagerConversionTime = villagerConversionTime; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java.patch index 2b43c1a453ec..923e5403fa79 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/monster/ZombifiedPiglin.java -+++ b/net/minecraft/world/entity/monster/ZombifiedPiglin.java +--- a/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java ++++ b/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java @@ -57,6 +_,7 @@ private static final int ALERT_RANGE_Y = 10; private static final UniformInt ALERT_INTERVAL = TimeUtil.rangeOfSeconds(4, 6); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/AbstractVillager.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/npc/villager/AbstractVillager.java.patch index 56eb11e321c0..f032420bf2ec 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/AbstractVillager.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/npc/AbstractVillager.java -+++ b/net/minecraft/world/entity/npc/AbstractVillager.java -@@ -41,7 +_,7 @@ +--- a/net/minecraft/world/entity/npc/villager/AbstractVillager.java ++++ b/net/minecraft/world/entity/npc/villager/AbstractVillager.java +@@ -43,7 +_,7 @@ private static final int VILLAGER_INVENTORY_SIZE = 8; private @Nullable Player tradingPlayer; protected @Nullable MerchantOffers offers; @@ -9,7 +9,7 @@ public AbstractVillager(EntityType type, Level level) { super(type, level); -@@ -93,6 +_,20 @@ +@@ -95,6 +_,20 @@ return this.tradingPlayer != null; } @@ -30,7 +30,7 @@ @Override public MerchantOffers getOffers() { if (this.level() instanceof ServerLevel serverLevel) { -@@ -115,11 +_,24 @@ +@@ -117,11 +_,24 @@ public void overrideXp(int xp) { } @@ -57,7 +57,7 @@ if (this.tradingPlayer instanceof ServerPlayer) { CriteriaTriggers.TRADE.trigger((ServerPlayer)this.tradingPlayer, this, offer.getResult()); } -@@ -223,7 +_,20 @@ +@@ -225,7 +_,20 @@ while (i < maxNumbers && !list.isEmpty()) { MerchantOffer offer = list.remove(this.random.nextInt(list.size())).getOffer(level, this, this.random); if (offer != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/Villager.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/npc/villager/Villager.java.patch index 213ff7ba75e4..9065f2e46d63 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/Villager.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/npc/Villager.java -+++ b/net/minecraft/world/entity/npc/Villager.java -@@ -286,7 +_,7 @@ +--- a/net/minecraft/world/entity/npc/villager/Villager.java ++++ b/net/minecraft/world/entity/npc/villager/Villager.java +@@ -287,7 +_,7 @@ this.increaseProfessionLevelOnUpdate = false; } @@ -9,7 +9,7 @@ } } -@@ -395,7 +_,12 @@ +@@ -396,7 +_,12 @@ this.updateDemand(); for (MerchantOffer merchantOffer : this.getOffers()) { @@ -23,7 +23,7 @@ } this.resendOffersToTradingPlayer(); -@@ -451,7 +_,12 @@ +@@ -452,7 +_,12 @@ int i = 2 - this.numberOfRestocksToday; if (i > 0) { for (MerchantOffer merchantOffer : this.getOffers()) { @@ -37,7 +37,7 @@ } } -@@ -472,6 +_,7 @@ +@@ -473,6 +_,7 @@ int playerReputation = this.getPlayerReputation(player); if (playerReputation != 0) { for (MerchantOffer merchantOffer : this.getOffers()) { @@ -45,7 +45,7 @@ merchantOffer.addToSpecialPriceDiff(-Mth.floor(playerReputation * merchantOffer.getPriceMultiplier())); } } -@@ -481,6 +_,7 @@ +@@ -482,6 +_,7 @@ int amplifier = effect.getAmplifier(); for (MerchantOffer merchantOffer1 : this.getOffers()) { @@ -53,7 +53,7 @@ double d = 0.3 + 0.0625 * amplifier; int i = (int)Math.floor(d * merchantOffer1.getBaseCostA().getCount()); merchantOffer1.addToSpecialPriceDiff(-Math.max(i, 1)); -@@ -588,7 +_,7 @@ +@@ -589,7 +_,7 @@ } if (offer.shouldRewardExp()) { @@ -62,7 +62,7 @@ } } -@@ -606,7 +_,7 @@ +@@ -607,7 +_,7 @@ @Override public void die(DamageSource damageSource) { @@ -71,7 +71,7 @@ Entity entity = damageSource.getEntity(); if (entity != null) { this.tellWitnessesThatIWasMurdered(entity); -@@ -705,7 +_,7 @@ +@@ -706,7 +_,7 @@ return VillagerData.canLevelUp(level) && this.villagerXp >= VillagerData.getMaxXpPerLevel(level); } @@ -80,7 +80,7 @@ this.setVillagerData(this.getVillagerData().withLevel(this.getVillagerData().level() + 1)); this.updateTrades(level); } -@@ -772,12 +_,19 @@ +@@ -773,12 +_,19 @@ @Override public void thunderHit(ServerLevel level, LightningBolt lightning) { if (level.getDifficulty() != Difficulty.PEACEFUL) { @@ -102,7 +102,7 @@ if (witch == null) { super.thunderHit(level, lightning); } -@@ -817,6 +_,12 @@ +@@ -818,6 +_,12 @@ @Override protected void updateTrades(ServerLevel level) { @@ -115,7 +115,7 @@ VillagerData villagerData = this.getVillagerData(); ResourceKey resourceKey = villagerData.profession().unwrapKey().orElse(null); if (resourceKey != null) { -@@ -832,13 +_,15 @@ +@@ -833,13 +_,15 @@ VillagerTrades.ItemListing[] itemListings = map1.get(villagerData.level()); if (itemListings != null) { MerchantOffers offers = this.getOffers(); @@ -133,7 +133,7 @@ } public void gossip(ServerLevel level, Villager target, long gameTime) { -@@ -867,7 +_,7 @@ +@@ -868,7 +_,7 @@ List entitiesOfClass = level.getEntitiesOfClass(Villager.class, aabb); List list = entitiesOfClass.stream().filter(villager -> villager.wantsToSpawnGolem(gameTime)).limit(5L).toList(); if (list.size() >= minVillagerAmount) { @@ -142,7 +142,7 @@ EntityType.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, level, -@@ -876,9 +_,11 @@ +@@ -877,9 +_,11 @@ 8, 6, SpawnUtil.Strategy.LEGACY_IRON_GOLEM, diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/VillagerTrades.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/npc/villager/VillagerTrades.java.patch index 90dc6c5da082..3df5d43063e8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/VillagerTrades.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/npc/VillagerTrades.java -+++ b/net/minecraft/world/entity/npc/VillagerTrades.java +--- a/net/minecraft/world/entity/npc/villager/VillagerTrades.java ++++ b/net/minecraft/world/entity/npc/villager/VillagerTrades.java @@ -1737,7 +_,8 @@ @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java.patch index 97413a49a27b..ba03df93c684 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/npc/WanderingTrader.java -+++ b/net/minecraft/world/entity/npc/WanderingTrader.java -@@ -50,6 +_,10 @@ +--- a/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java ++++ b/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java +@@ -52,6 +_,10 @@ private static final int DEFAULT_DESPAWN_DELAY = 0; private @Nullable BlockPos wanderTarget; private int despawnDelay = 0; @@ -11,7 +11,7 @@ public WanderingTrader(EntityType type, Level level) { super(type, level); -@@ -65,7 +_,7 @@ +@@ -67,7 +_,7 @@ this, PotionContents.createItemStack(Items.POTION, Potions.INVISIBILITY), SoundEvents.WANDERING_TRADER_DISAPPEARED, @@ -20,7 +20,7 @@ ) ); this.goalSelector -@@ -75,7 +_,7 @@ +@@ -77,7 +_,7 @@ this, new ItemStack(Items.MILK_BUCKET), SoundEvents.WANDERING_TRADER_REAPPEARED, @@ -29,7 +29,7 @@ ) ); this.goalSelector.addGoal(1, new TradeWithPlayerGoal(this)); -@@ -162,7 +_,7 @@ +@@ -164,7 +_,7 @@ protected void rewardTradeXp(MerchantOffer offer) { if (offer.shouldRewardExp()) { int i = 3 + this.random.nextInt(4); @@ -38,7 +38,7 @@ } } -@@ -214,7 +_,7 @@ +@@ -216,7 +_,7 @@ private void maybeDespawn() { if (this.despawnDelay > 0 && !this.isTrading() && --this.despawnDelay == 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch similarity index 97% rename from paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch index 9e346da1df25..f88caff4d5cc 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/npc/WanderingTraderSpawner.java -+++ b/net/minecraft/world/entity/npc/WanderingTraderSpawner.java +--- a/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java ++++ b/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java @@ -38,36 +_,45 @@ public WanderingTraderSpawner(ServerLevelData serverLevelData) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index e61a241d39ca..56a703c64308 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -151,7 +_,7 @@ +@@ -150,7 +_,7 @@ private static final boolean DEFAULT_IGNORE_FALL_DAMAGE_FROM_CURRENT_IMPULSE = false; private static final int DEFAULT_CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME = 0; final Inventory inventory; @@ -9,7 +9,7 @@ public final InventoryMenu inventoryMenu; public AbstractContainerMenu containerMenu; protected FoodData foodData = new FoodData(); -@@ -179,6 +_,18 @@ +@@ -176,6 +_,18 @@ public @Nullable Entity currentExplosionCause; private boolean ignoreFallDamageFromCurrentImpulse = false; private int currentImpulseContextResetGraceTime = 0; @@ -28,7 +28,7 @@ public Player(Level level, GameProfile gameProfile) { super(EntityType.PLAYER, level); -@@ -246,6 +_,13 @@ +@@ -243,6 +_,13 @@ if (this.isSleeping()) { this.sleepCounter++; @@ -42,7 +42,7 @@ if (this.sleepCounter > 100) { this.sleepCounter = 100; } -@@ -329,7 +_,7 @@ +@@ -326,7 +_,7 @@ } private void turtleHelmetTick() { @@ -51,7 +51,7 @@ } private boolean isEquipped(Item item) { -@@ -433,6 +_,18 @@ +@@ -430,6 +_,18 @@ } } @@ -70,7 +70,7 @@ public void closeContainer() { this.containerMenu = this.inventoryMenu; } -@@ -444,8 +_,14 @@ +@@ -441,8 +_,14 @@ public void rideTick() { if (!this.level().isClientSide() && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -87,7 +87,7 @@ super.rideTick(); } } -@@ -704,10 +_,10 @@ +@@ -701,10 +_,10 @@ if (this.isDeadOrDying()) { return false; } else { @@ -100,7 +100,7 @@ } if (level.getDifficulty() == Difficulty.EASY) { -@@ -719,7 +_,14 @@ +@@ -716,7 +_,14 @@ } } @@ -116,7 +116,7 @@ } } } -@@ -731,7 +_,7 @@ +@@ -728,7 +_,7 @@ BlocksAttacks blocksAttacks = itemBlockingWith != null ? itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS) : null; float secondsToDisableBlocking = entity.getSecondsToDisableBlocking(); if (secondsToDisableBlocking > 0.0F && blocksAttacks != null) { @@ -125,7 +125,7 @@ } } -@@ -741,9 +_,29 @@ +@@ -738,9 +_,29 @@ } public boolean canHarmPlayer(Player other) { @@ -158,7 +158,7 @@ } @Override -@@ -757,7 +_,12 @@ +@@ -754,7 +_,12 @@ } @Override @@ -172,7 +172,7 @@ if (!this.isInvulnerableTo(level, damageSource)) { amount = this.getDamageAfterArmorAbsorb(damageSource, amount); amount = this.getDamageAfterMagicAbsorb(damageSource, amount); -@@ -769,7 +_,7 @@ +@@ -766,7 +_,7 @@ } if (var8 != 0.0F) { @@ -181,7 +181,7 @@ this.getCombatTracker().recordDamage(damageSource, var8); this.setHealth(this.getHealth() - var8); if (var8 < 3.4028235E37F) { -@@ -779,6 +_,7 @@ +@@ -776,6 +_,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -189,7 +189,7 @@ } public boolean isTextFilteringEnabled() { -@@ -865,14 +_,16 @@ +@@ -862,14 +_,16 @@ } @Override @@ -209,7 +209,7 @@ } @Override -@@ -951,15 +_,25 @@ +@@ -948,15 +_,25 @@ } public void attack(Entity target) { @@ -238,7 +238,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = attackStrengthScale > 0.9F; boolean flag1; -@@ -972,7 +_,9 @@ +@@ -969,7 +_,9 @@ f += weaponItem.getItem().getAttackDamageBonus(target, f, damageSource); boolean flag2 = flag && this.canCriticalAttack(target); @@ -248,7 +248,7 @@ f *= 1.5F; } -@@ -1018,11 +_,12 @@ +@@ -1015,11 +_,12 @@ return !target.isAttackable() || target.skipAttackInteraction(this); } @@ -263,7 +263,7 @@ return true; } else { return false; -@@ -1115,21 +_,43 @@ +@@ -1112,21 +_,43 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F) { if (target instanceof LivingEntity livingEntity) { @@ -308,7 +308,7 @@ } } -@@ -1150,7 +_,10 @@ +@@ -1147,7 +_,10 @@ && !(livingEntity instanceof ArmorStand armorStand && armorStand.isMarker()) && this.distanceToSqr(livingEntity) < 9.0) { float f1 = this.getEnchantedDamage(livingEntity, var12, damageSource) * strengthScale; @@ -320,7 +320,7 @@ livingEntity.knockback(0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity, damageSource); } -@@ -1182,7 +_,16 @@ +@@ -1179,7 +_,16 @@ @Override public boolean stabAttack(EquipmentSlot slot, Entity target, float damageAmount, boolean damage, boolean knockback, boolean dismount) { @@ -338,7 +338,7 @@ return false; } else { ItemStack itemBySlot = this.getItemBySlot(slot); -@@ -1193,7 +_,8 @@ +@@ -1190,7 +_,8 @@ damageAmount *= this.baseDamageScaleFactor(); } @@ -348,7 +348,7 @@ return true; } else { float f1 = damage ? damageAmount + f : 0.0F; -@@ -1221,7 +_,7 @@ +@@ -1218,7 +_,7 @@ this.setLastHurtMob(target); this.itemAttackInteraction(target, itemBySlot, damageSource, flag); this.damageStatsAndHearts(target, f2); @@ -357,7 +357,7 @@ return true; } } -@@ -1232,8 +_,8 @@ +@@ -1229,8 +_,8 @@ } @Override @@ -368,7 +368,7 @@ this.inventoryMenu.removed(this); if (this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1301,6 +_,12 @@ +@@ -1298,6 +_,12 @@ } public Either startSleepInBed(BlockPos bedPos) { @@ -381,7 +381,7 @@ this.startSleeping(bedPos); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1412,7 +_,7 @@ +@@ -1409,7 +_,7 @@ @Override public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) { @@ -390,7 +390,7 @@ return false; } else { if (fallDistance >= 2.0) { -@@ -1453,7 +_,15 @@ +@@ -1450,7 +_,15 @@ } public void startFallFlying() { @@ -407,7 +407,7 @@ } @Override -@@ -1551,7 +_,7 @@ +@@ -1548,7 +_,7 @@ if (levels > 0 && this.experienceLevel % 5 == 0 && this.lastLevelUpTime < this.tickCount - 100.0F) { float f = this.experienceLevel > 30 ? 1.0F : this.experienceLevel / 30.0F; @@ -416,7 +416,7 @@ this.lastLevelUpTime = this.tickCount; } } -@@ -1559,15 +_,35 @@ +@@ -1556,15 +_,35 @@ public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { return 112 + (this.experienceLevel - 30) * 9; @@ -454,7 +454,7 @@ } } } -@@ -1826,7 +_,7 @@ +@@ -1823,7 +_,7 @@ @Override public void onAttack() { @@ -463,7 +463,7 @@ super.onAttack(); } -@@ -1861,17 +_,32 @@ +@@ -1858,17 +_,32 @@ return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } @@ -498,7 +498,7 @@ for (int i = 0; i < this.inventory.getContainerSize(); i++) { ItemStack item = this.inventory.getItem(i); -@@ -1880,6 +_,7 @@ +@@ -1877,6 +_,7 @@ } } @@ -506,25 +506,3 @@ return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; } } -@@ -1966,12 +_,20 @@ - } - - public boolean hasClientLoaded() { -- return this.clientLoaded || this.clientLoadedTimeoutTimer <= 0; -+ return this.clientLoaded; // Paper - Add PlayerLoadedWorldEvent - } - - public void tickClientLoadTimeout() { - if (!this.clientLoaded) { - this.clientLoadedTimeoutTimer--; -+ // Paper start - Add PlayerLoadedWorldEvent -+ if (this.clientLoadedTimeoutTimer <= 0) { -+ this.clientLoaded = true; -+ -+ final io.papermc.paper.event.player.PlayerClientLoadedWorldEvent event = new io.papermc.paper.event.player.PlayerClientLoadedWorldEvent((org.bukkit.craftbukkit.entity.CraftPlayer) getBukkitEntity(), true); -+ event.callEvent(); -+ } -+ // Paper end - Add PlayerLoadedWorldEvent - } - } - diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch index 4ccdf0bec601..87b1e923f9cf 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java -@@ -43,6 +_,7 @@ +@@ -44,6 +_,7 @@ private boolean leftOwnerChecked; public boolean hasBeenShot = false; private @Nullable Entity lastDeflectedBy; + protected boolean hitCancelled = false; // CraftBukkit - Projectile(EntityType type, Level level) { + protected Projectile(EntityType type, Level level) { super(type, level); -@@ -50,12 +_,25 @@ +@@ -51,12 +_,25 @@ protected void setOwner(@Nullable EntityReference owner) { this.owner = owner; @@ -34,7 +34,7 @@ @Override public @Nullable Entity getOwner() { return EntityReference.getEntity(this.owner, this.level()); -@@ -82,6 +_,7 @@ +@@ -83,6 +_,7 @@ @Override protected void readAdditionalSaveData(ValueInput input) { this.setOwner(EntityReference.read(input, "Owner")); @@ -42,7 +42,7 @@ this.leftOwner = input.getBooleanOr("LeftOwner", false); this.hasBeenShot = input.getBooleanOr("HasBeenShot", false); } -@@ -154,7 +_,14 @@ +@@ -155,7 +_,14 @@ float f2 = Mth.cos(y * (float) (Math.PI / 180.0)) * Mth.cos(x * (float) (Math.PI / 180.0)); this.shoot(f, f1, f2, velocity, inaccuracy); Vec3 knownMovement = shooter.getKnownMovement(); @@ -57,7 +57,7 @@ } @Override -@@ -174,7 +_,12 @@ +@@ -175,7 +_,12 @@ public static T spawnProjectileFromRotation( Projectile.ProjectileFactory factory, ServerLevel level, ItemStack spawnedFrom, LivingEntity owner, float z, float velocity, float inaccuracy ) { @@ -71,7 +71,7 @@ factory.create(level, owner, spawnedFrom), level, spawnedFrom, -@@ -199,7 +_,13 @@ +@@ -200,7 +_,13 @@ public static T spawnProjectileUsingShoot( T projectile, ServerLevel level, ItemStack spawnedFrom, double x, double y, double z, float velocity, float inaccuracy ) { @@ -86,7 +86,7 @@ } public static T spawnProjectile(T projectile, ServerLevel level, ItemStack spawnedFrom) { -@@ -207,11 +_,46 @@ +@@ -208,11 +_,46 @@ } public static T spawnProjectile(T projectile, ServerLevel level, ItemStack stack, Consumer adapter) { @@ -137,7 +137,7 @@ public void applyOnProjectileSpawned(ServerLevel level, ItemStack spawnedFrom) { EnchantmentHelper.onProjectileSpawned(level, spawnedFrom, this, item -> {}); -@@ -223,6 +_,17 @@ +@@ -224,6 +_,17 @@ } } @@ -155,7 +155,7 @@ protected ProjectileDeflection hitTargetOrDeflectSelf(HitResult hitResult) { if (hitResult.getType() == HitResult.Type.ENTITY) { EntityHitResult entityHitResult = (EntityHitResult)hitResult; -@@ -290,15 +_,35 @@ +@@ -291,15 +_,35 @@ } protected void onHitBlock(BlockHitResult result) { @@ -191,7 +191,7 @@ return owner == null || this.leftOwner || !owner.isPassengerOfSameVehicle(target); } } -@@ -311,13 +_,7 @@ +@@ -312,13 +_,7 @@ } protected static float lerpRotation(float currentRotation, float targetRotation) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch index 7e747f41c175..cee3560183ff 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/projectile/AbstractArrow.java -+++ b/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -83,7 +_,14 @@ +--- a/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java ++++ b/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java +@@ -86,7 +_,14 @@ protected AbstractArrow( EntityType type, double x, double y, double z, Level level, ItemStack pickupItemStack, @Nullable ItemStack firedFromWeapon ) { @@ -15,7 +15,7 @@ this.pickupItemStack = pickupItemStack.copy(); this.applyComponentsFromItemStack(pickupItemStack); Unit unit = pickupItemStack.remove(DataComponents.INTANGIBLE_PROJECTILE); -@@ -108,8 +_,8 @@ +@@ -111,8 +_,8 @@ protected AbstractArrow( EntityType type, LivingEntity owner, Level level, ItemStack pickupItemStack, @Nullable ItemStack firedFromWeapon ) { @@ -26,7 +26,7 @@ } public void setSoundEvent(SoundEvent soundEvent) { -@@ -204,6 +_,7 @@ +@@ -207,6 +_,7 @@ this.setSharedFlagOnFire(this.getRemainingFireTicks() > 0); } } else { @@ -34,7 +34,7 @@ this.inGroundTime = 0; Vec3 vec31 = this.position(); if (this.isInWater()) { -@@ -273,7 +_,7 @@ +@@ -276,7 +_,7 @@ if (list.isEmpty()) { if (this.isAlive() && hitResult.getType() != HitResult.Type.MISS) { @@ -43,7 +43,7 @@ this.needsSync = true; } break; -@@ -290,7 +_,7 @@ +@@ -293,7 +_,7 @@ private ProjectileDeflection hitTargetsOrDeflectSelf(Collection hitResults) { for (EntityHitResult entityHitResult : hitResults) { @@ -52,7 +52,7 @@ if (!this.isAlive() || projectileDeflection != ProjectileDeflection.NONE) { return projectileDeflection; } -@@ -322,13 +_,26 @@ +@@ -325,13 +_,26 @@ } } @@ -80,7 +80,7 @@ } private void startFalling() { -@@ -361,8 +_,8 @@ +@@ -364,8 +_,8 @@ protected void tickDespawn() { this.life++; @@ -91,7 +91,7 @@ } } -@@ -396,9 +_,9 @@ +@@ -399,9 +_,9 @@ } @Override @@ -103,7 +103,7 @@ } } -@@ -425,7 +_,7 @@ +@@ -428,7 +_,7 @@ } if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) { @@ -112,7 +112,7 @@ return; } -@@ -441,10 +_,16 @@ +@@ -444,10 +_,16 @@ livingEntity.setLastHurtMob(entity); } @@ -130,7 +130,7 @@ } if (entity.hurtOrSimulate(damageSource, ceil)) { -@@ -482,7 +_,7 @@ +@@ -485,7 +_,7 @@ this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); if (this.getPierceLevel() <= 0) { @@ -139,7 +139,7 @@ } } else { entity.setRemainingFireTicks(remainingFireTicks); -@@ -493,7 +_,7 @@ +@@ -496,7 +_,7 @@ this.spawnAtLocation(serverLevel2, this.getPickupItem(), 0.1F); } @@ -148,7 +148,7 @@ } } } -@@ -506,7 +_,7 @@ +@@ -509,7 +_,7 @@ double max = Math.max(0.0, 1.0 - entity.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); Vec3 vec3 = this.getDeltaMovement().multiply(1.0, 0.0, 1.0).normalize().scale(d * 0.6 * max); if (vec3.lengthSqr() > 0.0) { @@ -157,7 +157,7 @@ } } } -@@ -617,7 +_,14 @@ +@@ -620,7 +_,14 @@ @Override public void setOwner(@Nullable Entity entity) { @@ -172,7 +172,7 @@ this.pickup = switch (entity) { case Player player when this.pickup == AbstractArrow.Pickup.DISALLOWED -> AbstractArrow.Pickup.ALLOWED; -@@ -629,9 +_,22 @@ +@@ -632,9 +_,22 @@ @Override public void playerTouch(Player entity) { if (!this.level().isClientSide() && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Arrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/Arrow.java.patch similarity index 82% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/Arrow.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/Arrow.java.patch index 706855d787e0..55d81a23186f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Arrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/Arrow.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/Arrow.java -+++ b/net/minecraft/world/entity/projectile/Arrow.java +--- a/net/minecraft/world/entity/projectile/arrow/Arrow.java ++++ b/net/minecraft/world/entity/projectile/arrow/Arrow.java @@ -115,7 +_,7 @@ Entity effectSource = this.getEffectSource(); PotionContents potionContents = this.getPotionContents(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/SpectralArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java.patch similarity index 77% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/SpectralArrow.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java.patch index 7932ff5dd462..a44b58670aa4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/SpectralArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/SpectralArrow.java -+++ b/net/minecraft/world/entity/projectile/SpectralArrow.java +--- a/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java ++++ b/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java @@ -41,7 +_,7 @@ protected void doPostHurtEffects(LivingEntity target) { super.doPostHurtEffects(target); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java.patch index ca1d733d00ac..0e745702adcb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/projectile/ThrownTrident.java -+++ b/net/minecraft/world/entity/projectile/ThrownTrident.java -@@ -50,6 +_,12 @@ +--- a/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java ++++ b/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java +@@ -51,6 +_,12 @@ this.entityData.set(ID_FOIL, pickupItemStack.hasFoil()); } @@ -13,7 +13,7 @@ @Override protected void defineSynchedData(SynchedEntityData.Builder builder) { super.defineSynchedData(builder); -@@ -71,10 +_,10 @@ +@@ -72,10 +_,10 @@ this.spawnAtLocation(serverLevel, this.getPickupItem(), 0.1F); } @@ -26,7 +26,7 @@ return; } -@@ -103,6 +_,20 @@ +@@ -104,6 +_,20 @@ return this.entityData.get(ID_FOIL); } @@ -47,7 +47,7 @@ @Override protected @Nullable EntityHitResult findHitEntity(Vec3 startVec, Vec3 endVec) { return this.dealtDamage ? null : super.findHitEntity(startVec, endVec); -@@ -117,7 +_,7 @@ +@@ -118,7 +_,7 @@ @Override protected void onHitEntity(EntityHitResult result) { Entity entity = result.getEntity(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java.patch similarity index 81% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java.patch index 1b219a7e19c3..9eb8af597e53 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -+++ b/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -@@ -20,6 +_,8 @@ +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java +@@ -22,6 +_,8 @@ public static final double INITAL_ACCELERATION_POWER = 0.1; public static final double DEFLECTION_SCALE = 0.5; public double accelerationPower = 0.1; @@ -9,7 +9,7 @@ protected AbstractHurtingProjectile(EntityType type, Level level) { super(type, level); -@@ -84,12 +_,12 @@ +@@ -86,12 +_,12 @@ } if (hitResultOnMoveVector.getType() != HitResult.Type.MISS && this.isAlive()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java.patch index 9697917eaaf7..0f3dffb6cd05 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/DragonFireball.java -+++ b/net/minecraft/world/entity/projectile/DragonFireball.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java @@ -55,9 +_,11 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java.patch similarity index 93% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java.patch index 2a386a6ddb5d..68379e517009 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/LargeFireball.java -+++ b/net/minecraft/world/entity/projectile/LargeFireball.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java @@ -20,20 +_,27 @@ public LargeFireball(EntityType type, Level level) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/SmallFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/SmallFireball.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java.patch index 8990fd8cb5f1..59a16e4ae357 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/SmallFireball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/SmallFireball.java -+++ b/net/minecraft/world/entity/projectile/SmallFireball.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java @@ -23,6 +_,11 @@ public SmallFireball(Level level, LivingEntity owner, Vec3 movement) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/WitherSkull.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java.patch similarity index 93% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/WitherSkull.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java.patch index 14bb11e3177d..427e628f7980 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/WitherSkull.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/WitherSkull.java -+++ b/net/minecraft/world/entity/projectile/WitherSkull.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java @@ -67,11 +_,11 @@ if (var8.isAlive()) { EnchantmentHelper.doPostAttackEffects(serverLevel, var8, damageSource); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java.patch index 1f826ae0660e..503b3602f153 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java -+++ b/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java @@ -85,7 +_,7 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/BreezeWindCharge.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/BreezeWindCharge.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java.patch index bdc705872528..c2905d1cb136 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/BreezeWindCharge.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/windcharge/BreezeWindCharge.java -+++ b/net/minecraft/world/entity/projectile/windcharge/BreezeWindCharge.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java @@ -21,6 +_,12 @@ @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/WindCharge.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/WindCharge.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java.patch index c607b0fbaeac..a4a45fc9312a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/WindCharge.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/windcharge/WindCharge.java -+++ b/net/minecraft/world/entity/projectile/windcharge/WindCharge.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java @@ -54,6 +_,12 @@ @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/AbstractThrownPotion.java.patch similarity index 97% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/AbstractThrownPotion.java.patch index 719320435111..69d4e6502d60 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/AbstractThrownPotion.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/AbstractThrownPotion.java -+++ b/net/minecraft/world/entity/projectile/AbstractThrownPotion.java +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/AbstractThrownPotion.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/AbstractThrownPotion.java @@ -68,56 +_,97 @@ @Override protected void onHit(HitResult result) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Snowball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java.patch similarity index 67% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/Snowball.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java.patch index 440d63416474..5ce544f89f5f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Snowball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/Snowball.java -+++ b/net/minecraft/world/entity/projectile/Snowball.java +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java @@ -62,7 +_,7 @@ super.onHit(result); if (!this.level().isClientSide()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java.patch similarity index 96% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java.patch index 59fda363d32e..1c7b472ff8d8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/ThrownEgg.java -+++ b/net/minecraft/world/entity/projectile/ThrownEgg.java +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java @@ -62,31 +_,66 @@ protected void onHit(HitResult result) { super.onHit(result); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java.patch similarity index 96% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java.patch index 65ac961eb6e6..5baf743b58a9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -+++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java @@ -102,11 +_,21 @@ Vec3 vec3 = this.oldPosition(); if (owner instanceof ServerPlayer serverPlayer) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java.patch similarity index 91% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java.patch index 1cb59c72ff4e..74692dd6ce53 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java -+++ b/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java @@ -40,16 +_,25 @@ protected void onHit(HitResult result) { super.onHit(result); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java.patch index 8fc9c61e7f87..e41c58a29c49 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java -+++ b/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java @@ -29,7 +_,7 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownSplashPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java.patch similarity index 93% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownSplashPotion.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java.patch index 64d6f78a89ec..5a1801fc2f15 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownSplashPotion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/projectile/ThrownSplashPotion.java -+++ b/net/minecraft/world/entity/projectile/ThrownSplashPotion.java -@@ -36,13 +_,14 @@ +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java +@@ -37,13 +_,14 @@ } @Override @@ -16,7 +16,7 @@ float f = ProjectileUtil.computeMargin(this); if (!entitiesOfClass.isEmpty()) { Entity effectSource = this.getEffectSource(); -@@ -51,8 +_,25 @@ +@@ -52,8 +_,25 @@ if (livingEntity.isAffectedByPotions()) { double d = aabb.distanceToSqr(livingEntity.getBoundingBox().inflate(f)); if (d < 16.0) { @@ -44,7 +44,7 @@ for (MobEffectInstance mobEffectInstance : allEffects) { Holder effect = mobEffectInstance.getEffect(); if (effect.value().isInstantenous()) { -@@ -63,7 +_,7 @@ +@@ -64,7 +_,7 @@ effect, i, mobEffectInstance.getAmplifier(), mobEffectInstance.isAmbient(), mobEffectInstance.isVisible() ); if (!mobEffectInstance1.endsWithin(20)) { @@ -53,7 +53,7 @@ } } } -@@ -71,5 +_,6 @@ +@@ -72,5 +_,6 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch index d2f7b286e9be..ceb95d1af909 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch @@ -62,7 +62,7 @@ builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player); @@ -170,4 +_,14 @@ default boolean isChestVehicleStillValid(Player player) { - return !this.isRemoved() && player.canInteractWithEntity(this.getBoundingBox(), 4.0); + return !this.isRemoved() && player.isWithinEntityInteractionRange(this.getBoundingBox(), 4.0); } + + // Paper start - LootTable API diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java.patch index b85056082a32..c26b465f5514 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/vehicle/AbstractBoat.java -+++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java -@@ -77,6 +_,15 @@ +--- a/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java ++++ b/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java +@@ -79,6 +_,15 @@ private Leashable.@Nullable LeashData leashData; private final Supplier dropItem; @@ -16,7 +16,7 @@ public AbstractBoat(EntityType type, Level level, Supplier dropItem) { super(type, level); this.dropItem = dropItem; -@@ -118,7 +_,7 @@ +@@ -120,7 +_,7 @@ } @Override @@ -25,7 +25,7 @@ return true; } -@@ -173,11 +_,30 @@ +@@ -175,11 +_,30 @@ @Override public void push(Entity entity) { @@ -56,7 +56,7 @@ super.push(entity); } } -@@ -244,6 +_,18 @@ +@@ -246,6 +_,18 @@ this.setDeltaMovement(Vec3.ZERO); } @@ -75,7 +75,7 @@ this.applyEffectsFromBlocks(); this.applyEffectsFromBlocks(); this.tickBubbleColumn(); -@@ -543,7 +_,7 @@ +@@ -545,7 +_,7 @@ this.waterLevel = this.getY(1.0); double d2 = this.getWaterLevelAbove() - this.getBbHeight() + 0.101; if (this.level().noCollision(this, this.getBoundingBox().move(0.0, d2 - this.getY(), 0.0))) { @@ -84,7 +84,7 @@ this.setDeltaMovement(this.getDeltaMovement().multiply(1.0, 0.0, 1.0)); this.lastYd = 0.0; } -@@ -706,12 +_,12 @@ +@@ -708,12 +_,12 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java.patch index d8f0cc02f216..fe519a27e621 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/vehicle/AbstractChestBoat.java -+++ b/net/minecraft/world/entity/vehicle/AbstractChestBoat.java -@@ -66,12 +_,12 @@ +--- a/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java ++++ b/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java +@@ -67,12 +_,12 @@ } @Override @@ -15,7 +15,7 @@ } @Override -@@ -94,8 +_,8 @@ +@@ -95,8 +_,8 @@ @Override public void openCustomInventoryScreen(Player player) { @@ -26,7 +26,7 @@ this.gameEvent(GameEvent.CONTAINER_OPEN, player); PiglinAi.angerNearbyPiglins(serverLevel, player, true); } -@@ -147,7 +_,7 @@ +@@ -148,7 +_,7 @@ @Override public @Nullable AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { @@ -35,7 +35,7 @@ return null; } else { this.unpackLootTable(playerInventory.player); -@@ -193,4 +_,58 @@ +@@ -194,4 +_,58 @@ public void stopOpen(ContainerUser user) { this.level().gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.Context.of(user.getLivingEntity())); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java.patch index 4c32e25a43a5..3e918e368e71 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java -+++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java -@@ -93,6 +_,17 @@ +--- a/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java ++++ b/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java +@@ -96,6 +_,17 @@ } ) ); @@ -18,7 +18,7 @@ protected AbstractMinecart(EntityType type, Level level) { super(type, level); -@@ -151,11 +_,19 @@ +@@ -154,11 +_,19 @@ @Override public boolean canCollideWith(Entity entity) { @@ -40,7 +40,7 @@ return true; } -@@ -256,6 +_,14 @@ +@@ -259,6 +_,14 @@ @Override public void tick() { @@ -55,7 +55,7 @@ if (this.getHurtTime() > 0) { this.setHurtTime(this.getHurtTime() - 1); } -@@ -266,8 +_,20 @@ +@@ -269,8 +_,20 @@ this.checkBelowWorld(); this.computeSpeed(); @@ -77,7 +77,7 @@ this.updateInWaterStateAndDoFluidPushing(); if (this.isInLava()) { this.lavaIgnite(); -@@ -355,12 +_,16 @@ +@@ -358,12 +_,16 @@ Vec3 deltaMovement = this.getDeltaMovement(); this.setDeltaMovement(Mth.clamp(deltaMovement.x, -maxSpeed, maxSpeed), deltaMovement.y, Mth.clamp(deltaMovement.z, -maxSpeed, maxSpeed)); if (this.onGround()) { @@ -96,7 +96,7 @@ } } -@@ -462,6 +_,15 @@ +@@ -465,6 +_,15 @@ this.setDisplayOffset(input.getIntOr("DisplayOffset", this.getDefaultDisplayOffset())); this.flipped = input.getBooleanOr("FlippedRotation", false); this.firstTick = input.getBooleanOr("HasTicked", false); @@ -112,7 +112,7 @@ } @Override -@@ -474,13 +_,26 @@ +@@ -477,13 +_,26 @@ output.putBoolean("FlippedRotation", this.flipped); output.putBoolean("HasTicked", this.firstTick); @@ -139,7 +139,7 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double d2 = d * d + d1 * d1; -@@ -589,4 +_,26 @@ +@@ -592,4 +_,26 @@ public boolean isFurnace() { return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java.patch similarity index 93% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java.patch index 2c01132fdea0..aef9f3d9e99e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -+++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -@@ -22,9 +_,10 @@ +--- a/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java ++++ b/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java +@@ -23,9 +_,10 @@ import org.jspecify.annotations.Nullable; public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity { @@ -12,7 +12,7 @@ protected AbstractMinecartContainer(EntityType type, Level level) { super(type, level); -@@ -71,12 +_,12 @@ +@@ -72,12 +_,12 @@ } @Override @@ -27,7 +27,7 @@ } @Override -@@ -162,4 +_,56 @@ +@@ -163,4 +_,56 @@ public void clearItemStacks() { this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch similarity index 91% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch index cb5267b68e44..bc2e741efc08 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java -+++ b/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java +--- a/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java ++++ b/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java @@ -84,7 +_,7 @@ @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java.patch index e0a9d385e70f..a0cc24069497 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/vehicle/MinecartTNT.java -+++ b/net/minecraft/world/entity/vehicle/MinecartTNT.java +--- a/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java ++++ b/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java @@ -39,6 +_,7 @@ public int fuse = -1; public float explosionPowerBase = 4.0F; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch index 753b35e02c21..d07d507f6177 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java -+++ b/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java +--- a/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java ++++ b/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java @@ -479,6 +_,12 @@ @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch index 38721192ef0f..e4369eabbed7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java -+++ b/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java +--- a/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java ++++ b/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java @@ -376,8 +_,22 @@ && !(entity instanceof AbstractMinecart) && !this.minecart.isVehicle() diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/ItemCombinerMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/ItemCombinerMenu.java.patch index 313f84934b73..942a38db2986 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/ItemCombinerMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/ItemCombinerMenu.java.patch @@ -51,6 +51,6 @@ @Override public boolean stillValid(Player player) { + if (!this.checkReachable) return true; // CraftBukkit - return this.access.evaluate((level, pos) -> !this.isValidBlock(level.getBlockState(pos)) ? false : player.canInteractWithBlock(pos, 4.0), true); + return this.access + .evaluate((level, pos) -> !this.isValidBlock(level.getBlockState(pos)) ? false : player.isWithinBlockInteractionRange(pos, 4.0), true); } - diff --git a/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch index 8310777e293c..f37ed962b413 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -75,6 +_,13 @@ +@@ -76,6 +_,13 @@ if (!(entity instanceof Mob mob && (mob.isPersistenceRequired() || mob.requiresCustomPersistence()))) { MobCategory category = entity.getType().getCategory(); if (category != MobCategory.MISC) { @@ -14,7 +14,7 @@ BlockPos blockPos = entity.blockPosition(); chunkGetter.query(ChunkPos.asLong(blockPos), chunk -> { MobSpawnSettings.MobSpawnCost mobSpawnCost = getRoughBiome(blockPos, chunk).getMobSettings().getMobSpawnCost(entity.getType()); -@@ -99,17 +_,34 @@ +@@ -100,17 +_,34 @@ return chunk.getNoiseBiome(QuartPos.fromBlock(pos.getX()), QuartPos.fromBlock(pos.getY()), QuartPos.fromBlock(pos.getZ())).value(); } @@ -51,7 +51,7 @@ } } -@@ -129,6 +_,16 @@ +@@ -130,6 +_,16 @@ profilerFiller.pop(); } @@ -68,7 +68,7 @@ public static void spawnCategoryForChunk( MobCategory category, ServerLevel level, LevelChunk chunk, NaturalSpawner.SpawnPredicate filter, NaturalSpawner.AfterSpawnCallback callback ) { -@@ -154,8 +_,8 @@ +@@ -155,8 +_,8 @@ StructureManager structureManager = level.structureManager(); ChunkGenerator generator = level.getChunkSource().getGenerator(); int y = pos.getY(); @@ -79,7 +79,7 @@ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); int i = 0; -@@ -177,7 +_,7 @@ +@@ -178,7 +_,7 @@ Player nearestPlayer = level.getNearestPlayer(d, y, d1, -1.0, false); if (nearestPlayer != null) { double d2 = nearestPlayer.distanceToSqr(d, y, d1); @@ -88,7 +88,7 @@ if (spawnerData == null) { Optional randomSpawnMobAt = getRandomSpawnMobAt( level, structureManager, generator, category, level.random, mutableBlockPos -@@ -190,7 +_,13 @@ +@@ -191,7 +_,13 @@ ceil = spawnerData.minCount() + level.random.nextInt(1 + spawnerData.maxCount() - spawnerData.minCount()); } @@ -103,7 +103,7 @@ && filter.test(spawnerData.type(), mutableBlockPos, chunk)) { Mob mobForSpawn = getMobForSpawn(level, spawnerData.type()); if (mobForSpawn == null) { -@@ -202,10 +_,15 @@ +@@ -203,10 +_,15 @@ spawnGroupData = mobForSpawn.finalizeSpawn( level, level.getCurrentDifficultyAt(mobForSpawn.blockPosition()), EntitySpawnReason.NATURAL, spawnGroupData ); @@ -123,7 +123,7 @@ if (i >= mobForSpawn.getMaxSpawnClusterSize()) { return; } -@@ -237,7 +_,15 @@ +@@ -238,7 +_,15 @@ } } @@ -140,7 +140,7 @@ ServerLevel level, MobCategory category, StructureManager structureManager, -@@ -247,7 +_,19 @@ +@@ -248,7 +_,19 @@ double distance ) { EntityType entityType = data.type(); @@ -161,7 +161,7 @@ && ( entityType.canSpawnFarFromPlayer() || !(distance > entityType.getCategory().getDespawnDistance() * entityType.getCategory().getDespawnDistance()) -@@ -257,6 +_,7 @@ +@@ -258,6 +_,7 @@ && SpawnPlacements.isSpawnPositionOk(entityType, level, pos) && SpawnPlacements.checkSpawnRules(entityType, level, EntitySpawnReason.NATURAL, pos, level.random) && level.noCollision(entityType.getSpawnAABB(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5)); @@ -169,7 +169,7 @@ } private static @Nullable Mob getMobForSpawn(ServerLevel level, EntityType entityType) { -@@ -268,6 +_,7 @@ +@@ -269,6 +_,7 @@ LOGGER.warn("Can't spawn entity of type: {}", BuiltInRegistries.ENTITY_TYPE.getKey(entityType)); } catch (Exception var4) { LOGGER.warn("Failed to create mob", (Throwable)var4); @@ -177,7 +177,7 @@ } return null; -@@ -374,6 +_,7 @@ +@@ -375,6 +_,7 @@ entity = spawnerData.type().create(level.getLevel(), EntitySpawnReason.NATURAL); } catch (Exception var27) { LOGGER.warn("Failed to create mob", (Throwable)var27); @@ -185,7 +185,7 @@ continue; } -@@ -388,7 +_,7 @@ +@@ -389,7 +_,7 @@ spawnGroupData = mob.finalizeSpawn( level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CHUNK_GENERATION, spawnGroupData ); @@ -194,7 +194,7 @@ flag = true; } } -@@ -506,8 +_,10 @@ +@@ -507,8 +_,10 @@ return this.unmodifiableMobCategoryCounts; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch index 70016c81ecf8..5b1e1d124407 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch @@ -243,7 +243,7 @@ + private static void createExperience(ServerLevel level, Vec3 popVec, int recipeIndex, float experience, BlockPos blockPos, ServerPlayer serverPlayer, ItemStack itemStack, int amount) { // CraftBukkit int floor = Mth.floor(recipeIndex * experience); float fraction = Mth.frac(recipeIndex * experience); - if (fraction != 0.0F && Math.random() < fraction) { + if (fraction != 0.0F && level.random.nextFloat() < fraction) { floor++; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch index ab7b5675fab3..af68b818219b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/LevelStorageSource.java +++ b/net/minecraft/world/level/storage/LevelStorageSource.java -@@ -143,6 +_,7 @@ +@@ -142,6 +_,7 @@ PrimaryLevelData primaryLevelData = PrimaryLevelData.parse( dynamic, levelSettings, complete.specialWorldProperty(), worldGenSettings.options(), lifecycle ); @@ -8,7 +8,7 @@ return new LevelDataAndDimensions(primaryLevelData, complete); } -@@ -337,25 +_,39 @@ +@@ -336,25 +_,39 @@ return this.backupDir; } @@ -53,7 +53,7 @@ public record LevelCandidates(List levels) implements Iterable { public boolean isEmpty() { return this.levels.isEmpty(); -@@ -406,8 +_,12 @@ +@@ -405,8 +_,12 @@ public final LevelStorageSource.LevelDirectory levelDirectory; private final String levelId; private final Map resources = Maps.newHashMap(); @@ -67,7 +67,7 @@ this.levelId = levelId; this.levelDirectory = new LevelStorageSource.LevelDirectory(levelDir); this.lock = DirectoryLock.create(levelDir); -@@ -450,7 +_,7 @@ +@@ -449,7 +_,7 @@ } public Path getDimensionPath(ResourceKey dimensionPath) { diff --git a/todo-snapshot.txt b/todo-snapshot.txt index e76c660e9e28..2d9c445e66f8 100644 --- a/todo-snapshot.txt +++ b/todo-snapshot.txt @@ -7,3 +7,5 @@ - Add back array storage for game rules in GameRuleMap? - 25w45a: - PatrolSpawner: Paper start day config is overriding timeline environment attribute +- 1.21.11-pre1: + - Dropped Player.java hunks for PlayerClientLoadedWorldEvent From 14d7d07806525894a6be164d8b67487fd5144270 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 20 Nov 2025 08:47:26 -0700 Subject: [PATCH 087/112] disable oldPaperCommit --- paper-server/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 5bd8c816ef9a..f6a229cbec23 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -41,7 +41,7 @@ paperweight { ) updatingMinecraft { - oldPaperCommit = "926d6304e09d05e451668ac1915248530165007b" + // oldPaperCommit = "926d6304e09d05e451668ac1915248530165007b" } } From 34f7a102b6344cf1a2367712f1a1b71730ae7cea Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 20 Nov 2025 09:29:55 -0700 Subject: [PATCH 088/112] Update for some renames --- .../java/io/papermc/generator/Rewriters.java | 12 +- .../generator/registry/RegistryEntries.java | 16 +-- .../trial/VillagerProfessionRewriter.java | 2 +- .../generator/types/goal/MobGoalNames.java | 122 +++++++++--------- .../moonrise/paper/PaperHooks.java.patch | 2 +- .../io/papermc/paper/FeatureHooks.java.patch | 2 +- .../chat/ComponentSerialization.java.patch | 2 +- .../server/level/ServerLevel.java.patch | 2 +- .../ServerGamePacketListenerImpl.java.patch | 2 +- .../server/players/PlayerList.java.patch | 2 +- .../minecraft/world/entity/Entity.java.patch | 2 +- .../ai/behavior/PoiCompetitorScan.java.patch | 2 +- .../monster/zombie/ZombieVillager.java.patch | 2 +- .../entity/projectile/Projectile.java.patch | 2 +- .../minecart/MinecartCommandBlock.java.patch | 2 +- .../inventory/MerchantContainer.java.patch | 4 +- .../inventory/MerchantResultSlot.java.patch | 4 +- .../world/level/NaturalSpawner.java.patch | 2 +- .../world/level/ServerExplosion.java.patch | 2 +- .../paper/entity/ai/MobGoalHelper.java | 122 +++++++++--------- .../configuration/WorldConfiguration.java | 6 +- .../datacomponent/DataComponentAdapters.java | 16 +-- .../paper/entity/PaperSchoolableFish.java | 2 +- .../entity/activation/ActivationType.java | 4 +- .../data/PaperCatTypeRegistryEntry.java | 2 +- .../PaperChickenVariantRegistryEntry.java | 2 +- .../data/PaperCowVariantRegistryEntry.java | 2 +- .../PaperPaintingVariantRegistryEntry.java | 2 +- .../data/PaperPigVariantRegistryEntry.java | 2 +- ...perZombieNautilusVariantRegistryEntry.java | 2 +- .../java/org/bukkit/craftbukkit/CraftArt.java | 2 +- .../org/bukkit/craftbukkit/CraftServer.java | 2 +- .../org/bukkit/craftbukkit/CraftWorld.java | 2 +- .../entity/CraftAbstractArrow.java | 8 +- .../craftbukkit/entity/CraftAbstractCow.java | 6 +- .../entity/CraftAbstractHorse.java | 6 +- .../entity/CraftAbstractSkeleton.java | 8 +- .../entity/CraftAbstractVillager.java | 6 +- .../entity/CraftAbstractWindCharge.java | 6 +- .../bukkit/craftbukkit/entity/CraftArrow.java | 10 +- .../bukkit/craftbukkit/entity/CraftBee.java | 6 +- .../bukkit/craftbukkit/entity/CraftBoat.java | 6 +- .../craftbukkit/entity/CraftBogged.java | 6 +- .../entity/CraftBreezeWindCharge.java | 6 +- .../bukkit/craftbukkit/entity/CraftCat.java | 8 +- .../craftbukkit/entity/CraftCaveSpider.java | 6 +- .../craftbukkit/entity/CraftChestBoat.java | 2 +- .../craftbukkit/entity/CraftChestedHorse.java | 2 +- .../craftbukkit/entity/CraftChicken.java | 8 +- .../bukkit/craftbukkit/entity/CraftCod.java | 6 +- .../craftbukkit/entity/CraftComplexPart.java | 2 +- .../craftbukkit/entity/CraftCopperGolem.java | 14 +- .../bukkit/craftbukkit/entity/CraftCow.java | 8 +- .../craftbukkit/entity/CraftDolphin.java | 6 +- .../craftbukkit/entity/CraftDonkey.java | 2 +- .../entity/CraftDragonFireball.java | 2 +- .../craftbukkit/entity/CraftDrowned.java | 8 +- .../bukkit/craftbukkit/entity/CraftEgg.java | 2 +- .../craftbukkit/entity/CraftEnderDragon.java | 2 +- .../entity/CraftEnderDragonPart.java | 2 +- .../craftbukkit/entity/CraftEnderPearl.java | 2 +- .../craftbukkit/entity/CraftEntity.java | 4 +- .../craftbukkit/entity/CraftEntityTypes.java | 18 +-- .../craftbukkit/entity/CraftEvoker.java | 8 +- .../craftbukkit/entity/CraftFireball.java | 2 +- .../bukkit/craftbukkit/entity/CraftFish.java | 2 +- .../bukkit/craftbukkit/entity/CraftFox.java | 20 +-- .../craftbukkit/entity/CraftGlowSquid.java | 6 +- .../bukkit/craftbukkit/entity/CraftGolem.java | 2 +- .../craftbukkit/entity/CraftHappyGhast.java | 2 +- .../bukkit/craftbukkit/entity/CraftHorse.java | 10 +- .../craftbukkit/entity/CraftHumanEntity.java | 2 +- .../bukkit/craftbukkit/entity/CraftHusk.java | 2 +- .../craftbukkit/entity/CraftIllager.java | 2 +- .../craftbukkit/entity/CraftIllusioner.java | 8 +- .../craftbukkit/entity/CraftIronGolem.java | 6 +- .../entity/CraftLargeFireball.java | 6 +- .../craftbukkit/entity/CraftLivingEntity.java | 34 ++--- .../bukkit/craftbukkit/entity/CraftLlama.java | 10 +- .../craftbukkit/entity/CraftMinecart.java | 2 +- .../entity/CraftMinecartChest.java | 2 +- .../entity/CraftMinecartCommand.java | 2 +- .../entity/CraftMinecartContainer.java | 4 +- .../entity/CraftMinecartFurnace.java | 2 +- .../entity/CraftMinecartHopper.java | 6 +- .../entity/CraftMinecartMobSpawner.java | 2 +- .../entity/CraftMinecartRideable.java | 2 +- .../craftbukkit/entity/CraftMinecartTNT.java | 2 +- .../bukkit/craftbukkit/entity/CraftMule.java | 2 +- .../craftbukkit/entity/CraftMushroomCow.java | 8 +- .../craftbukkit/entity/CraftOcelot.java | 6 +- .../craftbukkit/entity/CraftPainting.java | 10 +- .../bukkit/craftbukkit/entity/CraftPanda.java | 12 +- .../craftbukkit/entity/CraftParched.java | 2 +- .../craftbukkit/entity/CraftParrot.java | 8 +- .../bukkit/craftbukkit/entity/CraftPig.java | 8 +- .../craftbukkit/entity/CraftPigZombie.java | 2 +- .../craftbukkit/entity/CraftPillager.java | 8 +- .../craftbukkit/entity/CraftPolarBear.java | 6 +- .../craftbukkit/entity/CraftPufferFish.java | 2 +- .../craftbukkit/entity/CraftRabbit.java | 8 +- .../craftbukkit/entity/CraftSalmon.java | 8 +- .../entity/CraftSizedFireball.java | 2 +- .../craftbukkit/entity/CraftSkeleton.java | 8 +- .../entity/CraftSkeletonHorse.java | 6 +- .../entity/CraftSmallFireball.java | 6 +- .../craftbukkit/entity/CraftSnowball.java | 6 +- .../craftbukkit/entity/CraftSnowman.java | 2 +- .../entity/CraftSpectralArrow.java | 6 +- .../craftbukkit/entity/CraftSpellcaster.java | 2 +- .../craftbukkit/entity/CraftSpider.java | 6 +- .../bukkit/craftbukkit/entity/CraftSquid.java | 6 +- .../bukkit/craftbukkit/entity/CraftStray.java | 2 +- .../entity/CraftThrowableProjectile.java | 2 +- .../entity/CraftThrownExpBottle.java | 2 +- .../entity/CraftThrownLingeringPotion.java | 2 +- .../craftbukkit/entity/CraftThrownPotion.java | 2 +- .../entity/CraftThrownSplashPotion.java | 2 +- .../craftbukkit/entity/CraftTraderLlama.java | 6 +- .../craftbukkit/entity/CraftTrident.java | 2 +- .../craftbukkit/entity/CraftTropicalFish.java | 10 +- .../craftbukkit/entity/CraftTurtle.java | 6 +- .../craftbukkit/entity/CraftVillager.java | 22 ++-- .../entity/CraftVillagerZombie.java | 8 +- .../craftbukkit/entity/CraftVindicator.java | 6 +- .../entity/CraftWanderingTrader.java | 6 +- .../craftbukkit/entity/CraftWaterMob.java | 2 +- .../craftbukkit/entity/CraftWindCharge.java | 6 +- .../entity/CraftWitherSkeleton.java | 2 +- .../craftbukkit/entity/CraftWitherSkull.java | 6 +- .../craftbukkit/entity/CraftZombie.java | 10 +- .../craftbukkit/entity/CraftZombieHorse.java | 2 +- .../entity/CraftZombieNautilus.java | 2 +- .../entity/boat/CraftAcaciaBoat.java | 2 +- .../entity/boat/CraftAcaciaChestBoat.java | 2 +- .../entity/boat/CraftBambooChestRaft.java | 2 +- .../entity/boat/CraftBambooRaft.java | 2 +- .../entity/boat/CraftBirchBoat.java | 2 +- .../entity/boat/CraftBirchChestBoat.java | 2 +- .../entity/boat/CraftCherryBoat.java | 2 +- .../entity/boat/CraftCherryChestBoat.java | 2 +- .../entity/boat/CraftDarkOakBoat.java | 2 +- .../entity/boat/CraftDarkOakChestBoat.java | 2 +- .../entity/boat/CraftJungleBoat.java | 2 +- .../entity/boat/CraftJungleChestBoat.java | 2 +- .../entity/boat/CraftMangroveBoat.java | 2 +- .../entity/boat/CraftMangroveChestBoat.java | 2 +- .../craftbukkit/entity/boat/CraftOakBoat.java | 2 +- .../entity/boat/CraftOakChestBoat.java | 2 +- .../entity/boat/CraftPaleOakBoat.java | 2 +- .../entity/boat/CraftPaleOakChestBoat.java | 2 +- .../entity/boat/CraftSpruceBoat.java | 2 +- .../entity/boat/CraftSpruceChestBoat.java | 2 +- .../craftbukkit/event/CraftEventFactory.java | 16 +-- .../inventory/CraftMerchantCustom.java | 2 +- .../inventory/util/CraftMenus.java | 2 +- .../CraftMerchantInventoryViewBuilder.java | 2 +- .../main/java/org/spigotmc/TrackingRange.java | 2 +- .../provider/RegistriesArgumentProvider.java | 16 +-- 159 files changed, 503 insertions(+), 503 deletions(-) diff --git a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java index c957260d1fcb..6a337d533bff 100644 --- a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java +++ b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java @@ -126,18 +126,18 @@ protected EnumValue.Builder rewriteEnumValue(net.minecraft.world.scores.DisplayS } }) .register("SnifferState", Sniffer.State.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.sniffer.Sniffer.State.class)) - .register("PandaGene", Panda.Gene.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.Panda.Gene.class) { + .register("PandaGene", Panda.Gene.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.panda.Panda.Gene.class) { @Override - protected EnumValue.Builder rewriteEnumValue(net.minecraft.world.entity.animal.Panda.Gene gene) { + protected EnumValue.Builder rewriteEnumValue(net.minecraft.world.entity.animal.panda.Panda.Gene gene) { return super.rewriteEnumValue(gene).argument(String.valueOf(gene.isRecessive())); } }) .register("CookingBookCategory", CookingBookCategory.class, new EnumCloneRewriter<>(net.minecraft.world.item.crafting.CookingBookCategory.class)) .register("CraftingBookCategory", CraftingBookCategory.class, new EnumCloneRewriter<>(net.minecraft.world.item.crafting.CraftingBookCategory.class)) - .register("TropicalFishPattern", TropicalFish.Pattern.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.TropicalFish.Pattern.class)) - .register("BoatStatus", Boat.Status.class, new EnumCloneRewriter<>(net.minecraft.world.entity.vehicle.Boat.Status.class)) - .register("FoxType", Fox.Type.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.Fox.Variant.class)) - .register("SalmonVariant", Salmon.Variant.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.Salmon.Variant.class)) + .register("TropicalFishPattern", TropicalFish.Pattern.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.fish.TropicalFish.Pattern.class)) + .register("BoatStatus", Boat.Status.class, new EnumCloneRewriter<>(net.minecraft.world.entity.vehicle.boat.Boat.Status.class)) + .register("FoxType", Fox.Type.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.fox.Fox.Variant.class)) + .register("SalmonVariant", Salmon.Variant.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.fish.Salmon.Variant.class)) .register("ArmadilloState", Armadillo.State.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.armadillo.Armadillo.ArmadilloState.class)) .register("SoundCategory", SoundCategory.class, new EnumCloneRewriter<>(SoundSource.class)) .register("AttributeSentiment", Attribute.Sentiment.class, new EnumCloneRewriter<>(net.minecraft.world.entity.ai.attributes.Attribute.Sentiment.class)) diff --git a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java index 36965af585e0..0a9f1e9a68f7 100644 --- a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java +++ b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java @@ -43,17 +43,17 @@ import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.memory.MemoryModuleType; -import net.minecraft.world.entity.animal.CatVariants; -import net.minecraft.world.entity.animal.ChickenVariants; -import net.minecraft.world.entity.animal.CowVariants; -import net.minecraft.world.entity.animal.PigVariants; -import net.minecraft.world.entity.animal.ZombieNautilusVariants; +import net.minecraft.world.entity.animal.feline.CatVariants; +import net.minecraft.world.entity.animal.chicken.ChickenVariants; +import net.minecraft.world.entity.animal.cow.CowVariants; +import net.minecraft.world.entity.animal.pig.PigVariants; +import net.minecraft.world.entity.animal.nautilus.ZombieNautilusVariants; import net.minecraft.world.entity.animal.frog.FrogVariants; import net.minecraft.world.entity.animal.wolf.WolfSoundVariants; import net.minecraft.world.entity.animal.wolf.WolfVariants; -import net.minecraft.world.entity.decoration.PaintingVariants; -import net.minecraft.world.entity.npc.VillagerProfession; -import net.minecraft.world.entity.npc.VillagerType; +import net.minecraft.world.entity.decoration.painting.PaintingVariants; +import net.minecraft.world.entity.npc.villager.VillagerProfession; +import net.minecraft.world.entity.npc.villager.VillagerType; import net.minecraft.world.item.Instruments; import net.minecraft.world.item.Items; import net.minecraft.world.item.JukeboxSongs; diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java index 52884792aa78..e23548e36c9c 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java @@ -15,7 +15,7 @@ import java.util.function.Predicate; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.world.entity.npc.VillagerProfession; +import net.minecraft.world.entity.npc.villager.VillagerProfession; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; public class VillagerProfessionRewriter extends RegistryFieldRewriter { diff --git a/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java b/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java index 257c98c4a932..77f75a900573 100644 --- a/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java @@ -34,94 +34,94 @@ public final class MobGoalNames { // todo sync with MobGoalHelper ideally this s map.put(net.minecraft.world.entity.ambient.AmbientCreature.class, Ambient.class); map.put(net.minecraft.world.entity.animal.Animal.class, Animals.class); map.put(net.minecraft.world.entity.ambient.Bat.class, Bat.class); - map.put(net.minecraft.world.entity.animal.Bee.class, Bee.class); + map.put(net.minecraft.world.entity.animal.bee.Bee.class, Bee.class); map.put(net.minecraft.world.entity.monster.Blaze.class, Blaze.class); - map.put(net.minecraft.world.entity.animal.Cat.class, Cat.class); - map.put(net.minecraft.world.entity.monster.CaveSpider.class, CaveSpider.class); - map.put(net.minecraft.world.entity.animal.Chicken.class, Chicken.class); - map.put(net.minecraft.world.entity.animal.Cod.class, Cod.class); - map.put(net.minecraft.world.entity.animal.Cow.class, Cow.class); + map.put(net.minecraft.world.entity.animal.feline.Cat.class, Cat.class); + map.put(net.minecraft.world.entity.monster.spider.CaveSpider.class, CaveSpider.class); + map.put(net.minecraft.world.entity.animal.chicken.Chicken.class, Chicken.class); + map.put(net.minecraft.world.entity.animal.fish.Cod.class, Cod.class); + map.put(net.minecraft.world.entity.animal.cow.Cow.class, Cow.class); map.put(net.minecraft.world.entity.PathfinderMob.class, Creature.class); map.put(net.minecraft.world.entity.monster.Creeper.class, Creeper.class); - map.put(net.minecraft.world.entity.animal.Dolphin.class, Dolphin.class); - map.put(net.minecraft.world.entity.monster.Drowned.class, Drowned.class); + map.put(net.minecraft.world.entity.animal.dolphin.Dolphin.class, Dolphin.class); + map.put(net.minecraft.world.entity.monster.zombie.Drowned.class, Drowned.class); map.put(net.minecraft.world.entity.boss.enderdragon.EnderDragon.class, EnderDragon.class); map.put(net.minecraft.world.entity.monster.EnderMan.class, Enderman.class); map.put(net.minecraft.world.entity.monster.Endermite.class, Endermite.class); - map.put(net.minecraft.world.entity.monster.Evoker.class, Evoker.class); - map.put(net.minecraft.world.entity.animal.AbstractFish.class, Fish.class); - map.put(net.minecraft.world.entity.animal.AbstractSchoolingFish.class, SchoolableFish.class); - map.put(net.minecraft.world.entity.animal.Fox.class, Fox.class); + map.put(net.minecraft.world.entity.monster.illager.Evoker.class, Evoker.class); + map.put(net.minecraft.world.entity.animal.fish.AbstractFish.class, Fish.class); + map.put(net.minecraft.world.entity.animal.fish.AbstractSchoolingFish.class, SchoolableFish.class); + map.put(net.minecraft.world.entity.animal.fox.Fox.class, Fox.class); map.put(net.minecraft.world.entity.monster.Ghast.class, Ghast.class); map.put(net.minecraft.world.entity.monster.Giant.class, Giant.class); - map.put(net.minecraft.world.entity.animal.AbstractGolem.class, Golem.class); + map.put(net.minecraft.world.entity.animal.golem.AbstractGolem.class, Golem.class); map.put(net.minecraft.world.entity.monster.Guardian.class, Guardian.class); map.put(net.minecraft.world.entity.monster.ElderGuardian.class, ElderGuardian.class); - map.put(net.minecraft.world.entity.animal.horse.Horse.class, Horse.class); - map.put(net.minecraft.world.entity.animal.horse.AbstractHorse.class, AbstractHorse.class); - map.put(net.minecraft.world.entity.animal.horse.AbstractChestedHorse.class, ChestedHorse.class); - map.put(net.minecraft.world.entity.animal.horse.Donkey.class, Donkey.class); - map.put(net.minecraft.world.entity.animal.horse.Mule.class, Mule.class); - map.put(net.minecraft.world.entity.animal.horse.SkeletonHorse.class, SkeletonHorse.class); - map.put(net.minecraft.world.entity.animal.horse.ZombieHorse.class, ZombieHorse.class); + map.put(net.minecraft.world.entity.animal.equine.Horse.class, Horse.class); + map.put(net.minecraft.world.entity.animal.equine.AbstractHorse.class, AbstractHorse.class); + map.put(net.minecraft.world.entity.animal.equine.AbstractChestedHorse.class, ChestedHorse.class); + map.put(net.minecraft.world.entity.animal.equine.Donkey.class, Donkey.class); + map.put(net.minecraft.world.entity.animal.equine.Mule.class, Mule.class); + map.put(net.minecraft.world.entity.animal.equine.SkeletonHorse.class, SkeletonHorse.class); + map.put(net.minecraft.world.entity.animal.equine.ZombieHorse.class, ZombieHorse.class); map.put(net.minecraft.world.entity.animal.camel.Camel.class, org.bukkit.entity.Camel.class); - map.put(net.minecraft.world.entity.monster.AbstractIllager.class, Illager.class); - map.put(net.minecraft.world.entity.monster.Illusioner.class, Illusioner.class); - map.put(net.minecraft.world.entity.monster.SpellcasterIllager.class, Spellcaster.class); - map.put(net.minecraft.world.entity.animal.IronGolem.class, IronGolem.class); - map.put(net.minecraft.world.entity.animal.horse.Llama.class, Llama.class); - map.put(net.minecraft.world.entity.animal.horse.TraderLlama.class, TraderLlama.class); + map.put(net.minecraft.world.entity.monster.illager.AbstractIllager.class, Illager.class); + map.put(net.minecraft.world.entity.monster.illager.Illusioner.class, Illusioner.class); + map.put(net.minecraft.world.entity.monster.illager.SpellcasterIllager.class, Spellcaster.class); + map.put(net.minecraft.world.entity.animal.golem.IronGolem.class, IronGolem.class); + map.put(net.minecraft.world.entity.animal.equine.Llama.class, Llama.class); + map.put(net.minecraft.world.entity.animal.equine.TraderLlama.class, TraderLlama.class); map.put(net.minecraft.world.entity.monster.MagmaCube.class, MagmaCube.class); map.put(net.minecraft.world.entity.monster.Monster.class, Monster.class); map.put(net.minecraft.world.entity.monster.PatrollingMonster.class, Raider.class); // close enough - map.put(net.minecraft.world.entity.animal.MushroomCow.class, MushroomCow.class); - map.put(net.minecraft.world.entity.animal.Ocelot.class, Ocelot.class); - map.put(net.minecraft.world.entity.animal.Panda.class, Panda.class); - map.put(net.minecraft.world.entity.animal.Parrot.class, Parrot.class); - map.put(net.minecraft.world.entity.animal.ShoulderRidingEntity.class, Parrot.class); // close enough + map.put(net.minecraft.world.entity.animal.cow.MushroomCow.class, MushroomCow.class); + map.put(net.minecraft.world.entity.animal.feline.Ocelot.class, Ocelot.class); + map.put(net.minecraft.world.entity.animal.panda.Panda.class, Panda.class); + map.put(net.minecraft.world.entity.animal.parrot.Parrot.class, Parrot.class); + map.put(net.minecraft.world.entity.animal.parrot.ShoulderRidingEntity.class, Parrot.class); // close enough map.put(net.minecraft.world.entity.monster.Phantom.class, Phantom.class); - map.put(net.minecraft.world.entity.animal.Pig.class, Pig.class); - map.put(net.minecraft.world.entity.monster.ZombifiedPiglin.class, PigZombie.class); - map.put(net.minecraft.world.entity.monster.Pillager.class, Pillager.class); - map.put(net.minecraft.world.entity.animal.PolarBear.class, PolarBear.class); - map.put(net.minecraft.world.entity.animal.Pufferfish.class, PufferFish.class); - map.put(net.minecraft.world.entity.animal.Rabbit.class, Rabbit.class); + map.put(net.minecraft.world.entity.animal.pig.Pig.class, Pig.class); + map.put(net.minecraft.world.entity.monster.zombie.ZombifiedPiglin.class, PigZombie.class); + map.put(net.minecraft.world.entity.monster.illager.Pillager.class, Pillager.class); + map.put(net.minecraft.world.entity.animal.polarbear.PolarBear.class, PolarBear.class); + map.put(net.minecraft.world.entity.animal.fish.Pufferfish.class, PufferFish.class); + map.put(net.minecraft.world.entity.animal.rabbit.Rabbit.class, Rabbit.class); map.put(net.minecraft.world.entity.raid.Raider.class, Raider.class); map.put(net.minecraft.world.entity.monster.Ravager.class, Ravager.class); - map.put(net.minecraft.world.entity.animal.Salmon.class, Salmon.class); + map.put(net.minecraft.world.entity.animal.fish.Salmon.class, Salmon.class); map.put(net.minecraft.world.entity.animal.sheep.Sheep.class, Sheep.class); map.put(net.minecraft.world.entity.monster.Shulker.class, Shulker.class); map.put(net.minecraft.world.entity.monster.Silverfish.class, Silverfish.class); - map.put(net.minecraft.world.entity.monster.Skeleton.class, Skeleton.class); - map.put(net.minecraft.world.entity.monster.AbstractSkeleton.class, AbstractSkeleton.class); - map.put(net.minecraft.world.entity.monster.Stray.class, Stray.class); - map.put(net.minecraft.world.entity.monster.WitherSkeleton.class, WitherSkeleton.class); + map.put(net.minecraft.world.entity.monster.skeleton.Skeleton.class, Skeleton.class); + map.put(net.minecraft.world.entity.monster.skeleton.AbstractSkeleton.class, AbstractSkeleton.class); + map.put(net.minecraft.world.entity.monster.skeleton.Stray.class, Stray.class); + map.put(net.minecraft.world.entity.monster.skeleton.WitherSkeleton.class, WitherSkeleton.class); map.put(net.minecraft.world.entity.monster.Slime.class, Slime.class); - map.put(net.minecraft.world.entity.animal.SnowGolem.class, Snowman.class); - map.put(net.minecraft.world.entity.monster.Spider.class, Spider.class); - map.put(net.minecraft.world.entity.animal.Squid.class, Squid.class); + map.put(net.minecraft.world.entity.animal.golem.SnowGolem.class, Snowman.class); + map.put(net.minecraft.world.entity.monster.spider.Spider.class, Spider.class); + map.put(net.minecraft.world.entity.animal.squid.Squid.class, Squid.class); map.put(net.minecraft.world.entity.TamableAnimal.class, Tameable.class); - map.put(net.minecraft.world.entity.animal.TropicalFish.class, TropicalFish.class); - map.put(net.minecraft.world.entity.animal.Turtle.class, Turtle.class); + map.put(net.minecraft.world.entity.animal.fish.TropicalFish.class, TropicalFish.class); + map.put(net.minecraft.world.entity.animal.turtle.Turtle.class, Turtle.class); map.put(net.minecraft.world.entity.monster.Vex.class, Vex.class); - map.put(net.minecraft.world.entity.npc.Villager.class, Villager.class); - map.put(net.minecraft.world.entity.npc.AbstractVillager.class, AbstractVillager.class); - map.put(net.minecraft.world.entity.npc.WanderingTrader.class, WanderingTrader.class); - map.put(net.minecraft.world.entity.monster.Vindicator.class, Vindicator.class); - map.put(net.minecraft.world.entity.animal.WaterAnimal.class, WaterMob.class); + map.put(net.minecraft.world.entity.npc.villager.Villager.class, Villager.class); + map.put(net.minecraft.world.entity.npc.villager.AbstractVillager.class, AbstractVillager.class); + map.put(net.minecraft.world.entity.npc.wanderingtrader.WanderingTrader.class, WanderingTrader.class); + map.put(net.minecraft.world.entity.monster.illager.Vindicator.class, Vindicator.class); + map.put(net.minecraft.world.entity.animal.fish.WaterAnimal.class, WaterMob.class); map.put(net.minecraft.world.entity.monster.Witch.class, Witch.class); map.put(net.minecraft.world.entity.boss.wither.WitherBoss.class, Wither.class); map.put(net.minecraft.world.entity.animal.wolf.Wolf.class, Wolf.class); - map.put(net.minecraft.world.entity.monster.Zombie.class, Zombie.class); - map.put(net.minecraft.world.entity.monster.Husk.class, Husk.class); - map.put(net.minecraft.world.entity.monster.ZombieVillager.class, ZombieVillager.class); + map.put(net.minecraft.world.entity.monster.zombie.Zombie.class, Zombie.class); + map.put(net.minecraft.world.entity.monster.zombie.Husk.class, Husk.class); + map.put(net.minecraft.world.entity.monster.zombie.ZombieVillager.class, ZombieVillager.class); map.put(net.minecraft.world.entity.monster.hoglin.Hoglin.class, Hoglin.class); map.put(net.minecraft.world.entity.monster.piglin.Piglin.class, Piglin.class); map.put(net.minecraft.world.entity.monster.piglin.AbstractPiglin.class, PiglinAbstract.class); map.put(net.minecraft.world.entity.monster.piglin.PiglinBrute.class, PiglinBrute.class); map.put(net.minecraft.world.entity.monster.Strider.class, Strider.class); map.put(net.minecraft.world.entity.monster.Zoglin.class, Zoglin.class); - map.put(net.minecraft.world.entity.GlowSquid.class, GlowSquid.class); + map.put(net.minecraft.world.entity.animal.squid.GlowSquid.class, GlowSquid.class); map.put(net.minecraft.world.entity.animal.axolotl.Axolotl.class, Axolotl.class); map.put(net.minecraft.world.entity.animal.goat.Goat.class, Goat.class); map.put(net.minecraft.world.entity.animal.frog.Frog.class, Frog.class); @@ -131,17 +131,17 @@ public final class MobGoalNames { // todo sync with MobGoalHelper ideally this s map.put(net.minecraft.world.entity.animal.sniffer.Sniffer.class, Sniffer.class); map.put(net.minecraft.world.entity.monster.breeze.Breeze.class, Breeze.class); map.put(net.minecraft.world.entity.animal.armadillo.Armadillo.class, Armadillo.class); - map.put(net.minecraft.world.entity.monster.Bogged.class, Bogged.class); + map.put(net.minecraft.world.entity.monster.skeleton.Bogged.class, Bogged.class); map.put(net.minecraft.world.entity.monster.creaking.Creaking.class, Creaking.class); map.put(net.minecraft.world.entity.animal.AgeableWaterCreature.class, Squid.class); // close enough - map.put(net.minecraft.world.entity.animal.AbstractCow.class, AbstractCow.class); - map.put(net.minecraft.world.entity.animal.HappyGhast.class, HappyGhast.class); - map.put(net.minecraft.world.entity.animal.coppergolem.CopperGolem.class, org.bukkit.entity.CopperGolem.class); + map.put(net.minecraft.world.entity.animal.cow.AbstractCow.class, AbstractCow.class); + map.put(net.minecraft.world.entity.animal.happyghast.HappyGhast.class, HappyGhast.class); + map.put(net.minecraft.world.entity.animal.golem.CopperGolem.class, org.bukkit.entity.CopperGolem.class); map.put(net.minecraft.world.entity.animal.nautilus.AbstractNautilus.class, org.bukkit.entity.AbstractNautilus.class); map.put(net.minecraft.world.entity.animal.nautilus.Nautilus.class, org.bukkit.entity.Nautilus.class); map.put(net.minecraft.world.entity.animal.nautilus.ZombieNautilus.class, org.bukkit.entity.ZombieNautilus.class); map.put(net.minecraft.world.entity.animal.camel.CamelHusk.class, org.bukkit.entity.CamelHusk.class); - map.put(net.minecraft.world.entity.monster.Parched.class, org.bukkit.entity.Parched.class); + map.put(net.minecraft.world.entity.monster.skeleton.Parched.class, org.bukkit.entity.Parched.class); // }); diff --git a/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/PaperHooks.java.patch b/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/PaperHooks.java.patch index fb16e7594569..803bcf504342 100644 --- a/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/PaperHooks.java.patch +++ b/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/PaperHooks.java.patch @@ -17,7 +17,7 @@ +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; -+import net.minecraft.world.entity.boss.EnderDragonPart; ++import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; diff --git a/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch b/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch index 8d94e6c9e93a..dd764f0757aa 100644 --- a/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch +++ b/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch @@ -17,7 +17,7 @@ +import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; -+import net.minecraft.world.entity.monster.Spider; ++import net.minecraft.world.entity.monster.spider.Spider; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; diff --git a/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch index 32a7711c1546..1f1547c9d69d 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch @@ -5,7 +5,7 @@ public class ComponentSerialization { public static final Codec CODEC = Codec.recursive("Component", ComponentSerialization::createCodec); - public static final StreamCodec STREAM_CODEC = ByteBufCodecs.fromCodecWithRegistries(CODEC); -+ public static final StreamCodec STREAM_CODEC = createTranslationAware(() -> net.minecraft.nbt.NbtAccounter.create(net.minecraft.network.FriendlyByteBuf.DEFAULT_NBT_QUOTA)); // Paper - adventure ++ public static final StreamCodec STREAM_CODEC = createTranslationAware(() -> net.minecraft.nbt.NbtAccounter.create(net.minecraft.nbt.NbtAccounter.DEFAULT_NBT_QUOTA)); // Paper - adventure public static final StreamCodec> OPTIONAL_STREAM_CODEC = STREAM_CODEC.apply(ByteBufCodecs::optional); - public static final StreamCodec TRUSTED_STREAM_CODEC = ByteBufCodecs.fromCodecWithRegistriesTrusted(CODEC); + // Paper start - adventure; use locale from bytebuf for translation diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch index aa4d31ec7361..1bbc0a2e82a1 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -1076,7 +1076,7 @@ public void onTickingEnd(Entity entity) { ServerLevel.this.entityTickList.remove(entity); + // Paper start - Reset pearls when they stop being ticked -+ if (ServerLevel.this.paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && ServerLevel.this.paperConfig().misc.legacyEnderPearlBehavior && entity instanceof net.minecraft.world.entity.projectile.ThrownEnderpearl pearl) { ++ if (ServerLevel.this.paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && ServerLevel.this.paperConfig().misc.legacyEnderPearlBehavior && entity instanceof net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl pearl) { + pearl.setOwner(null); + } + // Paper end - Reset pearls when they stop being ticked diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index af52efdcb93f..9d9a2c7643a5 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1846,7 +1846,7 @@ + // Refresh the current entity metadata + target.refreshEntityData(ServerGamePacketListenerImpl.this.player); + // SPIGOT-7136 - Allays -+ if (target instanceof net.minecraft.world.entity.animal.allay.Allay || target instanceof net.minecraft.world.entity.animal.horse.AbstractHorse) { // Paper - Fix horse armor desync ++ if (target instanceof net.minecraft.world.entity.animal.allay.Allay || target instanceof net.minecraft.world.entity.animal.equine.AbstractHorse) { // Paper - Fix horse armor desync + ServerGamePacketListenerImpl.this.send(new net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket( + target.getId(), java.util.Arrays.stream(net.minecraft.world.entity.EquipmentSlot.values()) + .map((slot) -> com.mojang.datafixers.util.Pair.of(slot, ((LivingEntity) target).getItemBySlot(slot).copy())) diff --git a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch index bd413b2ec3e1..b90e3c916231 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch @@ -333,7 +333,7 @@ - rootVehicle.getPassengersAndSelf().forEach(entity -> entity.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER)); + rootVehicle.getPassengersAndSelf().forEach(entity -> { + // Paper start - Fix villager boat exploit -+ if (entity instanceof net.minecraft.world.entity.npc.AbstractVillager villager) { ++ if (entity instanceof net.minecraft.world.entity.npc.villager.AbstractVillager villager) { + final net.minecraft.world.entity.player.Player human = villager.getTradingPlayer(); + if (human != null) { + villager.setTradingPlayer(null); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch index 8620f51ebb1f..4fc0f5ec4bb7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -903,7 +903,7 @@ + if (spawnReason == null) { + if (spawnedViaMobSpawner) { + spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER; -+ } else if (this instanceof Mob && (this instanceof net.minecraft.world.entity.animal.Animal || this instanceof net.minecraft.world.entity.animal.AbstractFish) && !((Mob) this).removeWhenFarAway(0.0)) { ++ } else if (this instanceof Mob && (this instanceof net.minecraft.world.entity.animal.Animal || this instanceof net.minecraft.world.entity.animal.fish.AbstractFish) && !((Mob) this).removeWhenFarAway(0.0)) { + if (!input.getBooleanOr("PersistenceRequired", false)) { + spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL; + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PoiCompetitorScan.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PoiCompetitorScan.java.patch index abad8cfd918c..2158504f91e1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PoiCompetitorScan.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PoiCompetitorScan.java.patch @@ -24,7 +24,7 @@ + if (other == villager) { + continue; + } -+ if (!(other instanceof final net.minecraft.world.entity.npc.Villager otherVillager)) { ++ if (!(other instanceof final net.minecraft.world.entity.npc.villager.Villager otherVillager)) { + continue; + } + if (!other.isAlive()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch index b761296a746a..7737670b825a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch @@ -8,7 +8,7 @@ + this.startConverting(conversionStarter, villagerConversionTime, true); + } + -+ private void startConverting(@Nullable UUID conversionStarter, int villagerConversionTime, boolean broadcastEntityEvent) { ++ public void startConverting(@Nullable UUID conversionStarter, int villagerConversionTime, boolean broadcastEntityEvent) { + // Paper end - missing entity behaviour api - converting without entity event this.conversionStarter = conversionStarter; this.villagerConversionTime = villagerConversionTime; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch index 87b1e923f9cf..bbddee96ba82 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -38,7 +38,7 @@ @Override protected void readAdditionalSaveData(ValueInput input) { this.setOwner(EntityReference.read(input, "Owner")); -+ if (this instanceof ThrownEnderpearl && this.level().paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && this.level().paperConfig().misc.legacyEnderPearlBehavior) { this.owner = null; } // Paper - Reset pearls when they stop being ticked; Don't store shooter name for pearls to block enderpearl travel exploit ++ if (this instanceof net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl && this.level().paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && this.level().paperConfig().misc.legacyEnderPearlBehavior) { this.owner = null; } // Paper - Reset pearls when they stop being ticked; Don't store shooter name for pearls to block enderpearl travel exploit this.leftOwner = input.getBooleanOr("LeftOwner", false); this.hasBeenShot = input.getBooleanOr("HasBeenShot", false); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch index bc2e741efc08..0eaa33118f97 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch @@ -26,7 +26,7 @@ + // CraftBukkit start + @Override + public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { -+ return net.minecraft.world.entity.vehicle.MinecartCommandBlock.this.getBukkitEntity(); ++ return net.minecraft.world.entity.vehicle.minecart.MinecartCommandBlock.this.getBukkitEntity(); + } + + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch index 757e9e948ad6..043e9ad15879 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch @@ -35,12 +35,12 @@ + } + + public @javax.annotation.Nullable org.bukkit.inventory.InventoryHolder getOwner() { -+ return (this.merchant instanceof net.minecraft.world.entity.npc.AbstractVillager abstractVillager) ? (org.bukkit.craftbukkit.entity.CraftAbstractVillager) abstractVillager.getBukkitEntity() : null; ++ return (this.merchant instanceof net.minecraft.world.entity.npc.villager.AbstractVillager abstractVillager) ? (org.bukkit.craftbukkit.entity.CraftAbstractVillager) abstractVillager.getBukkitEntity() : null; + } + + @Override + public @javax.annotation.Nullable org.bukkit.Location getLocation() { -+ return (this.merchant instanceof net.minecraft.world.entity.npc.AbstractVillager abstractVillager) ? abstractVillager.getBukkitEntity().getLocation() : null; // Paper - Fix inventories returning null Locations ++ return (this.merchant instanceof net.minecraft.world.entity.npc.villager.AbstractVillager abstractVillager) ? abstractVillager.getBukkitEntity().getLocation() : null; // Paper - Fix inventories returning null Locations + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantResultSlot.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantResultSlot.java.patch index 17cd510f9084..9b233499d30a 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantResultSlot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantResultSlot.java.patch @@ -10,7 +10,7 @@ + // Paper start - Add PlayerTradeEvent and PlayerPurchaseEvent + io.papermc.paper.event.player.PlayerPurchaseEvent event = null; + if (activeOffer != null && player instanceof net.minecraft.server.level.ServerPlayer serverPlayer) { -+ if (this.merchant instanceof net.minecraft.world.entity.npc.AbstractVillager abstractVillager) { ++ if (this.merchant instanceof net.minecraft.world.entity.npc.villager.AbstractVillager abstractVillager) { + event = new io.papermc.paper.event.player.PlayerTradeEvent(serverPlayer.getBukkitEntity(), (org.bukkit.entity.AbstractVillager) abstractVillager.getBukkitEntity(), activeOffer.asBukkit(), true, true); + } else if (this.merchant instanceof org.bukkit.craftbukkit.inventory.CraftMerchantCustom.MinecraftMerchant) { + event = new io.papermc.paper.event.player.PlayerPurchaseEvent(serverPlayer.getBukkitEntity(), activeOffer.asBukkit(), false, true); @@ -19,7 +19,7 @@ + if (!event.callEvent()) { + stack.setCount(0); + player.containerMenu.sendAllDataToRemote(); -+ int level = merchant instanceof net.minecraft.world.entity.npc.Villager villager ? villager.getVillagerData().level() : 1; ++ int level = merchant instanceof net.minecraft.world.entity.npc.villager.Villager villager ? villager.getVillagerData().level() : 1; + serverPlayer.sendMerchantOffers(player.containerMenu.containerId, merchant.getOffers(), level, merchant.getVillagerXp(), merchant.showProgressBar(), merchant.canRestock()); + return; + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch index f37ed962b413..fba73eea2467 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch @@ -113,7 +113,7 @@ - callback.run(mobForSpawn, chunk); + // CraftBukkit start + // SPIGOT-7045: Give ocelot babies back their special spawn reason. Note: This is the only modification required as ocelots count as monsters which means they only spawn during normal chunk ticking and do not spawn during chunk generation as starter mobs. -+ level.addFreshEntityWithPassengers(mobForSpawn, (mobForSpawn instanceof net.minecraft.world.entity.animal.Ocelot && !((org.bukkit.entity.Ageable) mobForSpawn.getBukkitEntity()).isAdult()) ? org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.OCELOT_BABY : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); ++ level.addFreshEntityWithPassengers(mobForSpawn, (mobForSpawn instanceof net.minecraft.world.entity.animal.feline.Ocelot && !((org.bukkit.entity.Ageable) mobForSpawn.getBukkitEntity()).isAdult()) ? org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.OCELOT_BABY : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); + if (!mobForSpawn.isRemoved()) { + ++i; + ++i3; diff --git a/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch b/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch index 4a607bcc0be0..77a2f704aa99 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch @@ -5,7 +5,7 @@ import org.jspecify.annotations.Nullable; +// CraftBukkit start -+import net.minecraft.world.entity.boss.EnderDragonPart; ++import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; +import net.minecraft.world.entity.boss.enderdragon.EnderDragon; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.util.CraftLocation; diff --git a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java index 4158b36deffd..c8583cb0bc5a 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java @@ -32,94 +32,94 @@ public class MobGoalHelper { map.put(net.minecraft.world.entity.ambient.AmbientCreature.class, Ambient.class); map.put(net.minecraft.world.entity.animal.Animal.class, Animals.class); map.put(net.minecraft.world.entity.ambient.Bat.class, Bat.class); - map.put(net.minecraft.world.entity.animal.Bee.class, Bee.class); + map.put(net.minecraft.world.entity.animal.bee.Bee.class, Bee.class); map.put(net.minecraft.world.entity.monster.Blaze.class, Blaze.class); - map.put(net.minecraft.world.entity.animal.Cat.class, Cat.class); - map.put(net.minecraft.world.entity.monster.CaveSpider.class, CaveSpider.class); - map.put(net.minecraft.world.entity.animal.Chicken.class, Chicken.class); - map.put(net.minecraft.world.entity.animal.Cod.class, Cod.class); - map.put(net.minecraft.world.entity.animal.Cow.class, Cow.class); + map.put(net.minecraft.world.entity.animal.feline.Cat.class, Cat.class); + map.put(net.minecraft.world.entity.monster.spider.CaveSpider.class, CaveSpider.class); + map.put(net.minecraft.world.entity.animal.chicken.Chicken.class, Chicken.class); + map.put(net.minecraft.world.entity.animal.fish.Cod.class, Cod.class); + map.put(net.minecraft.world.entity.animal.cow.Cow.class, Cow.class); map.put(net.minecraft.world.entity.PathfinderMob.class, Creature.class); map.put(net.minecraft.world.entity.monster.Creeper.class, Creeper.class); - map.put(net.minecraft.world.entity.animal.Dolphin.class, Dolphin.class); - map.put(net.minecraft.world.entity.monster.Drowned.class, Drowned.class); + map.put(net.minecraft.world.entity.animal.dolphin.Dolphin.class, Dolphin.class); + map.put(net.minecraft.world.entity.monster.zombie.Drowned.class, Drowned.class); map.put(net.minecraft.world.entity.boss.enderdragon.EnderDragon.class, EnderDragon.class); map.put(net.minecraft.world.entity.monster.EnderMan.class, Enderman.class); map.put(net.minecraft.world.entity.monster.Endermite.class, Endermite.class); - map.put(net.minecraft.world.entity.monster.Evoker.class, Evoker.class); - map.put(net.minecraft.world.entity.animal.AbstractFish.class, Fish.class); - map.put(net.minecraft.world.entity.animal.AbstractSchoolingFish.class, SchoolableFish.class); - map.put(net.minecraft.world.entity.animal.Fox.class, Fox.class); + map.put(net.minecraft.world.entity.monster.illager.Evoker.class, Evoker.class); + map.put(net.minecraft.world.entity.animal.fish.AbstractFish.class, Fish.class); + map.put(net.minecraft.world.entity.animal.fish.AbstractSchoolingFish.class, SchoolableFish.class); + map.put(net.minecraft.world.entity.animal.fox.Fox.class, Fox.class); map.put(net.minecraft.world.entity.monster.Ghast.class, Ghast.class); map.put(net.minecraft.world.entity.monster.Giant.class, Giant.class); - map.put(net.minecraft.world.entity.animal.AbstractGolem.class, Golem.class); + map.put(net.minecraft.world.entity.animal.golem.AbstractGolem.class, Golem.class); map.put(net.minecraft.world.entity.monster.Guardian.class, Guardian.class); map.put(net.minecraft.world.entity.monster.ElderGuardian.class, ElderGuardian.class); - map.put(net.minecraft.world.entity.animal.horse.Horse.class, Horse.class); - map.put(net.minecraft.world.entity.animal.horse.AbstractHorse.class, AbstractHorse.class); - map.put(net.minecraft.world.entity.animal.horse.AbstractChestedHorse.class, ChestedHorse.class); - map.put(net.minecraft.world.entity.animal.horse.Donkey.class, Donkey.class); - map.put(net.minecraft.world.entity.animal.horse.Mule.class, Mule.class); - map.put(net.minecraft.world.entity.animal.horse.SkeletonHorse.class, SkeletonHorse.class); - map.put(net.minecraft.world.entity.animal.horse.ZombieHorse.class, ZombieHorse.class); + map.put(net.minecraft.world.entity.animal.equine.Horse.class, Horse.class); + map.put(net.minecraft.world.entity.animal.equine.AbstractHorse.class, AbstractHorse.class); + map.put(net.minecraft.world.entity.animal.equine.AbstractChestedHorse.class, ChestedHorse.class); + map.put(net.minecraft.world.entity.animal.equine.Donkey.class, Donkey.class); + map.put(net.minecraft.world.entity.animal.equine.Mule.class, Mule.class); + map.put(net.minecraft.world.entity.animal.equine.SkeletonHorse.class, SkeletonHorse.class); + map.put(net.minecraft.world.entity.animal.equine.ZombieHorse.class, ZombieHorse.class); map.put(net.minecraft.world.entity.animal.camel.Camel.class, Camel.class); - map.put(net.minecraft.world.entity.monster.AbstractIllager.class, Illager.class); - map.put(net.minecraft.world.entity.monster.Illusioner.class, Illusioner.class); - map.put(net.minecraft.world.entity.monster.SpellcasterIllager.class, Spellcaster.class); - map.put(net.minecraft.world.entity.animal.IronGolem.class, IronGolem.class); - map.put(net.minecraft.world.entity.animal.horse.Llama.class, Llama.class); - map.put(net.minecraft.world.entity.animal.horse.TraderLlama.class, TraderLlama.class); + map.put(net.minecraft.world.entity.monster.illager.AbstractIllager.class, Illager.class); + map.put(net.minecraft.world.entity.monster.illager.Illusioner.class, Illusioner.class); + map.put(net.minecraft.world.entity.monster.illager.SpellcasterIllager.class, Spellcaster.class); + map.put(net.minecraft.world.entity.animal.golem.IronGolem.class, IronGolem.class); + map.put(net.minecraft.world.entity.animal.equine.Llama.class, Llama.class); + map.put(net.minecraft.world.entity.animal.equine.TraderLlama.class, TraderLlama.class); map.put(net.minecraft.world.entity.monster.MagmaCube.class, MagmaCube.class); map.put(net.minecraft.world.entity.monster.Monster.class, Monster.class); map.put(net.minecraft.world.entity.monster.PatrollingMonster.class, Raider.class); - map.put(net.minecraft.world.entity.animal.MushroomCow.class, MushroomCow.class); - map.put(net.minecraft.world.entity.animal.Ocelot.class, Ocelot.class); - map.put(net.minecraft.world.entity.animal.Panda.class, Panda.class); - map.put(net.minecraft.world.entity.animal.Parrot.class, Parrot.class); - map.put(net.minecraft.world.entity.animal.ShoulderRidingEntity.class, Parrot.class); + map.put(net.minecraft.world.entity.animal.cow.MushroomCow.class, MushroomCow.class); + map.put(net.minecraft.world.entity.animal.feline.Ocelot.class, Ocelot.class); + map.put(net.minecraft.world.entity.animal.panda.Panda.class, Panda.class); + map.put(net.minecraft.world.entity.animal.parrot.Parrot.class, Parrot.class); + map.put(net.minecraft.world.entity.animal.parrot.ShoulderRidingEntity.class, Parrot.class); map.put(net.minecraft.world.entity.monster.Phantom.class, Phantom.class); - map.put(net.minecraft.world.entity.animal.Pig.class, Pig.class); - map.put(net.minecraft.world.entity.monster.ZombifiedPiglin.class, PigZombie.class); - map.put(net.minecraft.world.entity.monster.Pillager.class, Pillager.class); - map.put(net.minecraft.world.entity.animal.PolarBear.class, PolarBear.class); - map.put(net.minecraft.world.entity.animal.Pufferfish.class, PufferFish.class); - map.put(net.minecraft.world.entity.animal.Rabbit.class, Rabbit.class); + map.put(net.minecraft.world.entity.animal.pig.Pig.class, Pig.class); + map.put(net.minecraft.world.entity.monster.zombie.ZombifiedPiglin.class, PigZombie.class); + map.put(net.minecraft.world.entity.monster.illager.Pillager.class, Pillager.class); + map.put(net.minecraft.world.entity.animal.polarbear.PolarBear.class, PolarBear.class); + map.put(net.minecraft.world.entity.animal.fish.Pufferfish.class, PufferFish.class); + map.put(net.minecraft.world.entity.animal.rabbit.Rabbit.class, Rabbit.class); map.put(net.minecraft.world.entity.raid.Raider.class, Raider.class); map.put(net.minecraft.world.entity.monster.Ravager.class, Ravager.class); - map.put(net.minecraft.world.entity.animal.Salmon.class, Salmon.class); + map.put(net.minecraft.world.entity.animal.fish.Salmon.class, Salmon.class); map.put(net.minecraft.world.entity.animal.sheep.Sheep.class, Sheep.class); map.put(net.minecraft.world.entity.monster.Shulker.class, Shulker.class); map.put(net.minecraft.world.entity.monster.Silverfish.class, Silverfish.class); - map.put(net.minecraft.world.entity.monster.Skeleton.class, Skeleton.class); - map.put(net.minecraft.world.entity.monster.AbstractSkeleton.class, AbstractSkeleton.class); - map.put(net.minecraft.world.entity.monster.Stray.class, Stray.class); - map.put(net.minecraft.world.entity.monster.WitherSkeleton.class, WitherSkeleton.class); + map.put(net.minecraft.world.entity.monster.skeleton.Skeleton.class, Skeleton.class); + map.put(net.minecraft.world.entity.monster.skeleton.AbstractSkeleton.class, AbstractSkeleton.class); + map.put(net.minecraft.world.entity.monster.skeleton.Stray.class, Stray.class); + map.put(net.minecraft.world.entity.monster.skeleton.WitherSkeleton.class, WitherSkeleton.class); map.put(net.minecraft.world.entity.monster.Slime.class, Slime.class); - map.put(net.minecraft.world.entity.animal.SnowGolem.class, Snowman.class); - map.put(net.minecraft.world.entity.monster.Spider.class, Spider.class); - map.put(net.minecraft.world.entity.animal.Squid.class, Squid.class); + map.put(net.minecraft.world.entity.animal.golem.SnowGolem.class, Snowman.class); + map.put(net.minecraft.world.entity.monster.spider.Spider.class, Spider.class); + map.put(net.minecraft.world.entity.animal.squid.Squid.class, Squid.class); map.put(net.minecraft.world.entity.TamableAnimal.class, Tameable.class); - map.put(net.minecraft.world.entity.animal.TropicalFish.class, TropicalFish.class); - map.put(net.minecraft.world.entity.animal.Turtle.class, Turtle.class); + map.put(net.minecraft.world.entity.animal.fish.TropicalFish.class, TropicalFish.class); + map.put(net.minecraft.world.entity.animal.turtle.Turtle.class, Turtle.class); map.put(net.minecraft.world.entity.monster.Vex.class, Vex.class); - map.put(net.minecraft.world.entity.npc.Villager.class, Villager.class); - map.put(net.minecraft.world.entity.npc.AbstractVillager.class, AbstractVillager.class); - map.put(net.minecraft.world.entity.npc.WanderingTrader.class, WanderingTrader.class); - map.put(net.minecraft.world.entity.monster.Vindicator.class, Vindicator.class); - map.put(net.minecraft.world.entity.animal.WaterAnimal.class, WaterMob.class); + map.put(net.minecraft.world.entity.npc.villager.Villager.class, Villager.class); + map.put(net.minecraft.world.entity.npc.villager.AbstractVillager.class, AbstractVillager.class); + map.put(net.minecraft.world.entity.npc.wanderingtrader.WanderingTrader.class, WanderingTrader.class); + map.put(net.minecraft.world.entity.monster.illager.Vindicator.class, Vindicator.class); + map.put(net.minecraft.world.entity.animal.fish.WaterAnimal.class, WaterMob.class); map.put(net.minecraft.world.entity.monster.Witch.class, Witch.class); map.put(net.minecraft.world.entity.boss.wither.WitherBoss.class, Wither.class); map.put(net.minecraft.world.entity.animal.wolf.Wolf.class, Wolf.class); - map.put(net.minecraft.world.entity.monster.Zombie.class, Zombie.class); - map.put(net.minecraft.world.entity.monster.Husk.class, Husk.class); - map.put(net.minecraft.world.entity.monster.ZombieVillager.class, ZombieVillager.class); + map.put(net.minecraft.world.entity.monster.zombie.Zombie.class, Zombie.class); + map.put(net.minecraft.world.entity.monster.zombie.Husk.class, Husk.class); + map.put(net.minecraft.world.entity.monster.zombie.ZombieVillager.class, ZombieVillager.class); map.put(net.minecraft.world.entity.monster.hoglin.Hoglin.class, Hoglin.class); map.put(net.minecraft.world.entity.monster.piglin.Piglin.class, Piglin.class); map.put(net.minecraft.world.entity.monster.piglin.AbstractPiglin.class, PiglinAbstract.class); map.put(net.minecraft.world.entity.monster.piglin.PiglinBrute.class, PiglinBrute.class); map.put(net.minecraft.world.entity.monster.Strider.class, Strider.class); map.put(net.minecraft.world.entity.monster.Zoglin.class, Zoglin.class); - map.put(net.minecraft.world.entity.GlowSquid.class, GlowSquid.class); + map.put(net.minecraft.world.entity.animal.squid.GlowSquid.class, GlowSquid.class); map.put(net.minecraft.world.entity.animal.axolotl.Axolotl.class, Axolotl.class); map.put(net.minecraft.world.entity.animal.goat.Goat.class, Goat.class); map.put(net.minecraft.world.entity.animal.frog.Frog.class, Frog.class); @@ -129,17 +129,17 @@ public class MobGoalHelper { map.put(net.minecraft.world.entity.animal.sniffer.Sniffer.class, Sniffer.class); map.put(net.minecraft.world.entity.monster.breeze.Breeze.class, Breeze.class); map.put(net.minecraft.world.entity.animal.armadillo.Armadillo.class, Armadillo.class); - map.put(net.minecraft.world.entity.monster.Bogged.class, Bogged.class); + map.put(net.minecraft.world.entity.monster.skeleton.Bogged.class, Bogged.class); map.put(net.minecraft.world.entity.monster.creaking.Creaking.class, Creaking.class); map.put(net.minecraft.world.entity.animal.AgeableWaterCreature.class, Squid.class); - map.put(net.minecraft.world.entity.animal.AbstractCow.class, AbstractCow.class); - map.put(net.minecraft.world.entity.animal.HappyGhast.class, HappyGhast.class); - map.put(net.minecraft.world.entity.animal.coppergolem.CopperGolem.class, CopperGolem.class); + map.put(net.minecraft.world.entity.animal.cow.AbstractCow.class, AbstractCow.class); + map.put(net.minecraft.world.entity.animal.happyghast.HappyGhast.class, HappyGhast.class); + map.put(net.minecraft.world.entity.animal.golem.CopperGolem.class, CopperGolem.class); map.put(net.minecraft.world.entity.animal.nautilus.AbstractNautilus.class, AbstractNautilus.class); map.put(net.minecraft.world.entity.animal.nautilus.Nautilus.class, Nautilus.class); map.put(net.minecraft.world.entity.animal.nautilus.ZombieNautilus.class, ZombieNautilus.class); map.put(net.minecraft.world.entity.animal.camel.CamelHusk.class, CamelHusk.class); - map.put(net.minecraft.world.entity.monster.Parched.class, Parched.class); + map.put(net.minecraft.world.entity.monster.skeleton.Parched.class, Parched.class); // End generate - MobGoalHelper#BUKKIT_BRIDGE // }); diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/paper-server/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java index 10ca4e8370fe..237abcf06ebf 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java @@ -48,8 +48,8 @@ import net.minecraft.world.entity.boss.enderdragon.EnderDragon; import net.minecraft.world.entity.decoration.HangingEntity; import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.monster.Vindicator; -import net.minecraft.world.entity.monster.Zombie; +import net.minecraft.world.entity.monster.illager.Vindicator; +import net.minecraft.world.entity.monster.zombie.Zombie; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; @@ -238,7 +238,7 @@ public class SlimeChunk extends ConfigurationPart { public class WanderingTrader extends ConfigurationPart { public int spawnMinuteLength = 1200; - public int spawnDayLength = net.minecraft.world.entity.npc.WanderingTraderSpawner.DEFAULT_SPAWN_DELAY; + public int spawnDayLength = net.minecraft.world.entity.npc.wanderingtrader.WanderingTraderSpawner.DEFAULT_SPAWN_DELAY; public int spawnChanceFailureIncrement = 25; public int spawnChanceMin = 25; public int spawnChanceMax = 75; diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java index ae33c20ec6f2..0310b7c8ed5a 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java @@ -185,22 +185,22 @@ public static void bootstrap() { register(DataComponents.WOLF_VARIANT, CraftWolf.CraftVariant::minecraftHolderToBukkit, CraftWolf.CraftVariant::bukkitToMinecraftHolder); register(DataComponents.WOLF_COLLAR, nms -> DyeColor.getByWoolData((byte) nms.getId()), api -> net.minecraft.world.item.DyeColor.byId(api.getWoolData())); register(DataComponents.WOLF_SOUND_VARIANT, CraftWolf.CraftSoundVariant::minecraftHolderToBukkit, CraftWolf.CraftSoundVariant::bukkitToMinecraftHolder); - register(DataComponents.FOX_VARIANT, nms -> org.bukkit.entity.Fox.Type.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.Fox.Variant.byId(api.ordinal())); - register(DataComponents.SALMON_SIZE, nms -> Salmon.Variant.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.Salmon.Variant.values()[api.ordinal()]); - register(DataComponents.PARROT_VARIANT, nms -> Parrot.Variant.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.Parrot.Variant.byId(api.ordinal())); - register(DataComponents.TROPICAL_FISH_PATTERN, nms -> TropicalFish.Pattern.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.TropicalFish.Pattern.values()[api.ordinal()]); + register(DataComponents.FOX_VARIANT, nms -> org.bukkit.entity.Fox.Type.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.fox.Fox.Variant.byId(api.ordinal())); + register(DataComponents.SALMON_SIZE, nms -> Salmon.Variant.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.fish.Salmon.Variant.values()[api.ordinal()]); + register(DataComponents.PARROT_VARIANT, nms -> Parrot.Variant.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.parrot.Parrot.Variant.byId(api.ordinal())); + register(DataComponents.TROPICAL_FISH_PATTERN, nms -> TropicalFish.Pattern.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.fish.TropicalFish.Pattern.values()[api.ordinal()]); register(DataComponents.TROPICAL_FISH_BASE_COLOR, nms -> DyeColor.getByWoolData((byte) nms.getId()), api -> net.minecraft.world.item.DyeColor.byId(api.getWoolData())); register(DataComponents.TROPICAL_FISH_PATTERN_COLOR, nms -> DyeColor.getByWoolData((byte) nms.getId()), api -> net.minecraft.world.item.DyeColor.byId(api.getWoolData())); - register(DataComponents.MOOSHROOM_VARIANT, nms -> MushroomCow.Variant.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.MushroomCow.Variant.values()[api.ordinal()]); - register(DataComponents.RABBIT_VARIANT, nms -> Rabbit.Type.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.Rabbit.Variant.byId(api.ordinal())); + register(DataComponents.MOOSHROOM_VARIANT, nms -> MushroomCow.Variant.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.cow.MushroomCow.Variant.values()[api.ordinal()]); + register(DataComponents.RABBIT_VARIANT, nms -> Rabbit.Type.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.rabbit.Rabbit.Variant.byId(api.ordinal())); register(DataComponents.PIG_VARIANT, CraftPig.CraftVariant::minecraftHolderToBukkit, CraftPig.CraftVariant::bukkitToMinecraftHolder); register(DataComponents.COW_VARIANT, CraftCow.CraftVariant::minecraftHolderToBukkit, CraftCow.CraftVariant::bukkitToMinecraftHolder); register(DataComponents.CHICKEN_VARIANT, nms -> CraftChicken.CraftVariant.minecraftHolderToBukkit(nms.unwrap(CraftRegistry.getMinecraftRegistry()).orElseThrow()), api -> new EitherHolder<>(CraftChicken.CraftVariant.bukkitToMinecraftHolder(api))); register(DataComponents.FROG_VARIANT, CraftFrog.CraftVariant::minecraftHolderToBukkit, CraftFrog.CraftVariant::bukkitToMinecraftHolder); register(DataComponents.ZOMBIE_NAUTILUS_VARIANT, nms -> CraftZombieNautilus.CraftVariant.minecraftHolderToBukkit(nms.unwrap(CraftRegistry.getMinecraftRegistry()).orElseThrow()), api -> new EitherHolder<>(CraftZombieNautilus.CraftVariant.bukkitToMinecraftHolder(api))); - register(DataComponents.HORSE_VARIANT, nms -> Horse.Color.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.horse.Variant.byId(api.ordinal())); + register(DataComponents.HORSE_VARIANT, nms -> Horse.Color.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.equine.Variant.byId(api.ordinal())); register(DataComponents.PAINTING_VARIANT, CraftArt::minecraftHolderToBukkit, CraftArt::bukkitToMinecraftHolder); - register(DataComponents.LLAMA_VARIANT, nms -> Llama.Color.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.horse.Llama.Variant.byId(api.ordinal())); + register(DataComponents.LLAMA_VARIANT, nms -> Llama.Color.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.equine.Llama.Variant.byId(api.ordinal())); register(DataComponents.AXOLOTL_VARIANT, nms -> Axolotl.Variant.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.axolotl.Axolotl.Variant.byId(api.ordinal())); register(DataComponents.CAT_VARIANT, CraftCat.CraftType::minecraftHolderToBukkit, CraftCat.CraftType::bukkitToMinecraftHolder); register(DataComponents.CAT_COLLAR, nms -> DyeColor.getByWoolData((byte) nms.getId()), api -> net.minecraft.world.item.DyeColor.byId(api.getWoolData())); diff --git a/paper-server/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java b/paper-server/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java index 04c8213ae6f3..661e0c324cac 100644 --- a/paper-server/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java +++ b/paper-server/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java @@ -1,6 +1,6 @@ package io.papermc.paper.entity; -import net.minecraft.world.entity.animal.AbstractSchoolingFish; +import net.minecraft.world.entity.animal.fish.AbstractSchoolingFish; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftFish; import org.jetbrains.annotations.NotNull; diff --git a/paper-server/src/main/java/io/papermc/paper/entity/activation/ActivationType.java b/paper-server/src/main/java/io/papermc/paper/entity/activation/ActivationType.java index 493914c8d14a..b6fccd37c76d 100644 --- a/paper-server/src/main/java/io/papermc/paper/entity/activation/ActivationType.java +++ b/paper-server/src/main/java/io/papermc/paper/entity/activation/ActivationType.java @@ -4,11 +4,11 @@ import net.minecraft.world.entity.PathfinderMob; import net.minecraft.world.entity.ambient.AmbientCreature; import net.minecraft.world.entity.animal.AgeableWaterCreature; -import net.minecraft.world.entity.animal.WaterAnimal; +import net.minecraft.world.entity.animal.fish.WaterAnimal; import net.minecraft.world.entity.monster.Enemy; import net.minecraft.world.entity.monster.Ghast; import net.minecraft.world.entity.monster.Phantom; -import net.minecraft.world.entity.npc.Villager; +import net.minecraft.world.entity.npc.villager.Villager; import net.minecraft.world.entity.raid.Raider; import net.minecraft.world.phys.AABB; diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCatTypeRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCatTypeRegistryEntry.java index 68fadaf8aa98..7b73a4a8e549 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCatTypeRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCatTypeRegistryEntry.java @@ -4,7 +4,7 @@ import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; import net.minecraft.core.ClientAsset; -import net.minecraft.world.entity.animal.CatVariant; +import net.minecraft.world.entity.animal.feline.CatVariant; import net.minecraft.world.entity.variant.SpawnPrioritySelectors; import org.bukkit.entity.Cat; import org.jspecify.annotations.Nullable; diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperChickenVariantRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperChickenVariantRegistryEntry.java index 000127f3b6b4..31b931326467 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperChickenVariantRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperChickenVariantRegistryEntry.java @@ -4,7 +4,7 @@ import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; import net.minecraft.core.ClientAsset; -import net.minecraft.world.entity.animal.ChickenVariant; +import net.minecraft.world.entity.animal.chicken.ChickenVariant; import net.minecraft.world.entity.variant.ModelAndTexture; import net.minecraft.world.entity.variant.SpawnPrioritySelectors; import org.bukkit.entity.Chicken; diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCowVariantRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCowVariantRegistryEntry.java index c168150e2c75..cd3249196b26 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCowVariantRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCowVariantRegistryEntry.java @@ -4,7 +4,7 @@ import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; import net.minecraft.core.ClientAsset; -import net.minecraft.world.entity.animal.CowVariant; +import net.minecraft.world.entity.animal.cow.CowVariant; import net.minecraft.world.entity.variant.ModelAndTexture; import net.minecraft.world.entity.variant.SpawnPrioritySelectors; import org.bukkit.entity.Cow; diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java index 46802fce6346..2fd8ece677df 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java @@ -8,7 +8,7 @@ import net.kyori.adventure.key.Key; import net.minecraft.network.chat.Component; import net.minecraft.resources.Identifier; -import net.minecraft.world.entity.decoration.PaintingVariant; +import net.minecraft.world.entity.decoration.painting.PaintingVariant; import org.bukkit.Art; import org.jetbrains.annotations.Range; import org.jspecify.annotations.Nullable; diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPigVariantRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPigVariantRegistryEntry.java index b43dcd08180d..3f8af47de16b 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPigVariantRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPigVariantRegistryEntry.java @@ -4,7 +4,7 @@ import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; import net.minecraft.core.ClientAsset; -import net.minecraft.world.entity.animal.PigVariant; +import net.minecraft.world.entity.animal.pig.PigVariant; import net.minecraft.world.entity.variant.ModelAndTexture; import net.minecraft.world.entity.variant.SpawnPrioritySelectors; import org.bukkit.entity.Pig; diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperZombieNautilusVariantRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperZombieNautilusVariantRegistryEntry.java index 31cf65bf5b44..c9938e7772e0 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperZombieNautilusVariantRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperZombieNautilusVariantRegistryEntry.java @@ -4,7 +4,7 @@ import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; import net.minecraft.core.ClientAsset; -import net.minecraft.world.entity.animal.ZombieNautilusVariant; +import net.minecraft.world.entity.animal.nautilus.ZombieNautilusVariant; import net.minecraft.world.entity.variant.ModelAndTexture; import net.minecraft.world.entity.variant.SpawnPrioritySelectors; import org.bukkit.entity.ZombieNautilus; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java index b96522330eaa..95995694fbb5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java @@ -5,7 +5,7 @@ import net.kyori.adventure.text.Component; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.world.entity.decoration.PaintingVariant; +import net.minecraft.world.entity.decoration.painting.PaintingVariant; import org.bukkit.Art; public class CraftArt extends OldEnumHolderable implements Art { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 25e2a85f047b..b2961752b50e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -81,7 +81,7 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.ai.village.VillageSiege; import net.minecraft.world.entity.npc.CatSpawner; -import net.minecraft.world.entity.npc.WanderingTraderSpawner; +import net.minecraft.world.entity.npc.wanderingtrader.WanderingTraderSpawner; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.inventory.CraftingMenu; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 356b692c5022..3f1bf621a283 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -693,7 +693,7 @@ public T spawnArrow(Location location, Vector directio Preconditions.checkArgument(direction != null, "Vector cannot be null"); Preconditions.checkArgument(clazz != null, "clazz Entity for the arrow cannot be null"); - net.minecraft.world.entity.projectile.AbstractArrow arrow; + net.minecraft.world.entity.projectile.arrow.AbstractArrow arrow; if (TippedArrow.class.isAssignableFrom(clazz)) { arrow = EntityType.ARROW.create(this.world, EntitySpawnReason.COMMAND); ((Arrow) arrow.getBukkitEntity()).setBasePotionType(PotionType.WATER); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java index 227f20390113..3874807787f7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java @@ -17,13 +17,13 @@ public abstract class CraftAbstractArrow extends AbstractProjectile implements AbstractArrow { - public CraftAbstractArrow(CraftServer server, net.minecraft.world.entity.projectile.AbstractArrow entity) { + public CraftAbstractArrow(CraftServer server, net.minecraft.world.entity.projectile.arrow.AbstractArrow entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.AbstractArrow getHandle() { - return (net.minecraft.world.entity.projectile.AbstractArrow) this.entity; + public net.minecraft.world.entity.projectile.arrow.AbstractArrow getHandle() { + return (net.minecraft.world.entity.projectile.arrow.AbstractArrow) this.entity; } @Override @@ -95,7 +95,7 @@ public PickupStatus getPickupStatus() { @Override public void setPickupStatus(PickupStatus status) { Preconditions.checkArgument(status != null, "PickupStatus cannot be null"); - this.getHandle().pickup = net.minecraft.world.entity.projectile.AbstractArrow.Pickup.byOrdinal(status.ordinal()); + this.getHandle().pickup = net.minecraft.world.entity.projectile.arrow.AbstractArrow.Pickup.byOrdinal(status.ordinal()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractCow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractCow.java index 4ee1cc51e9c9..7bbd895b8c2a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractCow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractCow.java @@ -7,12 +7,12 @@ @NullMarked public abstract class CraftAbstractCow extends CraftAnimals implements AbstractCow { - public CraftAbstractCow(CraftServer server, net.minecraft.world.entity.animal.AbstractCow entity) { + public CraftAbstractCow(CraftServer server, net.minecraft.world.entity.animal.cow.AbstractCow entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.AbstractCow getHandle() { - return (net.minecraft.world.entity.animal.AbstractCow) this.entity; + public net.minecraft.world.entity.animal.cow.AbstractCow getHandle() { + return (net.minecraft.world.entity.animal.cow.AbstractCow) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java index 984dc57a2f2c..0e4cacf29d0c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java @@ -15,13 +15,13 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements AbstractHorse { - public CraftAbstractHorse(CraftServer server, net.minecraft.world.entity.animal.horse.AbstractHorse entity) { + public CraftAbstractHorse(CraftServer server, net.minecraft.world.entity.animal.equine.AbstractHorse entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.horse.AbstractHorse getHandle() { - return (net.minecraft.world.entity.animal.horse.AbstractHorse) this.entity; + public net.minecraft.world.entity.animal.equine.AbstractHorse getHandle() { + return (net.minecraft.world.entity.animal.equine.AbstractHorse) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java index f59fdd04d991..879f57922cc0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java @@ -4,15 +4,15 @@ import org.bukkit.entity.AbstractSkeleton; import org.bukkit.entity.Skeleton; -public abstract class CraftAbstractSkeleton extends CraftMonster implements AbstractSkeleton, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper +public abstract class CraftAbstractSkeleton extends CraftMonster implements AbstractSkeleton, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper - public CraftAbstractSkeleton(CraftServer server, net.minecraft.world.entity.monster.AbstractSkeleton entity) { + public CraftAbstractSkeleton(CraftServer server, net.minecraft.world.entity.monster.skeleton.AbstractSkeleton entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.AbstractSkeleton getHandle() { - return (net.minecraft.world.entity.monster.AbstractSkeleton) this.entity; + public net.minecraft.world.entity.monster.skeleton.AbstractSkeleton getHandle() { + return (net.minecraft.world.entity.monster.skeleton.AbstractSkeleton) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java index 11a72607c484..6add47c0e3e0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.npc.Villager; +import net.minecraft.world.entity.npc.villager.Villager; import net.minecraft.world.item.trading.Merchant; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftInventory; @@ -11,12 +11,12 @@ public abstract class CraftAbstractVillager extends CraftAgeable implements CraftMerchant, AbstractVillager, InventoryHolder { - public CraftAbstractVillager(CraftServer server, net.minecraft.world.entity.npc.AbstractVillager entity) { + public CraftAbstractVillager(CraftServer server, net.minecraft.world.entity.npc.villager.AbstractVillager entity) { super(server, entity); } @Override - public net.minecraft.world.entity.npc.AbstractVillager getHandle() { + public net.minecraft.world.entity.npc.villager.AbstractVillager getHandle() { return (Villager) this.entity; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java index df1e31c60f3d..ebb865373672 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java @@ -5,13 +5,13 @@ import org.bukkit.event.entity.EntityRemoveEvent; public abstract class CraftAbstractWindCharge extends CraftFireball implements AbstractWindCharge { - public CraftAbstractWindCharge(CraftServer server, net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge entity) { + public CraftAbstractWindCharge(CraftServer server, net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.AbstractWindCharge entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge getHandle() { - return (net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge) this.entity; + public net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.AbstractWindCharge getHandle() { + return (net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.AbstractWindCharge) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java index 7926dca4e40f..332ae05a221a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -20,13 +20,13 @@ public class CraftArrow extends CraftAbstractArrow implements Arrow { - public CraftArrow(CraftServer server, net.minecraft.world.entity.projectile.Arrow entity) { + public CraftArrow(CraftServer server, net.minecraft.world.entity.projectile.arrow.Arrow entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.Arrow getHandle() { - return (net.minecraft.world.entity.projectile.Arrow) this.entity; + public net.minecraft.world.entity.projectile.arrow.Arrow getHandle() { + return (net.minecraft.world.entity.projectile.arrow.Arrow) this.entity; } @Override @@ -110,7 +110,7 @@ public PotionType getBasePotionType() { @Override public void setColor(Color color) { - int colorRGB = (color == null) ? net.minecraft.world.entity.projectile.Arrow.NO_EFFECT_COLOR : color.asARGB(); // Paper + int colorRGB = (color == null) ? net.minecraft.world.entity.projectile.arrow.Arrow.NO_EFFECT_COLOR : color.asARGB(); // Paper PotionContents old = this.getHandle().getPotionContents(); this.getHandle().setPotionContents(new PotionContents(old.potion(), Optional.of(colorRGB), old.customEffects(), old.customName())); } @@ -118,7 +118,7 @@ public void setColor(Color color) { @Override public Color getColor() { int color = this.getHandle().getColor(); // Paper - if (color == net.minecraft.world.entity.projectile.Arrow.NO_EFFECT_COLOR) { // Paper + if (color == net.minecraft.world.entity.projectile.arrow.Arrow.NO_EFFECT_COLOR) { // Paper return null; } return Color.fromARGB(color); // Paper diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java index 78fe5cf6e471..7602f93e1f61 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java @@ -9,13 +9,13 @@ public class CraftBee extends CraftAnimals implements Bee { - public CraftBee(CraftServer server, net.minecraft.world.entity.animal.Bee entity) { + public CraftBee(CraftServer server, net.minecraft.world.entity.animal.bee.Bee entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Bee getHandle() { - return (net.minecraft.world.entity.animal.Bee) this.entity; + public net.minecraft.world.entity.animal.bee.Bee getHandle() { + return (net.minecraft.world.entity.animal.bee.Bee) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java index aba0a70af908..02a4a8641050 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.TreeSpecies; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Boat; @@ -89,7 +89,7 @@ public org.bukkit.Material getBoatMaterial() { @Override public Status getStatus() { // Paper start - Fix NPE on Boat getStatus - final net.minecraft.world.entity.vehicle.AbstractBoat handle = this.getHandle(); + final net.minecraft.world.entity.vehicle.boat.AbstractBoat handle = this.getHandle(); if (handle.status == null) { if (handle.valid) { // Don't actually set the status because it would skew the old status check in the next tick @@ -142,7 +142,7 @@ public static Boat.Type boatTypeFromNms(EntityType boatType) { throw new EnumConstantNotPresentException(Type.class, boatType.toString()); } - public static Status boatStatusFromNms(net.minecraft.world.entity.vehicle.AbstractBoat.Status enumStatus) { // Paper - remap fixes + public static Status boatStatusFromNms(net.minecraft.world.entity.vehicle.boat.AbstractBoat.Status enumStatus) { // Paper - remap fixes return switch (enumStatus) { default -> throw new EnumConstantNotPresentException(Status.class, enumStatus.name()); case IN_AIR -> Status.IN_AIR; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java index 3db0be03f46d..a2eab26f3b79 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java @@ -6,13 +6,13 @@ public class CraftBogged extends CraftAbstractSkeleton implements Bogged, io.papermc.paper.entity.PaperShearable { // Paper - Shear API - public CraftBogged(CraftServer server, net.minecraft.world.entity.monster.Bogged entity) { + public CraftBogged(CraftServer server, net.minecraft.world.entity.monster.skeleton.Bogged entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Bogged getHandle() { - return (net.minecraft.world.entity.monster.Bogged) this.entity; + public net.minecraft.world.entity.monster.skeleton.Bogged getHandle() { + return (net.minecraft.world.entity.monster.skeleton.Bogged) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBreezeWindCharge.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBreezeWindCharge.java index 59dd96368973..416d0c45a702 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBreezeWindCharge.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBreezeWindCharge.java @@ -4,12 +4,12 @@ import org.bukkit.entity.BreezeWindCharge; public class CraftBreezeWindCharge extends CraftAbstractWindCharge implements BreezeWindCharge { - public CraftBreezeWindCharge(CraftServer server, net.minecraft.world.entity.projectile.windcharge.BreezeWindCharge entity) { + public CraftBreezeWindCharge(CraftServer server, net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.BreezeWindCharge entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.windcharge.BreezeWindCharge getHandle() { - return (net.minecraft.world.entity.projectile.windcharge.BreezeWindCharge) this.entity; + public net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.BreezeWindCharge getHandle() { + return (net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.BreezeWindCharge) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java index 22f6a08426d4..0ff5f7417259 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java @@ -4,7 +4,7 @@ import io.papermc.paper.util.OldEnumHolderable; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.world.entity.animal.CatVariant; +import net.minecraft.world.entity.animal.feline.CatVariant; import org.bukkit.DyeColor; import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftServer; @@ -12,13 +12,13 @@ public class CraftCat extends CraftTameableAnimal implements Cat { - public CraftCat(CraftServer server, net.minecraft.world.entity.animal.Cat entity) { + public CraftCat(CraftServer server, net.minecraft.world.entity.animal.feline.Cat entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Cat getHandle() { - return (net.minecraft.world.entity.animal.Cat) this.entity; + public net.minecraft.world.entity.animal.feline.Cat getHandle() { + return (net.minecraft.world.entity.animal.feline.Cat) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java index 79907f902734..6e75b9518192 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java @@ -4,12 +4,12 @@ import org.bukkit.entity.CaveSpider; public class CraftCaveSpider extends CraftSpider implements CaveSpider { - public CraftCaveSpider(CraftServer server, net.minecraft.world.entity.monster.CaveSpider entity) { + public CraftCaveSpider(CraftServer server, net.minecraft.world.entity.monster.spider.CaveSpider entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.CaveSpider getHandle() { - return (net.minecraft.world.entity.monster.CaveSpider) this.entity; + public net.minecraft.world.entity.monster.spider.CaveSpider getHandle() { + return (net.minecraft.world.entity.monster.spider.CaveSpider) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java index 22ea11d7ada3..b718a5fa75eb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.inventory.Inventory; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java index d05897695fc3..166dba85fe90 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.animal.horse.AbstractChestedHorse; +import net.minecraft.world.entity.animal.equine.AbstractChestedHorse; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.ChestedHorse; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java index 677165bee7f4..1e015dc87c62 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java @@ -4,7 +4,7 @@ import io.papermc.paper.registry.HolderableBase; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.world.entity.animal.ChickenVariant; +import net.minecraft.world.entity.animal.chicken.ChickenVariant; import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Chicken; @@ -13,13 +13,13 @@ @NullMarked public class CraftChicken extends CraftAnimals implements Chicken { - public CraftChicken(CraftServer server, net.minecraft.world.entity.animal.Chicken entity) { + public CraftChicken(CraftServer server, net.minecraft.world.entity.animal.chicken.Chicken entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Chicken getHandle() { - return (net.minecraft.world.entity.animal.Chicken) this.entity; + public net.minecraft.world.entity.animal.chicken.Chicken getHandle() { + return (net.minecraft.world.entity.animal.chicken.Chicken) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java index ca8c10cca87d..d26545a066a2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java @@ -5,12 +5,12 @@ public class CraftCod extends io.papermc.paper.entity.PaperSchoolableFish implements Cod { // Paper - School Fish API - public CraftCod(CraftServer server, net.minecraft.world.entity.animal.Cod entity) { + public CraftCod(CraftServer server, net.minecraft.world.entity.animal.fish.Cod entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Cod getHandle() { - return (net.minecraft.world.entity.animal.Cod) this.entity; + public net.minecraft.world.entity.animal.fish.Cod getHandle() { + return (net.minecraft.world.entity.animal.fish.Cod) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java index 178cadf023bf..e6d884596d20 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.boss.EnderDragonPart; +import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.ComplexEntityPart; import org.bukkit.entity.ComplexLivingEntity; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCopperGolem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCopperGolem.java index 0ea9e83df77f..36d838fe5abc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCopperGolem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCopperGolem.java @@ -10,13 +10,13 @@ @NullMarked public class CraftCopperGolem extends CraftGolem implements CopperGolem, PaperShearable { - public CraftCopperGolem(final CraftServer server, final net.minecraft.world.entity.animal.coppergolem.CopperGolem entity) { + public CraftCopperGolem(final CraftServer server, final net.minecraft.world.entity.animal.golem.CopperGolem entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.coppergolem.CopperGolem getHandle() { - return (net.minecraft.world.entity.animal.coppergolem.CopperGolem) this.entity; + public net.minecraft.world.entity.animal.golem.CopperGolem getHandle() { + return (net.minecraft.world.entity.animal.golem.CopperGolem) this.entity; } @Override @@ -33,9 +33,9 @@ public void setWeatheringState(final WeatheringCopperState state) { @Override public Oxidizing getOxidizing() { long value = this.getHandle().nextWeatheringTick; - if (value == net.minecraft.world.entity.animal.coppergolem.CopperGolem.UNSET_WEATHERING_TICK) { + if (value == net.minecraft.world.entity.animal.golem.CopperGolem.UNSET_WEATHERING_TICK) { return Oxidizing.unset(); - } else if (value == net.minecraft.world.entity.animal.coppergolem.CopperGolem.IGNORE_WEATHERING_TICK) { + } else if (value == net.minecraft.world.entity.animal.golem.CopperGolem.IGNORE_WEATHERING_TICK) { return Oxidizing.waxed(); } if (value < 0) { @@ -49,8 +49,8 @@ public Oxidizing getOxidizing() { public void setOxidizing(final Oxidizing oxidizing) { Preconditions.checkArgument(oxidizing != null, "oxidizing cannot be null"); switch (oxidizing) { - case Oxidizing.Waxed waxed -> this.getHandle().nextWeatheringTick = net.minecraft.world.entity.animal.coppergolem.CopperGolem.IGNORE_WEATHERING_TICK; - case Oxidizing.Unset unset -> this.getHandle().nextWeatheringTick = net.minecraft.world.entity.animal.coppergolem.CopperGolem.UNSET_WEATHERING_TICK; + case Oxidizing.Waxed waxed -> this.getHandle().nextWeatheringTick = net.minecraft.world.entity.animal.golem.CopperGolem.IGNORE_WEATHERING_TICK; + case Oxidizing.Unset unset -> this.getHandle().nextWeatheringTick = net.minecraft.world.entity.animal.golem.CopperGolem.UNSET_WEATHERING_TICK; case Oxidizing.AtTime atTime -> this.getHandle().nextWeatheringTick = atTime.time(); default -> throw new IllegalStateException("Unexpected value: " + oxidizing); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java index 81aaf5c979ef..e0adc2c33c26 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java @@ -4,7 +4,7 @@ import io.papermc.paper.registry.HolderableBase; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.world.entity.animal.CowVariant; +import net.minecraft.world.entity.animal.cow.CowVariant; import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Cow; @@ -13,13 +13,13 @@ @NullMarked public class CraftCow extends CraftAbstractCow implements Cow { - public CraftCow(CraftServer server, net.minecraft.world.entity.animal.Cow entity) { + public CraftCow(CraftServer server, net.minecraft.world.entity.animal.cow.Cow entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Cow getHandle() { - return (net.minecraft.world.entity.animal.Cow) this.entity; + public net.minecraft.world.entity.animal.cow.Cow getHandle() { + return (net.minecraft.world.entity.animal.cow.Cow) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java index 0400e181e4cb..880127650213 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java @@ -7,13 +7,13 @@ public class CraftDolphin extends CraftAgeable implements Dolphin { - public CraftDolphin(CraftServer server, net.minecraft.world.entity.animal.Dolphin entity) { + public CraftDolphin(CraftServer server, net.minecraft.world.entity.animal.dolphin.Dolphin entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Dolphin getHandle() { - return (net.minecraft.world.entity.animal.Dolphin) this.entity; + public net.minecraft.world.entity.animal.dolphin.Dolphin getHandle() { + return (net.minecraft.world.entity.animal.dolphin.Dolphin) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDonkey.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDonkey.java index 85820f25d735..dff9bb9c37e6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDonkey.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDonkey.java @@ -6,7 +6,7 @@ public class CraftDonkey extends CraftChestedHorse implements Donkey { - public CraftDonkey(CraftServer server, net.minecraft.world.entity.animal.horse.Donkey entity) { + public CraftDonkey(CraftServer server, net.minecraft.world.entity.animal.equine.Donkey entity) { super(server, entity); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDragonFireball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDragonFireball.java index 00b4487b10f5..ce443bb35ae6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDragonFireball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDragonFireball.java @@ -5,7 +5,7 @@ public class CraftDragonFireball extends CraftFireball implements DragonFireball { - public CraftDragonFireball(CraftServer server, net.minecraft.world.entity.projectile.DragonFireball entity) { + public CraftDragonFireball(CraftServer server, net.minecraft.world.entity.projectile.hurtingprojectile.DragonFireball entity) { super(server, entity); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java index 4dfed6e60ce3..45172aaf11bf 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java @@ -3,14 +3,14 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Drowned; -public class CraftDrowned extends CraftZombie implements Drowned, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper +public class CraftDrowned extends CraftZombie implements Drowned, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper - public CraftDrowned(CraftServer server, net.minecraft.world.entity.monster.Drowned entity) { + public CraftDrowned(CraftServer server, net.minecraft.world.entity.monster.zombie.Drowned entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Drowned getHandle() { - return (net.minecraft.world.entity.monster.Drowned) this.entity; + public net.minecraft.world.entity.monster.zombie.Drowned getHandle() { + return (net.minecraft.world.entity.monster.zombie.Drowned) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java index 6b1c6e0239fc..9d578ee22f3f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.projectile.ThrownEgg; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEgg; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Egg; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java index a716433db42e..a1854acb8a15 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java @@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; import java.util.Set; -import net.minecraft.world.entity.boss.EnderDragonPart; +import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase; import org.bukkit.boss.BossBar; import org.bukkit.boss.DragonBattle; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java index 9d7268b6b4e9..25e9b002df1f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java @@ -7,7 +7,7 @@ import org.bukkit.entity.Entity; public class CraftEnderDragonPart extends CraftComplexPart implements EnderDragonPart { - public CraftEnderDragonPart(CraftServer server, net.minecraft.world.entity.boss.EnderDragonPart entity) { + public CraftEnderDragonPart(CraftServer server, net.minecraft.world.entity.boss.enderdragon.EnderDragonPart entity) { super(server, entity); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java index eb7e63d5697d..f97a961971f3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.projectile.ThrownEnderpearl; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EnderPearl; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 20c344f78a5a..2a572ef0ba74 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -31,9 +31,9 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityProcessor; import net.minecraft.world.entity.EntitySpawnReason; -import net.minecraft.world.entity.boss.EnderDragonPart; +import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.entity.projectile.AbstractArrow; +import net.minecraft.world.entity.projectile.arrow.AbstractArrow; import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.level.storage.TagValueOutput; import net.minecraft.world.level.storage.ValueInput; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java index 0c4f859ed392..3f9a42944e5d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java @@ -16,13 +16,13 @@ import net.minecraft.world.entity.item.FallingBlockEntity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.PrimedTnt; -import net.minecraft.world.entity.projectile.AbstractHurtingProjectile; +import net.minecraft.world.entity.projectile.hurtingprojectile.AbstractHurtingProjectile; import net.minecraft.world.entity.projectile.EyeOfEnder; import net.minecraft.world.entity.projectile.FireworkRocketEntity; -import net.minecraft.world.entity.projectile.ThrownEgg; -import net.minecraft.world.entity.projectile.ThrownLingeringPotion; -import net.minecraft.world.entity.projectile.ThrownSplashPotion; -import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEgg; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownLingeringPotion; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownSplashPotion; +import net.minecraft.world.entity.vehicle.minecart.AbstractMinecart; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; @@ -385,13 +385,13 @@ Level minecraftWorld() { register(new EntityTypeData<>(EntityType.PAINTING, Painting.class, CraftPainting::new, createHanging(Painting.class, (spawnData, hangingData) -> { if (spawnData.normalWorld && hangingData.randomize()) { // Paper start - if randomizeData fails, force it - final net.minecraft.world.entity.decoration.Painting entity = net.minecraft.world.entity.decoration.Painting.create(spawnData.minecraftWorld(), hangingData.position(), hangingData.direction()).orElse(null); + final net.minecraft.world.entity.decoration.painting.Painting entity = net.minecraft.world.entity.decoration.painting.Painting.create(spawnData.minecraftWorld(), hangingData.position(), hangingData.direction()).orElse(null); if (entity != null) { return entity; } } /*else*/ { // Paper end - if randomizeData fails, force it - net.minecraft.world.entity.decoration.Painting entity = new net.minecraft.world.entity.decoration.Painting(net.minecraft.world.entity.EntityType.PAINTING, spawnData.minecraftWorld()); + net.minecraft.world.entity.decoration.painting.Painting entity = new net.minecraft.world.entity.decoration.painting.Painting(net.minecraft.world.entity.EntityType.PAINTING, spawnData.minecraftWorld()); entity.absSnapTo(spawnData.x(), spawnData.y(), spawnData.z(), spawnData.yaw(), spawnData.pitch()); entity.setDirection(hangingData.direction()); return entity; @@ -460,7 +460,7 @@ Level minecraftWorld() { register(new EntityTypeData<>(EntityType.AREA_EFFECT_CLOUD, AreaEffectCloud.class, CraftAreaEffectCloud::new, createAndMove(net.minecraft.world.entity.EntityType.AREA_EFFECT_CLOUD))); // Paper - set area effect cloud rotation register(new EntityTypeData<>(EntityType.EGG, Egg.class, CraftEgg::new, spawnData -> new ThrownEgg(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new ItemStack(Items.EGG)))); register(new EntityTypeData<>(EntityType.LEASH_KNOT, LeashHitch.class, CraftLeash::new, spawnData -> new LeashFenceKnotEntity(spawnData.minecraftWorld(), BlockPos.containing(spawnData.x(), spawnData.y(), spawnData.z())))); // SPIGOT-5732: LeashHitch has no direction and is always centered at a block - register(new EntityTypeData<>(EntityType.SNOWBALL, Snowball.class, CraftSnowball::new, spawnData -> new net.minecraft.world.entity.projectile.Snowball(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new ItemStack(Items.SNOWBALL)))); + register(new EntityTypeData<>(EntityType.SNOWBALL, Snowball.class, CraftSnowball::new, spawnData -> new net.minecraft.world.entity.projectile.throwableitemprojectile.Snowball(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new ItemStack(Items.SNOWBALL)))); register(new EntityTypeData<>(EntityType.EYE_OF_ENDER, EnderSignal.class, CraftEnderSignal::new, spawnData -> new EyeOfEnder(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z()))); register(new EntityTypeData<>(EntityType.SPLASH_POTION, SplashPotion.class, CraftThrownSplashPotion::new, spawnData -> new ThrownSplashPotion(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new ItemStack(Items.SPLASH_POTION)))); register(new EntityTypeData<>(EntityType.LINGERING_POTION, LingeringPotion.class, CraftThrownLingeringPotion::new, spawnData -> new ThrownLingeringPotion(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new ItemStack(Items.LINGERING_POTION)))); @@ -566,7 +566,7 @@ private static Function list = spawnData.world().getEntities(null, bb); for (Iterator it = list.iterator(); !taken && it.hasNext(); ) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java index 73b50136708d..1142007368e1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java @@ -1,19 +1,19 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.world.entity.animal.sheep.Sheep; -import net.minecraft.world.entity.monster.SpellcasterIllager; +import net.minecraft.world.entity.monster.illager.SpellcasterIllager; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Evoker; public class CraftEvoker extends CraftSpellcaster implements Evoker { - public CraftEvoker(CraftServer server, net.minecraft.world.entity.monster.Evoker entity) { + public CraftEvoker(CraftServer server, net.minecraft.world.entity.monster.illager.Evoker entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Evoker getHandle() { - return (net.minecraft.world.entity.monster.Evoker) this.entity; + public net.minecraft.world.entity.monster.illager.Evoker getHandle() { + return (net.minecraft.world.entity.monster.illager.Evoker) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java index 7e53e12c8ec5..72291b2142ba 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.world.entity.projectile.AbstractHurtingProjectile; +import net.minecraft.world.entity.projectile.hurtingprojectile.AbstractHurtingProjectile; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.util.CraftVector; import org.bukkit.entity.Fireball; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java index 207f06a854d2..331a3ccac263 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.animal.AbstractFish; +import net.minecraft.world.entity.animal.fish.AbstractFish; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Fish; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java index dbf84ba61bf9..8f3e0ddd4033 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java @@ -11,13 +11,13 @@ public class CraftFox extends CraftAnimals implements Fox { - public CraftFox(CraftServer server, net.minecraft.world.entity.animal.Fox entity) { + public CraftFox(CraftServer server, net.minecraft.world.entity.animal.fox.Fox entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Fox getHandle() { - return (net.minecraft.world.entity.animal.Fox) this.entity; + public net.minecraft.world.entity.animal.fox.Fox getHandle() { + return (net.minecraft.world.entity.animal.fox.Fox) this.entity; } @Override @@ -29,7 +29,7 @@ public Type getFoxType() { public void setFoxType(Type type) { Preconditions.checkArgument(type != null, "type"); - this.getHandle().setVariant(net.minecraft.world.entity.animal.Fox.Variant.values()[type.ordinal()]); + this.getHandle().setVariant(net.minecraft.world.entity.animal.fox.Fox.Variant.values()[type.ordinal()]); } @Override @@ -72,30 +72,30 @@ private AnimalTamer getTrustedPlayer(EntityDataAccessor { // Paper +public class CraftIllusioner extends CraftSpellcaster implements Illusioner, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper - public CraftIllusioner(CraftServer server, net.minecraft.world.entity.monster.Illusioner entity) { + public CraftIllusioner(CraftServer server, net.minecraft.world.entity.monster.illager.Illusioner entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Illusioner getHandle() { - return (net.minecraft.world.entity.monster.Illusioner) this.entity; + public net.minecraft.world.entity.monster.illager.Illusioner getHandle() { + return (net.minecraft.world.entity.monster.illager.Illusioner) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java index 2d7be6f2afe3..54cea2ff4abb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java @@ -4,13 +4,13 @@ import org.bukkit.entity.IronGolem; public class CraftIronGolem extends CraftGolem implements IronGolem { - public CraftIronGolem(CraftServer server, net.minecraft.world.entity.animal.IronGolem entity) { + public CraftIronGolem(CraftServer server, net.minecraft.world.entity.animal.golem.IronGolem entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.IronGolem getHandle() { - return (net.minecraft.world.entity.animal.IronGolem) this.entity; + public net.minecraft.world.entity.animal.golem.IronGolem getHandle() { + return (net.minecraft.world.entity.animal.golem.IronGolem) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java index 742c02279629..f4c4252174f6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java @@ -5,13 +5,13 @@ public class CraftLargeFireball extends CraftSizedFireball implements LargeFireball { - public CraftLargeFireball(CraftServer server, net.minecraft.world.entity.projectile.LargeFireball entity) { + public CraftLargeFireball(CraftServer server, net.minecraft.world.entity.projectile.hurtingprojectile.LargeFireball entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.LargeFireball getHandle() { - return (net.minecraft.world.entity.projectile.LargeFireball) this.entity; + public net.minecraft.world.entity.projectile.hurtingprojectile.LargeFireball getHandle() { + return (net.minecraft.world.entity.projectile.hurtingprojectile.LargeFireball) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index a0fabdcb744f..dfc66145bcd4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -27,12 +27,12 @@ import net.minecraft.world.entity.decoration.Mannequin; import net.minecraft.world.entity.projectile.FireworkRocketEntity; import net.minecraft.world.entity.projectile.FishingHook; -import net.minecraft.world.entity.projectile.LargeFireball; +import net.minecraft.world.entity.projectile.hurtingprojectile.LargeFireball; import net.minecraft.world.entity.projectile.ThrowableProjectile; -import net.minecraft.world.entity.projectile.ThrownEgg; -import net.minecraft.world.entity.projectile.ThrownEnderpearl; -import net.minecraft.world.entity.projectile.ThrownExperienceBottle; -import net.minecraft.world.entity.projectile.ThrownTrident; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEgg; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownExperienceBottle; +import net.minecraft.world.entity.projectile.arrow.ThrownTrident; import net.minecraft.world.item.Items; import net.minecraft.world.item.component.Consumable; import net.minecraft.world.phys.Vec3; @@ -544,7 +544,7 @@ public T launchProjectile(Class projectile, net.minecraft.world.entity.Entity launch = null; if (Snowball.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.Snowball(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.SNOWBALL)); + launch = new net.minecraft.world.entity.projectile.throwableitemprojectile.Snowball(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.SNOWBALL)); ((ThrowableProjectile) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemSnowball } else if (Egg.class.isAssignableFrom(projectile)) { launch = new ThrownEgg(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.EGG)); @@ -554,21 +554,21 @@ public T launchProjectile(Class projectile, ((ThrowableProjectile) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemEnderPearl } else if (AbstractArrow.class.isAssignableFrom(projectile)) { if (TippedArrow.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.Arrow(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null); + launch = new net.minecraft.world.entity.projectile.arrow.Arrow(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null); ((Arrow) launch.getBukkitEntity()).setBasePotionType(PotionType.WATER); } else if (SpectralArrow.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.SpectralArrow(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.SPECTRAL_ARROW), null); + launch = new net.minecraft.world.entity.projectile.arrow.SpectralArrow(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.SPECTRAL_ARROW), null); } else if (Trident.class.isAssignableFrom(projectile)) { launch = new ThrownTrident(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.TRIDENT)); } else { - launch = new net.minecraft.world.entity.projectile.Arrow(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null); + launch = new net.minecraft.world.entity.projectile.arrow.Arrow(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null); } - ((net.minecraft.world.entity.projectile.AbstractArrow) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, Trident.class.isAssignableFrom(projectile) ? net.minecraft.world.item.TridentItem.PROJECTILE_SHOOT_POWER : 3.0F, 1.0F); // ItemBow // Paper - see TridentItem + ((net.minecraft.world.entity.projectile.arrow.AbstractArrow) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, Trident.class.isAssignableFrom(projectile) ? net.minecraft.world.item.TridentItem.PROJECTILE_SHOOT_POWER : 3.0F, 1.0F); // ItemBow // Paper - see TridentItem } else if (ThrownPotion.class.isAssignableFrom(projectile)) { if (LingeringPotion.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.ThrownLingeringPotion(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.LINGERING_POTION)); + launch = new net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownLingeringPotion(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.LINGERING_POTION)); } else { - launch = new net.minecraft.world.entity.projectile.ThrownSplashPotion(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.SPLASH_POTION)); + launch = new net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownSplashPotion(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.SPLASH_POTION)); } ((ThrowableProjectile) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), -20.0F, 0.5F, 1.0F); // ItemSplashPotion } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) { @@ -582,11 +582,11 @@ public T launchProjectile(Class projectile, Vec3 vec = new Vec3(direction.getX(), direction.getY(), direction.getZ()); if (SmallFireball.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.SmallFireball(world, this.getHandle(), vec); + launch = new net.minecraft.world.entity.projectile.hurtingprojectile.SmallFireball(world, this.getHandle(), vec); } else if (WitherSkull.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.WitherSkull(world, this.getHandle(), vec); + launch = new net.minecraft.world.entity.projectile.hurtingprojectile.WitherSkull(world, this.getHandle(), vec); } else if (DragonFireball.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.DragonFireball(world, this.getHandle(), vec); + launch = new net.minecraft.world.entity.projectile.hurtingprojectile.DragonFireball(world, this.getHandle(), vec); } else if (AbstractWindCharge.class.isAssignableFrom(projectile)) { if (BreezeWindCharge.class.isAssignableFrom(projectile)) { launch = EntityType.BREEZE_WIND_CHARGE.create(world, EntitySpawnReason.TRIGGERED); @@ -594,8 +594,8 @@ public T launchProjectile(Class projectile, launch = EntityType.WIND_CHARGE.create(world, EntitySpawnReason.TRIGGERED); } - ((net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge) launch).setOwner(this.getHandle()); - ((net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // WindChargeItem + ((net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.AbstractWindCharge) launch).setOwner(this.getHandle()); + ((net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.AbstractWindCharge) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // WindChargeItem } else { launch = new LargeFireball(world, this.getHandle(), vec, 1); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java index 96b88f301b55..443146323ee5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -8,15 +8,15 @@ import org.bukkit.entity.Llama; import org.bukkit.inventory.LlamaInventory; -public class CraftLlama extends CraftChestedHorse implements Llama, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper +public class CraftLlama extends CraftChestedHorse implements Llama, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper - public CraftLlama(CraftServer server, net.minecraft.world.entity.animal.horse.Llama entity) { + public CraftLlama(CraftServer server, net.minecraft.world.entity.animal.equine.Llama entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.horse.Llama getHandle() { - return (net.minecraft.world.entity.animal.horse.Llama) this.entity; + public net.minecraft.world.entity.animal.equine.Llama getHandle() { + return (net.minecraft.world.entity.animal.equine.Llama) this.entity; } @Override @@ -28,7 +28,7 @@ public Color getColor() { public void setColor(Color color) { Preconditions.checkArgument(color != null, "color"); - this.getHandle().setVariant(net.minecraft.world.entity.animal.horse.Llama.Variant.byId(color.ordinal())); + this.getHandle().setVariant(net.minecraft.world.entity.animal.equine.Llama.Variant.byId(color.ordinal())); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java index 9c5caa4b9c11..78149d1adc3a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java @@ -2,7 +2,7 @@ import com.google.common.base.Preconditions; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.vehicle.minecart.AbstractMinecart; import net.minecraft.world.level.block.state.BlockState; import org.bukkit.Material; import org.bukkit.block.data.BlockData; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java index 0a3581cdc53b..e47ec7b25a23 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.vehicle.MinecartChest; +import net.minecraft.world.entity.vehicle.minecart.MinecartChest; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.entity.minecart.StorageMinecart; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java index bbfb29ebb674..d3fae5d5959e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java @@ -2,7 +2,7 @@ import java.util.Set; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.vehicle.MinecartCommandBlock; +import net.minecraft.world.entity.vehicle.minecart.MinecartCommandBlock; import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.craftbukkit.CraftServer; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java index a1f27890787b..04114f773c94 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.vehicle.AbstractMinecart; -import net.minecraft.world.entity.vehicle.AbstractMinecartContainer; +import net.minecraft.world.entity.vehicle.minecart.AbstractMinecart; +import net.minecraft.world.entity.vehicle.minecart.AbstractMinecartContainer; import org.bukkit.craftbukkit.CraftServer; public abstract class CraftMinecartContainer extends CraftMinecart implements com.destroystokyo.paper.loottable.PaperLootableEntityInventory { // Paper diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java index 65d808c2b088..070aafdf1446 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.world.entity.vehicle.MinecartFurnace; +import net.minecraft.world.entity.vehicle.minecart.MinecartFurnace; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.minecart.PoweredMinecart; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java index 7933ee5f7327..91a534e2ef94 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.vehicle.MinecartHopper; +import net.minecraft.world.entity.vehicle.minecart.MinecartHopper; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.entity.minecart.HopperMinecart; @@ -16,8 +16,8 @@ public CraftMinecartHopper(CraftServer server, MinecartHopper entity) { } @Override - public net.minecraft.world.entity.vehicle.MinecartHopper getHandle() { - return (net.minecraft.world.entity.vehicle.MinecartHopper) this.entity; + public net.minecraft.world.entity.vehicle.minecart.MinecartHopper getHandle() { + return (net.minecraft.world.entity.vehicle.minecart.MinecartHopper) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java index ab1a4dceae22..f051c44b7ce3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java @@ -8,7 +8,7 @@ import net.minecraft.util.ProblemReporter; import net.minecraft.util.RandomSource; import net.minecraft.util.random.WeightedList; -import net.minecraft.world.entity.vehicle.MinecartSpawner; +import net.minecraft.world.entity.vehicle.minecart.MinecartSpawner; import net.minecraft.world.level.SpawnData; import net.minecraft.world.level.storage.TagValueInput; import org.bukkit.block.spawner.SpawnRule; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartRideable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartRideable.java index a043737f0344..d869a0e3a4b2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartRideable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartRideable.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.vehicle.Minecart; +import net.minecraft.world.entity.vehicle.minecart.Minecart; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.minecart.RideableMinecart; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java index 41e706d45015..4bc70737a538 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java @@ -2,7 +2,7 @@ import com.google.common.base.Preconditions; import net.minecraft.util.Mth; -import net.minecraft.world.entity.vehicle.MinecartTNT; +import net.minecraft.world.entity.vehicle.minecart.MinecartTNT; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.minecart.ExplosiveMinecart; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMule.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMule.java index 075bf368f7e7..909bdd845e6f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMule.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMule.java @@ -6,7 +6,7 @@ public class CraftMule extends CraftChestedHorse implements Mule { - public CraftMule(CraftServer server, net.minecraft.world.entity.animal.horse.Mule entity) { + public CraftMule(CraftServer server, net.minecraft.world.entity.animal.equine.Mule entity) { super(server, entity); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java index fb25c0f554a5..a69bc672ed2e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java @@ -15,13 +15,13 @@ public class CraftMushroomCow extends CraftAbstractCow implements MushroomCow, io.papermc.paper.entity.PaperShearable { // Paper - public CraftMushroomCow(CraftServer server, net.minecraft.world.entity.animal.MushroomCow entity) { + public CraftMushroomCow(CraftServer server, net.minecraft.world.entity.animal.cow.MushroomCow entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.MushroomCow getHandle() { - return (net.minecraft.world.entity.animal.MushroomCow) this.entity; + public net.minecraft.world.entity.animal.cow.MushroomCow getHandle() { + return (net.minecraft.world.entity.animal.cow.MushroomCow) this.entity; } @Override @@ -106,7 +106,7 @@ public Variant getVariant() { public void setVariant(Variant variant) { Preconditions.checkArgument(variant != null, "Variant cannot be null"); - this.getHandle().setVariant(net.minecraft.world.entity.animal.MushroomCow.Variant.values()[variant.ordinal()]); + this.getHandle().setVariant(net.minecraft.world.entity.animal.cow.MushroomCow.Variant.values()[variant.ordinal()]); } // Paper start diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java index b4685c9773ee..0c61f068acfc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java @@ -5,13 +5,13 @@ public class CraftOcelot extends CraftAnimals implements Ocelot { - public CraftOcelot(CraftServer server, net.minecraft.world.entity.animal.Ocelot ocelot) { + public CraftOcelot(CraftServer server, net.minecraft.world.entity.animal.feline.Ocelot ocelot) { super(server, ocelot); } @Override - public net.minecraft.world.entity.animal.Ocelot getHandle() { - return (net.minecraft.world.entity.animal.Ocelot) this.entity; + public net.minecraft.world.entity.animal.feline.Ocelot getHandle() { + return (net.minecraft.world.entity.animal.feline.Ocelot) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java index 614a17330020..4582a36fe461 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.core.Holder; -import net.minecraft.world.entity.decoration.PaintingVariant; +import net.minecraft.world.entity.decoration.painting.PaintingVariant; import org.bukkit.Art; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.CraftArt; @@ -10,13 +10,13 @@ public class CraftPainting extends CraftHanging implements Painting { - public CraftPainting(CraftServer server, net.minecraft.world.entity.decoration.Painting entity) { + public CraftPainting(CraftServer server, net.minecraft.world.entity.decoration.painting.Painting entity) { super(server, entity); } @Override - public net.minecraft.world.entity.decoration.Painting getHandle() { - return (net.minecraft.world.entity.decoration.Painting) this.entity; + public net.minecraft.world.entity.decoration.painting.Painting getHandle() { + return (net.minecraft.world.entity.decoration.painting.Painting) this.entity; } @Override @@ -31,7 +31,7 @@ public boolean setArt(Art art) { @Override public boolean setArt(Art art, boolean force) { - net.minecraft.world.entity.decoration.Painting painting = this.getHandle(); + net.minecraft.world.entity.decoration.painting.Painting painting = this.getHandle(); Holder oldArt = painting.getVariant(); painting.setVariant(CraftArt.bukkitToMinecraftHolder(art)); painting.setDirection(painting.getDirection()); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java index df2877d055fe..5a533dc43d15 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java @@ -6,13 +6,13 @@ public class CraftPanda extends CraftAnimals implements Panda { - public CraftPanda(CraftServer server, net.minecraft.world.entity.animal.Panda entity) { + public CraftPanda(CraftServer server, net.minecraft.world.entity.animal.panda.Panda entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Panda getHandle() { - return (net.minecraft.world.entity.animal.Panda) this.entity; + public net.minecraft.world.entity.animal.panda.Panda getHandle() { + return (net.minecraft.world.entity.animal.panda.Panda) this.entity; } @Override @@ -127,15 +127,15 @@ public int getUnhappyTicks() { return this.getHandle().getUnhappyCounter(); } - public static Gene fromNms(net.minecraft.world.entity.animal.Panda.Gene gene) { + public static Gene fromNms(net.minecraft.world.entity.animal.panda.Panda.Gene gene) { Preconditions.checkArgument(gene != null, "Gene may not be null"); return Gene.values()[gene.ordinal()]; } - public static net.minecraft.world.entity.animal.Panda.Gene toNms(Gene gene) { + public static net.minecraft.world.entity.animal.panda.Panda.Gene toNms(Gene gene) { Preconditions.checkArgument(gene != null, "Gene may not be null"); - return net.minecraft.world.entity.animal.Panda.Gene.values()[gene.ordinal()]; + return net.minecraft.world.entity.animal.panda.Panda.Gene.values()[gene.ordinal()]; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java index 6154c4e3c977..ef3cfe465820 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.monster.Parched; +import net.minecraft.world.entity.monster.skeleton.Parched; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Skeleton; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java index 60e1da70c682..b5b5e7f4ef2d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java @@ -6,13 +6,13 @@ public class CraftParrot extends CraftTameableAnimal implements Parrot { - public CraftParrot(CraftServer server, net.minecraft.world.entity.animal.Parrot parrot) { + public CraftParrot(CraftServer server, net.minecraft.world.entity.animal.parrot.Parrot parrot) { super(server, parrot); } @Override - public net.minecraft.world.entity.animal.Parrot getHandle() { - return (net.minecraft.world.entity.animal.Parrot) this.entity; + public net.minecraft.world.entity.animal.parrot.Parrot getHandle() { + return (net.minecraft.world.entity.animal.parrot.Parrot) this.entity; } @Override @@ -24,7 +24,7 @@ public Variant getVariant() { public void setVariant(Variant variant) { Preconditions.checkArgument(variant != null, "variant cannot be null"); - this.getHandle().setVariant(net.minecraft.world.entity.animal.Parrot.Variant.byId(variant.ordinal())); + this.getHandle().setVariant(net.minecraft.world.entity.animal.parrot.Parrot.Variant.byId(variant.ordinal())); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java index 85a5fd1ef890..b127a2b4b36d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java @@ -5,7 +5,7 @@ import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.animal.PigVariant; +import net.minecraft.world.entity.animal.pig.PigVariant; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import org.bukkit.Material; @@ -17,13 +17,13 @@ @NullMarked public class CraftPig extends CraftAnimals implements Pig { - public CraftPig(CraftServer server, net.minecraft.world.entity.animal.Pig entity) { + public CraftPig(CraftServer server, net.minecraft.world.entity.animal.pig.Pig entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Pig getHandle() { - return (net.minecraft.world.entity.animal.Pig) this.entity; + public net.minecraft.world.entity.animal.pig.Pig getHandle() { + return (net.minecraft.world.entity.animal.pig.Pig) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java index c5fcdde22826..7ce42b761b01 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.monster.ZombifiedPiglin; +import net.minecraft.world.entity.monster.zombie.ZombifiedPiglin; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.PigZombie; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java index d927938df4ac..1c416a449e2d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java @@ -5,15 +5,15 @@ import org.bukkit.entity.Pillager; import org.bukkit.inventory.Inventory; -public class CraftPillager extends CraftIllager implements Pillager, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper +public class CraftPillager extends CraftIllager implements Pillager, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper - public CraftPillager(CraftServer server, net.minecraft.world.entity.monster.Pillager entity) { + public CraftPillager(CraftServer server, net.minecraft.world.entity.monster.illager.Pillager entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Pillager getHandle() { - return (net.minecraft.world.entity.monster.Pillager) this.entity; + public net.minecraft.world.entity.monster.illager.Pillager getHandle() { + return (net.minecraft.world.entity.monster.illager.Pillager) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java index 1e3b8eb597f6..eb9eeb616d5d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java @@ -5,13 +5,13 @@ public class CraftPolarBear extends CraftAnimals implements PolarBear { - public CraftPolarBear(CraftServer server, net.minecraft.world.entity.animal.PolarBear entity) { + public CraftPolarBear(CraftServer server, net.minecraft.world.entity.animal.polarbear.PolarBear entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.PolarBear getHandle() { - return (net.minecraft.world.entity.animal.PolarBear) this.entity; + public net.minecraft.world.entity.animal.polarbear.PolarBear getHandle() { + return (net.minecraft.world.entity.animal.polarbear.PolarBear) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java index e63c3bdd1b9f..21b8c89328e1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.animal.Pufferfish; +import net.minecraft.world.entity.animal.fish.Pufferfish; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.PufferFish; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java index 994eb2d881fd..94d2863c5b80 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java @@ -5,13 +5,13 @@ public class CraftRabbit extends CraftAnimals implements Rabbit { - public CraftRabbit(CraftServer server, net.minecraft.world.entity.animal.Rabbit entity) { + public CraftRabbit(CraftServer server, net.minecraft.world.entity.animal.rabbit.Rabbit entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Rabbit getHandle() { - return (net.minecraft.world.entity.animal.Rabbit) this.entity; + public net.minecraft.world.entity.animal.rabbit.Rabbit getHandle() { + return (net.minecraft.world.entity.animal.rabbit.Rabbit) this.entity; } @Override @@ -21,7 +21,7 @@ public Type getRabbitType() { @Override public void setRabbitType(Type type) { - this.getHandle().setVariant(net.minecraft.world.entity.animal.Rabbit.Variant.values()[type.ordinal()]); + this.getHandle().setVariant(net.minecraft.world.entity.animal.rabbit.Rabbit.Variant.values()[type.ordinal()]); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java index 8b2c8924f66f..addf37e28357 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java @@ -6,13 +6,13 @@ public class CraftSalmon extends io.papermc.paper.entity.PaperSchoolableFish implements Salmon { // Paper - Schooling Fish API - public CraftSalmon(CraftServer server, net.minecraft.world.entity.animal.Salmon entity) { + public CraftSalmon(CraftServer server, net.minecraft.world.entity.animal.fish.Salmon entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Salmon getHandle() { - return (net.minecraft.world.entity.animal.Salmon) this.entity; + public net.minecraft.world.entity.animal.fish.Salmon getHandle() { + return (net.minecraft.world.entity.animal.fish.Salmon) this.entity; } @Override @@ -24,6 +24,6 @@ public Variant getVariant() { public void setVariant(Variant variant) { Preconditions.checkArgument(variant != null, "variant cannot be null"); - this.getHandle().setVariant(net.minecraft.world.entity.animal.Salmon.Variant.values()[variant.ordinal()]); + this.getHandle().setVariant(net.minecraft.world.entity.animal.fish.Salmon.Variant.values()[variant.ordinal()]); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java index 579ec5453078..6cab47b6c934 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.projectile.Fireball; +import net.minecraft.world.entity.projectile.hurtingprojectile.Fireball; import org.bukkit.Material; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftItemStack; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java index af73ee0ce87d..1cd0d2738e5e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java @@ -6,13 +6,13 @@ public class CraftSkeleton extends CraftAbstractSkeleton implements Skeleton { - public CraftSkeleton(CraftServer server, net.minecraft.world.entity.monster.Skeleton entity) { + public CraftSkeleton(CraftServer server, net.minecraft.world.entity.monster.skeleton.Skeleton entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Skeleton getHandle() { - return (net.minecraft.world.entity.monster.Skeleton) this.entity; + public net.minecraft.world.entity.monster.skeleton.Skeleton getHandle() { + return (net.minecraft.world.entity.monster.skeleton.Skeleton) this.entity; } @Override @@ -30,7 +30,7 @@ public int getConversionTime() { public void setConversionTime(int time) { if (time < 0) { this.getHandle().conversionTime = -1; - this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.Skeleton.DATA_STRAY_CONVERSION_ID, false); + this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.skeleton.Skeleton.DATA_STRAY_CONVERSION_ID, false); } else { this.getHandle().startFreezeConversion(time); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java index f40729e9cf8c..b1acf372976a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java @@ -6,13 +6,13 @@ public class CraftSkeletonHorse extends CraftAbstractHorse implements SkeletonHorse { - public CraftSkeletonHorse(CraftServer server, net.minecraft.world.entity.animal.horse.SkeletonHorse entity) { + public CraftSkeletonHorse(CraftServer server, net.minecraft.world.entity.animal.equine.SkeletonHorse entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.horse.SkeletonHorse getHandle() { - return (net.minecraft.world.entity.animal.horse.SkeletonHorse) this.entity; + public net.minecraft.world.entity.animal.equine.SkeletonHorse getHandle() { + return (net.minecraft.world.entity.animal.equine.SkeletonHorse) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java index fbd3f86bfd04..05783caadd2d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java @@ -5,12 +5,12 @@ public class CraftSmallFireball extends CraftSizedFireball implements SmallFireball { - public CraftSmallFireball(CraftServer server, net.minecraft.world.entity.projectile.SmallFireball entity) { + public CraftSmallFireball(CraftServer server, net.minecraft.world.entity.projectile.hurtingprojectile.SmallFireball entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.SmallFireball getHandle() { - return (net.minecraft.world.entity.projectile.SmallFireball) this.entity; + public net.minecraft.world.entity.projectile.hurtingprojectile.SmallFireball getHandle() { + return (net.minecraft.world.entity.projectile.hurtingprojectile.SmallFireball) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java index b31f2a939e95..d7b05f5bdbd3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java @@ -5,12 +5,12 @@ public class CraftSnowball extends CraftThrowableProjectile implements Snowball { - public CraftSnowball(CraftServer server, net.minecraft.world.entity.projectile.Snowball entity) { + public CraftSnowball(CraftServer server, net.minecraft.world.entity.projectile.throwableitemprojectile.Snowball entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.Snowball getHandle() { - return (net.minecraft.world.entity.projectile.Snowball) this.entity; + public net.minecraft.world.entity.projectile.throwableitemprojectile.Snowball getHandle() { + return (net.minecraft.world.entity.projectile.throwableitemprojectile.Snowball) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java index f03f9f94c51e..0a912863fe9f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.animal.SnowGolem; +import net.minecraft.world.entity.animal.golem.SnowGolem; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Snowman; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java index 4afd6e013ac7..638fc96ade16 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java @@ -5,13 +5,13 @@ public class CraftSpectralArrow extends CraftAbstractArrow implements SpectralArrow { - public CraftSpectralArrow(CraftServer server, net.minecraft.world.entity.projectile.SpectralArrow entity) { + public CraftSpectralArrow(CraftServer server, net.minecraft.world.entity.projectile.arrow.SpectralArrow entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.SpectralArrow getHandle() { - return (net.minecraft.world.entity.projectile.SpectralArrow) this.entity; + public net.minecraft.world.entity.projectile.arrow.SpectralArrow getHandle() { + return (net.minecraft.world.entity.projectile.arrow.SpectralArrow) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java index b28ef9d0003c..a6bad13a0ef8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.world.entity.monster.SpellcasterIllager; +import net.minecraft.world.entity.monster.illager.SpellcasterIllager; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Spellcaster; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java index 90be754d6aa0..133ef079af63 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java @@ -5,12 +5,12 @@ public class CraftSpider extends CraftMonster implements Spider { - public CraftSpider(CraftServer server, net.minecraft.world.entity.monster.Spider entity) { + public CraftSpider(CraftServer server, net.minecraft.world.entity.monster.spider.Spider entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Spider getHandle() { - return (net.minecraft.world.entity.monster.Spider) this.entity; + public net.minecraft.world.entity.monster.spider.Spider getHandle() { + return (net.minecraft.world.entity.monster.spider.Spider) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java index d1a49aaa259c..4537b8f6b70b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java @@ -5,12 +5,12 @@ public class CraftSquid extends CraftAgeable implements Squid { - public CraftSquid(CraftServer server, net.minecraft.world.entity.animal.Squid entity) { + public CraftSquid(CraftServer server, net.minecraft.world.entity.animal.squid.Squid entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Squid getHandle() { - return (net.minecraft.world.entity.animal.Squid) this.entity; + public net.minecraft.world.entity.animal.squid.Squid getHandle() { + return (net.minecraft.world.entity.animal.squid.Squid) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStray.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStray.java index 397ca2e097a1..80b39f324d1a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStray.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStray.java @@ -6,7 +6,7 @@ public class CraftStray extends CraftAbstractSkeleton implements Stray { - public CraftStray(CraftServer server, net.minecraft.world.entity.monster.Stray entity) { + public CraftStray(CraftServer server, net.minecraft.world.entity.monster.skeleton.Stray entity) { super(server, entity); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java index f34b81ac5a1a..7044d72edb6e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.projectile.ThrowableItemProjectile; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrowableItemProjectile; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.ThrowableProjectile; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java index 9e4b555450d4..325a7ec636bd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.projectile.ThrownExperienceBottle; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownExperienceBottle; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.ThrownExpBottle; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownLingeringPotion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownLingeringPotion.java index 8be9f69889cd..091c27150dbc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownLingeringPotion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownLingeringPotion.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.world.entity.projectile.ThrownLingeringPotion; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownLingeringPotion; import org.bukkit.Material; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftItemStack; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java index 61becdf5c4ad..77a3a2ca5caa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java @@ -4,7 +4,7 @@ import java.util.Collection; import net.minecraft.core.component.DataComponents; import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.entity.projectile.AbstractThrownPotion; +import net.minecraft.world.entity.projectile.throwableitemprojectile.AbstractThrownPotion; import net.minecraft.world.item.alchemy.PotionContents; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftItemStack; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownSplashPotion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownSplashPotion.java index 8e7078878b62..05b962ff4c2c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownSplashPotion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownSplashPotion.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.world.entity.projectile.ThrownSplashPotion; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownSplashPotion; import org.bukkit.Material; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftItemStack; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java index 174332208a0e..4e2acd754b38 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java @@ -5,12 +5,12 @@ public class CraftTraderLlama extends CraftLlama implements TraderLlama { - public CraftTraderLlama(CraftServer server, net.minecraft.world.entity.animal.horse.TraderLlama entity) { + public CraftTraderLlama(CraftServer server, net.minecraft.world.entity.animal.equine.TraderLlama entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.horse.TraderLlama getHandle() { - return (net.minecraft.world.entity.animal.horse.TraderLlama) this.entity; + public net.minecraft.world.entity.animal.equine.TraderLlama getHandle() { + return (net.minecraft.world.entity.animal.equine.TraderLlama) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java index 6d4f7d5164eb..505b8603829e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.projectile.ThrownTrident; +import net.minecraft.world.entity.projectile.arrow.ThrownTrident; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.Trident; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java index 6ec2e173c58f..928caed39022 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java @@ -6,13 +6,13 @@ public class CraftTropicalFish extends io.papermc.paper.entity.PaperSchoolableFish implements TropicalFish { // Paper - Schooling Fish API - public CraftTropicalFish(CraftServer server, net.minecraft.world.entity.animal.TropicalFish entity) { + public CraftTropicalFish(CraftServer server, net.minecraft.world.entity.animal.fish.TropicalFish entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.TropicalFish getHandle() { - return (net.minecraft.world.entity.animal.TropicalFish) this.entity; + public net.minecraft.world.entity.animal.fish.TropicalFish getHandle() { + return (net.minecraft.world.entity.animal.fish.TropicalFish) this.entity; } @Override @@ -46,7 +46,7 @@ public void setPattern(Pattern pattern) { } public static int getData(DyeColor patternColor, DyeColor bodyColor, Pattern type) { - net.minecraft.world.entity.animal.TropicalFish.Pattern pattern = net.minecraft.world.entity.animal.TropicalFish.Pattern.valueOf(type.name()); + net.minecraft.world.entity.animal.fish.TropicalFish.Pattern pattern = net.minecraft.world.entity.animal.fish.TropicalFish.Pattern.valueOf(type.name()); return patternColor.getWoolData() << 24 | bodyColor.getWoolData() << 16 | pattern.getPackedId(); } @@ -59,6 +59,6 @@ public static DyeColor getBodyColor(int data) { } public static Pattern getPattern(int data) { - return Pattern.valueOf(net.minecraft.world.entity.animal.TropicalFish.getPattern(data).name()); + return Pattern.valueOf(net.minecraft.world.entity.animal.fish.TropicalFish.getPattern(data).name()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java index 3aae36e3bd03..5d8dd7a9ec44 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java @@ -6,13 +6,13 @@ public class CraftTurtle extends CraftAnimals implements Turtle { - public CraftTurtle(CraftServer server, net.minecraft.world.entity.animal.Turtle entity) { + public CraftTurtle(CraftServer server, net.minecraft.world.entity.animal.turtle.Turtle entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Turtle getHandle() { - return (net.minecraft.world.entity.animal.Turtle) this.entity; + public net.minecraft.world.entity.animal.turtle.Turtle getHandle() { + return (net.minecraft.world.entity.animal.turtle.Turtle) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index 290f101be698..22704813d84f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -9,9 +9,9 @@ import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.monster.Zombie; -import net.minecraft.world.entity.npc.VillagerProfession; -import net.minecraft.world.entity.npc.VillagerType; +import net.minecraft.world.entity.monster.zombie.Zombie; +import net.minecraft.world.entity.npc.villager.VillagerProfession; +import net.minecraft.world.entity.npc.villager.VillagerType; import net.minecraft.world.level.block.BedBlock; import net.minecraft.world.level.block.state.BlockState; import org.bukkit.Location; @@ -25,13 +25,13 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { - public CraftVillager(CraftServer server, net.minecraft.world.entity.npc.Villager entity) { + public CraftVillager(CraftServer server, net.minecraft.world.entity.npc.villager.Villager entity) { super(server, entity); } @Override - public net.minecraft.world.entity.npc.Villager getHandle() { - return (net.minecraft.world.entity.npc.Villager) this.entity; + public net.minecraft.world.entity.npc.villager.Villager getHandle() { + return (net.minecraft.world.entity.npc.villager.Villager) this.entity; } @Override @@ -92,11 +92,11 @@ public void setVillagerExperience(int experience) { public boolean increaseLevel(int amount) { Preconditions.checkArgument(amount > 0, "Level earned must be positive"); int supposedFinalLevel = this.getVillagerLevel() + amount; - Preconditions.checkArgument(net.minecraft.world.entity.npc.VillagerData.MIN_VILLAGER_LEVEL <= supposedFinalLevel && supposedFinalLevel <= net.minecraft.world.entity.npc.VillagerData.MAX_VILLAGER_LEVEL, - "Final level reached after the donation (%d) must be between [%d, %d]".formatted(supposedFinalLevel, net.minecraft.world.entity.npc.VillagerData.MIN_VILLAGER_LEVEL, net.minecraft.world.entity.npc.VillagerData.MAX_VILLAGER_LEVEL)); + Preconditions.checkArgument(net.minecraft.world.entity.npc.villager.VillagerData.MIN_VILLAGER_LEVEL <= supposedFinalLevel && supposedFinalLevel <= net.minecraft.world.entity.npc.villager.VillagerData.MAX_VILLAGER_LEVEL, + "Final level reached after the donation (%d) must be between [%d, %d]".formatted(supposedFinalLevel, net.minecraft.world.entity.npc.villager.VillagerData.MIN_VILLAGER_LEVEL, net.minecraft.world.entity.npc.villager.VillagerData.MAX_VILLAGER_LEVEL)); - it.unimi.dsi.fastutil.ints.Int2ObjectMap trades = - net.minecraft.world.entity.npc.VillagerTrades.TRADES.get((this.getHandle().getVillagerData().profession().unwrapKey().orElseThrow())); + it.unimi.dsi.fastutil.ints.Int2ObjectMap trades = + net.minecraft.world.entity.npc.villager.VillagerTrades.TRADES.get((this.getHandle().getVillagerData().profession().unwrapKey().orElseThrow())); if (trades == null || trades.isEmpty()) { this.getHandle().setVillagerData(this.getHandle().getVillagerData().withLevel(supposedFinalLevel)); @@ -159,7 +159,7 @@ public void shakeHead() { @Override public ZombieVillager zombify() { - net.minecraft.world.entity.monster.ZombieVillager entityzombievillager = Zombie.convertVillagerToZombieVillager(this.getHandle().level().getMinecraftWorld(), this.getHandle(), this.getHandle().blockPosition(), this.isSilent(), EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.CUSTOM); + net.minecraft.world.entity.monster.zombie.ZombieVillager entityzombievillager = Zombie.convertVillagerToZombieVillager(this.getHandle().level().getMinecraftWorld(), this.getHandle(), this.getHandle().blockPosition(), this.isSilent(), EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.CUSTOM); return (entityzombievillager != null) ? (ZombieVillager) entityzombievillager.getBukkitEntity() : null; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java index c09a3e065bbb..745f5e77e5a7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -10,13 +10,13 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { - public CraftVillagerZombie(CraftServer server, net.minecraft.world.entity.monster.ZombieVillager entity) { + public CraftVillagerZombie(CraftServer server, net.minecraft.world.entity.monster.zombie.ZombieVillager entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.ZombieVillager getHandle() { - return (net.minecraft.world.entity.monster.ZombieVillager) this.entity; + public net.minecraft.world.entity.monster.zombie.ZombieVillager getHandle() { + return (net.minecraft.world.entity.monster.zombie.ZombieVillager) this.entity; } @Override @@ -64,7 +64,7 @@ public void setConversionTime(int time, boolean broadcastEntityEvent) { // Paper end - missing entity behaviour api - converting without entity event if (time < 0) { this.getHandle().villagerConversionTime = -1; - this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.ZombieVillager.DATA_CONVERTING_ID, false); + this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.zombie.ZombieVillager.DATA_CONVERTING_ID, false); this.getHandle().conversionStarter = null; this.getHandle().removeEffect(MobEffects.STRENGTH, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); } else { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java index 4207a1cd7572..e670779ecbfe 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java @@ -5,13 +5,13 @@ public class CraftVindicator extends CraftIllager implements Vindicator { - public CraftVindicator(CraftServer server, net.minecraft.world.entity.monster.Vindicator entity) { + public CraftVindicator(CraftServer server, net.minecraft.world.entity.monster.illager.Vindicator entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Vindicator getHandle() { - return (net.minecraft.world.entity.monster.Vindicator) this.entity; + public net.minecraft.world.entity.monster.illager.Vindicator getHandle() { + return (net.minecraft.world.entity.monster.illager.Vindicator) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java index e698cbf4f1e7..60d158ddb6e4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java @@ -6,13 +6,13 @@ public class CraftWanderingTrader extends CraftAbstractVillager implements WanderingTrader { - public CraftWanderingTrader(CraftServer server, net.minecraft.world.entity.npc.WanderingTrader entity) { + public CraftWanderingTrader(CraftServer server, net.minecraft.world.entity.npc.wanderingtrader.WanderingTrader entity) { super(server, entity); } @Override - public net.minecraft.world.entity.npc.WanderingTrader getHandle() { - return (net.minecraft.world.entity.npc.WanderingTrader) this.entity; + public net.minecraft.world.entity.npc.wanderingtrader.WanderingTrader getHandle() { + return (net.minecraft.world.entity.npc.wanderingtrader.WanderingTrader) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java index be249743cb53..fc84fdd157af 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.animal.WaterAnimal; +import net.minecraft.world.entity.animal.fish.WaterAnimal; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.WaterMob; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWindCharge.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWindCharge.java index bb3301ff6a93..394ba22015df 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWindCharge.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWindCharge.java @@ -5,12 +5,12 @@ public class CraftWindCharge extends CraftAbstractWindCharge implements WindCharge { - public CraftWindCharge(CraftServer server, net.minecraft.world.entity.projectile.windcharge.WindCharge entity) { + public CraftWindCharge(CraftServer server, net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.WindCharge entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.windcharge.WindCharge getHandle() { - return (net.minecraft.world.entity.projectile.windcharge.WindCharge) this.entity; + public net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.WindCharge getHandle() { + return (net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.WindCharge) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkeleton.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkeleton.java index 79eee42227ea..e05cc9c0628b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkeleton.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkeleton.java @@ -6,7 +6,7 @@ public class CraftWitherSkeleton extends CraftAbstractSkeleton implements WitherSkeleton { - public CraftWitherSkeleton(CraftServer server, net.minecraft.world.entity.monster.WitherSkeleton entity) { + public CraftWitherSkeleton(CraftServer server, net.minecraft.world.entity.monster.skeleton.WitherSkeleton entity) { super(server, entity); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java index 027849368189..7ed4524d4220 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java @@ -5,13 +5,13 @@ public class CraftWitherSkull extends CraftFireball implements WitherSkull { - public CraftWitherSkull(CraftServer server, net.minecraft.world.entity.projectile.WitherSkull entity) { + public CraftWitherSkull(CraftServer server, net.minecraft.world.entity.projectile.hurtingprojectile.WitherSkull entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.WitherSkull getHandle() { - return (net.minecraft.world.entity.projectile.WitherSkull) this.entity; + public net.minecraft.world.entity.projectile.hurtingprojectile.WitherSkull getHandle() { + return (net.minecraft.world.entity.projectile.hurtingprojectile.WitherSkull) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java index 9851c3890c93..58f0b6987122 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java @@ -1,20 +1,20 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.world.entity.monster.ZombieVillager; +import net.minecraft.world.entity.monster.zombie.ZombieVillager; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Villager; import org.bukkit.entity.Zombie; public class CraftZombie extends CraftMonster implements Zombie { - public CraftZombie(CraftServer server, net.minecraft.world.entity.monster.Zombie entity) { + public CraftZombie(CraftServer server, net.minecraft.world.entity.monster.zombie.Zombie entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Zombie getHandle() { - return (net.minecraft.world.entity.monster.Zombie) this.entity; + public net.minecraft.world.entity.monster.zombie.Zombie getHandle() { + return (net.minecraft.world.entity.monster.zombie.Zombie) this.entity; } @Override @@ -63,7 +63,7 @@ public int getConversionTime() { public void setConversionTime(int time) { if (time < 0) { this.getHandle().conversionTime = -1; - this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.Zombie.DATA_DROWNED_CONVERSION_ID, false); + this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.zombie.Zombie.DATA_DROWNED_CONVERSION_ID, false); } else { this.getHandle().startUnderWaterConversion(time); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieHorse.java index 1b3b52a54339..549fb4ec9eba 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieHorse.java @@ -6,7 +6,7 @@ public class CraftZombieHorse extends CraftAbstractHorse implements ZombieHorse { - public CraftZombieHorse(CraftServer server, net.minecraft.world.entity.animal.horse.ZombieHorse entity) { + public CraftZombieHorse(CraftServer server, net.minecraft.world.entity.animal.equine.ZombieHorse entity) { super(server, entity); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java index 0cf3b0c7a88c..6ad86ba7abac 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java @@ -4,7 +4,7 @@ import io.papermc.paper.registry.HolderableBase; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.world.entity.animal.ZombieNautilusVariant; +import net.minecraft.world.entity.animal.nautilus.ZombieNautilusVariant; import net.minecraft.world.entity.animal.nautilus.ZombieNautilus; import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftServer; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaBoat.java index 0ffa2e8e054f..5ffa0cb44a69 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.AcaciaBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaChestBoat.java index 29bb5460b3a8..0eb78998950e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.AcaciaChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooChestRaft.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooChestRaft.java index eea576358532..20a32fb30e03 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooChestRaft.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooChestRaft.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.BambooChestRaft; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooRaft.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooRaft.java index 05952dd62c21..de041ab79e85 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooRaft.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooRaft.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.BambooRaft; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchBoat.java index 1d629bf9df9a..6d71b6d16ada 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.BirchBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchChestBoat.java index 24734c47a71e..91221cae40de 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.BirchChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryBoat.java index 3f55982cc5d5..08989c870d0c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.CherryBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryChestBoat.java index a983236cab83..a4fe6736abda 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.CherryChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakBoat.java index 06c64e922040..fad036eb8454 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.DarkOakBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakChestBoat.java index f49955cfea72..14e7e6fce308 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.DarkOakChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleBoat.java index 400bfe452321..0fd049f60206 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.JungleBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleChestBoat.java index e8d6cd4c96d0..86e106945235 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.JungleChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveBoat.java index c1f0c3e55811..ca184c73053b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.MangroveBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveChestBoat.java index 97eb913be028..95978027fe8c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.MangroveChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakBoat.java index 7e3e8f5fda0a..98fb6c02c7bd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.OakBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakChestBoat.java index 7beb16449195..b7d78ee954ef 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.OakChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakBoat.java index e6d65858edd8..88f82dd5d822 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.PaleOakBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakChestBoat.java index bcc91c8319f5..eef9cada0367 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.PaleOakChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceBoat.java index 92eb7ea21174..8cff0a245483 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.SpruceBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceChestBoat.java index 64cc4dc33aa5..a01ac047c83c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.SpruceChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index e0f3ba43f90e..6a3e0da1f602 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -41,15 +41,15 @@ import net.minecraft.world.entity.Leashable; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.PathfinderMob; -import net.minecraft.world.entity.animal.AbstractFish; -import net.minecraft.world.entity.animal.AbstractGolem; +import net.minecraft.world.entity.animal.fish.AbstractFish; +import net.minecraft.world.entity.animal.golem.AbstractGolem; import net.minecraft.world.entity.animal.Animal; -import net.minecraft.world.entity.animal.WaterAnimal; +import net.minecraft.world.entity.animal.fish.WaterAnimal; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.monster.Ghast; import net.minecraft.world.entity.monster.Monster; import net.minecraft.world.entity.monster.Slime; -import net.minecraft.world.entity.monster.SpellcasterIllager; +import net.minecraft.world.entity.monster.illager.SpellcasterIllager; import net.minecraft.world.entity.projectile.FireworkRocketEntity; import net.minecraft.world.entity.raid.Raid; import net.minecraft.world.inventory.AbstractContainerMenu; @@ -589,7 +589,7 @@ public static EntityShootBowEvent callEntityShootBowEvent(net.minecraft.world.en return event; } - public static VillagerCareerChangeEvent callVillagerCareerChangeEvent(net.minecraft.world.entity.npc.Villager villager, Profession future, VillagerCareerChangeEvent.ChangeReason reason) { + public static VillagerCareerChangeEvent callVillagerCareerChangeEvent(net.minecraft.world.entity.npc.villager.Villager villager, Profession future, VillagerCareerChangeEvent.ChangeReason reason) { VillagerCareerChangeEvent event = new VillagerCareerChangeEvent((Villager) villager.getBukkitEntity(), future, reason); Bukkit.getPluginManager().callEvent(event); @@ -748,7 +748,7 @@ public static boolean callItemMergeEvent(ItemEntity merging, ItemEntity mergingW return !event.isCancelled(); } - public static PotionSplashEvent callPotionSplashEvent(net.minecraft.world.entity.projectile.ThrownSplashPotion potion, @Nullable HitResult position, Map affectedEntities) { // Paper - nullable hitResult + public static PotionSplashEvent callPotionSplashEvent(net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownSplashPotion potion, @Nullable HitResult position, Map affectedEntities) { // Paper - nullable hitResult ThrownPotion thrownPotion = (ThrownPotion) potion.getBukkitEntity(); Block hitBlock = null; @@ -769,7 +769,7 @@ public static PotionSplashEvent callPotionSplashEvent(net.minecraft.world.entity return event; } - public static LingeringPotionSplashEvent callLingeringPotionSplashEvent(net.minecraft.world.entity.projectile.ThrownLingeringPotion potion, @Nullable HitResult position, net.minecraft.world.entity.AreaEffectCloud cloud) { // Paper - nullable hitResult + public static LingeringPotionSplashEvent callLingeringPotionSplashEvent(net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownLingeringPotion potion, @Nullable HitResult position, net.minecraft.world.entity.AreaEffectCloud cloud) { // Paper - nullable hitResult ThrownPotion thrownPotion = (ThrownPotion) potion.getBukkitEntity(); AreaEffectCloud effectCloud = (AreaEffectCloud) cloud.getBukkitEntity(); @@ -792,7 +792,7 @@ public static LingeringPotionSplashEvent callLingeringPotionSplashEvent(net.mine } // Paper start - Fix potions splash events - public static io.papermc.paper.event.entity.WaterBottleSplashEvent callWaterBottleSplashEvent(net.minecraft.world.entity.projectile.AbstractThrownPotion potion, @Nullable HitResult hitResult, Map affectedEntities, java.util.Set rehydrate, java.util.Set extinguish) { + public static io.papermc.paper.event.entity.WaterBottleSplashEvent callWaterBottleSplashEvent(net.minecraft.world.entity.projectile.throwableitemprojectile.AbstractThrownPotion potion, @Nullable HitResult hitResult, Map affectedEntities, java.util.Set rehydrate, java.util.Set extinguish) { ThrownPotion thrownPotion = (ThrownPotion) potion.getBukkitEntity(); Block hitBlock = null; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java index 75fa6f99c939..71c14b8c4d46 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java @@ -84,7 +84,7 @@ public MerchantOffers getOffers() { // Paper start - Add PlayerTradeEvent and PlayerPurchaseEvent @Override public void processTrade(MerchantOffer offer, @javax.annotation.Nullable io.papermc.paper.event.player.PlayerPurchaseEvent event) { // The MerchantRecipe passed in here is the one set by the PlayerPurchaseEvent - /* Based on {@link net.minecraft.world.entity.npc.AbstractVillager#processTrade(MerchantOffer, io.papermc.paper.event.player.PlayerPurchaseEvent)} */ + /* Based on {@link net.minecraft.world.entity.npc.villager.AbstractVillager#processTrade(MerchantOffer, io.papermc.paper.event.player.PlayerPurchaseEvent)} */ if (getTradingPlayer() instanceof net.minecraft.server.level.ServerPlayer) { if (event == null || event.willIncreaseTradeUses()) { offer.increaseUses(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftMenus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftMenus.java index 96dda6e0baa5..7a33cabd19c7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftMenus.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftMenus.java @@ -2,7 +2,7 @@ import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.npc.Villager; +import net.minecraft.world.entity.npc.villager.Villager; import net.minecraft.world.inventory.MerchantMenu; import net.minecraft.world.item.trading.Merchant; import net.minecraft.world.item.trading.MerchantOffers; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/view/builder/CraftMerchantInventoryViewBuilder.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/view/builder/CraftMerchantInventoryViewBuilder.java index d46f942e1c41..c32be77880c6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/view/builder/CraftMerchantInventoryViewBuilder.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/view/builder/CraftMerchantInventoryViewBuilder.java @@ -4,7 +4,7 @@ import io.papermc.paper.adventure.PaperAdventure; import net.kyori.adventure.text.Component; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.npc.AbstractVillager; +import net.minecraft.world.entity.npc.villager.AbstractVillager; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.MenuType; import net.minecraft.world.inventory.MerchantMenu; diff --git a/paper-server/src/main/java/org/spigotmc/TrackingRange.java b/paper-server/src/main/java/org/spigotmc/TrackingRange.java index 7222b2dc97e5..c4384fd7ca7d 100644 --- a/paper-server/src/main/java/org/spigotmc/TrackingRange.java +++ b/paper-server/src/main/java/org/spigotmc/TrackingRange.java @@ -6,7 +6,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.ExperienceOrb; import net.minecraft.world.entity.decoration.ItemFrame; -import net.minecraft.world.entity.decoration.Painting; +import net.minecraft.world.entity.decoration.painting.Painting; import net.minecraft.world.entity.item.ItemEntity; public final class TrackingRange { diff --git a/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java b/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java index ffec21232a87..00b949fc0982 100644 --- a/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java +++ b/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java @@ -13,17 +13,17 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.entity.animal.CatVariant; -import net.minecraft.world.entity.animal.ChickenVariant; -import net.minecraft.world.entity.animal.CowVariant; -import net.minecraft.world.entity.animal.PigVariant; -import net.minecraft.world.entity.animal.ZombieNautilusVariant; +import net.minecraft.world.entity.animal.feline.CatVariant; +import net.minecraft.world.entity.animal.chicken.ChickenVariant; +import net.minecraft.world.entity.animal.cow.CowVariant; +import net.minecraft.world.entity.animal.pig.PigVariant; +import net.minecraft.world.entity.animal.nautilus.ZombieNautilusVariant; import net.minecraft.world.entity.animal.frog.FrogVariant; import net.minecraft.world.entity.animal.wolf.WolfSoundVariant; import net.minecraft.world.entity.animal.wolf.WolfVariant; -import net.minecraft.world.entity.decoration.PaintingVariant; -import net.minecraft.world.entity.npc.VillagerProfession; -import net.minecraft.world.entity.npc.VillagerType; +import net.minecraft.world.entity.decoration.painting.PaintingVariant; +import net.minecraft.world.entity.npc.villager.VillagerProfession; +import net.minecraft.world.entity.npc.villager.VillagerType; import net.minecraft.world.item.Instrument; import net.minecraft.world.level.block.entity.BannerPattern; import net.minecraft.world.level.saveddata.maps.MapDecorationType; From 6844f9c6be150f67feab5b6179f6bfbdd3aa922c Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 20 Nov 2025 10:58:21 -0700 Subject: [PATCH 089/112] Fix some compile errors --- .../server/network/ServerGamePacketListenerImpl.java.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 9d9a2c7643a5..607d72744841 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -176,7 +176,7 @@ + this.cserver.getPluginManager().callEvent(event); + + // Technically the player input and the flag is desynced, but this is previous behavior.. so should be fine? -+ if (!event.isCancelled() && this.player.hasClientLoaded()) { ++ if (!event.isCancelled() && this.hasClientLoaded()) { + // Only set the shift key status if the shift input has changed and the event has not been cancelled + this.player.setShiftKeyDown(packet.input().shift()); + } @@ -386,7 +386,7 @@ public void handleAcceptPlayerLoad(ServerboundPlayerLoadedPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); + // Paper start - PlayerLoadedWorldEvent -+ if (this.player.hasClientLoaded()) { ++ if (this.hasClientLoaded()) { + return; + } + final io.papermc.paper.event.player.PlayerClientLoadedWorldEvent event = new io.papermc.paper.event.player.PlayerClientLoadedWorldEvent(this.player.getBukkitEntity(), false); @@ -1164,7 +1164,7 @@ case ABORT_DESTROY_BLOCK: case STOP_DESTROY_BLOCK: + // Paper start - Don't allow digging into unloaded chunks -+ if (this.player.level().getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4) == null || !this.player.canInteractWithBlock(pos, 1.0)) { ++ if (this.player.level().getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4) == null || !this.player.isWithinBlockInteractionRange(pos, 1.0)) { + this.player.connection.ackBlockChangesUpTo(packet.getSequence()); + return; + } From e76f08bb944e26b35ffee77cf0c41e3d0b191f14 Mon Sep 17 00:00:00 2001 From: Pedro <3602279+Doc94@users.noreply.github.com> Date: Thu, 20 Nov 2025 22:21:19 -0300 Subject: [PATCH 090/112] DataComponent Changes for 1.21.11-pre1 (#13327) --- .../paper/datacomponent/item/AttackRange.java | 59 +++++++++++++ .../item/ItemComponentTypesBridge.java | 2 + .../datacomponent/item/KineticWeapon.java | 18 ---- .../datacomponent/item/PiercingWeapon.java | 15 ---- .../datacomponent/DataComponentAdapters.java | 2 + .../item/ItemComponentTypesBridgesImpl.java | 5 ++ .../datacomponent/item/PaperAttackRange.java | 82 +++++++++++++++++++ .../item/PaperKineticWeapon.java | 42 ---------- .../item/PaperPiercingWeapon.java | 44 ---------- 9 files changed, 150 insertions(+), 119 deletions(-) create mode 100644 paper-api/src/main/java/io/papermc/paper/datacomponent/item/AttackRange.java create mode 100644 paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperAttackRange.java diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/AttackRange.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/AttackRange.java new file mode 100644 index 000000000000..4e405d83573f --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/AttackRange.java @@ -0,0 +1,59 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.datacomponent.DataComponentBuilder; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Range; +import org.jspecify.annotations.NullMarked; + +@NullMarked +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface AttackRange { + + /** + * Returns a new builder for creating an Attack Range. + * + * @return a builder instance + */ + @Contract(value = "-> new", pure = true) + static Builder attackRange() { + return ItemComponentTypesBridge.bridge().attackRange(); + } + + @Contract(pure = true) + @Range(from = 0, to = 64) + float minReach(); + + @Contract(pure = true) + @Range(from = 0, to = 64) + float maxReach(); + + @Contract(pure = true) + @Range(from = 0, to = 1) + float hitboxMargin(); + + @Contract(pure = true) + @Range(from = 0, to = 2) + float mobFactor(); + + /** + * Builder for {@link AttackRange}. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends DataComponentBuilder { + + @Contract(value = "_ -> this", mutates = "this") + Builder minReach(@Range(from = 0, to = 64) float minReach); + + @Contract(value = "_ -> this", mutates = "this") + Builder maxReach(@Range(from = 0, to = 64) float maxReach); + + @Contract(value = "_ -> this", mutates = "this") + Builder hitboxMargin(@Range(from = 0, to = 1) float hitboxMargin); + + @Contract(value = "_ -> this", mutates = "this") + Builder mobFactor(@Range(from = 0, to = 2) float mobFactor); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java index bf00003d10a2..9a35d98bc101 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java @@ -124,6 +124,8 @@ static ItemComponentTypesBridge bridge() { PiercingWeapon.Builder piercingWeapon(); + AttackRange.Builder attackRange(); + SwingAnimation.Builder swingAnimation(); KineticWeapon.Condition kineticWeaponCondition(int maxDurationTicks, float minSpeed, float minRelativeSpeed); diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java index 14947936288a..0be65fcca9fc 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java @@ -32,15 +32,6 @@ static Condition condition(final @NonNegative int maxDurationTicks, final float return ItemComponentTypesBridge.bridge().kineticWeaponCondition(maxDurationTicks, minSpeed, minRelativeSpeed); } - @Contract(pure = true) - @Range(from = 0, to = 128) float minReach(); - - @Contract(pure = true) - @Range(from = 0, to = 128) float maxReach(); - - @Contract(pure = true) - @Range(from = 0, to = 1) float hitboxMargin(); - @Contract(pure = true) @NonNegative int contactCooldownTicks(); @@ -85,15 +76,6 @@ interface Condition { @ApiStatus.NonExtendable interface Builder extends DataComponentBuilder { - @Contract(value = "_ -> this", mutates = "this") - Builder minReach(@Range(from = 0, to = 128) float minReach); - - @Contract(value = "_ -> this", mutates = "this") - Builder maxReach(@Range(from = 0, to = 128) float maxReach); - - @Contract(value = "_ -> this", mutates = "this") - Builder hitboxMargin(@Range(from = 0, to = 1) float hitboxMargin); - @Contract(value = "_ -> this", mutates = "this") Builder contactCooldownTicks(@NonNegative int ticks); diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java index 5338b772ed80..342151af60bc 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java @@ -22,12 +22,6 @@ static Builder piercingWeapon() { return ItemComponentTypesBridge.bridge().piercingWeapon(); } - @Range(from = 0, to = 128) float minReach(); - - @Range(from = 0, to = 128) float maxReach(); - - @Range(from = 0, to = 1) float hitboxMargin(); - boolean dealsKnockback(); boolean dismounts(); @@ -43,15 +37,6 @@ static Builder piercingWeapon() { @ApiStatus.NonExtendable interface Builder extends DataComponentBuilder { - @Contract(value = "_ -> this", mutates = "this") - Builder minReach(@Range(from = 0, to = 128) float minReach); - - @Contract(value = "_ -> this", mutates = "this") - Builder maxReach(@Range(from = 0, to = 128) float maxReach); - - @Contract(value = "_ -> this", mutates = "this") - Builder hitboxMargin(@Range(from = 0, to = 1) float hitboxMargin); - @Contract(value = "_ -> this", mutates = "this") Builder dealsKnockback(boolean dealsKnockback); diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java index 0310b7c8ed5a..f6783d5f9279 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java @@ -1,6 +1,7 @@ package io.papermc.paper.datacomponent; import io.papermc.paper.adventure.PaperAdventure; +import io.papermc.paper.datacomponent.item.PaperAttackRange; import io.papermc.paper.datacomponent.item.PaperBannerPatternLayers; import io.papermc.paper.datacomponent.item.PaperBlockItemDataProperties; import io.papermc.paper.datacomponent.item.PaperBlocksAttacks; @@ -180,6 +181,7 @@ public static void bootstrap() { register(DataComponents.BLOCKS_ATTACKS, PaperBlocksAttacks::new); register(DataComponents.PIERCING_WEAPON, PaperPiercingWeapon::new); register(DataComponents.KINETIC_WEAPON, PaperKineticWeapon::new); + register(DataComponents.ATTACK_RANGE, PaperAttackRange::new); register(DataComponents.SWING_ANIMATION, PaperSwingAnimation::new); register(DataComponents.VILLAGER_VARIANT, CraftVillager.CraftType::minecraftHolderToBukkit, CraftVillager.CraftType::bukkitToMinecraftHolder); register(DataComponents.WOLF_VARIANT, CraftWolf.CraftVariant::minecraftHolderToBukkit, CraftWolf.CraftVariant::bukkitToMinecraftHolder); diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java index 266296263849..f8ba50404d24 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java @@ -272,6 +272,11 @@ public PiercingWeapon.Builder piercingWeapon() { return new PaperPiercingWeapon.BuilderImpl(); } + @Override + public AttackRange.Builder attackRange() { + return new PaperAttackRange.BuilderImpl(); + } + @Override public SwingAnimation.Builder swingAnimation() { return new PaperSwingAnimation.BuilderImpl(); diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperAttackRange.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperAttackRange.java new file mode 100644 index 000000000000..6ff60151b548 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperAttackRange.java @@ -0,0 +1,82 @@ +package io.papermc.paper.datacomponent.item; + +import com.google.common.base.Preconditions; +import org.bukkit.craftbukkit.util.Handleable; + +public record PaperAttackRange( + net.minecraft.world.item.component.AttackRange impl +) implements AttackRange, Handleable { + + @Override + public net.minecraft.world.item.component.AttackRange getHandle() { + return this.impl; + } + + @Override + public float minReach() { + return this.impl.minRange(); + } + + @Override + public float maxReach() { + return this.impl.maxRange(); + } + + @Override + public float hitboxMargin() { + return this.impl.hitboxMargin(); + } + + @Override + public float mobFactor() { + return this.impl.mobFactor(); + } + + static final class BuilderImpl implements AttackRange.Builder { + + private float minReach = net.minecraft.world.item.component.AttackRange.DEFAULT.minRange(); + private float maxReach = net.minecraft.world.item.component.AttackRange.DEFAULT.maxRange(); + private float hitboxMargin = net.minecraft.world.item.component.AttackRange.DEFAULT.hitboxMargin(); + private float mobFactor = net.minecraft.world.item.component.AttackRange.DEFAULT.mobFactor(); + + @Override + public AttackRange.Builder minReach(final float minReach) { + Preconditions.checkArgument(minReach >= 0.0F && minReach <= 64.0F, "minReach must be in range [0,64] was %s", minReach); + this.minReach = minReach; + return this; + } + + @Override + public AttackRange.Builder maxReach(final float maxReach) { + Preconditions.checkArgument(maxReach >= 0.0F && maxReach <= 64.0F, "maxReach must be in range [0,64] was %s", maxReach); + this.maxReach = maxReach; + return this; + } + + @Override + public AttackRange.Builder hitboxMargin(final float hitboxMargin) { + Preconditions.checkArgument(hitboxMargin >= 0.0F && hitboxMargin <= 1.0F, "hitboxMargin must be in range [0,1] was %s", hitboxMargin); + this.hitboxMargin = hitboxMargin; + return this; + } + + @Override + public AttackRange.Builder mobFactor(final float mobFactor) { + Preconditions.checkArgument(mobFactor >= 0.0F && mobFactor <= 2.0F, "mobFactor must be in range [0,2] was %s", mobFactor); + this.mobFactor = mobFactor; + return this; + } + + @Override + public AttackRange build() { + return new PaperAttackRange( + new net.minecraft.world.item.component.AttackRange( + this.minReach, + this.maxReach, + this.hitboxMargin, + this.mobFactor + ) + ); + } + } +} diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java index 638fc39bb887..acbe7842cffa 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java @@ -28,21 +28,6 @@ public net.minecraft.world.item.component.KineticWeapon getHandle() { return this.impl; } - @Override - public float minReach() { - return this.impl.minReach(); - } - - @Override - public float maxReach() { - return this.impl.maxReach(); - } - - @Override - public float hitboxMargin() { - return this.impl.hitboxMargin(); - } - @Override public int contactCooldownTicks() { return this.impl.contactCooldownTicks(); @@ -126,9 +111,6 @@ public float minRelativeSpeed() { static final class BuilderImpl implements KineticWeapon.Builder { - private float minReach = 0.0F; - private float maxReach = 3.0F; - private float hitboxMargin = 0.3F; private int contactCooldownTicks = 10; private int delayTicks = 0; @@ -142,27 +124,6 @@ static final class BuilderImpl implements KineticWeapon.Builder { private float damageMultiplier = 1; private float forwardMovement = 0.0F; - @Override - public KineticWeapon.Builder minReach(final float minReach) { - Preconditions.checkArgument(minReach >= 0.0F && minReach <= 128.0F, "minReach must be in range [0,128] was %s", minReach); - this.minReach = minReach; - return this; - } - - @Override - public KineticWeapon.Builder maxReach(final float maxReach) { - Preconditions.checkArgument(maxReach >= 0.0F && maxReach <= 128.0F, "maxReach must be in range [0,128] was %s", maxReach); - this.maxReach = maxReach; - return this; - } - - @Override - public KineticWeapon.Builder hitboxMargin(final float hitboxMargin) { - Preconditions.checkArgument(hitboxMargin >= 0.0F && hitboxMargin <= 1.0F, "hitboxMargin must be in range [0,1] was %s", hitboxMargin); - this.hitboxMargin = hitboxMargin; - return this; - } - @Override public KineticWeapon.Builder contactCooldownTicks(final int ticks) { Preconditions.checkArgument(ticks >= 0, "contactCooldownTicks must be non-negative"); @@ -223,9 +184,6 @@ public KineticWeapon.Builder hitSound(final @Nullable Key sound) { public KineticWeapon build() { return new PaperKineticWeapon( new net.minecraft.world.item.component.KineticWeapon( - this.minReach, - this.maxReach, - this.hitboxMargin, this.contactCooldownTicks, this.delayTicks, Optional.ofNullable(this.dismountConditions), diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java index 084b394e1417..7843e88b2c5a 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java @@ -1,6 +1,5 @@ package io.papermc.paper.datacomponent.item; -import com.google.common.base.Preconditions; import io.papermc.paper.adventure.PaperAdventure; import java.util.Optional; import net.kyori.adventure.key.Key; @@ -18,21 +17,6 @@ public net.minecraft.world.item.component.PiercingWeapon getHandle() { return this.impl; } - @Override - public float minReach() { - return this.impl.minReach(); - } - - @Override - public float maxReach() { - return this.impl.maxReach(); - } - - @Override - public float hitboxMargin() { - return this.impl.hitboxMargin(); - } - @Override public boolean dealsKnockback() { return this.impl.dealsKnockback(); @@ -63,37 +47,12 @@ public boolean dismounts() { static final class BuilderImpl implements PiercingWeapon.Builder { - private float minReach = 0.0F; - private float maxReach = 3.0F; - private float hitboxMargin = 0.3F; - private boolean dealsKnockback = true; private boolean dismounts = false; private @Nullable Key sound = null; private @Nullable Key hitSound = null; - @Override - public PiercingWeapon.Builder minReach(final float minReach) { - Preconditions.checkArgument(minReach >= 0.0F && minReach <= 128.0F, "minReach must be in range [0,128] was %s", minReach); - this.minReach = minReach; - return this; - } - - @Override - public PiercingWeapon.Builder maxReach(final float maxReach) { - Preconditions.checkArgument(maxReach >= 0.0F && maxReach <= 128.0F, "maxReach must be in range [0,128] was %s", maxReach); - this.maxReach = maxReach; - return this; - } - - @Override - public PiercingWeapon.Builder hitboxMargin(final float hitboxMargin) { - Preconditions.checkArgument(hitboxMargin >= 0.0F && hitboxMargin <= 1.0F, "hitboxMargin must be in range [0,1] was %s", hitboxMargin); - this.hitboxMargin = hitboxMargin; - return this; - } - @Override public PiercingWeapon.Builder dealsKnockback(final boolean dealsKnockback) { this.dealsKnockback = dealsKnockback; @@ -122,9 +81,6 @@ public PiercingWeapon.Builder hitSound(final @Nullable Key sound) { public PiercingWeapon build() { return new PaperPiercingWeapon( new net.minecraft.world.item.component.PiercingWeapon( - this.minReach, - this.maxReach, - this.hitboxMargin, this.dealsKnockback, this.dismounts, Optional.ofNullable(this.sound).map(PaperAdventure::resolveSound), From 455fdd7adaa2a7cf34cf331fdfc3a327b8c4bfd8 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 20 Nov 2025 18:28:17 -0700 Subject: [PATCH 091/112] Run generators --- .../registry/keys/DataComponentTypeKeys.java | 7 ++ .../paper/registry/keys/SoundEventKeys.java | 91 +++++++++++++++++++ paper-api/src/main/java/org/bukkit/Sound.java | 26 ++++++ .../org/bukkit/entity/memory/MemoryKey.java | 6 ++ 4 files changed, 130 insertions(+) diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java index 32e5909fc79a..a3d447f8cd6d 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java @@ -25,6 +25,13 @@ @NullMarked @GeneratedClass public final class DataComponentTypeKeys { + /** + * {@code minecraft:attack_range} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ATTACK_RANGE = create(key("attack_range")); + /** * {@code minecraft:attribute_modifiers} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java index 1e94d5a361f5..f12ba25ff870 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java @@ -6038,6 +6038,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_BABY_NAUTILUS_AMBIENT = create(key("entity.baby_nautilus.ambient")); + /** + * {@code minecraft:entity.baby_nautilus.ambient_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_AMBIENT_LAND = create(key("entity.baby_nautilus.ambient_land")); + /** * {@code minecraft:entity.baby_nautilus.death} * @@ -6045,6 +6052,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_BABY_NAUTILUS_DEATH = create(key("entity.baby_nautilus.death")); + /** + * {@code minecraft:entity.baby_nautilus.death_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_DEATH_LAND = create(key("entity.baby_nautilus.death_land")); + /** * {@code minecraft:entity.baby_nautilus.eat} * @@ -6059,6 +6073,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_BABY_NAUTILUS_HURT = create(key("entity.baby_nautilus.hurt")); + /** + * {@code minecraft:entity.baby_nautilus.hurt_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_HURT_LAND = create(key("entity.baby_nautilus.hurt_land")); + /** * {@code minecraft:entity.baby_nautilus.swim} * @@ -8600,6 +8621,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_NAUTILUS_AMBIENT = create(key("entity.nautilus.ambient")); + /** + * {@code minecraft:entity.nautilus.ambient_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_AMBIENT_LAND = create(key("entity.nautilus.ambient_land")); + /** * {@code minecraft:entity.nautilus.dash} * @@ -8607,6 +8635,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_NAUTILUS_DASH = create(key("entity.nautilus.dash")); + /** + * {@code minecraft:entity.nautilus.dash_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_DASH_LAND = create(key("entity.nautilus.dash_land")); + /** * {@code minecraft:entity.nautilus.dash_ready} * @@ -8614,6 +8649,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_NAUTILUS_DASH_READY = create(key("entity.nautilus.dash_ready")); + /** + * {@code minecraft:entity.nautilus.dash_ready_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_DASH_READY_LAND = create(key("entity.nautilus.dash_ready_land")); + /** * {@code minecraft:entity.nautilus.death} * @@ -8621,6 +8663,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_NAUTILUS_DEATH = create(key("entity.nautilus.death")); + /** + * {@code minecraft:entity.nautilus.death_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_DEATH_LAND = create(key("entity.nautilus.death_land")); + /** * {@code minecraft:entity.nautilus.eat} * @@ -8635,6 +8684,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_NAUTILUS_HURT = create(key("entity.nautilus.hurt")); + /** + * {@code minecraft:entity.nautilus.hurt_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_HURT_LAND = create(key("entity.nautilus.hurt_land")); + /** * {@code minecraft:entity.nautilus.riding} * @@ -11400,6 +11456,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_AMBIENT = create(key("entity.zombie_nautilus.ambient")); + /** + * {@code minecraft:entity.zombie_nautilus.ambient_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_AMBIENT_LAND = create(key("entity.zombie_nautilus.ambient_land")); + /** * {@code minecraft:entity.zombie_nautilus.dash} * @@ -11407,6 +11470,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DASH = create(key("entity.zombie_nautilus.dash")); + /** + * {@code minecraft:entity.zombie_nautilus.dash_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DASH_LAND = create(key("entity.zombie_nautilus.dash_land")); + /** * {@code minecraft:entity.zombie_nautilus.dash_ready} * @@ -11414,6 +11484,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DASH_READY = create(key("entity.zombie_nautilus.dash_ready")); + /** + * {@code minecraft:entity.zombie_nautilus.dash_ready_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DASH_READY_LAND = create(key("entity.zombie_nautilus.dash_ready_land")); + /** * {@code minecraft:entity.zombie_nautilus.death} * @@ -11421,6 +11498,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DEATH = create(key("entity.zombie_nautilus.death")); + /** + * {@code minecraft:entity.zombie_nautilus.death_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DEATH_LAND = create(key("entity.zombie_nautilus.death_land")); + /** * {@code minecraft:entity.zombie_nautilus.eat} * @@ -11435,6 +11519,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_HURT = create(key("entity.zombie_nautilus.hurt")); + /** + * {@code minecraft:entity.zombie_nautilus.hurt_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_HURT_LAND = create(key("entity.zombie_nautilus.hurt_land")); + /** * {@code minecraft:entity.zombie_nautilus.swim} * diff --git a/paper-api/src/main/java/org/bukkit/Sound.java b/paper-api/src/main/java/org/bukkit/Sound.java index 8820c2664eb1..1ba2f4969419 100644 --- a/paper-api/src/main/java/org/bukkit/Sound.java +++ b/paper-api/src/main/java/org/bukkit/Sound.java @@ -1741,12 +1741,18 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_BABY_NAUTILUS_AMBIENT = getSound("entity.baby_nautilus.ambient"); + Sound ENTITY_BABY_NAUTILUS_AMBIENT_LAND = getSound("entity.baby_nautilus.ambient_land"); + Sound ENTITY_BABY_NAUTILUS_DEATH = getSound("entity.baby_nautilus.death"); + Sound ENTITY_BABY_NAUTILUS_DEATH_LAND = getSound("entity.baby_nautilus.death_land"); + Sound ENTITY_BABY_NAUTILUS_EAT = getSound("entity.baby_nautilus.eat"); Sound ENTITY_BABY_NAUTILUS_HURT = getSound("entity.baby_nautilus.hurt"); + Sound ENTITY_BABY_NAUTILUS_HURT_LAND = getSound("entity.baby_nautilus.hurt_land"); + Sound ENTITY_BABY_NAUTILUS_SWIM = getSound("entity.baby_nautilus.swim"); Sound ENTITY_BAT_AMBIENT = getSound("entity.bat.ambient"); @@ -2473,16 +2479,26 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_NAUTILUS_AMBIENT = getSound("entity.nautilus.ambient"); + Sound ENTITY_NAUTILUS_AMBIENT_LAND = getSound("entity.nautilus.ambient_land"); + Sound ENTITY_NAUTILUS_DASH = getSound("entity.nautilus.dash"); + Sound ENTITY_NAUTILUS_DASH_LAND = getSound("entity.nautilus.dash_land"); + Sound ENTITY_NAUTILUS_DASH_READY = getSound("entity.nautilus.dash_ready"); + Sound ENTITY_NAUTILUS_DASH_READY_LAND = getSound("entity.nautilus.dash_ready_land"); + Sound ENTITY_NAUTILUS_DEATH = getSound("entity.nautilus.death"); + Sound ENTITY_NAUTILUS_DEATH_LAND = getSound("entity.nautilus.death_land"); + Sound ENTITY_NAUTILUS_EAT = getSound("entity.nautilus.eat"); Sound ENTITY_NAUTILUS_HURT = getSound("entity.nautilus.hurt"); + Sound ENTITY_NAUTILUS_HURT_LAND = getSound("entity.nautilus.hurt_land"); + Sound ENTITY_NAUTILUS_RIDING = getSound("entity.nautilus.riding"); Sound ENTITY_NAUTILUS_SWIM = getSound("entity.nautilus.swim"); @@ -3273,16 +3289,26 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_ZOMBIE_NAUTILUS_AMBIENT = getSound("entity.zombie_nautilus.ambient"); + Sound ENTITY_ZOMBIE_NAUTILUS_AMBIENT_LAND = getSound("entity.zombie_nautilus.ambient_land"); + Sound ENTITY_ZOMBIE_NAUTILUS_DASH = getSound("entity.zombie_nautilus.dash"); + Sound ENTITY_ZOMBIE_NAUTILUS_DASH_LAND = getSound("entity.zombie_nautilus.dash_land"); + Sound ENTITY_ZOMBIE_NAUTILUS_DASH_READY = getSound("entity.zombie_nautilus.dash_ready"); + Sound ENTITY_ZOMBIE_NAUTILUS_DASH_READY_LAND = getSound("entity.zombie_nautilus.dash_ready_land"); + Sound ENTITY_ZOMBIE_NAUTILUS_DEATH = getSound("entity.zombie_nautilus.death"); + Sound ENTITY_ZOMBIE_NAUTILUS_DEATH_LAND = getSound("entity.zombie_nautilus.death_land"); + Sound ENTITY_ZOMBIE_NAUTILUS_EAT = getSound("entity.zombie_nautilus.eat"); Sound ENTITY_ZOMBIE_NAUTILUS_HURT = getSound("entity.zombie_nautilus.hurt"); + Sound ENTITY_ZOMBIE_NAUTILUS_HURT_LAND = getSound("entity.zombie_nautilus.hurt_land"); + Sound ENTITY_ZOMBIE_NAUTILUS_SWIM = getSound("entity.zombie_nautilus.swim"); Sound ENTITY_ZOMBIE_VILLAGER_AMBIENT = getSound("entity.zombie_villager.ambient"); diff --git a/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java b/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java index aa327854fe16..a895e6c68bfd 100644 --- a/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java +++ b/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java @@ -121,6 +121,12 @@ public Class getMemoryClass() { public static final MemoryKey SNIFFER_HAPPY = new MemoryKey<>(NamespacedKey.minecraft("sniffer_happy"), Boolean.class); + public static final MemoryKey SPEAR_ENGAGE_TIME = new MemoryKey<>(NamespacedKey.minecraft("spear_engage_time"), Integer.class); + + public static final MemoryKey SPEAR_FLEEING_TIME = new MemoryKey<>(NamespacedKey.minecraft("spear_fleeing_time"), Integer.class); + + // public static final MemoryKey SPEAR_STATUS = new MemoryKey<>(NamespacedKey.minecraft("spear_status"), SpearStatus.class); // TODO - snapshot: SpearStatus API + public static final MemoryKey TEMPTATION_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("temptation_cooldown_ticks"), Integer.class); public static final MemoryKey TIME_TRYING_TO_REACH_ADMIRE_ITEM = new MemoryKey<>(NamespacedKey.minecraft("time_trying_to_reach_admire_item"), Integer.class); From ec252b43a8f43e881996f30b60dac3adf6b3e65e Mon Sep 17 00:00:00 2001 From: Pedro <3602279+Doc94@users.noreply.github.com> Date: Thu, 20 Nov 2025 22:47:48 -0300 Subject: [PATCH 092/112] Add ATTACK_RANGE for DataComponentTypes (#13331) --- .../java/io/papermc/paper/datacomponent/DataComponentTypes.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java index 247f14bd61fc..1fcdc62cff07 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java @@ -1,5 +1,6 @@ package io.papermc.paper.datacomponent; +import io.papermc.paper.datacomponent.item.AttackRange; import io.papermc.paper.datacomponent.item.BannerPatternLayers; import io.papermc.paper.datacomponent.item.BlockItemDataProperties; import io.papermc.paper.datacomponent.item.BlocksAttacks; @@ -222,6 +223,7 @@ public final class DataComponentTypes { public static final DataComponentType.Valued BLOCKS_ATTACKS = valued("blocks_attacks"); public static final DataComponentType.Valued PIERCING_WEAPON = valued("piercing_weapon"); public static final DataComponentType.Valued KINETIC_WEAPON = valued("kinetic_weapon"); + public static final DataComponentType.Valued ATTACK_RANGE = valued("attack_range"); public static final DataComponentType.Valued SWING_ANIMATION = valued("swing_animation"); /** * Stores list of enchantments and their levels for an Enchanted Book. From 907c4afa7a3ad338a77dcdf19c608e23885f1913 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 21 Nov 2025 09:05:25 -0700 Subject: [PATCH 093/112] Init 1.21.11-pre2 --- gradle.properties | 4 +- paper-server/build.gradle.kts | 4 +- .../server/level/ServerPlayer.java.patch | 144 +++++++++--------- .../net/minecraft/world/LockCode.java.patch | 20 +++ .../world/entity/player/Player.java.patch | 54 +++---- .../world/level/block/ChestBlock.java.patch | 12 +- .../world/level/block/LeavesBlock.java.patch | 2 +- .../BaseContainerBlockEntity.java.patch | 57 ++----- .../block/entity/BeaconBlockEntity.java.patch | 10 +- ...andomizableContainerBlockEntity.java.patch | 2 +- .../LegacyStructureDataHandler.java.patch | 8 +- .../craftbukkit/event/CraftEventFactory.java | 46 ++++++ todo-snapshot.txt | 2 + 13 files changed, 204 insertions(+), 161 deletions(-) create mode 100644 paper-server/patches/sources/net/minecraft/world/LockCode.java.patch diff --git a/gradle.properties b/gradle.properties index 26c9ffea56ea..9c7dbb64fefa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group=io.papermc.paper -version=1.21.11-pre1-R0.1-SNAPSHOT -mcVersion=1.21.11-pre1 +version=1.21.11-pre2-R0.1-SNAPSHOT +mcVersion=1.21.11-pre2 # This is the current API version for use in (paper-)plugin.yml files # During snapshot cycles this should be the anticipated version of the release target apiVersion=1.21.11 diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 28110ddc23cd..8ef35fef2864 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:1.21.11-pre1+build.2") + mache("io.papermc:mache:1.21.11-pre2+build.1") paperclip("io.papermc:paperclip:3.0.3") } @@ -41,7 +41,7 @@ paperweight { ) updatingMinecraft { - // oldPaperCommit = "926d6304e09d05e451668ac1915248530165007b" + oldPaperCommit = "c82b438b5b4ea0b230439b8e690e34708cd11ab3" } } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index 6176bf429b47..1051f772c116 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -255,7 +_,8 @@ +@@ -251,7 +_,8 @@ private int levitationStartTime; private boolean disconnected; private int requestedViewDistance = 2; @@ -10,7 +10,7 @@ private @Nullable Vec3 startingToFallPosition; private @Nullable Vec3 enteredNetherPosition; private @Nullable Vec3 enteredLavaOnVehiclePosition; -@@ -299,6 +_,13 @@ +@@ -295,6 +_,13 @@ } } @@ -24,7 +24,7 @@ @Override public void sendSlotChange(AbstractContainerMenu container, int slot, ItemStack stack) { ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(container.containerId, container.incrementStateId(), slot, stack)); -@@ -334,6 +_,32 @@ +@@ -330,6 +_,32 @@ } } @@ -57,7 +57,7 @@ @Override public void dataChanged(AbstractContainerMenu containerMenu, int dataSlotIndex, int value) { } -@@ -360,10 +_,43 @@ +@@ -356,10 +_,43 @@ public void sendSystemMessage(Component message) { ServerPlayer.this.sendSystemMessage(message); } @@ -101,7 +101,7 @@ public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) { super(level, gameProfile); -@@ -374,8 +_,14 @@ +@@ -370,8 +_,14 @@ this.recipeBook = new ServerRecipeBook((recipe, output) -> server.getRecipeManager().listDisplaysForRecipe(recipe, output)); this.stats = server.getPlayerList().getPlayerStats(this); this.advancements = server.getPlayerList().getPlayerAdvancements(this); @@ -117,7 +117,7 @@ } @Override -@@ -393,6 +_,7 @@ +@@ -389,6 +_,7 @@ this.seenCredits = input.getBooleanOr("seenCredits", false); input.read("recipeBook", ServerRecipeBook.Packed.CODEC) .ifPresent(packed -> this.recipeBook.loadUntrusted(packed, key -> this.server.getRecipeManager().byKey(key).isPresent())); @@ -125,7 +125,7 @@ if (this.isSleeping()) { this.stopSleeping(); } -@@ -400,6 +_,19 @@ +@@ -396,6 +_,19 @@ this.respawnConfig = input.read("respawn", ServerPlayer.RespawnConfig.CODEC).orElse(null); this.spawnExtraParticlesOnFall = input.getBooleanOr("spawn_extra_particles_on_fall", false); this.raidOmenPosition = input.read("raid_omen_position", BlockPos.CODEC).orElse(null); @@ -145,7 +145,7 @@ this.gameMode .setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(input, "playerGameType")), readPlayerMode(input, "previousPlayerGameType")); this.setShoulderEntityLeft(input.read("ShoulderEntityLeft", CompoundTag.CODEC).orElseGet(CompoundTag::new)); -@@ -427,12 +_,24 @@ +@@ -423,12 +_,24 @@ if (!this.getShoulderEntityRight().isEmpty()) { output.store("ShoulderEntityRight", CompoundTag.CODEC, this.getShoulderEntityRight()); } @@ -171,7 +171,7 @@ ValueOutput valueOutput = output.child("RootVehicle"); valueOutput.store("Attach", UUIDUtil.CODEC, vehicle.getUUID()); rootVehicle.save(valueOutput.child("Entity")); -@@ -444,7 +_,7 @@ +@@ -440,7 +_,7 @@ if (!optional.isEmpty()) { ServerLevel serverLevel = this.level(); Entity entity = EntityType.loadEntityRecursive( @@ -180,7 +180,7 @@ ); if (entity != null) { UUID uuid = optional.get().read("Attach", UUIDUtil.CODEC).orElse(null); -@@ -461,10 +_,10 @@ +@@ -457,10 +_,10 @@ if (!this.isPassenger()) { LOGGER.warn("Couldn't reattach entity to player"); @@ -193,7 +193,7 @@ } } } -@@ -476,6 +_,7 @@ +@@ -472,6 +_,7 @@ ValueOutput.ValueOutputList valueOutputList = output.childrenList("ender_pearls"); for (ThrownEnderpearl thrownEnderpearl : this.enderPearls) { @@ -201,7 +201,7 @@ if (thrownEnderpearl.isRemoved()) { LOGGER.warn("Trying to save removed ender pearl, skipping"); } else { -@@ -508,6 +_,16 @@ +@@ -504,6 +_,16 @@ } } @@ -218,7 +218,7 @@ public void setExperiencePoints(int experiencePoints) { float f = this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -572,6 +_,11 @@ +@@ -568,6 +_,11 @@ @Override public void tick() { @@ -230,7 +230,7 @@ this.connection.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); -@@ -579,9 +_,18 @@ +@@ -575,9 +_,18 @@ this.invulnerableTime--; } @@ -252,7 +252,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -640,10 +_,10 @@ +@@ -636,10 +_,10 @@ public void doTick() { try { @@ -265,7 +265,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -673,7 +_,7 @@ +@@ -669,7 +_,7 @@ if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -274,7 +274,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -704,6 +_,12 @@ +@@ -700,6 +_,12 @@ this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float)this.lastRecordedExperience)); } @@ -287,7 +287,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float)this.lastRecordedLevel)); -@@ -717,6 +_,21 @@ +@@ -713,6 +_,21 @@ if (this.tickCount % 20 == 0) { CriteriaTriggers.LOCATION.trigger(this); } @@ -309,7 +309,7 @@ } catch (Throwable var4) { CrashReport crashReport = CrashReport.forThrowable(var4, "Ticking player"); CrashReportCategory crashReportCategory = crashReport.addCategory("Player being ticked"); -@@ -741,7 +_,7 @@ +@@ -737,7 +_,7 @@ if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.level().getGameRules().get(GameRules.NATURAL_HEALTH_REGENERATION)) { if (this.tickCount % 20 == 0) { if (this.getHealth() < this.getMaxHealth()) { @@ -318,7 +318,7 @@ } float saturationLevel = this.foodData.getSaturationLevel(); -@@ -761,6 +_,7 @@ +@@ -757,6 +_,7 @@ this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft()); this.playShoulderEntityAmbientSound(this.getShoulderEntityRight()); if (this.fallDistance > 0.5 || this.isInWater() || this.getAbilities().flying || this.isSleeping() || this.isInPowderSnow) { @@ -326,7 +326,7 @@ this.removeEntitiesOnShoulder(); } } -@@ -805,35 +_,64 @@ +@@ -801,35 +_,64 @@ @Override public void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { @@ -398,7 +398,7 @@ } @Override -@@ -870,15 +_,36 @@ +@@ -866,15 +_,36 @@ } private void updateScoreForCriteria(ObjectiveCriteria criteria, int points) { @@ -444,7 +444,7 @@ this.connection .send( new ClientboundPlayerCombatKillPacket(this.getId(), deathMessage), -@@ -895,6 +_,65 @@ +@@ -891,6 +_,65 @@ } ) ); @@ -510,7 +510,7 @@ Team team = this.getTeam(); if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) { this.server.getPlayerList().broadcastSystemMessage(deathMessage, false); -@@ -904,7 +_,7 @@ +@@ -900,7 +_,7 @@ this.server.getPlayerList().broadcastSystemToAllExceptTeam(this, deathMessage); } } else { @@ -519,7 +519,7 @@ } this.removeEntitiesOnShoulder(); -@@ -912,11 +_,35 @@ +@@ -908,11 +_,35 @@ this.tellNeutralMobsThatIDied(); } @@ -558,7 +558,7 @@ LivingEntity killCredit = this.getKillCredit(); if (killCredit != null) { this.awardStat(Stats.ENTITY_KILLED_BY.get(killCredit.getType())); -@@ -950,10 +_,10 @@ +@@ -946,10 +_,10 @@ if (entity != this) { super.awardKillScore(entity, damageSource); Scoreboard scoreboard = this.level().getScoreboard(); @@ -571,7 +571,7 @@ } else { this.awardStat(Stats.MOB_KILLS); } -@@ -965,12 +_,11 @@ +@@ -961,12 +_,11 @@ } private void handleTeamKill(ScoreHolder scoreHolder, ScoreHolder teamMember, ObjectiveCriteria[] criteria) { @@ -586,7 +586,7 @@ } } } -@@ -981,9 +_,20 @@ +@@ -977,9 +_,20 @@ return false; } else { Entity entity = damageSource.getEntity(); @@ -609,7 +609,7 @@ } } -@@ -993,25 +_,95 @@ +@@ -989,25 +_,95 @@ } private boolean isPvpAllowed() { @@ -713,7 +713,7 @@ } public boolean isReceivingWaypoints() { -@@ -1046,14 +_,16 @@ +@@ -1042,14 +_,16 @@ && (flag || blockState.getValue(RespawnAnchorBlock.CHARGE) > 0) && RespawnAnchorBlock.canSetSpawn(level, blockPos)) { Optional optional = RespawnAnchorBlock.findStandUpPosition(EntityType.PLAYER, level, blockPos); @@ -733,7 +733,7 @@ } else if (!flag) { return Optional.empty(); } else { -@@ -1061,7 +_,7 @@ +@@ -1057,7 +_,7 @@ BlockState blockState1 = level.getBlockState(blockPos.above()); boolean isPossibleToRespawnInThis1 = blockState1.getBlock().isPossibleToRespawnInThis(blockState1); return isPossibleToRespawnInThis && isPossibleToRespawnInThis1 @@ -742,7 +742,7 @@ : Optional.empty(); } } -@@ -1078,6 +_,7 @@ +@@ -1074,6 +_,7 @@ @Override public @Nullable ServerPlayer teleport(TeleportTransition teleportTransition) { @@ -750,7 +750,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1087,13 +_,48 @@ +@@ -1083,13 +_,48 @@ ServerLevel level = teleportTransition.newLevel(); ServerLevel serverLevel = this.level(); @@ -802,7 +802,7 @@ this.connection.resetPosition(); teleportTransition.postTeleportTransition().onTransition(this); return this; -@@ -1104,18 +_,19 @@ +@@ -1100,18 +_,19 @@ this.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); PlayerList playerList = this.server.getPlayerList(); playerList.sendPlayerPermissionLevel(this); @@ -824,7 +824,7 @@ this.connection.resetPosition(); level.addDuringTeleport(this); profilerFiller.pop(); -@@ -1130,6 +_,15 @@ +@@ -1126,6 +_,15 @@ this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(teleportTransition, serverLevel); @@ -840,7 +840,7 @@ return this; } } -@@ -1144,12 +_,26 @@ +@@ -1140,12 +_,26 @@ public void triggerDimensionChangeTriggers(ServerLevel level) { ResourceKey resourceKey = level.dimension(); ResourceKey resourceKey1 = this.level().dimension(); @@ -870,7 +870,7 @@ this.enteredNetherPosition = null; } } -@@ -1165,9 +_,8 @@ +@@ -1161,9 +_,8 @@ this.containerMenu.broadcastChanges(); } @@ -882,7 +882,7 @@ if (!this.isSleeping() && this.isAlive()) { BedRule bedRule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, bedPos); boolean canSleep = bedRule.canSleep(this.level()); -@@ -1181,7 +_,7 @@ +@@ -1177,7 +_,7 @@ } else { if (canSetSpawn) { this.setRespawnPosition( @@ -891,7 +891,7 @@ ); } -@@ -1203,7 +_,37 @@ +@@ -1199,7 +_,37 @@ } } @@ -930,7 +930,7 @@ this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1213,10 +_,7 @@ +@@ -1209,10 +_,7 @@ this.level().updateSleepingPlayerList(); return either; @@ -941,7 +941,7 @@ } } -@@ -1242,21 +_,29 @@ +@@ -1238,21 +_,29 @@ @Override public void stopSleepInBed(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) { @@ -974,7 +974,7 @@ } @Override -@@ -1304,8 +_,9 @@ +@@ -1300,8 +_,9 @@ this.connection.send(new ClientboundShowDialogPacket(dialog)); } @@ -985,7 +985,7 @@ } @Override -@@ -1313,12 +_,39 @@ +@@ -1309,12 +_,39 @@ if (menu == null) { return OptionalInt.empty(); } else { @@ -1026,7 +1026,7 @@ if (abstractContainerMenu == null) { if (this.isSpectator()) { this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true); -@@ -1326,10 +_,14 @@ +@@ -1322,10 +_,14 @@ return OptionalInt.empty(); } else { @@ -1043,7 +1043,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1342,27 +_,49 @@ +@@ -1338,27 +_,49 @@ @Override public void openHorseInventory(AbstractHorse horse, Container inventory) { @@ -1098,7 +1098,7 @@ this.initMenu(this.containerMenu); } -@@ -1384,10 +_,30 @@ +@@ -1380,10 +_,30 @@ @Override public void closeContainer() { @@ -1129,7 +1129,7 @@ @Override public void doCloseContainer() { this.containerMenu.removed(this); -@@ -1410,19 +_,19 @@ +@@ -1406,19 +_,19 @@ int rounded = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); if (rounded > 0) { this.awardStat(Stats.SWIM_ONE_CM, rounded); @@ -1152,7 +1152,7 @@ } } else if (this.onClimbable()) { if (dy > 0.0) { -@@ -1433,13 +_,13 @@ +@@ -1429,13 +_,13 @@ if (rounded > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, rounded); @@ -1169,7 +1169,7 @@ } } } else if (this.isFallFlying()) { -@@ -1483,13 +_,13 @@ +@@ -1479,13 +_,13 @@ @Override public void awardStat(Stat stat, int amount) { this.stats.increment(this, stat, amount); @@ -1185,7 +1185,7 @@ } @Override -@@ -1520,9 +_,9 @@ +@@ -1516,9 +_,9 @@ super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1197,7 +1197,7 @@ } } -@@ -1537,6 +_,13 @@ +@@ -1533,6 +_,13 @@ public void disconnect() { this.disconnected = true; this.ejectPassengers(); @@ -1211,7 +1211,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, false); } -@@ -1548,6 +_,7 @@ +@@ -1544,6 +_,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1219,7 +1219,7 @@ } @Override -@@ -1582,12 +_,12 @@ +@@ -1578,12 +_,12 @@ this.onUpdateAbilities(); if (keepEverything) { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1234,7 +1234,7 @@ } this.getInventory().replaceWith(that.getInventory()); -@@ -1598,7 +_,7 @@ +@@ -1594,7 +_,7 @@ this.portalProcess = that.portalProcess; } else { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1243,7 +1243,7 @@ if (this.level().getGameRules().get(GameRules.KEEP_INVENTORY) || that.isSpectator()) { this.getInventory().replaceWith(that.getInventory()); this.experienceLevel = that.experienceLevel; -@@ -1614,7 +_,7 @@ +@@ -1610,7 +_,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1252,7 +1252,7 @@ this.seenCredits = that.seenCredits; this.enteredNetherPosition = that.enteredNetherPosition; this.chunkTrackingView = that.chunkTrackingView; -@@ -1657,9 +_,22 @@ +@@ -1653,9 +_,22 @@ CriteriaTriggers.EFFECTS_CHANGED.trigger(this, null); } @@ -1276,7 +1276,7 @@ } @Override -@@ -1668,7 +_,7 @@ +@@ -1664,7 +_,7 @@ } @Override @@ -1285,7 +1285,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, true); } -@@ -1677,7 +_,7 @@ +@@ -1673,7 +_,7 @@ this.setCamera(this); } @@ -1294,7 +1294,7 @@ if (flag) { this.setYHeadRot(relativeMovements.contains(Relative.Y_ROT) ? this.getYHeadRot() + yaw : yaw); this.connection.resetFlyingTicks(); -@@ -1716,9 +_,18 @@ +@@ -1712,9 +_,18 @@ } public boolean setGameMode(GameType gameMode) { @@ -1315,7 +1315,7 @@ } else { this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, gameMode.getId())); if (gameMode == GameType.SPECTATOR) { -@@ -1735,7 +_,7 @@ +@@ -1731,7 +_,7 @@ this.onUpdateAbilities(); this.updateEffectVisibility(); @@ -1324,7 +1324,7 @@ } } -@@ -1790,8 +_,13 @@ +@@ -1786,8 +_,13 @@ } public void sendChatMessage(OutgoingChatMessage message, boolean filtered, ChatType.Bound boundChatType) { @@ -1339,7 +1339,7 @@ } } -@@ -1802,7 +_,42 @@ +@@ -1798,7 +_,42 @@ } public void updateOptions(ClientInformation clientInformation) { @@ -1382,7 +1382,7 @@ this.requestedViewDistance = clientInformation.viewDistance(); this.chatVisibility = clientInformation.chatVisibility(); this.canChatColor = clientInformation.chatColors(); -@@ -1887,8 +_,23 @@ +@@ -1883,8 +_,23 @@ Entity camera = this.getCamera(); this.camera = (Entity)(entityToSpectate == null ? this : entityToSpectate); if (camera != this.camera) { @@ -1407,7 +1407,7 @@ } if (entityToSpectate != null) { -@@ -1921,11 +_,11 @@ +@@ -1917,11 +_,11 @@ } public @Nullable Component getTabListDisplayName() { @@ -1421,7 +1421,7 @@ } @Override -@@ -1955,11 +_,62 @@ +@@ -1951,11 +_,62 @@ } public void setRespawnPosition(ServerPlayer.@Nullable RespawnConfig respawnConfig, boolean displayInChat) { @@ -1486,7 +1486,7 @@ } public SectionPos getLastSectionPos() { -@@ -1989,16 +_,23 @@ +@@ -1975,16 +_,23 @@ } @Override @@ -1515,7 +1515,7 @@ return itemEntity; } -@@ -2050,7 +_,7 @@ +@@ -2036,7 +_,7 @@ super.updateUsingItem(usingItem); } @@ -1524,7 +1524,7 @@ Inventory inventory = this.getInventory(); ItemStack itemStack = inventory.removeFromSelected(dropStack); this.containerMenu -@@ -2060,7 +_,7 @@ +@@ -2046,7 +_,7 @@ this.stopUsingItem(); } @@ -1533,7 +1533,7 @@ } @Override -@@ -2123,9 +_,9 @@ +@@ -2109,9 +_,9 @@ } @Override @@ -1545,7 +1545,7 @@ if (vehicle instanceof LivingEntity livingEntity) { for (MobEffectInstance mobEffectInstance : livingEntity.getActiveEffects()) { this.connection.send(new ClientboundRemoveMobEffectPacket(vehicle.getId(), mobEffectInstance.getEffect())); -@@ -2247,7 +_,7 @@ +@@ -2233,7 +_,7 @@ } public static long placeEnderPearlTicket(ServerLevel level, ChunkPos pos) { @@ -1554,7 +1554,7 @@ return TicketType.ENDER_PEARL.timeout(); } -@@ -2277,9 +_,11 @@ +@@ -2263,9 +_,11 @@ } } @@ -1569,7 +1569,7 @@ } private static float calculateLookAtYaw(Vec3 position, BlockPos towardsPos) { -@@ -2299,4 +_,135 @@ +@@ -2285,4 +_,135 @@ ); public static final ServerPlayer.SavedPosition EMPTY = new ServerPlayer.SavedPosition(Optional.empty(), Optional.empty(), Optional.empty()); } diff --git a/paper-server/patches/sources/net/minecraft/world/LockCode.java.patch b/paper-server/patches/sources/net/minecraft/world/LockCode.java.patch new file mode 100644 index 000000000000..300efc7b8464 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/LockCode.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/LockCode.java ++++ b/net/minecraft/world/LockCode.java +@@ -22,9 +_,15 @@ + } + } + ++ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - use new variant for event compatibility + public boolean canUnlock(Player player) { +- return player.isSpectator() || this.unlocksWith(player.getMainHandItem()); +- } ++ return player.isSpectator() || this.unlocksWith(player.getMainHandItem()); // Paper - diff on change ++ } ++ // Paper start - allow overriding key item ++ public boolean canUnlock(Player player, ItemStack keyItem) { ++ return player.isSpectator() || this.unlocksWith(keyItem); ++ } ++ // Paper end - allow overriding key item + + public static LockCode fromTag(ValueInput input) { + return input.read("lock", CODEC).orElse(NO_LOCK); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index 56a703c64308..108481a5a436 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -51,7 +51,7 @@ } private boolean isEquipped(Item item) { -@@ -430,6 +_,18 @@ +@@ -427,6 +_,18 @@ } } @@ -70,7 +70,7 @@ public void closeContainer() { this.containerMenu = this.inventoryMenu; } -@@ -441,8 +_,14 @@ +@@ -438,8 +_,14 @@ public void rideTick() { if (!this.level().isClientSide() && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -87,7 +87,7 @@ super.rideTick(); } } -@@ -701,10 +_,10 @@ +@@ -698,10 +_,10 @@ if (this.isDeadOrDying()) { return false; } else { @@ -100,7 +100,7 @@ } if (level.getDifficulty() == Difficulty.EASY) { -@@ -716,7 +_,14 @@ +@@ -713,7 +_,14 @@ } } @@ -116,7 +116,7 @@ } } } -@@ -728,7 +_,7 @@ +@@ -725,7 +_,7 @@ BlocksAttacks blocksAttacks = itemBlockingWith != null ? itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS) : null; float secondsToDisableBlocking = entity.getSecondsToDisableBlocking(); if (secondsToDisableBlocking > 0.0F && blocksAttacks != null) { @@ -125,7 +125,7 @@ } } -@@ -738,9 +_,29 @@ +@@ -735,9 +_,29 @@ } public boolean canHarmPlayer(Player other) { @@ -158,7 +158,7 @@ } @Override -@@ -754,7 +_,12 @@ +@@ -751,7 +_,12 @@ } @Override @@ -172,7 +172,7 @@ if (!this.isInvulnerableTo(level, damageSource)) { amount = this.getDamageAfterArmorAbsorb(damageSource, amount); amount = this.getDamageAfterMagicAbsorb(damageSource, amount); -@@ -766,7 +_,7 @@ +@@ -763,7 +_,7 @@ } if (var8 != 0.0F) { @@ -181,7 +181,7 @@ this.getCombatTracker().recordDamage(damageSource, var8); this.setHealth(this.getHealth() - var8); if (var8 < 3.4028235E37F) { -@@ -776,6 +_,7 @@ +@@ -773,6 +_,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -189,7 +189,7 @@ } public boolean isTextFilteringEnabled() { -@@ -862,14 +_,16 @@ +@@ -859,14 +_,16 @@ } @Override @@ -209,7 +209,7 @@ } @Override -@@ -948,15 +_,25 @@ +@@ -945,15 +_,25 @@ } public void attack(Entity target) { @@ -238,7 +238,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = attackStrengthScale > 0.9F; boolean flag1; -@@ -969,7 +_,9 @@ +@@ -966,7 +_,9 @@ f += weaponItem.getItem().getAttackDamageBonus(target, f, damageSource); boolean flag2 = flag && this.canCriticalAttack(target); @@ -248,7 +248,7 @@ f *= 1.5F; } -@@ -1015,11 +_,12 @@ +@@ -1012,11 +_,12 @@ return !target.isAttackable() || target.skipAttackInteraction(this); } @@ -263,7 +263,7 @@ return true; } else { return false; -@@ -1112,21 +_,43 @@ +@@ -1109,21 +_,43 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F) { if (target instanceof LivingEntity livingEntity) { @@ -308,7 +308,7 @@ } } -@@ -1147,7 +_,10 @@ +@@ -1144,7 +_,10 @@ && !(livingEntity instanceof ArmorStand armorStand && armorStand.isMarker()) && this.distanceToSqr(livingEntity) < 9.0) { float f1 = this.getEnchantedDamage(livingEntity, var12, damageSource) * strengthScale; @@ -320,7 +320,7 @@ livingEntity.knockback(0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity, damageSource); } -@@ -1179,7 +_,16 @@ +@@ -1176,7 +_,16 @@ @Override public boolean stabAttack(EquipmentSlot slot, Entity target, float damageAmount, boolean damage, boolean knockback, boolean dismount) { @@ -338,7 +338,7 @@ return false; } else { ItemStack itemBySlot = this.getItemBySlot(slot); -@@ -1190,7 +_,8 @@ +@@ -1187,7 +_,8 @@ damageAmount *= this.baseDamageScaleFactor(); } @@ -348,7 +348,7 @@ return true; } else { float f1 = damage ? damageAmount + f : 0.0F; -@@ -1218,7 +_,7 @@ +@@ -1215,7 +_,7 @@ this.setLastHurtMob(target); this.itemAttackInteraction(target, itemBySlot, damageSource, flag); this.damageStatsAndHearts(target, f2); @@ -357,7 +357,7 @@ return true; } } -@@ -1229,8 +_,8 @@ +@@ -1226,8 +_,8 @@ } @Override @@ -368,7 +368,7 @@ this.inventoryMenu.removed(this); if (this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1298,6 +_,12 @@ +@@ -1295,6 +_,12 @@ } public Either startSleepInBed(BlockPos bedPos) { @@ -381,7 +381,7 @@ this.startSleeping(bedPos); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1409,7 +_,7 @@ +@@ -1406,7 +_,7 @@ @Override public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) { @@ -390,7 +390,7 @@ return false; } else { if (fallDistance >= 2.0) { -@@ -1450,7 +_,15 @@ +@@ -1447,7 +_,15 @@ } public void startFallFlying() { @@ -407,7 +407,7 @@ } @Override -@@ -1548,7 +_,7 @@ +@@ -1545,7 +_,7 @@ if (levels > 0 && this.experienceLevel % 5 == 0 && this.lastLevelUpTime < this.tickCount - 100.0F) { float f = this.experienceLevel > 30 ? 1.0F : this.experienceLevel / 30.0F; @@ -416,7 +416,7 @@ this.lastLevelUpTime = this.tickCount; } } -@@ -1556,15 +_,35 @@ +@@ -1553,15 +_,35 @@ public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { return 112 + (this.experienceLevel - 30) * 9; @@ -454,7 +454,7 @@ } } } -@@ -1823,7 +_,7 @@ +@@ -1820,7 +_,7 @@ @Override public void onAttack() { @@ -463,7 +463,7 @@ super.onAttack(); } -@@ -1858,17 +_,32 @@ +@@ -1855,17 +_,32 @@ return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } @@ -498,7 +498,7 @@ for (int i = 0; i < this.inventory.getContainerSize(); i++) { ItemStack item = this.inventory.getItem(i); -@@ -1877,6 +_,7 @@ +@@ -1874,6 +_,7 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch index e492e02c72d0..af84505e929e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ChestBlock.java +++ b/net/minecraft/world/level/block/ChestBlock.java -@@ -94,7 +_,7 @@ +@@ -96,7 +_,7 @@ @Override public Optional acceptDouble(final ChestBlockEntity first, final ChestBlockEntity second) { final Container container = new CompoundContainer(first, second); @@ -9,7 +9,7 @@ @Override public @Nullable AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { if (first.canOpen(player) && second.canOpen(player)) { -@@ -111,10 +_,10 @@ +@@ -117,10 +_,10 @@ if (first.hasCustomName()) { return first.getDisplayName(); } else { @@ -22,7 +22,7 @@ } @Override -@@ -128,6 +_,34 @@ +@@ -134,6 +_,34 @@ } }; @@ -57,7 +57,7 @@ @Override public MapCodec codec() { return CODEC; -@@ -255,8 +_,7 @@ +@@ -261,8 +_,7 @@ protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { if (level instanceof ServerLevel serverLevel) { MenuProvider menuProvider = this.getMenuProvider(state, level, pos); @@ -67,7 +67,7 @@ player.awardStat(this.getOpenChestStat()); PiglinAi.angerNearbyPiglins(serverLevel, player, true); } -@@ -293,7 +_,14 @@ +@@ -299,7 +_,14 @@ @Override public @Nullable MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos) { @@ -83,7 +83,7 @@ } public static DoubleBlockCombiner.Combiner opennessCombiner(final LidBlockEntity lid) { -@@ -335,6 +_,11 @@ +@@ -341,6 +_,11 @@ } private static boolean isCatSittingOnChest(LevelAccessor level, BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LeavesBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LeavesBlock.java.patch index 24d95a3621a1..8cb50108abfb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LeavesBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LeavesBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LeavesBlock.java +++ b/net/minecraft/world/level/block/LeavesBlock.java -@@ -56,6 +_,14 @@ +@@ -66,6 +_,14 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (this.decaying(state)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch index e455a3f9962e..7e9e57263964 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch @@ -1,54 +1,29 @@ --- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -@@ -64,17 +_,45 @@ +@@ -66,14 +_,19 @@ protected abstract Component getDefaultName(); public boolean canOpen(Player player) { -- return canUnlock(player, this.lockKey, this.getDisplayName()); -+ return canUnlock(player, this.lockKey, this.getDisplayName(), this); // Paper - Add BlockLockCheckEvent +- return this.lockKey.canUnlock(player); ++ return org.bukkit.craftbukkit.event.CraftEventFactory.callBlockLockCheckEvent(this, this.lockKey, this.getDisplayName(), player); // Paper - Call BlockLockCheckEvent } -+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - Add BlockLockCheckEvent - public static boolean canUnlock(Player player, LockCode code, Component displayName) { -+ // Paper start - Add BlockLockCheckEvent -+ return canUnlock(player, code, displayName, null); -+ } -+ -+ public static boolean canUnlock(Player player, LockCode code, Component displayName, @Nullable BlockEntity blockEntity) { -+ if (player instanceof net.minecraft.server.level.ServerPlayer serverPlayer && blockEntity != null && blockEntity.getLevel() != null && blockEntity.getLevel().getBlockEntity(blockEntity.getBlockPos()) == blockEntity) { -+ final org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(blockEntity.getLevel(), blockEntity.getBlockPos()); -+ net.kyori.adventure.text.Component lockedMessage = net.kyori.adventure.text.Component.translatable("container.isLocked", io.papermc.paper.adventure.PaperAdventure.asAdventure(displayName)); -+ net.kyori.adventure.sound.Sound lockedSound = net.kyori.adventure.sound.Sound.sound(org.bukkit.Sound.BLOCK_CHEST_LOCKED, net.kyori.adventure.sound.Sound.Source.BLOCK, 1.0F, 1.0F); -+ final io.papermc.paper.event.block.BlockLockCheckEvent event = new io.papermc.paper.event.block.BlockLockCheckEvent(block, serverPlayer.getBukkitEntity(), lockedMessage, lockedSound); -+ event.callEvent(); -+ if (event.getResult() == org.bukkit.event.Event.Result.ALLOW) { -+ return true; -+ } else if (event.getResult() == org.bukkit.event.Event.Result.DENY || (!player.isSpectator() && !code.unlocksWith(event.isUsingCustomKeyItemStack() ? org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getKeyItem()) : player.getMainHandItem()))) { -+ if (event.getLockedMessage() != null) { -+ event.getPlayer().sendActionBar(event.getLockedMessage()); -+ } -+ if (event.getLockedSound() != null) { -+ event.getPlayer().playSound(event.getLockedSound()); -+ } -+ return false; -+ } else { -+ return true; -+ } -+ } else { // logic below is replaced by logic above -+ // Paper end - Add BlockLockCheckEvent - if (!player.isSpectator() && !code.unlocksWith(player.getMainHandItem())) { -- player.displayClientMessage(Component.translatable("container.isLocked", displayName), true); -+ player.displayClientMessage(Component.translatable("container.isLocked", displayName), true); // Paper - diff on change - player.playNotifySound(SoundEvents.CHEST_LOCKED, SoundSource.BLOCKS, 1.0F, 1.0F); - return false; - } else { - return true; + public static void sendChestLockedNotifications(Vec3 vec3, Player player, Component component) { ++ // Paper start - BlockLockCheckEvent ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.sendChestLockedNotifications(vec3)) { ++ return; ++ } ++ // Paper end - BlockLockCheckEvent + Level level = player.level(); +- player.displayClientMessage(Component.translatable("container.isLocked", component), true); ++ player.displayClientMessage(Component.translatable("container.isLocked", component), true); // Paper - diff on change + if (!level.isClientSide()) { +- level.playSound(null, vec3.x(), vec3.y(), vec3.z(), SoundEvents.CHEST_LOCKED, SoundSource.BLOCKS, 1.0F, 1.0F); ++ level.playSound(null, vec3.x(), vec3.y(), vec3.z(), SoundEvents.CHEST_LOCKED, SoundSource.BLOCKS, 1.0F, 1.0F); // Paper - diff on change } -+ } // Paper - Add BlockLockCheckEvent } - public boolean isLocked() { -@@ -165,4 +_,12 @@ +@@ -170,4 +_,12 @@ output.discard("lock"); output.discard("Items"); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch index 50562fa92e2b..74e7cf991841 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch @@ -232,8 +232,8 @@ @Override public @Nullable AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { -- return BaseContainerBlockEntity.canUnlock(player, this.lockKey, this.getDisplayName()) -+ return BaseContainerBlockEntity.canUnlock(player, this.lockKey, this.getDisplayName(), this) // Paper - Add BlockLockCheckEvent - ? new BeaconMenu(containerId, playerInventory, this.dataAccess, ContainerLevelAccess.create(this.level, this.getBlockPos())) - : null; - } +- if (this.lockKey.canUnlock(player)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockLockCheckEvent(this, this.lockKey, this.getDisplayName(), player)) { // Paper - Call BlockLockCheckEvent + return new BeaconMenu(containerId, playerInventory, this.dataAccess, ContainerLevelAccess.create(this.level, this.getBlockPos())); + } else { + BaseContainerBlockEntity.sendChestLockedNotifications(this.getBlockPos().getCenter(), player, this.getDisplayName()); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch index e2410f2e654c..587d8177a4e8 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -@@ -113,4 +_,13 @@ +@@ -114,4 +_,13 @@ output.discard("LootTable"); output.discard("LootTableSeed"); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch index f6e2f0cfa70c..153ca98175e9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java +++ b/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java -@@ -108,6 +_,15 @@ - @Override - public CompoundTag applyFix(CompoundTag tag) { +@@ -114,6 +_,15 @@ + } + int dataVersion = NbtUtils.getDataVersion(tag); + // CraftBukkit start + if (dataVersion < 1466) { @@ -16,7 +16,7 @@ if (dataVersion < 1493) { tag = DataFixTypes.CHUNK.update(this.dataFixer, tag, dataVersion, 1493); if (tag.getCompound("Level").flatMap(compoundTag -> compoundTag.getBoolean("hasLegacyStructureData")).orElse(false)) { -@@ -250,17 +_,18 @@ +@@ -258,17 +_,18 @@ } public static Supplier getLegacyTagFixer(ResourceKey level, Supplier<@Nullable DimensionDataStorage> storage, DataFixer dataFixer) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 6a3e0da1f602..d2b65570fea2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -17,6 +17,7 @@ import io.papermc.paper.adventure.PaperAdventure; import io.papermc.paper.connection.HorriblePlayerLoginEventHack; import io.papermc.paper.connection.PlayerConnection; +import io.papermc.paper.event.block.BlockLockCheckEvent; import io.papermc.paper.event.connection.PlayerConnectionValidateLoginEvent; import io.papermc.paper.event.entity.ItemTransportingEntityValidateTargetEvent; import io.papermc.paper.event.player.PlayerBedFailEnterEvent; @@ -33,6 +34,7 @@ import net.minecraft.util.Unit; import net.minecraft.world.Container; import net.minecraft.world.InteractionHand; +import net.minecraft.world.LockCode; import net.minecraft.world.attribute.EnvironmentAttributes; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageTypes; @@ -64,6 +66,7 @@ import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.SignBlockEntity; import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; import net.minecraft.world.level.gamerules.GameRule; @@ -2239,4 +2242,47 @@ public static GameRuleSetResult handleGameRuleSet(GameRule<@NotNull T> ru public record GameRuleSetResult(T value, boolean cancelled) { } + + private static BlockLockCheckEvent LAST_BLOCK_LOCK_CHECK_EVENT = null; + + public static boolean callBlockLockCheckEvent( + BlockEntity blockEntity, + LockCode code, + Component displayName, + net.minecraft.world.entity.player.Player p + ) { + if (p instanceof net.minecraft.server.level.ServerPlayer player + && blockEntity != null + && blockEntity.getLevel() != null + && blockEntity.getLevel().getBlockEntity(blockEntity.getBlockPos()) == blockEntity) { + final org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(blockEntity.getLevel(), blockEntity.getBlockPos()); + net.kyori.adventure.text.Component lockedMessage = net.kyori.adventure.text.Component.translatable("container.isLocked", io.papermc.paper.adventure.PaperAdventure.asAdventure(displayName)); + net.kyori.adventure.sound.Sound lockedSound = net.kyori.adventure.sound.Sound.sound(org.bukkit.Sound.BLOCK_CHEST_LOCKED, net.kyori.adventure.sound.Sound.Source.BLOCK, 1.0F, 1.0F); + final io.papermc.paper.event.block.BlockLockCheckEvent event = new io.papermc.paper.event.block.BlockLockCheckEvent(block, player.getBukkitEntity(), lockedMessage, lockedSound); + event.callEvent(); + if (event.getResult() == org.bukkit.event.Event.Result.ALLOW) { + return true; + } else if (event.getResult() == org.bukkit.event.Event.Result.DENY || !code.canUnlock(player, event.isUsingCustomKeyItemStack() ? org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getKeyItem()) : player.getMainHandItem())) { + LAST_BLOCK_LOCK_CHECK_EVENT = event; + return false; + } + } + // Shouldn't happen + return false; + } + + public static boolean sendChestLockedNotifications(Vec3 pos) { + if (LAST_BLOCK_LOCK_CHECK_EVENT != null) { + final io.papermc.paper.event.block.BlockLockCheckEvent event = LAST_BLOCK_LOCK_CHECK_EVENT; + LAST_BLOCK_LOCK_CHECK_EVENT = null; + if (event.getLockedMessage() != null) { + event.getPlayer().sendActionBar(event.getLockedMessage()); + } + if (event.getLockedSound() != null) { + event.getPlayer().getWorld().playSound(event.getLockedSound(), pos.x(), pos.y(), pos.z()); + } + return true; + } + return false; + } } diff --git a/todo-snapshot.txt b/todo-snapshot.txt index 2d9c445e66f8..b2a62d8933e0 100644 --- a/todo-snapshot.txt +++ b/todo-snapshot.txt @@ -9,3 +9,5 @@ - PatrolSpawner: Paper start day config is overriding timeline environment attribute - 1.21.11-pre1: - Dropped Player.java hunks for PlayerClientLoadedWorldEvent +- 1.21.11-pre2: + - Review BlockLockCheckEvent changes From fd3cc3b7079d745745e5917cce6e34775ebef305 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 21 Nov 2025 10:15:10 -0700 Subject: [PATCH 094/112] Disable oldPaperCommit --- paper-server/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 8ef35fef2864..5a4033bb78a9 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -41,7 +41,7 @@ paperweight { ) updatingMinecraft { - oldPaperCommit = "c82b438b5b4ea0b230439b8e690e34708cd11ab3" + // oldPaperCommit = "c82b438b5b4ea0b230439b8e690e34708cd11ab3" } } From 0d604a5aaf77424fbb70709d53a959bfa7d5cfae Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 21 Nov 2025 10:21:29 -0700 Subject: [PATCH 095/112] Fix chests without locks being locked --- .../java/org/bukkit/craftbukkit/event/CraftEventFactory.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index d2b65570fea2..2e5623020b42 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -2267,8 +2267,7 @@ public static boolean callBlockLockCheckEvent( return false; } } - // Shouldn't happen - return false; + return true; } public static boolean sendChestLockedNotifications(Vec3 pos) { From 5d5a4ff0a3b660805bbda02ba9bf2927dbfefbc9 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Fri, 21 Nov 2025 20:17:37 +0100 Subject: [PATCH 096/112] update parchment --- paper-server/build.gradle.kts | 2 +- .../block/entity/BaseContainerBlockEntity.java.patch | 12 ++++++------ .../structure/LegacyStructureDataHandler.java.patch | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 5a4033bb78a9..22be545e6ea8 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:1.21.11-pre2+build.1") + mache("io.papermc:mache:1.21.11-pre2+build.2") paperclip("io.papermc:paperclip:3.0.3") } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch index 7e9e57263964..1c321829b731 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch @@ -8,18 +8,18 @@ + return org.bukkit.craftbukkit.event.CraftEventFactory.callBlockLockCheckEvent(this, this.lockKey, this.getDisplayName(), player); // Paper - Call BlockLockCheckEvent } - public static void sendChestLockedNotifications(Vec3 vec3, Player player, Component component) { + public static void sendChestLockedNotifications(Vec3 pos, Player player, Component displayName) { + // Paper start - BlockLockCheckEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.sendChestLockedNotifications(vec3)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.sendChestLockedNotifications(pos)) { + return; + } + // Paper end - BlockLockCheckEvent Level level = player.level(); -- player.displayClientMessage(Component.translatable("container.isLocked", component), true); -+ player.displayClientMessage(Component.translatable("container.isLocked", component), true); // Paper - diff on change +- player.displayClientMessage(Component.translatable("container.isLocked", displayName), true); ++ player.displayClientMessage(Component.translatable("container.isLocked", displayName), true); // Paper - diff on change if (!level.isClientSide()) { -- level.playSound(null, vec3.x(), vec3.y(), vec3.z(), SoundEvents.CHEST_LOCKED, SoundSource.BLOCKS, 1.0F, 1.0F); -+ level.playSound(null, vec3.x(), vec3.y(), vec3.z(), SoundEvents.CHEST_LOCKED, SoundSource.BLOCKS, 1.0F, 1.0F); // Paper - diff on change +- level.playSound(null, pos.x(), pos.y(), pos.z(), SoundEvents.CHEST_LOCKED, SoundSource.BLOCKS, 1.0F, 1.0F); ++ level.playSound(null, pos.x(), pos.y(), pos.z(), SoundEvents.CHEST_LOCKED, SoundSource.BLOCKS, 1.0F, 1.0F); // Paper - diff on change } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch index 153ca98175e9..50db0210b37d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java +++ b/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java -@@ -114,6 +_,15 @@ +@@ -116,6 +_,15 @@ } int dataVersion = NbtUtils.getDataVersion(tag); @@ -16,7 +16,7 @@ if (dataVersion < 1493) { tag = DataFixTypes.CHUNK.update(this.dataFixer, tag, dataVersion, 1493); if (tag.getCompound("Level").flatMap(compoundTag -> compoundTag.getBoolean("hasLegacyStructureData")).orElse(false)) { -@@ -258,17 +_,18 @@ +@@ -260,17 +_,18 @@ } public static Supplier getLegacyTagFixer(ResourceKey level, Supplier<@Nullable DimensionDataStorage> storage, DataFixer dataFixer) { From 5de53da55b1d6fc61e48b45ede10f621d887f5e8 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Fri, 21 Nov 2025 20:27:10 +0100 Subject: [PATCH 097/112] skip SpearStatus types in memory keys rewriter and account for nested classes --- .../src/main/java/org/bukkit/entity/memory/MemoryKey.java | 2 -- .../generator/rewriter/types/simple/MemoryKeyRewriter.java | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java b/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java index a895e6c68bfd..dc5ebe7cb492 100644 --- a/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java +++ b/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java @@ -125,8 +125,6 @@ public Class getMemoryClass() { public static final MemoryKey SPEAR_FLEEING_TIME = new MemoryKey<>(NamespacedKey.minecraft("spear_fleeing_time"), Integer.class); - // public static final MemoryKey SPEAR_STATUS = new MemoryKey<>(NamespacedKey.minecraft("spear_status"), SpearStatus.class); // TODO - snapshot: SpearStatus API - public static final MemoryKey TEMPTATION_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("temptation_cooldown_ticks"), Integer.class); public static final MemoryKey TIME_TRYING_TO_REACH_ADMIRE_ITEM = new MemoryKey<>(NamespacedKey.minecraft("time_trying_to_reach_admire_item"), Integer.class); diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java index dad0cefa24b0..265c6f432e18 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java @@ -16,6 +16,7 @@ import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.ai.behavior.PositionTracker; +import net.minecraft.world.entity.ai.behavior.SpearAttack; import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities; import net.minecraft.world.entity.ai.memory.WalkTarget; @@ -46,6 +47,7 @@ public MemoryKeyRewriter() { NearestVisibleLivingEntities.class, WalkTarget.class, PositionTracker.class, + SpearAttack.SpearStatus.class, Path.class, DamageSource.class, Vec3.class, @@ -110,7 +112,7 @@ protected String rewriteFieldValue(Holder.Reference> referen this.registryEntry.apiClass().getSimpleName(), NamespacedKey.class.getSimpleName(), quoted(reference.key().identifier().getPath()), - this.apiMemoryType.getSimpleName() // assume the type is already import (see above in rewriteFieldType) + io.papermc.typewriter.util.ClassHelper.retrieveFullNestedName(this.apiMemoryType) // assume the type is already imported (see above in rewriteFieldType) ); } } From ebbffeadc1835941b81d171212ae9db6bed12c4b Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Fri, 21 Nov 2025 20:45:33 +0100 Subject: [PATCH 098/112] update dependencies for the generator --- paper-generator/build.gradle.kts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/paper-generator/build.gradle.kts b/paper-generator/build.gradle.kts index b520750adb69..d305a18dc35e 100644 --- a/paper-generator/build.gradle.kts +++ b/paper-generator/build.gradle.kts @@ -23,10 +23,10 @@ dependencies { implementation("io.papermc.typewriter:typewriter:1.0.1") { isTransitive = false // paper-api already have everything } - implementation("info.picocli:picocli:4.7.6") - implementation("io.github.classgraph:classgraph:4.8.47") - implementation("org.jetbrains:annotations:26.0.1") - testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") + implementation("info.picocli:picocli:4.7.7") + implementation("io.github.classgraph:classgraph:4.8.179") + implementation("org.jetbrains:annotations:26.0.2") + testImplementation("org.junit.jupiter:junit-jupiter:5.12.2") testRuntimeOnly("org.junit.platform:junit-platform-launcher") serverRuntimeClasspath(project(":paper-server", "runtimeConfiguration")) From d81b1ddc9eb412a87aa760b0accc1e60833f2829 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 21 Nov 2025 15:58:10 -0700 Subject: [PATCH 099/112] Add back PlayerClientLoadedWorldEvent call --- .../ServerGamePacketListenerImpl.java.patch | 23 +++++++++++++++++++ todo-snapshot.txt | 2 -- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 607d72744841..3c247a56ed66 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -2581,6 +2581,29 @@ if (!this.receivedMovementThisTick) { this.player.setKnownMovement(Vec3.ZERO); } +@@ -2130,13 +_,21 @@ + } + + public boolean hasClientLoaded() { +- return !this.waitingForRespawn && this.clientLoadedTimeoutTimer <= 0; ++ return !this.waitingForRespawn; // Paper - Add PlayerLoadedWorldEvent + } + + public void tickClientLoadTimeout() { + if (this.clientLoadedTimeoutTimer > 0) { + this.clientLoadedTimeoutTimer--; + } ++ // Paper start - Add PlayerLoadedWorldEvent ++ if (this.clientLoadedTimeoutTimer <= 0) { ++ this.waitingForRespawn = false; ++ ++ final io.papermc.paper.event.player.PlayerClientLoadedWorldEvent event = new io.papermc.paper.event.player.PlayerClientLoadedWorldEvent((org.bukkit.craftbukkit.entity.CraftPlayer) getBukkitEntity(), true); ++ event.callEvent(); ++ } ++ // Paper end - Add PlayerLoadedWorldEvent + } + + private void markClientLoaded() { @@ -2156,4 +_,80 @@ interface EntityInteraction { InteractionResult run(ServerPlayer player, Entity entity, InteractionHand hand); diff --git a/todo-snapshot.txt b/todo-snapshot.txt index b2a62d8933e0..bb6f584f5b85 100644 --- a/todo-snapshot.txt +++ b/todo-snapshot.txt @@ -7,7 +7,5 @@ - Add back array storage for game rules in GameRuleMap? - 25w45a: - PatrolSpawner: Paper start day config is overriding timeline environment attribute -- 1.21.11-pre1: - - Dropped Player.java hunks for PlayerClientLoadedWorldEvent - 1.21.11-pre2: - Review BlockLockCheckEvent changes From f070245058ba24ec3efd025439ecd430b141d0af Mon Sep 17 00:00:00 2001 From: roro1506HD Date: Sat, 22 Nov 2025 00:27:39 +0100 Subject: [PATCH 100/112] Fixes and updates to bed events (#13203) --- .../paper/block/bed/BedEnterAction.java | 56 ++++++++ .../paper/block/bed/BedEnterActionBridge.java | 30 ++++ .../paper/block/bed/BedEnterProblem.java | 63 +++++++++ .../paper/block/bed/BedRuleResult.java | 37 +++++ .../paper/block/bed/BedRuleResultImpl.java | 12 ++ .../papermc/paper/block/bed/package-info.java | 4 + .../event/player/PlayerBedFailEnterEvent.java | 40 ++++-- paper-api/src/main/java/org/bukkit/World.java | 16 ++- .../event/player/PlayerBedEnterEvent.java | 53 ++++--- .../server/level/ServerPlayer.java.patch | 12 +- .../ServerGamePacketListenerImpl.java.patch | 2 +- .../world/entity/player/Player.java.patch | 7 + .../world/level/block/BedBlock.java.patch | 21 +-- .../block/bed/BedEnterActionBridgeImpl.java | 33 +++++ .../paper/block/bed/BedEnterActionImpl.java | 12 ++ .../paper/block/bed/BedEnterProblemImpl.java | 21 +++ .../org/bukkit/craftbukkit/CraftWorld.java | 4 +- .../craftbukkit/event/CraftEventFactory.java | 132 +++++++++++++++--- ...permc.paper.block.bed.BedEnterActionBridge | 1 + todo-snapshot.txt | 1 + 20 files changed, 488 insertions(+), 69 deletions(-) create mode 100644 paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterAction.java create mode 100644 paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridge.java create mode 100644 paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterProblem.java create mode 100644 paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResult.java create mode 100644 paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResultImpl.java create mode 100644 paper-api/src/main/java/io/papermc/paper/block/bed/package-info.java create mode 100644 paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridgeImpl.java create mode 100644 paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterActionImpl.java create mode 100644 paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterProblemImpl.java create mode 100644 paper-server/src/main/resources/META-INF/services/io.papermc.paper.block.bed.BedEnterActionBridge diff --git a/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterAction.java b/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterAction.java new file mode 100644 index 000000000000..459a433dd763 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterAction.java @@ -0,0 +1,56 @@ +package io.papermc.paper.block.bed; + +import net.kyori.adventure.text.Component; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.Nullable; + +/** + * An action type that represents the action that will happen after + * {@link org.bukkit.event.player.PlayerBedEnterEvent} and that is + * happening during {@link io.papermc.paper.event.player.PlayerBedFailEnterEvent} + */ +@ApiStatus.NonExtendable +@ApiStatus.Experimental +public interface BedEnterAction { + + /** + * Gets if the player is allowed to sleep in the bed. + * This can be {@link BedRuleResult#ALLOWED} at the same time as {@link #canSetSpawn()} + *

+ * It is advised to check for {@link BedEnterProblem}s first, as if it returns anything but {@code null} + * the bed interaction is prevented + * + * @return whether the player is allowed to sleep + */ + BedRuleResult canSleep(); + + /** + * Gets if the player is allowed to save its spawn point in the bed. + * This can be {@link BedRuleResult#ALLOWED} at the same time as {@link #canSleep()} + *

+ * It is advised to check for {@link BedEnterProblem}s first, as if it returns anything but {@code null} + * the bed interaction is prevented + * + * @return whether the player is allowed to save its spawn point + */ + BedRuleResult canSetSpawn(); + + /** + * A problem is an issue that prevents the player from sleeping and from saving its spawn point. + * No problem being found doesn't mean the player successfully slept or set its spawn point, + * see {@link #canSleep()} and {@link #canSetSpawn()} for individual successes + * + * @return any of {@link BedEnterProblem}s if one is found, otherwise {@code null} + */ + @Nullable + BedEnterProblem problem(); + + /** + * Returns the default error message to be shown as an actionbar message to the player + * + * @return the error message + */ + @Nullable + Component errorMessage(); + +} diff --git a/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridge.java b/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridge.java new file mode 100644 index 000000000000..38f9d2ed110b --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridge.java @@ -0,0 +1,30 @@ +package io.papermc.paper.block.bed; + +import java.util.Optional; +import java.util.ServiceLoader; +import org.jetbrains.annotations.ApiStatus; + +/** + * @hidden + */ +@ApiStatus.Internal +public interface BedEnterActionBridge { + + static BedEnterActionBridge instance() { + final class Holder { + static final Optional INSTANCE = ServiceLoader.load(BedEnterActionBridge.class, BedEnterActionBridge.class.getClassLoader()).findFirst(); + } + return Holder.INSTANCE.orElseThrow(); + } + + BedEnterProblem createTooFarAwayProblem(); + + BedEnterProblem createObstructedProblem(); + + BedEnterProblem createNotSafeProblem(); + + BedEnterProblem createExplosionProblem(); + + BedEnterProblem createOtherProblem(); + +} diff --git a/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterProblem.java b/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterProblem.java new file mode 100644 index 000000000000..eb8135c8f84b --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterProblem.java @@ -0,0 +1,63 @@ +package io.papermc.paper.block.bed; + +import net.kyori.adventure.text.Component; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.Nullable; + +/** + * Represents a problem that prevents a player from continuing + * the sleeping process, preventing it from sleeping and from setting + * its spawn point + */ +@ApiStatus.NonExtendable +@ApiStatus.Experimental +public interface BedEnterProblem { + + /** + * Happens when the bed is too far away from the player. + * Makes no explosion and has an error message + * + * @see #errorMessage() + */ + BedEnterProblem TOO_FAR_AWAY = BedEnterActionBridge.instance().createTooFarAwayProblem(); + + /** + * Happens when the bed has blocks one block above it. + * Makes no explosion and has an error message + * + * @see #errorMessage() + */ + BedEnterProblem OBSTRUCTED = BedEnterActionBridge.instance().createObstructedProblem(); + + /** + * Happens when there are monsters in a 16x10x16 box centered on the bed's head + * and the player is not in creative mode. Makes no explosion and has an error message + * + * @see #errorMessage() + */ + BedEnterProblem NOT_SAFE = BedEnterActionBridge.instance().createNotSafeProblem(); + + /** + * Happens when the bed is set to explode. This is defined in the environment attributes of the world. + * This doesn't have a fixed error message, see {@link BedEnterAction#errorMessage()} + */ + BedEnterProblem EXPLOSION = BedEnterActionBridge.instance().createExplosionProblem(); + + /** + * Happens when a player tries to sleep when an invalid state, for example when a player tries + * to sleep but is already sleeping or is dead. + * This doesn't have an error message at all, the interaction is simply discarded + */ + BedEnterProblem OTHER = BedEnterActionBridge.instance().createOtherProblem(); + + /** + * Returns the error message associated with this problem, if any. + * This component is sent to the client as an actionbar message + * when this problem occur + * + * @return the error message + */ + @Nullable + Component errorMessage(); + +} diff --git a/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResult.java b/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResult.java new file mode 100644 index 000000000000..ebcb8cdf7bb6 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResult.java @@ -0,0 +1,37 @@ +package io.papermc.paper.block.bed; + +import org.jetbrains.annotations.ApiStatus; + +/** + * Represents the result of a bed rule during {@link org.bukkit.event.player.PlayerBedEnterEvent} + * and {@link io.papermc.paper.event.player.PlayerBedFailEnterEvent}. Bed rules are responsible + * for allowing players to sleep and to set their spawn point + */ +@ApiStatus.Experimental +public sealed interface BedRuleResult permits BedRuleResultImpl { + + /** + * Used when the bed rule is allowed + */ + BedRuleResult ALLOWED = new BedRuleResultImpl(true); + + /** + * Used when the bed rule is denied due to there + * being too much light. This is the case during + * daytime without thunderstorms + */ + BedRuleResult TOO_MUCH_LIGHT = new BedRuleResultImpl(false); + + /** + * Used when the bed rule is set to always be denied + */ + BedRuleResult NEVER = new BedRuleResultImpl(false); + + /** + * Returns {@code true} if this result is a success + * + * @return whether this result is a success + */ + boolean success(); + +} diff --git a/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResultImpl.java b/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResultImpl.java new file mode 100644 index 000000000000..42edaa3223f4 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResultImpl.java @@ -0,0 +1,12 @@ +package io.papermc.paper.block.bed; + +import org.jetbrains.annotations.ApiStatus; + +/** + * @hidden + */ +@ApiStatus.Internal +record BedRuleResultImpl( + boolean success +) implements BedRuleResult { +} diff --git a/paper-api/src/main/java/io/papermc/paper/block/bed/package-info.java b/paper-api/src/main/java/io/papermc/paper/block/bed/package-info.java new file mode 100644 index 000000000000..d7f5cbbb3e94 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/block/bed/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package io.papermc.paper.block.bed; + +import org.jspecify.annotations.NullMarked; diff --git a/paper-api/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java b/paper-api/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java index c30873dfbf98..f20436a91b75 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java @@ -1,5 +1,6 @@ package io.papermc.paper.event.player; +import io.papermc.paper.block.bed.BedEnterAction; import net.kyori.adventure.text.Component; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -17,24 +18,41 @@ public class PlayerBedFailEnterEvent extends PlayerEvent implements Cancellable private final FailReason failReason; private final Block bed; + private final BedEnterAction enterAction; private boolean willExplode; private @Nullable Component message; private boolean cancelled; @ApiStatus.Internal - public PlayerBedFailEnterEvent(final Player player, final FailReason failReason, final Block bed, final boolean willExplode, final @Nullable Component message) { + public PlayerBedFailEnterEvent(final Player player, final FailReason failReason, final Block bed, final boolean willExplode, final @Nullable Component message, BedEnterAction enterAction) { super(player); this.failReason = failReason; this.bed = bed; + this.enterAction = enterAction; this.willExplode = willExplode; this.message = message; } + /** + * @deprecated This enum has been replaced with a system that better + * represents how beds work. See {@link #enterAction} + */ + @ApiStatus.Obsolete(since = "1.21.11") public FailReason getFailReason() { return this.failReason; } + /** + * This describes the default outcome of this event. + * + * @return the action representing the default outcome of this event + */ + @ApiStatus.Experimental + public BedEnterAction enterAction() { + return this.enterAction; + } + public Block getBed() { return this.bed; } @@ -80,14 +98,17 @@ public static HandlerList getHandlerList() { return HANDLER_LIST; } + /** + * @deprecated Enums no longer represents reliably how beds work and fail. This has been + * replaced with {@link BedEnterAction} that better fits the new beds + */ + @ApiStatus.Obsolete(since = "1.21.11") public enum FailReason { /** * The world doesn't allow sleeping (ex. Nether or The End). Entering - * the bed is prevented and the bed explodes. - * - * @deprecated TODO - snapshot - no longer exists in vanilla + * the bed is prevented but the bed doesn't explode. When the bed + * explodes, {@link #EXPLOSION} is used instead. */ - @Deprecated(since = "1.21.11") NOT_POSSIBLE_HERE, /** * Entering the bed is prevented due to it not being night nor @@ -96,10 +117,7 @@ public enum FailReason { * If the event is forcefully allowed during daytime, the player will * enter the bed (and set its bed location), but might get immediately * thrown out again. - * - * @deprecated TODO - snapshot - no longer exists in vanilla */ - @Deprecated(since = "1.21.11") NOT_POSSIBLE_NOW, /** * Entering the bed is prevented due to the player being too far away. @@ -116,6 +134,10 @@ public enum FailReason { /** * Entering the bed is prevented due to there being monsters nearby. */ - NOT_SAFE + NOT_SAFE, + /** + * Entering the bed is prevented and the bed explodes. + */ + EXPLOSION } } diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index 54c0d40c8bee..698f730efe1c 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -43,6 +43,7 @@ import org.bukkit.util.RayTraceResult; import org.bukkit.util.StructureSearchResult; import org.bukkit.util.Vector; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -2796,10 +2797,8 @@ default double getHumidity(int x, int z) { /** * Gets if this world is natural. - * - * When false, compasses spin randomly, and using a bed to set the respawn - * point or sleep, is disabled. When true, nether portals can spawn - * zombified piglins. + *

+ * When false, the moon is not visible and eyeblossoms do not open/close * * @return true if world is natural * @deprecated replaced by the gameplay/eyeblossom_open and gameplay/creaking_active environment attributes @@ -2809,12 +2808,15 @@ default double getHumidity(int x, int z) { /** * Gets if beds work in this world. - * - * A non-working bed will blow up when trying to sleep. {@link #isNatural()} - * defines if a bed can be used to set spawn point. + *

+ * A non-working bed can blow up when trying to sleep, but that may + * not always be the case. * * @return true if beds work in this world + * @deprecated Due to 1.21.11 beds changes, a boolean no longer + * represents if they work. There is no replacement API yet */ + @ApiStatus.Obsolete(since = "1.21.11") public boolean isBedWorks(); /** diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java index 8b68c9fe2709..5119df1e31c8 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.player; -import org.bukkit.World; +import io.papermc.paper.block.bed.BedEnterAction; +import io.papermc.paper.block.bed.BedRuleResult; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; @@ -17,19 +18,15 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable { private final Block bed; private final BedEnterResult bedEnterResult; + private final @NotNull BedEnterAction enterAction; private Result useBed = Result.DEFAULT; @ApiStatus.Internal - public PlayerBedEnterEvent(@NotNull Player player, @NotNull Block bed, @NotNull BedEnterResult bedEnterResult) { + public PlayerBedEnterEvent(@NotNull Player player, @NotNull Block bed, @NotNull BedEnterResult bedEnterResult, @NotNull BedEnterAction enterAction) { super(player); this.bed = bed; this.bedEnterResult = bedEnterResult; - } - - @ApiStatus.Internal - @Deprecated(since = "1.13.2", forRemoval = true) - public PlayerBedEnterEvent(@NotNull Player player, @NotNull Block bed) { - this(player, bed, BedEnterResult.OK); + this.enterAction = enterAction; } /** @@ -46,12 +43,25 @@ public Block getBed() { * This describes the default outcome of this event. * * @return the bed enter result representing the default outcome of this event + * @deprecated This enum has been replaced with a system that better + * represents how beds work. See {@link #enterAction} */ @NotNull + @ApiStatus.Obsolete(since = "1.21.11") public BedEnterResult getBedEnterResult() { return this.bedEnterResult; } + /** + * This describes the default outcome of this event. + * + * @return the action representing the default outcome of this event + */ + @ApiStatus.Experimental + public @NotNull BedEnterAction enterAction() { + return this.enterAction; + } + /** * This controls the action to take with the bed that was clicked on. *

@@ -100,7 +110,7 @@ public void setUseBed(@NotNull Result useBed) { */ @Override public boolean isCancelled() { - return this.useBed == Result.DENY || this.useBed == Result.DEFAULT && this.bedEnterResult != BedEnterResult.OK; + return this.useBed == Result.DENY || this.useBed == Result.DEFAULT && this.enterAction.canSleep() != BedRuleResult.ALLOWED; } /** @@ -126,23 +136,23 @@ public static HandlerList getHandlerList() { /** * Represents the default possible outcomes of this event. + * @deprecated Enums no longer represents reliably how beds work and fail. This has been + * replaced with {@link BedEnterAction} that better fits the new beds */ + @ApiStatus.Obsolete(since = "1.21.11") public enum BedEnterResult { /** * The player will enter the bed. */ OK, /** - * The world doesn't allow sleeping or saving the spawn point (eg, - * Nether, The End or Custom Worlds). This is based on - * {@link World#isBedWorks()} and {@link World#isNatural()}. + * The world doesn't allow sleeping (eg, Nether, The End or Custom Worlds), but + * saving the spawn point may still be allowed. See {@link com.destroystokyo.paper.event.player.PlayerSetSpawnEvent}. + * for spawn point changes. This is only called when sleeping isn't allowed and the bed + * doesn't explode. When the bed explodes, {@link #EXPLOSION} is called instead. *

- * Entering the bed is prevented and if {@link World#isBedWorks()} is - * {@code false} then the bed explodes. - * - * @deprecated TODO - snapshot - no longer exists in vanilla + * Entering the bed is prevented */ - @Deprecated(since = "1.21.11") NOT_POSSIBLE_HERE, /** * Entering the bed is prevented due to it not being night nor @@ -151,10 +161,7 @@ public enum BedEnterResult { * If the event is forcefully allowed during daytime, the player will * enter the bed (and set its bed location), but might get immediately * thrown out again. - * - * @deprecated TODO - snapshot - no longer exists in vanilla */ - @Deprecated(since = "1.21.11") NOT_POSSIBLE_NOW, /** * Entering the bed is prevented due to the player being too far away. @@ -171,6 +178,10 @@ public enum BedEnterResult { /** * Entering the bed is prevented due to there being some other problem. */ - OTHER_PROBLEM; + OTHER_PROBLEM, + /** + * Entering the bed is prevented and the bed explodes. + */ + EXPLOSION; } } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index 1051f772c116..3bb9f5251dd3 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -870,18 +870,24 @@ this.enteredNetherPosition = null; } } -@@ -1161,9 +_,8 @@ +@@ -1161,11 +_,12 @@ this.containerMenu.broadcastChanges(); } - @Override - public Either startSleepInBed(BlockPos bedPos) { - Direction direction = this.level().getBlockState(bedPos).getValue(HorizontalDirectionalBlock.FACING); +- if (!this.isSleeping() && this.isAlive()) { +- BedRule bedRule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, bedPos); + // CraftBukkit start - moved bed result checks from below into separate method + private Either getBedResult(BlockPos bedPos, Direction direction) { - if (!this.isSleeping() && this.isAlive()) { - BedRule bedRule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, bedPos); ++ BedRule bedRule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, bedPos); ++ if (bedRule.explodes()) { ++ return Either.left(Player.BedSleepingProblem.EXPLOSION); ++ } else if (!this.isSleeping() && this.isAlive()) { boolean canSleep = bedRule.canSleep(this.level()); + boolean canSetSpawn = bedRule.canSetSpawn(this.level()); + if (!canSetSpawn && !canSleep) { @@ -1177,7 +_,7 @@ } else { if (canSetSpawn) { diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 3c247a56ed66..b59453759987 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -2597,7 +2597,7 @@ + if (this.clientLoadedTimeoutTimer <= 0) { + this.waitingForRespawn = false; + -+ final io.papermc.paper.event.player.PlayerClientLoadedWorldEvent event = new io.papermc.paper.event.player.PlayerClientLoadedWorldEvent((org.bukkit.craftbukkit.entity.CraftPlayer) getBukkitEntity(), true); ++ final io.papermc.paper.event.player.PlayerClientLoadedWorldEvent event = new io.papermc.paper.event.player.PlayerClientLoadedWorldEvent(this.player.getBukkitEntity(), true); + event.callEvent(); + } + // Paper end - Add PlayerLoadedWorldEvent diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index 108481a5a436..599876ca0f68 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -506,3 +506,10 @@ return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; } } +@@ -2054,5 +_,6 @@ + public static final Player.BedSleepingProblem OBSTRUCTED = new Player.BedSleepingProblem(Component.translatable("block.minecraft.bed.obstructed")); + public static final Player.BedSleepingProblem OTHER_PROBLEM = new Player.BedSleepingProblem(null); + public static final Player.BedSleepingProblem NOT_SAFE = new Player.BedSleepingProblem(Component.translatable("block.minecraft.bed.not_safe")); ++ public static final Player.BedSleepingProblem EXPLOSION = new Player.BedSleepingProblem(null); // Paper - Added to properly handle explosions in bed events + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch index 416739da623a..e84aaa56a922 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch @@ -9,11 +9,11 @@ bedRule.errorMessage().ifPresent(component -> player.displayClientMessage(component, true)); level.removeBlock(pos, false); BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); -@@ -103,22 +_,56 @@ +@@ -103,22 +_,59 @@ level.explode(null, level.damageSources().badRespawnPointExplosion(center), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); return InteractionResult.SUCCESS_SERVER; } else if (state.getValue(OCCUPIED)) { -+ if (!bedRule.explodes()) return this.explodeBed(state, level, pos); // Paper - check explode first ++ if (bedRule.explodes()) return this.explodeBed(state, level, pos); // Paper - check explode first if (!this.kickVillagerOutOfBed(level, pos)) { player.displayClientMessage(Component.translatable("block.minecraft.bed.occupied"), true); } @@ -25,7 +25,11 @@ + final BlockPos finalBlockPos = pos; + // CraftBukkit end player.startSleepInBed(pos).ifLeft(bedSleepingProblem -> { +- if (bedSleepingProblem.message() != null) { + // Paper start - PlayerBedFailEnterEvent ++ if (false && bedSleepingProblem.message() != null) { // Moved down + player.displayClientMessage(bedSleepingProblem.message(), true); + } + if (bedSleepingProblem != null) { + io.papermc.paper.event.player.PlayerBedFailEnterEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBedFailEnterEvent(player, finalBlockPos, bedSleepingProblem); + if (event.isCancelled()) { @@ -35,14 +39,13 @@ + // CraftBukkit start - handling bed explosion from below here + if (event.getWillExplode()) { // Paper - PlayerBedFailEnterEvent + this.explodeBed(finalBlockState, level, finalBlockPos); -+ } else ++ } + // CraftBukkit end - if (bedSleepingProblem.message() != null) { -- player.displayClientMessage(bedSleepingProblem.message(), true); -+ final net.kyori.adventure.text.Component message = event.getMessage(); // Paper - PlayerBedFailEnterEvent -+ if (message != null) player.displayClientMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), true); // Paper - PlayerBedFailEnterEvent - } -+ } // Paper - PlayerBedFailEnterEvent ++ // Paper start - PlayerBedFailEnterEvent ++ final net.kyori.adventure.text.Component message = event.getMessage(); ++ if (message != null) player.displayClientMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), true); ++ } ++ // Paper end - PlayerBedFailEnterEvent }); return InteractionResult.SUCCESS_SERVER; } diff --git a/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridgeImpl.java b/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridgeImpl.java new file mode 100644 index 000000000000..8527db6c2b4a --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridgeImpl.java @@ -0,0 +1,33 @@ +package io.papermc.paper.block.bed; + +import net.minecraft.world.entity.player.Player; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class BedEnterActionBridgeImpl implements BedEnterActionBridge { + + @Override + public BedEnterProblem createTooFarAwayProblem() { + return new BedEnterProblemImpl(Player.BedSleepingProblem.TOO_FAR_AWAY); + } + + @Override + public BedEnterProblem createObstructedProblem() { + return new BedEnterProblemImpl(Player.BedSleepingProblem.OBSTRUCTED); + } + + @Override + public BedEnterProblem createNotSafeProblem() { + return new BedEnterProblemImpl(Player.BedSleepingProblem.NOT_SAFE); + } + + @Override + public BedEnterProblem createExplosionProblem() { + return new BedEnterProblemImpl(Player.BedSleepingProblem.EXPLOSION); + } + + @Override + public BedEnterProblem createOtherProblem() { + return new BedEnterProblemImpl(Player.BedSleepingProblem.OTHER_PROBLEM); + } +} diff --git a/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterActionImpl.java b/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterActionImpl.java new file mode 100644 index 000000000000..b1a2eb96601f --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterActionImpl.java @@ -0,0 +1,12 @@ +package io.papermc.paper.block.bed; + +import net.kyori.adventure.text.Component; +import org.jspecify.annotations.Nullable; + +public record BedEnterActionImpl( + BedRuleResult canSleep, + BedRuleResult canSetSpawn, + @Nullable BedEnterProblem problem, + @Nullable Component errorMessage +) implements BedEnterAction { +} diff --git a/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterProblemImpl.java b/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterProblemImpl.java new file mode 100644 index 000000000000..9782a9e05e33 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterProblemImpl.java @@ -0,0 +1,21 @@ +package io.papermc.paper.block.bed; + +import io.papermc.paper.adventure.PaperAdventure; +import net.kyori.adventure.text.Component; +import net.minecraft.world.entity.player.Player; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +record BedEnterProblemImpl( + Player.BedSleepingProblem vanillaProblem, + @Nullable Component errorMessage +) implements BedEnterProblem { + + BedEnterProblemImpl(Player.BedSleepingProblem vanillaProblem) { + this( + vanillaProblem, + vanillaProblem.message() == null ? null : PaperAdventure.asAdventure(vanillaProblem.message()) + ); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 3f1bf621a283..5d1afba644e0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -57,6 +57,7 @@ import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; +import net.minecraft.world.attribute.BedRule; import net.minecraft.util.NullOps; import net.minecraft.world.attribute.EnvironmentAttributes; import net.minecraft.world.entity.EntitySpawnReason; @@ -1375,7 +1376,8 @@ public boolean isNatural() { @Override public boolean isBedWorks() { - return this.world.environmentAttributes().getDimensionValue(EnvironmentAttributes.BED_RULE).canSleep().test(this.world); // TODO - snapshot - check if canSleep is correct + BedRule bedRule = this.world.environmentAttributes().getDimensionValue(EnvironmentAttributes.BED_RULE); + return !bedRule.explodes() && bedRule.canSleep().test(this.world); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 2e5623020b42..b950465debc2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -11,10 +11,12 @@ import java.util.EnumMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; import io.papermc.paper.adventure.PaperAdventure; +import io.papermc.paper.block.bed.BedEnterProblem; import io.papermc.paper.connection.HorriblePlayerLoginEventHack; import io.papermc.paper.connection.PlayerConnection; import io.papermc.paper.event.block.BlockLockCheckEvent; @@ -297,46 +299,140 @@ public static boolean callPlayerSignOpenEvent(Player player, Sign sign, Side sid return !event.isCancelled(); } - public static PlayerBedFailEnterEvent.FailReason asFailReason(final net.minecraft.world.entity.player.Player.BedSleepingProblem sleepingProblem) { + public static com.mojang.datafixers.util.Pair asFailReason( + final net.minecraft.world.entity.player.Player player, final net.minecraft.world.attribute.BedRule bedRule, final net.minecraft.world.entity.player.Player.BedSleepingProblem sleepingProblem) { + PlayerBedFailEnterEvent.FailReason failReason = null; + io.papermc.paper.block.bed.BedEnterProblem enterProblem = null; + Component errorMessage = sleepingProblem.message(); if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.OTHER_PROBLEM) { - return PlayerBedFailEnterEvent.FailReason.OTHER_PROBLEM; + failReason = PlayerBedFailEnterEvent.FailReason.OTHER_PROBLEM; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.OTHER; } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.NOT_SAFE) { - return PlayerBedFailEnterEvent.FailReason.NOT_SAFE; + failReason = PlayerBedFailEnterEvent.FailReason.NOT_SAFE; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.NOT_SAFE; } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.OBSTRUCTED) { - return PlayerBedFailEnterEvent.FailReason.OBSTRUCTED; + failReason = PlayerBedFailEnterEvent.FailReason.OBSTRUCTED; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.OBSTRUCTED; } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.TOO_FAR_AWAY) { - return PlayerBedFailEnterEvent.FailReason.TOO_FAR_AWAY; + failReason = PlayerBedFailEnterEvent.FailReason.TOO_FAR_AWAY; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.TOO_FAR_AWAY; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.EXPLOSION) { + failReason = PlayerBedFailEnterEvent.FailReason.EXPLOSION; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.EXPLOSION; + errorMessage = bedRule.errorMessage().orElse(null); + } else if (bedRule.canSleep() == net.minecraft.world.attribute.BedRule.Rule.NEVER) { + failReason = PlayerBedFailEnterEvent.FailReason.NOT_POSSIBLE_HERE; + } else if (bedRule.canSleep() == net.minecraft.world.attribute.BedRule.Rule.WHEN_DARK) { + failReason = PlayerBedFailEnterEvent.FailReason.NOT_POSSIBLE_NOW; + } + + if (failReason == null) { + // Don't know what the fail reason is, defaulting to OTHER to prevent server crashes + failReason = PlayerBedFailEnterEvent.FailReason.OTHER_PROBLEM; + enterProblem = BedEnterProblem.OTHER; + } + + return com.mojang.datafixers.util.Pair.of( + failReason, + new io.papermc.paper.block.bed.BedEnterActionImpl( + CraftEventFactory.asBedRuleResult(bedRule.canSleep(), bedRule.canSleep().test(player.level())), + CraftEventFactory.asBedRuleResult(bedRule.canSetSpawn(), bedRule.canSetSpawn().test(player.level())), + enterProblem, + errorMessage == null ? null : io.papermc.paper.adventure.PaperAdventure.asAdventure(errorMessage) + ) + ); + } + + public static io.papermc.paper.block.bed.BedRuleResult asBedRuleResult(net.minecraft.world.attribute.BedRule.Rule rule, boolean value) { + if (rule == net.minecraft.world.attribute.BedRule.Rule.ALWAYS) { + return io.papermc.paper.block.bed.BedRuleResult.ALLOWED; + } else if (rule == net.minecraft.world.attribute.BedRule.Rule.WHEN_DARK) { + if (value) { + return io.papermc.paper.block.bed.BedRuleResult.ALLOWED; + } else { + return io.papermc.paper.block.bed.BedRuleResult.TOO_MUCH_LIGHT; + } + } else if (rule == net.minecraft.world.attribute.BedRule.Rule.NEVER) { + return io.papermc.paper.block.bed.BedRuleResult.NEVER; } - throw new IllegalArgumentException(sleepingProblem.toString()); + throw new IllegalArgumentException(rule.toString()); } public static PlayerBedFailEnterEvent callPlayerBedFailEnterEvent( net.minecraft.world.entity.player.Player player, BlockPos bed, net.minecraft.world.entity.player.Player.BedSleepingProblem bedSleepingProblem) { + net.minecraft.world.attribute.BedRule bedRule = player.level().environmentAttributes().getDimensionValue(EnvironmentAttributes.BED_RULE); + com.mojang.datafixers.util.Pair actionPair = asFailReason(player, bedRule, bedSleepingProblem); final var event = new PlayerBedFailEnterEvent( (org.bukkit.entity.Player) player.getBukkitEntity(), - asFailReason(bedSleepingProblem), + actionPair.getFirst(), org.bukkit.craftbukkit.block.CraftBlock.at(player.level(), bed), - !player.level().environmentAttributes().getDimensionValue(EnvironmentAttributes.BED_RULE).canSleep().test(player.level()), // TODO - snapshot - check if canSleep is correct - io.papermc.paper.adventure.PaperAdventure.asAdventure(bedSleepingProblem.message())); + bedSleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.EXPLOSION, + actionPair.getSecond().errorMessage(), + actionPair.getSecond()); event.callEvent(); return event; } - public static Either callPlayerBedEnterEvent(net.minecraft.world.entity.player.Player player, BlockPos bed, Either nmsBedResult) { - BedEnterResult bedEnterResult = nmsBedResult.mapBoth(sleepingProblem -> { + public static Either callPlayerBedEnterEvent( + net.minecraft.world.entity.player.Player player, BlockPos bed, Either nmsBedResult) { + final net.minecraft.world.attribute.BedRule bedRule = player.level().environmentAttributes().getDimensionValue(EnvironmentAttributes.BED_RULE); + com.mojang.datafixers.util.Pair bedEnterResult = nmsBedResult.mapBoth(sleepingProblem -> { + BedEnterResult enterResult = null; + io.papermc.paper.block.bed.BedEnterProblem enterProblem = null; + Component errorMessage = sleepingProblem.message(); if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.OTHER_PROBLEM) { - return BedEnterResult.OTHER_PROBLEM; + enterResult = BedEnterResult.OTHER_PROBLEM; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.OTHER; } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.NOT_SAFE) { - return BedEnterResult.NOT_SAFE; + enterResult = BedEnterResult.NOT_SAFE; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.NOT_SAFE; } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.OBSTRUCTED) { - return BedEnterResult.OBSTRUCTED; + enterResult = BedEnterResult.OBSTRUCTED; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.OBSTRUCTED; } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.TOO_FAR_AWAY) { - return BedEnterResult.TOO_FAR_AWAY; + enterResult = BedEnterResult.TOO_FAR_AWAY; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.TOO_FAR_AWAY; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.EXPLOSION) { + enterResult = BedEnterResult.EXPLOSION; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.EXPLOSION; + errorMessage = bedRule.errorMessage().orElse(null); + } else if (bedRule.canSleep() == net.minecraft.world.attribute.BedRule.Rule.NEVER) { + enterResult = BedEnterResult.NOT_POSSIBLE_HERE; + } else if (bedRule.canSleep() == net.minecraft.world.attribute.BedRule.Rule.WHEN_DARK) { + enterResult = BedEnterResult.NOT_POSSIBLE_NOW; } - throw new IllegalStateException(); - }, t -> BedEnterResult.OK).map(java.util.function.Function.identity(), java.util.function.Function.identity()); - PlayerBedEnterEvent event = new PlayerBedEnterEvent((Player) player.getBukkitEntity(), CraftBlock.at(player.level(), bed), bedEnterResult); + if (enterResult == null) { + // Don't know what the fail reason is, defaulting to OTHER to prevent server crashes + enterResult = BedEnterResult.OTHER_PROBLEM; + enterProblem = BedEnterProblem.OTHER; + } + + return com.mojang.datafixers.util.Pair.of( + enterResult, + new io.papermc.paper.block.bed.BedEnterActionImpl( + CraftEventFactory.asBedRuleResult(bedRule.canSleep(), bedRule.canSleep().test(player.level())), + CraftEventFactory.asBedRuleResult(bedRule.canSetSpawn(), bedRule.canSetSpawn().test(player.level())), + enterProblem, + errorMessage == null ? null : io.papermc.paper.adventure.PaperAdventure.asAdventure(errorMessage) + ) + ); + }, t -> com.mojang.datafixers.util.Pair.of( + BedEnterResult.OK, + new io.papermc.paper.block.bed.BedEnterActionImpl( + CraftEventFactory.asBedRuleResult(bedRule.canSleep(), bedRule.canSleep().test(player.level())), + CraftEventFactory.asBedRuleResult(bedRule.canSetSpawn(), bedRule.canSetSpawn().test(player.level())), + null, + null + ) + )).map(java.util.function.Function.identity(), java.util.function.Function.identity()); + + PlayerBedEnterEvent event = new PlayerBedEnterEvent( + (Player) player.getBukkitEntity(), + CraftBlock.at(player.level(), bed), + bedEnterResult.getFirst(), + bedEnterResult.getSecond() + ); Bukkit.getServer().getPluginManager().callEvent(event); Result result = event.useBed(); diff --git a/paper-server/src/main/resources/META-INF/services/io.papermc.paper.block.bed.BedEnterActionBridge b/paper-server/src/main/resources/META-INF/services/io.papermc.paper.block.bed.BedEnterActionBridge new file mode 100644 index 000000000000..540fa11b068c --- /dev/null +++ b/paper-server/src/main/resources/META-INF/services/io.papermc.paper.block.bed.BedEnterActionBridge @@ -0,0 +1 @@ +io.papermc.paper.block.bed.BedEnterActionBridgeImpl diff --git a/todo-snapshot.txt b/todo-snapshot.txt index bb6f584f5b85..d2ac52c0a9e4 100644 --- a/todo-snapshot.txt +++ b/todo-snapshot.txt @@ -1,5 +1,6 @@ - Check ServerPlayer bed diffs - anything marked with 'TODO - snapshot' +- Environment attributes API - 25w43a: - Connection, ServerConnectionListener - dropped diff for thread pool config (fields gone) - 25w44a: From 7efb86a1f05307bd6ca028808a92273e15680b73 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 22 Nov 2025 20:31:58 +0100 Subject: [PATCH 101/112] hide internal classes --- .../paper/block/bed/BedEnterActionBridge.java | 5 +---- .../paper/block/bed/BedRuleResultImpl.java | 3 --- .../paper/datacomponent/item/AttackRange.java | 12 ++++------- .../event/player/PlayerBedEnterEvent.java | 9 +++++---- .../world/level/block/BedBlock.java.patch | 20 ++++++++++--------- 5 files changed, 21 insertions(+), 28 deletions(-) diff --git a/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridge.java b/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridge.java index 38f9d2ed110b..e2e4db862f89 100644 --- a/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridge.java +++ b/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridge.java @@ -4,11 +4,8 @@ import java.util.ServiceLoader; import org.jetbrains.annotations.ApiStatus; -/** - * @hidden - */ @ApiStatus.Internal -public interface BedEnterActionBridge { +interface BedEnterActionBridge { static BedEnterActionBridge instance() { final class Holder { diff --git a/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResultImpl.java b/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResultImpl.java index 42edaa3223f4..559049bd2c29 100644 --- a/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResultImpl.java +++ b/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResultImpl.java @@ -2,9 +2,6 @@ import org.jetbrains.annotations.ApiStatus; -/** - * @hidden - */ @ApiStatus.Internal record BedRuleResultImpl( boolean success diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/AttackRange.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/AttackRange.java index 4e405d83573f..3eefaf5dd558 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/AttackRange.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/AttackRange.java @@ -22,20 +22,16 @@ static Builder attackRange() { } @Contract(pure = true) - @Range(from = 0, to = 64) - float minReach(); + @Range(from = 0, to = 64) float minReach(); @Contract(pure = true) - @Range(from = 0, to = 64) - float maxReach(); + @Range(from = 0, to = 64) float maxReach(); @Contract(pure = true) - @Range(from = 0, to = 1) - float hitboxMargin(); + @Range(from = 0, to = 1) float hitboxMargin(); @Contract(pure = true) - @Range(from = 0, to = 2) - float mobFactor(); + @Range(from = 0, to = 2) float mobFactor(); /** * Builder for {@link AttackRange}. diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java index 5119df1e31c8..5a5d1ca16f9c 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java @@ -66,7 +66,7 @@ public BedEnterResult getBedEnterResult() { * This controls the action to take with the bed that was clicked on. *

* In case of {@link Result#DEFAULT}, the default outcome is described by - * {@link #getBedEnterResult()}. + * {@link #enterAction()}. * * @return the action to take with the interacted bed * @see #setUseBed(Result) @@ -80,13 +80,13 @@ public Result useBed() { * Sets the action to take with the interacted bed. *

* {@link Result#ALLOW} will result in the player sleeping, regardless of - * the default outcome described by {@link #getBedEnterResult()}. + * the default outcome described by {@link #enterAction()}. *
* {@link Result#DENY} will prevent the player from sleeping. This has the * same effect as canceling the event via {@link #setCancelled(boolean)}. *
* {@link Result#DEFAULT} will result in the outcome described by - * {@link #getBedEnterResult()}. + * {@link #enterAction()}. * * @param useBed the action to take with the interacted bed * @see #useBed() @@ -104,7 +104,7 @@ public void setUseBed(@NotNull Result useBed) { *

* For backwards compatibility reasons this also returns {@code true} if * {@link #useBed()} is {@link Result#DEFAULT} and the - * {@link #getBedEnterResult() default action} is to prevent bed entering. + * {@link #enterAction() default action} is to prevent bed entering. * * @return boolean cancellation state */ @@ -136,6 +136,7 @@ public static HandlerList getHandlerList() { /** * Represents the default possible outcomes of this event. + * * @deprecated Enums no longer represents reliably how beds work and fail. This has been * replaced with {@link BedEnterAction} that better fits the new beds */ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch index e84aaa56a922..9b9473adc698 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch @@ -9,7 +9,7 @@ bedRule.errorMessage().ifPresent(component -> player.displayClientMessage(component, true)); level.removeBlock(pos, false); BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); -@@ -103,22 +_,59 @@ +@@ -103,22 +_,61 @@ level.explode(null, level.damageSources().badRespawnPointExplosion(center), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); return InteractionResult.SUCCESS_SERVER; } else if (state.getValue(OCCUPIED)) { @@ -36,14 +36,16 @@ + return; + } + // Paper end - PlayerBedFailEnterEvent -+ // CraftBukkit start - handling bed explosion from below here -+ if (event.getWillExplode()) { // Paper - PlayerBedFailEnterEvent -+ this.explodeBed(finalBlockState, level, finalBlockPos); -+ } -+ // CraftBukkit end -+ // Paper start - PlayerBedFailEnterEvent -+ final net.kyori.adventure.text.Component message = event.getMessage(); -+ if (message != null) player.displayClientMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), true); ++ // CraftBukkit start - handling bed explosion from below here ++ if (event.getWillExplode()) { // Paper - PlayerBedFailEnterEvent ++ this.explodeBed(finalBlockState, level, finalBlockPos); ++ } ++ // CraftBukkit end ++ // Paper start - PlayerBedFailEnterEvent ++ final net.kyori.adventure.text.Component message = event.getMessage(); ++ if (message != null) { ++ player.displayClientMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), true); ++ } + } + // Paper end - PlayerBedFailEnterEvent }); From e492b083fce1aca100590dedd9f0471f6f8ac75e Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sun, 23 Nov 2025 16:40:59 -0700 Subject: [PATCH 102/112] Update CraftPlayer#setPlayerTime --- .../main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 0660070207c0..6d31e4c351d9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1541,7 +1541,7 @@ public void setPlayerTime(long time, boolean relative) { final long gameTime = this.getHandle().level().getGameTime(); final long dayTime = this.getHandle().getPlayerTime(); - final boolean tickDayTime = this.getHandle().relativeTime && this.getHandle().level().getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_DAYLIGHT); + final boolean tickDayTime = this.getHandle().relativeTime && this.getHandle().level().getGameRules().get(net.minecraft.world.level.gamerules.GameRules.ADVANCE_TIME); this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundSetTimePacket(gameTime, dayTime, tickDayTime)); } From e49b9cc42b087b5250fc23805d96457ea5f42b85 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 25 Nov 2025 10:19:53 -0700 Subject: [PATCH 103/112] 1.21.11-pre3 --- gradle.properties | 4 +- paper-server/build.gradle.kts | 2 +- .../world/entity/LivingEntity.java.patch | 150 +++++++++--------- .../world/entity/player/Player.java.patch | 66 ++++---- 4 files changed, 111 insertions(+), 111 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9c7dbb64fefa..86cbd02304f2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group=io.papermc.paper -version=1.21.11-pre2-R0.1-SNAPSHOT -mcVersion=1.21.11-pre2 +version=1.21.11-pre3-R0.1-SNAPSHOT +mcVersion=1.21.11-pre3 # This is the current API version for use in (paper-)plugin.yml files # During snapshot cycles this should be the anticipated version of the release target apiVersion=1.21.11 diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 22be545e6ea8..e2bd4f6bc3e8 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:1.21.11-pre2+build.2") + mache("io.papermc:mache:1.21.11-pre3+build.2") paperclip("io.papermc:paperclip:3.0.3") } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index ffbef27aa589..c93d29f0a0d9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -142,6 +_,17 @@ +@@ -143,6 +_,17 @@ import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -18,7 +18,7 @@ public abstract class LivingEntity extends Entity implements Attackable, WaypointTransmitter { private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; -@@ -267,11 +_,25 @@ +@@ -268,11 +_,25 @@ ); protected final EntityEquipment equipment; private Waypoint.Icon locatorBarIcon = new Waypoint.Icon(); @@ -45,7 +45,7 @@ this.equipment = this.createEquipment(); this.blocksBuilding = true; this.reapplyPosition(); -@@ -370,7 +_,13 @@ +@@ -371,7 +_,13 @@ double d1 = Math.min(0.2F + d / 15.0, 2.5); int i = (int)(150.0 * d1); @@ -60,7 +60,7 @@ } } -@@ -555,7 +_,7 @@ +@@ -556,7 +_,7 @@ this.deathTime++; if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { this.level().broadcastEntityEvent(this, EntityEvent.POOF); @@ -69,7 +69,7 @@ } } -@@ -657,7 +_,7 @@ +@@ -658,7 +_,7 @@ } public boolean shouldDiscardFriction() { @@ -78,7 +78,7 @@ } public void setDiscardFriction(boolean discardFriction) { -@@ -669,10 +_,15 @@ +@@ -670,10 +_,15 @@ } public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem) { @@ -95,7 +95,7 @@ this.level() .playSeededSound( null, -@@ -699,12 +_,12 @@ +@@ -700,12 +_,12 @@ } @Override @@ -110,7 +110,7 @@ this.brain.clearMemories(); } -@@ -721,11 +_,17 @@ +@@ -722,11 +_,17 @@ mobEffectInstance.onMobRemoved(level, this, removalReason); } @@ -128,7 +128,7 @@ output.putFloat("Health", this.getHealth()); output.putShort("HurtTime", (short)this.hurtTime); output.putInt("HurtByTimestamp", this.lastHurtByMobTimestamp); -@@ -759,7 +_,12 @@ +@@ -760,7 +_,12 @@ } } @@ -142,7 +142,7 @@ if (stack.isEmpty()) { return null; } else if (this.level().isClientSide()) { -@@ -768,6 +_,31 @@ +@@ -769,6 +_,31 @@ } else { ItemEntity itemEntity = this.createItemStackToDrop(stack, randomizeMotion, includeThrower); if (itemEntity != null) { @@ -174,7 +174,7 @@ this.level().addFreshEntity(itemEntity); } -@@ -777,7 +_,22 @@ +@@ -778,7 +_,22 @@ @Override protected void readAdditionalSaveData(ValueInput input) { @@ -198,7 +198,7 @@ if (this.level() != null && !this.level().isClientSide()) { input.read("attributes", AttributeInstance.Packed.LIST_CODEC).ifPresent(this.getAttributes()::apply); } -@@ -790,6 +_,11 @@ +@@ -791,6 +_,11 @@ this.effectsDirty = true; } @@ -210,7 +210,7 @@ this.setHealth(input.getFloatOr("Health", this.getMaxHealth())); this.hurtTime = input.getShortOr("HurtTime", (short)0); this.deathTime = input.getShortOr("DeathTime", (short)0); -@@ -797,6 +_,7 @@ +@@ -798,6 +_,7 @@ input.getString("Team").ifPresent(string -> { Scoreboard scoreboard = this.level().getScoreboard(); PlayerTeam playerTeam = scoreboard.getPlayerTeam(string); @@ -218,7 +218,7 @@ boolean flag = playerTeam != null && scoreboard.addPlayerToTeam(this.getStringUUID(), playerTeam); if (!flag) { LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", string); -@@ -804,11 +_,13 @@ +@@ -805,11 +_,13 @@ }); this.setSharedFlag(Entity.FLAG_FALL_FLYING, input.getBooleanOr("FallFlying", false)); input.read("sleeping_pos", BlockPos.CODEC).ifPresentOrElse(blockPos -> { @@ -232,7 +232,7 @@ }, this::clearSleepingPos); input.read("Brain", Codec.PASSTHROUGH).ifPresent(dynamic -> this.brain = this.makeBrain((Dynamic)dynamic)); this.lastHurtByPlayer = EntityReference.read(input, "last_hurt_by_player"); -@@ -825,15 +_,44 @@ +@@ -826,15 +_,44 @@ this.updateDirtyEffects(); } @@ -277,7 +277,7 @@ iterator.remove(); this.onEffectsRemoved(List.of(mobEffectInstance)); } else if (mobEffectInstance.getDuration() % 600 == 0) { -@@ -842,6 +_,18 @@ +@@ -843,6 +_,18 @@ } } catch (ConcurrentModificationException var6) { } @@ -296,7 +296,7 @@ } else { for (MobEffectInstance mobEffectInstance1 : this.activeEffects.values()) { mobEffectInstance1.tickClient(); -@@ -952,15 +_,33 @@ +@@ -953,15 +_,33 @@ } public boolean removeAllEffects() { @@ -334,7 +334,7 @@ } } -@@ -986,21 +_,57 @@ +@@ -987,21 +_,57 @@ } public final boolean addEffect(MobEffectInstance effectInstance) { @@ -394,7 +394,7 @@ this.onEffectUpdated(mobEffectInstance, true, entity); flag = true; } -@@ -1038,11 +_,35 @@ +@@ -1039,11 +_,35 @@ } public final @Nullable MobEffectInstance removeEffectNoUpdate(Holder effect) { @@ -431,7 +431,7 @@ if (mobEffectInstance != null) { this.onEffectsRemoved(List.of(mobEffectInstance)); return true; -@@ -1133,17 +_,62 @@ +@@ -1134,17 +_,62 @@ } public void heal(float amount) { @@ -495,7 +495,7 @@ this.entityData.set(DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth())); } -@@ -1155,7 +_,7 @@ +@@ -1156,7 +_,7 @@ public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { if (this.isInvulnerableTo(level, damageSource)) { return false; @@ -504,7 +504,7 @@ return false; } else if (damageSource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1171,35 +_,58 @@ +@@ -1172,35 +_,58 @@ ItemStack useItem = this.getUseItem(); float originAmount = amount; @@ -571,7 +571,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1214,7 +_,7 @@ +@@ -1215,7 +_,7 @@ level.broadcastDamageEvent(this, damageSource); } @@ -580,7 +580,7 @@ this.markHurt(); } -@@ -1229,8 +_,16 @@ +@@ -1230,8 +_,16 @@ d = damageSource.getSourcePosition().x() - this.getX(); d1 = damageSource.getSourcePosition().z() - this.getZ(); } @@ -598,7 +598,7 @@ if (!flag) { this.indicateDamage(d, d1); } -@@ -1239,19 +_,19 @@ +@@ -1240,19 +_,19 @@ if (this.isDeadOrDying()) { if (!this.checkTotemDeathProtection(damageSource)) { @@ -623,7 +623,7 @@ if (flag2) { this.lastDamageSource = damageSource; this.lastDamageStamp = this.level().getGameTime(); -@@ -1277,6 +_,12 @@ +@@ -1278,6 +_,12 @@ } public float applyItemBlocking(ServerLevel level, DamageSource damageSource, float damageAmount) { @@ -636,7 +636,7 @@ if (damageAmount <= 0.0F) { return 0.0F; } else { -@@ -1301,10 +_,12 @@ +@@ -1302,10 +_,12 @@ } float f = blocksAttacks.resolveBlockedDamage(damageSource, damageAmount, acos); @@ -650,7 +650,7 @@ return f; } -@@ -1315,6 +_,59 @@ +@@ -1316,6 +_,59 @@ } } @@ -710,7 +710,7 @@ public void playSecondaryHurtSound(DamageSource damageSource) { if (damageSource.is(DamageTypes.THORNS)) { SoundSource soundSource = this instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE; -@@ -1346,12 +_,24 @@ +@@ -1347,12 +_,24 @@ return EntityReference.getPlayer(this.lastHurtByPlayer, this.level()); } @@ -736,7 +736,7 @@ } private boolean checkTotemDeathProtection(DamageSource damageSource) { -@@ -1361,18 +_,39 @@ +@@ -1362,18 +_,39 @@ ItemStack itemStack = null; DeathProtection deathProtection = null; @@ -783,7 +783,7 @@ serverPlayer.awardStat(Stats.ITEM_USED.get(itemStack.getItem())); CriteriaTriggers.USED_TOTEM.trigger(serverPlayer, itemStack); itemStack.causeUseVibration(this, GameEvent.ITEM_INTERACT_FINISH); -@@ -1430,6 +_,7 @@ +@@ -1431,6 +_,7 @@ if (!this.isRemoved() && !this.dead) { Entity entity = damageSource.getEntity(); LivingEntity killCredit = this.getKillCredit(); @@ -791,7 +791,7 @@ if (killCredit != null) { killCredit.awardKillScore(this, damageSource); } -@@ -1440,68 +_,147 @@ +@@ -1441,68 +_,147 @@ this.stopUsingItem(); if (!this.level().isClientSide() && this.hasCustomName()) { @@ -952,7 +952,7 @@ } protected void dropCustomDeathLoot(ServerLevel level, DamageSource damageSource, boolean recentlyHit) { -@@ -1605,9 +_,14 @@ +@@ -1606,9 +_,14 @@ } public void knockback(double strength, double x, double z) { @@ -969,7 +969,7 @@ Vec3 deltaMovement = this.getDeltaMovement(); while (x * x + z * z < 1.0E-5F) { -@@ -1616,11 +_,22 @@ +@@ -1617,11 +_,22 @@ } Vec3 vec3 = new Vec3(x, 0.0, z).normalize().scale(strength); @@ -993,7 +993,7 @@ } } -@@ -1711,7 +_,7 @@ +@@ -1712,7 +_,7 @@ @Override public boolean isAlive() { @@ -1002,7 +1002,7 @@ } public boolean isLookingAtMe(LivingEntity entity, double tolerance, boolean scaleByDistance, boolean visual, double... yValues) { -@@ -1745,9 +_,14 @@ +@@ -1746,9 +_,14 @@ boolean flag = super.causeFallDamage(fallDistance, damageMultiplier, damageSource); int i = this.calculateFallDamage(fallDistance, damageMultiplier); if (i > 0) { @@ -1018,7 +1018,7 @@ return true; } else { return flag; -@@ -1812,7 +_,7 @@ +@@ -1813,7 +_,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damageSource, float damageAmount) { if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -1027,7 +1027,7 @@ damageAmount = CombatRules.getDamageAfterAbsorb( this, damageAmount, damageSource, this.getArmorValue(), (float)this.getAttributeValue(Attributes.ARMOR_TOUGHNESS) ); -@@ -1825,7 +_,8 @@ +@@ -1826,7 +_,8 @@ if (damageSource.is(DamageTypeTags.BYPASSES_EFFECTS)) { return damageAmount; } else { @@ -1037,7 +1037,7 @@ int i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int i1 = 25 - i; float f = damageAmount * i1; -@@ -1862,24 +_,201 @@ +@@ -1863,24 +_,201 @@ } } @@ -1249,7 +1249,7 @@ } public CombatTracker getCombatTracker() { -@@ -1907,7 +_,17 @@ +@@ -1908,7 +_,17 @@ } public final void setArrowCount(int count) { @@ -1268,7 +1268,7 @@ } public final int getStingerCount() { -@@ -1954,7 +_,7 @@ +@@ -1955,7 +_,7 @@ @Override public void handleDamageEvent(DamageSource damageSource) { this.walkAnimation.setSpeed(1.5F); @@ -1277,7 +1277,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; SoundEvent hurtSound = this.getHurtSound(damageSource); -@@ -2073,7 +_,7 @@ +@@ -2084,7 +_,7 @@ @Override protected void onBelowWorld() { @@ -1286,7 +1286,7 @@ } protected void updateSwingTime() { -@@ -2176,8 +_,15 @@ +@@ -2187,8 +_,15 @@ } public void setItemSlot(EquipmentSlot slot, ItemStack stack) { @@ -1304,7 +1304,7 @@ public float getArmorCoverPercentage() { int i = 0; -@@ -2269,14 +_,27 @@ +@@ -2280,14 +_,27 @@ return this.hasEffect(MobEffects.JUMP_BOOST) ? 0.1F * (this.getEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1.0F) : 0.0F; } @@ -1332,7 +1332,7 @@ this.addDeltaMovement(new Vec3(-Mth.sin(f) * 0.2, 0.0, Mth.cos(f) * 0.2)); } -@@ -2459,8 +_,10 @@ +@@ -2470,8 +_,10 @@ } public void stopFallFlying() { @@ -1343,7 +1343,7 @@ } private Vec3 updateFallFlyingMovement(Vec3 deltaMovement) { -@@ -2604,7 +_,7 @@ +@@ -2615,7 +_,7 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F && target instanceof LivingEntity livingEntity) { @@ -1352,7 +1352,7 @@ this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); } } -@@ -2680,37 +_,15 @@ +@@ -2691,37 +_,15 @@ profilerFiller.pop(); profilerFiller.push("rangeChecks"); @@ -1399,7 +1399,7 @@ profilerFiller.pop(); if (this.isFallFlying()) { -@@ -2795,16 +_,39 @@ +@@ -2806,16 +_,39 @@ private @Nullable Map collectEquipmentChanges() { Map map = null; @@ -1439,7 +1439,7 @@ AttributeMap attributes = this.getAttributes(); if (!itemStack.isEmpty()) { this.stopLocationBasedEffects(itemStack, equipmentSlot, attributes); -@@ -2829,6 +_,8 @@ +@@ -2840,6 +_,8 @@ } } } @@ -1448,7 +1448,7 @@ } return map; -@@ -2860,7 +_,7 @@ +@@ -2871,7 +_,7 @@ list.add(Pair.of(equipmentSlot, itemStack1)); this.lastEquipmentItems.put(equipmentSlot, itemStack1); }); @@ -1457,7 +1457,7 @@ } protected void tickHeadTurn(float yBodyRot) { -@@ -2946,8 +_,10 @@ +@@ -2957,8 +_,10 @@ if (!flag || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if (!this.isInLava() || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if ((this.onGround() || flag && fluidHeight <= fluidJumpThreshold) && this.noJumpDelay == 0) { @@ -1468,7 +1468,7 @@ } } else { this.jumpInLiquid(FluidTags.LAVA); -@@ -2988,7 +_,7 @@ +@@ -2999,7 +_,7 @@ profilerFiller.pop(); if (this.level() instanceof ServerLevel serverLevel) { profilerFiller.push("freezing"); @@ -1477,7 +1477,7 @@ this.setTicksFrozen(Math.max(0, this.getTicksFrozen() - 2)); } -@@ -3009,6 +_,20 @@ +@@ -3020,6 +_,20 @@ this.pushEntities(); profilerFiller.pop(); @@ -1498,7 +1498,7 @@ if (this.level() instanceof ServerLevel serverLevel && this.isSensitiveToWater() && this.isInWaterOrRain()) { this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F); } -@@ -3031,6 +_,7 @@ +@@ -3042,6 +_,7 @@ this.checkFallDistanceAccumulation(); if (!this.level().isClientSide()) { if (!this.canGlide()) { @@ -1506,7 +1506,7 @@ this.setSharedFlag(Entity.FLAG_FALL_FLYING, false); return; } -@@ -3070,10 +_,25 @@ +@@ -3081,10 +_,25 @@ } protected void pushEntities() { @@ -1533,7 +1533,7 @@ if (i > 0 && pushableEntities.size() > i - 1 && this.random.nextInt(4) == 0) { int i1 = 0; -@@ -3089,7 +_,16 @@ +@@ -3100,7 +_,16 @@ } } @@ -1550,7 +1550,7 @@ this.doPush(entity1); } } -@@ -3098,16 +_,32 @@ +@@ -3109,16 +_,32 @@ protected void checkAutoSpinAttack(AABB boundingBoxBeforeSpin, AABB boundingBoxAfterSpin) { AABB aabb = boundingBoxBeforeSpin.minmax(boundingBoxAfterSpin); List entities = this.level().getEntities(this, aabb); @@ -1584,7 +1584,7 @@ this.autoSpinAttackTicks = 0; } -@@ -3130,10 +_,10 @@ +@@ -3141,10 +_,10 @@ } @Override @@ -1598,7 +1598,7 @@ this.dismountVehicle(vehicle); } } -@@ -3160,7 +_,7 @@ +@@ -3171,7 +_,7 @@ } public void onItemPickup(ItemEntity itemEntity) { @@ -1607,7 +1607,7 @@ if (owner instanceof ServerPlayer) { CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer)owner, itemEntity.getItem(), this); } -@@ -3172,7 +_,7 @@ +@@ -3183,7 +_,7 @@ && (entity instanceof ItemEntity || entity instanceof AbstractArrow || entity instanceof ExperienceOrb)) { ((ServerLevel)this.level()) .getChunkSource() @@ -1616,7 +1616,7 @@ } } -@@ -3186,7 +_,8 @@ +@@ -3197,7 +_,8 @@ } else { Vec3 vec3 = new Vec3(this.getX(), this.getEyeY(), this.getZ()); Vec3 vec31 = new Vec3(entity.getX(), y, entity.getZ()); @@ -1626,7 +1626,7 @@ } } -@@ -3206,13 +_,27 @@ +@@ -3217,13 +_,27 @@ @Override public boolean isPickable() { @@ -1657,7 +1657,7 @@ @Override public float getYHeadRot() { -@@ -3243,7 +_,7 @@ +@@ -3254,7 +_,7 @@ } public final void setAbsorptionAmount(float absorptionAmount) { @@ -1666,7 +1666,7 @@ } protected void internalSetAbsorptionAmount(float absorptionAmount) { -@@ -3270,6 +_,15 @@ +@@ -3281,6 +_,15 @@ return (this.entityData.get(DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; } @@ -1682,7 +1682,7 @@ private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { -@@ -3286,6 +_,11 @@ +@@ -3297,6 +_,11 @@ return null; } else { double d = this.getEyeY() - 0.3F; @@ -1694,7 +1694,7 @@ ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), d, this.getZ(), stack); itemEntity.setPickUpDelay(40); if (includeThrower) { -@@ -3317,7 +_,12 @@ +@@ -3328,7 +_,12 @@ protected void updateUsingItem(ItemStack usingItem) { usingItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); @@ -1708,7 +1708,7 @@ this.completeUsingItem(); } } -@@ -3343,10 +_,19 @@ +@@ -3354,10 +_,19 @@ } public void startUsingItem(InteractionHand hand) { @@ -1730,7 +1730,7 @@ if (!this.level().isClientSide()) { this.setLivingEntityFlag(LIVING_ENTITY_FLAG_IS_USING, true); this.setLivingEntityFlag(LIVING_ENTITY_FLAG_OFF_HAND, hand == InteractionHand.OFF_HAND); -@@ -3373,7 +_,10 @@ +@@ -3384,7 +_,10 @@ } } else if (!this.isUsingItem() && !this.useItem.isEmpty()) { this.useItem = ItemStack.EMPTY; @@ -1742,7 +1742,7 @@ } } } -@@ -3412,7 +_,38 @@ +@@ -3423,7 +_,38 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1782,7 +1782,7 @@ if (itemStack != this.useItem) { this.setItemInHand(usedItemHand, itemStack); } -@@ -3446,6 +_,7 @@ +@@ -3457,6 +_,7 @@ ItemStack itemInHand = this.getItemInHand(this.getUsedItemHand()); if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemInHand, this.useItem)) { this.useItem = itemInHand; @@ -1790,7 +1790,7 @@ this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); if (this.useItem.useOnRelease()) { this.updatingUsingItem(); -@@ -3466,7 +_,10 @@ +@@ -3477,7 +_,10 @@ } this.useItem = ItemStack.EMPTY; @@ -1802,7 +1802,7 @@ } public boolean isBlocking() { -@@ -3489,6 +_,60 @@ +@@ -3500,6 +_,60 @@ } } @@ -1863,7 +1863,7 @@ public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); } -@@ -3507,6 +_,12 @@ +@@ -3518,6 +_,12 @@ } public boolean randomTeleport(double x, double y, double z, boolean broadcastTeleport) { @@ -1876,7 +1876,7 @@ double x1 = this.getX(); double y1 = this.getY(); double z1 = this.getZ(); -@@ -3529,16 +_,39 @@ +@@ -3540,16 +_,39 @@ } if (flag1) { @@ -1919,7 +1919,7 @@ } else { if (broadcastTeleport) { level.broadcastEntityEvent(this, EntityEvent.TELEPORT); -@@ -3548,7 +_,7 @@ +@@ -3559,7 +_,7 @@ pathfinderMob.getNavigation().stop(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index 599876ca0f68..cd2ff98d5e90 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -150,7 +_,7 @@ - private static final boolean DEFAULT_IGNORE_FALL_DAMAGE_FROM_CURRENT_IMPULSE = false; +@@ -151,7 +_,7 @@ private static final int DEFAULT_CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME = 0; + public static final float CREATIVE_ENTITY_INTERACTION_RANGE_MODIFIER_VALUE = 2.0F; final Inventory inventory; - protected PlayerEnderChestContainer enderChestInventory = new PlayerEnderChestContainer(); + protected PlayerEnderChestContainer enderChestInventory = new PlayerEnderChestContainer(this); // CraftBukkit - add "this" to constructor public final InventoryMenu inventoryMenu; public AbstractContainerMenu containerMenu; protected FoodData foodData = new FoodData(); -@@ -176,6 +_,18 @@ +@@ -177,6 +_,18 @@ public @Nullable Entity currentExplosionCause; private boolean ignoreFallDamageFromCurrentImpulse = false; private int currentImpulseContextResetGraceTime = 0; @@ -28,7 +28,7 @@ public Player(Level level, GameProfile gameProfile) { super(EntityType.PLAYER, level); -@@ -243,6 +_,13 @@ +@@ -244,6 +_,13 @@ if (this.isSleeping()) { this.sleepCounter++; @@ -42,7 +42,7 @@ if (this.sleepCounter > 100) { this.sleepCounter = 100; } -@@ -326,7 +_,7 @@ +@@ -327,7 +_,7 @@ } private void turtleHelmetTick() { @@ -51,7 +51,7 @@ } private boolean isEquipped(Item item) { -@@ -427,6 +_,18 @@ +@@ -428,6 +_,18 @@ } } @@ -70,7 +70,7 @@ public void closeContainer() { this.containerMenu = this.inventoryMenu; } -@@ -438,8 +_,14 @@ +@@ -439,8 +_,14 @@ public void rideTick() { if (!this.level().isClientSide() && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -87,7 +87,7 @@ super.rideTick(); } } -@@ -698,10 +_,10 @@ +@@ -699,10 +_,10 @@ if (this.isDeadOrDying()) { return false; } else { @@ -100,7 +100,7 @@ } if (level.getDifficulty() == Difficulty.EASY) { -@@ -713,7 +_,14 @@ +@@ -714,7 +_,14 @@ } } @@ -116,7 +116,7 @@ } } } -@@ -725,7 +_,7 @@ +@@ -726,7 +_,7 @@ BlocksAttacks blocksAttacks = itemBlockingWith != null ? itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS) : null; float secondsToDisableBlocking = entity.getSecondsToDisableBlocking(); if (secondsToDisableBlocking > 0.0F && blocksAttacks != null) { @@ -125,7 +125,7 @@ } } -@@ -735,9 +_,29 @@ +@@ -736,9 +_,29 @@ } public boolean canHarmPlayer(Player other) { @@ -158,7 +158,7 @@ } @Override -@@ -751,7 +_,12 @@ +@@ -752,7 +_,12 @@ } @Override @@ -172,7 +172,7 @@ if (!this.isInvulnerableTo(level, damageSource)) { amount = this.getDamageAfterArmorAbsorb(damageSource, amount); amount = this.getDamageAfterMagicAbsorb(damageSource, amount); -@@ -763,7 +_,7 @@ +@@ -764,7 +_,7 @@ } if (var8 != 0.0F) { @@ -181,7 +181,7 @@ this.getCombatTracker().recordDamage(damageSource, var8); this.setHealth(this.getHealth() - var8); if (var8 < 3.4028235E37F) { -@@ -773,6 +_,7 @@ +@@ -774,6 +_,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -189,7 +189,7 @@ } public boolean isTextFilteringEnabled() { -@@ -859,14 +_,16 @@ +@@ -860,14 +_,16 @@ } @Override @@ -209,7 +209,7 @@ } @Override -@@ -945,15 +_,25 @@ +@@ -946,15 +_,25 @@ } public void attack(Entity target) { @@ -238,7 +238,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = attackStrengthScale > 0.9F; boolean flag1; -@@ -966,7 +_,9 @@ +@@ -967,7 +_,9 @@ f += weaponItem.getItem().getAttackDamageBonus(target, f, damageSource); boolean flag2 = flag && this.canCriticalAttack(target); @@ -248,7 +248,7 @@ f *= 1.5F; } -@@ -1012,11 +_,12 @@ +@@ -1013,11 +_,12 @@ return !target.isAttackable() || target.skipAttackInteraction(this); } @@ -263,7 +263,7 @@ return true; } else { return false; -@@ -1109,21 +_,43 @@ +@@ -1110,21 +_,43 @@ public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { if (strength > 0.0F) { if (target instanceof LivingEntity livingEntity) { @@ -308,7 +308,7 @@ } } -@@ -1144,7 +_,10 @@ +@@ -1145,7 +_,10 @@ && !(livingEntity instanceof ArmorStand armorStand && armorStand.isMarker()) && this.distanceToSqr(livingEntity) < 9.0) { float f1 = this.getEnchantedDamage(livingEntity, var12, damageSource) * strengthScale; @@ -320,7 +320,7 @@ livingEntity.knockback(0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity, damageSource); } -@@ -1176,7 +_,16 @@ +@@ -1177,7 +_,16 @@ @Override public boolean stabAttack(EquipmentSlot slot, Entity target, float damageAmount, boolean damage, boolean knockback, boolean dismount) { @@ -338,7 +338,7 @@ return false; } else { ItemStack itemBySlot = this.getItemBySlot(slot); -@@ -1187,7 +_,8 @@ +@@ -1188,7 +_,8 @@ damageAmount *= this.baseDamageScaleFactor(); } @@ -348,7 +348,7 @@ return true; } else { float f1 = damage ? damageAmount + f : 0.0F; -@@ -1215,7 +_,7 @@ +@@ -1216,7 +_,7 @@ this.setLastHurtMob(target); this.itemAttackInteraction(target, itemBySlot, damageSource, flag); this.damageStatsAndHearts(target, f2); @@ -357,7 +357,7 @@ return true; } } -@@ -1226,8 +_,8 @@ +@@ -1227,8 +_,8 @@ } @Override @@ -368,7 +368,7 @@ this.inventoryMenu.removed(this); if (this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1295,6 +_,12 @@ +@@ -1296,6 +_,12 @@ } public Either startSleepInBed(BlockPos bedPos) { @@ -381,7 +381,7 @@ this.startSleeping(bedPos); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1406,7 +_,7 @@ +@@ -1407,7 +_,7 @@ @Override public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) { @@ -390,7 +390,7 @@ return false; } else { if (fallDistance >= 2.0) { -@@ -1447,7 +_,15 @@ +@@ -1448,7 +_,15 @@ } public void startFallFlying() { @@ -407,7 +407,7 @@ } @Override -@@ -1545,7 +_,7 @@ +@@ -1546,7 +_,7 @@ if (levels > 0 && this.experienceLevel % 5 == 0 && this.lastLevelUpTime < this.tickCount - 100.0F) { float f = this.experienceLevel > 30 ? 1.0F : this.experienceLevel / 30.0F; @@ -416,7 +416,7 @@ this.lastLevelUpTime = this.tickCount; } } -@@ -1553,15 +_,35 @@ +@@ -1554,15 +_,35 @@ public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { return 112 + (this.experienceLevel - 30) * 9; @@ -454,7 +454,7 @@ } } } -@@ -1820,7 +_,7 @@ +@@ -1821,7 +_,7 @@ @Override public void onAttack() { @@ -463,7 +463,7 @@ super.onAttack(); } -@@ -1855,17 +_,32 @@ +@@ -1856,17 +_,32 @@ return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } @@ -498,7 +498,7 @@ for (int i = 0; i < this.inventory.getContainerSize(); i++) { ItemStack item = this.inventory.getItem(i); -@@ -1874,6 +_,7 @@ +@@ -1875,6 +_,7 @@ } } @@ -506,7 +506,7 @@ return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; } } -@@ -2054,5 +_,6 @@ +@@ -2055,5 +_,6 @@ public static final Player.BedSleepingProblem OBSTRUCTED = new Player.BedSleepingProblem(Component.translatable("block.minecraft.bed.obstructed")); public static final Player.BedSleepingProblem OTHER_PROBLEM = new Player.BedSleepingProblem(null); public static final Player.BedSleepingProblem NOT_SAFE = new Player.BedSleepingProblem(Component.translatable("block.minecraft.bed.not_safe")); From 219a31ed369088d026904845304856ab31c5ae8c Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Tue, 25 Nov 2025 18:30:08 +0000 Subject: [PATCH 104/112] Drop unused access transformers --- build-data/paper.at | 7 ------- 1 file changed, 7 deletions(-) diff --git a/build-data/paper.at b/build-data/paper.at index 0f916b2b5112..c8e2c32d9298 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -20,8 +20,6 @@ public net.minecraft.network.Connection address public net.minecraft.network.Connection channel public net.minecraft.network.chat.TextColor name public net.minecraft.network.chat.contents.TranslatableContents filterAllowedArguments(Ljava/lang/Object;)Lcom/mojang/serialization/DataResult; -public net.minecraft.network.chat.numbers.FixedFormat value -public net.minecraft.network.chat.numbers.StyledFormat style public net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket (Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntityType;Lnet/minecraft/nbt/CompoundTag;)V public net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket blockState public net.minecraft.network.protocol.game.ServerboundMovePlayerPacket hasPos @@ -421,7 +419,6 @@ public net.minecraft.world.entity.monster.zombie.ZombieVillager DATA_CONVERTING_ public net.minecraft.world.entity.monster.zombie.ZombieVillager conversionStarter public net.minecraft.world.entity.monster.zombie.ZombieVillager startConverting(Ljava/util/UUID;I)V public net.minecraft.world.entity.monster.zombie.ZombieVillager villagerConversionTime -public net.minecraft.world.entity.npc.villager.Villager increaseMerchantCareer()V public net.minecraft.world.entity.npc.villager.Villager numberOfRestocksToday public net.minecraft.world.entity.npc.villager.Villager releaseAllPois()V public net.minecraft.world.entity.npc.villager.Villager setUnhappy()V @@ -572,9 +569,6 @@ public net.minecraft.world.level.BaseSpawner spawnCount public net.minecraft.world.level.BaseSpawner spawnDelay public net.minecraft.world.level.BaseSpawner spawnPotentials public net.minecraft.world.level.BaseSpawner spawnRange -public net.minecraft.world.level.GameRules GAME_RULE_TYPES -public net.minecraft.world.level.GameRules$Value deserialize(Ljava/lang/String;)V -public net.minecraft.world.level.GameRules$Value onChanged(Lnet/minecraft/server/MinecraftServer;)V public net.minecraft.world.level.Level DEFAULT_EXPLOSION_BLOCK_PARTICLES public net.minecraft.world.level.Level blockEntityTickers public net.minecraft.world.level.Level getEntities()Lnet/minecraft/world/level/entity/LevelEntityGetter; @@ -766,7 +760,6 @@ public-f net.minecraft.server.dedicated.DedicatedServer serverLinks public-f net.minecraft.server.dedicated.DedicatedServer settings public-f net.minecraft.server.dedicated.DedicatedServerProperties pauseWhenEmptySeconds public-f net.minecraft.world.entity.LivingEntity combatTracker -public-f net.minecraft.world.entity.LivingEntity invulnerableDuration public-f net.minecraft.world.entity.Mob goalSelector public-f net.minecraft.world.entity.Mob targetSelector public-f net.minecraft.world.entity.ai.attributes.RangedAttribute maxValue From 674cb33dd0d4f3413533f4ccad8475e275c03814 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Tue, 25 Nov 2025 20:49:37 +0100 Subject: [PATCH 105/112] update parchment --- paper-server/build.gradle.kts | 2 +- .../net/minecraft/world/item/FireChargeItem.java.patch | 2 +- .../net/minecraft/world/item/FireworkRocketItem.java.patch | 6 +++--- .../net/minecraft/world/item/WindChargeItem.java.patch | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index e2bd4f6bc3e8..3319d83929ce 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:1.21.11-pre3+build.2") + mache("io.papermc:mache:1.21.11-pre3+build.3") paperclip("io.papermc:paperclip:3.0.3") } diff --git a/paper-server/patches/sources/net/minecraft/world/item/FireChargeItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/FireChargeItem.java.patch index 7d07004bad81..0ea5aed2bbc2 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/FireChargeItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/FireChargeItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/FireChargeItem.java +++ b/net/minecraft/world/item/FireChargeItem.java -@@ -35,12 +_,28 @@ +@@ -36,12 +_,28 @@ if (!CampfireBlock.canLight(blockState) && !CandleBlock.canLight(blockState) && !CandleCakeBlock.canLight(blockState)) { clickedPos = clickedPos.relative(context.getClickedFace()); if (BaseFireBlock.canBePlacedAt(level, clickedPos, context.getHorizontalDirection())) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch index f767729f2db9..803d94ec2889 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/FireworkRocketItem.java +++ b/net/minecraft/world/item/FireworkRocketItem.java -@@ -35,7 +_,7 @@ +@@ -36,7 +_,7 @@ ItemStack itemInHand = context.getItemInHand(); Vec3 clickLocation = context.getClickLocation(); Direction clickedFace = context.getClickedFace(); @@ -9,7 +9,7 @@ new FireworkRocketEntity( level, context.getPlayer(), -@@ -45,9 +_,14 @@ +@@ -46,9 +_,14 @@ itemInHand ), serverLevel, @@ -26,7 +26,7 @@ } return InteractionResult.SUCCESS; -@@ -59,13 +_,24 @@ +@@ -60,13 +_,24 @@ if (player.isFallFlying()) { ItemStack itemInHand = player.getItemInHand(hand); if (level instanceof ServerLevel serverLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/WindChargeItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/WindChargeItem.java.patch index 0f46433c55fa..ad11eafc3829 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/WindChargeItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/WindChargeItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/WindChargeItem.java +++ b/net/minecraft/world/item/WindChargeItem.java -@@ -27,7 +_,7 @@ +@@ -28,7 +_,7 @@ public InteractionResult use(Level level, Player player, InteractionHand hand) { ItemStack itemInHand = player.getItemInHand(hand); if (level instanceof ServerLevel serverLevel) { @@ -9,7 +9,7 @@ (level1, owner, spawnedFrom) -> new WindCharge(player, level, player.position().x(), player.getEyePosition().y(), player.position().z()), serverLevel, itemInHand, -@@ -36,6 +_,22 @@ +@@ -37,6 +_,22 @@ PROJECTILE_SHOOT_POWER, 1.0F ); @@ -32,7 +32,7 @@ } level.playSound( -@@ -48,8 +_,7 @@ +@@ -49,8 +_,7 @@ 0.5F, 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F) ); From 3552de22b2f065aa1466c357be6b65fcbdd209d3 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 25 Nov 2025 12:51:15 -0700 Subject: [PATCH 106/112] Update Moonrise --- .../0001-Moonrise-optimisation-patches.patch | 1451 ++++++++--------- 1 file changed, 709 insertions(+), 742 deletions(-) rename paper-server/patches/{features-unapplied => features}/0001-Moonrise-optimisation-patches.patch (97%) diff --git a/paper-server/patches/features-unapplied/0001-Moonrise-optimisation-patches.patch b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch similarity index 97% rename from paper-server/patches/features-unapplied/0001-Moonrise-optimisation-patches.patch rename to paper-server/patches/features/0001-Moonrise-optimisation-patches.patch index bb3b428fc387..8286ae41fe15 100644 --- a/paper-server/patches/features-unapplied/0001-Moonrise-optimisation-patches.patch +++ b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch @@ -297,7 +297,7 @@ index 0000000000000000000000000000000000000000..1b8193587814225c2ef2c5d9e667436e + } +} diff --git a/ca/spottedleaf/moonrise/paper/PaperHooks.java b/ca/spottedleaf/moonrise/paper/PaperHooks.java -index e4f0653c575c33b1ef8160b6c88e29ee9fb44508..05b65330c1566e7e0045ea87e2111e8ff04b2333 100644 +index c50f13c735c97b0418cfe97d7d99b74bfb08b842..a91bcda9d6d8c8d75bce45373944743c55a1b4a5 100644 --- a/ca/spottedleaf/moonrise/paper/PaperHooks.java +++ b/ca/spottedleaf/moonrise/paper/PaperHooks.java @@ -13,6 +13,7 @@ import net.minecraft.server.level.ChunkHolder; @@ -306,7 +306,7 @@ index e4f0653c575c33b1ef8160b6c88e29ee9fb44508..05b65330c1566e7e0045ea87e2111e8f import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.TicketType; import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.boss.EnderDragonPart; + import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; import net.minecraft.world.level.BlockGetter; @@ -150,7 +151,15 @@ public final class PaperHooks extends BaseChunkSystemHooks implements PlatformHo @@ -334,13 +334,6 @@ index e4f0653c575c33b1ef8160b6c88e29ee9fb44508..05b65330c1566e7e0045ea87e2111e8f } } -@@ -252,4 +261,4 @@ public final class PaperHooks extends BaseChunkSystemHooks implements PlatformHo - public boolean addTicketForEnderPearls(final ServerLevel world) { - return !world.paperConfig().misc.legacyEnderPearlBehavior; - } --} -\ No newline at end of file -+} diff --git a/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java b/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java index ce81e9f4f1e80be3b4f0cbdd95609990f9006534..3e7b616cbd196f56393719e84c7118ab47308337 100644 --- a/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java @@ -1120,7 +1113,7 @@ index 0000000000000000000000000000000000000000..f77ba1b6aaedf6c8c1e0c49ff2779eb4 +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/entity/ChunkSystemEntity.java b/ca/spottedleaf/moonrise/patches/chunk_system/entity/ChunkSystemEntity.java new file mode 100644 -index 0000000000000000000000000000000000000000..1d2498e33b9cd5a22cb348a213be3d75281b6d24 +index 0000000000000000000000000000000000000000..c351a80c5c47f3f5148dec93219e1a7ee22e9056 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/entity/ChunkSystemEntity.java @@ -0,0 +1,45 @@ @@ -1129,10 +1122,10 @@ index 0000000000000000000000000000000000000000..1d2498e33b9cd5a22cb348a213be3d75 +import ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkData; +import net.minecraft.server.level.FullChunkStatus; +import net.minecraft.world.entity.Entity; -+import net.minecraft.world.entity.animal.HappyGhast; ++import net.minecraft.world.entity.animal.happyghast.HappyGhast; +import net.minecraft.world.entity.monster.Shulker; -+import net.minecraft.world.entity.vehicle.AbstractMinecart; -+import net.minecraft.world.entity.vehicle.Boat; ++import net.minecraft.world.entity.vehicle.minecart.AbstractMinecart; ++import net.minecraft.world.entity.vehicle.boat.Boat; + +public interface ChunkSystemEntity { + @@ -2703,24 +2696,22 @@ index 0000000000000000000000000000000000000000..344e155420de9148cd402f626af11d4c +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/io/datacontroller/ChunkDataController.java b/ca/spottedleaf/moonrise/patches/chunk_system/io/datacontroller/ChunkDataController.java new file mode 100644 -index 0000000000000000000000000000000000000000..a36ab89f5c37f5f9ab0152f087bb4cf3560f8581 +index 0000000000000000000000000000000000000000..633e85bf7824fec10c81b2a64756a7ef756cd481 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/io/datacontroller/ChunkDataController.java -@@ -0,0 +1,50 @@ +@@ -0,0 +1,48 @@ +package ca.spottedleaf.moonrise.patches.chunk_system.io.datacontroller; + +import ca.spottedleaf.moonrise.patches.chunk_system.io.ChunkSystemRegionFileStorage; +import ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO; +import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemChunkMap; +import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler; -+import ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemChunkStorage; ++import ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemSimpleRegionStorage; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.chunk.storage.RegionFileStorage; +import java.io.IOException; -+import java.util.concurrent.CompletableFuture; -+import java.util.concurrent.CompletionException; + +public final class ChunkDataController extends MoonriseRegionFileIO.RegionDataController { + @@ -2733,7 +2724,7 @@ index 0000000000000000000000000000000000000000..a36ab89f5c37f5f9ab0152f087bb4cf3 + + @Override + public RegionFileStorage getCache() { -+ return ((ChunkSystemChunkStorage)this.world.getChunkSource().chunkMap).moonrise$getRegionStorage(); ++ return ((ChunkSystemSimpleRegionStorage)this.world.getChunkSource().chunkMap).moonrise$getRegionStorage(); + } + + @Override @@ -3164,7 +3155,7 @@ index 0000000000000000000000000000000000000000..59cbbf65c9df5c680b803f6dd6436a35 +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java new file mode 100644 -index 0000000000000000000000000000000000000000..c380487a97f626163e1f13d87231d64ce2ea4b24 +index 0000000000000000000000000000000000000000..c2363cfa5e93942fe837efd9f39478698f6d1a98 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java @@ -0,0 +1,591 @@ @@ -3189,7 +3180,7 @@ index 0000000000000000000000000000000000000000..c380487a97f626163e1f13d87231d64c +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntitySpawnReason; +import net.minecraft.world.entity.EntityType; -+import net.minecraft.world.entity.boss.EnderDragonPart; ++import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; +import net.minecraft.world.entity.boss.enderdragon.EnderDragon; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; @@ -5027,7 +5018,7 @@ index 0000000000000000000000000000000000000000..2ff58cf753c60913ee73aae015182e9c +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java new file mode 100644 -index 0000000000000000000000000000000000000000..a2fbc13105673e926cbaed69221826ebd392140f +index 0000000000000000000000000000000000000000..2bc436cdf5180a7943c45fabb9fbbedae6f7db56 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java @@ -0,0 +1,166 @@ @@ -5047,7 +5038,7 @@ index 0000000000000000000000000000000000000000..a2fbc13105673e926cbaed69221826eb +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.TicketType; +import net.minecraft.world.entity.Entity; -+import net.minecraft.world.entity.projectile.ThrownEnderpearl; ++import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl; +import net.minecraft.world.level.entity.LevelCallback; + +public final class ServerEntityLookup extends EntityLookup { @@ -5490,7 +5481,7 @@ index 0000000000000000000000000000000000000000..003a857e70ead858e8437e3c1bfaf22f +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java b/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java new file mode 100644 -index 0000000000000000000000000000000000000000..8697528095ebed543ee1bb3b6b617a26a800bd5d +index 0000000000000000000000000000000000000000..7129c5e1920008ac54f3a8ac83f5589396f4e4e9 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java @@ -0,0 +1,1093 @@ @@ -5529,10 +5520,10 @@ index 0000000000000000000000000000000000000000..8697528095ebed543ee1bb3b6b617a26 +import net.minecraft.server.level.TicketType; +import net.minecraft.server.network.PlayerChunkSender; +import net.minecraft.world.level.ChunkPos; -+import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.status.ChunkStatus; ++import net.minecraft.world.level.gamerules.GameRules; +import net.minecraft.world.level.levelgen.BelowZeroRetrogen; +import java.lang.invoke.VarHandle; +import java.util.ArrayDeque; @@ -6055,7 +6046,7 @@ index 0000000000000000000000000000000000000000..8697528095ebed543ee1bb3b6b617a26 + } + + private boolean canPlayerGenerateChunks() { -+ return !this.player.isSpectator() || this.world.getGameRules().getBoolean(GameRules.RULE_SPECTATORSGENERATECHUNKS); ++ return !this.player.isSpectator() || this.world.getGameRules().get(GameRules.SPECTATORS_GENERATE_CHUNKS); + } + + private double getMaxChunkLoadRate() { @@ -13171,7 +13162,7 @@ index 0000000000000000000000000000000000000000..4538ccfaea83d217ed85eaf16e82393c +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkLoadTask.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkLoadTask.java new file mode 100644 -index 0000000000000000000000000000000000000000..d1d68bacc86e4a4e785e3180b9aeb766c025eccb +index 0000000000000000000000000000000000000000..7463cf5bf871033a0e5f6d54dd0d427c474d7cd4 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkLoadTask.java @@ -0,0 +1,494 @@ @@ -13517,7 +13508,7 @@ index 0000000000000000000000000000000000000000..d1d68bacc86e4a4e785e3180b9aeb766 + + try { + // run converters -+ final CompoundTag converted = this.world.getChunkSource().chunkMap.upgradeChunkTag(data, new ChunkPos(this.chunkX, this.chunkZ)); // Paper ++ final CompoundTag converted = this.world.getChunkSource().chunkMap.upgradeChunkTag(data); + + // unpack the data + final SerializableChunkData chunkData = SerializableChunkData.parse( @@ -14729,21 +14720,6 @@ index 0000000000000000000000000000000000000000..51c126735ace8fdde89ad97b5cab62f2 + + public void moonrise$write(final RegionFile regionFile) throws IOException; +} -diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemChunkStorage.java b/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemChunkStorage.java -new file mode 100644 -index 0000000000000000000000000000000000000000..129a35ff2db5b3bb6736810fc180796ce55e1875 ---- /dev/null -+++ b/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemChunkStorage.java -@@ -0,0 +1,9 @@ -+package ca.spottedleaf.moonrise.patches.chunk_system.storage; -+ -+import net.minecraft.world.level.chunk.storage.RegionFileStorage; -+ -+public interface ChunkSystemChunkStorage { -+ -+ public RegionFileStorage moonrise$getRegionStorage(); -+ -+} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemRegionFile.java b/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemRegionFile.java new file mode 100644 index 0000000000000000000000000000000000000000..3bd1b59250dbab15097a64d515999b278636795a @@ -14762,6 +14738,21 @@ index 0000000000000000000000000000000000000000..3bd1b59250dbab15097a64d515999b27 + public MoonriseRegionFileIO.RegionDataController.WriteData moonrise$startWrite(final CompoundTag data, final ChunkPos pos) throws IOException; + +} +diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemSimpleRegionStorage.java b/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemSimpleRegionStorage.java +new file mode 100644 +index 0000000000000000000000000000000000000000..76a480dea1cfe1cf118c1a0b10ca5c5718917420 +--- /dev/null ++++ b/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemSimpleRegionStorage.java +@@ -0,0 +1,9 @@ ++package ca.spottedleaf.moonrise.patches.chunk_system.storage; ++ ++import net.minecraft.world.level.chunk.storage.RegionFileStorage; ++ ++public interface ChunkSystemSimpleRegionStorage { ++ ++ public RegionFileStorage moonrise$getRegionStorage(); ++ ++} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/ticket/ChunkSystemTicket.java b/ca/spottedleaf/moonrise/patches/chunk_system/ticket/ChunkSystemTicket.java new file mode 100644 index 0000000000000000000000000000000000000000..4536f675a8496c3b1681278cf56453a21d656cfe @@ -15623,7 +15614,7 @@ index 0000000000000000000000000000000000000000..1414f25ef770b0fe73ea618a450ade2f +} diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java new file mode 100644 -index 0000000000000000000000000000000000000000..2082b7506a403ed6815076cbd0d3b7eecd7225a0 +index 0000000000000000000000000000000000000000..817e4ffd597938697f0c4dca16068f8d20c088b3 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java @@ -0,0 +1,2190 @@ @@ -15643,7 +15634,7 @@ index 0000000000000000000000000000000000000000..2082b7506a403ed6815076cbd0d3b7ee +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; -+import net.minecraft.world.entity.vehicle.AbstractMinecart; ++import net.minecraft.world.entity.vehicle.minecart.AbstractMinecart; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.CollisionGetter; +import net.minecraft.world.level.Level; @@ -22265,7 +22256,7 @@ index 0000000000000000000000000000000000000000..95154636727366adfb4fb67e7db8b09f + private SaveUtil() {} +} diff --git a/io/papermc/paper/FeatureHooks.java b/io/papermc/paper/FeatureHooks.java -index 6f97231787dd422d2462135b11092aa6339332ac..045778402404d46610165d15d8d430d6ae968688 100644 +index 61c526263cfbd1871f6b8548ed4431a76ee95a31..485413cb6b20c4bd20fbc29a0db43c051993fe79 100644 --- a/io/papermc/paper/FeatureHooks.java +++ b/io/papermc/paper/FeatureHooks.java @@ -1,6 +1,9 @@ @@ -22471,7 +22462,7 @@ index 6f97231787dd422d2462135b11092aa6339332ac..045778402404d46610165d15d8d430d6 } public static java.util.concurrent.Executor getWorldgenExecutor() { -- return net.minecraft.Util.backgroundExecutor(); +- return net.minecraft.util.Util.backgroundExecutor(); + return Runnable::run; // Paper - rewrite chunk system } @@ -22490,8 +22481,9 @@ index 6f97231787dd422d2462135b11092aa6339332ac..045778402404d46610165d15d8d430d6 + ((ca.spottedleaf.moonrise.patches.chunk_system.player.ChunkSystemServerPlayer)player).moonrise$getViewDistanceHolder().setSendViewDistance(distance); // Paper - rewrite chunk system } - } +-} \ No newline at end of file ++} diff --git a/io/papermc/paper/command/subcommands/ChunkDebugCommand.java b/io/papermc/paper/command/subcommands/ChunkDebugCommand.java new file mode 100644 index 0000000000000000000000000000000000000000..2dca7afbd93cfbb8686f336fcd3b45dd01fba0fc @@ -22914,12 +22906,12 @@ index 0000000000000000000000000000000000000000..8424cf9d4617b4732d44cc460d25b044 + +} diff --git a/net/minecraft/core/Direction.java b/net/minecraft/core/Direction.java -index f8d2e0f2e21668dd34bd61455b34c0b2b818ddb1..cbb743ce94f08b624a64555d057ed04286094ba9 100644 +index 3a5aad2acd2a7ac1f0fc3c33f1705c5d737cb10c..9926682586fda91017e3e1ab079296a8c4a88879 100644 --- a/net/minecraft/core/Direction.java +++ b/net/minecraft/core/Direction.java -@@ -29,7 +29,7 @@ import org.joml.Quaternionf; - import org.joml.Vector3f; +@@ -29,7 +29,7 @@ import org.joml.Vector3f; import org.joml.Vector3fc; + import org.jspecify.annotations.Nullable; -public enum Direction implements StringRepresentable { +public enum Direction implements StringRepresentable, ca.spottedleaf.moonrise.patches.collisions.util.CollisionDirection { // Paper - optimise collisions @@ -23004,7 +22996,7 @@ index f8d2e0f2e21668dd34bd61455b34c0b2b818ddb1..cbb743ce94f08b624a64555d057ed042 } public Direction getClockWise(Direction.Axis axis) { -@@ -633,4 +672,17 @@ public enum Direction implements StringRepresentable { +@@ -629,4 +668,17 @@ public enum Direction implements StringRepresentable { return this.faces.length; } } @@ -23023,10 +23015,10 @@ index f8d2e0f2e21668dd34bd61455b34c0b2b818ddb1..cbb743ce94f08b624a64555d057ed042 + // Paper end - optimise collisions } diff --git a/net/minecraft/core/MappedRegistry.java b/net/minecraft/core/MappedRegistry.java -index 737f61ba5ff7752e94f3c8316f823db60e35bc3f..1610198bd96e0d79debdeddc360500e98cd28504 100644 +index fd09226af661a6970062ee11d38f6e69464fb74b..ad1558693564ebd18f5e16b85ae552d2af95efef 100644 --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java -@@ -57,6 +57,19 @@ public class MappedRegistry implements WritableRegistry { +@@ -56,6 +56,19 @@ public class MappedRegistry implements WritableRegistry { return this.getTags(); } @@ -23046,32 +23038,32 @@ index 737f61ba5ff7752e94f3c8316f823db60e35bc3f..1610198bd96e0d79debdeddc360500e9 public MappedRegistry(ResourceKey> key, Lifecycle registryLifecycle) { this(key, registryLifecycle, false); } -@@ -122,6 +135,7 @@ public class MappedRegistry implements WritableRegistry { +@@ -121,6 +134,7 @@ public class MappedRegistry implements WritableRegistry { this.registrationInfos.put(key, registrationInfo); this.registryLifecycle = this.registryLifecycle.add(registrationInfo.lifecycle()); - this.temporaryUnfrozenMap.put(key.location(), value); // Paper - support pre-filling in registry mod API + this.temporaryUnfrozenMap.put(key.identifier(), value); // Paper - support pre-filling in registry mod API + this.injectFluidRegister(key, value); // Paper - fluid method optimisations return reference; } } diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java -index 13424bce076493f146bdc5fd0b1f2e09805bd5e7..2de7072c8ccc005e514673bba494b64d42e95a15 100644 +index cda915fcb4822689f42b25280eb99aee082ddb74..094d2d528cb74b8f1d277cd780bba7f438dbe764 100644 --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -301,6 +301,7 @@ public class Main { +@@ -299,6 +299,7 @@ public class Main { levelStorageAccess.saveDataTag(frozen, worldData); */ -+ Class.forName(net.minecraft.world.entity.npc.VillagerTrades.class.getName()); // Paper - load this sync so it won't fail later async ++ Class.forName(net.minecraft.world.entity.npc.villager.VillagerTrades.class.getName()); // Paper - load this sync so it won't fail later async final DedicatedServer dedicatedServer = MinecraftServer.spin( thread1 -> { DedicatedServer dedicatedServer1 = new DedicatedServer( diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index ab95014e66a7e217024ad9845669cc77fbbb13c2..40730d5775ed81bd715960b2c7dd710ca11dcb0e 100644 +index be6e4b5e485e10d37b5194c214f69b677622cc8a..bdaca3647425711ee8b10eb0593a9c3cb4037ede 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -177,7 +177,7 @@ import net.minecraft.world.phys.Vec2; - import net.minecraft.world.phys.Vec3; +@@ -185,7 +185,7 @@ import net.minecraft.world.scores.ScoreboardSaveData; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ServerInfo, CommandSource, ChunkIOErrorReporter { @@ -23079,7 +23071,7 @@ index ab95014e66a7e217024ad9845669cc77fbbb13c2..40730d5775ed81bd715960b2c7dd710c private static MinecraftServer SERVER; // Paper public static final Logger LOGGER = LogUtils.getLogger(); public static final net.kyori.adventure.text.logger.slf4j.ComponentLogger COMPONENT_LOGGER = net.kyori.adventure.text.logger.slf4j.ComponentLogger.logger(LOGGER.getName()); // Paper -@@ -393,6 +393,93 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop false : this::haveTime); -+ // Paper start - rewrite chunk system -+ final Throwable crash = this.chunkSystemCrash; -+ if (crash != null) { -+ this.chunkSystemCrash = null; -+ throw new RuntimeException("Chunk system crash propagated to tick()", crash); -+ } -+ // Paper end - rewrite chunk system - this.tickFrame.end(); - this.recordEndOfTick(); // Paper - improve tick loop - profilerFiller.popPush("nextTickWait"); -@@ -1399,6 +1514,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop false : this::haveTime); ++ // Paper start - rewrite chunk system ++ final Throwable crash = this.chunkSystemCrash; ++ if (crash != null) { ++ this.chunkSystemCrash = null; ++ throw new RuntimeException("Chunk system crash propagated to tick()", crash); ++ } ++ // Paper end - rewrite chunk system + this.tickFrame.end(); + this.recordEndOfTick(); // Paper - improve tick loop + profilerFiller.pop(); +@@ -2559,6 +2678,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> getTickingChunkFuture() { @@ -23536,8 +23523,7 @@ index b95de132c53f82d270de396787dda3be8bc6c910..656041c9539b6834b4d37b353eb6b810 + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } - @Nullable - public final LevelChunk getTickingChunk() { // Paper - final for inline + public final @Nullable LevelChunk getTickingChunk() { // Paper - final for inline - return this.getTickingChunkFuture().getNow(UNLOADED_LEVEL_CHUNK).orElse(null); + // Paper start - rewrite chunk system + if (this.newChunkHolder.isTickingReady()) { @@ -23549,8 +23535,7 @@ index b95de132c53f82d270de396787dda3be8bc6c910..656041c9539b6834b4d37b353eb6b810 + // Paper end - rewrite chunk system } - @Nullable - public LevelChunk getChunkToSend() { + public @Nullable LevelChunk getChunkToSend() { - return !this.sendSync.isDone() ? null : this.getTickingChunk(); + // Paper start - rewrite chunk system + final LevelChunk ret = this.moonrise$getFullChunk(); @@ -23833,34 +23818,32 @@ index b95de132c53f82d270de396787dda3be8bc6c910..656041c9539b6834b4d37b353eb6b810 @FunctionalInterface diff --git a/net/minecraft/server/level/ChunkLevel.java b/net/minecraft/server/level/ChunkLevel.java -index e823b8aac00158892538083bc877ccf99895909a..7d871318065f19540748363809de82652613e733 100644 +index 3a6fb3b46d94e23357be8af241340e3de06b7c7c..a5ce3593e92e6771f3c8df23ba1bf4d7872c9304 100644 --- a/net/minecraft/server/level/ChunkLevel.java +++ b/net/minecraft/server/level/ChunkLevel.java -@@ -7,8 +7,8 @@ import net.minecraft.world.level.chunk.status.ChunkStep; - import org.jetbrains.annotations.Contract; +@@ -8,7 +8,7 @@ import org.jspecify.annotations.Nullable; public class ChunkLevel { -- private static final int FULL_CHUNK_LEVEL = 33; + public static final int FULL_CHUNK_LEVEL = 33; // Paper - public - private static final int BLOCK_TICKING_LEVEL = 32; -+ public static final int FULL_CHUNK_LEVEL = 33; + public static final int BLOCK_TICKING_LEVEL = 32; public static final int ENTITY_TICKING_LEVEL = 31; private static final ChunkStep FULL_CHUNK_STEP = ChunkPyramid.GENERATION_PYRAMID.getStepTo(ChunkStatus.FULL); public static final int RADIUS_AROUND_FULL_CHUNK = FULL_CHUNK_STEP.accumulatedDependencies().getRadius(); diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d4f31d69a 100644 +index 8519ad77190ef51acdd940794faf73e292169c63..b0b4e5c96498eef48fe0cb2637faed73409941ad 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -102,7 +102,7 @@ import net.minecraft.world.phys.Vec3; - import org.apache.commons.lang3.mutable.MutableBoolean; +@@ -108,7 +108,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; --public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider, GeneratingChunkMap { -+public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider, GeneratingChunkMap, ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemChunkMap { // Paper - rewrite chunk system +-public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerProvider, GeneratingChunkMap { ++public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerProvider, GeneratingChunkMap, ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemChunkMap { // Paper - rewrite chunk system private static final ChunkResult> UNLOADED_CHUNK_LIST_RESULT = ChunkResult.error("Unloaded chunks found in range"); private static final CompletableFuture>> UNLOADED_CHUNK_LIST_FUTURE = CompletableFuture.completedFuture( UNLOADED_CHUNK_LIST_RESULT -@@ -118,10 +118,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -124,10 +124,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP public static final int MIN_VIEW_DISTANCE = 2; public static final int MAX_VIEW_DISTANCE = 32; public static final int FORCED_TICKET_LEVEL = ChunkLevel.byStatus(FullChunkStatus.ENTITY_TICKING); @@ -23872,7 +23855,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d public final ServerLevel level; private final ThreadedLevelLightEngine lightEngine; private final BlockableEventLoop mainThreadExecutor; -@@ -132,20 +129,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -137,20 +134,16 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP private final PoiManager poiManager; public final LongSet toDrop = new LongOpenHashSet(); private boolean modified; @@ -23896,7 +23879,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback() public final CallbackExecutor callbackExecutor = new CallbackExecutor(); -@@ -170,9 +163,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -175,9 +168,16 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP // Paper start public final ChunkHolder getUnloadingChunkHolder(int chunkX, int chunkZ) { @@ -23908,13 +23891,13 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d + @Override + public final void moonrise$writeFinishCallback(final ChunkPos pos) throws IOException { + // see ChunkStorage#write -+ this.handleLegacyStructureIndex(pos); ++ this.markChunkDone(pos); + } + // Paper end - rewrite chunk system public ChunkMap( ServerLevel level, -@@ -217,10 +217,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -224,10 +224,9 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP ConsecutiveExecutor consecutiveExecutor = new ConsecutiveExecutor(dispatcher, "worldgen"); this.chunkStatusListener = chunkStatusListener; ConsecutiveExecutor consecutiveExecutor1 = new ConsecutiveExecutor(dispatcher, "light"); @@ -23926,8 +23909,8 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d + lightChunk, this, this.level.dimensionType().hasSkyLight(), consecutiveExecutor1, null // Paper - rewrite chunk system ); this.distanceManager = new ChunkMap.DistanceManager(ticketStorage, dispatcher, mainThreadExecutor); - this.overworldDataStorage = overworldDataStorage; -@@ -235,11 +234,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + this.ticketStorage = ticketStorage; +@@ -241,11 +240,11 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP level ); this.setServerViewDistance(serverViewDistance); @@ -23941,7 +23924,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } // Paper start -@@ -261,23 +260,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -267,23 +266,11 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public boolean isChunkTracked(ServerPlayer player, int x, int z) { @@ -23967,10 +23950,10 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } protected ThreadedLevelLightEngine getLightEngine() { -@@ -286,12 +273,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -291,11 +278,17 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP + } - @Nullable - public ChunkHolder getUpdatingChunkIfPresent(long chunkPos) { + public @Nullable ChunkHolder getUpdatingChunkIfPresent(long chunkPos) { - return this.updatingChunkMap.get(chunkPos); + // Paper start - rewrite chunk system + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder holder = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(chunkPos); @@ -23978,8 +23961,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d + // Paper end - rewrite chunk system } - @Nullable - public ChunkHolder getVisibleChunkIfPresent(long chunkPos) { + public @Nullable ChunkHolder getVisibleChunkIfPresent(long chunkPos) { - return this.visibleChunkMap.get(chunkPos); + // Paper start - rewrite chunk system + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder holder = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(chunkPos); @@ -23987,8 +23969,8 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d + // Paper end - rewrite chunk system } - @Nullable -@@ -301,12 +294,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + public @Nullable ChunkStatus getLatestStatus(long chunkPos) { +@@ -304,12 +297,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } protected IntSupplier getChunkQueueLevel(long chunkPos) { @@ -24002,7 +23984,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } public String getChunkDebugData(ChunkPos pos) { -@@ -332,47 +320,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -335,47 +323,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } CompletableFuture>> getChunkRangeFuture(ChunkHolder chunkHolder, int range, IntFunction statusGetter) { @@ -24051,7 +24033,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } public ReportedException debugFuturesAndCreateReportedException(IllegalStateException exception, String details) { -@@ -404,93 +352,29 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -407,92 +355,28 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public CompletableFuture> prepareEntityTickingChunk(ChunkHolder chunk) { @@ -24060,8 +24042,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } - @Nullable - ChunkHolder updateChunkScheduling(long chunkPos, int newLevel, @Nullable ChunkHolder holder, int oldLevel) { + @Nullable ChunkHolder updateChunkScheduling(long chunkPos, int newLevel, @Nullable ChunkHolder holder, int oldLevel) { - if (!ChunkLevel.isLoaded(oldLevel) && !ChunkLevel.isLoaded(newLevel)) { - return holder; - } else { @@ -24137,7 +24118,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d - - this.poiManager.flushAll(); - this.processUnloads(() -> true); -- this.flushWorker(); +- this.synchronize(true).join(); - } else { - this.nextChunkSaveTime.clear(); - long millis = Util.getMillis(); @@ -24154,7 +24135,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } protected void tick(BooleanSupplier hasMoreTime) { -@@ -506,129 +390,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -508,129 +392,28 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public boolean hasWork() { @@ -24291,7 +24272,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } private ChunkAccess handleChunkLoadFailure(Throwable exception, ChunkPos chunkPos) { -@@ -666,230 +449,129 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -665,230 +448,134 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP @Override public GenerationChunkHolder acquireGeneration(long chunkPos) { @@ -24548,8 +24529,8 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d private static void dropChunk(ServerPlayer player, ChunkPos chunkPos) { - player.connection.chunkSender.dropChunk(player, chunkPos); + // Paper - rewrite chunk system - } - ++ } ++ + // Paper start - rewrite chunk system + @Override + public CompletableFuture> read(final ChunkPos pos) { @@ -24576,25 +24557,33 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d + ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionFileType.CHUNK_DATA + ); + return null; -+ } -+ + } + + @Override -+ public void flushWorker() { -+ ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.flush(this.level); ++ public CompletableFuture synchronize(boolean flush) { ++ try { ++ ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.flush(this.level); ++ return CompletableFuture.completedFuture(null); ++ } catch (final Exception ex) { ++ return CompletableFuture.failedFuture(ex); ++ } + } + // Paper end - rewrite chunk system + - @Nullable - public LevelChunk getChunkToSend(long chunkPos) { + public @Nullable LevelChunk getChunkToSend(long chunkPos) { ChunkHolder visibleChunkIfPresent = this.getVisibleChunkIfPresent(chunkPos); -@@ -971,28 +653,71 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + return visibleChunkIfPresent == null ? null : visibleChunkIfPresent.getChunkToSend(); +@@ -968,7 +655,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP + return this.read(pos).thenApplyAsync(optional -> optional.map(this::upgradeChunkTag), Util.backgroundExecutor().forName("upgradeChunk")); } - // CraftBukkit start -- private CompoundTag upgradeChunkTag(CompoundTag tag, ChunkPos pos) { -+ public CompoundTag upgradeChunkTag(CompoundTag tag, ChunkPos pos) { // Paper - public - return this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, tag, this.generator().getTypeNameForDataFixer(), pos, this.level); - // CraftBukkit end +- private CompoundTag upgradeChunkTag(CompoundTag tag) { ++ public CompoundTag upgradeChunkTag(CompoundTag tag) { // Paper - rewrite chunk system - public + return this.upgradeChunkTag(tag, -1, getChunkDataFixContextTag(this.level.getTypeKey(), this.generator().getTypeNameForDataFixer()), this.level); // CraftBukkit + } + +@@ -979,23 +666,66 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP + return compoundTag; } + // Paper start - optimise chunk tick iteration @@ -24669,7 +24658,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d if (chunkHolder != null) { LevelChunk tickingChunk = chunkHolder.getTickingChunk(); if (tickingChunk != null) { -@@ -1008,8 +733,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1011,8 +741,8 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkPos, boolean reducedRange) { @@ -24680,7 +24669,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d // Spigot end } -@@ -1021,7 +746,20 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1036,7 +766,20 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP private boolean anyPlayerCloseEnoughForSpawningInternal(ChunkPos chunkPos, boolean reducedRange) { double blockRange; // Paper - use from event // Spigot end @@ -24702,7 +24691,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d // Paper start - PlayerNaturallySpawnCreaturesEvent com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event; blockRange = 16384.0D; -@@ -1037,26 +775,41 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1052,26 +795,41 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } return false; @@ -24755,7 +24744,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d if (player.isSpectator()) { return false; } else { -@@ -1085,18 +838,20 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1109,18 +867,20 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP this.updatePlayerPos(player); if (!flag) { this.distanceManager.addPlayer(SectionPos.of(player), player); @@ -24778,7 +24767,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } } -@@ -1106,13 +861,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1130,13 +890,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public void move(ServerPlayer player) { @@ -24793,7 +24782,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d SectionPos lastSectionPos = player.getLastSectionPos(); SectionPos sectionPos = SectionPos.of(player); -@@ -1121,6 +870,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1145,6 +899,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP boolean flag2 = lastSectionPos.asLong() != sectionPos.asLong(); if (flag2 || flag != flag1) { this.updatePlayerPos(player); @@ -24801,7 +24790,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d if (!flag) { this.distanceManager.removePlayer(lastSectionPos, player); } -@@ -1137,49 +887,29 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1161,49 +916,29 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP this.playerMap.unIgnorePlayer(player); } @@ -24862,7 +24851,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } public void addEntity(Entity entity) { -@@ -1203,6 +933,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1227,6 +962,12 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } else { ChunkMap.TrackedEntity trackedEntity = new ChunkMap.TrackedEntity(entity, i, updateInterval, type.trackDeltas()); this.entityMap.put(entity.getId(), trackedEntity); @@ -24875,7 +24864,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d trackedEntity.updatePlayers(this.level.players()); if (entity instanceof ServerPlayer serverPlayer) { this.updatePlayerStatus(serverPlayer, true); -@@ -1232,12 +968,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1256,12 +997,38 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP if (trackedEntity1 != null) { trackedEntity1.broadcastRemoved(); } @@ -24916,7 +24905,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d List list = Lists.newArrayList(); List list1 = this.level.players(); -@@ -1335,17 +1097,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1359,17 +1126,11 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public void waitForLightBeforeSending(ChunkPos chunkPos, int range) { @@ -24936,7 +24925,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d LevelChunk chunkToSend = chunkHolder.getChunkToSend(); if (chunkToSend != null) { action.accept(chunkToSend); -@@ -1353,14 +1109,21 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1377,14 +1138,21 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } } @@ -24959,8 +24948,8 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } - @Nullable -@@ -1376,13 +1139,96 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + @Override +@@ -1398,13 +1166,96 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } } @@ -25058,7 +25047,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) { this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this, this.seenBy); // Paper this.entity = entity; -@@ -1492,17 +1338,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1514,17 +1365,24 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } private int getEffectiveRange() { @@ -25092,11 +25081,11 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d public void updatePlayers(List playersList) { diff --git a/net/minecraft/server/level/DistanceManager.java b/net/minecraft/server/level/DistanceManager.java -index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f5b3bbf5b 100644 +index d444c29800e103de55bfb99fd8671ee69b003419..8a5c37cf572abc6b9526648d3c8ec92b7af37e3d 100644 --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -31,30 +31,63 @@ import net.minecraft.world.level.TicketStorage; - import net.minecraft.world.level.chunk.LevelChunk; +@@ -31,96 +31,79 @@ import net.minecraft.world.level.chunk.LevelChunk; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public abstract class DistanceManager { @@ -25129,6 +25118,9 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f + this.ticketStorage.moonrise$setChunkMap(this.moonrise$getChunkMap()); // Paper - rewrite chunk system } +- protected abstract boolean isChunkToRemove(long chunkPos); +- +- protected abstract @Nullable ChunkHolder getChunk(long chunkPos); + // Paper start - rewrite chunk system + @Override + public final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkHolderManager moonrise$getChunkHolderManager() { @@ -25144,13 +25136,22 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f + this.spawnChunkTracker.add(player, pos.x(), pos.z(), ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickConstants.PLAYER_SPAWN_TRACK_RANGE); + // Note: Cannot do narrow tracking on Paper due to custom spawn range + } -+ + +- protected abstract @Nullable ChunkHolder updateChunkScheduling(long chunkPos, int newLevel, @Nullable ChunkHolder holder, int oldLevel); + @Override + public final void moonrise$removePlayer(final ServerPlayer player, final SectionPos pos) { + this.spawnChunkTracker.remove(player); + // Note: Cannot do narrow tracking on Paper due to custom spawn range + } -+ + +- public boolean runAllUpdates(ChunkMap chunkMap) { +- this.naturalSpawnChunkCounter.runAllUpdates(); +- this.simulationChunkTracker.runAllUpdates(); +- this.playerTicketManager.runAllUpdates(); +- int i = Integer.MAX_VALUE - this.loadingChunkTracker.runDistanceUpdates(Integer.MAX_VALUE); +- boolean flag = i != 0; +- if (flag && SharedConstants.DEBUG_VERBOSE_SERVER_EVENTS) { +- LOGGER.debug("DMU {}", i); + @Override + public final void moonrise$updatePlayer(final ServerPlayer player, + final SectionPos oldPos, final SectionPos newPos, @@ -25161,31 +25162,9 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f + } else { + this.spawnChunkTracker.addOrUpdate(player, newPos.x(), newPos.z(), ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickConstants.PLAYER_SPAWN_TRACK_RANGE); + // Note: Cannot do narrow tracking on Paper due to custom spawn range -+ } -+ } -+ -+ @Override -+ public final boolean moonrise$hasAnyNearbyNarrow(final int chunkX, final int chunkZ) { -+ throw new UnsupportedOperationException(); // Note: Cannot do narrow tracking on Paper due to custom spawn range + } + } -+ -+ // Paper end - chunk tick iteration optimisation - protected abstract boolean isChunkToRemove(long chunkPos); - - @Nullable -@@ -64,65 +97,15 @@ public abstract class DistanceManager { - protected abstract ChunkHolder updateChunkScheduling(long chunkPos, int newLevel, @Nullable ChunkHolder holder, int oldLevel); - public boolean runAllUpdates(ChunkMap chunkMap) { -- this.naturalSpawnChunkCounter.runAllUpdates(); -- this.simulationChunkTracker.runAllUpdates(); -- this.playerTicketManager.runAllUpdates(); -- int i = Integer.MAX_VALUE - this.loadingChunkTracker.runDistanceUpdates(Integer.MAX_VALUE); -- boolean flag = i != 0; -- if (flag && SharedConstants.DEBUG_VERBOSE_SERVER_EVENTS) { -- LOGGER.debug("DMU {}", i); -- } -- - if (!this.chunksToUpdateFutures.isEmpty()) { - // CraftBukkit start - SPIGOT-7780: Call chunk unload events before updateHighestAllowedStatus - for (final ChunkHolder chunkHolder : this.chunksToUpdateFutures) { @@ -25206,7 +25185,11 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f - } else { - if (!this.ticketsToRelease.isEmpty()) { - LongIterator longIterator = this.ticketsToRelease.iterator(); -- ++ @Override ++ public final boolean moonrise$hasAnyNearbyNarrow(final int chunkX, final int chunkZ) { ++ throw new UnsupportedOperationException(); // Note: Cannot do narrow tracking on Paper due to custom spawn range ++ } + - while (longIterator.hasNext()) { - long l = longIterator.nextLong(); - if (this.ticketStorage.getTickets(l).stream().anyMatch(ticket -> ticket.getType() == TicketType.PLAYER_LOADING)) { @@ -25214,19 +25197,24 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f - if (updatingChunkIfPresent == null) { - throw new IllegalStateException(); - } -- ++ // Paper end - chunk tick iteration optimisation ++ protected abstract boolean isChunkToRemove(long chunkPos); + - CompletableFuture> entityTickingChunkFuture = updatingChunkIfPresent.getEntityTickingChunkFuture(); - entityTickingChunkFuture.thenAccept( - chunkResult -> this.mainThreadExecutor.execute(() -> this.ticketDispatcher.release(l, () -> {}, false)) - ); - } - } -- ++ protected abstract @Nullable ChunkHolder getChunk(long chunkPos); + - this.ticketsToRelease.clear(); - } -- ++ protected abstract @Nullable ChunkHolder updateChunkScheduling(long chunkPos, int newLevel, @Nullable ChunkHolder holder, int oldLevel); + - return flag; - } ++ public boolean runAllUpdates(ChunkMap chunkMap) { + return this.moonrise$getChunkHolderManager().processTicketUpdates(); // Paper - rewrite chunk system } @@ -25242,7 +25230,7 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f } public void removePlayer(SectionPos sectionPos, ServerPlayer player) { -@@ -134,71 +117,79 @@ public abstract class DistanceManager { +@@ -132,71 +115,79 @@ public abstract class DistanceManager { if (set == null || set.isEmpty()) { // Paper end - some state corruption happens here, don't crash, clean up gracefully this.playersPerChunk.remove(packedChunkPos); @@ -25352,7 +25340,7 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f } public boolean hasTickets() { -@@ -250,6 +241,7 @@ public abstract class DistanceManager { +@@ -248,6 +239,7 @@ public abstract class DistanceManager { } } @@ -25360,7 +25348,7 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f class PlayerTicketTracker extends DistanceManager.FixedPlayerDistanceChunkTracker { private int viewDistance; private final Long2IntMap queueLevels = Long2IntMaps.synchronize(new Long2IntOpenHashMap()); -@@ -328,5 +320,5 @@ public abstract class DistanceManager { +@@ -326,5 +318,5 @@ public abstract class DistanceManager { private boolean haveTicketFor(int level) { return level <= this.viewDistance; } @@ -25368,25 +25356,24 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f + }*/ // Paper - rewrite chunk system } diff --git a/net/minecraft/server/level/GenerationChunkHolder.java b/net/minecraft/server/level/GenerationChunkHolder.java -index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a816ed4cbe9 100644 +index abbba6fbff118e8dc273a95243567f805cdaf3b7..3a7fbbb92c6960d30b981895e0d24f7676efc8ec 100644 --- a/net/minecraft/server/level/GenerationChunkHolder.java +++ b/net/minecraft/server/level/GenerationChunkHolder.java -@@ -27,13 +27,7 @@ public abstract class GenerationChunkHolder { +@@ -27,12 +27,7 @@ public abstract class GenerationChunkHolder { public static final ChunkResult UNLOADED_CHUNK = ChunkResult.error("Unloaded chunk"); public static final CompletableFuture> UNLOADED_CHUNK_FUTURE = CompletableFuture.completedFuture(UNLOADED_CHUNK); protected final ChunkPos pos; -- @Nullable -- private volatile ChunkStatus highestAllowedStatus; -- private final AtomicReference startedWork = new AtomicReference<>(); -- private final AtomicReferenceArray>> futures = new AtomicReferenceArray<>(CHUNK_STATUSES.size()); -- private final AtomicReference task = new AtomicReference<>(); +- private volatile @Nullable ChunkStatus highestAllowedStatus; +- private final AtomicReference<@Nullable ChunkStatus> startedWork = new AtomicReference<>(); +- private final AtomicReferenceArray<@Nullable CompletableFuture>> futures = new AtomicReferenceArray<>(CHUNK_STATUSES.size()); +- private final AtomicReference<@Nullable ChunkGenerationTask> task = new AtomicReference<>(); - private final AtomicInteger generationRefCount = new AtomicInteger(); - private volatile CompletableFuture generationSaveSyncFuture = CompletableFuture.completedFuture(null); + // Paper - rewrite chunk system public GenerationChunkHolder(ChunkPos pos) { this.pos = pos; -@@ -43,243 +37,96 @@ public abstract class GenerationChunkHolder { +@@ -42,238 +37,91 @@ public abstract class GenerationChunkHolder { } public CompletableFuture> scheduleChunkGenerationTask(ChunkStatus targetStatus, ChunkMap chunkMap) { @@ -25548,8 +25535,7 @@ index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a81 + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } - @Nullable - private ChunkStatus findHighestStatusWithPendingFuture(@Nullable ChunkStatus generationStatus) { + private @Nullable ChunkStatus findHighestStatusWithPendingFuture(@Nullable ChunkStatus generationStatus) { - if (generationStatus == null) { - return null; - } else { @@ -25615,8 +25601,7 @@ index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a81 + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } - @Nullable - public ChunkAccess getChunkIfPresentUnchecked(ChunkStatus status) { + public @Nullable ChunkAccess getChunkIfPresentUnchecked(ChunkStatus status) { - CompletableFuture> completableFuture = this.futures.get(status.getIndex()); - return completableFuture == null ? null : completableFuture.getNow(NOT_DONE_YET).orElse(null); + // Paper start - rewrite chunk system @@ -25624,16 +25609,14 @@ index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a81 + // Paper end - rewrite chunk system } - @Nullable - public ChunkAccess getChunkIfPresent(ChunkStatus status) { + public @Nullable ChunkAccess getChunkIfPresent(ChunkStatus status) { - return this.isStatusDisallowed(status) ? null : this.getChunkIfPresentUnchecked(status); + // Paper start - rewrite chunk system + return ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemChunkHolder)(Object)this).moonrise$getRealChunkHolder().getChunkIfPresent(status); + // Paper end - rewrite chunk system } - @Nullable - public ChunkAccess getLatestChunk() { + public @Nullable ChunkAccess getLatestChunk() { - ChunkStatus chunkStatus = this.startedWork.get(); - if (chunkStatus == null) { - return null; @@ -25647,8 +25630,7 @@ index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a81 + // Paper end - rewrite chunk system } - @Nullable - public ChunkStatus getPersistedStatus() { + public @Nullable ChunkStatus getPersistedStatus() { - CompletableFuture> completableFuture = this.futures.get(ChunkStatus.EMPTY.getIndex()); - ChunkAccess chunkAccess = completableFuture == null ? null : completableFuture.getNow(NOT_DONE_YET).orElse(null); - return chunkAccess == null ? null : chunkAccess.getPersistedStatus(); @@ -25659,7 +25641,7 @@ index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a81 } public ChunkPos getPos() { -@@ -287,7 +134,7 @@ public abstract class GenerationChunkHolder { +@@ -281,7 +129,7 @@ public abstract class GenerationChunkHolder { } public FullChunkStatus getFullStatus() { @@ -25668,10 +25650,10 @@ index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a81 } public abstract int getTicketLevel(); -@@ -296,24 +143,15 @@ public abstract class GenerationChunkHolder { +@@ -290,23 +138,14 @@ public abstract class GenerationChunkHolder { @VisibleForDebug - public List>>> getAllFutures() { + public List>>> getAllFutures() { - List>>> list = new ArrayList<>(); - - for (int i = 0; i < CHUNK_STATUSES.size(); i++) { @@ -25682,9 +25664,8 @@ index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a81 + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } - @Nullable @VisibleForDebug - public ChunkStatus getLatestStatus() { + public @Nullable ChunkStatus getLatestStatus() { - ChunkStatus chunkStatus = this.startedWork.get(); - if (chunkStatus == null) { - return null; @@ -25712,7 +25693,7 @@ index 302841522cf990c38b1493b716048c0f2db40726..7932a6676db7b652d63be5ae4dcf9bcf } } diff --git a/net/minecraft/server/level/PlayerSpawnFinder.java b/net/minecraft/server/level/PlayerSpawnFinder.java -index fbbddc9ae0ed4e28602ab1103d860e4639f19c8f..f637d14b0188728192b543d7841e99a98f0c5269 100644 +index d930750ae2ccfe72ff4fa574a49a024cb5f67baa..b5332b1632716679dcba2b36a9d4bb0070d9db88 100644 --- a/net/minecraft/server/level/PlayerSpawnFinder.java +++ b/net/minecraft/server/level/PlayerSpawnFinder.java @@ -122,9 +122,7 @@ public class PlayerSpawnFinder { @@ -25727,11 +25708,11 @@ index fbbddc9ae0ed4e28602ab1103d860e4639f19c8f..f637d14b0188728192b543d7841e99a9 if (throwable == null) { try { diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b43cd0ea6 100644 +index 4bf684986cadfa25ae475be4d54f0359e94b9e11..75fe6e026e3f91b66dcf5b97a86491d5277f7661 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -56,7 +56,7 @@ import net.minecraft.world.level.storage.DimensionDataStorage; - import net.minecraft.world.level.storage.LevelStorageSource; +@@ -55,7 +55,7 @@ import net.minecraft.world.level.storage.LevelStorageSource; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class ServerChunkCache extends ChunkSource { @@ -25739,7 +25720,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b private static final Logger LOGGER = LogUtils.getLogger(); private final DistanceManager distanceManager; private final ServerLevel level; -@@ -85,6 +85,106 @@ public class ServerChunkCache extends ChunkSource { +@@ -83,6 +83,106 @@ public class ServerChunkCache extends ChunkSource { } long chunkFutureAwaitCounter; // Paper end @@ -25818,7 +25799,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b + private final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom shuffleRandom = new ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom(0L); + private void iterateTickingChunksFaster() { + final ServerLevel world = this.level; -+ final int randomTickSpeed = world.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); ++ final int randomTickSpeed = world.getGameRules().get(GameRules.RANDOM_TICK_SPEED); + + // TODO check on update: impl of forEachBlockTickingChunk will only iterate ENTITY ticking chunks! + // TODO check on update: consumer just runs tickChunk @@ -25846,7 +25827,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b public ServerChunkCache( ServerLevel level, -@@ -143,13 +243,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -141,13 +241,7 @@ public class ServerChunkCache extends ChunkSource { } // CraftBukkit end // Paper start @@ -25861,10 +25842,10 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b @Nullable public ChunkAccess getChunkAtImmediately(int x, int z) { -@@ -216,68 +310,42 @@ public class ServerChunkCache extends ChunkSource { - @Nullable +@@ -212,67 +306,41 @@ public class ServerChunkCache extends ChunkSource { + @Override - public ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) { + public @Nullable ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) { - if (Thread.currentThread() != this.mainThread) { - return CompletableFuture.supplyAsync(() -> this.getChunk(x, z, chunkStatus, requireChunk), this.mainThreadProcessor).join(); - } else { @@ -25906,9 +25887,8 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b + // Paper end - rewrite chunk system } - @Nullable @Override - public LevelChunk getChunkNow(int chunkX, int chunkZ) { + public @Nullable LevelChunk getChunkNow(int chunkX, int chunkZ) { - if (Thread.currentThread() != this.mainThread) { - return null; - } else { @@ -25955,7 +25935,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b } private void clearCache() { -@@ -303,54 +371,59 @@ public class ServerChunkCache extends ChunkSource { +@@ -298,53 +366,58 @@ public class ServerChunkCache extends ChunkSource { } private CompletableFuture> getChunkFutureMainThread(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) { @@ -26035,9 +26015,8 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b + return this.getChunkNow(x, z) != null; // Paper - rewrite chunk system } - @Nullable @Override - public LightChunk getChunkForLighting(int chunkX, int chunkZ) { + public @Nullable LightChunk getChunkForLighting(int chunkX, int chunkZ) { - long packedChunkPos = ChunkPos.asLong(chunkX, chunkZ); - ChunkHolder visibleChunkIfPresent = this.getVisibleChunkIfPresent(packedChunkPos); - return visibleChunkIfPresent == null ? null : visibleChunkIfPresent.getChunkIfPresentUnchecked(ChunkStatus.INITIALIZE_LIGHT.getParent()); @@ -26051,7 +26030,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b } @Override -@@ -363,28 +436,18 @@ public class ServerChunkCache extends ChunkSource { +@@ -357,28 +430,18 @@ public class ServerChunkCache extends ChunkSource { } public boolean runDistanceManagerUpdates() { @@ -26086,7 +26065,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b this.chunkMap.saveAllChunks(flush); } -@@ -395,17 +458,15 @@ public class ServerChunkCache extends ChunkSource { +@@ -389,17 +452,15 @@ public class ServerChunkCache extends ChunkSource { } public void close(boolean save) throws IOException { @@ -26107,7 +26086,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b ProfilerFiller gameprofilerfiller = Profiler.get(); gameprofilerfiller.push("purge"); -@@ -429,6 +490,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -423,6 +484,7 @@ public class ServerChunkCache extends ChunkSource { this.runDistanceManagerUpdates(); profilerFiller.popPush("chunks"); if (tickChunks) { @@ -26115,7 +26094,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b this.tickChunks(); this.chunkMap.tick(); } -@@ -461,7 +523,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -455,7 +517,7 @@ public class ServerChunkCache extends ChunkSource { profiler.push("broadcast"); for (ChunkHolder chunkHolder : this.chunkHoldersToBroadcast) { @@ -26124,7 +26103,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b if (tickingChunk != null) { chunkHolder.broadcastChanges(tickingChunk); } -@@ -502,7 +564,10 @@ public class ServerChunkCache extends ChunkSource { +@@ -496,7 +558,10 @@ public class ServerChunkCache extends ChunkSource { profiler.popPush("filteringSpawningChunks"); this.chunkMap.collectSpawningChunks(list); profiler.popPush("shuffleSpawningChunks"); @@ -26136,16 +26115,16 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b profiler.popPush("tickSpawningChunks"); for (LevelChunk levelChunk : list) { -@@ -513,7 +578,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -507,7 +572,7 @@ public class ServerChunkCache extends ChunkSource { } profiler.popPush("tickTickingChunks"); -- this.chunkMap.forEachBlockTickingChunk(levelChunk1 -> this.level.tickChunk(levelChunk1, _int)); -+ this.iterateTickingChunksFaster(); // Paper - chunk tick iteration optimisations - if (_boolean) { +- this.chunkMap.forEachBlockTickingChunk(levelChunk1 -> this.level.tickChunk(levelChunk1, i)); ++ this.iterateTickingChunksFaster(); // Paper - chunk tick iteration optimizations + if (flag) { profiler.popPush("customSpawners"); this.level.tickCustomSpawners(this.spawnEnemies); -@@ -525,22 +590,25 @@ public class ServerChunkCache extends ChunkSource { +@@ -519,22 +584,25 @@ public class ServerChunkCache extends ChunkSource { private void tickSpawningChunk(LevelChunk chunk, long timeInhabited, List spawnCategories, NaturalSpawner.SpawnState spawnState) { ChunkPos pos = chunk.getPos(); chunk.incrementInhabitedTime(timeInhabited); @@ -26176,7 +26155,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b } @Override -@@ -598,17 +666,11 @@ public class ServerChunkCache extends ChunkSource { +@@ -592,17 +660,11 @@ public class ServerChunkCache extends ChunkSource { } public CompletableFuture addTicketAndLoadWithRadius(TicketType ticketType, ChunkPos chunkPos, int radius) { @@ -26199,7 +26178,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b } public void addTicketWithRadius(TicketType ticketType, ChunkPos chunkPos, int radius) { -@@ -658,6 +720,12 @@ public class ServerChunkCache extends ChunkSource { +@@ -652,6 +714,12 @@ public class ServerChunkCache extends ChunkSource { this.chunkMap.setServerViewDistance(viewDistance); } @@ -26212,7 +26191,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b public void setSimulationDistance(int simulationDistance) { this.distanceManager.updateSimulationDistance(simulationDistance); } -@@ -743,18 +811,14 @@ public class ServerChunkCache extends ChunkSource { +@@ -736,18 +804,14 @@ public class ServerChunkCache extends ChunkSource { @Override public boolean pollTask() { @@ -26237,10 +26216,10 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b } } diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index 9dbb7c744030fb8d6891780a0928c8cca2a2b68d..f019f1330f9f1e6aa98ef3f914833769cbadea16 100644 +index 182e7468a01e76a22c7af3c081469b4f84f87558..b7915685026e9a944f42440e4a95215f927f385e 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -89,6 +89,11 @@ public class ServerEntity { +@@ -88,6 +88,11 @@ public class ServerEntity { } public void sendChanges() { @@ -26249,15 +26228,15 @@ index 9dbb7c744030fb8d6891780a0928c8cca2a2b68d..f019f1330f9f1e6aa98ef3f914833769 + this.teleportDelay = 9999; + } + // Paper end - optimise collisions + this.entity.updateDataBeforeSync(); List passengers = this.entity.getPassengers(); if (!passengers.equals(this.lastPassengers)) { - this.synchronizer diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09e68aa979 100644 +index f25d50bcccf9b35ae70f8162c6b2b67fffcd319a..5494b92ab1c3c202a640e483e8a4bcb64395ed99 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -175,7 +175,7 @@ import net.minecraft.world.ticks.LevelTicks; - import net.minecraft.world.waypoints.WaypointTransmitter; +@@ -181,7 +181,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLevel { @@ -26265,16 +26244,16 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 public static final BlockPos END_SPAWN_POINT = new BlockPos(100, 50, 0); public static final IntProvider RAIN_DELAY = UniformInt.of(12000, 180000); public static final IntProvider RAIN_DURATION = UniformInt.of(12000, 24000); -@@ -190,7 +190,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type +@@ -197,7 +197,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe final EntityTickList entityTickList = new EntityTickList(); private final ServerWaypointManager waypointManager; + private final EnvironmentAttributeSystem environmentAttributes; - public final PersistentEntitySectionManager entityManager; + // Paper - rewrite chunk system private final GameEventDispatcher gameEventDispatcher; public boolean noSave; private final SleepStatus sleepStatus; -@@ -264,12 +264,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -270,12 +270,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public final void loadChunksForMoveAsync(AABB box, ca.spottedleaf.concurrentutil.util.Priority priority, java.util.function.Consumer> onLoad) { @@ -26288,7 +26267,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 int minBlockX = Mth.floor(box.minX - 1.0E-7D) - 3; int minBlockZ = Mth.floor(box.minZ - 1.0E-7D) - 3; -@@ -288,30 +283,171 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -294,30 +289,171 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public final void loadChunks(int minChunkX, int minChunkZ, int maxChunkX, int maxChunkZ, ca.spottedleaf.concurrentutil.util.Priority priority, java.util.function.Consumer> onLoad) { @@ -26476,7 +26455,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } } } -@@ -325,16 +461,135 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -331,16 +467,135 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } } } @@ -26619,7 +26598,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 public ServerLevel( MinecraftServer server, -@@ -381,18 +636,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -387,18 +642,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // CraftBukkit end boolean flag = server.forceSynchronousWrites(); DataFixer fixerUpper = server.getFixerUpper(); @@ -26639,7 +26618,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 this.chunkSource = new ServerChunkCache( this, levelStorageAccess, -@@ -403,7 +647,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -409,7 +653,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.spigotConfig.viewDistance, // Spigot this.spigotConfig.simulationDistance, // Spigot flag, @@ -26648,10 +26627,10 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 () -> server.overworld().getDataStorage() ); this.chunkSource.getGeneratorState().ensureStructuresGenerated(); -@@ -439,6 +683,20 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - this.gameEventDispatcher = new GameEventDispatcher(this); - this.randomSequences = Objects.requireNonNullElseGet(randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE)); +@@ -449,6 +693,20 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.waypointManager = new ServerWaypointManager(); + this.environmentAttributes = EnvironmentAttributeSystem.builder().addDefaultLayers(this).build(); + this.updateSkyBrightness(); + // Paper start - rewrite chunk system + this.moonrise$setEntityLookup(new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.server.ServerEntityLookup((ServerLevel)(Object)this, ((ServerLevel)(Object)this).new EntityCallbacks())); + this.chunkTaskScheduler = new ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler((ServerLevel)(Object)this); @@ -26669,7 +26648,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit } -@@ -565,8 +823,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -580,8 +838,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe profilerFiller.push("checkDespawn"); entity.checkDespawn(); profilerFiller.pop(); @@ -26679,7 +26658,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 Entity vehicle = entity.getVehicle(); if (vehicle != null) { if (!vehicle.isRemoved() && vehicle.hasPassenger(entity)) { -@@ -590,7 +847,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -605,7 +862,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } profilerFiller.push("entityManagement"); @@ -26688,7 +26667,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 profilerFiller.pop(); profilerFiller.push("debugSynchronizers"); if (this.debugSynchronizers.hasAnySubscriberFor(DebugSubscriptions.NEIGHBOR_UPDATES)) { -@@ -606,7 +863,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -622,7 +879,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public boolean shouldTickBlocksAt(long chunkPos) { @@ -26700,7 +26679,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } protected void tickTime() { -@@ -637,7 +897,60 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -657,7 +917,60 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.players.stream().filter(LivingEntity::isSleeping).collect(Collectors.toList()).forEach(player -> player.stopSleepInBed(false, false)); } @@ -26761,7 +26740,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 ChunkPos pos = chunk.getPos(); int minBlockX = pos.getMinBlockX(); int minBlockZ = pos.getMinBlockZ(); -@@ -646,7 +959,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -666,7 +979,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (!this.paperConfig().environment.disableIceAndSnow) { // Paper - Option to disable ice and snow for (int i = 0; i < randomTickSpeed; i++) { @@ -26770,7 +26749,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 this.tickPrecipitation(this.getBlockRandomPos(minBlockX, 0, minBlockZ, 15)); } } -@@ -654,33 +967,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -674,33 +987,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe profilerFiller.popPush("tickBlocks"); if (randomTickSpeed > 0) { @@ -26805,7 +26784,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } profilerFiller.pop(); -@@ -975,6 +1262,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1013,6 +1300,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (fluidState.is(fluid)) { fluidState.tick(this, pos, blockState); } @@ -26818,7 +26797,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } private void tickBlock(BlockPos pos, Block block) { -@@ -982,6 +1275,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1020,6 +1313,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (blockState.is(block)) { blockState.tick(this, pos, this.random); } @@ -26831,7 +26810,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } // Paper start - log detailed entity tick information -@@ -1066,6 +1365,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1104,6 +1403,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) { @@ -26843,7 +26822,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 ServerChunkCache chunkSource = this.getChunkSource(); if (!skipSave) { org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(this.getWorld())); // CraftBukkit -@@ -1078,13 +1382,18 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1116,13 +1420,18 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe progress.progressStage(Component.translatable("menu.savingChunks")); } @@ -26867,7 +26846,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 // CraftBukkit start - moved from MinecraftServer#saveAllChunks ServerLevel serverLevel1 = this; -@@ -1214,7 +1523,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1251,7 +1560,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.removePlayerImmediately((ServerPlayer)entity, Entity.RemovalReason.DISCARDED); } @@ -26876,7 +26855,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } // CraftBukkit start -@@ -1245,7 +1554,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1282,7 +1591,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } // CraftBukkit end @@ -26885,7 +26864,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } } -@@ -1256,7 +1565,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1293,7 +1602,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public boolean tryAddFreshEntityWithPassengers(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { // CraftBukkit end @@ -26894,7 +26873,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 return false; } else { this.addFreshEntityWithPassengers(entity, reason); // CraftBukkit -@@ -2009,7 +2318,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2039,7 +2348,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } } @@ -26903,7 +26882,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 bufferedWriter.write(String.format(Locale.ROOT, "block_entity_tickers: %d\n", this.blockEntityTickers.size())); bufferedWriter.write(String.format(Locale.ROOT, "block_ticks: %d\n", this.getBlockTicks().count())); bufferedWriter.write(String.format(Locale.ROOT, "fluid_ticks: %d\n", this.getFluidTicks().count())); -@@ -2027,13 +2336,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2057,13 +2366,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe Path path1 = path.resolve("chunks.csv"); try (Writer bufferedWriter2 = Files.newBufferedWriter(path1)) { @@ -26919,7 +26898,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } Path path3 = path.resolve("entities.csv"); -@@ -2130,8 +2439,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2159,8 +2468,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe Locale.ROOT, "players: %s, entities: %s [%s], block_entities: %d [%s], block_ticks: %d, fluid_ticks: %d, chunk_source: %s", this.players.size(), @@ -26930,7 +26909,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 this.blockEntityTickers.size(), getTypeCount(this.blockEntityTickers, TickingBlockEntity::getType), this.getBlockTicks().count(), -@@ -2163,15 +2472,25 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2192,15 +2501,25 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public LevelEntityGetter getEntities() { org.spigotmc.AsyncCatcher.catchOp("Chunk getEntities call"); // Spigot @@ -26959,7 +26938,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } public void startTickingChunk(LevelChunk chunk) { -@@ -2188,8 +2507,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2217,8 +2536,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public void waitForEntities(ChunkPos chunkPos, int radius) { List list = ChunkPos.rangeClosed(chunkPos, radius).toList(); @@ -26970,7 +26949,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 for (ChunkPos chunkPos1 : list) { if (!this.areEntitiesLoaded(chunkPos1.toLong())) { -@@ -2208,28 +2527,38 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2239,28 +2558,38 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public void close() throws IOException { super.close(); @@ -27015,7 +26994,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } public boolean anyPlayerCloseEnoughForSpawning(BlockPos pos) { -@@ -2241,7 +2570,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2277,7 +2606,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } public boolean canSpawnEntitiesInChunk(ChunkPos chunkPos) { @@ -27027,7 +27006,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } @Override -@@ -2296,7 +2628,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2332,7 +2664,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public CrashReportCategory fillReportDetails(CrashReport report) { CrashReportCategory crashReportCategory = super.fillReportDetails(report); @@ -27037,11 +27016,11 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 8ecbcfb5f4e2d1cfcde694e9c57b74bbae4b2ac9..8b3efe83166e73dea6545384883c8db74f04cea7 100644 +index b09e6a9fa5fbe9a0d3df615d02109992612b4416..8688d1eb7427b8d07757af84d615781867a34288 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -202,7 +202,7 @@ import net.minecraft.world.scores.Team; - import net.minecraft.world.scores.criteria.ObjectiveCriteria; +@@ -201,7 +201,7 @@ import net.minecraft.world.scores.criteria.ObjectiveCriteria; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class ServerPlayer extends Player { @@ -27049,9 +27028,9 @@ index 8ecbcfb5f4e2d1cfcde694e9c57b74bbae4b2ac9..8b3efe83166e73dea6545384883c8db7 private static final Logger LOGGER = LogUtils.getLogger(); private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_XZ = 32; private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10; -@@ -438,6 +438,36 @@ public class ServerPlayer extends Player { - public @Nullable com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent - public @Nullable 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 +@@ -428,6 +428,36 @@ public class ServerPlayer extends Player { + public com.destroystokyo.paper.event.entity.@Nullable PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent + public org.bukkit.event.player.PlayerQuitEvent.@Nullable 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 + // Paper start - rewrite chunk system + private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader; @@ -27086,7 +27065,7 @@ index 8ecbcfb5f4e2d1cfcde694e9c57b74bbae4b2ac9..8b3efe83166e73dea6545384883c8db7 public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) { super(level, gameProfile); this.server = server; -@@ -460,7 +490,7 @@ public class ServerPlayer extends Player { +@@ -450,7 +480,7 @@ public class ServerPlayer extends Player { @Override public BlockPos adjustSpawnLocation(ServerLevel level, BlockPos pos) { CompletableFuture completableFuture = PlayerSpawnFinder.findSpawn(level, pos); @@ -27096,11 +27075,11 @@ index 8ecbcfb5f4e2d1cfcde694e9c57b74bbae4b2ac9..8b3efe83166e73dea6545384883c8db7 } diff --git a/net/minecraft/server/level/ThreadedLevelLightEngine.java b/net/minecraft/server/level/ThreadedLevelLightEngine.java -index 664d1aaf0fffd5ca649476966da2d950858279d8..db960cb5397a8840c145f200a753e5507688957b 100644 +index 6acaf953df4f2775a73ff6b5168e6b7cdfc702f2..c33edee3c8a32507f01fc025135d57af0b41b10d 100644 --- a/net/minecraft/server/level/ThreadedLevelLightEngine.java +++ b/net/minecraft/server/level/ThreadedLevelLightEngine.java -@@ -23,23 +23,151 @@ import net.minecraft.world.level.chunk.LightChunkGetter; - import net.minecraft.world.level.lighting.LevelLightEngine; +@@ -23,23 +23,151 @@ import net.minecraft.world.level.lighting.LevelLightEngine; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCloseable { @@ -27450,12 +27429,12 @@ index 664d1aaf0fffd5ca649476966da2d950858279d8..db960cb5397a8840c145f200a753e550 static enum TaskType { diff --git a/net/minecraft/server/level/Ticket.java b/net/minecraft/server/level/Ticket.java -index a663c84c756bc59aaddbceda939f552e8a422e60..c3a923b7292e970cbfcde7b9fedcbb6eab02c866 100644 +index c86c72b384ade21165d61958119a21f2128ffdf8..481321fe20adc967d41959258e1915f7fbe8e63c 100644 --- a/net/minecraft/server/level/Ticket.java +++ b/net/minecraft/server/level/Ticket.java -@@ -7,7 +7,7 @@ import net.minecraft.Util; - import net.minecraft.core.registries.BuiltInRegistries; +@@ -7,7 +7,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.util.ExtraCodecs; + import net.minecraft.util.Util; -public class Ticket { +public class Ticket implements Comparable, ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicket { // Paper - rewrite chunk system @@ -27554,14 +27533,14 @@ index a663c84c756bc59aaddbceda939f552e8a422e60..c3a923b7292e970cbfcde7b9fedcbb6e public TicketType getType() { diff --git a/net/minecraft/server/level/TicketType.java b/net/minecraft/server/level/TicketType.java -index e78d33adda88ed2b58e0bd1c4133d260f126970d..82adb0a0831478b999274fdabab8f94db06b28a9 100644 +index f501cf98260742fc9e3e4bfba1faade49e4d6db6..b2914cbe1ba89ef23f3ca41a98d0c8679198ce4c 100644 --- a/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java -@@ -3,7 +3,45 @@ package net.minecraft.server.level; +@@ -7,7 +7,45 @@ import java.lang.annotation.Target; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; --public record TicketType(long timeout, int flags) { +-public record TicketType(long timeout, @TicketType.Flags int flags) { +public final class TicketType implements ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType { // Paper - rewrite chunk system + // Paper start - rewrite chunk system + private static final java.util.concurrent.atomic.AtomicLong ID_GENERATOR = new java.util.concurrent.atomic.AtomicLong(); @@ -27602,9 +27581,9 @@ index e78d33adda88ed2b58e0bd1c4133d260f126970d..82adb0a0831478b999274fdabab8f94d + // Paper end - rewrite chunk system + public static final long NO_TIMEOUT = 0L; - public static final int FLAG_PERSIST = 1; - public static final int FLAG_LOADING = 2; -@@ -21,7 +59,7 @@ public record TicketType(long timeout, int flags) { + // Paper start - diff on change - all listed in Flags annotation + public static final int FLAG_PERSIST = 1; // Paper - diff on change - all listed in Flags annotation +@@ -27,7 +65,7 @@ public record TicketType(long timeout, @TicketType.Flags int flags) { public static final TicketType UNKNOWN = register("unknown", 1L, FLAG_CAN_EXPIRE_IF_UNLOADED | FLAG_LOADING); public static final TicketType PLUGIN = register("plugin", 0L, FLAG_LOADING | FLAG_SIMULATION); // CraftBukkit public static final TicketType POST_TELEPORT = register("post_teleport", 5L, FLAG_LOADING | FLAG_SIMULATION); // Paper @@ -27613,8 +27592,8 @@ index e78d33adda88ed2b58e0bd1c4133d260f126970d..82adb0a0831478b999274fdabab8f94d public static final TicketType FUTURE_AWAIT = register("future_await", NO_TIMEOUT, FLAG_LOADING | FLAG_SIMULATION); // Paper public static final TicketType CHUNK_LOAD = register("chunk_load", NO_TIMEOUT, FLAG_LOADING); // Paper - moonrise -@@ -49,9 +87,44 @@ public record TicketType(long timeout, int flags) { - return (this.flags & 16) != 0; +@@ -55,9 +93,44 @@ public record TicketType(long timeout, @TicketType.Flags int flags) { + return (this.flags & FLAG_CAN_EXPIRE_IF_UNLOADED) != 0; } + // Paper start - rewrite chunk system - convert to class @@ -27660,12 +27639,12 @@ index e78d33adda88ed2b58e0bd1c4133d260f126970d..82adb0a0831478b999274fdabab8f94d return this == PLUGIN ? PLUGIN_TYPE_TIMEOUT : this.timeout; } diff --git a/net/minecraft/server/level/WorldGenRegion.java b/net/minecraft/server/level/WorldGenRegion.java -index ea9a2c391df81930f85106c85daa9386a03868b2..b8be39ae633e466d764f329f614620f1a2e1ef3f 100644 +index f7bd29f062baa396ba25d987149159571ee8fa8a..bf5e460b89d7c0fcdcb8826ba693bd23761df430 100644 --- a/net/minecraft/server/level/WorldGenRegion.java +++ b/net/minecraft/server/level/WorldGenRegion.java @@ -78,6 +78,36 @@ public class WorldGenRegion implements WorldGenLevel { private final AtomicLong subTickCount = new AtomicLong(); - private static final ResourceLocation WORLDGEN_REGION_RANDOM = ResourceLocation.withDefaultNamespace("worldgen_region_random"); + private static final Identifier WORLDGEN_REGION_RANDOM = Identifier.withDefaultNamespace("worldgen_region_random"); + // Paper start - rewrite chunk system + /** @@ -27714,19 +27693,19 @@ index f41ddc6f23786d3d3def15aa32ab3782d4839e5f..c65b274b965b95eae33690e63c5da2d5 // Paper start - PlayerChunkLoadEvent if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) { diff --git a/net/minecraft/server/network/config/PrepareSpawnTask.java b/net/minecraft/server/network/config/PrepareSpawnTask.java -index 4367d84309e6dbae6637cb465332896304db5b5a..384289f5d898fef2f791edcbe0716ed057be62e6 100644 +index 4016d26304a0bf3894eed2bef72113b2ca2d7a6f..5014840bf5d7ef53a4fea8aa6f3b25eb4033ff96 100644 --- a/net/minecraft/server/network/config/PrepareSpawnTask.java +++ b/net/minecraft/server/network/config/PrepareSpawnTask.java -@@ -168,7 +168,7 @@ public class PrepareSpawnTask implements ConfigurationTask { - @Nullable - private CompletableFuture chunkLoadFuture; +@@ -166,7 +166,7 @@ public class PrepareSpawnTask implements ConfigurationTask { + private Vec2 spawnAngle; // Paper - remove final + private @Nullable CompletableFuture chunkLoadFuture; private @Nullable CompletableFuture eventFuture; // Paper - private final ChunkLoadCounter chunkLoadCounter = new ChunkLoadCounter(); + private final ChunkLoadCounter chunkLoadCounter = new ca.spottedleaf.moonrise.patches.chunk_system.MoonriseChunkLoadCounter(); // Paper - rewrite chunk system Preparing(final ServerLevel spawnLevel, final CompletableFuture spawnPosition, final Vec2 spawnAngle) { this.spawnLevel = spawnLevel; -@@ -232,11 +232,7 @@ public class PrepareSpawnTask implements ConfigurationTask { +@@ -229,11 +229,7 @@ public class PrepareSpawnTask implements ConfigurationTask { } // Paper end - PlayerSpawnLocationEvent ChunkPos chunkPos = new ChunkPos(BlockPos.containing(vec3)); @@ -27740,10 +27719,10 @@ index 4367d84309e6dbae6637cb465332896304db5b5a..384289f5d898fef2f791edcbe0716ed0 PrepareSpawnTask.this.loadListener.updateFocus(this.spawnLevel.dimension(), chunkPos); } diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index f0a231faba60cd00bdfeb2db01c3d2af53812ea9..3939b5333e3f2f0c1771a3fba04d75445eaba14f 100644 +index 3f3fc8617d37e8653e6e64e6d405372496284258..12ab84ddce4868ddb9e480a2bb8f322bc3346cce 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -1182,7 +1182,7 @@ public abstract class PlayerList { +@@ -1195,7 +1195,7 @@ public abstract class PlayerList { public void setViewDistance(int viewDistance) { this.viewDistance = viewDistance; @@ -27751,8 +27730,8 @@ index f0a231faba60cd00bdfeb2db01c3d2af53812ea9..3939b5333e3f2f0c1771a3fba04d7544 + //this.broadcastAll(new ClientboundSetChunkCacheRadiusPacket(viewDistance)); // Paper - rewrite chunk system for (ServerLevel serverLevel : this.server.getAllLevels()) { - if (serverLevel != null) { -@@ -1193,7 +1193,7 @@ public abstract class PlayerList { + serverLevel.getChunkSource().setViewDistance(viewDistance); +@@ -1204,7 +1204,7 @@ public abstract class PlayerList { public void setSimulationDistance(int simulationDistance) { this.simulationDistance = simulationDistance; @@ -27760,7 +27739,7 @@ index f0a231faba60cd00bdfeb2db01c3d2af53812ea9..3939b5333e3f2f0c1771a3fba04d7544 + //this.broadcastAll(new ClientboundSetSimulationDistancePacket(simulationDistance)); // Paper - rewrite chunk system for (ServerLevel serverLevel : this.server.getAllLevels()) { - if (serverLevel != null) { + serverLevel.getChunkSource().setSimulationDistance(simulationDistance); diff --git a/net/minecraft/util/BitStorage.java b/net/minecraft/util/BitStorage.java index 32fe9b22e1d3a422dd80c64d61156dbc7241ba20..02502d50f0255f5bbcc0ecb965abb48cc1a112da 100644 --- a/net/minecraft/util/BitStorage.java @@ -27798,12 +27777,12 @@ index 32fe9b22e1d3a422dd80c64d61156dbc7241ba20..02502d50f0255f5bbcc0ecb965abb48c + // Paper end - block counting } diff --git a/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java b/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java -index c21f1816159b54e97f4ac4ab88bc54399579359a..bb8b1081356674c89663cee95cf5990e1b8e5c38 100644 +index 4d406af549764de9827274cd0875e5a71b63cba2..d134400dcf2dee5a918fd5ededda802086dd5bbb 100644 --- a/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java +++ b/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java @@ -7,7 +7,7 @@ import java.util.Iterator; - import javax.annotation.Nullable; import net.minecraft.core.IdMap; + import org.jspecify.annotations.Nullable; -public class CrudeIncrementalIntIdentityHashBiMap implements IdMap { +public class CrudeIncrementalIntIdentityHashBiMap implements IdMap, ca.spottedleaf.moonrise.patches.fast_palette.FastPalette { // Paper - optimise palette reads @@ -27827,7 +27806,7 @@ index c21f1816159b54e97f4ac4ab88bc54399579359a..bb8b1081356674c89663cee95cf5990e private CrudeIncrementalIntIdentityHashBiMap(int size) { this.keys = (K[])(new Object[size]); this.values = new int[size]; -@@ -88,6 +98,12 @@ public class CrudeIncrementalIntIdentityHashBiMap implements IdMap { +@@ -87,6 +97,12 @@ public class CrudeIncrementalIntIdentityHashBiMap implements IdMap { this.byId = crudeIncrementalIntIdentityHashBiMap.byId; this.nextId = crudeIncrementalIntIdentityHashBiMap.nextId; this.size = crudeIncrementalIntIdentityHashBiMap.size; @@ -27841,7 +27820,7 @@ index c21f1816159b54e97f4ac4ab88bc54399579359a..bb8b1081356674c89663cee95cf5990e public void addMapping(K object, int intKey) { diff --git a/net/minecraft/util/SimpleBitStorage.java b/net/minecraft/util/SimpleBitStorage.java -index 6fb3a3f167d8cbaa78135af0c180b592661e2c1d..e6306a68c8652d4c5d22d5ecb1416f5f931f76ee 100644 +index 82b13c0aa0762ff9aa3a9adb7227531804094712..08af7687cdbf395116c2ae0c40befa518b796846 100644 --- a/net/minecraft/util/SimpleBitStorage.java +++ b/net/minecraft/util/SimpleBitStorage.java @@ -208,6 +208,20 @@ public class SimpleBitStorage implements BitStorage { @@ -28014,12 +27993,12 @@ index 6fb3a3f167d8cbaa78135af0c180b592661e2c1d..e6306a68c8652d4c5d22d5ecb1416f5f InitializationException(String message) { super(message); diff --git a/net/minecraft/util/SortedArraySet.java b/net/minecraft/util/SortedArraySet.java -index 0b50a8a7ce28742b272ba61d0cf9b7971b4e867d..62c643febe5d642f5741ac2dcec1606a844593be 100644 +index 2da05663f659b1e36c2c9ebe5e68b95779aa2789..2f13822f830ccb208a96e0b00f5b28109448ea2f 100644 --- a/net/minecraft/util/SortedArraySet.java +++ b/net/minecraft/util/SortedArraySet.java -@@ -9,12 +9,88 @@ import java.util.NoSuchElementException; - import javax.annotation.Nullable; - import net.minecraft.Util; +@@ -8,12 +8,88 @@ import java.util.Iterator; + import java.util.NoSuchElementException; + import org.jspecify.annotations.Nullable; -public class SortedArraySet extends AbstractSet { +public class SortedArraySet extends AbstractSet implements ca.spottedleaf.moonrise.patches.chunk_system.util.ChunkSystemSortedArraySet { // Paper - rewrite chunk system @@ -28135,19 +28114,19 @@ index 8cc5c0716392ba06501542ff5cbe71ee43979e5d..09fd99c9cbd23b5f3c899bfb00c9b896 + // Paper end - block counting } diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf4b672617 100644 +index 262ac42b02b2809439aec5b9e8f4bc3fba04e7fe..9cd31bf05ef7e5b14696cb33bbf995a9405481e3 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -149,7 +149,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter; - import org.jetbrains.annotations.Contract; +@@ -152,7 +152,7 @@ import org.jetbrains.annotations.Contract; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; --public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, EntityAccess, ScoreHolder, DataComponentGetter { -+public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker +-public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, SlotProvider, EntityAccess, ScoreHolder, DataComponentGetter { ++public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, SlotProvider, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker // CraftBukkit start private static final int CURRENT_LEVEL = 2; static boolean isLevelAtLeast(ValueInput input, int level) { -@@ -158,7 +158,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -161,7 +161,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name // Paper start - Share random for entities to make them more random public static RandomSource SHARED_RANDOM = new RandomRandomSource(); @@ -28166,7 +28145,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf private boolean locked = false; @Override -@@ -171,61 +181,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -174,61 +184,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } } @@ -28228,8 +28207,8 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf + // Paper - replace random } // Paper end - Share random for entities to make them more random - public @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason -@@ -418,6 +374,156 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + public org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason +@@ -419,6 +375,156 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name return this.dimensions.makeBoundingBox(x, y, z); } // Paper end @@ -28386,7 +28365,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf public Entity(EntityType type, Level level) { this.type = type; -@@ -1370,35 +1476,77 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -1385,35 +1491,77 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name return list.isEmpty() ? distance : -Shapes.collide(Direction.Axis.Y, boundingBox, list, -distance); } @@ -28488,7 +28467,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf } private static float[] collectCandidateStepUpHeights(AABB box, List colliders, float deltaY, float maxUpStep) { -@@ -2696,21 +2844,110 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -2709,21 +2857,110 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } public boolean isInWall() { @@ -28610,7 +28589,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf } public InteractionResult interact(Player player, InteractionHand hand) { -@@ -4298,15 +4535,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4314,15 +4551,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } public Iterable getIndirectPassengers() { @@ -28636,7 +28615,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf } public int countPlayerPassengers() { -@@ -4449,77 +4688,126 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4471,77 +4710,126 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name return Mth.lerp(partialTick, this.yRotO, this.yRot); } @@ -28821,7 +28800,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf public boolean touchingUnloadedChunk() { AABB aabb = this.getBoundingBox().inflate(1.0); -@@ -4675,6 +4963,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4701,6 +4989,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) { @@ -28837,10 +28816,10 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf if (!checkPosition(this, x, y, z)) { return; } -@@ -4826,6 +5123,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4850,6 +5147,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name @Override - public final void setRemoved(Entity.RemovalReason removalReason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause + public final void setRemoved(Entity.RemovalReason removalReason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { // CraftBukkit - add Bukkit remove cause + // Paper start - rewrite chunk system + if (!((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this.level).moonrise$getEntityLookup().canRemoveEntity((Entity)(Object)this)) { + LOGGER.warn("Entity " + this + " is currently prevented from being removed from the world since it is processing section status updates", new Throwable()); @@ -28850,7 +28829,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); // CraftBukkit final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers if (this.removalReason == null) { -@@ -4836,7 +5139,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4860,7 +5163,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.stopRiding(); } @@ -28859,7 +28838,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf this.levelCallback.onRemove(removalReason); this.onRemoval(removalReason); // Paper start - Folia schedulers -@@ -4870,7 +5173,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4894,7 +5197,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name public boolean shouldBeSaved() { return (this.removalReason == null || this.removalReason.shouldSave()) && !this.isPassenger() @@ -28869,12 +28848,12 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf @Override diff --git a/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/net/minecraft/world/entity/ai/village/poi/PoiManager.java -index 5efaf3a1eb1cefc2e925af94ce7064103f0f56f5..f67fbc8b6f5f0374f41180ec36de355c7a538aca 100644 +index 436da1efde31d5f1103ecbf04cac9c82928c372a..e2b05800736d29f6061a9f2117e51c8a0d5bfeb6 100644 --- a/net/minecraft/world/entity/ai/village/poi/PoiManager.java +++ b/net/minecraft/world/entity/ai/village/poi/PoiManager.java -@@ -40,12 +40,137 @@ import net.minecraft.world.level.chunk.storage.RegionStorageInfo; - import net.minecraft.world.level.chunk.storage.SectionStorage; +@@ -40,12 +40,137 @@ import net.minecraft.world.level.chunk.storage.SectionStorage; import net.minecraft.world.level.chunk.storage.SimpleRegionStorage; + import org.jspecify.annotations.Nullable; -public class PoiManager extends SectionStorage { +public class PoiManager extends SectionStorage implements ca.spottedleaf.moonrise.patches.chunk_system.level.poi.ChunkSystemPoiManager { // Paper - rewrite chunk system @@ -29018,8 +28997,8 @@ index 5efaf3a1eb1cefc2e925af94ce7064103f0f56f5..f67fbc8b6f5f0374f41180ec36de355c + this.world = (net.minecraft.server.level.ServerLevel)levelHeightAccessor; // Paper - rewrite chunk system } - @Nullable -@@ -200,8 +326,10 @@ public class PoiManager extends SectionStorage { + public @Nullable PoiRecord add(BlockPos pos, Holder type) { +@@ -198,8 +324,10 @@ public class PoiManager extends SectionStorage { } public int sectionsToVillage(SectionPos sectionPos) { @@ -29032,7 +29011,7 @@ index 5efaf3a1eb1cefc2e925af94ce7064103f0f56f5..f67fbc8b6f5f0374f41180ec36de355c } boolean isVillageCenter(long chunkPos) { -@@ -215,19 +343,26 @@ public class PoiManager extends SectionStorage { +@@ -213,19 +341,26 @@ public class PoiManager extends SectionStorage { @Override public void tick(BooleanSupplier aheadOfTime) { @@ -29065,7 +29044,7 @@ index 5efaf3a1eb1cefc2e925af94ce7064103f0f56f5..f67fbc8b6f5f0374f41180ec36de355c } public void checkConsistencyWithBlocks(SectionPos sectionPos, LevelChunkSection levelChunkSection) { -@@ -266,7 +401,7 @@ public class PoiManager extends SectionStorage { +@@ -264,7 +399,7 @@ public class PoiManager extends SectionStorage { .map(sectionPos -> Pair.of(sectionPos, this.getOrLoad(sectionPos.asLong()))) .filter(pair -> !pair.getSecond().map(PoiSection::isValid).orElse(false)) .map(pair -> pair.getFirst().chunk()) @@ -29075,11 +29054,11 @@ index 5efaf3a1eb1cefc2e925af94ce7064103f0f56f5..f67fbc8b6f5f0374f41180ec36de355c } diff --git a/net/minecraft/world/entity/ai/village/poi/PoiSection.java b/net/minecraft/world/entity/ai/village/poi/PoiSection.java -index 4a566870695d0b4974cb2ef6804798208c2536cf..bba84a390e46a1288cc3cb36ba01941e47a1fec2 100644 +index 080fcef99f5407685181c2fb7bdb41b14481f6f7..f209696e0158df5cd32e9949b3054452d6a3e5cd 100644 --- a/net/minecraft/world/entity/ai/village/poi/PoiSection.java +++ b/net/minecraft/world/entity/ai/village/poi/PoiSection.java -@@ -25,13 +25,27 @@ import net.minecraft.util.VisibleForDebug; - import net.minecraft.util.debug.DebugPoiInfo; +@@ -25,13 +25,27 @@ import net.minecraft.util.debug.DebugPoiInfo; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class PoiSection { @@ -29108,7 +29087,7 @@ index 4a566870695d0b4974cb2ef6804798208c2536cf..bba84a390e46a1288cc3cb36ba01941e this(setDirty, true, ImmutableList.of()); } diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java -index 5d4d01fdc75ffe256545df0b8d9cc9037c4d9b87..15479a9fc47cca3d6627b42c31ba8ff114bbe362 100644 +index 8a6dfb642c89264386ad9302a8bb190ce5e23a26..79ae039d1908830e81912d230b3540a4920e2017 100644 --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java @@ -204,7 +204,7 @@ public class ArmorStand extends LivingEntity { @@ -29121,10 +29100,10 @@ index 5d4d01fdc75ffe256545df0b8d9cc9037c4d9b87..15479a9fc47cca3d6627b42c31ba8ff1 entity.push(this); } diff --git a/net/minecraft/world/level/ClipContext.java b/net/minecraft/world/level/ClipContext.java -index 628ed83e198dd67c4384c51f98253547d59b5219..9f3187728c0bc69572f27194754016682913e385 100644 +index 3d317880a257bf431f110048d305ddd2a06880d7..25f2e74e229fa12a2d7f1ff43c6cb12a84788ba2 100644 --- a/net/minecraft/world/level/ClipContext.java +++ b/net/minecraft/world/level/ClipContext.java -@@ -21,7 +21,7 @@ public class ClipContext { +@@ -22,7 +22,7 @@ public class ClipContext { private final Vec3 from; private final Vec3 to; private final ClipContext.Block block; @@ -29134,12 +29113,12 @@ index 628ed83e198dd67c4384c51f98253547d59b5219..9f3187728c0bc69572f2719475401668 public ClipContext(Vec3 from, Vec3 to, ClipContext.Block block, ClipContext.Fluid fluid, Entity entity) { diff --git a/net/minecraft/world/level/EntityGetter.java b/net/minecraft/world/level/EntityGetter.java -index 300f3ed58109219d97846082941b860585f66fed..9175a7e4e6076626cb46144c5858c2f2474f1858 100644 +index d4c78c7f521b31ea9ce0cf7d62978b8e324b5d10..bcbe39eed2d254861689c95f7040f27b6ff2d438 100644 --- a/net/minecraft/world/level/EntityGetter.java +++ b/net/minecraft/world/level/EntityGetter.java -@@ -15,7 +15,7 @@ import net.minecraft.world.phys.shapes.BooleanOp; - import net.minecraft.world.phys.shapes.Shapes; +@@ -15,7 +15,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; -public interface EntityGetter { +public interface EntityGetter extends ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemEntityGetter { // Paper - rewrite chunk system @@ -29257,7 +29236,7 @@ index 300f3ed58109219d97846082941b860585f66fed..9175a7e4e6076626cb46144c5858c2f2 // Paper start - Affects Spawning API diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520bfb97cf3 100644 +index 48158dafe7b937ff5089ac741da3e1e1bdde00ec..ef09aaebf4fc7fcd24a736434cd0a860d6b97905 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -82,6 +82,7 @@ import net.minecraft.world.level.storage.LevelData; @@ -29267,16 +29246,16 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 +import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.scores.Scoreboard; import org.apache.commons.lang3.mutable.MutableBoolean; - -@@ -95,7 +96,7 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData; + import org.jspecify.annotations.Nullable; +@@ -96,7 +97,7 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.entity.SpawnCategory; // CraftBukkit end -public abstract class Level implements LevelAccessor, AutoCloseable { +public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel, ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemEntityGetter { // Paper - rewrite chunk system // Paper - optimise collisions public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); - public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("overworld")); - public static final ResourceKey NETHER = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("the_nether")); + public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, Identifier.withDefaultNamespace("overworld")); + public static final ResourceKey NETHER = ResourceKey.create(Registries.DIMENSION, Identifier.withDefaultNamespace("the_nether")); @@ -124,7 +125,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public float rainLevel; protected float oThunderLevel; @@ -29932,7 +29911,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config this.generator = generator; -@@ -226,6 +859,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -225,6 +858,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.registryAccess = registryAccess; this.palettedContainerFactory = PalettedContainerFactory.create(registryAccess); this.damageSources = new DamageSources(registryAccess); @@ -29940,7 +29919,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 } // Paper start - Cancel hit for vanished players -@@ -499,7 +1133,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -496,7 +1130,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.setBlocksDirty(pos, blockState, blockState1); } @@ -29949,7 +29928,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 this.sendBlockUpdated(pos, blockState, state, flags); } -@@ -762,6 +1396,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -747,6 +1381,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Spigot start boolean runsNormally = this.tickRateManager().runsNormally(); @@ -29957,7 +29936,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet(); // Paper - Fix MC-117075; use removeAll toRemove.add(null); // Paper - Fix MC-117075 for (this.tileTickPosition = 0; this.tileTickPosition < this.blockEntityTickers.size(); this.tileTickPosition++) { // Paper - Disable tick limiters -@@ -771,6 +1406,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -756,6 +1391,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll } else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) { tickingBlockEntity.tick(); @@ -29969,7 +29948,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 } } this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 -@@ -790,6 +1430,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -775,6 +1415,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Paper end - Prevent block entity and entity crashes } @@ -29977,7 +29956,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 } // Paper start - Option to prevent armor stands from doing entity lookups -@@ -797,7 +1438,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -782,7 +1423,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public boolean noCollision(@Nullable Entity entity, AABB box) { if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return false; @@ -29993,7 +29972,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 } // Paper end - Option to prevent armor stands from doing entity lookups -@@ -933,7 +1581,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -917,7 +1565,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { if (this.isOutsideBuildHeight(pos)) { return null; } else { @@ -30002,7 +29981,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 ? null : this.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE); } -@@ -1027,22 +1675,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1007,22 +1655,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public List getEntities(@Nullable Entity entity, AABB boundingBox, Predicate predicate) { Profiler.get().incrementCounter("getEntities"); List list = Lists.newArrayList(); @@ -30033,7 +30012,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 } @Override -@@ -1056,33 +1698,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1036,33 +1678,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.getEntities(entityTypeTest, bounds, predicate, output, Integer.MAX_VALUE); } @@ -30149,16 +30128,15 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 public boolean hasEntities(EntityTypeTest entityTypeTest, AABB bounds, Predicate predicate) { Profiler.get().incrementCounter("hasEntities"); diff --git a/net/minecraft/world/level/LevelReader.java b/net/minecraft/world/level/LevelReader.java -index 93110c815abe7baef61b1eaacfe28ebb1fc821f7..564c5064ec105a4f59476f2d21d3664b76e0aa55 100644 +index 60be05520f1093e3edc7dbfcf5bd01601d5e6e7b..fd5a38a9f24c26f8eca738f78180446d354ff3ac 100644 --- a/net/minecraft/world/level/LevelReader.java +++ b/net/minecraft/world/level/LevelReader.java -@@ -22,7 +22,18 @@ import net.minecraft.world.level.dimension.DimensionType; - import net.minecraft.world.level.levelgen.Heightmap; +@@ -23,7 +23,16 @@ import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.phys.AABB; + import org.jspecify.annotations.Nullable; -public interface LevelReader extends BlockAndTintGetter, CollisionGetter, SignalGetter, BiomeManager.NoiseBiomeSource { +public interface LevelReader extends ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevelReader, BlockAndTintGetter, CollisionGetter, SignalGetter, BiomeManager.NoiseBiomeSource { // Paper - rewrite chunk system -+ + // Paper start - rewrite chunk system + @Override + public default ChunkAccess moonrise$syncLoadNonFull(final int chunkX, final int chunkZ, final ChunkStatus status) { @@ -30168,12 +30146,11 @@ index 93110c815abe7baef61b1eaacfe28ebb1fc821f7..564c5064ec105a4f59476f2d21d3664b + return ((LevelReader)this).getChunk(chunkX, chunkZ, status, true); + } + // Paper end - rewrite chunk system -+ - @Nullable - ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk); + @Nullable ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk); + @Nullable ChunkAccess getChunkIfLoadedImmediately(int x, int z); // Paper - ifLoaded api (we need this since current impl blocks if the chunk is loading) diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index c132a3bfff7cf020e7fe4be616daa763b83e4b25..1c521f9f32340cf75310686c90777e521ac3ae5c 100644 +index ebbf5ceab837675ffa6a5380c0c54bc1dd788348..6279596058f76f113d238be3201cb0c6e6b49566 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java @@ -62,6 +62,249 @@ public class ServerExplosion implements Explosion { @@ -30466,17 +30443,6 @@ index c132a3bfff7cf020e7fe4be616daa763b83e4b25..1c521f9f32340cf75310686c90777e52 - f -= (blockExplosionResistance.get() + 0.3F) * 0.3F; - } + final Vec3 center = this.center; -+ -+ final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache = this.directMappedBlockCache; -+ -+ // use initial cache value that is most likely to be used: the source position -+ final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache initialCache; -+ { -+ final int blockX = Mth.floor(center.x); -+ final int blockY = Mth.floor(center.y); -+ final int blockZ = Mth.floor(center.z); -+ -+ final long key = BlockPos.asLong(blockX, blockY, blockZ); - if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockPos, blockState, f)) { - set.add(blockPos); @@ -30487,6 +30453,17 @@ index c132a3bfff7cf020e7fe4be616daa763b83e4b25..1c521f9f32340cf75310686c90777e52 - net.minecraft.core.Direction direction = blockState.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING); - set.add(blockPos.relative(direction.getOpposite())); - } ++ final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache = this.directMappedBlockCache; ++ ++ // use initial cache value that is most likely to be used: the source position ++ final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache initialCache; ++ { ++ final int blockX = Mth.floor(center.x); ++ final int blockY = Mth.floor(center.y); ++ final int blockZ = Mth.floor(center.z); ++ ++ final long key = BlockPos.asLong(blockX, blockY, blockZ); ++ + initialCache = this.getOrCacheExplosionBlock(blockX, blockY, blockZ, key, true); + } + @@ -30576,7 +30553,7 @@ index c132a3bfff7cf020e7fe4be616daa763b83e4b25..1c521f9f32340cf75310686c90777e52 } private void hurtEntities() { -@@ -346,6 +628,14 @@ public class ServerExplosion implements Explosion { +@@ -350,6 +632,14 @@ public class ServerExplosion implements Explosion { } public int explode() { @@ -30591,7 +30568,7 @@ index c132a3bfff7cf020e7fe4be616daa763b83e4b25..1c521f9f32340cf75310686c90777e52 this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center); List list = this.calculateExplodedPositions(); this.hurtEntities(); -@@ -360,6 +650,13 @@ public class ServerExplosion implements Explosion { +@@ -364,6 +654,13 @@ public class ServerExplosion implements Explosion { this.createFire(list); } @@ -30605,7 +30582,7 @@ index c132a3bfff7cf020e7fe4be616daa763b83e4b25..1c521f9f32340cf75310686c90777e52 return list.size(); } -@@ -449,12 +746,12 @@ public class ServerExplosion implements Explosion { +@@ -447,12 +744,12 @@ public class ServerExplosion implements Explosion { // Paper start - Optimize explosions private float getBlockDensity(Vec3 vec3d, Entity entity) { if (!this.level.paperConfig().environment.optimizeExplosions) { @@ -30621,11 +30598,11 @@ index c132a3bfff7cf020e7fe4be616daa763b83e4b25..1c521f9f32340cf75310686c90777e52 } diff --git a/net/minecraft/world/level/TicketStorage.java b/net/minecraft/world/level/TicketStorage.java -index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7f22ff8c4 100644 +index ad5c9c32be4be9324a313fbd9e099c9dd3f68253..b1c663187720d308c4cf3a5352879262183a9ce2 100644 --- a/net/minecraft/world/level/TicketStorage.java +++ b/net/minecraft/world/level/TicketStorage.java -@@ -29,7 +29,7 @@ import net.minecraft.world.level.saveddata.SavedData; - import net.minecraft.world.level.saveddata.SavedDataType; +@@ -29,7 +29,7 @@ import net.minecraft.world.level.saveddata.SavedDataType; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class TicketStorage extends SavedData { @@ -30633,7 +30610,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 private static final int INITIAL_TICKET_LIST_CAPACITY = 4; private static final Logger LOGGER = LogUtils.getLogger(); private static final Codec> TICKET_ENTRY = Codec.mapPair(ChunkPos.CODEC.fieldOf("chunk_pos"), Ticket.CODEC).codec(); -@@ -38,18 +38,32 @@ public class TicketStorage extends SavedData { +@@ -38,16 +38,30 @@ public class TicketStorage extends SavedData { .apply(instance, TicketStorage::fromPacked) ); public static final SavedDataType TYPE = new SavedDataType<>("chunks", TicketStorage::new, CODEC, DataFixTypes.SAVED_DATA_FORCED_CHUNKS); @@ -30642,10 +30619,8 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 private final Long2ObjectOpenHashMap> deactivatedTickets; - private LongSet chunksWithForcedTickets = new LongOpenHashSet(); + // Paper - rewrite chunk system - @Nullable - private TicketStorage.ChunkUpdated loadingChunkUpdatedListener; - @Nullable - private TicketStorage.ChunkUpdated simulationChunkUpdatedListener; + private TicketStorage.@Nullable ChunkUpdated loadingChunkUpdatedListener; + private TicketStorage.@Nullable ChunkUpdated simulationChunkUpdatedListener; + // Paper start - rewrite chunk system + private ChunkMap chunkMap; @@ -30670,7 +30645,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 } public TicketStorage() { -@@ -78,8 +92,32 @@ public class TicketStorage extends SavedData { +@@ -76,8 +90,32 @@ public class TicketStorage extends SavedData { return list; } @@ -30704,15 +30679,15 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 forEachTicket(action, this.deactivatedTickets); } -@@ -104,35 +142,34 @@ public class TicketStorage extends SavedData { +@@ -102,35 +140,34 @@ public class TicketStorage extends SavedData { } - public void setLoadingChunkUpdatedListener(@Nullable TicketStorage.ChunkUpdated loadingChunkUpdatedListener) { + public void setLoadingChunkUpdatedListener(TicketStorage.@Nullable ChunkUpdated loadingChunkUpdatedListener) { - this.loadingChunkUpdatedListener = loadingChunkUpdatedListener; + // Paper - rewrite chunk system } - public void setSimulationChunkUpdatedListener(@Nullable TicketStorage.ChunkUpdated simulationChunkUpdatedListener) { + public void setSimulationChunkUpdatedListener(TicketStorage.@Nullable ChunkUpdated simulationChunkUpdatedListener) { - this.simulationChunkUpdatedListener = simulationChunkUpdatedListener; + // Paper - rewrite chunk system } @@ -30753,7 +30728,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 } public void addTicketWithRadius(TicketType ticketType, ChunkPos chunkPos, int radius) { -@@ -145,37 +182,14 @@ public class TicketStorage extends SavedData { +@@ -143,37 +180,14 @@ public class TicketStorage extends SavedData { } public boolean addTicket(long chunkPos, Ticket ticket) { @@ -30797,7 +30772,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 } private static boolean isTicketSameTypeAndLevel(Ticket first, Ticket second) { -@@ -222,53 +236,20 @@ public class TicketStorage extends SavedData { +@@ -219,53 +233,20 @@ public class TicketStorage extends SavedData { } public boolean removeTicket(long chunkPos, Ticket ticket) { @@ -30860,7 +30835,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 } public String getTicketDebugString(long chunkPos, boolean requireSimulation) { -@@ -278,14 +259,7 @@ public class TicketStorage extends SavedData { +@@ -275,14 +256,7 @@ public class TicketStorage extends SavedData { } public void purgeStaleTickets(ChunkMap map) { @@ -30876,7 +30851,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 this.setDirty(); } -@@ -301,82 +275,15 @@ public class TicketStorage extends SavedData { +@@ -298,82 +272,15 @@ public class TicketStorage extends SavedData { } public void deactivateTicketsOnClosing() { @@ -30962,7 +30937,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 } public boolean updateChunkForced(ChunkPos chunkPos, boolean add) { -@@ -385,22 +292,29 @@ public class TicketStorage extends SavedData { +@@ -382,22 +289,29 @@ public class TicketStorage extends SavedData { } public LongSet getForceLoadedChunks() { @@ -31005,7 +30980,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 } @FunctionalInterface -@@ -424,7 +338,7 @@ public class TicketStorage extends SavedData { +@@ -421,7 +335,7 @@ public class TicketStorage extends SavedData { } public void removeAllPluginRegionTickets(TicketType ticketType, int ticketLevel, org.bukkit.plugin.Plugin ticketIdentifier) { @@ -31015,10 +30990,10 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 // Paper end } diff --git a/net/minecraft/world/level/biome/Biome.java b/net/minecraft/world/level/biome/Biome.java -index 4370a7fd33cc3fcd511a3ccaf48b6648c78d408c..91fd52eeb410cf6b4c8de1ed9d41d60506bf8dd1 100644 +index dfc24fd23e26010274e02cc26666c1801ef811c0..a253b02bb6e07ba4cdbd9320445a6b6c3e54ada2 100644 --- a/net/minecraft/world/level/biome/Biome.java +++ b/net/minecraft/world/level/biome/Biome.java -@@ -118,20 +118,7 @@ public final class Biome { +@@ -123,20 +123,7 @@ public final class Biome { @Deprecated public float getTemperature(BlockPos pos, int seaLevel) { @@ -31055,10 +31030,10 @@ index 8d98cba3830dc5dfb5cae9a6f5fedfffee0d2cd8..73962e79a0f3d892e3155443a1b84508 public interface NoiseBiomeSource { diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java -index 6a6e83bc61de06c75b7a8b677c616c00ea936710..572fcb33b14d16334e2ab92ddf8699f1ba975aff 100644 +index f1340eb90e22772114a1303ef3f3f905fe101351..ab08211e0f64a14a335e3cc4479bcf1f82e25cdd 100644 --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -344,7 +344,7 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -355,7 +355,7 @@ public class Block extends BlockBehaviour implements ItemLike { } public static boolean isShapeFullBlock(VoxelShape shape) { @@ -31068,10 +31043,10 @@ index 6a6e83bc61de06c75b7a8b677c616c00ea936710..572fcb33b14d16334e2ab92ddf8699f1 public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) { diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java -index 0b19272315a8598c2e132a0f8d3c4a6ceec46e16..d31da50baeb7f47f0e1d81ee3c05023370df8cd3 100644 +index fd626256ffcf0372f85666e2ee1bd5c7bdcb105a..c5953d5751e655e121e459aaab35e7719948e69e 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -416,7 +416,7 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -415,7 +415,7 @@ public abstract class BlockBehaviour implements FeatureElement { return this.properties.destroyTime; } @@ -31080,7 +31055,7 @@ index 0b19272315a8598c2e132a0f8d3c4a6ceec46e16..d31da50baeb7f47f0e1d81ee3c050233 private static final Direction[] DIRECTIONS = Direction.values(); private static final VoxelShape[] EMPTY_OCCLUSION_SHAPES = Util.make(new VoxelShape[DIRECTIONS.length], shape -> Arrays.fill(shape, Shapes.empty())); private static final VoxelShape[] FULL_BLOCK_OCCLUSION_SHAPES = Util.make( -@@ -455,6 +455,76 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -452,6 +452,76 @@ public abstract class BlockBehaviour implements FeatureElement { private boolean propagatesSkylightDown; private int lightBlock; @@ -31157,7 +31132,7 @@ index 0b19272315a8598c2e132a0f8d3c4a6ceec46e16..d31da50baeb7f47f0e1d81ee3c050233 protected BlockStateBase(Block owner, Reference2ObjectArrayMap, Comparable> values, MapCodec propertiesCodec) { super(owner, values, propertiesCodec); BlockBehaviour.Properties properties = owner.properties; -@@ -533,6 +603,41 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -529,6 +599,41 @@ public abstract class BlockBehaviour implements FeatureElement { this.propagatesSkylightDown = this.owner.propagatesSkylightDown(this.asState()); this.lightBlock = this.owner.getLightBlock(this.asState()); @@ -31200,12 +31175,12 @@ index 0b19272315a8598c2e132a0f8d3c4a6ceec46e16..d31da50baeb7f47f0e1d81ee3c050233 public Block getBlock() { diff --git a/net/minecraft/world/level/block/state/StateHolder.java b/net/minecraft/world/level/block/state/StateHolder.java -index e9bf5e2c43ff0945c8f2eb40ed381ac061abd0d4..040919c61ed29b3eda73b5d0f8ed905011e969a4 100644 +index abb2189902af888ac30510d5088ea77fb9e0c542..c020d1944a25e2cd247e30a97c35bf93731d694a 100644 --- a/net/minecraft/world/level/block/state/StateHolder.java +++ b/net/minecraft/world/level/block/state/StateHolder.java @@ -15,7 +15,7 @@ import java.util.stream.Collectors; - import javax.annotation.Nullable; import net.minecraft.world.level.block.state.properties.Property; + import org.jspecify.annotations.Nullable; -public abstract class StateHolder { +public abstract class StateHolder implements ca.spottedleaf.moonrise.patches.blockstate_propertyaccess.PropertyAccessStateHolder { // Paper - optimise blockstate property access @@ -31271,10 +31246,10 @@ index e9bf5e2c43ff0945c8f2eb40ed381ac061abd0d4..040919c61ed29b3eda73b5d0f8ed9050 } public > Optional getOptionalValue(Property property) { -@@ -103,22 +118,30 @@ public abstract class StateHolder { +@@ -102,22 +117,30 @@ public abstract class StateHolder { + } - @Nullable - private > T getNullableValue(Property property) { + private > @Nullable T getNullableValue(Property property) { - Comparable comparable = this.values.get(property); - return comparable == null ? null : property.getValueClass().cast(comparable); + return property == null ? null : this.optimisedTable.get(this.tableIndex, property); // Paper - optimise blockstate property access @@ -31311,7 +31286,7 @@ index e9bf5e2c43ff0945c8f2eb40ed381ac061abd0d4..040919c61ed29b3eda73b5d0f8ed9050 } private , V extends T> S setValueInternal(Property property, V value, Comparable comparable) { -@@ -135,21 +158,27 @@ public abstract class StateHolder { +@@ -134,21 +157,27 @@ public abstract class StateHolder { } public void populateNeighbours(Map, Comparable>, S> possibleStateMap) { @@ -31352,7 +31327,7 @@ index e9bf5e2c43ff0945c8f2eb40ed381ac061abd0d4..040919c61ed29b3eda73b5d0f8ed9050 } private Map, Comparable> makeNeighbourValues(Property property, Comparable value) { -@@ -159,7 +188,11 @@ public abstract class StateHolder { +@@ -158,7 +187,11 @@ public abstract class StateHolder { } public Map, Comparable> getValues() { @@ -31495,19 +31470,19 @@ index 28a15908420cb239c317d58f7e3a1df3c6278b33..b7543eb5a8f87bc7bd275ed9d46a6807 @Override diff --git a/net/minecraft/world/level/block/state/properties/Property.java b/net/minecraft/world/level/block/state/properties/Property.java -index 92350434746f06bbf4a161c6bc42602de7b45220..1c24f38d21da1be9740512981f219924c5d3cf76 100644 +index aa836c652aecda582772c016e62abfce32d32fe5..1200466d8718fb35205894fc09584d5104e56f43 100644 --- a/net/minecraft/world/level/block/state/properties/Property.java +++ b/net/minecraft/world/level/block/state/properties/Property.java @@ -10,7 +10,7 @@ import java.util.stream.Stream; - import javax.annotation.Nullable; import net.minecraft.world.level.block.state.StateHolder; + import org.jspecify.annotations.Nullable; -public abstract class Property> { +public abstract class Property> implements ca.spottedleaf.moonrise.patches.blockstate_propertyaccess.PropertyAccess { // Paper - optimise blockstate property access private final Class clazz; private final String name; - @Nullable -@@ -24,9 +24,38 @@ public abstract class Property> { + private @Nullable Integer hashCode; +@@ -23,9 +23,38 @@ public abstract class Property> { ); private final Codec> valueCodec = this.codec.xmap(this::value, Property.Value::value); @@ -31547,11 +31522,11 @@ index 92350434746f06bbf4a161c6bc42602de7b45220..1c24f38d21da1be9740512981f219924 public Property.Value value(T value) { diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java -index a5199906f1ca63e66c9547d85d40f86b506a1c7f..71aa0220309e418fbbda66c2fa14fec498bf443d 100644 +index 9dc13a5b6cc1afc118a261802c71da25ae577fe5..a49a06662de4062a77112e358f536d45d65bf91f 100644 --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java -@@ -57,7 +57,7 @@ import net.minecraft.world.ticks.SavedTick; - import net.minecraft.world.ticks.TickContainerAccess; +@@ -57,7 +57,7 @@ import net.minecraft.world.ticks.TickContainerAccess; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, LightChunk, StructureAccess { @@ -31559,16 +31534,16 @@ index a5199906f1ca63e66c9547d85d40f86b506a1c7f..71aa0220309e418fbbda66c2fa14fec4 public static final int NO_FILLED_SECTION = -1; private static final Logger LOGGER = LogUtils.getLogger(); private static final LongSet EMPTY_REFERENCE_SET = new LongOpenHashSet(); -@@ -75,7 +75,7 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh - @Nullable - protected BlendingData blendingData; +@@ -72,7 +72,7 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh + protected final UpgradeData upgradeData; + protected @Nullable BlendingData blendingData; public final Map heightmaps = Maps.newEnumMap(Heightmap.Types.class); - protected ChunkSkyLightSources skyLightSources; + // Paper - rewrite chunk system private final Map structureStarts = Maps.newHashMap(); private final Map structuresRefences = Maps.newHashMap(); protected final Map pendingBlockEntities = Maps.newHashMap(); -@@ -87,6 +87,57 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -84,6 +84,57 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh public org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer(ChunkAccess.DATA_TYPE_REGISTRY); // CraftBukkit end @@ -31626,7 +31601,7 @@ index a5199906f1ca63e66c9547d85d40f86b506a1c7f..71aa0220309e418fbbda66c2fa14fec4 public ChunkAccess( ChunkPos chunkPos, UpgradeData upgradeData, -@@ -104,7 +155,7 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -101,7 +152,7 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh this.inhabitedTime = inhabitedTime; this.postProcessing = new ShortList[levelHeightAccessor.getSectionsCount()]; this.blendingData = blendingData; @@ -31635,7 +31610,7 @@ index a5199906f1ca63e66c9547d85d40f86b506a1c7f..71aa0220309e418fbbda66c2fa14fec4 if (sections != null) { if (this.sections.length == sections.length) { System.arraycopy(sections, 0, this.sections, 0, this.sections.length); -@@ -114,6 +165,16 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -111,6 +162,16 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh } replaceMissingSections(containerFactory, this.sections); @@ -31652,7 +31627,7 @@ index a5199906f1ca63e66c9547d85d40f86b506a1c7f..71aa0220309e418fbbda66c2fa14fec4 } private static void replaceMissingSections(PalettedContainerFactory containerFactory, LevelChunkSection[] sections) { -@@ -442,18 +503,22 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -433,18 +494,22 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh @Override public Holder getNoiseBiome(int x, int y, int z) { @@ -31686,7 +31661,7 @@ index a5199906f1ca63e66c9547d85d40f86b506a1c7f..71aa0220309e418fbbda66c2fa14fec4 } // CraftBukkit start public void setBiome(int x, int y, int z, Holder biome) { -@@ -503,12 +568,12 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -493,12 +558,12 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh } public void initializeLightSources() { @@ -31702,7 +31677,7 @@ index a5199906f1ca63e66c9547d85d40f86b506a1c7f..71aa0220309e418fbbda66c2fa14fec4 public static ProblemReporter.PathElement problemPath(ChunkPos pos) { diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java -index a935380b544e12a06a8152085a82b0fa16522331..4e4a5595ccbadf7e2df0f6de1c8e2ceb00b9ec90 100644 +index 2acee7d7211c4e7b9ac02e9a48d6c3ea239e6949..78600f4c583056403c93e72ec0996b00ec6d1284 100644 --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java @@ -116,7 +116,7 @@ public abstract class ChunkGenerator { @@ -31714,7 +31689,7 @@ index a935380b544e12a06a8152085a82b0fa16522331..4e4a5595ccbadf7e2df0f6de1c8e2ceb } public abstract void applyCarvers( -@@ -318,7 +318,7 @@ public abstract class ChunkGenerator { +@@ -314,7 +314,7 @@ public abstract class ChunkGenerator { return Pair.of(placement.getLocatePos(chunkPos), holder); } @@ -31724,19 +31699,19 @@ index a935380b544e12a06a8152085a82b0fa16522331..4e4a5595ccbadf7e2df0f6de1c8e2ceb if (startForStructure != null && startForStructure.isValid() && (!skipKnownStructures || tryAddReference(structureManager, startForStructure))) { return Pair.of(placement.getLocatePos(startForStructure.getChunkPos()), holder); diff --git a/net/minecraft/world/level/chunk/EmptyLevelChunk.java b/net/minecraft/world/level/chunk/EmptyLevelChunk.java -index 0de3316ee56116b9fbabb7970b8e6dd7520229cf..b7cf517a87c7c03cf53cc91697157ee087af1cf7 100644 +index 4925c35f89b2e9ec099c66168621521129dd9035..bb8c2e1fb91a5921b5fe35c78c584f81f0189e13 100644 --- a/net/minecraft/world/level/chunk/EmptyLevelChunk.java +++ b/net/minecraft/world/level/chunk/EmptyLevelChunk.java -@@ -13,7 +13,7 @@ import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.level.material.FluidState; +@@ -14,7 +14,7 @@ import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; + import org.jspecify.annotations.Nullable; -public class EmptyLevelChunk extends LevelChunk { +public class EmptyLevelChunk extends LevelChunk implements ca.spottedleaf.moonrise.patches.starlight.chunk.StarlightChunk { // Paper - rewrite chunk system private final Holder biome; public EmptyLevelChunk(Level level, ChunkPos pos, Holder biome) { -@@ -21,6 +21,40 @@ public class EmptyLevelChunk extends LevelChunk { +@@ -22,6 +22,40 @@ public class EmptyLevelChunk extends LevelChunk { this.biome = biome; } @@ -31801,12 +31776,12 @@ index 0841918bd2c7b95151baa5cfabc9d44b37b0c588..5b9346b25aa01db9f3c36e243f46846b this(bits); values.forEach(this.values::add); diff --git a/net/minecraft/world/level/chunk/ImposterProtoChunk.java b/net/minecraft/world/level/chunk/ImposterProtoChunk.java -index ab33c5dc6f4d70c1edf0377478110881aadafd3d..7d739e72c9a47776d1cc19204a4e13d9f6c43e19 100644 +index 8c5585c5a961b03853849f92e2811425391e5405..ba91dc3b8b4d70af32b7d9323f22c1fafabe913f 100644 --- a/net/minecraft/world/level/chunk/ImposterProtoChunk.java +++ b/net/minecraft/world/level/chunk/ImposterProtoChunk.java -@@ -29,7 +29,7 @@ import net.minecraft.world.level.material.FluidState; - import net.minecraft.world.ticks.BlackholeTickAccess; +@@ -29,7 +29,7 @@ import net.minecraft.world.ticks.BlackholeTickAccess; import net.minecraft.world.ticks.TickContainerAccess; + import org.jspecify.annotations.Nullable; -public class ImposterProtoChunk extends ProtoChunk { +public class ImposterProtoChunk extends ProtoChunk implements ca.spottedleaf.moonrise.patches.starlight.chunk.StarlightChunk { // Paper - rewrite chunk system @@ -31859,15 +31834,15 @@ index ab33c5dc6f4d70c1edf0377478110881aadafd3d..7d739e72c9a47776d1cc19204a4e13d9 + } + // Paper end - rewrite chunk system + - @Nullable @Override - public BlockEntity getBlockEntity(BlockPos pos) { + public @Nullable BlockEntity getBlockEntity(BlockPos pos) { + return this.wrapped.getBlockEntity(pos); diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e064958038da44bf 100644 +index d95fb59650cf5018902321cc7be895b7e7de7f25..356a89ef2396f245e438d59d65edd0445693cb8b 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -62,7 +62,7 @@ import net.minecraft.world.ticks.LevelChunkTicks; - import net.minecraft.world.ticks.TickContainerAccess; +@@ -63,7 +63,7 @@ import net.minecraft.world.ticks.TickContainerAccess; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class LevelChunk extends ChunkAccess implements DebugValueSource { @@ -31875,7 +31850,7 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 static final Logger LOGGER = LogUtils.getLogger(); private static final TickingBlockEntity NULL_TICKER = new TickingBlockEntity() { @Override -@@ -103,6 +103,39 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -102,6 +102,39 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { // Paper start boolean loadedTicketLevel; // Paper end @@ -31915,7 +31890,7 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 public LevelChunk(Level level, ChunkPos pos) { this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null); -@@ -132,6 +165,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -131,6 +164,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { this.postLoad = postLoad; this.blockTicks = blockTicks; this.fluidTicks = fluidTicks; @@ -31929,8 +31904,8 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 + // Paper end - get block chunk optimisation } - public LevelChunk(ServerLevel level, ProtoChunk chunk, @Nullable LevelChunk.PostLoadProcessor postLoad) { -@@ -169,13 +210,19 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { + public LevelChunk(ServerLevel level, ProtoChunk chunk, LevelChunk.@Nullable PostLoadProcessor postLoad) { +@@ -168,13 +209,19 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { } } @@ -31951,7 +31926,7 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 } public void setUnsavedListener(LevelChunk.UnsavedListener unsavedListener) { -@@ -347,7 +394,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -345,7 +392,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { if (LightEngine.hasDifferentLightProperties(blockState, state)) { ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("updateSkyLightSources"); @@ -31960,7 +31935,7 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 profilerFiller.popPush("queueCheckLight"); this.level.getChunkSource().getLightEngine().checkBlock(pos); profilerFiller.pop(); -@@ -594,11 +641,12 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -588,11 +635,12 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { // CraftBukkit start public void loadCallback() { @@ -31974,7 +31949,7 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 if (server != null) { /* * If it's a new world, the first few chunks are generated inside -@@ -607,6 +655,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -601,6 +649,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { */ org.bukkit.Chunk bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this); server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(bukkitChunk, this.needsDecoration)); @@ -31982,7 +31957,7 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 if (this.needsDecoration) { this.needsDecoration = false; -@@ -633,13 +682,15 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -627,13 +676,15 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { } public void unloadCallback() { @@ -32000,7 +31975,7 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 // Paper start this.loadedTicketLevel = false; // Paper end -@@ -647,8 +698,31 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -641,8 +692,31 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { @Override public boolean isUnsaved() { @@ -32033,14 +32008,14 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 // CraftBukkit end public boolean isEmpty() { -@@ -726,6 +800,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -721,6 +795,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { this.pendingBlockEntities.clear(); this.upgradeData.upgrade(this); + this.postProcessingDone = true; // Paper - rewrite chunk system } - @Nullable + private @Nullable BlockEntity promotePendingBlockEntity(BlockPos pos, CompoundTag tag) { diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java index c721edb770a46403da38a5cdcff241a1c50cb32d..5a76746a27d04cc095585655f2ef19ac10528071 100644 --- a/net/minecraft/world/level/chunk/LevelChunkSection.java @@ -32297,10 +32272,10 @@ index 8ac6109c37cd83c87e4257ed2f33b2352d072702..43679751e0251f9ccab9d617be672854 boolean maybeHas(Predicate filter); diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java -index 3644acef852d1ae0ff6daf6208b1a4422b003d7b..49c00586c1ae55e5e85787fa7cd4b84e8d5c83c7 100644 +index 889d2db9ae9a8d5ca7b150431f1d3c4892a241d9..0740775f2fa49c4313c1de6dd00f0a39fe2e0463 100644 --- a/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/net/minecraft/world/level/chunk/PalettedContainer.java -@@ -24,7 +24,7 @@ import net.minecraft.util.ZeroBitStorage; +@@ -24,7 +24,7 @@ import org.jspecify.annotations.Nullable; public class PalettedContainer implements PaletteResize, PalettedContainerRO { private static final int MIN_PALETTE_BITS = 0; @@ -32359,7 +32334,7 @@ index 3644acef852d1ae0ff6daf6208b1a4422b003d7b..49c00586c1ae55e5e85787fa7cd4b84e + this.updateData(this.data); // Paper - optimise palette reads } - private PalettedContainer.Data createOrReuseData(@Nullable PalettedContainer.Data data, int bits) { + private PalettedContainer.Data createOrReuseData(PalettedContainer.@Nullable Data data, int bits) { @@ -98,6 +128,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer PalettedContainer.Data data1 = this.createOrReuseData(data, bits); data1.copyFrom(data.palette, data.storage); @@ -32454,10 +32429,10 @@ index 3644acef852d1ae0ff6daf6208b1a4422b003d7b..49c00586c1ae55e5e85787fa7cd4b84e PaletteResize paletteResize = PaletteResize.noResizeExpected(); diff --git a/net/minecraft/world/level/chunk/ProtoChunk.java b/net/minecraft/world/level/chunk/ProtoChunk.java -index 6868cb3ba98b10e32fcee32719f53f90eae59ec3..456d301d45350fb15de5ab663c482257e607f3aa 100644 +index ff2a34c83fbcc27e87a85bcaab411b042c85dc0b..fd923d89d4456f0b13d97ef6fa90815a27e2e734 100644 --- a/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/net/minecraft/world/level/chunk/ProtoChunk.java -@@ -158,7 +158,7 @@ public class ProtoChunk extends ChunkAccess { +@@ -154,7 +154,7 @@ public class ProtoChunk extends ChunkAccess { } if (LightEngine.hasDifferentLightProperties(blockState, state)) { @@ -32467,17 +32442,16 @@ index 6868cb3ba98b10e32fcee32719f53f90eae59ec3..456d301d45350fb15de5ab663c482257 } } diff --git a/net/minecraft/world/level/chunk/SingleValuePalette.java b/net/minecraft/world/level/chunk/SingleValuePalette.java -index 6e7462fbe6a973a5d2d9f89ac2abc72e1f78d882..9759285f029ba62ac80b9783ddb1f278ec88bf70 100644 +index 18a006890c466b84c32537745ea249662ac2aaf0..e0ed8499a90eb350cc483001ea10f2c8e9173875 100644 --- a/net/minecraft/world/level/chunk/SingleValuePalette.java +++ b/net/minecraft/world/level/chunk/SingleValuePalette.java -@@ -8,10 +8,22 @@ import net.minecraft.network.FriendlyByteBuf; - import net.minecraft.network.VarInt; +@@ -8,9 +8,21 @@ import net.minecraft.network.VarInt; import org.apache.commons.lang3.Validate; + import org.jspecify.annotations.Nullable; -public class SingleValuePalette implements Palette { +public class SingleValuePalette implements Palette, ca.spottedleaf.moonrise.patches.fast_palette.FastPalette { // Paper - optimise palette reads - @Nullable - private T value; + private @Nullable T value; + // Paper start - optimise palette reads + private T[] rawPalette; @@ -32492,9 +32466,9 @@ index 6e7462fbe6a973a5d2d9f89ac2abc72e1f78d882..9759285f029ba62ac80b9783ddb1f278 + // Paper end - optimise palette reads + public SingleValuePalette(List values) { - if (values.size() > 0) { + if (!values.isEmpty()) { Validate.isTrue(values.size() <= 1, "Can't initialize SingleValuePalette with %d values.", (long)values.size()); -@@ -29,6 +41,11 @@ public class SingleValuePalette implements Palette { +@@ -28,6 +40,11 @@ public class SingleValuePalette implements Palette { return resizeHandler.onResize(1, state); } else { this.value = state; @@ -32506,7 +32480,7 @@ index 6e7462fbe6a973a5d2d9f89ac2abc72e1f78d882..9759285f029ba62ac80b9783ddb1f278 return 0; } } -@@ -54,6 +71,11 @@ public class SingleValuePalette implements Palette { +@@ -53,6 +70,11 @@ public class SingleValuePalette implements Palette { @Override public void read(FriendlyByteBuf buffer, IdMap map) { this.value = map.byIdOrThrow(buffer.readVarInt()); @@ -32532,12 +32506,12 @@ index 9c6f4aa173fa25f9c8a3852d91a4585e069236b6..b14001afe0bf841dac7d0a1d1568fd10 .step(ChunkStatus.FULL, builder -> builder.setTask(ChunkStatusTasks::full)) .build(); diff --git a/net/minecraft/world/level/chunk/status/ChunkStatus.java b/net/minecraft/world/level/chunk/status/ChunkStatus.java -index f2aa944dedf917f01d669a703a9b9f4f35af78c2..116efc09663cac3b0f4b8c157e93201e8cc9b7a4 100644 +index 204b99f48ba8e2fd724a43ede73abc41a4147872..a04f20297c984a31216cbeb1c8d049728c9b6a65 100644 --- a/net/minecraft/world/level/chunk/status/ChunkStatus.java +++ b/net/minecraft/world/level/chunk/status/ChunkStatus.java -@@ -12,7 +12,7 @@ import net.minecraft.resources.ResourceLocation; +@@ -12,7 +12,7 @@ import net.minecraft.resources.Identifier; import net.minecraft.world.level.levelgen.Heightmap; - import org.jetbrains.annotations.VisibleForTesting; + import org.jspecify.annotations.Nullable; -public class ChunkStatus { +public class ChunkStatus implements ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemChunkStatus { // Paper - rewrite chunk system @@ -32644,12 +32618,12 @@ index 98e85820ac5aad77a003be4b6f7a59346524ae81..d620862e95abf9f098bb53a76825883f } } diff --git a/net/minecraft/world/level/chunk/status/ChunkStep.java b/net/minecraft/world/level/chunk/status/ChunkStep.java -index 7a4d299d2ce36982204e30de9278ddfd5b37c3df..b8348976e80578d9eff64eea68c04c603fed49ad 100644 +index e29ad470f868fd26259bc0c2dbd6e0c1eb97bae4..aa8c40d49756611537e2698b7f2a861c303ef842 100644 --- a/net/minecraft/world/level/chunk/status/ChunkStep.java +++ b/net/minecraft/world/level/chunk/status/ChunkStep.java -@@ -11,9 +11,50 @@ import net.minecraft.util.profiling.jfr.callback.ProfiledDuration; - import net.minecraft.world.level.chunk.ChunkAccess; +@@ -11,9 +11,50 @@ import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ProtoChunk; + import org.jspecify.annotations.Nullable; -public record ChunkStep( - ChunkStatus targetStatus, ChunkDependencies directDependencies, ChunkDependencies accumulatedDependencies, int blockStateWriteRadius, ChunkStatusTask task @@ -32757,137 +32731,12 @@ index 7a4d299d2ce36982204e30de9278ddfd5b37c3df..b8348976e80578d9eff64eea68c04c60 + public static class Builder { private final ChunkStatus status; - @Nullable -diff --git a/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/net/minecraft/world/level/chunk/storage/ChunkStorage.java -index 8c1417c659ea0e079e99b9bfa79e1cf6ba9b712b..8847fc3b164bb011cea24217623c59f5b78f787b 100644 ---- a/net/minecraft/world/level/chunk/storage/ChunkStorage.java -+++ b/net/minecraft/world/level/chunk/storage/ChunkStorage.java -@@ -22,20 +22,30 @@ import net.minecraft.world.level.chunk.ChunkGenerator; - import net.minecraft.world.level.levelgen.structure.LegacyStructureDataHandler; - import net.minecraft.world.level.storage.DimensionDataStorage; - --public class ChunkStorage implements AutoCloseable { -+public class ChunkStorage implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemChunkStorage { // Paper - rewrite chunk system - public static final int LAST_MONOLYTH_STRUCTURE_DATA_VERSION = 1493; -- private final IOWorker worker; -+ // Paper - rewrite chunk system - protected final DataFixer fixerUpper; - @Nullable - private volatile LegacyStructureDataHandler legacyStructureHandler; - -+ // Paper start - rewrite chunk system -+ private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); -+ private final RegionFileStorage storage; -+ -+ @Override -+ public final RegionFileStorage moonrise$getRegionStorage() { -+ return this.storage; -+ } -+ // Paper end - rewrite chunk system -+ - public ChunkStorage(RegionStorageInfo info, Path folder, DataFixer fixerUpper, boolean sync) { - this.fixerUpper = fixerUpper; -- this.worker = new IOWorker(info, folder, sync); -+ this.storage = new IOWorker(info, folder, sync).storage; // Paper - rewrite chunk system - } - - public boolean isOldChunkAround(ChunkPos pos, int radius) { -- return this.worker.isOldChunkAround(pos, radius); -+ return true; // Paper - rewrite chunk system - } - - // CraftBukkit start -@@ -66,7 +76,9 @@ public class ChunkStorage implements AutoCloseable { - chunkData = DataFixTypes.CHUNK.update(this.fixerUpper, chunkData, version, 1493); - if (chunkData.getCompound("Level").flatMap(compoundTag -> compoundTag.getBoolean("hasLegacyStructureData")).orElse(false)) { - LegacyStructureDataHandler legacyStructureHandler = this.getLegacyStructureHandler(levelKey, storage); -+ synchronized (legacyStructureHandler) { // Paper - rewrite chunk system - chunkData = legacyStructureHandler.updateFromLegacy(chunkData); -+ } - } - } - -@@ -130,7 +142,13 @@ public class ChunkStorage implements AutoCloseable { - } - - public CompletableFuture> read(ChunkPos chunkPos) { -- return this.worker.loadAsync(chunkPos); -+ // Paper start - rewrite chunk system -+ try { -+ return CompletableFuture.completedFuture(Optional.ofNullable(this.storage.read(chunkPos))); -+ } catch (final Throwable throwable) { -+ return CompletableFuture.failedFuture(throwable); -+ } -+ // Paper end - rewrite chunk system - } - - public CompletableFuture write(ChunkPos pos, Supplier tagSupplier) { -@@ -146,29 +164,54 @@ public class ChunkStorage implements AutoCloseable { - }; - // Paper end - guard against possible chunk pos desync - this.handleLegacyStructureIndex(pos); -- return this.worker.store(pos, guardedPosCheck); // Paper - guard against possible chunk pos desync -+ // Paper start - rewrite chunk system -+ try { -+ this.storage.write(pos, guardedPosCheck.get()); -+ return CompletableFuture.completedFuture(null); -+ } catch (final Throwable throwable) { -+ return CompletableFuture.failedFuture(throwable); -+ } -+ // Paper end - rewrite chunk system - } - - protected void handleLegacyStructureIndex(ChunkPos chunkPos) { - if (this.legacyStructureHandler != null) { -+ synchronized (this.legacyStructureHandler) { // Paper - rewrite chunk system - this.legacyStructureHandler.removeIndex(chunkPos.toLong()); -+ } // Paper - rewrite chunk system - } - } - - public void flushWorker() { -- this.worker.synchronize(true).join(); -+ // Paper start - rewrite chunk system -+ try { -+ this.storage.flush(); -+ } catch (final IOException ex) { -+ LOGGER.error("Failed to flush chunk storage", ex); -+ } -+ // Paper end - rewrite chunk system - } - - @Override - public void close() throws IOException { -- this.worker.close(); -+ this.storage.close(); // Paper - rewrite chunk system - } - - public ChunkScanAccess chunkScanner() { -- return this.worker; -+ // Paper start - rewrite chunk system -+ // TODO ChunkMap implementation? -+ return (chunkPos, streamTagVisitor) -> { -+ try { -+ this.storage.scanChunk(chunkPos, streamTagVisitor); -+ return java.util.concurrent.CompletableFuture.completedFuture(null); -+ } catch (IOException e) { -+ throw new RuntimeException(e); -+ } -+ }; -+ // Paper end - rewrite chunk system - } - -- protected RegionStorageInfo storageInfo() { -- return this.worker.storageInfo(); -+ public RegionStorageInfo storageInfo() { // Paper - public -+ return this.storage.info(); // Paper - rewrite chunk system - } - } + private final @Nullable ChunkStep parent; diff --git a/net/minecraft/world/level/chunk/storage/IOWorker.java b/net/minecraft/world/level/chunk/storage/IOWorker.java -index d0de56609f6f22dded474d7693935180761d2cb5..27e1edbd8d8ffd80c1a3df17bc47f4a6936619f7 100644 +index 17c91f6aa109b3cba51637e8499602d47e7a8649..b2b7c20a25bdefd42e8a36eb29935b8d5b24925d 100644 --- a/net/minecraft/world/level/chunk/storage/IOWorker.java +++ b/net/minecraft/world/level/chunk/storage/IOWorker.java -@@ -30,7 +30,7 @@ public class IOWorker implements ChunkScanAccess, AutoCloseable { +@@ -31,7 +31,7 @@ public class IOWorker implements ChunkScanAccess, AutoCloseable { private static final Logger LOGGER = LogUtils.getLogger(); private final AtomicBoolean shutdownRequested = new AtomicBoolean(); private final PriorityConsecutiveExecutor consecutiveExecutor; @@ -32897,11 +32746,11 @@ index d0de56609f6f22dded474d7693935180761d2cb5..27e1edbd8d8ffd80c1a3df17bc47f4a6 private final Long2ObjectLinkedOpenHashMap> regionCacheForBlender = new Long2ObjectLinkedOpenHashMap<>(); private static final int REGION_CACHE_SIZE = 1024; diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java -index 43d38cf26224919cd53d7479753d658f4ab40dbc..07c2e2170af5820acdcb64f2c7978845c31641a1 100644 +index f5d24254c84876f85d89e33381fae484817acf04..99bbae1f8f681950f410b2bfe9af037164d8dcb7 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java -@@ -22,7 +22,7 @@ import net.minecraft.util.profiling.jfr.JvmProfiler; - import net.minecraft.world.level.ChunkPos; +@@ -22,7 +22,7 @@ import net.minecraft.world.level.ChunkPos; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class RegionFile implements AutoCloseable { @@ -32931,10 +32780,13 @@ index 43d38cf26224919cd53d7479753d658f4ab40dbc..07c2e2170af5820acdcb64f2c7978845 public RegionFile(RegionStorageInfo info, Path path, Path externalFileDir, boolean sync) throws IOException { this(info, path, externalFileDir, RegionFileVersion.getCompressionFormat(), sync); // Paper - Configurable region compression format } -@@ -203,6 +218,16 @@ public class RegionFile implements AutoCloseable { +@@ -199,7 +214,17 @@ public class RegionFile implements AutoCloseable { + } + } - @Nullable - private DataInputStream createExternalChunkInputStream(ChunkPos chunkPos, byte versionByte) throws IOException { +- private @Nullable DataInputStream createExternalChunkInputStream(ChunkPos chunkPos, byte versionByte) throws IOException { ++ @Nullable ++ private DataInputStream createExternalChunkInputStream(ChunkPos chunkPos, byte versionByte) throws IOException { + // Paper start - rewrite chunk system + final DataInputStream is = this.createExternalChunkInputStream0(chunkPos, versionByte); + if (is == null) { @@ -32942,13 +32794,12 @@ index 43d38cf26224919cd53d7479753d658f4ab40dbc..07c2e2170af5820acdcb64f2c7978845 + } + return new ca.spottedleaf.moonrise.patches.chunk_system.util.stream.ExternalChunkStreamMarker(is); + } -+ @Nullable -+ private DataInputStream createExternalChunkInputStream0(ChunkPos chunkPos, byte versionByte) throws IOException { ++ private @Nullable DataInputStream createExternalChunkInputStream0(ChunkPos chunkPos, byte versionByte) throws IOException { + // Paper end - rewrite chunk system Path externalChunkPath = this.getExternalChunkPath(chunkPos); if (!Files.isRegularFile(externalChunkPath)) { LOGGER.error("External chunk path {} is not file", externalChunkPath); -@@ -397,9 +422,28 @@ public class RegionFile implements AutoCloseable { +@@ -394,9 +419,28 @@ public class RegionFile implements AutoCloseable { } } @@ -32978,7 +32829,7 @@ index 43d38cf26224919cd53d7479753d658f4ab40dbc..07c2e2170af5820acdcb64f2c7978845 public ChunkBuffer(final ChunkPos pos) { super(8096); super.write(0); -@@ -416,7 +460,7 @@ public class RegionFile implements AutoCloseable { +@@ -413,7 +457,7 @@ public class RegionFile implements AutoCloseable { int i = this.count - 5 + 1; JvmProfiler.INSTANCE.onRegionFileWrite(RegionFile.this.info, this.pos, RegionFile.this.version, i); byteBuffer.putInt(0, i); @@ -32988,12 +32839,12 @@ index 43d38cf26224919cd53d7479753d658f4ab40dbc..07c2e2170af5820acdcb64f2c7978845 } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 54ac20dede33a20231476d433f39cadc40c9fa49..263ab4a8056ed9115c293484fef13e6f485dcf6d 100644 +index 95a717797dc1bba5595e8305f21b193b2e1702cc..5d9168242f7a7ca4dd888f32fecb27457fd89456 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -15,7 +15,7 @@ import net.minecraft.nbt.StreamTagVisitor; - import net.minecraft.util.ExceptionCollector; +@@ -15,7 +15,7 @@ import net.minecraft.util.FileUtil; import net.minecraft.world.level.ChunkPos; + import org.jspecify.annotations.Nullable; -public final class RegionFileStorage implements AutoCloseable { +public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.io.ChunkSystemRegionFileStorage { // Paper - rewrite chunk system @@ -33230,8 +33081,8 @@ index 54ac20dede33a20231476d433f39cadc40c9fa49..263ab4a8056ed9115c293484fef13e6f + // Paper end - rewrite chunk system } - @Nullable -@@ -84,9 +273,15 @@ public final class RegionFileStorage implements AutoCloseable { + public @Nullable CompoundTag read(ChunkPos chunkPos) throws IOException { +@@ -83,9 +272,15 @@ public final class RegionFileStorage implements AutoCloseable { } } @@ -33249,7 +33100,7 @@ index 54ac20dede33a20231476d433f39cadc40c9fa49..263ab4a8056ed9115c293484fef13e6f if (chunkData == null) { regionFile.clear(chunkPos); } else { -@@ -99,23 +294,36 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -98,23 +293,36 @@ public final class RegionFileStorage implements AutoCloseable { @Override public void close() throws IOException { @@ -33298,11 +33149,11 @@ index 54ac20dede33a20231476d433f39cadc40c9fa49..263ab4a8056ed9115c293484fef13e6f public RegionStorageInfo info() { diff --git a/net/minecraft/world/level/chunk/storage/SectionStorage.java b/net/minecraft/world/level/chunk/storage/SectionStorage.java -index 06cf2363218eddacc6cdfd95dcfd9dfc55403b88..afac559b3c38c4a175070ed823dc8f2c34f4a004 100644 +index 7514737caf11630433752206fd614ee221f3523e..42699c82321233eaa3647ca0ac4d1f24b6a6227f 100644 --- a/net/minecraft/world/level/chunk/storage/SectionStorage.java +++ b/net/minecraft/world/level/chunk/storage/SectionStorage.java -@@ -40,10 +40,10 @@ import net.minecraft.world.level.ChunkPos; - import net.minecraft.world.level.LevelHeightAccessor; +@@ -40,10 +40,10 @@ import net.minecraft.world.level.LevelHeightAccessor; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class SectionStorage implements AutoCloseable { @@ -33346,11 +33197,11 @@ index 06cf2363218eddacc6cdfd95dcfd9dfc55403b88..afac559b3c38c4a175070ed823dc8f2c this.registryAccess = registryAccess; this.errorReporter = errorReporter; this.levelHeightAccessor = levelHeightAccessor; -+ this.regionStorage = simpleRegionStorage.worker.storage; // Paper - rewrite chunk system ++ this.regionStorage = ((ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemSimpleRegionStorage)simpleRegionStorage).moonrise$getRegionStorage(); // Paper - rewrite chunk system } protected void tick(BooleanSupplier aheadOfTime) { -@@ -188,65 +201,15 @@ public class SectionStorage implements AutoCloseable { +@@ -187,65 +200,15 @@ public class SectionStorage implements AutoCloseable { } private CompletableFuture>> tryRead(ChunkPos chunkPos) { @@ -33379,7 +33230,7 @@ index 06cf2363218eddacc6cdfd95dcfd9dfc55403b88..afac559b3c38c4a175070ed823dc8f2c + throw new IllegalStateException("Only chunk system can write state, offending class:" + this.getClass().getName()); // Paper - rewrite chunk system } - private void unpackChunk(ChunkPos pos, @Nullable SectionStorage.PackedChunk

packedChunk) { + private void unpackChunk(ChunkPos pos, SectionStorage.@Nullable PackedChunk

packedChunk) { - if (packedChunk == null) { - for (int sectionY = this.levelHeightAccessor.getMinSectionY(); sectionY <= this.levelHeightAccessor.getMaxSectionY(); sectionY++) { - this.storage.put(getKey(pos, sectionY), Optional.empty()); @@ -33407,8 +33258,8 @@ index 06cf2363218eddacc6cdfd95dcfd9dfc55403b88..afac559b3c38c4a175070ed823dc8f2c - RegistryOps registryOps = this.registryAccess.createSerializationContext(NbtOps.INSTANCE); - Dynamic dynamic = this.writeChunk(pos, registryOps); - Tag tag = dynamic.getValue(); -- if (tag instanceof CompoundTag) { -- this.simpleRegionStorage.write(pos, (CompoundTag)tag).exceptionally(throwable -> { +- if (tag instanceof CompoundTag compoundTag) { +- this.simpleRegionStorage.write(pos, compoundTag).exceptionally(throwable -> { - this.errorReporter.reportChunkSaveFailure(throwable, this.simpleRegionStorage.storageInfo(), pos); - return null; - }); @@ -33419,7 +33270,7 @@ index 06cf2363218eddacc6cdfd95dcfd9dfc55403b88..afac559b3c38c4a175070ed823dc8f2c } private Dynamic writeChunk(ChunkPos pos, DynamicOps ops) { -@@ -282,7 +245,7 @@ public class SectionStorage implements AutoCloseable { +@@ -281,7 +244,7 @@ public class SectionStorage implements AutoCloseable { protected void onSectionLoad(long sectionKey) { } @@ -33428,7 +33279,7 @@ index 06cf2363218eddacc6cdfd95dcfd9dfc55403b88..afac559b3c38c4a175070ed823dc8f2c Optional optional = this.storage.get(sectionPos); if (optional != null && !optional.isEmpty()) { this.dirtyChunks.add(ChunkPos.asLong(SectionPos.x(sectionPos), SectionPos.z(sectionPos))); -@@ -299,7 +262,7 @@ public class SectionStorage implements AutoCloseable { +@@ -298,7 +261,7 @@ public class SectionStorage implements AutoCloseable { @Override public void close() throws IOException { @@ -33438,10 +33289,10 @@ index 06cf2363218eddacc6cdfd95dcfd9dfc55403b88..afac559b3c38c4a175070ed823dc8f2c record PackedChunk(Int2ObjectMap sectionsByY, boolean versionChanged) { diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19794343b1 100644 +index 7fe16da65d6cf5019fa854324d43e0f97bb0b016..b2363fa364be15d0a28f5966615131282b7aaa8f 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -@@ -144,7 +144,7 @@ public record SerializableChunkData( +@@ -143,7 +143,7 @@ public record SerializableChunkData( long longOr1 = tag.getLongOr("InhabitedTime", 0L); ChunkStatus chunkStatus = tag.read("Status", ChunkStatus.CODEC).orElse(ChunkStatus.EMPTY); UpgradeData upgradeData = tag.getCompound("UpgradeData").map(compoundTag1 -> new UpgradeData(compoundTag1, level)).orElse(UpgradeData.EMPTY); @@ -33450,16 +33301,16 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 BlendingData.Packed packed = tag.read("blending_data", BlendingData.Packed.CODEC).orElse(null); BelowZeroRetrogen belowZeroRetrogen = tag.read("below_zero_retrogen", BelowZeroRetrogen.CODEC).orElse(null); long[] longs = tag.getLongArray("carving_mask").orElse(null); -@@ -182,7 +182,7 @@ public record SerializableChunkData( - for (int i2 = 0; i2 < listOrEmpty2.size(); i2++) { - Optional compound = listOrEmpty2.getCompound(i2); +@@ -183,7 +183,7 @@ public record SerializableChunkData( + for (int i2 = 0; i2 < listOrEmpty1.size(); i2++) { + Optional compound = listOrEmpty1.getCompound(i2); if (!compound.isEmpty()) { - CompoundTag compoundTag = compound.get(); + CompoundTag compoundTag = compound.get(); final CompoundTag sectionData = compoundTag; // Paper - OBFHELPER int byteOr = compoundTag.getByteOr("Y", (byte)0); LevelChunkSection levelChunkSection; if (byteOr >= level.getMinSectionY() && byteOr <= level.getMaxSectionY()) { -@@ -207,7 +207,17 @@ public record SerializableChunkData( +@@ -208,7 +208,17 @@ public record SerializableChunkData( DataLayer dataLayer = compoundTag.getByteArray("BlockLight").map(DataLayer::new).orElse(null); DataLayer dataLayer1 = compoundTag.getByteArray("SkyLight").map(DataLayer::new).orElse(null); @@ -33478,7 +33329,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 } } -@@ -235,6 +245,59 @@ public record SerializableChunkData( +@@ -236,6 +246,59 @@ public record SerializableChunkData( } } @@ -33538,7 +33389,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 public ProtoChunk read(ServerLevel level, PoiManager poiManager, RegionStorageInfo regionStorageInfo, ChunkPos pos) { if (!Objects.equals(pos, this.chunkPos)) { LOGGER.error("Chunk file at {} is in the wrong location; relocating. (Expected {}, got {})", pos, pos, this.chunkPos); -@@ -253,7 +316,7 @@ public record SerializableChunkData( +@@ -254,7 +317,7 @@ public record SerializableChunkData( SectionPos sectionPos = SectionPos.of(pos, sectionData.y); if (sectionData.chunkSection != null) { levelChunkSections[level.getSectionIndexFromSectionY(sectionData.y)] = sectionData.chunkSection; @@ -33547,7 +33398,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 } boolean flag1 = sectionData.blockLight != null; -@@ -342,7 +405,7 @@ public record SerializableChunkData( +@@ -346,7 +409,7 @@ public record SerializableChunkData( } if (chunkType == ChunkType.LEVELCHUNK) { @@ -33556,7 +33407,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 } else { ProtoChunk protoChunk1 = (ProtoChunk)chunkAccess; -@@ -358,7 +421,7 @@ public record SerializableChunkData( +@@ -362,7 +425,7 @@ public record SerializableChunkData( protoChunk1.setCarvingMask(new CarvingMask(this.carvingMask, chunkAccess.getMinY())); } @@ -33565,7 +33416,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 } } -@@ -371,22 +434,48 @@ public record SerializableChunkData( +@@ -375,22 +438,48 @@ public record SerializableChunkData( throw new IllegalArgumentException("Chunk can't be serialized: " + chunk); } else { ChunkPos pos = chunk.getPos(); @@ -33625,7 +33476,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 List list1 = new ArrayList<>(chunk.getBlockEntitiesPos().size()); -@@ -473,7 +562,7 @@ public record SerializableChunkData( +@@ -477,7 +566,7 @@ public record SerializableChunkData( Codec>> codec1 = this.containerFactory.biomeContainerCodec(); for (SerializableChunkData.SectionData sectionData : this.sectionData) { @@ -33634,7 +33485,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 LevelChunkSection levelChunkSection = sectionData.chunkSection; if (levelChunkSection != null) { compoundTag1.store("block_states", codec, levelChunkSection.getStates()); -@@ -488,6 +577,19 @@ public record SerializableChunkData( +@@ -492,6 +581,19 @@ public record SerializableChunkData( compoundTag1.putByteArray("SkyLight", sectionData.skyLight.getData()); } @@ -33654,7 +33505,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 if (!compoundTag1.isEmpty()) { compoundTag1.putByte("Y", (byte)sectionData.y); listTag.add(compoundTag1); -@@ -522,6 +624,14 @@ public record SerializableChunkData( +@@ -526,6 +628,14 @@ public record SerializableChunkData( compoundTag.put("ChunkBukkitValues", this.persistentDataContainer); } // CraftBukkit end @@ -33669,7 +33520,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 return compoundTag; } -@@ -667,6 +777,66 @@ public record SerializableChunkData( +@@ -670,6 +780,66 @@ public record SerializableChunkData( } } @@ -33738,30 +33589,147 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 } } diff --git a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java -index bc4adf91ca8aa0160a1e3940f1396e62207fcc74..a30cbccae6d6cf2f7248501c1b1de3c124688b5e 100644 +index ab5ee9d343ef3b3930eadf9bc17c202215c15121..ba620dafb862dd59fff85da0619dc66cc1c2cb20 100644 --- a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java +++ b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java -@@ -14,7 +14,7 @@ import net.minecraft.util.datafix.DataFixTypes; +@@ -19,8 +19,9 @@ import net.minecraft.util.datafix.DataFixTypes; import net.minecraft.world.level.ChunkPos; + import org.jspecify.annotations.Nullable; - public class SimpleRegionStorage implements AutoCloseable { +-public class SimpleRegionStorage implements AutoCloseable { - private final IOWorker worker; -+ public final IOWorker worker; // Paper - public ++public class SimpleRegionStorage implements ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemSimpleRegionStorage, AutoCloseable { // Paper - rewrite chunk system ++ private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getClassLogger(); // Paper - rewrite chunk system ++ private final RegionFileStorage storage; // Paper - rewrite chunk system private final DataFixer fixerUpper; private final DataFixTypes dataFixType; + private final Supplier legacyFixer; +@@ -34,16 +35,29 @@ public class SimpleRegionStorage implements AutoCloseable { + ) { + this.fixerUpper = fixerUpper; + this.dataFixType = dataFixType; +- this.worker = new IOWorker(info, folder, sync); ++ this.storage = new IOWorker(info, folder, sync).storage; // Paper - rewrite chunk system + this.legacyFixer = Suppliers.memoize(legacyFixer::get); + } ++ // Paper start - rewrite chunk system ++ @Override ++ public final RegionFileStorage moonrise$getRegionStorage() { ++ return this.storage; ++ } ++ // Paper end - rewrite chunk system ++ + public boolean isOldChunkAround(ChunkPos chunkPos, int radius) { +- return this.worker.isOldChunkAround(chunkPos, radius); ++ return true; // Paper - rewrite chunk system + } + + public CompletableFuture> read(ChunkPos chunkPos) { +- return this.worker.loadAsync(chunkPos); ++ // Paper start - rewrite chunk system ++ try { ++ return CompletableFuture.completedFuture(Optional.ofNullable(this.storage.read(chunkPos))); ++ } catch (final Throwable throwable) { ++ return CompletableFuture.failedFuture(throwable); ++ } ++ // Paper end - rewrite chunk system + } + + public CompletableFuture write(ChunkPos chunkPos, CompoundTag data) { +@@ -64,7 +78,14 @@ public class SimpleRegionStorage implements AutoCloseable { + }; + // Paper end - guard against possible chunk pos desync + this.markChunkDone(chunkPos); +- return this.worker.store(chunkPos, guardedPosCheck); // Paper - guard against possible chunk pos desync ++ // Paper - rewrite chunk system ++ try { ++ this.storage.write(chunkPos, guardedPosCheck.get()); ++ return CompletableFuture.completedFuture(null); ++ } catch (final Throwable throwable) { ++ return CompletableFuture.failedFuture(throwable); ++ } ++ // Paper end - rewrite chunk system + } + + public CompoundTag upgradeChunkTag(CompoundTag tag, int fallbackVersion, @Nullable CompoundTag contextTag, net.minecraft.world.level.@Nullable LevelAccessor levelAccessor) { // CraftBukkit +@@ -73,7 +94,12 @@ public class SimpleRegionStorage implements AutoCloseable { + return tag; + } else { + try { +- tag = this.legacyFixer.get().applyFix(tag); ++ // Paper start - rewrite chunk system ++ final net.minecraft.world.level.chunk.storage.LegacyTagFixer legacyFixer = this.legacyFixer.get(); ++ synchronized (legacyFixer) { ++ tag = legacyFixer.applyFix(tag); ++ } ++ // Paper end - rewrite chunk system + // Spigot start - SPIGOT-6806: Quick and dirty way to prevent below zero generation in old chunks, by setting the status to heightmap instead of empty + boolean stopBelowZero = false; + final boolean chunkStorage = this.dataFixType == net.minecraft.util.datafix.DataFixTypes.CHUNK; +@@ -123,23 +149,46 @@ public class SimpleRegionStorage implements AutoCloseable { + } + + protected void markChunkDone(ChunkPos chunkPos) { +- this.legacyFixer.get().markChunkDone(chunkPos); ++ // Paper start - rewrite chunk system ++ final net.minecraft.world.level.chunk.storage.LegacyTagFixer legacyFixer = this.legacyFixer.get(); ++ synchronized (legacyFixer) { ++ legacyFixer.markChunkDone(chunkPos); ++ } ++ // Paper end - rewrite chunk system + } + + public CompletableFuture synchronize(boolean flushStorage) { +- return this.worker.synchronize(flushStorage); ++ // Paper start - rewrite chunk system ++ try { ++ this.storage.flush(); ++ return CompletableFuture.completedFuture(null); ++ } catch (final IOException ex) { ++ LOGGER.error("Failed to flush chunk storage", ex); ++ return CompletableFuture.failedFuture(ex); ++ } ++ // Paper end - rewrite chunk system + } + + @Override + public void close() throws IOException { +- this.worker.close(); ++ this.storage.close(); // Paper - rewrite chunk system + } + + public ChunkScanAccess chunkScanner() { +- return this.worker; ++ // Paper start - rewrite chunk system ++ // TODO ChunkMap implementation? ++ return (chunkPos, streamTagVisitor) -> { ++ try { ++ this.storage.scanChunk(chunkPos, streamTagVisitor); ++ return java.util.concurrent.CompletableFuture.completedFuture(null); ++ } catch (IOException e) { ++ throw new RuntimeException(e); ++ } ++ }; ++ // Paper end - rewrite chunk system + } + + public RegionStorageInfo storageInfo() { +- return this.worker.storageInfo(); ++ return this.storage.info(); // Paper - rewrite chunk system + } + } diff --git a/net/minecraft/world/level/entity/EntityTickList.java b/net/minecraft/world/level/entity/EntityTickList.java -index 342c83309b19c64d86e0dd97c1756c96be52772b..423779a2b690f387a4f0bd07b97b50e0baefda76 100644 +index 3861282e2e55c28bd4fa0169373ce5d8b914802e..79a34ce6c888a611115719412d9a9bbcc0be498a 100644 --- a/net/minecraft/world/level/entity/EntityTickList.java +++ b/net/minecraft/world/level/entity/EntityTickList.java -@@ -9,52 +9,38 @@ import javax.annotation.Nullable; - import net.minecraft.world.entity.Entity; +@@ -9,51 +9,38 @@ import net.minecraft.world.entity.Entity; + import org.jspecify.annotations.Nullable; public class EntityTickList { - private Int2ObjectMap active = new Int2ObjectLinkedOpenHashMap<>(); - private Int2ObjectMap passive = new Int2ObjectLinkedOpenHashMap<>(); -- @Nullable -- private Int2ObjectMap iterated; +- private @Nullable Int2ObjectMap iterated; + private final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet entities = new ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<>(); // Paper - rewrite chunk system private void ensureActiveIsNotIterated() { @@ -33823,10 +33791,10 @@ index 342c83309b19c64d86e0dd97c1756c96be52772b..423779a2b690f387a4f0bd07b97b50e0 } } diff --git a/net/minecraft/world/level/gameevent/DynamicGameEventListener.java b/net/minecraft/world/level/gameevent/DynamicGameEventListener.java -index 2b98932e69271571e6e9350c55c82edc858d76f6..c8980c50713e1526c526ed181fb2ad9486bab353 100644 +index b25fdc2562d6710da698b5d2532304e8e47bd535..cf1f2ed003a94156cf688071aeea53c7ad22b700 100644 --- a/net/minecraft/world/level/gameevent/DynamicGameEventListener.java +++ b/net/minecraft/world/level/gameevent/DynamicGameEventListener.java -@@ -27,6 +27,14 @@ public class DynamicGameEventListener { +@@ -26,6 +26,14 @@ public class DynamicGameEventListener { public void remove(ServerLevel level) { ifChunkExists(level, this.lastSection, listenerRegistry -> listenerRegistry.unregister(this.listener)); @@ -33842,10 +33810,10 @@ index 2b98932e69271571e6e9350c55c82edc858d76f6..c8980c50713e1526c526ed181fb2ad94 public void move(ServerLevel level) { diff --git a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -index 613c7d730ba0ffd61b0525c2a772b837f7a39e3d..576749f5088e6ec49a79b440aa109822e0be33c8 100644 +index b619bfcdc53fb1fc325dc1093695c13ea3bab1ae..d1068a122e5dbd5af274d0f8178ca9f5fa49f930 100644 --- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -@@ -83,7 +83,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { +@@ -85,7 +85,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { return CompletableFuture.supplyAsync(() -> { this.doCreateBiomes(blender, randomState, structureManager, chunk); return chunk; @@ -33854,7 +33822,7 @@ index 613c7d730ba0ffd61b0525c2a772b837f7a39e3d..576749f5088e6ec49a79b440aa109822 } private void doCreateBiomes(Blender blender, RandomState random, StructureManager structureManager, ChunkAccess chunk) { -@@ -325,7 +325,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { +@@ -327,7 +327,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { } return var20; @@ -33864,10 +33832,10 @@ index 613c7d730ba0ffd61b0525c2a772b837f7a39e3d..576749f5088e6ec49a79b440aa109822 private ChunkAccess doFill(Blender blender, StructureManager structureManager, RandomState random, ChunkAccess chunk, int minCellY, int cellCountY) { diff --git a/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -index 6a5451440751ad017324e3fec8cfd8efb118511b..48fce0845fb023d6286dac144c285b048d778564 100644 +index 97d9e4d3e47dd568f624b96ce4e27f3abcd23678..5198894e7a9b4fffa5ee9d9e4d8fad173c2294cd 100644 --- a/net/minecraft/world/level/levelgen/structure/StructureCheck.java +++ b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -@@ -48,8 +48,13 @@ public class StructureCheck { +@@ -50,8 +50,13 @@ public class StructureCheck { private final BiomeSource biomeSource; private final long seed; private final DataFixer fixerUpper; @@ -33883,7 +33851,7 @@ index 6a5451440751ad017324e3fec8cfd8efb118511b..48fce0845fb023d6286dac144c285b04 public StructureCheck( ChunkScanAccess storageAccess, -@@ -91,7 +96,7 @@ public class StructureCheck { +@@ -93,7 +98,7 @@ public class StructureCheck { public StructureCheckResult checkStart(ChunkPos chunkPos, Structure structure, StructurePlacement placement, boolean skipKnownStructures) { long packedChunkPos = chunkPos.toLong(); @@ -33892,7 +33860,7 @@ index 6a5451440751ad017324e3fec8cfd8efb118511b..48fce0845fb023d6286dac144c285b04 if (map != null) { return this.checkStructureInfo(map, structure, skipKnownStructures); } else { -@@ -101,9 +106,11 @@ public class StructureCheck { +@@ -103,9 +108,11 @@ public class StructureCheck { } else if (!placement.applyAdditionalChunkRestrictions(chunkPos.x, chunkPos.z, this.seed, this.getSaltOverride(structure))) { // Paper - add missing structure seed configs return StructureCheckResult.START_NOT_PRESENT; } else { @@ -33907,7 +33875,7 @@ index 6a5451440751ad017324e3fec8cfd8efb118511b..48fce0845fb023d6286dac144c285b04 return !flag ? StructureCheckResult.START_NOT_PRESENT : StructureCheckResult.CHUNK_LOAD_NEEDED; } } -@@ -222,15 +229,25 @@ public class StructureCheck { +@@ -224,15 +231,25 @@ public class StructureCheck { } private void storeFullResults(long chunkPos, Object2IntMap structureChunks) { @@ -33938,22 +33906,20 @@ index 6a5451440751ad017324e3fec8cfd8efb118511b..48fce0845fb023d6286dac144c285b04 map.computeInt(structure, (structure1, integer) -> integer == null ? 1 : integer + 1); return map; diff --git a/net/minecraft/world/level/lighting/LevelLightEngine.java b/net/minecraft/world/level/lighting/LevelLightEngine.java -index e67d7915748e55e1f7244902e9f8f73666dcb67b..d1ebecde6d3fe741f819ae0eb1df63426aa0c146 100644 +index dbf0a3a30070ad5c8d4084cd4fcd9941b50e98f8..51c9462d091a42192989dee08738caa25e88b1a2 100644 --- a/net/minecraft/world/level/lighting/LevelLightEngine.java +++ b/net/minecraft/world/level/lighting/LevelLightEngine.java -@@ -9,151 +9,111 @@ import net.minecraft.world.level.LightLayer; - import net.minecraft.world.level.chunk.DataLayer; +@@ -9,149 +9,111 @@ import net.minecraft.world.level.chunk.DataLayer; import net.minecraft.world.level.chunk.LightChunkGetter; + import org.jspecify.annotations.Nullable; -public class LevelLightEngine implements LightEventListener { +public class LevelLightEngine implements LightEventListener, ca.spottedleaf.moonrise.patches.starlight.light.StarLightLightingProvider { // Paper - rewrite chunk system public static final int LIGHT_SECTION_PADDING = 1; public static final LevelLightEngine EMPTY = new LevelLightEngine(); protected final LevelHeightAccessor levelHeightAccessor; -- @Nullable -- private final LightEngine blockEngine; -- @Nullable -- private final LightEngine skyEngine; +- private final @Nullable LightEngine blockEngine; +- private final @Nullable LightEngine skyEngine; + // Paper start - rewrite chunk system + protected final ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface lightEngine; + @@ -34312,12 +34278,12 @@ index 41bea92e2ce834ddb2e5d62d0a0008ef662b77b4..85e9ec8061fc01d39977f6db314da14b protected abstract boolean canConvertToSource(ServerLevel level); diff --git a/net/minecraft/world/level/material/FluidState.java b/net/minecraft/world/level/material/FluidState.java -index 9dda7d19f3f6ca9b402ebe0e4b042ff859b5dcbd..0a5ae623a636923f3bbd3c01974497f39b7c4b62 100644 +index c460de79f14cab6c7de4ba28e359762382d7c972..3e5ada4a84bc1da06102dfacb0d3d45a4fc6db8a 100644 --- a/net/minecraft/world/level/material/FluidState.java +++ b/net/minecraft/world/level/material/FluidState.java -@@ -25,12 +25,30 @@ import net.minecraft.world.phys.AABB; - import net.minecraft.world.phys.Vec3; +@@ -25,12 +25,30 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; -public final class FluidState extends StateHolder { +public final class FluidState extends StateHolder implements ca.spottedleaf.moonrise.patches.fluid.FluidFluidState { // Paper - fluid method optimisations @@ -34397,22 +34363,26 @@ index 9dda7d19f3f6ca9b402ebe0e4b042ff859b5dcbd..0a5ae623a636923f3bbd3c01974497f3 + // Paper end - fluid method optimisations } - @Nullable + public @Nullable ParticleOptions getDripParticle() { diff --git a/net/minecraft/world/phys/AABB.java b/net/minecraft/world/phys/AABB.java -index d410f88d6810046d8fca92afe198f04fdf0a9aca..cffb3b7d480f72cdb9ed535f362fa60f30597523 100644 +index 26f807a2fadabfdd7a7144e1c1146e7a2577190a..e6ba6447616ee70b4dd5baa467650da450450f1e 100644 --- a/net/minecraft/world/phys/AABB.java +++ b/net/minecraft/world/phys/AABB.java -@@ -319,7 +319,7 @@ public class AABB { +@@ -317,9 +317,10 @@ public class AABB { + } } - @Nullable -- private static Direction getDirection(AABB aabb, Vec3 start, double[] minDistance, @Nullable Direction facing, double deltaX, double deltaY, double deltaZ) { -+ public static Direction getDirection(AABB aabb, Vec3 start, double[] minDistance, @Nullable Direction facing, double deltaX, double deltaY, double deltaZ) { // Paper - optimise collisions - public +- private static @Nullable Direction getDirection( ++ ++ public static @Nullable Direction getDirection( + AABB aabb, Vec3 start, double[] minDistance, @Nullable Direction facing, double deltaX, double deltaY, double deltaZ +- ) { ++ ) { // Paper - optimise collisions - public return getDirection(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ, start, minDistance, facing, deltaX, deltaY, deltaZ); } diff --git a/net/minecraft/world/phys/shapes/ArrayVoxelShape.java b/net/minecraft/world/phys/shapes/ArrayVoxelShape.java -index 4f79538b8127207eae988dfb137d643b7969aafc..31664aeaffd0d891d954a7058e9a49985e23ba02 100644 +index 91a8124a302594eedad0833a50eeb95d291b3674..3506d7db68d4428497126d5ebd29106d5816bcfe 100644 --- a/net/minecraft/world/phys/shapes/ArrayVoxelShape.java +++ b/net/minecraft/world/phys/shapes/ArrayVoxelShape.java @@ -20,7 +20,7 @@ public class ArrayVoxelShape extends VoxelShape { @@ -34607,12 +34577,12 @@ index f6b6481591e009de80f6b6318d35f193aabb7df3..e9b5069dcd572966b2f5aa220cef30e7 @Override diff --git a/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java b/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java -index 8f4c93832c26322c0051043cbd405729075d6e3a..f4efe69ed6c85ea499eefd0bae863ba70ed2d722 100644 +index aad858a5a1bf50b1e3121cfd5bfb9660dca7b8e7..c60fbd10cae82f75566ffc2c9cc1abd94a6086f4 100644 --- a/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java +++ b/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java -@@ -4,12 +4,79 @@ import com.mojang.math.OctahedralGroup; - import net.minecraft.core.AxisCycle; +@@ -5,12 +5,79 @@ import net.minecraft.core.AxisCycle; import net.minecraft.core.Direction; + import org.joml.Vector3i; -public abstract class DiscreteVoxelShape { +public abstract class DiscreteVoxelShape implements ca.spottedleaf.moonrise.patches.collisions.shape.CollisionDiscreteVoxelShape { // Paper - optimise collisions @@ -34707,10 +34677,10 @@ index ac1488875537421b74f0c491c9b7a40e75539c92..9eb27eb8d6dcaad6ce02f8ce4546acc2 public OffsetDoubleList(DoubleList delegate, double offset) { this.delegate = delegate; diff --git a/net/minecraft/world/phys/shapes/Shapes.java b/net/minecraft/world/phys/shapes/Shapes.java -index 2d3a58a256689132747013acd57251c85e3477d5..608dcf0e486c1cf2303e2039221e414ce6f069d0 100644 +index b17ffae691eaaedf6b1371adae02adf92147056e..ac4bb789df88c07ea38d20700dccb6571e3ea58d 100644 --- a/net/minecraft/world/phys/shapes/Shapes.java +++ b/net/minecraft/world/phys/shapes/Shapes.java -@@ -22,9 +22,15 @@ public final class Shapes { +@@ -21,9 +21,15 @@ public final class Shapes { public static final double EPSILON = 1.0E-7; public static final double BIG_EPSILON = 1.0E-6; private static final VoxelShape BLOCK = Util.make(() -> { @@ -34729,7 +34699,7 @@ index 2d3a58a256689132747013acd57251c85e3477d5..608dcf0e486c1cf2303e2039221e414c }); private static final Vec3 BLOCK_CENTER = new Vec3(0.5, 0.5, 0.5); public static final VoxelShape INFINITY = box( -@@ -50,6 +56,30 @@ public final class Shapes { +@@ -49,6 +55,30 @@ public final class Shapes { return BLOCK; } @@ -34760,7 +34730,7 @@ index 2d3a58a256689132747013acd57251c85e3477d5..608dcf0e486c1cf2303e2039221e414c public static VoxelShape box(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { if (!(minX > maxX) && !(minY > maxY) && !(minZ > maxZ)) { return create(minX, minY, minZ, maxX, maxY, maxZ); -@@ -59,39 +89,42 @@ public final class Shapes { +@@ -58,39 +88,42 @@ public final class Shapes { } public static VoxelShape create(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { @@ -34829,7 +34799,7 @@ index 2d3a58a256689132747013acd57251c85e3477d5..608dcf0e486c1cf2303e2039221e414c } public static VoxelShape create(AABB aabb) { -@@ -127,85 +160,52 @@ public final class Shapes { +@@ -126,85 +159,52 @@ public final class Shapes { } public static VoxelShape or(VoxelShape shape1, VoxelShape... others) { @@ -34952,7 +34922,7 @@ index 2d3a58a256689132747013acd57251c85e3477d5..608dcf0e486c1cf2303e2039221e414c } private static boolean joinIsNotEmpty( -@@ -237,52 +237,113 @@ public final class Shapes { +@@ -236,52 +236,113 @@ public final class Shapes { return desiredOffset; } @@ -35091,11 +35061,11 @@ index 2d3a58a256689132747013acd57251c85e3477d5..608dcf0e486c1cf2303e2039221e414c + return ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)shape1).moonrise$occludesFullBlock(); + } -- public static boolean faceShapeOccludes(VoxelShape voxelShape1, VoxelShape voxelShape2) { -- return voxelShape1 == block() -- || voxelShape2 == block() -- || (!voxelShape1.isEmpty() || !voxelShape2.isEmpty()) -- && !joinIsNotEmpty(block(), joinUnoptimized(voxelShape1, voxelShape2, BooleanOp.OR), BooleanOp.ONLY_FIRST); +- public static boolean faceShapeOccludes(VoxelShape shape, VoxelShape adjacentShape) { +- return shape == block() +- || adjacentShape == block() +- || (!shape.isEmpty() || !adjacentShape.isEmpty()) +- && !joinIsNotEmpty(block(), joinUnoptimized(shape, adjacentShape, BooleanOp.OR), BooleanOp.ONLY_FIRST); + return mergedMayOccludeBlock(shape1, shape2) && ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)shape1).moonrise$orUnoptimized(shape2)).moonrise$occludesFullBlock(); + // Paper end - optimise collisions } @@ -35114,19 +35084,18 @@ index 79f7f04207891dd98cc0b2d93ecb2e07c8baa7b6..7ca12213c10f962ff597a8d51413a17b private static DiscreteVoxelShape makeSlice(DiscreteVoxelShape shape, Direction.Axis axis, int index) { diff --git a/net/minecraft/world/phys/shapes/VoxelShape.java b/net/minecraft/world/phys/shapes/VoxelShape.java -index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70f6b9dd73 100644 +index 72727d38d1de7ae82b0fc755aacbc600cb811078..59ca209aa0c545c4288c89ea5ff18842cf10fceb 100644 --- a/net/minecraft/world/phys/shapes/VoxelShape.java +++ b/net/minecraft/world/phys/shapes/VoxelShape.java -@@ -16,61 +16,546 @@ import net.minecraft.world.phys.AABB; - import net.minecraft.world.phys.BlockHitResult; - import net.minecraft.world.phys.Vec3; +@@ -18,60 +18,545 @@ import net.minecraft.world.phys.Vec3; + import org.apache.commons.lang3.mutable.MutableObject; + import org.jspecify.annotations.Nullable; -public abstract class VoxelShape { - protected final DiscreteVoxelShape shape; +public abstract class VoxelShape implements ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape { // Paper - optimise collisions + public final DiscreteVoxelShape shape; // Paper - optimise collisions - public - @Nullable - private VoxelShape[] faces; + private @Nullable VoxelShape @Nullable [] faces; + // Paper start - optimise collisions + private double offsetX; @@ -35693,7 +35662,7 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 } public VoxelShape move(Vec3 offset) { -@@ -82,20 +567,96 @@ public abstract class VoxelShape { +@@ -83,20 +568,96 @@ public abstract class VoxelShape { } public VoxelShape move(double xOffset, double yOffset, double zOffset) { @@ -35801,7 +35770,7 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 } public void forAllEdges(Shapes.DoubleLineConsumer action) { -@@ -127,9 +688,24 @@ public abstract class VoxelShape { +@@ -128,9 +689,24 @@ public abstract class VoxelShape { } public List toAabbs() { @@ -35829,7 +35798,7 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 } public double min(Direction.Axis axis, double primaryPosition, double secondaryPosition) { -@@ -151,46 +727,92 @@ public abstract class VoxelShape { +@@ -152,46 +728,91 @@ public abstract class VoxelShape { } protected int findIndex(Direction.Axis axis, double position) { @@ -35862,8 +35831,7 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 + // Paper end - optimise collisions } - @Nullable - public BlockHitResult clip(Vec3 startVec, Vec3 endVec, BlockPos pos) { + public @Nullable BlockHitResult clip(Vec3 startVec, Vec3 endVec, BlockPos pos) { - if (this.isEmpty()) { + // Paper start - optimise collisions + if (this.isEmpty) { @@ -35916,16 +35884,17 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 + if (this.isEmpty) { return Optional.empty(); - } else { -- Vec3[] vec3s = new Vec3[1]; +- MutableObject mutableObject = new MutableObject<>(); - this.forAllBoxes((x1, y1, z1, x2, y2, z2) -> { - double d = Mth.clamp(point.x(), x1, x2); - double d1 = Mth.clamp(point.y(), y1, y2); - double d2 = Mth.clamp(point.z(), z1, z2); -- if (vec3s[0] == null || point.distanceToSqr(d, d1, d2) < point.distanceToSqr(vec3s[0])) { -- vec3s[0] = new Vec3(d, d1, d2); +- Vec3 vec3 = mutableObject.get(); +- if (vec3 == null || point.distanceToSqr(d, d1, d2) < point.distanceToSqr(vec3)) { +- mutableObject.setValue(new Vec3(d, d1, d2)); - } - }); -- return Optional.of(vec3s[0]); +- return Optional.of(Objects.requireNonNull(mutableObject.get())); } + + Vec3 ret = null; @@ -35950,7 +35919,7 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 } public VoxelShape getFaceShape(Direction side) { -@@ -213,19 +835,23 @@ public abstract class VoxelShape { +@@ -214,19 +835,23 @@ public abstract class VoxelShape { } private VoxelShape calculateFace(Direction side) { @@ -35985,7 +35954,7 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 } protected boolean isCubeLike() { -@@ -243,9 +869,30 @@ public abstract class VoxelShape { +@@ -244,9 +869,30 @@ public abstract class VoxelShape { return coords.size() == 2 && DoubleMath.fuzzyEquals(coords.getDouble(0), 0.0, 1.0E-7) && DoubleMath.fuzzyEquals(coords.getDouble(1), 1.0, 1.0E-7); } @@ -36019,21 +35988,19 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 protected double collideX(AxisCycle movementAxis, AABB collisionBox, double desiredOffset) { if (this.isEmpty()) { diff --git a/net/minecraft/world/ticks/LevelChunkTicks.java b/net/minecraft/world/ticks/LevelChunkTicks.java -index 9334c5dcc4fa71cac38eed9ed18b50def313bcb4..2e28cc201e4557ff603aba7a6ed997b8d36fbb4a 100644 +index 5fa7b312bf3bdd1ea0900dc7c599f88542115329..0b13971259f58876b778c0d28ad20c3510ed46ad 100644 --- a/net/minecraft/world/ticks/LevelChunkTicks.java +++ b/net/minecraft/world/ticks/LevelChunkTicks.java -@@ -13,7 +13,7 @@ import java.util.stream.Stream; - import javax.annotation.Nullable; +@@ -13,12 +13,36 @@ import java.util.stream.Stream; import net.minecraft.core.BlockPos; + import org.jspecify.annotations.Nullable; -public class LevelChunkTicks implements SerializableTickContainer, TickContainerAccess { +public class LevelChunkTicks implements SerializableTickContainer, TickContainerAccess, ca.spottedleaf.moonrise.patches.chunk_system.ticks.ChunkSystemLevelChunkTicks { // Paper - rewrite chunk system private final Queue> tickQueue = new PriorityQueue<>(ScheduledTick.DRAIN_ORDER); - @Nullable - private List> pendingTicks; -@@ -21,6 +21,30 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon - @Nullable - private BiConsumer, ScheduledTick> onTickAdded; + private @Nullable List> pendingTicks; + private final Set> ticksPerPosition = new ObjectOpenCustomHashSet<>(ScheduledTick.UNIQUE_TICK_HASH); + private @Nullable BiConsumer, ScheduledTick> onTickAdded; + // Paper start - rewrite chunk system + /* @@ -36062,8 +36029,8 @@ index 9334c5dcc4fa71cac38eed9ed18b50def313bcb4..2e28cc201e4557ff603aba7a6ed997b8 public LevelChunkTicks() { } -@@ -45,7 +69,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon - public ScheduledTick poll() { +@@ -41,7 +65,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon + public @Nullable ScheduledTick poll() { ScheduledTick scheduledTick = this.tickQueue.poll(); if (scheduledTick != null) { - this.ticksPerPosition.remove(scheduledTick); @@ -36071,7 +36038,7 @@ index 9334c5dcc4fa71cac38eed9ed18b50def313bcb4..2e28cc201e4557ff603aba7a6ed997b8 } return scheduledTick; -@@ -54,7 +78,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon +@@ -50,7 +74,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon @Override public void schedule(ScheduledTick tick) { if (this.ticksPerPosition.add(tick)) { @@ -36080,7 +36047,7 @@ index 9334c5dcc4fa71cac38eed9ed18b50def313bcb4..2e28cc201e4557ff603aba7a6ed997b8 } } -@@ -76,7 +100,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon +@@ -72,7 +96,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon while (iterator.hasNext()) { ScheduledTick scheduledTick = iterator.next(); if (predicate.test(scheduledTick)) { @@ -36089,7 +36056,7 @@ index 9334c5dcc4fa71cac38eed9ed18b50def313bcb4..2e28cc201e4557ff603aba7a6ed997b8 this.ticksPerPosition.remove(scheduledTick); } } -@@ -93,6 +117,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon +@@ -89,6 +113,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon @Override public List> pack(long gameTime) { @@ -36097,7 +36064,7 @@ index 9334c5dcc4fa71cac38eed9ed18b50def313bcb4..2e28cc201e4557ff603aba7a6ed997b8 List> list = new ArrayList<>(this.tickQueue.size()); if (this.pendingTicks != null) { list.addAll(this.pendingTicks); -@@ -107,6 +132,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon +@@ -103,6 +128,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon public void unpack(long gameTime) { if (this.pendingTicks != null) { From c507d55f99dd37872949ace71e8d3ec2d3aa3d29 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 25 Nov 2025 20:45:54 -0700 Subject: [PATCH 107/112] Update feature patches 3-13 --- ...Manager-and-add-advanced-packet-sup.patch} | 37 +++-- ...03-Allow-Saving-of-Oversized-Chunks.patch} | 14 +- .../0004-Entity-Activation-Range-2.0.patch} | 132 +++++++++--------- ...city-compression-and-cipher-natives.patch} | 17 +-- ...alSelector-Goal.Flag-Set-operations.patch} | 2 +- .../0007-Optimize-Voxel-Shape-Merging.patch} | 6 +- ...-Oversized-block-entities-in-chunks.patch} | 4 +- ...09-optimize-dirt-and-snow-spreading.patch} | 0 ...Optimize-Bit-Operations-by-inlining.patch} | 10 +- .../0011-Remove-streams-from-hot-code.patch} | 0 ...er-Remove-Streams-Optimized-collect.patch} | 17 ++- 11 files changed, 119 insertions(+), 120 deletions(-) rename paper-server/patches/{features-unapplied/0003-Optimize-Network-Manager-and-add-advanced-packet-sup.patch => features/0002-Optimize-Network-Manager-and-add-advanced-packet-sup.patch} (93%) rename paper-server/patches/{features-unapplied/0004-Allow-Saving-of-Oversized-Chunks.patch => features/0003-Allow-Saving-of-Oversized-Chunks.patch} (94%) rename paper-server/patches/{features-unapplied/0005-Entity-Activation-Range-2.0.patch => features/0004-Entity-Activation-Range-2.0.patch} (90%) rename paper-server/patches/{features-unapplied/0006-Use-Velocity-compression-and-cipher-natives.patch => features/0005-Use-Velocity-compression-and-cipher-natives.patch} (96%) rename paper-server/patches/{features-unapplied/0007-Optimize-GoalSelector-Goal.Flag-Set-operations.patch => features/0006-Optimize-GoalSelector-Goal.Flag-Set-operations.patch} (98%) rename paper-server/patches/{features-unapplied/0008-Optimize-Voxel-Shape-Merging.patch => features/0007-Optimize-Voxel-Shape-Merging.patch} (96%) rename paper-server/patches/{features-unapplied/0009-Handle-Oversized-block-entities-in-chunks.patch => features/0008-Handle-Oversized-block-entities-in-chunks.patch} (94%) rename paper-server/patches/{features-unapplied/0010-optimize-dirt-and-snow-spreading.patch => features/0009-optimize-dirt-and-snow-spreading.patch} (100%) rename paper-server/patches/{features-unapplied/0011-Optimize-Bit-Operations-by-inlining.patch => features/0010-Optimize-Bit-Operations-by-inlining.patch} (96%) rename paper-server/patches/{features-unapplied/0012-Remove-streams-from-hot-code.patch => features/0011-Remove-streams-from-hot-code.patch} (100%) rename paper-server/patches/{features-unapplied/0013-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch => features/0012-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch} (91%) diff --git a/paper-server/patches/features-unapplied/0003-Optimize-Network-Manager-and-add-advanced-packet-sup.patch b/paper-server/patches/features/0002-Optimize-Network-Manager-and-add-advanced-packet-sup.patch similarity index 93% rename from paper-server/patches/features-unapplied/0003-Optimize-Network-Manager-and-add-advanced-packet-sup.patch rename to paper-server/patches/features/0002-Optimize-Network-Manager-and-add-advanced-packet-sup.patch index 5bf1a407b9e2..bd8a743b0fdf 100644 --- a/paper-server/patches/features-unapplied/0003-Optimize-Network-Manager-and-add-advanced-packet-sup.patch +++ b/paper-server/patches/features/0002-Optimize-Network-Manager-and-add-advanced-packet-sup.patch @@ -28,10 +28,10 @@ and then catch exceptions and close if they fire. Part of this commit was authored by: Spottedleaf, sandtechnology diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java -index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d8a2d2e16 100644 +index 68b081ef1b0bf9a58564d900569bc7a5dfef2a32..8817a2d6500d1bdce96d87dc8f7f364ccfa390e5 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -84,7 +84,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -65,7 +65,7 @@ public class Connection extends SimpleChannelInboundHandler> { private static final ProtocolInfo INITIAL_PROTOCOL = HandshakeProtocols.SERVERBOUND; private final PacketFlow receiving; private volatile boolean sendLoginDisconnect = true; @@ -40,10 +40,10 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d public Channel channel; public SocketAddress address; // Spigot start -@@ -147,6 +147,10 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -123,6 +123,10 @@ public class Connection extends SimpleChannelInboundHandler> { public boolean handledLegacyLoginEvent; // Paper - playerloginevent - public @Nullable net.minecraft.server.level.ServerPlayer savedPlayerForLegacyEvents; // Paper - playerloginevent & PlayerSpawnLocationEvent - public @Nullable org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus; // Paper + public net.minecraft.server.level.@Nullable ServerPlayer savedPlayerForLegacyEvents; // Paper - playerloginevent & PlayerSpawnLocationEvent + public org.bukkit.event.player.PlayerResourcePackStatusEvent.@Nullable Status resourcePackStatus; // Paper + // Paper start - Optimize network + public boolean isPending = true; + public boolean queueImmunity; @@ -51,7 +51,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d public Connection(PacketFlow receiving) { this.receiving = receiving; -@@ -419,11 +423,38 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -395,11 +399,38 @@ public class Connection extends SimpleChannelInboundHandler> { } public void send(Packet packet, @Nullable ChannelFutureListener sendListener, boolean flush) { @@ -93,7 +93,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d } } -@@ -432,7 +463,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -408,7 +439,7 @@ public class Connection extends SimpleChannelInboundHandler> { this.flushQueue(); action.accept(this); } else { @@ -102,7 +102,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d } } -@@ -446,21 +477,41 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -422,21 +453,41 @@ public class Connection extends SimpleChannelInboundHandler> { } private void doSendPacket(Packet packet, @Nullable ChannelFutureListener sendListener, boolean flush) { @@ -148,7 +148,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d } } -@@ -472,16 +523,57 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -448,16 +499,57 @@ public class Connection extends SimpleChannelInboundHandler> { } } @@ -211,7 +211,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d private static final int MAX_PER_TICK = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick; // Paper - Buffer joins to world private static int joinAttemptsThisTick; // Paper - Buffer joins to world -@@ -551,6 +643,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -527,6 +619,7 @@ public class Connection extends SimpleChannelInboundHandler> { public void disconnect(DisconnectionDetails disconnectionDetails) { this.preparing = false; // Spigot @@ -219,7 +219,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d if (this.channel == null) { this.delayedDisconnect = disconnectionDetails; } -@@ -739,7 +832,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -703,7 +796,7 @@ public class Connection extends SimpleChannelInboundHandler> { public void handleDisconnection() { if (this.channel != null && !this.channel.isOpen()) { if (this.disconnectionHandled) { @@ -228,7 +228,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d } else { this.disconnectionHandled = true; PacketListener packetListener = this.getPacketListener(); -@@ -750,7 +843,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -714,7 +807,7 @@ public class Connection extends SimpleChannelInboundHandler> { ); packetListener1.onDisconnect(disconnectionDetails); } @@ -237,7 +237,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d // Paper start - Add PlayerConnectionCloseEvent if (packetListener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl commonPacketListener) { /* Player was logged in, either game listener or configuration listener */ -@@ -785,4 +878,97 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -749,4 +842,96 @@ public class Connection extends SimpleChannelInboundHandler> { public void setBandwidthLogger(LocalSampleLogger bandwidthLogger) { this.bandwidthDebugMonitor = new BandwidthDebugMonitor(bandwidthLogger); } @@ -256,10 +256,9 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d + this.pendingActions.clear(); + } + -+ private static class InnerUtil { // Attempt to hide these methods from ProtocolLib, so it doesn't accidently pick them up. ++ private static final class InnerUtil { // Attempt to hide these methods from ProtocolLib, so it doesn't accidently pick them up. + -+ @Nullable -+ private static java.util.List> buildExtraPackets(final Packet packet) { ++ private static java.util.@Nullable List> buildExtraPackets(final Packet packet) { + final java.util.List> extra = packet.getExtraPackets(); + if (extra == null || extra.isEmpty()) { + return null; @@ -373,10 +372,10 @@ index 65ff8b9112ec76eeac48c679044fc02ae7d4ffeb..062fd531edf6dfebb42dbaeee7bbda52 + // Paper end } diff --git a/net/minecraft/server/network/ServerConnectionListener.java b/net/minecraft/server/network/ServerConnectionListener.java -index 16719b3eaec6fc261d227f47e82afc0506a6524d..deefad689070750a3ae033a3e54dd8f5c849e794 100644 +index c080b4eccb94551eefd7016200431e37221232b5..309845b28306dfa5946e79b80e5b1dde82dd68cd 100644 --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -67,11 +67,13 @@ public class ServerConnectionListener { +@@ -50,11 +50,13 @@ public class ServerConnectionListener { // Paper start - prevent blocking on adding a new connection while the server is ticking private final java.util.Queue pending = new java.util.concurrent.ConcurrentLinkedQueue<>(); @@ -390,7 +389,7 @@ index 16719b3eaec6fc261d227f47e82afc0506a6524d..deefad689070750a3ae033a3e54dd8f5 } } // Paper end - prevent blocking on adding a new connection while the server is ticking -@@ -121,6 +123,7 @@ public class ServerConnectionListener { +@@ -86,6 +88,7 @@ public class ServerConnectionListener { } catch (ChannelException var5) { } diff --git a/paper-server/patches/features-unapplied/0004-Allow-Saving-of-Oversized-Chunks.patch b/paper-server/patches/features/0003-Allow-Saving-of-Oversized-Chunks.patch similarity index 94% rename from paper-server/patches/features-unapplied/0004-Allow-Saving-of-Oversized-Chunks.patch rename to paper-server/patches/features/0003-Allow-Saving-of-Oversized-Chunks.patch index 9b30daaf094d..7cf5f74712b2 100644 --- a/paper-server/patches/features-unapplied/0004-Allow-Saving-of-Oversized-Chunks.patch +++ b/paper-server/patches/features/0003-Allow-Saving-of-Oversized-Chunks.patch @@ -31,7 +31,7 @@ this fix, as the data will remain in the oversized file. Once the server returns to a jar with this fix, the data will be restored. diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java -index 07c2e2170af5820acdcb64f2c7978845c31641a1..984db72272d552c7210bd6f437ea88694ddd2828 100644 +index 99bbae1f8f681950f410b2bfe9af037164d8dcb7..944a01c34d19225d8366f6f97cbc3cacbb5d5498 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -68,6 +68,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche @@ -42,7 +42,7 @@ index 07c2e2170af5820acdcb64f2c7978845c31641a1..984db72272d552c7210bd6f437ea8869 if (!Files.isDirectory(externalFileDir)) { throw new IllegalArgumentException("Expected directory, got " + externalFileDir.toAbsolutePath()); } else { -@@ -467,4 +468,75 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche +@@ -464,4 +465,75 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche interface CommitOp { void run() throws IOException; } @@ -119,7 +119,7 @@ index 07c2e2170af5820acdcb64f2c7978845c31641a1..984db72272d552c7210bd6f437ea8869 + // Paper end } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 263ab4a8056ed9115c293484fef13e6f485dcf6d..283f73e633e32585530458545bf54fc6a644c830 100644 +index 5d9168242f7a7ca4dd888f32fecb27457fd89456..98b3f20c720d70293c6fcf77fdc081b44c71dd6b 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -237,6 +237,43 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise @@ -163,10 +163,10 @@ index 263ab4a8056ed9115c293484fef13e6f485dcf6d..283f73e633e32585530458545bf54fc6 + } + // Paper end + - @Nullable - public CompoundTag read(ChunkPos chunkPos) throws IOException { + public @Nullable CompoundTag read(ChunkPos chunkPos) throws IOException { // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing -@@ -245,6 +282,12 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise + RegionFile regionFile = this.getRegionFile(chunkPos, true); +@@ -244,6 +281,12 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise return null; } // CraftBukkit end @@ -179,7 +179,7 @@ index 263ab4a8056ed9115c293484fef13e6f485dcf6d..283f73e633e32585530458545bf54fc6 CompoundTag var4; try (DataInputStream chunkDataInputStream = regionFile.getChunkDataInputStream(chunkPos)) { -@@ -287,6 +330,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -286,6 +329,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise } else { try (DataOutputStream chunkDataOutputStream = regionFile.getChunkDataOutputStream(chunkPos)) { NbtIo.write(chunkData, chunkDataOutputStream); diff --git a/paper-server/patches/features-unapplied/0005-Entity-Activation-Range-2.0.patch b/paper-server/patches/features/0004-Entity-Activation-Range-2.0.patch similarity index 90% rename from paper-server/patches/features-unapplied/0005-Entity-Activation-Range-2.0.patch rename to paper-server/patches/features/0004-Entity-Activation-Range-2.0.patch index 8d64e6029c0c..6b47b9641cc2 100644 --- a/paper-server/patches/features-unapplied/0005-Entity-Activation-Range-2.0.patch +++ b/paper-server/patches/features/0004-Entity-Activation-Range-2.0.patch @@ -15,7 +15,7 @@ Adds villagers as separate config diff --git a/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java new file mode 100644 -index 0000000000000000000000000000000000000000..ae2bb9a73106febfe5f0d090abd4252bbb5fd27e +index 0000000000000000000000000000000000000000..c18823746ab2edcab536cb1589b7720e3af07e0f --- /dev/null +++ b/io/papermc/paper/entity/activation/ActivationRange.java @@ -0,0 +1,334 @@ @@ -32,29 +32,29 @@ index 0000000000000000000000000000000000000000..ae2bb9a73106febfe5f0d090abd4252b +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.ai.Brain; +import net.minecraft.world.entity.animal.Animal; -+import net.minecraft.world.entity.animal.Bee; ++import net.minecraft.world.entity.animal.bee.Bee; ++import net.minecraft.world.entity.animal.equine.Llama; +import net.minecraft.world.entity.animal.sheep.Sheep; -+import net.minecraft.world.entity.animal.horse.Llama; -+import net.minecraft.world.entity.boss.EnderDragonPart; +import net.minecraft.world.entity.boss.enderdragon.EndCrystal; +import net.minecraft.world.entity.boss.enderdragon.EnderDragon; ++import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; +import net.minecraft.world.entity.boss.wither.WitherBoss; +import net.minecraft.world.entity.item.FallingBlockEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.item.PrimedTnt; +import net.minecraft.world.entity.monster.Creeper; -+import net.minecraft.world.entity.monster.Pillager; -+import net.minecraft.world.entity.npc.Villager; ++import net.minecraft.world.entity.monster.illager.Pillager; ++import net.minecraft.world.entity.npc.villager.Villager; +import net.minecraft.world.entity.player.Player; -+import net.minecraft.world.entity.projectile.AbstractArrow; -+import net.minecraft.world.entity.projectile.AbstractHurtingProjectile; +import net.minecraft.world.entity.projectile.EyeOfEnder; +import net.minecraft.world.entity.projectile.FireworkRocketEntity; +import net.minecraft.world.entity.projectile.ThrowableProjectile; -+import net.minecraft.world.entity.projectile.ThrownTrident; ++import net.minecraft.world.entity.projectile.arrow.AbstractArrow; ++import net.minecraft.world.entity.projectile.arrow.ThrownTrident; ++import net.minecraft.world.entity.projectile.hurtingprojectile.AbstractHurtingProjectile; +import net.minecraft.world.entity.schedule.Activity; -+import net.minecraft.world.entity.vehicle.AbstractBoat; -+import net.minecraft.world.entity.vehicle.AbstractMinecart; ++import net.minecraft.world.entity.vehicle.boat.AbstractBoat; ++import net.minecraft.world.entity.vehicle.minecart.AbstractMinecart; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.AABB; +import org.spigotmc.SpigotWorldConfig; @@ -354,10 +354,10 @@ index 0000000000000000000000000000000000000000..ae2bb9a73106febfe5f0d090abd4252b + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 5e305c9a64e856de70ed787901c01d09e68aa979..ce6f83c83b0235d59b4cadd248ff218985978ab5 100644 +index 5494b92ab1c3c202a640e483e8a4bcb64395ed99..d7238270a6df8d1182874b46b588b971ca6f7a0e 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -815,6 +815,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -830,6 +830,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe profilerFiller.pop(); } @@ -365,7 +365,7 @@ index 5e305c9a64e856de70ed787901c01d09e68aa979..ce6f83c83b0235d59b4cadd248ff2189 this.entityTickList .forEach( entity -> { -@@ -1309,12 +1310,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1347,12 +1348,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe entity.totalEntityAge++; // Paper - age-like counter for all entities profilerFiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString()); profilerFiller.incrementCounter("tickNonPassenger"); @@ -382,7 +382,7 @@ index 5e305c9a64e856de70ed787901c01d09e68aa979..ce6f83c83b0235d59b4cadd248ff2189 } // Paper start - log detailed entity tick information } finally { -@@ -1325,7 +1329,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1363,7 +1367,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper end - log detailed entity tick information } @@ -391,7 +391,7 @@ index 5e305c9a64e856de70ed787901c01d09e68aa979..ce6f83c83b0235d59b4cadd248ff2189 if (passengerEntity.isRemoved() || passengerEntity.getVehicle() != ridingEntity) { passengerEntity.stopRiding(); } else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) { -@@ -1335,12 +1339,21 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1373,12 +1377,21 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(passengerEntity.getType()).toString()); profilerFiller.incrementCounter("tickPassenger"); @@ -415,10 +415,10 @@ index 5e305c9a64e856de70ed787901c01d09e68aa979..ce6f83c83b0235d59b4cadd248ff2189 } } diff --git a/net/minecraft/world/entity/AgeableMob.java b/net/minecraft/world/entity/AgeableMob.java -index 1d4a0319c92478185d0bc1aaa56c40e7f837cd1a..0adfd1cd5c21f8a7823cd1bf7c9aa91dd2654150 100644 +index 1cd4f112cf97bce414a73fa49c210534578eeba8..ffe7b73dafa81ab96c24198d83474fd9af542476 100644 --- a/net/minecraft/world/entity/AgeableMob.java +++ b/net/minecraft/world/entity/AgeableMob.java -@@ -131,6 +131,23 @@ public abstract class AgeableMob extends PathfinderMob { +@@ -129,6 +129,23 @@ public abstract class AgeableMob extends PathfinderMob { super.onSyncedDataUpdated(key); } @@ -443,10 +443,10 @@ index 1d4a0319c92478185d0bc1aaa56c40e7f837cd1a..0adfd1cd5c21f8a7823cd1bf7c9aa91d public void aiStep() { super.aiStep(); diff --git a/net/minecraft/world/entity/AreaEffectCloud.java b/net/minecraft/world/entity/AreaEffectCloud.java -index 35e852c4bb5e632ac4e1dc8c9e89f7a366ba7c09..f500e724034b330b590825c07b7dd61571335302 100644 +index 5461bd9a39bb20ad29d3bc110c38860cf35a770a..75f80787966cdda6f51f55a8f6cb22183fbf91ea 100644 --- a/net/minecraft/world/entity/AreaEffectCloud.java +++ b/net/minecraft/world/entity/AreaEffectCloud.java -@@ -142,6 +142,16 @@ public class AreaEffectCloud extends Entity implements TraceableEntity { +@@ -140,6 +140,16 @@ public class AreaEffectCloud extends Entity implements TraceableEntity { this.duration = duration; } @@ -464,10 +464,10 @@ index 35e852c4bb5e632ac4e1dc8c9e89f7a366ba7c09..f500e724034b330b590825c07b7dd615 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index d5a38c3464539b05453ead3dfd77f4cf4b672617..7ab250350027543adc3926632b0d68a2254c6ad3 100644 +index 9cd31bf05ef7e5b14696cb33bbf995a9405481e3..e491170cd817b5f2a6951456d36b4ca1bf45c15f 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -367,6 +367,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -368,6 +368,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name private final int despawnTime; // Paper - entity despawn time limit public int totalEntityAge; // Paper - age-like counter for all entities public final io.papermc.paper.entity.activation.ActivationType activationType = io.papermc.paper.entity.activation.ActivationType.activationTypeFor(this); // Paper - EAR 2/tracking ranges @@ -483,7 +483,7 @@ index d5a38c3464539b05453ead3dfd77f4cf4b672617..7ab250350027543adc3926632b0d68a2 // CraftBukkit end // Paper start -@@ -532,6 +541,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -533,6 +542,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.position = Vec3.ZERO; this.blockPosition = BlockPos.ZERO; this.chunkPosition = ChunkPos.ZERO; @@ -497,7 +497,7 @@ index d5a38c3464539b05453ead3dfd77f4cf4b672617..7ab250350027543adc3926632b0d68a2 SynchedEntityData.Builder builder = new SynchedEntityData.Builder(this); builder.define(DATA_SHARED_FLAGS_ID, (byte)0); builder.define(DATA_AIR_SUPPLY_ID, this.getMaxAirSupply()); -@@ -1100,6 +1116,10 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -1115,6 +1131,10 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.minorHorizontalCollision = false; } else { if (type == MoverType.PISTON) { @@ -508,7 +508,7 @@ index d5a38c3464539b05453ead3dfd77f4cf4b672617..7ab250350027543adc3926632b0d68a2 movement = this.limitPistonMovement(movement); if (movement.equals(Vec3.ZERO)) { return; -@@ -1116,6 +1136,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -1131,6 +1151,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.stuckSpeedMultiplier = Vec3.ZERO; this.setDeltaMovement(Vec3.ZERO); } @@ -523,11 +523,11 @@ index d5a38c3464539b05453ead3dfd77f4cf4b672617..7ab250350027543adc3926632b0d68a2 movement = this.maybeBackOffFromEdge(movement, type); Vec3 vec3 = this.collide(movement); diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 712983c9f55f4a5c120cda8b95ec16ce815fa205..025ef0b83e5d481c8b2ef25206cafd30897caabd 100644 +index b89e05476fca18847d86d953039e66613a1a9976..0a2f85bbab4f464ee4e2357b20f93ddeaabea262 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3255,6 +3255,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - return false; +@@ -3318,6 +3318,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin + protected void playAttackSound() { } + // Paper start - EAR 2 @@ -542,7 +542,7 @@ index 712983c9f55f4a5c120cda8b95ec16ce815fa205..025ef0b83e5d481c8b2ef25206cafd30 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java -index 93f56d5d8b4af495c16bf0d953098cde574674d9..f2a321d94ddc9247a3820d42f4a04290ea3ce6f6 100644 +index 6ab728f46369d11bc97f3bc44fb1a30ea88a9854..9c754488ac24222b10b093f66e8492dfa5fe48f7 100644 --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java @@ -217,6 +217,19 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab @@ -641,10 +641,10 @@ index 3f780276be6766ef253c50212e06fd93a96b0caa..7e70c7bee633c54497d1cd2854dd60f4 } } diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java -index c02c27a8cc931b2e5fdb29b7b615e5a292d13bf2..6be576368695c902a0d6da74b1d77d3018b4585a 100644 +index 768adc0205a2ec5221045c9c2ca0fdeec9f734b6..e82bb8f2d2b0e771dc371fd7e709116e1f5f204f 100644 --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -120,6 +120,29 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -117,6 +117,29 @@ public class ItemEntity extends Entity implements TraceableEntity { return 0.04; } @@ -674,10 +674,10 @@ index c02c27a8cc931b2e5fdb29b7b615e5a292d13bf2..6be576368695c902a0d6da74b1d77d30 @Override public void tick() { if (this.getItem().isEmpty()) { -diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java -index 135d44fe54d45d3e3f4310f603d0f406f3729b6b..d10a407bef7da29a24582e48d8ee599c981384c5 100644 ---- a/net/minecraft/world/entity/npc/Villager.java -+++ b/net/minecraft/world/entity/npc/Villager.java +diff --git a/net/minecraft/world/entity/npc/villager/Villager.java b/net/minecraft/world/entity/npc/villager/Villager.java +index 10a66bb3c093a1d31f3c985b418acb9232cc882c..89844d7e804cc8a2110b694e448bc5993991bea7 100644 +--- a/net/minecraft/world/entity/npc/villager/Villager.java ++++ b/net/minecraft/world/entity/npc/villager/Villager.java @@ -269,11 +269,35 @@ public class Villager extends AbstractVillager implements ReputationEventHandler return this.assignProfessionWhenSpawned; } @@ -732,32 +732,11 @@ index 135d44fe54d45d3e3f4310f603d0f406f3729b6b..d10a407bef7da29a24582e48d8ee599c super.customServerAiStep(level); } -diff --git a/net/minecraft/world/entity/projectile/Arrow.java b/net/minecraft/world/entity/projectile/Arrow.java -index df8e4830f5be29c64ef5e6350a77ad7527e5d612..bbe2773bf789a42cc5cd9f847bdb5c4b51dfb9f2 100644 ---- a/net/minecraft/world/entity/projectile/Arrow.java -+++ b/net/minecraft/world/entity/projectile/Arrow.java -@@ -70,6 +70,16 @@ public class Arrow extends AbstractArrow { - builder.define(ID_EFFECT_COLOR, -1); - } - -+ // Paper start - EAR 2 -+ @Override -+ public void inactiveTick() { -+ if (this.isInGround()) { -+ this.life++; -+ } -+ super.inactiveTick(); -+ } -+ // Paper end -+ - @Override - public void tick() { - super.tick(); diff --git a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -index e7c1e11cc6709e34ec2c59d545cfba23c35b829d..145ed3c5f5823c7505767b6d7f4f4d16cc863948 100644 +index 3ba7d5bcaa76442adbd681a15175ba178297e704..1b633d2eb77704fd9a6358f09ed368fab2a5b212 100644 --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -108,6 +108,21 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { +@@ -107,6 +107,21 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { return super.shouldRender(x, y, z) && !this.isAttachedToEntity(); } @@ -779,11 +758,32 @@ index e7c1e11cc6709e34ec2c59d545cfba23c35b829d..145ed3c5f5823c7505767b6d7f4f4d16 @Override public void tick() { super.tick(); -diff --git a/net/minecraft/world/entity/vehicle/MinecartHopper.java b/net/minecraft/world/entity/vehicle/MinecartHopper.java -index d5cb27dd5bff34890ee431d4b301a0be0167dd37..681dab5e26f8fb359f101f22ac85aac3c30d8f7a 100644 ---- a/net/minecraft/world/entity/vehicle/MinecartHopper.java -+++ b/net/minecraft/world/entity/vehicle/MinecartHopper.java -@@ -49,6 +49,7 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper +diff --git a/net/minecraft/world/entity/projectile/arrow/Arrow.java b/net/minecraft/world/entity/projectile/arrow/Arrow.java +index acef4aee02169a155fb2cc5195c33fb5fe29fa4d..bbbdf0048db1e806642ad96cce66818e524acc62 100644 +--- a/net/minecraft/world/entity/projectile/arrow/Arrow.java ++++ b/net/minecraft/world/entity/projectile/arrow/Arrow.java +@@ -70,6 +70,16 @@ public class Arrow extends AbstractArrow { + builder.define(ID_EFFECT_COLOR, -1); + } + ++ // Paper start - EAR 2 ++ @Override ++ public void inactiveTick() { ++ if (this.isInGround()) { ++ this.life++; ++ } ++ super.inactiveTick(); ++ } ++ // Paper end ++ + @Override + public void tick() { + super.tick(); +diff --git a/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java b/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java +index 4a6384a668546371f4ffa13927be4bd462d47c60..3c961b76769f16160caedce8ec32bb2a2561163f 100644 +--- a/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java ++++ b/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java +@@ -50,6 +50,7 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper if (flag != this.isEnabled()) { this.setEnabled(flag); } @@ -791,7 +791,7 @@ index d5cb27dd5bff34890ee431d4b301a0be0167dd37..681dab5e26f8fb359f101f22ac85aac3 } public boolean isEnabled() { -@@ -102,11 +103,13 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper +@@ -103,11 +104,13 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper public boolean suckInItems() { if (HopperBlockEntity.suckInItems(this.level(), this)) { @@ -805,7 +805,7 @@ index d5cb27dd5bff34890ee431d4b301a0be0167dd37..681dab5e26f8fb359f101f22ac85aac3 return true; } } -@@ -141,4 +144,11 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper +@@ -142,4 +145,11 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper public AbstractContainerMenu createMenu(int id, Inventory playerInventory) { return new HopperMenu(id, playerInventory, this); } @@ -818,7 +818,7 @@ index d5cb27dd5bff34890ee431d4b301a0be0167dd37..681dab5e26f8fb359f101f22ac85aac3 + } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 39947ac2fae9a088d1fbc5c72d6ac520bfb97cf3..439abba4f371343dfd8e5ede7c20050ca049fcd2 100644 +index ef09aaebf4fc7fcd24a736434cd0a860d6b97905..fd8b41b3f1ee64ec30895d787c282eaf108ea402 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -150,6 +150,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl diff --git a/paper-server/patches/features-unapplied/0006-Use-Velocity-compression-and-cipher-natives.patch b/paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch similarity index 96% rename from paper-server/patches/features-unapplied/0006-Use-Velocity-compression-and-cipher-natives.patch rename to paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch index 131539ee7e57..af74127d7157 100644 --- a/paper-server/patches/features-unapplied/0006-Use-Velocity-compression-and-cipher-natives.patch +++ b/paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch @@ -267,10 +267,10 @@ index 35b8a2bddeefff2b1ba8ed75ec780c41d59ce92f..1baa8daf880c5f87f1d72ecf0e1b93c7 + // Paper end - Use Velocity cipher } diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java -index c48d0a951f36e4449e9474994a21596d8a2d2e16..14addbaf68b7ad80490187d12d9c9b00891e2ce1 100644 +index 095e8040df7786bf92d9a7ad59fd8ef21235b945..8bded92b1002e292dfb053109d1683690aa45139 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -762,11 +762,22 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -728,11 +728,22 @@ public class Connection extends SimpleChannelInboundHandler> { return connection; } @@ -297,7 +297,7 @@ index c48d0a951f36e4449e9474994a21596d8a2d2e16..14addbaf68b7ad80490187d12d9c9b00 public boolean isEncrypted() { return this.encrypted; -@@ -805,16 +816,17 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -769,16 +780,17 @@ public class Connection extends SimpleChannelInboundHandler> { // Paper end - add proper async disconnect public void setupCompression(int threshold, boolean validateDecompressed) { if (threshold >= 0) { @@ -319,10 +319,10 @@ index c48d0a951f36e4449e9474994a21596d8a2d2e16..14addbaf68b7ad80490187d12d9c9b00 this.channel.pipeline().fireUserEventTriggered(io.papermc.paper.network.ConnectionEvent.COMPRESSION_THRESHOLD_SET); // Paper - Add Channel initialization listeners } else { diff --git a/net/minecraft/server/network/ServerConnectionListener.java b/net/minecraft/server/network/ServerConnectionListener.java -index deefad689070750a3ae033a3e54dd8f5c849e794..36e05fc720b5ea3884d9d52823c7f9c14c007061 100644 +index 309845b28306dfa5946e79b80e5b1dde82dd68cd..33e1cdb00d648c992af03a976899253141314b27 100644 --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -109,6 +109,10 @@ public class ServerConnectionListener { +@@ -75,6 +75,11 @@ public class ServerConnectionListener { LOGGER.warn("Using HAProxy, please ensure the server port is adequately firewalled."); } // Paper end - Warn people with console access that HAProxy is in use. @@ -330,14 +330,15 @@ index deefad689070750a3ae033a3e54dd8f5c849e794..36e05fc720b5ea3884d9d52823c7f9c1 + ServerConnectionListener.LOGGER.info("Paper: Using " + com.velocitypowered.natives.util.Natives.compress.getLoadedVariant() + " compression from Velocity."); + ServerConnectionListener.LOGGER.info("Paper: Using " + com.velocitypowered.natives.util.Natives.cipher.getLoadedVariant() + " cipher from Velocity."); + // Paper end - Use Velocity cipher - ++ this.channels .add( + new ServerBootstrap() diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index bb418174ce67f0aa05fd90ce2d5332d853e957e4..c5d071c591c844b11667013131d1d3bae8e3bac6 100644 +index ec5bd4568872c48addd26dd652868e0e5df57038..31bc0a105152a7f24a4126542bea7dbebc3e037c 100644 --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -244,11 +244,9 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -245,11 +245,9 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, } SecretKey secretKey = packet.getSecretKey(_private); diff --git a/paper-server/patches/features-unapplied/0007-Optimize-GoalSelector-Goal.Flag-Set-operations.patch b/paper-server/patches/features/0006-Optimize-GoalSelector-Goal.Flag-Set-operations.patch similarity index 98% rename from paper-server/patches/features-unapplied/0007-Optimize-GoalSelector-Goal.Flag-Set-operations.patch rename to paper-server/patches/features/0006-Optimize-GoalSelector-Goal.Flag-Set-operations.patch index 79957e9faa04..028ebc23a06c 100644 --- a/paper-server/patches/features-unapplied/0007-Optimize-GoalSelector-Goal.Flag-Set-operations.patch +++ b/paper-server/patches/features/0006-Optimize-GoalSelector-Goal.Flag-Set-operations.patch @@ -154,7 +154,7 @@ index 674966c580220a4e0c83a628c763aaea8bfd0b1c..859b859d29b637200cf7c9a0bd52d9f7 public void setControlFlag(Goal.Flag flag, boolean enabled) { diff --git a/net/minecraft/world/entity/ai/goal/WrappedGoal.java b/net/minecraft/world/entity/ai/goal/WrappedGoal.java -index 4bdbd323b642ed3422948fe24780be8b503602dc..2c2ab6a1df9d3d23773e44ce4041cc1c21b55163 100644 +index d0249ae3fee041245445a087dee2bb15a4067fc6..44a7c97164ac7ee731068f909372218350a8682d 100644 --- a/net/minecraft/world/entity/ai/goal/WrappedGoal.java +++ b/net/minecraft/world/entity/ai/goal/WrappedGoal.java @@ -69,7 +69,7 @@ public class WrappedGoal extends Goal { diff --git a/paper-server/patches/features-unapplied/0008-Optimize-Voxel-Shape-Merging.patch b/paper-server/patches/features/0007-Optimize-Voxel-Shape-Merging.patch similarity index 96% rename from paper-server/patches/features-unapplied/0008-Optimize-Voxel-Shape-Merging.patch rename to paper-server/patches/features/0007-Optimize-Voxel-Shape-Merging.patch index 4f4c5692daf6..bafbe6886916 100644 --- a/paper-server/patches/features-unapplied/0008-Optimize-Voxel-Shape-Merging.patch +++ b/paper-server/patches/features/0007-Optimize-Voxel-Shape-Merging.patch @@ -67,10 +67,10 @@ index 60b56a5086b8aad0fad693f686b89138b3a4c80d..5b079ec43c259368d0eed4e838588071 this.firstIndices = new int[i]; this.secondIndices = new int[i]; diff --git a/net/minecraft/world/phys/shapes/Shapes.java b/net/minecraft/world/phys/shapes/Shapes.java -index 881455dd3d576528adc68e00c00eb2819ccd4f0c..3205cc111b1165cd98705bb70d65c858961abc33 100644 +index ac4bb789df88c07ea38d20700dccb6571e3ea58d..fc2b393d24fef8ce3a74d38d0937bfe5604eae87 100644 --- a/net/minecraft/world/phys/shapes/Shapes.java +++ b/net/minecraft/world/phys/shapes/Shapes.java -@@ -347,9 +347,22 @@ public final class Shapes { +@@ -346,9 +346,22 @@ public final class Shapes { } @VisibleForTesting @@ -94,7 +94,7 @@ index 881455dd3d576528adc68e00c00eb2819ccd4f0c..3205cc111b1165cd98705bb70d65c858 if (list1 instanceof CubePointRange && list2 instanceof CubePointRange) { long l = lcm(i, i1); if (size * l <= 256L) { -@@ -357,14 +370,21 @@ public final class Shapes { +@@ -356,14 +369,21 @@ public final class Shapes { } } diff --git a/paper-server/patches/features-unapplied/0009-Handle-Oversized-block-entities-in-chunks.patch b/paper-server/patches/features/0008-Handle-Oversized-block-entities-in-chunks.patch similarity index 94% rename from paper-server/patches/features-unapplied/0009-Handle-Oversized-block-entities-in-chunks.patch rename to paper-server/patches/features/0008-Handle-Oversized-block-entities-in-chunks.patch index d1f3ce49f7b9..2b04a30e0fb3 100644 --- a/paper-server/patches/features-unapplied/0009-Handle-Oversized-block-entities-in-chunks.patch +++ b/paper-server/patches/features/0008-Handle-Oversized-block-entities-in-chunks.patch @@ -9,7 +9,7 @@ creating too large of a packet to sed. Co-authored-by: Spottedleaf diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index de234f220ba09ad9b5e0c8215b49d20ca51d0ac7..e216a9d70be5a3da7c03ee99a8986391ef2dbd5b 100644 +index 7cdac4a18b13805aea60495d369ee7cdd1db784f..919eaac837298c1936ec7aa06375c72a7acd2daa 100644 --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java @@ -32,6 +32,14 @@ public class ClientboundLevelChunkPacketData { @@ -47,7 +47,7 @@ index de234f220ba09ad9b5e0c8215b49d20ca51d0ac7..e216a9d70be5a3da7c03ee99a8986391 } } diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java -index 3a384175f8e7f204234bbaf3081bdc20c47a0d4b..fdd164cd45a26c7ef25f1153ab8985ba50c01b14 100644 +index 8475c1c3d79e7fae9ab83dea1ac18f7a28ff60bb..3c0f0a612cc57c9f03abfb0ccb1f891305d03d45 100644 --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java @@ -71,4 +71,11 @@ public class ClientboundLevelChunkWithLightPacket implements Packet targets, float maxRange, int reachRange, float maxVisitedNodesMultiplier) { -+ private Path findPath(Node node, List> positions, float maxRange, int reachRange, float maxVisitedNodesMultiplier) { // Paper - optimize collection +- private @Nullable Path findPath(Node node, Map targets, float maxRange, int reachRange, float maxVisitedNodesMultiplier) { ++ private @Nullable Path findPath(Node node, List> positions, float maxRange, int reachRange, float maxVisitedNodesMultiplier) { // Paper - optimize collection ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("find_path"); profilerFiller.markForCharting(MetricCategory.PATH_FINDING); @@ -59,7 +58,7 @@ index 1a9d8e6dd55ce30aca1c65b32417d61fd0a10f84..5894260481ea395c26a5b506e38530f7 int i1 = (int)(this.maxVisitedNodes * maxVisitedNodesMultiplier); while (!this.openSet.isEmpty()) { -@@ -81,14 +85,18 @@ public class PathFinder { +@@ -79,14 +83,18 @@ public class PathFinder { Node node1 = this.openSet.pop(); node1.closed = true; @@ -81,7 +80,7 @@ index 1a9d8e6dd55ce30aca1c65b32417d61fd0a10f84..5894260481ea395c26a5b506e38530f7 break; } -@@ -107,7 +115,7 @@ public class PathFinder { +@@ -105,7 +113,7 @@ public class PathFinder { if (node2.walkedDistance < maxRange && (!node2.inOpenSet() || f1 < node2.g)) { node2.cameFrom = node1; node2.g = f1; @@ -90,7 +89,7 @@ index 1a9d8e6dd55ce30aca1c65b32417d61fd0a10f84..5894260481ea395c26a5b506e38530f7 if (node2.inOpenSet()) { this.openSet.changeCost(node2, node2.g + node2.h); } else { -@@ -119,34 +127,41 @@ public class PathFinder { +@@ -117,34 +125,41 @@ public class PathFinder { } } From 8156643c4c98765f28ac608d48dd0f9b229fa87a Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 25 Nov 2025 20:58:58 -0700 Subject: [PATCH 108/112] Update feature patches 14-26 --- ...r-desync-when-new-players-are-added.patch} | 14 +-- ...-Eigencraft-redstone-implementation.patch} | 12 +-- ...ate-Current-redstone-implementation.patch} | 30 +++---- ...ove-exact-choice-recipe-ingredients.patch} | 87 ++++++++++++------- ...data-to-disk-if-it-serializes-witho.patch} | 14 +-- ...18-Entity-load-save-limit-per-chunk.patch} | 8 +- ...ulate-regionfile-header-if-it-is-co.patch} | 20 ++--- ...Incremental-chunk-and-player-saving.patch} | 20 ++--- .../0021-Optimise-general-POI-access.patch} | 23 ++--- ...nfiles-on-save-configuration-option.patch} | 0 ...n-checking-in-player-move-packet-ha.patch} | 18 ++-- .../0024-Improve-keepalive-ping-system.patch} | 2 +- ...25-Optimise-EntityScheduler-ticking.patch} | 10 +-- 13 files changed, 140 insertions(+), 118 deletions(-) rename paper-server/patches/{features-unapplied/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch => features/0013-Fix-entity-tracker-desync-when-new-players-are-added.patch} (89%) rename paper-server/patches/{features-unapplied/0015-Eigencraft-redstone-implementation.patch => features/0014-Eigencraft-redstone-implementation.patch} (99%) rename paper-server/patches/{features-unapplied/0016-Add-Alternate-Current-redstone-implementation.patch => features/0015-Add-Alternate-Current-redstone-implementation.patch} (98%) rename paper-server/patches/{features-unapplied/0017-Improve-exact-choice-recipe-ingredients.patch => features/0016-Improve-exact-choice-recipe-ingredients.patch} (90%) rename paper-server/patches/{features-unapplied/0018-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch => features/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch} (92%) rename paper-server/patches/{features-unapplied/0019-Entity-load-save-limit-per-chunk.patch => features/0018-Entity-load-save-limit-per-chunk.patch} (93%) rename paper-server/patches/{features-unapplied/0020-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch => features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch} (98%) rename paper-server/patches/{features-unapplied/0021-Incremental-chunk-and-player-saving.patch => features/0020-Incremental-chunk-and-player-saving.patch} (89%) rename paper-server/patches/{features-unapplied/0022-Optimise-general-POI-access.patch => features/0021-Optimise-general-POI-access.patch} (98%) rename paper-server/patches/{features-unapplied/0023-Flush-regionfiles-on-save-configuration-option.patch => features/0022-Flush-regionfiles-on-save-configuration-option.patch} (100%) rename paper-server/patches/{features-unapplied/0024-Optimise-collision-checking-in-player-move-packet-ha.patch => features/0023-Optimise-collision-checking-in-player-move-packet-ha.patch} (94%) rename paper-server/patches/{features-unapplied/0025-Improve-keepalive-ping-system.patch => features/0024-Improve-keepalive-ping-system.patch} (99%) rename paper-server/patches/{features-unapplied/0026-Optimise-EntityScheduler-ticking.patch => features/0025-Optimise-EntityScheduler-ticking.patch} (91%) diff --git a/paper-server/patches/features-unapplied/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch b/paper-server/patches/features/0013-Fix-entity-tracker-desync-when-new-players-are-added.patch similarity index 89% rename from paper-server/patches/features-unapplied/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch rename to paper-server/patches/features/0013-Fix-entity-tracker-desync-when-new-players-are-added.patch index e0f798b50629..3f3e1ff79b86 100644 --- a/paper-server/patches/features-unapplied/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch +++ b/paper-server/patches/features/0013-Fix-entity-tracker-desync-when-new-players-are-added.patch @@ -48,10 +48,10 @@ index 2a86ca1de6920017be6cd4a3a5251e892067f07c..f571ff64ae1007f8f0632febd2dcca70 serverEntity.getLastSentYRot(), entity.getType(), diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 032d164284ebc8fd4cfbc96f1381e8627edd1605..30c26d1f79621ac89d5dfd4652e627062af57956 100644 +index b0b4e5c96498eef48fe0cb2637faed73409941ad..dfd7a60192c46f01d245045adf86dec42eec4da7 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -1326,6 +1326,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1353,6 +1353,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP ChunkMap.this.level.debugSynchronizers().startTrackingEntity(player, this.entity); } // Paper end - entity tracking events @@ -60,10 +60,10 @@ index 032d164284ebc8fd4cfbc96f1381e8627edd1605..30c26d1f79621ac89d5dfd4652e62706 } else { this.removePlayer(player); diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index f019f1330f9f1e6aa98ef3f914833769cbadea16..638432a2e6506d3db6a25c068a33eeafb13cf0d6 100644 +index b7915685026e9a944f42440e4a95215f927f385e..3a817c92147bb78c60238f3ddc1644b721aed7a2 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -88,6 +88,13 @@ public class ServerEntity { +@@ -87,6 +87,13 @@ public class ServerEntity { this.trackedDataValues = entity.getEntityData().getNonDefaultValues(); } @@ -81,8 +81,8 @@ index f019f1330f9f1e6aa98ef3f914833769cbadea16..638432a2e6506d3db6a25c068a33eeaf this.sendDirtyEntityData(); } -- if (this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) { -+ if (this.forceStateResync || this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) { // Paper - fix desync when a player is added to the tracker +- if (this.tickCount % this.updateInterval == 0 || this.entity.needsSync || this.entity.getEntityData().isDirty()) { ++ if (this.forceStateResync || this.tickCount % this.updateInterval == 0 || this.entity.needsSync || this.entity.getEntityData().isDirty()) { // Paper - fix desync when a player is added to the tracker byte b = Mth.packDegrees(this.entity.getYRot()); byte b1 = Mth.packDegrees(this.entity.getXRot()); boolean flag = Math.abs(b - this.lastSentYRot) >= 1 || Math.abs(b1 - this.lastSentXRot) >= 1; @@ -98,7 +98,7 @@ index f019f1330f9f1e6aa98ef3f914833769cbadea16..638432a2e6506d3db6a25c068a33eeaf @@ -233,6 +240,7 @@ public class ServerEntity { } - this.entity.hasImpulse = false; + this.entity.needsSync = false; + this.forceStateResync = false; // Paper - fix desync when a player is added to the tracker } diff --git a/paper-server/patches/features-unapplied/0015-Eigencraft-redstone-implementation.patch b/paper-server/patches/features/0014-Eigencraft-redstone-implementation.patch similarity index 99% rename from paper-server/patches/features-unapplied/0015-Eigencraft-redstone-implementation.patch rename to paper-server/patches/features/0014-Eigencraft-redstone-implementation.patch index ba8898d4fb4e..ef84f13c5404 100644 --- a/paper-server/patches/features-unapplied/0015-Eigencraft-redstone-implementation.patch +++ b/paper-server/patches/features/0014-Eigencraft-redstone-implementation.patch @@ -978,10 +978,10 @@ index 0000000000000000000000000000000000000000..ff747a1ecdf3c888bca0d69de4f85dcd + } +} diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index bd8d8431766fd3fa98e51f4122259ba03fc39272..07d2b9b7ebea9827ef7a535c090b311a3c27d5c6 100644 +index 417e12d3dfabdfce40d6a53d217b86a39defc553..d7ff98f4ecadd37f22d0a38d94a5975db60d6285 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -265,6 +265,60 @@ public class RedStoneWireBlock extends Block { +@@ -264,6 +264,60 @@ public class RedStoneWireBlock extends Block { return state.isFaceSturdy(level, pos, Direction.UP) || state.is(Blocks.HOPPER); } @@ -1042,7 +1042,7 @@ index bd8d8431766fd3fa98e51f4122259ba03fc39272..07d2b9b7ebea9827ef7a535c090b311a private void updatePowerStrength(Level level, BlockPos pos, BlockState state, @Nullable Orientation orientation, boolean updateShape) { if (useExperimentalEvaluator(level)) { new ExperimentalRedstoneWireEvaluator(this).updatePowerStrength(level, pos, state, orientation, updateShape); -@@ -293,7 +347,7 @@ public class RedStoneWireBlock extends Block { +@@ -292,7 +346,7 @@ public class RedStoneWireBlock extends Block { @Override protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) { if (!oldState.is(state.getBlock()) && !level.isClientSide()) { @@ -1051,7 +1051,7 @@ index bd8d8431766fd3fa98e51f4122259ba03fc39272..07d2b9b7ebea9827ef7a535c090b311a for (Direction direction : Direction.Plane.VERTICAL) { level.updateNeighborsAt(pos.relative(direction), this); -@@ -310,7 +364,7 @@ public class RedStoneWireBlock extends Block { +@@ -309,7 +363,7 @@ public class RedStoneWireBlock extends Block { level.updateNeighborsAt(pos.relative(direction), this); } @@ -1060,7 +1060,7 @@ index bd8d8431766fd3fa98e51f4122259ba03fc39272..07d2b9b7ebea9827ef7a535c090b311a this.updateNeighborsOfNeighboringWires(level, pos); } } -@@ -335,7 +389,7 @@ public class RedStoneWireBlock extends Block { +@@ -334,7 +388,7 @@ public class RedStoneWireBlock extends Block { if (!level.isClientSide()) { if (neighborBlock != this || !useExperimentalEvaluator(level)) { if (state.canSurvive(level, pos)) { @@ -1070,7 +1070,7 @@ index bd8d8431766fd3fa98e51f4122259ba03fc39272..07d2b9b7ebea9827ef7a535c090b311a dropResources(state, level, pos); level.removeBlock(pos, false); diff --git a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java -index 8c4d7047ae5b74262d4fb6c46975822953c23938..4edf6e96cd47ab75aedd4baefcf49cd3fae00d7a 100644 +index 82a45a598cd3d7520b15bac9b47117ef7b1f98ba..53b8df8e6dd379126af3e1feb2220e222430ce94 100644 --- a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java +++ b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java @@ -45,7 +45,7 @@ public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator { diff --git a/paper-server/patches/features-unapplied/0016-Add-Alternate-Current-redstone-implementation.patch b/paper-server/patches/features/0015-Add-Alternate-Current-redstone-implementation.patch similarity index 98% rename from paper-server/patches/features-unapplied/0016-Add-Alternate-Current-redstone-implementation.patch rename to paper-server/patches/features/0015-Add-Alternate-Current-redstone-implementation.patch index eca4cb8bd5c2..7ddb020d9b5e 100644 --- a/paper-server/patches/features-unapplied/0016-Add-Alternate-Current-redstone-implementation.patch +++ b/paper-server/patches/features/0015-Add-Alternate-Current-redstone-implementation.patch @@ -2326,10 +2326,10 @@ index 0000000000000000000000000000000000000000..298076a0db4e6ee6e4775ac43bf749d9 + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index ce6f83c83b0235d59b4cadd248ff218985978ab5..71de8d8920eb33d15a18653dcef370c8e1a43712 100644 +index d7238270a6df8d1182874b46b588b971ca6f7a0e..db2054e84f5717a37683d57890dcd585769effbc 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -221,6 +221,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -227,6 +227,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public final net.minecraft.server.level.progress.LevelLoadListener levelLoadListener; public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent @@ -2337,7 +2337,7 @@ index ce6f83c83b0235d59b4cadd248ff218985978ab5..71de8d8920eb33d15a18653dcef370c8 @Override public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { -@@ -2660,6 +2661,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2696,6 +2697,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe return this.debugSynchronizers; } @@ -2348,14 +2348,14 @@ index ce6f83c83b0235d59b4cadd248ff218985978ab5..71de8d8920eb33d15a18653dcef370c8 + } + // Paper end - optimize redstone (Alternate Current) + - final class EntityCallbacks implements LevelCallback { - @Override - public void onCreated(Entity entity) { + public boolean isAllowedToEnterPortal(Level level) { + return level.dimension() != Level.NETHER || this.getGameRules().get(GameRules.ALLOW_ENTERING_NETHER_USING_PORTALS); + } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 439abba4f371343dfd8e5ede7c20050ca049fcd2..96fa7390a4bcfa7bdf2cf5346f2de895ac085203 100644 +index fd8b41b3f1ee64ec30895d787c282eaf108ea402..bc0824b42e2fde246f052afe1e1393de632ccfb7 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -2078,6 +2078,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -2040,6 +2040,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl return this.palettedContainerFactory; } @@ -2374,10 +2374,10 @@ index 439abba4f371343dfd8e5ede7c20050ca049fcd2..96fa7390a4bcfa7bdf2cf5346f2de895 NONE("none"), BLOCK("block"), diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index 07d2b9b7ebea9827ef7a535c090b311a3c27d5c6..a07d9237d227fe6d419d8a9bc44fc623b244ad3e 100644 +index d7ff98f4ecadd37f22d0a38d94a5975db60d6285..6d98bc37d88459d1e0a171b52bbff5810d775c38 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -265,7 +265,7 @@ public class RedStoneWireBlock extends Block { +@@ -264,7 +264,7 @@ public class RedStoneWireBlock extends Block { return state.isFaceSturdy(level, pos, Direction.UP) || state.is(Blocks.HOPPER); } @@ -2386,7 +2386,7 @@ index 07d2b9b7ebea9827ef7a535c090b311a3c27d5c6..a07d9237d227fe6d419d8a9bc44fc623 // The bulk of the new functionality is found in RedstoneWireTurbo.java io.papermc.paper.redstone.RedstoneWireTurbo turbo = new io.papermc.paper.redstone.RedstoneWireTurbo(this); -@@ -347,7 +347,13 @@ public class RedStoneWireBlock extends Block { +@@ -346,7 +346,13 @@ public class RedStoneWireBlock extends Block { @Override protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) { if (!oldState.is(state.getBlock()) && !level.isClientSide()) { @@ -2401,7 +2401,7 @@ index 07d2b9b7ebea9827ef7a535c090b311a3c27d5c6..a07d9237d227fe6d419d8a9bc44fc623 for (Direction direction : Direction.Plane.VERTICAL) { level.updateNeighborsAt(pos.relative(direction), this); -@@ -364,7 +370,13 @@ public class RedStoneWireBlock extends Block { +@@ -363,7 +369,13 @@ public class RedStoneWireBlock extends Block { level.updateNeighborsAt(pos.relative(direction), this); } @@ -2416,7 +2416,7 @@ index 07d2b9b7ebea9827ef7a535c090b311a3c27d5c6..a07d9237d227fe6d419d8a9bc44fc623 this.updateNeighborsOfNeighboringWires(level, pos); } } -@@ -387,9 +399,15 @@ public class RedStoneWireBlock extends Block { +@@ -386,9 +398,15 @@ public class RedStoneWireBlock extends Block { @Override protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) { if (!level.isClientSide()) { @@ -2434,10 +2434,10 @@ index 07d2b9b7ebea9827ef7a535c090b311a3c27d5c6..a07d9237d227fe6d419d8a9bc44fc623 dropResources(state, level, pos); level.removeBlock(pos, false); diff --git a/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java b/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java -index 83f5da3e24834882193b9d7e3a788517e4b12b55..0c50a0bbbef1229230712b7c04364fea06859674 100644 +index 413d6b66a7e368ebb590064b0d0dd47b64c68659..05e99653bb1f3b392be86f9fa9814b87ca301bca 100644 --- a/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java +++ b/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java -@@ -17,6 +17,11 @@ public class ExperimentalRedstoneUtils { +@@ -16,6 +16,11 @@ public class ExperimentalRedstoneUtils { if (front != null) { orientation = orientation.withFront(front); } diff --git a/paper-server/patches/features-unapplied/0017-Improve-exact-choice-recipe-ingredients.patch b/paper-server/patches/features/0016-Improve-exact-choice-recipe-ingredients.patch similarity index 90% rename from paper-server/patches/features-unapplied/0017-Improve-exact-choice-recipe-ingredients.patch rename to paper-server/patches/features/0016-Improve-exact-choice-recipe-ingredients.patch index 813b82b4dc9c..4971dc26805a 100644 --- a/paper-server/patches/features-unapplied/0017-Improve-exact-choice-recipe-ingredients.patch +++ b/paper-server/patches/features/0016-Improve-exact-choice-recipe-ingredients.patch @@ -224,11 +224,11 @@ index 76eda3bd8c513c7e42ceedf1aa605fb6df8b7019..41e59f3739945ca7f6ab710c993b5c0f return i; } diff --git a/net/minecraft/world/entity/player/StackedContents.java b/net/minecraft/world/entity/player/StackedContents.java -index a4b528574ab371af94b0e07819e471cec94da244..a3fea6c8397046596afe3c8b5589f2ed37fcdfc3 100644 +index bc4f7d16365dffc87b1eef8aa5791a5cb595ee78..cbb37480c19b210cf83999247c1d670c9df2d150 100644 --- a/net/minecraft/world/entity/player/StackedContents.java +++ b/net/minecraft/world/entity/player/StackedContents.java @@ -13,7 +13,7 @@ import java.util.List; - import javax.annotation.Nullable; + import org.jspecify.annotations.Nullable; public class StackedContents { - public final Reference2IntOpenHashMap amounts = new Reference2IntOpenHashMap<>(); @@ -262,11 +262,11 @@ index a4b528574ab371af94b0e07819e471cec94da244..a3fea6c8397046596afe3c8b5589f2ed if (intValue > i1) { if (ingredientInfo.acceptsItem(entry.getKey())) { diff --git a/net/minecraft/world/entity/player/StackedItemContents.java b/net/minecraft/world/entity/player/StackedItemContents.java -index 6bbe2e51ef71d193e0a5d3cace2b0ad1760ce759..83ccde54c625d40dc595e000c533f60aa929bd5a 100644 +index e0121e9c8439e32b7ef064c06942ccd5dd74987d..cb3ad6141e88cd86afd6d00db31ca9133b4d6e5a 100644 --- a/net/minecraft/world/entity/player/StackedItemContents.java +++ b/net/minecraft/world/entity/player/StackedItemContents.java -@@ -9,9 +9,14 @@ import net.minecraft.world.item.crafting.PlacementInfo; - import net.minecraft.world.item.crafting.Recipe; +@@ -9,9 +9,14 @@ import net.minecraft.world.item.crafting.Recipe; + import org.jspecify.annotations.Nullable; public class StackedItemContents { - private final StackedContents> raw = new StackedContents<>(); @@ -281,7 +281,7 @@ index 6bbe2e51ef71d193e0a5d3cace2b0ad1760ce759..83ccde54c625d40dc595e000c533f60a if (Inventory.isUsableForCrafting(stack)) { this.accountStack(stack); } -@@ -24,34 +29,51 @@ public class StackedItemContents { +@@ -24,20 +29,21 @@ public class StackedItemContents { public void accountStack(ItemStack stack, int maxStackSize) { if (!stack.isEmpty()) { int min = Math.min(maxStackSize, stack.getCount()); @@ -291,12 +291,39 @@ index 6bbe2e51ef71d193e0a5d3cace2b0ad1760ce759..83ccde54c625d40dc595e000c533f60a } } -- public boolean canCraft(Recipe recipe, @Nullable StackedContents.Output> output) { -+ public boolean canCraft(Recipe recipe, @Nullable StackedContents.Output output) { // Paper - Improve exact choice recipe ingredients +- public boolean canCraft(Recipe recipe, StackedContents.@Nullable Output> output) { ++ public boolean canCraft(Recipe recipe, StackedContents.@Nullable Output> output) { // Paper - Improve exact choice recipe ingredients return this.canCraft(recipe, 1, output); } -- public boolean canCraft(Recipe recipe, int maxCount, @Nullable StackedContents.Output> output) { +- public boolean canCraft(Recipe recipe, int maxCount, StackedContents.@Nullable Output> output) { ++ public boolean canCraft(Recipe recipe, int maxCount, StackedContents.@Nullable Output output) { // Paper - Improve exact choice recipe ingredients + PlacementInfo placementInfo = recipe.placementInfo(); + return !placementInfo.isImpossibleToPlace() && this.canCraft(placementInfo.ingredients(), maxCount, output); + } + +- public boolean canCraft(List>> ingredients, StackedContents.@Nullable Output> output) { ++ public boolean canCraft(List>> ingredients, StackedContents.@Nullable Output> output) { // Paper - Improve exact choice recipe ingredients + return this.canCraft(ingredients, 1, output); + } + +@@ -47,7 +53,7 @@ public class StackedItemContents { + return this.raw.tryPick(ingredients, maxCount, output); + } + +- public int getBiggestCraftableStack(Recipe recipe, StackedContents.@Nullable Output> output) { ++ public int getBiggestCraftableStack(Recipe recipe, StackedContents.@Nullable Output> output) { // Paper - Improve exact choice recipe ingredients + return this.getBiggestCraftableStack(recipe, Integer.MAX_VALUE, output); + } + +@@ -55,6 +61,44 @@ public class StackedItemContents { + return this.raw.tryPickAll(recipe.placementInfo().ingredients(), maxCount, output); + } + ++ public boolean canCraft(Recipe recipe, @Nullable StackedContents.Output output) { // Paper - Improve exact choice recipe ingredients ++ return this.canCraft(recipe, 1, output); ++ } ++ + // Paper start - Improve exact choice recipe ingredients + public void initializeExtras(final Recipe recipe, @Nullable final net.minecraft.world.item.crafting.CraftingInput input) { + if (this.extrasMap == null) { @@ -313,33 +340,27 @@ index 6bbe2e51ef71d193e0a5d3cace2b0ad1760ce759..83ccde54c625d40dc595e000c533f60a + } + // Paper end - Improve exact choice recipe ingredients + -+ public boolean canCraft(Recipe recipe, int maxCount, @Nullable StackedContents.Output output) { // Paper - Improve exact choice recipe ingredients - PlacementInfo placementInfo = recipe.placementInfo(); - return !placementInfo.isImpossibleToPlace() && this.canCraft(placementInfo.ingredients(), maxCount, output); - } - -- public boolean canCraft(List>> ingredients, @Nullable StackedContents.Output> output) { + public boolean canCraft(List> ingredients, @Nullable StackedContents.Output output) { // Paper - Improve exact choice recipe ingredients - return this.canCraft(ingredients, 1, output); - } - - private boolean canCraft( -- List>> ingredients, int maxCount, @Nullable StackedContents.Output> output ++ return this.canCraft(ingredients, 1, output); ++ } ++ ++ private boolean canCraft( + List> ingredients, int maxCount, @Nullable StackedContents.Output output // Paper - Improve exact choice recipe ingredients - ) { - return this.raw.tryPick(ingredients, maxCount, output); - } - -- public int getBiggestCraftableStack(Recipe recipe, @Nullable StackedContents.Output> output) { ++ ) { ++ return this.raw.tryPick(ingredients, maxCount, output); ++ } ++ + public int getBiggestCraftableStack(Recipe recipe, @Nullable StackedContents.Output output) { // Paper - Improve exact choice recipe ingredients - return this.getBiggestCraftableStack(recipe, Integer.MAX_VALUE, output); - } - -- public int getBiggestCraftableStack(Recipe recipe, int maxCount, @Nullable StackedContents.Output> output) { ++ return this.getBiggestCraftableStack(recipe, Integer.MAX_VALUE, output); ++ } ++ + public int getBiggestCraftableStack(Recipe recipe, int maxCount, @Nullable StackedContents.Output output) { // Paper - Improve exact choice recipe ingredients - return this.raw.tryPickAll(recipe.placementInfo().ingredients(), maxCount, output); ++ return this.raw.tryPickAll(recipe.placementInfo().ingredients(), maxCount, output); ++ } ++ + public void clear() { + this.raw.clear(); } - diff --git a/net/minecraft/world/item/crafting/Ingredient.java b/net/minecraft/world/item/crafting/Ingredient.java index e43641650d66a62b5b7b58c43833ce504970ab1e..879c8fe1f20decc793cfa39e686b61d521bd76ba 100644 --- a/net/minecraft/world/item/crafting/Ingredient.java @@ -426,10 +447,10 @@ index e43641650d66a62b5b7b58c43833ce504970ab1e..879c8fe1f20decc793cfa39e686b61d5 .unwrap() .map(SlotDisplay.TagSlotDisplay::new, list -> new SlotDisplay.Composite(list.stream().map(Ingredient::displayForSingleItem).toList())); diff --git a/net/minecraft/world/item/crafting/ShapelessRecipe.java b/net/minecraft/world/item/crafting/ShapelessRecipe.java -index fb317eafeed39adff793bffa8f6b21c37a32086c..d601b54b1de2f2ae44fe2b20c8116c71a6340e45 100644 +index 43c8b7a027c519196852602d136a31f8c392b786..28d085fce206634ee88c492e06fdbf63a618ee12 100644 --- a/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -72,13 +72,18 @@ public class ShapelessRecipe implements CraftingRecipe { +@@ -71,13 +71,18 @@ public class ShapelessRecipe implements CraftingRecipe { @Override public boolean matches(CraftingInput input, Level level) { diff --git a/paper-server/patches/features-unapplied/0018-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch b/paper-server/patches/features/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch similarity index 92% rename from paper-server/patches/features-unapplied/0018-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch rename to paper-server/patches/features/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch index 9a25ae0dcb90..d0845664ca6b 100644 --- a/paper-server/patches/features-unapplied/0018-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch +++ b/paper-server/patches/features/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch @@ -8,7 +8,7 @@ This ensures at least a valid version of the chunk exists on disk, even if outdated diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java -index 984db72272d552c7210bd6f437ea88694ddd2828..dea2823a9d1d69dcb0a4759d8ea9b3015ede20dc 100644 +index 944a01c34d19225d8366f6f97cbc3cacbb5d5498..f2ef716788c1ed1933139c1f53a6d73769362809 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -24,6 +24,7 @@ import org.slf4j.Logger; @@ -19,7 +19,7 @@ index 984db72272d552c7210bd6f437ea88694ddd2828..dea2823a9d1d69dcb0a4759d8ea9b301 private static final int SECTOR_BYTES = 4096; @VisibleForTesting protected static final int SECTOR_INTS = 1024; -@@ -455,6 +456,24 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche +@@ -452,6 +453,24 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche this.pos = pos; } @@ -45,11 +45,11 @@ index 984db72272d552c7210bd6f437ea88694ddd2828..dea2823a9d1d69dcb0a4759d8ea9b301 public void close() throws IOException { ByteBuffer byteBuffer = ByteBuffer.wrap(this.buf, 0, this.count); diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 283f73e633e32585530458545bf54fc6a644c830..5133590b1a8c7035a949b85ceefa904b583e4e7f 100644 +index 98b3f20c720d70293c6fcf77fdc081b44c71dd6b..3ca75289ac9eb05eadb74c87c0c94cbc026fd08f 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -16,6 +16,7 @@ import net.minecraft.util.ExceptionCollector; - import net.minecraft.world.level.ChunkPos; +@@ -16,6 +16,7 @@ import net.minecraft.world.level.ChunkPos; + import org.jspecify.annotations.Nullable; public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.io.ChunkSystemRegionFileStorage { // Paper - rewrite chunk system + private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); // Paper @@ -81,7 +81,7 @@ index 283f73e633e32585530458545bf54fc6a644c830..5133590b1a8c7035a949b85ceefa904b return writeData; } -@@ -328,9 +342,17 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -327,9 +341,17 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise if (chunkData == null) { regionFile.clear(chunkPos); } else { @@ -100,7 +100,7 @@ index 283f73e633e32585530458545bf54fc6a644c830..5133590b1a8c7035a949b85ceefa904b } } } -@@ -373,4 +395,13 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -372,4 +394,13 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise public RegionStorageInfo info() { return this.info; } diff --git a/paper-server/patches/features-unapplied/0019-Entity-load-save-limit-per-chunk.patch b/paper-server/patches/features/0018-Entity-load-save-limit-per-chunk.patch similarity index 93% rename from paper-server/patches/features-unapplied/0019-Entity-load-save-limit-per-chunk.patch rename to paper-server/patches/features/0018-Entity-load-save-limit-per-chunk.patch index 6ca36525f987..74c39921a062 100644 --- a/paper-server/patches/features-unapplied/0019-Entity-load-save-limit-per-chunk.patch +++ b/paper-server/patches/features/0018-Entity-load-save-limit-per-chunk.patch @@ -9,7 +9,7 @@ defaults are only included for certain entites, this allows setting limits for any entity type. diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java -index c380487a97f626163e1f13d87231d64ce2ea4b24..b2bcfb3557a0326fd7ec1059f95d6da4568dfd80 100644 +index c2363cfa5e93942fe837efd9f39478698f6d1a98..2dfd412344a0e57f25a08d9c65656a13113baa4e 100644 --- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java @@ -116,8 +116,19 @@ public final class ChunkEntitySlices { @@ -33,10 +33,10 @@ index c380487a97f626163e1f13d87231d64ce2ea4b24..b2bcfb3557a0326fd7ec1059f95d6da4 scopedCollector.forChild(entity.problemPath()), entity.registryAccess() ); diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java -index 6515f0eeb8f05985cd483d7b6264a6eac073d364..4706a41ecaccd20fc623ce64858b160204f60f9e 100644 +index 3cf2378a2ccf117fab9fc6fc60fcb0ecdf638d45..abccad13c2bb3a33e98ad8eb6d7f08c0ef021811 100644 --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -1598,7 +1598,18 @@ public class EntityType implements FeatureElement, EntityTypeT +@@ -1615,7 +1615,18 @@ public class EntityType implements FeatureElement, EntityTypeT } public static Stream loadEntitiesRecursive(ValueInput.ValueInputList input, Level level, EntitySpawnReason spawnReason) { @@ -56,7 +56,7 @@ index 6515f0eeb8f05985cd483d7b6264a6eac073d364..4706a41ecaccd20fc623ce64858b1602 return entity; })); diff --git a/net/minecraft/world/level/chunk/storage/EntityStorage.java b/net/minecraft/world/level/chunk/storage/EntityStorage.java -index bf45cce4db77966d44d7a8d97673bb6631a6adaf..f1f8575a4b37114ced3cdb1d2ea33a36a2db44fd 100644 +index bfba76d8f442905e4d3a62b65edabbca12fdb10e..2ce9caafffc86fee82abf0a33423a172a8158e37 100644 --- a/net/minecraft/world/level/chunk/storage/EntityStorage.java +++ b/net/minecraft/world/level/chunk/storage/EntityStorage.java @@ -95,7 +95,18 @@ public class EntityStorage implements EntityPersistentStorage { diff --git a/paper-server/patches/features-unapplied/0020-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch similarity index 98% rename from paper-server/patches/features-unapplied/0020-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch rename to paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch index 6aed043970d1..cd19a284f226 100644 --- a/paper-server/patches/features-unapplied/0020-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch +++ b/paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch @@ -55,7 +55,7 @@ index 64a718c98f799c62a5bb28e1e8e5f66cc96c915d..666f2e967c99f78422c83fb20e1a3bf3 this.used.set(sectorOffset, sectorOffset + sectorCount); } diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java -index dea2823a9d1d69dcb0a4759d8ea9b3015ede20dc..22f3aa1674664906e8ec45372d758d79017e3987 100644 +index f2ef716788c1ed1933139c1f53a6d73769362809..2feeacf16db69c53e6844cf3a8e5bab3b91255e5 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -46,6 +46,363 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche @@ -548,10 +548,10 @@ index dea2823a9d1d69dcb0a4759d8ea9b3015ede20dc..22f3aa1674664906e8ec45372d758d79 + } + // Paper end + - @Nullable - public synchronized DataInputStream getChunkDataInputStream(ChunkPos chunkPos) throws IOException { + public synchronized @Nullable DataInputStream getChunkDataInputStream(ChunkPos chunkPos) throws IOException { int offset = this.getOffset(chunkPos); -@@ -155,30 +584,67 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche + if (offset == 0) { +@@ -154,30 +583,67 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche byteBuffer.flip(); if (byteBuffer.remaining() < 5) { LOGGER.error("Chunk {} header is truncated: expected {} but read {}", chunkPos, i, byteBuffer.remaining()); @@ -621,7 +621,7 @@ index dea2823a9d1d69dcb0a4759d8ea9b3015ede20dc..22f3aa1674664906e8ec45372d758d79 } } } -@@ -361,9 +827,14 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche +@@ -358,9 +824,14 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche } private ByteBuffer createExternalStub() { @@ -638,7 +638,7 @@ index dea2823a9d1d69dcb0a4759d8ea9b3015ede20dc..22f3aa1674664906e8ec45372d758d79 return byteBuffer; } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 5133590b1a8c7035a949b85ceefa904b583e4e7f..8ea830f561f5b7d6ff6ca3c38adc7fe8e54e4cc7 100644 +index 3ca75289ac9eb05eadb74c87c0c94cbc026fd08f..1e9e061ec694ad64fc2724b83a66dfec7e069a43 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -24,6 +24,36 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise @@ -744,7 +744,7 @@ index 5133590b1a8c7035a949b85ceefa904b583e4e7f..8ea830f561f5b7d6ff6ca3c38adc7fe8 } @org.jetbrains.annotations.Contract("_, false -> !null") @Nullable private RegionFile getRegionFile(ChunkPos chunkPos, boolean existingOnly) throws IOException { // CraftBukkit -@@ -310,6 +366,19 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -309,6 +365,19 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise } var4 = NbtIo.read(chunkDataInputStream); @@ -765,7 +765,7 @@ index 5133590b1a8c7035a949b85ceefa904b583e4e7f..8ea830f561f5b7d6ff6ca3c38adc7fe8 return var4; diff --git a/net/minecraft/world/level/chunk/storage/RegionFileVersion.java b/net/minecraft/world/level/chunk/storage/RegionFileVersion.java -index 1649119f45d970a9bf1683d676c47ecfc18ad047..cc544f3199cd6af29e50362923d0651705877f16 100644 +index d857a69ad3a0c4eeec52585e8d92f0f8673684f3..e813dedf8d70ae58d595bcd7bc92a1de845fe4a9 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileVersion.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileVersion.java @@ -21,7 +21,7 @@ import org.slf4j.Logger; @@ -778,7 +778,7 @@ index 1649119f45d970a9bf1683d676c47ecfc18ad047..cc544f3199cd6af29e50362923d06517 public static final RegionFileVersion VERSION_GZIP = register( new RegionFileVersion( diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index 0994145addaa06c0094cfd6601d1cc19794343b1..1652513d8a7e6036c82162517948dd22ca98d109 100644 +index b2363fa364be15d0a28f5966615131282b7aaa8f..84c76f622f5a75bdbb2fd2f27670337bee17c96e 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java @@ -120,6 +120,18 @@ public record SerializableChunkData( @@ -800,7 +800,7 @@ index 0994145addaa06c0094cfd6601d1cc19794343b1..1652513d8a7e6036c82162517948dd22 // Paper start - Do not let the server load chunks from newer versions private static final int CURRENT_DATA_VERSION = net.minecraft.SharedConstants.getCurrentVersion().dataVersion().version(); -@@ -548,7 +560,7 @@ public record SerializableChunkData( +@@ -552,7 +564,7 @@ public record SerializableChunkData( compoundTag.putInt("xPos", this.chunkPos.x); compoundTag.putInt("yPos", this.minSectionY); compoundTag.putInt("zPos", this.chunkPos.z); diff --git a/paper-server/patches/features-unapplied/0021-Incremental-chunk-and-player-saving.patch b/paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch similarity index 89% rename from paper-server/patches/features-unapplied/0021-Incremental-chunk-and-player-saving.patch rename to paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch index 4e2a72531e39..e1e46a54f4de 100644 --- a/paper-server/patches/features-unapplied/0021-Incremental-chunk-and-player-saving.patch +++ b/paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Incremental chunk and player saving diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 3228e6c886b62325c3c47a860fcf3d04ea53f764..ff6fc300e9e7d1dbf4b0fa1e59bffe94e1f51259 100644 +index bdaca3647425711ee8b10eb0593a9c3cb4037ede..e7df5f105c721f2e1be1a13694275c0f03b7932b 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -971,7 +971,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> type = poiManager.getType(target); diff --git a/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/net/minecraft/world/entity/ai/village/poi/PoiManager.java -index f67fbc8b6f5f0374f41180ec36de355c7a538aca..179e6d26f85ca7c4812e855dd671d8e92067292b 100644 +index e2b05800736d29f6061a9f2117e51c8a0d5bfeb6..95fa0d9487542ba5308c60d29095efa6c90e86d6 100644 --- a/net/minecraft/world/entity/ai/village/poi/PoiManager.java +++ b/net/minecraft/world/entity/ai/village/poi/PoiManager.java -@@ -257,36 +257,47 @@ public class PoiManager extends SectionStorage im +@@ -256,36 +256,47 @@ public class PoiManager extends SectionStorage im public Optional find( Predicate> typePredicate, Predicate posPredicate, BlockPos pos, int distance, PoiManager.Occupancy status ) { @@ -955,7 +955,7 @@ index f67fbc8b6f5f0374f41180ec36de355c7a538aca..179e6d26f85ca7c4812e855dd671d8e9 .map(poiRecord -> { poiRecord.acquireTicket(); return poiRecord.getPos(); -@@ -301,8 +312,21 @@ public class PoiManager extends SectionStorage im +@@ -300,8 +311,21 @@ public class PoiManager extends SectionStorage im int distance, RandomSource random ) { @@ -980,7 +980,7 @@ index f67fbc8b6f5f0374f41180ec36de355c7a538aca..179e6d26f85ca7c4812e855dd671d8e9 public boolean release(BlockPos pos) { diff --git a/net/minecraft/world/entity/ai/village/poi/PoiSection.java b/net/minecraft/world/entity/ai/village/poi/PoiSection.java -index bba84a390e46a1288cc3cb36ba01941e47a1fec2..df5799fd48b509dc3ba02a21ad39a5add9b114e2 100644 +index f209696e0158df5cd32e9949b3054452d6a3e5cd..49cbdd80057250c37464ca5f5dd39a20dbaa9f2c 100644 --- a/net/minecraft/world/entity/ai/village/poi/PoiSection.java +++ b/net/minecraft/world/entity/ai/village/poi/PoiSection.java @@ -28,7 +28,7 @@ import org.slf4j.Logger; @@ -993,15 +993,16 @@ index bba84a390e46a1288cc3cb36ba01941e47a1fec2..df5799fd48b509dc3ba02a21ad39a5ad private boolean isValid; diff --git a/net/minecraft/world/level/chunk/storage/SectionStorage.java b/net/minecraft/world/level/chunk/storage/SectionStorage.java -index afac559b3c38c4a175070ed823dc8f2c34f4a004..1fc7d8518f7c8d69c2520dbc044a3c202d008756 100644 +index 42699c82321233eaa3647ca0ac4d1f24b6a6227f..a70329731f7d048b52b73f0d12d7436361cfaa96 100644 --- a/net/minecraft/world/level/chunk/storage/SectionStorage.java +++ b/net/minecraft/world/level/chunk/storage/SectionStorage.java -@@ -131,11 +131,11 @@ public class SectionStorage implements AutoCloseable, ca.spottedleaf.moonr +@@ -130,11 +130,12 @@ public class SectionStorage implements AutoCloseable, ca.spottedleaf.moonr + return !this.dirtyChunks.isEmpty(); } - @Nullable -- protected Optional get(long sectionKey) { -+ public Optional get(long sectionKey) { // Paper - public +- protected @Nullable Optional get(long sectionKey) { ++ ++ public @Nullable Optional get(long sectionKey) { // Paper - public return this.storage.get(sectionKey); } @@ -1011,7 +1012,7 @@ index afac559b3c38c4a175070ed823dc8f2c34f4a004..1fc7d8518f7c8d69c2520dbc044a3c20 return Optional.empty(); } else { diff --git a/net/minecraft/world/level/portal/PortalForcer.java b/net/minecraft/world/level/portal/PortalForcer.java -index 0556076d42cff262e8148078410fe6cfa4d8b14b..39418746d5818ce136e79aa1b57b1e6e44e17c37 100644 +index 491affe4343b3843bcdcbae0cca670d120ea24d0..9c552437faa20d10bb5bf67a15282b1e8dec94c5 100644 --- a/net/minecraft/world/level/portal/PortalForcer.java +++ b/net/minecraft/world/level/portal/PortalForcer.java @@ -49,13 +49,38 @@ public class PortalForcer { diff --git a/paper-server/patches/features-unapplied/0023-Flush-regionfiles-on-save-configuration-option.patch b/paper-server/patches/features/0022-Flush-regionfiles-on-save-configuration-option.patch similarity index 100% rename from paper-server/patches/features-unapplied/0023-Flush-regionfiles-on-save-configuration-option.patch rename to paper-server/patches/features/0022-Flush-regionfiles-on-save-configuration-option.patch diff --git a/paper-server/patches/features-unapplied/0024-Optimise-collision-checking-in-player-move-packet-ha.patch b/paper-server/patches/features/0023-Optimise-collision-checking-in-player-move-packet-ha.patch similarity index 94% rename from paper-server/patches/features-unapplied/0024-Optimise-collision-checking-in-player-move-packet-ha.patch rename to paper-server/patches/features/0023-Optimise-collision-checking-in-player-move-packet-ha.patch index 936897f94dde..72c2c9c5484e 100644 --- a/paper-server/patches/features-unapplied/0024-Optimise-collision-checking-in-player-move-packet-ha.patch +++ b/paper-server/patches/features/0023-Optimise-collision-checking-in-player-move-packet-ha.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Optimise collision checking in player move packet handling Move collision logic to just the hasNewCollision call instead of getCubes + hasNewCollision diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c414fe40d 100644 +index 1c5750c258bfb4b551048670a5e73a19a813ec47..ad4d20dda67ffb37e15a1623104a6e23417cc68e 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -613,6 +613,7 @@ public class ServerGamePacketListenerImpl +@@ -623,6 +623,7 @@ public class ServerGamePacketListenerImpl } rootVehicle.move(MoverType.PLAYER, new Vec3(d3, d4, d5)); @@ -17,7 +17,7 @@ index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c double verticalDelta = d4; d3 = d - rootVehicle.getX(); d4 = d1 - rootVehicle.getY(); -@@ -624,12 +625,21 @@ public class ServerGamePacketListenerImpl +@@ -634,12 +635,21 @@ public class ServerGamePacketListenerImpl d7 = d3 * d3 + d4 * d4 + d5 * d5; boolean flag1 = false; if (d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot @@ -42,7 +42,7 @@ index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c rootVehicle.absSnapTo(x, y, z, f, f1); this.send(ClientboundMoveVehiclePacket.fromEntity(rootVehicle)); rootVehicle.removeLatestMovementRecording(); -@@ -708,9 +718,32 @@ public class ServerGamePacketListenerImpl +@@ -718,9 +728,32 @@ public class ServerGamePacketListenerImpl } private boolean noBlocksAround(Entity entity) { @@ -78,7 +78,7 @@ index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c } @Override -@@ -1485,7 +1518,7 @@ public class ServerGamePacketListenerImpl +@@ -1509,7 +1542,7 @@ public class ServerGamePacketListenerImpl } } @@ -87,7 +87,7 @@ index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c d3 = d - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above d4 = d1 - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above d5 = d2 - this.lastGoodZ; // Paper - diff on change, used for checking large move vectors above -@@ -1524,6 +1557,7 @@ public class ServerGamePacketListenerImpl +@@ -1548,6 +1581,7 @@ public class ServerGamePacketListenerImpl boolean flag1 = this.player.verticalCollisionBelow; this.player.move(MoverType.PLAYER, new Vec3(d3, d4, d5)); this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move @@ -95,7 +95,7 @@ index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c // Paper start - prevent position desync if (this.awaitingPositionFromClient != null) { return; // ... thanks Mojang for letting move calls teleport across dimensions. -@@ -1556,7 +1590,17 @@ public class ServerGamePacketListenerImpl +@@ -1581,7 +1615,17 @@ public class ServerGamePacketListenerImpl } // Paper start - Add fail move event @@ -114,7 +114,7 @@ index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c if (!allowMovement) { io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK, toX, toY, toZ, toYaw, toPitch, false); -@@ -1692,7 +1736,7 @@ public class ServerGamePacketListenerImpl +@@ -1716,7 +1760,7 @@ public class ServerGamePacketListenerImpl private boolean updateAwaitingTeleport() { if (this.awaitingPositionFromClient != null) { @@ -123,7 +123,7 @@ index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c this.awaitingTeleportTime = this.tickCount; this.teleport( this.awaitingPositionFromClient.x, -@@ -1711,6 +1755,34 @@ public class ServerGamePacketListenerImpl +@@ -1735,6 +1779,34 @@ public class ServerGamePacketListenerImpl } } diff --git a/paper-server/patches/features-unapplied/0025-Improve-keepalive-ping-system.patch b/paper-server/patches/features/0024-Improve-keepalive-ping-system.patch similarity index 99% rename from paper-server/patches/features-unapplied/0025-Improve-keepalive-ping-system.patch rename to paper-server/patches/features/0024-Improve-keepalive-ping-system.patch index 3f4fcd3ca57f..f046496ff6a4 100644 --- a/paper-server/patches/features-unapplied/0025-Improve-keepalive-ping-system.patch +++ b/paper-server/patches/features/0024-Improve-keepalive-ping-system.patch @@ -100,7 +100,7 @@ index 21d50675bfe90c2276890779eb23de58ac915b9a..7be34e37562875313b8e43357921b5fe } } diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 39fe30969687d4675fec40e7df9c1f85971683f6..c6db2c96db96453daaf49779f588f75f7c3d3d60 100644 +index 079ab378920c0e52ef4e42ef20b37bd389f40870..b8a4b4cc02a2fc6b70f4b840796eed501aad6239 100644 --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java @@ -39,12 +39,13 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack diff --git a/paper-server/patches/features-unapplied/0026-Optimise-EntityScheduler-ticking.patch b/paper-server/patches/features/0025-Optimise-EntityScheduler-ticking.patch similarity index 91% rename from paper-server/patches/features-unapplied/0026-Optimise-EntityScheduler-ticking.patch rename to paper-server/patches/features/0025-Optimise-EntityScheduler-ticking.patch index 62505d9e534a..85beda79758c 100644 --- a/paper-server/patches/features-unapplied/0026-Optimise-EntityScheduler-ticking.patch +++ b/paper-server/patches/features/0025-Optimise-EntityScheduler-ticking.patch @@ -8,7 +8,7 @@ the EntityScheduler. We can avoid iterating the entire entity list by tracking which schedulers have any tasks scheduled. diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java -index a2fbc13105673e926cbaed69221826ebd392140f..a42938e1abd371dba6806e65552fde71b178a096 100644 +index 2bc436cdf5180a7943c45fabb9fbbedae6f7db56..f312a7f5b1b2a777ab36b94ce7cbf3873f5e88bc 100644 --- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java @@ -96,6 +96,7 @@ public final class ServerEntityLookup extends EntityLookup { @@ -20,10 +20,10 @@ index a2fbc13105673e926cbaed69221826ebd392140f..a42938e1abd371dba6806e65552fde71 @Override diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index ff6fc300e9e7d1dbf4b0fa1e59bffe94e1f51259..d58ee455467b2c8307ea20f8a9d88f0f18053fc1 100644 +index e7df5f105c721f2e1be1a13694275c0f03b7932b..0f56d83701ac770799970fceeb73eab57adf5c38 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1736,33 +1736,22 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop Date: Tue, 25 Nov 2025 21:04:10 -0700 Subject: [PATCH 109/112] Revert Improve exact choice recipe ingredients for now --- ...ove-exact-choice-recipe-ingredients.patch} | 87 +++++++------------ ...culate-regionfile-header-if-it-is-co.patch | 8 +- 2 files changed, 37 insertions(+), 58 deletions(-) rename paper-server/patches/{features/0016-Improve-exact-choice-recipe-ingredients.patch => features-unapplied/0017-Improve-exact-choice-recipe-ingredients.patch} (90%) diff --git a/paper-server/patches/features/0016-Improve-exact-choice-recipe-ingredients.patch b/paper-server/patches/features-unapplied/0017-Improve-exact-choice-recipe-ingredients.patch similarity index 90% rename from paper-server/patches/features/0016-Improve-exact-choice-recipe-ingredients.patch rename to paper-server/patches/features-unapplied/0017-Improve-exact-choice-recipe-ingredients.patch index 4971dc26805a..813b82b4dc9c 100644 --- a/paper-server/patches/features/0016-Improve-exact-choice-recipe-ingredients.patch +++ b/paper-server/patches/features-unapplied/0017-Improve-exact-choice-recipe-ingredients.patch @@ -224,11 +224,11 @@ index 76eda3bd8c513c7e42ceedf1aa605fb6df8b7019..41e59f3739945ca7f6ab710c993b5c0f return i; } diff --git a/net/minecraft/world/entity/player/StackedContents.java b/net/minecraft/world/entity/player/StackedContents.java -index bc4f7d16365dffc87b1eef8aa5791a5cb595ee78..cbb37480c19b210cf83999247c1d670c9df2d150 100644 +index a4b528574ab371af94b0e07819e471cec94da244..a3fea6c8397046596afe3c8b5589f2ed37fcdfc3 100644 --- a/net/minecraft/world/entity/player/StackedContents.java +++ b/net/minecraft/world/entity/player/StackedContents.java @@ -13,7 +13,7 @@ import java.util.List; - import org.jspecify.annotations.Nullable; + import javax.annotation.Nullable; public class StackedContents { - public final Reference2IntOpenHashMap amounts = new Reference2IntOpenHashMap<>(); @@ -262,11 +262,11 @@ index bc4f7d16365dffc87b1eef8aa5791a5cb595ee78..cbb37480c19b210cf83999247c1d670c if (intValue > i1) { if (ingredientInfo.acceptsItem(entry.getKey())) { diff --git a/net/minecraft/world/entity/player/StackedItemContents.java b/net/minecraft/world/entity/player/StackedItemContents.java -index e0121e9c8439e32b7ef064c06942ccd5dd74987d..cb3ad6141e88cd86afd6d00db31ca9133b4d6e5a 100644 +index 6bbe2e51ef71d193e0a5d3cace2b0ad1760ce759..83ccde54c625d40dc595e000c533f60aa929bd5a 100644 --- a/net/minecraft/world/entity/player/StackedItemContents.java +++ b/net/minecraft/world/entity/player/StackedItemContents.java -@@ -9,9 +9,14 @@ import net.minecraft.world.item.crafting.Recipe; - import org.jspecify.annotations.Nullable; +@@ -9,9 +9,14 @@ import net.minecraft.world.item.crafting.PlacementInfo; + import net.minecraft.world.item.crafting.Recipe; public class StackedItemContents { - private final StackedContents> raw = new StackedContents<>(); @@ -281,7 +281,7 @@ index e0121e9c8439e32b7ef064c06942ccd5dd74987d..cb3ad6141e88cd86afd6d00db31ca913 if (Inventory.isUsableForCrafting(stack)) { this.accountStack(stack); } -@@ -24,20 +29,21 @@ public class StackedItemContents { +@@ -24,34 +29,51 @@ public class StackedItemContents { public void accountStack(ItemStack stack, int maxStackSize) { if (!stack.isEmpty()) { int min = Math.min(maxStackSize, stack.getCount()); @@ -291,39 +291,12 @@ index e0121e9c8439e32b7ef064c06942ccd5dd74987d..cb3ad6141e88cd86afd6d00db31ca913 } } -- public boolean canCraft(Recipe recipe, StackedContents.@Nullable Output> output) { -+ public boolean canCraft(Recipe recipe, StackedContents.@Nullable Output> output) { // Paper - Improve exact choice recipe ingredients +- public boolean canCraft(Recipe recipe, @Nullable StackedContents.Output> output) { ++ public boolean canCraft(Recipe recipe, @Nullable StackedContents.Output output) { // Paper - Improve exact choice recipe ingredients return this.canCraft(recipe, 1, output); } -- public boolean canCraft(Recipe recipe, int maxCount, StackedContents.@Nullable Output> output) { -+ public boolean canCraft(Recipe recipe, int maxCount, StackedContents.@Nullable Output output) { // Paper - Improve exact choice recipe ingredients - PlacementInfo placementInfo = recipe.placementInfo(); - return !placementInfo.isImpossibleToPlace() && this.canCraft(placementInfo.ingredients(), maxCount, output); - } - -- public boolean canCraft(List>> ingredients, StackedContents.@Nullable Output> output) { -+ public boolean canCraft(List>> ingredients, StackedContents.@Nullable Output> output) { // Paper - Improve exact choice recipe ingredients - return this.canCraft(ingredients, 1, output); - } - -@@ -47,7 +53,7 @@ public class StackedItemContents { - return this.raw.tryPick(ingredients, maxCount, output); - } - -- public int getBiggestCraftableStack(Recipe recipe, StackedContents.@Nullable Output> output) { -+ public int getBiggestCraftableStack(Recipe recipe, StackedContents.@Nullable Output> output) { // Paper - Improve exact choice recipe ingredients - return this.getBiggestCraftableStack(recipe, Integer.MAX_VALUE, output); - } - -@@ -55,6 +61,44 @@ public class StackedItemContents { - return this.raw.tryPickAll(recipe.placementInfo().ingredients(), maxCount, output); - } - -+ public boolean canCraft(Recipe recipe, @Nullable StackedContents.Output output) { // Paper - Improve exact choice recipe ingredients -+ return this.canCraft(recipe, 1, output); -+ } -+ +- public boolean canCraft(Recipe recipe, int maxCount, @Nullable StackedContents.Output> output) { + // Paper start - Improve exact choice recipe ingredients + public void initializeExtras(final Recipe recipe, @Nullable final net.minecraft.world.item.crafting.CraftingInput input) { + if (this.extrasMap == null) { @@ -340,27 +313,33 @@ index e0121e9c8439e32b7ef064c06942ccd5dd74987d..cb3ad6141e88cd86afd6d00db31ca913 + } + // Paper end - Improve exact choice recipe ingredients + ++ public boolean canCraft(Recipe recipe, int maxCount, @Nullable StackedContents.Output output) { // Paper - Improve exact choice recipe ingredients + PlacementInfo placementInfo = recipe.placementInfo(); + return !placementInfo.isImpossibleToPlace() && this.canCraft(placementInfo.ingredients(), maxCount, output); + } + +- public boolean canCraft(List>> ingredients, @Nullable StackedContents.Output> output) { + public boolean canCraft(List> ingredients, @Nullable StackedContents.Output output) { // Paper - Improve exact choice recipe ingredients -+ return this.canCraft(ingredients, 1, output); -+ } -+ -+ private boolean canCraft( + return this.canCraft(ingredients, 1, output); + } + + private boolean canCraft( +- List>> ingredients, int maxCount, @Nullable StackedContents.Output> output + List> ingredients, int maxCount, @Nullable StackedContents.Output output // Paper - Improve exact choice recipe ingredients -+ ) { -+ return this.raw.tryPick(ingredients, maxCount, output); -+ } -+ + ) { + return this.raw.tryPick(ingredients, maxCount, output); + } + +- public int getBiggestCraftableStack(Recipe recipe, @Nullable StackedContents.Output> output) { + public int getBiggestCraftableStack(Recipe recipe, @Nullable StackedContents.Output output) { // Paper - Improve exact choice recipe ingredients -+ return this.getBiggestCraftableStack(recipe, Integer.MAX_VALUE, output); -+ } -+ + return this.getBiggestCraftableStack(recipe, Integer.MAX_VALUE, output); + } + +- public int getBiggestCraftableStack(Recipe recipe, int maxCount, @Nullable StackedContents.Output> output) { + public int getBiggestCraftableStack(Recipe recipe, int maxCount, @Nullable StackedContents.Output output) { // Paper - Improve exact choice recipe ingredients -+ return this.raw.tryPickAll(recipe.placementInfo().ingredients(), maxCount, output); -+ } -+ - public void clear() { - this.raw.clear(); + return this.raw.tryPickAll(recipe.placementInfo().ingredients(), maxCount, output); } + diff --git a/net/minecraft/world/item/crafting/Ingredient.java b/net/minecraft/world/item/crafting/Ingredient.java index e43641650d66a62b5b7b58c43833ce504970ab1e..879c8fe1f20decc793cfa39e686b61d521bd76ba 100644 --- a/net/minecraft/world/item/crafting/Ingredient.java @@ -447,10 +426,10 @@ index e43641650d66a62b5b7b58c43833ce504970ab1e..879c8fe1f20decc793cfa39e686b61d5 .unwrap() .map(SlotDisplay.TagSlotDisplay::new, list -> new SlotDisplay.Composite(list.stream().map(Ingredient::displayForSingleItem).toList())); diff --git a/net/minecraft/world/item/crafting/ShapelessRecipe.java b/net/minecraft/world/item/crafting/ShapelessRecipe.java -index 43c8b7a027c519196852602d136a31f8c392b786..28d085fce206634ee88c492e06fdbf63a618ee12 100644 +index fb317eafeed39adff793bffa8f6b21c37a32086c..d601b54b1de2f2ae44fe2b20c8116c71a6340e45 100644 --- a/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -71,13 +71,18 @@ public class ShapelessRecipe implements CraftingRecipe { +@@ -72,13 +72,18 @@ public class ShapelessRecipe implements CraftingRecipe { @Override public boolean matches(CraftingInput input, Level level) { diff --git a/paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch index cd19a284f226..0865b24e7776 100644 --- a/paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch +++ b/paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch @@ -55,7 +55,7 @@ index 64a718c98f799c62a5bb28e1e8e5f66cc96c915d..666f2e967c99f78422c83fb20e1a3bf3 this.used.set(sectorOffset, sectorOffset + sectorCount); } diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java -index f2ef716788c1ed1933139c1f53a6d73769362809..2feeacf16db69c53e6844cf3a8e5bab3b91255e5 100644 +index f2ef716788c1ed1933139c1f53a6d73769362809..c6adcb44bc96eaeba74bfc228a6a61765b1628e7 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -46,6 +46,363 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche @@ -72,7 +72,7 @@ index f2ef716788c1ed1933139c1f53a6d73769362809..2feeacf16db69c53e6844cf3a8e5bab3 + + private static final net.minecraft.nbt.CompoundTag OVERSIZED_COMPOUND = new net.minecraft.nbt.CompoundTag(); + -+ private @Nullable net.minecraft.nbt.CompoundTag attemptRead(long sector, int chunkDataLength, long fileLength) throws IOException { ++ private net.minecraft.nbt.@Nullable CompoundTag attemptRead(long sector, int chunkDataLength, long fileLength) throws IOException { + try { + if (chunkDataLength < 0) { + return null; @@ -778,7 +778,7 @@ index d857a69ad3a0c4eeec52585e8d92f0f8673684f3..e813dedf8d70ae58d595bcd7bc92a1de public static final RegionFileVersion VERSION_GZIP = register( new RegionFileVersion( diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index b2363fa364be15d0a28f5966615131282b7aaa8f..84c76f622f5a75bdbb2fd2f27670337bee17c96e 100644 +index b2363fa364be15d0a28f5966615131282b7aaa8f..68874c0b6f6f7c5d8e3a79c9a7b391b9624ab748 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java @@ -120,6 +120,18 @@ public record SerializableChunkData( @@ -788,7 +788,7 @@ index b2363fa364be15d0a28f5966615131282b7aaa8f..84c76f622f5a75bdbb2fd2f27670337b + // Paper start - Attempt to recalculate regionfile header if it is corrupt + // TODO: Check on update + public static long getLastWorldSaveTime(final CompoundTag chunkData) { -+ final int dataVersion = ChunkStorage.getVersion(chunkData); ++ final int dataVersion = NbtUtils.getDataVersion(chunkData); + if (dataVersion < 2842) { // Level tag is removed after this version + final CompoundTag levelData = chunkData.getCompoundOrEmpty("Level"); + return levelData.getLongOr("LastUpdate", 0L); From 590724a52093f4964e1a254e0f5c53aa2c70e664 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Wed, 26 Nov 2025 09:23:38 -0700 Subject: [PATCH 110/112] per-player mob spawns & optimize hoppers --- ...data-to-disk-if-it-serializes-witho.patch} | 0 ...17-Entity-load-save-limit-per-chunk.patch} | 0 ...ulate-regionfile-header-if-it-is-co.patch} | 0 ...Incremental-chunk-and-player-saving.patch} | 0 ...=> 0020-Optimise-general-POI-access.patch} | 0 ...nfiles-on-save-configuration-option.patch} | 0 ...n-checking-in-player-move-packet-ha.patch} | 0 ... 0023-Improve-keepalive-ping-system.patch} | 0 ...24-Optimise-EntityScheduler-ticking.patch} | 0 ...0025-Optional-per-player-mob-spawns.patch} | 49 +++++++++---------- ...g-PreCreatureSpawnEvent-with-per-pl.patch} | 18 +++---- .../0027-Optimize-Hoppers.patch} | 42 ++++++++-------- 12 files changed, 54 insertions(+), 55 deletions(-) rename paper-server/patches/features/{0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch => 0016-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch} (100%) rename paper-server/patches/features/{0018-Entity-load-save-limit-per-chunk.patch => 0017-Entity-load-save-limit-per-chunk.patch} (100%) rename paper-server/patches/features/{0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch => 0018-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch} (100%) rename paper-server/patches/features/{0020-Incremental-chunk-and-player-saving.patch => 0019-Incremental-chunk-and-player-saving.patch} (100%) rename paper-server/patches/features/{0021-Optimise-general-POI-access.patch => 0020-Optimise-general-POI-access.patch} (100%) rename paper-server/patches/features/{0022-Flush-regionfiles-on-save-configuration-option.patch => 0021-Flush-regionfiles-on-save-configuration-option.patch} (100%) rename paper-server/patches/features/{0023-Optimise-collision-checking-in-player-move-packet-ha.patch => 0022-Optimise-collision-checking-in-player-move-packet-ha.patch} (100%) rename paper-server/patches/features/{0024-Improve-keepalive-ping-system.patch => 0023-Improve-keepalive-ping-system.patch} (100%) rename paper-server/patches/features/{0025-Optimise-EntityScheduler-ticking.patch => 0024-Optimise-EntityScheduler-ticking.patch} (100%) rename paper-server/patches/{features-unapplied/0027-Optional-per-player-mob-spawns.patch => features/0025-Optional-per-player-mob-spawns.patch} (88%) rename paper-server/patches/{features-unapplied/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch => features/0026-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch} (87%) rename paper-server/patches/{features-unapplied/0029-Optimize-Hoppers.patch => features/0027-Optimize-Hoppers.patch} (95%) diff --git a/paper-server/patches/features/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch b/paper-server/patches/features/0016-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch similarity index 100% rename from paper-server/patches/features/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch rename to paper-server/patches/features/0016-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch diff --git a/paper-server/patches/features/0018-Entity-load-save-limit-per-chunk.patch b/paper-server/patches/features/0017-Entity-load-save-limit-per-chunk.patch similarity index 100% rename from paper-server/patches/features/0018-Entity-load-save-limit-per-chunk.patch rename to paper-server/patches/features/0017-Entity-load-save-limit-per-chunk.patch diff --git a/paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/paper-server/patches/features/0018-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch similarity index 100% rename from paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch rename to paper-server/patches/features/0018-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch diff --git a/paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch b/paper-server/patches/features/0019-Incremental-chunk-and-player-saving.patch similarity index 100% rename from paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch rename to paper-server/patches/features/0019-Incremental-chunk-and-player-saving.patch diff --git a/paper-server/patches/features/0021-Optimise-general-POI-access.patch b/paper-server/patches/features/0020-Optimise-general-POI-access.patch similarity index 100% rename from paper-server/patches/features/0021-Optimise-general-POI-access.patch rename to paper-server/patches/features/0020-Optimise-general-POI-access.patch diff --git a/paper-server/patches/features/0022-Flush-regionfiles-on-save-configuration-option.patch b/paper-server/patches/features/0021-Flush-regionfiles-on-save-configuration-option.patch similarity index 100% rename from paper-server/patches/features/0022-Flush-regionfiles-on-save-configuration-option.patch rename to paper-server/patches/features/0021-Flush-regionfiles-on-save-configuration-option.patch diff --git a/paper-server/patches/features/0023-Optimise-collision-checking-in-player-move-packet-ha.patch b/paper-server/patches/features/0022-Optimise-collision-checking-in-player-move-packet-ha.patch similarity index 100% rename from paper-server/patches/features/0023-Optimise-collision-checking-in-player-move-packet-ha.patch rename to paper-server/patches/features/0022-Optimise-collision-checking-in-player-move-packet-ha.patch diff --git a/paper-server/patches/features/0024-Improve-keepalive-ping-system.patch b/paper-server/patches/features/0023-Improve-keepalive-ping-system.patch similarity index 100% rename from paper-server/patches/features/0024-Improve-keepalive-ping-system.patch rename to paper-server/patches/features/0023-Improve-keepalive-ping-system.patch diff --git a/paper-server/patches/features/0025-Optimise-EntityScheduler-ticking.patch b/paper-server/patches/features/0024-Optimise-EntityScheduler-ticking.patch similarity index 100% rename from paper-server/patches/features/0025-Optimise-EntityScheduler-ticking.patch rename to paper-server/patches/features/0024-Optimise-EntityScheduler-ticking.patch diff --git a/paper-server/patches/features-unapplied/0027-Optional-per-player-mob-spawns.patch b/paper-server/patches/features/0025-Optional-per-player-mob-spawns.patch similarity index 88% rename from paper-server/patches/features-unapplied/0027-Optional-per-player-mob-spawns.patch rename to paper-server/patches/features/0025-Optional-per-player-mob-spawns.patch index 9cf39d16b9b8..a02ddfce44af 100644 --- a/paper-server/patches/features-unapplied/0027-Optional-per-player-mob-spawns.patch +++ b/paper-server/patches/features/0025-Optional-per-player-mob-spawns.patch @@ -5,16 +5,14 @@ Subject: [PATCH] Optional per player mob spawns diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index ccf5ee2d8a84c7cd136bf45ec19d6591586f5fd8..2aad9f90a7c1815ec4855d338848657dc0d9a3c7 100644 +index dfd7a60192c46f01d245045adf86dec42eec4da7..0bf14bf6ece5136f9c9972439076c33a7036be5c 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -241,11 +241,29 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -247,11 +247,29 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP // Paper - rewrite chunk system } - // Paper start -- public int getMobCountNear(final ServerPlayer player, final net.minecraft.world.entity.MobCategory mobCategory) { -- return -1; + // Paper start - Optional per player mob spawns + public void updatePlayerMobTypeMap(final Entity entity) { + if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { @@ -32,21 +30,22 @@ index ccf5ee2d8a84c7cd136bf45ec19d6591586f5fd8..2aad9f90a7c1815ec4855d338848657d + for (int i = 0, len = inRange.size(); i < len; i++) { + ++(backingSet[i].mobCounts[index]); + } - } -- // Paper end ++ } + -+ public int getMobCountNear(final ServerPlayer player, final net.minecraft.world.entity.MobCategory mobCategory) { + public int getMobCountNear(final ServerPlayer player, final net.minecraft.world.entity.MobCategory mobCategory) { +- return -1; + return player.mobCounts[mobCategory.ordinal()]; -+ } + } +- // Paper end + // Paper end - Optional per player mob spawns protected ChunkGenerator generator() { return this.worldGenContext.generator(); diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 9238182528b26f60001f6588b202a58b43cd0ea6..f31b7ddddf80e58c2323d85ff48a98c3e92e33e0 100644 +index 75fe6e026e3f91b66dcf5b97a86491d5277f7661..9b8222bda0f119f272d90f980c9f9540211af84a 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -536,9 +536,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -530,9 +530,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon private void tickChunks(ProfilerFiller profiler, long timeInhabited) { profiler.push("naturalSpawnCount"); int naturalSpawnChunkCount = this.distanceManager.getNaturalSpawnChunkCount(); @@ -66,9 +65,9 @@ index 9238182528b26f60001f6588b202a58b43cd0ea6..f31b7ddddf80e58c2323d85ff48a98c3 + } + // Paper end - Optional per player mob spawns this.lastSpawnState = spawnState; - boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit - int _int = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); -@@ -566,7 +575,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + boolean flag = this.level.getGameRules().get(GameRules.SPAWN_MOBS) && !this.level.players().isEmpty(); // CraftBukkit + int i = this.level.getGameRules().get(GameRules.RANDOM_TICK_SPEED); +@@ -560,7 +569,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon profiler.popPush("shuffleSpawningChunks"); // Paper start - chunk tick iteration optimisation this.shuffleRandom.setSeed(this.level.random.nextLong()); @@ -78,12 +77,12 @@ index 9238182528b26f60001f6588b202a58b43cd0ea6..f31b7ddddf80e58c2323d85ff48a98c3 profiler.popPush("tickSpawningChunks"); diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 691df6f92af8cbb7b5b2dd863678258e78e1884b..ebca471ba92f49b00707a3d193cd424a94b956e4 100644 +index d72f208f6924aeb1f6531c53f8f01851fa26f196..b3d9c359d091637e6911b17483cf594099aa61f4 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -419,6 +419,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -409,6 +409,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc public boolean queueHealthUpdatePacket; - public @Nullable net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; + public net.minecraft.network.protocol.game.@Nullable ClientboundSetHealthPacket queuedHealthUpdatePacket; // Paper end - cancellable death event + // Paper start - Optional per player mob spawns + public static final int MOBCATEGORY_TOTAL_ENUMS = net.minecraft.world.entity.MobCategory.values().length; @@ -93,10 +92,10 @@ index 691df6f92af8cbb7b5b2dd863678258e78e1884b..ebca471ba92f49b00707a3d193cd424a public @Nullable String lastKnownName; // Better rename detection public String displayName; diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java -index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a81fd38b82 100644 +index 6840ff5684e152c33773fc376fc2e3f1c6d56c76..253268a70179139daa9ad587f9e0e2f48d61beb9 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -68,6 +68,14 @@ public final class NaturalSpawner { +@@ -69,6 +69,14 @@ public final class NaturalSpawner { public static NaturalSpawner.SpawnState createState( int spawnableChunkCount, Iterable entities, NaturalSpawner.ChunkGetter chunkGetter, LocalMobCapCalculator calculator ) { @@ -111,7 +110,7 @@ index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a8 PotentialCalculator potentialCalculator = new PotentialCalculator(); Object2IntOpenHashMap map = new Object2IntOpenHashMap<>(); -@@ -89,11 +97,16 @@ public final class NaturalSpawner { +@@ -90,11 +98,16 @@ public final class NaturalSpawner { potentialCalculator.addCharge(entity.blockPosition(), mobSpawnCost.charge()); } @@ -129,7 +128,7 @@ index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a8 }); } } -@@ -131,7 +144,7 @@ public final class NaturalSpawner { +@@ -132,7 +145,7 @@ public final class NaturalSpawner { if ((spawnFriendlies || !mobCategory.isFriendly()) && (spawnEnemies || mobCategory.isFriendly()) && (spawnPassives || !mobCategory.isPersistent()) @@ -138,7 +137,7 @@ index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a8 list.add(mobCategory); // CraftBukkit end } -@@ -145,8 +158,37 @@ public final class NaturalSpawner { +@@ -146,8 +159,37 @@ public final class NaturalSpawner { profilerFiller.push("spawner"); for (MobCategory mobCategory : categories) { @@ -178,7 +177,7 @@ index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a8 } } -@@ -166,9 +208,16 @@ public final class NaturalSpawner { +@@ -167,9 +209,16 @@ public final class NaturalSpawner { public static void spawnCategoryForChunk( MobCategory category, ServerLevel level, LevelChunk chunk, NaturalSpawner.SpawnPredicate filter, NaturalSpawner.AfterSpawnCallback callback ) { @@ -196,7 +195,7 @@ index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a8 } } -@@ -185,6 +234,12 @@ public final class NaturalSpawner { +@@ -186,6 +235,12 @@ public final class NaturalSpawner { NaturalSpawner.SpawnPredicate filter, NaturalSpawner.AfterSpawnCallback callback ) { @@ -209,7 +208,7 @@ index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a8 StructureManager structureManager = level.structureManager(); ChunkGenerator generator = level.getChunkSource().getGenerator(); int y = pos.getY(); -@@ -249,9 +304,14 @@ public final class NaturalSpawner { +@@ -250,9 +305,14 @@ public final class NaturalSpawner { ++i; ++i3; callback.run(mobForSpawn, chunk); @@ -225,7 +224,7 @@ index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a8 return; } -@@ -566,7 +626,7 @@ public final class NaturalSpawner { +@@ -564,7 +624,7 @@ public final class NaturalSpawner { this.spawnPotential.addCharge(blockPos, d); MobCategory category = type.getCategory(); this.mobCategoryCounts.addTo(category, 1); diff --git a/paper-server/patches/features-unapplied/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch b/paper-server/patches/features/0026-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch similarity index 87% rename from paper-server/patches/features-unapplied/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch rename to paper-server/patches/features/0026-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch index 7b5342a2fb32..07ab47f034e4 100644 --- a/paper-server/patches/features-unapplied/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch +++ b/paper-server/patches/features/0026-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Improve cancelling PreCreatureSpawnEvent with per player mob diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 2aad9f90a7c1815ec4855d338848657dc0d9a3c7..ce53eb1e966e07b04e6a13785a858a3318b2c573 100644 +index 0bf14bf6ece5136f9c9972439076c33a7036be5c..6f32fb08788605ebf00839d412a7f4d78137aadf 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -260,8 +260,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -266,8 +266,25 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } } @@ -33,14 +33,14 @@ index 2aad9f90a7c1815ec4855d338848657dc0d9a3c7..ce53eb1e966e07b04e6a13785a858a33 public int getMobCountNear(final ServerPlayer player, final net.minecraft.world.entity.MobCategory mobCategory) { - return player.mobCounts[mobCategory.ordinal()]; + return player.mobCounts[mobCategory.ordinal()] + player.mobBackoffCounts[mobCategory.ordinal()]; // Paper - per player mob count backoff - } + } // Paper end - Optional per player mob spawns diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index f31b7ddddf80e58c2323d85ff48a98c3e92e33e0..488fc6088d69148f60a913b42ffb964c48eb0324 100644 +index 9b8222bda0f119f272d90f980c9f9540211af84a..af67b07722bb0125acd081dab767d7e7b360623b 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -541,7 +541,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -535,7 +535,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled // re-set mob counts for (ServerPlayer player : this.level.players) { @@ -60,10 +60,10 @@ index f31b7ddddf80e58c2323d85ff48a98c3e92e33e0..488fc6088d69148f60a913b42ffb964c spawnState = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, null, true); } else { diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index ebca471ba92f49b00707a3d193cd424a94b956e4..e2fdaf72b9714d919938b3e82328971c887c7ab1 100644 +index b3d9c359d091637e6911b17483cf594099aa61f4..791296eb42c961287db7ce8e56959910cc3b04e1 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -423,6 +423,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -413,6 +413,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc public static final int MOBCATEGORY_TOTAL_ENUMS = net.minecraft.world.entity.MobCategory.values().length; public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper end - Optional per player mob spawns @@ -72,10 +72,10 @@ index ebca471ba92f49b00707a3d193cd424a94b956e4..e2fdaf72b9714d919938b3e82328971c public @Nullable String lastKnownName; // Better rename detection public String displayName; diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java -index 47384eedbb67f2ea50a3846f8499f6a81fd38b82..911c5099a2bbb3e955c9314219114873642c7355 100644 +index 253268a70179139daa9ad587f9e0e2f48d61beb9..4e5078495037078922ab6350a500acdabe177ca5 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -281,6 +281,11 @@ public final class NaturalSpawner { +@@ -282,6 +282,11 @@ public final class NaturalSpawner { // Paper start - PreCreatureSpawnEvent PreSpawnStatus doSpawning = isValidSpawnPostitionForType(level, category, structureManager, generator, spawnerData, mutableBlockPos, d2); diff --git a/paper-server/patches/features-unapplied/0029-Optimize-Hoppers.patch b/paper-server/patches/features/0027-Optimize-Hoppers.patch similarity index 95% rename from paper-server/patches/features-unapplied/0029-Optimize-Hoppers.patch rename to paper-server/patches/features/0027-Optimize-Hoppers.patch index 1f428c03f88e..a8091d50ecbb 100644 --- a/paper-server/patches/features-unapplied/0029-Optimize-Hoppers.patch +++ b/paper-server/patches/features/0027-Optimize-Hoppers.patch @@ -48,22 +48,22 @@ index 0000000000000000000000000000000000000000..24a2090e068ad3c0d08705050944abdf + } +} diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index d58ee455467b2c8307ea20f8a9d88f0f18053fc1..f63a5567a2e845de904c2dacfbb875049e3e0c65 100644 +index 0f56d83701ac770799970fceeb73eab57adf5c38..ba4a3f33e10111d6b278d27938907c76ff28c88b 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1791,6 +1791,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper - BlockPhysicsEvent serverLevel.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent serverLevel.updateLagCompensationTick(); // Paper - lag compensation + net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = serverLevel.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers - profilerFiller.push(() -> serverLevel + " " + serverLevel.dimension().location()); + profilerFiller.push(() -> serverLevel + " " + serverLevel.dimension().identifier()); /* Drop global time updates if (this.tickCount % 20 == 0) { diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index fc6f17db0bf4b4ea9f913bbf5d4c1d5cbb10dc03..47862c00e9e01c7cdd5fcd808cc1b76740b85a57 100644 +index c91797613b68cd9c624779a2c7cd3e76edf9423e..b00ad17852e9890f848fc2124e2287885c2b9c5d 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -808,10 +808,16 @@ public final class ItemStack implements DataComponentHolder { +@@ -813,10 +813,16 @@ public final class ItemStack implements DataComponentHolder { } public ItemStack copy() { @@ -83,10 +83,10 @@ index fc6f17db0bf4b4ea9f913bbf5d4c1d5cbb10dc03..47862c00e9e01c7cdd5fcd808cc1b767 return itemStack; } diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java -index bdbc6df5787cd1ca77541bc0602ec563e8799fbc..bd038bdaa00fb1e09b098b4d2809d17e2382288b 100644 +index 647ef4c1715e151711e3de70dfcbbc5037ac12ab..fb22ebe9758014ebf2aebcda21155f1c4c83fafe 100644 --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -37,6 +37,7 @@ import net.minecraft.world.level.storage.ValueOutput; +@@ -37,6 +37,7 @@ import org.jspecify.annotations.Nullable; import org.slf4j.Logger; public abstract class BlockEntity implements DebugValueSource { @@ -94,7 +94,7 @@ index bdbc6df5787cd1ca77541bc0602ec563e8799fbc..bd038bdaa00fb1e09b098b4d2809d17e // CraftBukkit start - data containers private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer; -@@ -229,6 +230,7 @@ public abstract class BlockEntity implements DebugValueSource { +@@ -226,6 +227,7 @@ public abstract class BlockEntity implements DebugValueSource { public void setChanged() { if (this.level != null) { @@ -103,7 +103,7 @@ index bdbc6df5787cd1ca77541bc0602ec563e8799fbc..bd038bdaa00fb1e09b098b4d2809d17e } } diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index 96414f8bce0a89f11c64bf26924fc7bb4588e9be..28348e3881c3c8591053a01b193fb2a956f79726 100644 +index dbd03aa40f69522bc197ecaab88f53fd8bb6d7a9..ba554c02890d66a872f1c19723eb55b23ab7add2 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -144,18 +144,56 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @@ -628,21 +628,21 @@ index 96414f8bce0a89f11c64bf26924fc7bb4588e9be..28348e3881c3c8591053a01b193fb2a9 stack = leftover; // Paper - Make hoppers respect inventory max stack size flag = true; } else if (canMergeItems(item, stack)) { -@@ -526,13 +775,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -522,12 +771,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + } - @Nullable - public static Container getContainerAt(Level level, BlockPos pos) { + public static @Nullable Container getContainerAt(Level level, BlockPos pos) { - return getContainerAt(level, pos, level.getBlockState(pos), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); + return getContainerAt(level, pos, level.getBlockState(pos), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, true); // Paper - Optimize hoppers } - @Nullable - private static Container getContainerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z) { +- private static @Nullable Container getContainerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z) { ++ @Nullable ++ private static Container getContainerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z) { + // Paper start - Perf: Optimize Hoppers + return HopperBlockEntity.getContainerAt(level, pos, state, x, y, z, false); + } -+ @Nullable -+ private static Container getContainerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z, final boolean optimizeEntities) { ++ private static @Nullable Container getContainerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z, final boolean optimizeEntities) { + // Paper end - Perf: Optimize Hoppers Container blockContainer = getBlockContainer(level, pos, state); - if (blockContainer == null) { @@ -650,10 +650,10 @@ index 96414f8bce0a89f11c64bf26924fc7bb4588e9be..28348e3881c3c8591053a01b193fb2a9 blockContainer = getEntityContainer(level, x, y, z); } -@@ -558,14 +813,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -551,14 +806,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + } - @Nullable - private static Container getEntityContainer(Level level, double x, double y, double z) { + private static @Nullable Container getEntityContainer(Level level, double x, double y, double z) { - List entities = level.getEntities( - (Entity)null, new AABB(x - 0.5, y - 0.5, z - 0.5, x + 0.5, y + 0.5, z + 0.5), EntitySelector.CONTAINER_ENTITY_SELECTOR + List entities = level.getEntitiesOfClass( @@ -669,10 +669,10 @@ index 96414f8bce0a89f11c64bf26924fc7bb4588e9be..28348e3881c3c8591053a01b193fb2a9 @Override diff --git a/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -index d2cd30ed072a3d75c32b49a72920a9c26ce29922..dc59465d63e36bd50a48a8ea4197424556736552 100644 +index 54c2c171c4bdc2d4d0ad048609dbdd0be8691017..4bf59f040ca2d6f35ef3c74cd8195c326234190a 100644 --- a/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -@@ -54,7 +54,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc +@@ -52,7 +52,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc @Override public ItemStack getItem(int index) { From 81124970dcdbaa7285bb5e67f2953705a60257ca Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Wed, 26 Nov 2025 09:30:12 -0700 Subject: [PATCH 111/112] anti-xray --- .../0028-Anti-Xray.patch} | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) rename paper-server/patches/{features-unapplied/0030-Anti-Xray.patch => features/0028-Anti-Xray.patch} (93%) diff --git a/paper-server/patches/features-unapplied/0030-Anti-Xray.patch b/paper-server/patches/features/0028-Anti-Xray.patch similarity index 93% rename from paper-server/patches/features-unapplied/0030-Anti-Xray.patch rename to paper-server/patches/features/0028-Anti-Xray.patch index 235b571e6956..bc5f16e6da9e 100644 --- a/paper-server/patches/features-unapplied/0030-Anti-Xray.patch +++ b/paper-server/patches/features/0028-Anti-Xray.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Anti-Xray diff --git a/io/papermc/paper/FeatureHooks.java b/io/papermc/paper/FeatureHooks.java -index 045778402404d46610165d15d8d430d6ae968688..695b8b708ffda1a927d865ba9891bb85303d75af 100644 +index 485413cb6b20c4bd20fbc29a0db43c051993fe79..22f37a0779996c9e3a9416a2a1ba2bee74e3f568 100644 --- a/io/papermc/paper/FeatureHooks.java +++ b/io/papermc/paper/FeatureHooks.java @@ -48,20 +48,25 @@ public final class FeatureHooks { @@ -55,7 +55,7 @@ index c9086bca5cbb780fd586f667e31a8fe1400ae58a..f828d07018d9a17aaa0142aac67ebed5 if (buffer.writerIndex() != buffer.capacity()) { diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index bd9b29da33670afd6ad0ea86927dad8c4a69faca..33ca4c2110673dee34b66c8d05ee83c4df828f2e 100644 +index 919eaac837298c1936ec7aa06375c72a7acd2daa..19547e22620f16d01f05bbd13a4dcb9c0df636df 100644 --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java @@ -41,13 +41,23 @@ public class ClientboundLevelChunkPacketData { @@ -103,7 +103,7 @@ index bd9b29da33670afd6ad0ea86927dad8c4a69faca..33ca4c2110673dee34b66c8d05ee83c4 if (buffer.writerIndex() != buffer.capacity()) { diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java -index fdd164cd45a26c7ef25f1153ab8985ba50c01b14..8578d1f78ddd1bb75f3230f04bfaa35af9f5f822 100644 +index 3c0f0a612cc57c9f03abfb0ccb1f891305d03d45..9f43cfbdd49df61de869fd65fb2cbea39a563260 100644 --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java @@ -18,18 +18,31 @@ public class ClientboundLevelChunkWithLightPacket implements Packet server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules()))); // Paper - create paper world configs -+ super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs & Async-Anti-Xray: Pass executor +- super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.identifier(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules()))); // Paper - create paper world configs ++ super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.identifier(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs & Async-Anti-Xray: Pass executor this.levelStorageAccess = levelStorageAccess; this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getOrCreate(levelStorageAccess.levelDirectory.path().toFile()); this.levelLoadListener = new net.minecraft.server.level.progress.LoggingLevelLoadListener(false, this); diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java -index c7407319dc4f6c6c34428f7038cca407a0e43c61..7166889bce8065508030ecd5b1400ee9be031bf3 100644 +index e22368b036c35d32dca79b0e840f1008dce830a4..6771cbbae863fa181e19c5fb74d2018d3559ef4e 100644 --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -316,6 +316,7 @@ public class ServerPlayerGameMode { +@@ -313,6 +313,7 @@ public class ServerPlayerGameMode { org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDamageAbortEvent(this.player, pos, this.player.getInventory().getSelectedItem()); // CraftBukkit } } @@ -184,10 +184,10 @@ index c65b274b965b95eae33690e63c5da2d5a9f2981a..644948d64791d0ffa4166375d0f4419f if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) { new io.papermc.paper.event.packet.PlayerChunkLoadEvent(new org.bukkit.craftbukkit.CraftChunk(chunk), packetListener.getPlayer().getBukkitEntity()).callEvent(); diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 410be367549a345677c94e9f8d7db0b7fffbf073..015ffd8298989bdb597b18d79adc3debcffc0977 100644 +index a17d021269c65d98a2ba847c0059a421ea051863..9f86d1fc4ea4c6987fa207644573565aea7edead 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -323,7 +323,7 @@ public abstract class PlayerList { +@@ -329,7 +329,7 @@ public abstract class PlayerList { .getOrThrow(net.minecraft.world.level.biome.Biomes.PLAINS); player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket( new net.minecraft.world.level.chunk.EmptyLevelChunk(serverLevel, player.chunkPosition(), plains), @@ -197,7 +197,7 @@ index 410be367549a345677c94e9f8d7db0b7fffbf073..015ffd8298989bdb597b18d79adc3deb } // Paper end - Send empty chunk diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 96fa7390a4bcfa7bdf2cf5346f2de895ac085203..d225267b1b07854b76c88ce461d7817a86d023a0 100644 +index bc0824b42e2fde246f052afe1e1393de632ccfb7..7bfaec43c12fb61b3fd7bac2c01903b81404280f 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -139,6 +139,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -207,9 +207,9 @@ index 96fa7390a4bcfa7bdf2cf5346f2de895ac085203..d225267b1b07854b76c88ce461d7817a + public final io.papermc.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray private final CraftWorld world; public net.kyori.adventure.util.TriState pvpMode = net.kyori.adventure.util.TriState.NOT_SET; - public @Nullable org.bukkit.generator.ChunkGenerator generator; + public org.bukkit.generator.@Nullable ChunkGenerator generator; @@ -831,7 +832,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - @Nullable org.bukkit.generator.BiomeProvider biomeProvider, // Paper + org.bukkit.generator.@Nullable BiomeProvider biomeProvider, // Paper org.bukkit.World.Environment environment, // Paper java.util.function.Function paperWorldConfigCreator // Paper - create paper world config @@ -218,7 +218,7 @@ index 96fa7390a4bcfa7bdf2cf5346f2de895ac085203..d225267b1b07854b76c88ce461d7817a ) { // Paper start - getblock optimisations - cache world height/sections final DimensionType dimType = dimensionTypeRegistration.value(); -@@ -866,6 +868,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -865,6 +867,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl this.palettedContainerFactory = PalettedContainerFactory.create(registryAccess); this.damageSources = new DamageSources(registryAccess); this.entityLookup = new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.dfl.DefaultEntityLookup(this); // Paper - rewrite chunk system @@ -226,7 +226,7 @@ index 96fa7390a4bcfa7bdf2cf5346f2de895ac085203..d225267b1b07854b76c88ce461d7817a } // Paper start - Cancel hit for vanished players -@@ -1071,6 +1074,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1068,6 +1071,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl snapshot.setFlags(flags); // Paper - always set the flag of the most recent call to mitigate issues with multiple update at the same pos with different flags } BlockState blockState = chunkAt.setBlockState(pos, state, flags); @@ -235,10 +235,10 @@ index 96fa7390a4bcfa7bdf2cf5346f2de895ac085203..d225267b1b07854b76c88ce461d7817a if (blockState == null) { // CraftBukkit start - remove blockstate if failed (or the same) diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java -index 71aa0220309e418fbbda66c2fa14fec498bf443d..22bc09e99b6755db403fad2e1136175737abed7c 100644 +index a49a06662de4062a77112e358f536d45d65bf91f..54ddcf92e72b9cbd0eb442e5d0faa83c0cf3b33b 100644 --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java -@@ -164,7 +164,7 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -161,7 +161,7 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh } } @@ -247,7 +247,7 @@ index 71aa0220309e418fbbda66c2fa14fec498bf443d..22bc09e99b6755db403fad2e11361757 // Paper start - rewrite chunk system if (!((Object)this instanceof ImposterProtoChunk)) { this.starlight$setBlockNibbles(ca.spottedleaf.moonrise.patches.starlight.light.StarLightEngine.getFilledEmptyLight(levelHeightAccessor)); -@@ -177,10 +177,10 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -174,10 +174,10 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh // Paper end - get block chunk optimisation } @@ -261,11 +261,11 @@ index 71aa0220309e418fbbda66c2fa14fec498bf443d..22bc09e99b6755db403fad2e11361757 } } diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index 4be0c11b3066bc56ac2b8658e064958038da44bf..de59760d27280555a334bda4f436164568cffbd6 100644 +index 356a89ef2396f245e438d59d65edd0445693cb8b..7f2fa1978c2ca5620f0f3c1f26570d924d7fb3e5 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -152,7 +152,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot - @Nullable LevelChunk.PostLoadProcessor postLoad, +@@ -151,7 +151,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot + LevelChunk.@Nullable PostLoadProcessor postLoad, @Nullable BlendingData blendingData ) { - super(pos, data, level, level.palettedContainerFactory(), inhabitedTime, sections, blendingData); @@ -314,7 +314,7 @@ index 5a76746a27d04cc095585655f2ef19ac10528071..201ba8b6ea45f526fbd5292164bb4cb6 public int getSerializedSize() { diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java -index 49c00586c1ae55e5e85787fa7cd4b84e8d5c83c7..54d71bd666a946bdf6eece520e080c3f96003452 100644 +index 0740775f2fa49c4313c1de6dd00f0a39fe2e0463..7c8f8772a6fba04dbafdb5dbf8098b6ebce6d6f2 100644 --- a/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/net/minecraft/world/level/chunk/PalettedContainer.java @@ -26,6 +26,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer @@ -457,7 +457,7 @@ index 49c00586c1ae55e5e85787fa7cd4b84e8d5c83c7..54d71bd666a946bdf6eece520e080c3f + } @Override - public synchronized void write(FriendlyByteBuf buffer) { // Paper - synchronize -+ public synchronized void write(FriendlyByteBuf buffer, @Nullable io.papermc.paper.antixray.ChunkPacketInfo chunkPacketInfo, int chunkSectionIndex) { // Paper - synchronize ++ public synchronized void write(FriendlyByteBuf buffer, io.papermc.paper.antixray.@Nullable ChunkPacketInfo chunkPacketInfo, int chunkSectionIndex) { // Paper - synchronize this.acquire(); try { @@ -508,7 +508,7 @@ index 49c00586c1ae55e5e85787fa7cd4b84e8d5c83c7..54d71bd666a946bdf6eece520e080c3f - public void write(FriendlyByteBuf buffer, IdMap map) { + // Paper start - Anti-Xray - Add chunk packet info -+ public void write(FriendlyByteBuf buffer, IdMap map, @Nullable io.papermc.paper.antixray.ChunkPacketInfo chunkPacketInfo, int chunkSectionIndex) { ++ public void write(FriendlyByteBuf buffer, IdMap map, io.papermc.paper.antixray.@Nullable ChunkPacketInfo chunkPacketInfo, int chunkSectionIndex) { buffer.writeByte(this.storage.getBits()); this.palette.write(buffer, map); + if (chunkPacketInfo != null) { @@ -590,18 +590,18 @@ index bcf7d5cca1f6e70222fccbeb259b6e323aa4c21a..787f5173425f617a89033e5b76256688 private static final Palette.Factory HASHMAP_PALETTE_FACTORY = HashMapPalette::create; static final Configuration ZERO_BITS = new Configuration.Simple(SINGLE_VALUE_PALETTE_FACTORY, 0); diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index 1652513d8a7e6036c82162517948dd22ca98d109..2e8a1898c9ef8bbfd58ea1e9fbd7f6a633822fb9 100644 +index 68874c0b6f6f7c5d8e3a79c9a7b391b9624ab748..95c8d65a4b6db8d0721460ae55cb8fb8143ea9a2 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -@@ -140,6 +140,7 @@ public record SerializableChunkData( +@@ -139,6 +139,7 @@ public record SerializableChunkData( + // Paper end - Do not let the server load chunks from newer versions - @Nullable public static SerializableChunkData parse(LevelHeightAccessor level, PalettedContainerFactory containerFactory, CompoundTag tag) { + net.minecraft.server.level.ServerLevel serverLevel = (net.minecraft.server.level.ServerLevel) level; // Paper - Anti-Xray This is is seemingly only called from ChunkMap, where, we have a server level. We'll fight this later if needed. if (tag.getString("Status").isEmpty()) { return null; } else { -@@ -198,9 +199,11 @@ public record SerializableChunkData( +@@ -199,9 +200,11 @@ public record SerializableChunkData( int byteOr = compoundTag.getByteOr("Y", (byte)0); LevelChunkSection levelChunkSection; if (byteOr >= level.getMinSectionY() && byteOr <= level.getMaxSectionY()) { From f6e343ece77ecaf97870a5d001abe81bd788d202 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Wed, 26 Nov 2025 09:38:11 -0700 Subject: [PATCH 112/112] Delte TODO txt We will use https://github.com/PaperMC/Paper/issues/12563 now --- todo-snapshot.txt | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 todo-snapshot.txt diff --git a/todo-snapshot.txt b/todo-snapshot.txt deleted file mode 100644 index d2ac52c0a9e4..000000000000 --- a/todo-snapshot.txt +++ /dev/null @@ -1,12 +0,0 @@ -- Check ServerPlayer bed diffs -- anything marked with 'TODO - snapshot' -- Environment attributes API -- 25w43a: - - Connection, ServerConnectionListener - dropped diff for thread pool config (fields gone) -- 25w44a: - - ShulkerBoxBlock: retainUnlootedShulkerBoxLootTableOnNonPlayerBreak patch no longer applies (getDrops override removed) - - Add back array storage for game rules in GameRuleMap? -- 25w45a: - - PatrolSpawner: Paper start day config is overriding timeline environment attribute -- 1.21.11-pre2: - - Review BlockLockCheckEvent changes