From b8cf7d380e4ef58c6d2064d5348171d1c93d290c Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Mon, 14 Jun 2021 19:59:31 -0700 Subject: [PATCH] tons of patches (#5835) --- build-data/paper.at | 12 + ...essage-to-PlayerAdvancementDoneEvent.patch | 0 .../Add-Block-isValidTool.patch | 0 ...Add-EntityBlockStorage-clearEntities.patch | 0 .../Add-EntityInsideBlockEvent.patch | 0 .../Add-Mob-lookAt-API.patch | 0 .../Add-PufferFishStateChangeEvent.patch | 0 ...n-in-sunlight-API-for-Phantoms-and-S.patch | 2 +- .../Add-basic-Datapack-API.patch | 0 ...cause-to-Weather-ThunderChangeEvents.patch | 0 ...-option-to-load-extra-plugin-jars-no.patch | 0 ...ainThreadExecutor-to-BukkitScheduler.patch | 0 .../Add-missing-effects.patch | 0 .../Add-more-WanderingTrader-API.patch | 0 ...-address-to-AsyncPlayerPreLoginEvent.patch | 0 .../Add-recipe-to-cook-events.patch | 0 .../Add-worldborder-events.patch | 0 .../Added-PlayerBedFailEnterEvent.patch | 0 .../Added-PlayerDeepSleepEvent.patch | 0 ...w-adding-items-to-BlockDropItemEvent.patch | 0 ...ent-suggestion-tooltips-in-AsyncTabC.patch | 0 .../Attributes-API-for-item-defaults.patch | 0 ...Cache-the-result-of-Material-isBlock.patch | 0 .../Expose-Tracked-Players.patch | 0 .../Expose-protocol-version.patch | 0 .../Implement-Keyed-on-World.patch | 0 ...eacon-activation-deactivation-events.patch | 0 .../Inventory-close.patch | 0 .../Item-Rarity-API.patch | 0 .../ItemStack-editMeta.patch | 0 .../ItemStack-repair-check-API.patch | 0 ...-missing-hard-depends-not-just-first.patch | 0 .../More-Enchantment-API.patch | 0 .../More-Lidded-Block-API.patch | 0 .../More-World-API.patch | 0 .../PlayerMoveEvent-Improvements.patch | 0 ...d-RespawnFlags-to-PlayerRespawnEvent.patch | 0 .../add-consumeFuel-to-FurnaceBurnEvent.patch | 0 ...t-set-drop-chance-to-EntityEquipment.patch | 0 .../add-isDeeplySleeping-to-HumanEntity.patch | 0 .../added-PlayerNameEntityEvent.patch | 0 ...ditions-to-PlayerGameModeChangeEvent.patch | 0 ...ventory-getContents-null-annotations.patch | 0 ...-entity-allow-attribute-registration.patch | 0 ...essage-to-PlayerAdvancementDoneEvent.patch | 89 ------- .../server-remapped/Add-Mob-lookAt-API.patch | 127 ---------- .../server-remapped/Clear-SyncLoadInfo.patch | 40 --- .../Expose-Tracked-Players.patch | 53 ---- ...crease-structure-block-data-length-t.patch | 19 -- ...atus-dataconverter-for-pre-1.13-chun.patch | 91 ------- .../Implement-Keyed-on-World.patch | 110 -------- ...-to-remove-correct-TE-during-TE-tick.patch | 45 ---- patches/server-remapped/More-World-API.patch | 146 ----------- ...ditions-to-PlayerGameModeChangeEvent.patch | 138 ---------- ...unnecessary-copies-of-passenger-list.patch | 239 ------------------ ...don-t-throw-when-loading-invalid-TEs.patch | 33 --- ...fix-PlayerItemHeldEvent-firing-twice.patch | 30 --- ...essage-to-PlayerAdvancementDoneEvent.patch | 32 +++ .../Add-Block-isValidTool.patch | 0 ...Add-Channel-initialization-listeners.patch | 2 +- ...Add-EntityBlockStorage-clearEntities.patch | 2 +- .../Add-EntityInsideBlockEvent.patch | 60 +++-- patches/server/Add-Mob-lookAt-API.patch | 64 +++++ .../Add-PufferFishStateChangeEvent.patch | 0 .../Add-Unix-domain-socket-support.patch | 6 +- ...n-in-sunlight-API-for-Phantoms-and-S.patch | 30 +-- .../Add-basic-Datapack-API.patch | 75 +----- .../Add-bypass-host-check.patch | 8 +- ...cause-to-Weather-ThunderChangeEvents.patch | 77 +++--- ...-option-to-load-extra-plugin-jars-no.patch | 6 +- ...nment-variable-to-disable-server-gui.patch | 0 ...ternative-constructor-for-Rotations.patch} | 6 +- ...ainThreadExecutor-to-BukkitScheduler.patch | 0 .../Add-more-WanderingTrader-API.patch | 6 +- ...-address-to-AsyncPlayerPreLoginEvent.patch | 10 +- .../Add-recipe-to-cook-events.patch | 24 +- ...pport-for-hex-color-codes-in-console.patch | 12 + .../Add-worldborder-events.patch | 49 +--- .../Added-PlayerBedFailEnterEvent.patch | 25 +- .../Added-PlayerDeepSleepEvent.patch | 0 ...w-adding-items-to-BlockDropItemEvent.patch | 0 ...ent-suggestion-tooltips-in-AsyncTabC.patch | 10 +- ...-using-signs-inside-spawn-protection.patch | 17 +- .../Attributes-API-for-item-defaults.patch | 18 +- ...ignore-result-of-PlayerEditBookEvent.patch | 12 +- ...ed-item-when-player-has-disconnected.patch | 14 +- ...tab-completions-for-brigadier-comman.patch | 51 +--- patches/server/Expose-Tracked-Players.patch | 32 +++ .../Expose-protocol-version.patch | 2 +- .../Fix-CraftPotionBrewer-cache.patch | 16 +- ...ortation-and-cancel-velocity-if-tele.patch | 2 +- ...ItemConsumeEvent-cancelling-properly.patch | 0 ...wn-acting-as-a-bed-respawn-from-the-.patch | 4 +- ...x-and-optimise-world-force-upgrading.patch | 44 +--- ...x-checkReach-check-for-Shulker-boxes.patch | 0 ...ating-give-items-on-item-drop-cancel.patch | 65 +---- ...chantCustom-emit-PlayerPurchaseEvent.patch | 13 - patches/server/Implement-Keyed-on-World.patch | 51 ++++ ...s-to-convert-between-Component-and-B.patch | 0 .../Improve-ServerGUI.patch | 27 +- .../Inline-shift-direction-fields.patch | 20 +- ...eacon-activation-deactivation-events.patch | 20 +- .../Inventory-close.patch | 2 +- .../Item-Rarity-API.patch | 25 +- .../ItemStack-repair-check-API.patch | 16 +- .../Limit-item-frame-cursors-on-maps.patch | 1 + ...Fix-Wither-hostility-towards-players.patch | 3 +- ...ipes-should-return-an-immutable-list.patch | 4 +- .../More-Enchantment-API.patch | 78 +----- .../More-Lidded-Block-API.patch | 48 +--- patches/server/More-World-API.patch | 86 +++++++ ...Timer-for-Wandering-Traders-spawned-.patch | 10 +- ...-grindstones-from-overstacking-items.patch | 0 .../Remove-streams-from-SensorNearest.patch | 81 +++--- ...mmands-if-tab-completion-is-disabled.patch | 0 .../Set-area-affect-cloud-rotation.patch | 6 +- ...prove-performance-of-the-end-generat.patch | 2 +- ...per-exception-on-empty-JsonList-file.patch | 0 ...d-RespawnFlags-to-PlayerRespawnEvent.patch | 9 +- .../add-consumeFuel-to-FurnaceBurnEvent.patch | 14 +- ...t-set-drop-chance-to-EntityEquipment.patch | 2 +- .../add-isDeeplySleeping-to-HumanEntity.patch | 2 +- .../added-PlayerNameEntityEvent.patch | 11 +- ...disable-pathfinding-updates-on-block.patch | 3 +- ...ditions-to-PlayerGameModeChangeEvent.patch | 150 +++++++++++ ...CreateEvent-players-and-end-platform.patch | 4 +- ...opy-TESign-isEditable-from-snapshots.patch | 0 ...fix-PigZombieAngerEvent-cancellation.patch | 18 +- ...fix-PlayerItemHeldEvent-firing-twice.patch | 18 ++ ...-block-falling-causing-client-desync.patch | 36 +-- .../fix-converting-txt-to-json-file.patch | 23 +- ...fix-dead-slime-setSize-invincibility.patch | 4 +- ...telist-use-configurable-kick-message.patch | 0 ...-entity-allow-attribute-registration.patch | 13 +- .../misc-debugging-dumps.patch | 38 +-- ...sure-plate-EntityInteractEvent-for-i.patch | 0 136 files changed, 814 insertions(+), 1979 deletions(-) rename patches/{api-unmapped => api}/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch (100%) rename patches/{api-unmapped => api}/Add-Block-isValidTool.patch (100%) rename patches/{api-unmapped => api}/Add-EntityBlockStorage-clearEntities.patch (100%) rename patches/{api-unmapped => api}/Add-EntityInsideBlockEvent.patch (100%) rename patches/{api-unmapped => api}/Add-Mob-lookAt-API.patch (100%) rename patches/{api-unmapped => api}/Add-PufferFishStateChangeEvent.patch (100%) rename patches/{api-unmapped => api}/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch (94%) rename patches/{api-unmapped => api}/Add-basic-Datapack-API.patch (100%) rename patches/{api-unmapped => api}/Add-cause-to-Weather-ThunderChangeEvents.patch (100%) rename patches/{api-unmapped => api}/Add-command-line-option-to-load-extra-plugin-jars-no.patch (100%) rename patches/{api-unmapped => api}/Add-getMainThreadExecutor-to-BukkitScheduler.patch (100%) rename patches/{api-unmapped => api}/Add-missing-effects.patch (100%) rename patches/{api-unmapped => api}/Add-more-WanderingTrader-API.patch (100%) rename patches/{api-unmapped => api}/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch (100%) rename patches/{api-unmapped => api}/Add-recipe-to-cook-events.patch (100%) rename patches/{api-unmapped => api}/Add-worldborder-events.patch (100%) rename patches/{api-unmapped => api}/Added-PlayerBedFailEnterEvent.patch (100%) rename patches/{api-unmapped => api}/Added-PlayerDeepSleepEvent.patch (100%) rename patches/{api-unmapped => api}/Allow-adding-items-to-BlockDropItemEvent.patch (100%) rename patches/{api-unmapped => api}/Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch (100%) rename patches/{api-unmapped => api}/Attributes-API-for-item-defaults.patch (100%) rename patches/{api-unmapped => api}/Cache-the-result-of-Material-isBlock.patch (100%) rename patches/{api-unmapped => api}/Expose-Tracked-Players.patch (100%) rename patches/{api-unmapped => api}/Expose-protocol-version.patch (100%) rename patches/{api-unmapped => api}/Implement-Keyed-on-World.patch (100%) rename patches/{api-unmapped => api}/Introduce-beacon-activation-deactivation-events.patch (100%) rename patches/{api-unmapped => api}/Inventory-close.patch (100%) rename patches/{api-unmapped => api}/Item-Rarity-API.patch (100%) rename patches/{api-unmapped => api}/ItemStack-editMeta.patch (100%) rename patches/{api-unmapped => api}/ItemStack-repair-check-API.patch (100%) rename patches/{api-unmapped => api}/List-all-missing-hard-depends-not-just-first.patch (100%) rename patches/{api-unmapped => api}/More-Enchantment-API.patch (100%) rename patches/{api-unmapped => api}/More-Lidded-Block-API.patch (100%) rename patches/{api-unmapped => api}/More-World-API.patch (100%) rename patches/{api-unmapped => api}/PlayerMoveEvent-Improvements.patch (100%) rename patches/{api-unmapped => api}/add-RespawnFlags-to-PlayerRespawnEvent.patch (100%) rename patches/{api-unmapped => api}/add-consumeFuel-to-FurnaceBurnEvent.patch (100%) rename patches/{api-unmapped => api}/add-get-set-drop-chance-to-EntityEquipment.patch (100%) rename patches/{api-unmapped => api}/add-isDeeplySleeping-to-HumanEntity.patch (100%) rename patches/{api-unmapped => api}/added-PlayerNameEntityEvent.patch (100%) rename patches/{api-unmapped => api}/additions-to-PlayerGameModeChangeEvent.patch (100%) rename patches/{api-unmapped => api}/fix-Inventory-getContents-null-annotations.patch (100%) rename patches/{api-unmapped => api}/living-entity-allow-attribute-registration.patch (100%) delete mode 100644 patches/server-remapped/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch delete mode 100644 patches/server-remapped/Add-Mob-lookAt-API.patch delete mode 100644 patches/server-remapped/Clear-SyncLoadInfo.patch delete mode 100644 patches/server-remapped/Expose-Tracked-Players.patch delete mode 100644 patches/server-remapped/Fix-MC-148809-Increase-structure-block-data-length-t.patch delete mode 100644 patches/server-remapped/Fix-incorrect-status-dataconverter-for-pre-1.13-chun.patch delete mode 100644 patches/server-remapped/Implement-Keyed-on-World.patch delete mode 100644 patches/server-remapped/Make-sure-to-remove-correct-TE-during-TE-tick.patch delete mode 100644 patches/server-remapped/More-World-API.patch delete mode 100644 patches/server-remapped/additions-to-PlayerGameModeChangeEvent.patch delete mode 100644 patches/server-remapped/do-not-create-unnecessary-copies-of-passenger-list.patch delete mode 100644 patches/server-remapped/don-t-throw-when-loading-invalid-TEs.patch delete mode 100644 patches/server-remapped/fix-PlayerItemHeldEvent-firing-twice.patch create mode 100644 patches/server/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch rename patches/{server-remapped => server}/Add-Block-isValidTool.patch (100%) rename patches/{server-remapped => server}/Add-Channel-initialization-listeners.patch (97%) rename patches/{server-remapped => server}/Add-EntityBlockStorage-clearEntities.patch (98%) rename patches/{server-remapped => server}/Add-EntityInsideBlockEvent.patch (85%) create mode 100644 patches/server/Add-Mob-lookAt-API.patch rename patches/{server-remapped => server}/Add-PufferFishStateChangeEvent.patch (100%) rename patches/{server-remapped => server}/Add-Unix-domain-socket-support.patch (95%) rename patches/{server-remapped => server}/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch (83%) rename patches/{server-remapped => server}/Add-basic-Datapack-API.patch (51%) rename patches/{server-remapped => server}/Add-bypass-host-check.patch (82%) rename patches/{server-remapped => server}/Add-cause-to-Weather-ThunderChangeEvents.patch (67%) rename patches/{server-remapped => server}/Add-command-line-option-to-load-extra-plugin-jars-no.patch (93%) rename patches/{server-remapped => server}/Add-environment-variable-to-disable-server-gui.patch (100%) rename patches/{server-remapped/Add-fast-alternative-constructor-for-Vector3f.patch => server/Add-fast-alternative-constructor-for-Rotations.patch} (87%) rename patches/{server-remapped => server}/Add-getMainThreadExecutor-to-BukkitScheduler.patch (100%) rename patches/{server-remapped => server}/Add-more-WanderingTrader-API.patch (92%) rename patches/{server-remapped => server}/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch (79%) rename patches/{server-remapped => server}/Add-recipe-to-cook-events.patch (65%) rename patches/{server-remapped => server}/Add-support-for-hex-color-codes-in-console.patch (93%) rename patches/{server-remapped => server}/Add-worldborder-events.patch (56%) rename patches/{server-remapped => server}/Added-PlayerBedFailEnterEvent.patch (54%) rename patches/{server-remapped => server}/Added-PlayerDeepSleepEvent.patch (100%) rename patches/{server-remapped => server}/Allow-adding-items-to-BlockDropItemEvent.patch (100%) rename patches/{server-remapped => server}/Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch (97%) rename patches/{server-remapped => server}/Allow-using-signs-inside-spawn-protection.patch (78%) rename patches/{server-remapped => server}/Attributes-API-for-item-defaults.patch (61%) rename patches/{server-remapped => server}/Don-t-ignore-result-of-PlayerEditBookEvent.patch (58%) rename patches/{server-remapped => server}/Drop-carried-item-when-player-has-disconnected.patch (64%) rename patches/{server-remapped => server}/Enhance-console-tab-completions-for-brigadier-comman.patch (82%) create mode 100644 patches/server/Expose-Tracked-Players.patch rename patches/{server-remapped => server}/Expose-protocol-version.patch (91%) rename patches/{server-remapped => server}/Fix-CraftPotionBrewer-cache.patch (76%) rename patches/{server-remapped => server}/Fix-PlayerItemConsumeEvent-cancelling-properly.patch (100%) rename patches/{server-remapped => server}/Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch (92%) rename patches/{server-remapped => server}/Fix-and-optimise-world-force-upgrading.patch (87%) rename patches/{server-remapped => server}/Fix-checkReach-check-for-Shulker-boxes.patch (100%) rename patches/{server-remapped => server}/Fix-duplicating-give-items-on-item-drop-cancel.patch (53%) rename patches/{server-remapped => server}/Have-CraftMerchantCustom-emit-PlayerPurchaseEvent.patch (79%) create mode 100644 patches/server/Implement-Keyed-on-World.patch rename patches/{server-remapped => server}/Implement-methods-to-convert-between-Component-and-B.patch (100%) rename patches/{server-remapped => server}/Improve-ServerGUI.patch (95%) rename patches/{server-remapped => server}/Inline-shift-direction-fields.patch (73%) rename patches/{server-remapped => server}/Introduce-beacon-activation-deactivation-events.patch (74%) rename patches/{server-remapped => server}/Inventory-close.patch (97%) rename patches/{server-remapped => server}/Item-Rarity-API.patch (51%) rename patches/{server-remapped => server}/ItemStack-repair-check-API.patch (77%) rename patches/{server-remapped => server}/Limit-item-frame-cursors-on-maps.patch (99%) rename patches/{server-remapped => server}/MC-29274-Fix-Wither-hostility-towards-players.patch (98%) rename patches/{server-remapped => server}/Merchant-getRecipes-should-return-an-immutable-list.patch (69%) rename patches/{server-remapped => server}/More-Enchantment-API.patch (63%) rename patches/{server-remapped => server}/More-Lidded-Block-API.patch (70%) create mode 100644 patches/server/More-World-API.patch rename patches/{server-remapped => server}/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch (83%) rename patches/{server-remapped => server}/Prevent-grindstones-from-overstacking-items.patch (100%) rename patches/{server-remapped => server}/Remove-streams-from-SensorNearest.patch (55%) rename patches/{server-remapped => server}/Send-empty-commands-if-tab-completion-is-disabled.patch (100%) rename patches/{server-remapped => server}/Set-area-affect-cloud-rotation.patch (86%) rename patches/{server-remapped => server}/Throw-proper-exception-on-empty-JsonList-file.patch (100%) rename patches/{server-remapped => server}/add-RespawnFlags-to-PlayerRespawnEvent.patch (91%) rename patches/{server-remapped => server}/add-consumeFuel-to-FurnaceBurnEvent.patch (64%) rename patches/{server-remapped => server}/add-get-set-drop-chance-to-EntityEquipment.patch (96%) rename patches/{server-remapped => server}/add-isDeeplySleeping-to-HumanEntity.patch (95%) rename patches/{server-remapped => server}/added-PlayerNameEntityEvent.patch (88%) rename patches/{server-remapped => server}/added-option-to-disable-pathfinding-updates-on-block.patch (97%) create mode 100644 patches/server/additions-to-PlayerGameModeChangeEvent.patch rename patches/{server-remapped => server}/call-PortalCreateEvent-players-and-end-platform.patch (93%) rename patches/{server-remapped => server}/copy-TESign-isEditable-from-snapshots.patch (100%) rename patches/{server-remapped => server}/fix-PigZombieAngerEvent-cancellation.patch (70%) create mode 100644 patches/server/fix-PlayerItemHeldEvent-firing-twice.patch rename patches/{server-remapped => server}/fix-cancelling-block-falling-causing-client-desync.patch (50%) rename patches/{server-remapped => server}/fix-converting-txt-to-json-file.patch (77%) rename patches/{server-remapped => server}/fix-dead-slime-setSize-invincibility.patch (80%) rename patches/{server-remapped => server}/forced-whitelist-use-configurable-kick-message.patch (100%) rename patches/{server-remapped => server}/living-entity-allow-attribute-registration.patch (80%) rename patches/{server-remapped => server}/misc-debugging-dumps.patch (70%) rename patches/{server-remapped => server}/stop-firing-pressure-plate-EntityInteractEvent-for-i.patch (100%) diff --git a/build-data/paper.at b/build-data/paper.at index ced8ae8dfd..1afeccf82a 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -4,3 +4,15 @@ # This line would make the field public and remove the final modifier #public-f net.minecraft.network.protocol.game.ClientboundChatPacket sender # Leave out the member and it will apply to the class itself + +# Item Rarity API +public net.minecraft.world.item.Item rarity + +# More Enchantment API +public net.minecraft.world.item.enchantment.Enchantment slots; + +# Fix and optimise world force upgrading +public net.minecraft.util.worldupdate.WorldUpgrader REGEX; + +# More Lidded Block API +public net.minecraft.world.level.block.entity.EnderChestBlockEntity openersCounter \ No newline at end of file diff --git a/patches/api-unmapped/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch b/patches/api/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch similarity index 100% rename from patches/api-unmapped/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch rename to patches/api/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch diff --git a/patches/api-unmapped/Add-Block-isValidTool.patch b/patches/api/Add-Block-isValidTool.patch similarity index 100% rename from patches/api-unmapped/Add-Block-isValidTool.patch rename to patches/api/Add-Block-isValidTool.patch diff --git a/patches/api-unmapped/Add-EntityBlockStorage-clearEntities.patch b/patches/api/Add-EntityBlockStorage-clearEntities.patch similarity index 100% rename from patches/api-unmapped/Add-EntityBlockStorage-clearEntities.patch rename to patches/api/Add-EntityBlockStorage-clearEntities.patch diff --git a/patches/api-unmapped/Add-EntityInsideBlockEvent.patch b/patches/api/Add-EntityInsideBlockEvent.patch similarity index 100% rename from patches/api-unmapped/Add-EntityInsideBlockEvent.patch rename to patches/api/Add-EntityInsideBlockEvent.patch diff --git a/patches/api-unmapped/Add-Mob-lookAt-API.patch b/patches/api/Add-Mob-lookAt-API.patch similarity index 100% rename from patches/api-unmapped/Add-Mob-lookAt-API.patch rename to patches/api/Add-Mob-lookAt-API.patch diff --git a/patches/api-unmapped/Add-PufferFishStateChangeEvent.patch b/patches/api/Add-PufferFishStateChangeEvent.patch similarity index 100% rename from patches/api-unmapped/Add-PufferFishStateChangeEvent.patch rename to patches/api/Add-PufferFishStateChangeEvent.patch diff --git a/patches/api-unmapped/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch b/patches/api/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch similarity index 94% rename from patches/api-unmapped/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch rename to patches/api/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch index 8d495850c0..26b92f8cb4 100644 --- a/patches/api-unmapped/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch +++ b/patches/api/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch @@ -33,7 +33,7 @@ diff --git a/src/main/java/org/bukkit/entity/Skeleton.java b/src/main/java/org/b index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/Skeleton.java +++ b/src/main/java/org/bukkit/entity/Skeleton.java -@@ -0,0 +0,0 @@ public interface Skeleton extends Monster, RangedEntity { // Paper +@@ -0,0 +0,0 @@ public interface Skeleton extends AbstractSkeleton, com.destroystokyo.paper.enti */ STRAY; } diff --git a/patches/api-unmapped/Add-basic-Datapack-API.patch b/patches/api/Add-basic-Datapack-API.patch similarity index 100% rename from patches/api-unmapped/Add-basic-Datapack-API.patch rename to patches/api/Add-basic-Datapack-API.patch diff --git a/patches/api-unmapped/Add-cause-to-Weather-ThunderChangeEvents.patch b/patches/api/Add-cause-to-Weather-ThunderChangeEvents.patch similarity index 100% rename from patches/api-unmapped/Add-cause-to-Weather-ThunderChangeEvents.patch rename to patches/api/Add-cause-to-Weather-ThunderChangeEvents.patch diff --git a/patches/api-unmapped/Add-command-line-option-to-load-extra-plugin-jars-no.patch b/patches/api/Add-command-line-option-to-load-extra-plugin-jars-no.patch similarity index 100% rename from patches/api-unmapped/Add-command-line-option-to-load-extra-plugin-jars-no.patch rename to patches/api/Add-command-line-option-to-load-extra-plugin-jars-no.patch diff --git a/patches/api-unmapped/Add-getMainThreadExecutor-to-BukkitScheduler.patch b/patches/api/Add-getMainThreadExecutor-to-BukkitScheduler.patch similarity index 100% rename from patches/api-unmapped/Add-getMainThreadExecutor-to-BukkitScheduler.patch rename to patches/api/Add-getMainThreadExecutor-to-BukkitScheduler.patch diff --git a/patches/api-unmapped/Add-missing-effects.patch b/patches/api/Add-missing-effects.patch similarity index 100% rename from patches/api-unmapped/Add-missing-effects.patch rename to patches/api/Add-missing-effects.patch diff --git a/patches/api-unmapped/Add-more-WanderingTrader-API.patch b/patches/api/Add-more-WanderingTrader-API.patch similarity index 100% rename from patches/api-unmapped/Add-more-WanderingTrader-API.patch rename to patches/api/Add-more-WanderingTrader-API.patch diff --git a/patches/api-unmapped/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch b/patches/api/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch similarity index 100% rename from patches/api-unmapped/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch rename to patches/api/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch diff --git a/patches/api-unmapped/Add-recipe-to-cook-events.patch b/patches/api/Add-recipe-to-cook-events.patch similarity index 100% rename from patches/api-unmapped/Add-recipe-to-cook-events.patch rename to patches/api/Add-recipe-to-cook-events.patch diff --git a/patches/api-unmapped/Add-worldborder-events.patch b/patches/api/Add-worldborder-events.patch similarity index 100% rename from patches/api-unmapped/Add-worldborder-events.patch rename to patches/api/Add-worldborder-events.patch diff --git a/patches/api-unmapped/Added-PlayerBedFailEnterEvent.patch b/patches/api/Added-PlayerBedFailEnterEvent.patch similarity index 100% rename from patches/api-unmapped/Added-PlayerBedFailEnterEvent.patch rename to patches/api/Added-PlayerBedFailEnterEvent.patch diff --git a/patches/api-unmapped/Added-PlayerDeepSleepEvent.patch b/patches/api/Added-PlayerDeepSleepEvent.patch similarity index 100% rename from patches/api-unmapped/Added-PlayerDeepSleepEvent.patch rename to patches/api/Added-PlayerDeepSleepEvent.patch diff --git a/patches/api-unmapped/Allow-adding-items-to-BlockDropItemEvent.patch b/patches/api/Allow-adding-items-to-BlockDropItemEvent.patch similarity index 100% rename from patches/api-unmapped/Allow-adding-items-to-BlockDropItemEvent.patch rename to patches/api/Allow-adding-items-to-BlockDropItemEvent.patch diff --git a/patches/api-unmapped/Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch b/patches/api/Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch similarity index 100% rename from patches/api-unmapped/Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch rename to patches/api/Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch diff --git a/patches/api-unmapped/Attributes-API-for-item-defaults.patch b/patches/api/Attributes-API-for-item-defaults.patch similarity index 100% rename from patches/api-unmapped/Attributes-API-for-item-defaults.patch rename to patches/api/Attributes-API-for-item-defaults.patch diff --git a/patches/api-unmapped/Cache-the-result-of-Material-isBlock.patch b/patches/api/Cache-the-result-of-Material-isBlock.patch similarity index 100% rename from patches/api-unmapped/Cache-the-result-of-Material-isBlock.patch rename to patches/api/Cache-the-result-of-Material-isBlock.patch diff --git a/patches/api-unmapped/Expose-Tracked-Players.patch b/patches/api/Expose-Tracked-Players.patch similarity index 100% rename from patches/api-unmapped/Expose-Tracked-Players.patch rename to patches/api/Expose-Tracked-Players.patch diff --git a/patches/api-unmapped/Expose-protocol-version.patch b/patches/api/Expose-protocol-version.patch similarity index 100% rename from patches/api-unmapped/Expose-protocol-version.patch rename to patches/api/Expose-protocol-version.patch diff --git a/patches/api-unmapped/Implement-Keyed-on-World.patch b/patches/api/Implement-Keyed-on-World.patch similarity index 100% rename from patches/api-unmapped/Implement-Keyed-on-World.patch rename to patches/api/Implement-Keyed-on-World.patch diff --git a/patches/api-unmapped/Introduce-beacon-activation-deactivation-events.patch b/patches/api/Introduce-beacon-activation-deactivation-events.patch similarity index 100% rename from patches/api-unmapped/Introduce-beacon-activation-deactivation-events.patch rename to patches/api/Introduce-beacon-activation-deactivation-events.patch diff --git a/patches/api-unmapped/Inventory-close.patch b/patches/api/Inventory-close.patch similarity index 100% rename from patches/api-unmapped/Inventory-close.patch rename to patches/api/Inventory-close.patch diff --git a/patches/api-unmapped/Item-Rarity-API.patch b/patches/api/Item-Rarity-API.patch similarity index 100% rename from patches/api-unmapped/Item-Rarity-API.patch rename to patches/api/Item-Rarity-API.patch diff --git a/patches/api-unmapped/ItemStack-editMeta.patch b/patches/api/ItemStack-editMeta.patch similarity index 100% rename from patches/api-unmapped/ItemStack-editMeta.patch rename to patches/api/ItemStack-editMeta.patch diff --git a/patches/api-unmapped/ItemStack-repair-check-API.patch b/patches/api/ItemStack-repair-check-API.patch similarity index 100% rename from patches/api-unmapped/ItemStack-repair-check-API.patch rename to patches/api/ItemStack-repair-check-API.patch diff --git a/patches/api-unmapped/List-all-missing-hard-depends-not-just-first.patch b/patches/api/List-all-missing-hard-depends-not-just-first.patch similarity index 100% rename from patches/api-unmapped/List-all-missing-hard-depends-not-just-first.patch rename to patches/api/List-all-missing-hard-depends-not-just-first.patch diff --git a/patches/api-unmapped/More-Enchantment-API.patch b/patches/api/More-Enchantment-API.patch similarity index 100% rename from patches/api-unmapped/More-Enchantment-API.patch rename to patches/api/More-Enchantment-API.patch diff --git a/patches/api-unmapped/More-Lidded-Block-API.patch b/patches/api/More-Lidded-Block-API.patch similarity index 100% rename from patches/api-unmapped/More-Lidded-Block-API.patch rename to patches/api/More-Lidded-Block-API.patch diff --git a/patches/api-unmapped/More-World-API.patch b/patches/api/More-World-API.patch similarity index 100% rename from patches/api-unmapped/More-World-API.patch rename to patches/api/More-World-API.patch diff --git a/patches/api-unmapped/PlayerMoveEvent-Improvements.patch b/patches/api/PlayerMoveEvent-Improvements.patch similarity index 100% rename from patches/api-unmapped/PlayerMoveEvent-Improvements.patch rename to patches/api/PlayerMoveEvent-Improvements.patch diff --git a/patches/api-unmapped/add-RespawnFlags-to-PlayerRespawnEvent.patch b/patches/api/add-RespawnFlags-to-PlayerRespawnEvent.patch similarity index 100% rename from patches/api-unmapped/add-RespawnFlags-to-PlayerRespawnEvent.patch rename to patches/api/add-RespawnFlags-to-PlayerRespawnEvent.patch diff --git a/patches/api-unmapped/add-consumeFuel-to-FurnaceBurnEvent.patch b/patches/api/add-consumeFuel-to-FurnaceBurnEvent.patch similarity index 100% rename from patches/api-unmapped/add-consumeFuel-to-FurnaceBurnEvent.patch rename to patches/api/add-consumeFuel-to-FurnaceBurnEvent.patch diff --git a/patches/api-unmapped/add-get-set-drop-chance-to-EntityEquipment.patch b/patches/api/add-get-set-drop-chance-to-EntityEquipment.patch similarity index 100% rename from patches/api-unmapped/add-get-set-drop-chance-to-EntityEquipment.patch rename to patches/api/add-get-set-drop-chance-to-EntityEquipment.patch diff --git a/patches/api-unmapped/add-isDeeplySleeping-to-HumanEntity.patch b/patches/api/add-isDeeplySleeping-to-HumanEntity.patch similarity index 100% rename from patches/api-unmapped/add-isDeeplySleeping-to-HumanEntity.patch rename to patches/api/add-isDeeplySleeping-to-HumanEntity.patch diff --git a/patches/api-unmapped/added-PlayerNameEntityEvent.patch b/patches/api/added-PlayerNameEntityEvent.patch similarity index 100% rename from patches/api-unmapped/added-PlayerNameEntityEvent.patch rename to patches/api/added-PlayerNameEntityEvent.patch diff --git a/patches/api-unmapped/additions-to-PlayerGameModeChangeEvent.patch b/patches/api/additions-to-PlayerGameModeChangeEvent.patch similarity index 100% rename from patches/api-unmapped/additions-to-PlayerGameModeChangeEvent.patch rename to patches/api/additions-to-PlayerGameModeChangeEvent.patch diff --git a/patches/api-unmapped/fix-Inventory-getContents-null-annotations.patch b/patches/api/fix-Inventory-getContents-null-annotations.patch similarity index 100% rename from patches/api-unmapped/fix-Inventory-getContents-null-annotations.patch rename to patches/api/fix-Inventory-getContents-null-annotations.patch diff --git a/patches/api-unmapped/living-entity-allow-attribute-registration.patch b/patches/api/living-entity-allow-attribute-registration.patch similarity index 100% rename from patches/api-unmapped/living-entity-allow-attribute-registration.patch rename to patches/api/living-entity-allow-attribute-registration.patch diff --git a/patches/server-remapped/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch b/patches/server-remapped/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch deleted file mode 100644 index 9731b0b991..0000000000 --- a/patches/server-remapped/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Alvinn8 <42838560+Alvinn8@users.noreply.github.com> -Date: Fri, 8 Jan 2021 20:31:13 +0100 -Subject: [PATCH] Add Adventure message to PlayerAdvancementDoneEvent - - -diff --git a/src/main/java/net/minecraft/advancements/Advancement.java b/src/main/java/net/minecraft/advancements/Advancement.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/advancements/Advancement.java -+++ b/src/main/java/net/minecraft/advancements/Advancement.java -@@ -0,0 +0,0 @@ public class Advancement { - return this.parent; - } - -+ public final @Nullable DisplayInfo getAdvancementDisplay() { return this.getDisplay(); } // Paper - OBFHELPER - @Nullable - public DisplayInfo getDisplay() { - return this.display; -@@ -0,0 +0,0 @@ public class Advancement { - return this.requirements; - } - -+ public final Component getChatComponent() { return this.getChatComponent(); } // Paper - OBFHELPER - public Component getChatComponent() { - return this.chatComponent; - } -diff --git a/src/main/java/net/minecraft/advancements/DisplayInfo.java b/src/main/java/net/minecraft/advancements/DisplayInfo.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/advancements/DisplayInfo.java -+++ b/src/main/java/net/minecraft/advancements/DisplayInfo.java -@@ -0,0 +0,0 @@ public class DisplayInfo { - return this.description; - } - -+ public final FrameType getFrameType() { return this.getFrame(); } // Paper - OBFHELPER - public FrameType getFrame() { - return this.frame; - } - -+ public final boolean shouldAnnounceToChat() { return this.shouldAnnounceChat(); } // Paper - OBFHELPER - public boolean shouldAnnounceChat() { - return this.announceChat; - } -diff --git a/src/main/java/net/minecraft/advancements/FrameType.java b/src/main/java/net/minecraft/advancements/FrameType.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/advancements/FrameType.java -+++ b/src/main/java/net/minecraft/advancements/FrameType.java -@@ -0,0 +0,0 @@ public enum FrameType { - this.displayName = new TranslatableComponent("advancements.toast." + s); - } - -+ public final String getId() { return this.getName(); } // Paper - OBFHELPER - public String getName() { - return this.name; - } -diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/PlayerAdvancements.java -+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java -@@ -0,0 +0,0 @@ import net.minecraft.util.datafix.DataFixTypes; - import net.minecraft.world.level.GameRules; - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; -+import io.papermc.paper.adventure.PaperAdventure; // Paper - - public class PlayerAdvancements { - -@@ -0,0 +0,0 @@ public class PlayerAdvancements { - this.progressChanged.add(advancement); - flag = true; - if (!flag1 && advancementprogress.isDone()) { -- this.player.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit -+ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent -+ boolean announceToChat = advancement.getAdvancementDisplay() != null && advancement.getAdvancementDisplay().shouldAnnounceToChat(); -+ net.kyori.adventure.text.Component message = announceToChat ? PaperAdventure.asAdventure(new TranslatableComponent("chat.type.advancement." + advancement.getAdvancementDisplay().getFrameType().getId(), this.player.getDisplayName(), advancement.getChatComponent())) : null; -+ org.bukkit.event.player.PlayerAdvancementDoneEvent event = new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit, message); -+ this.player.level.getCraftServer().getPluginManager().callEvent(event); -+ message = event.message(); -+ // Paper end - advancement.getRewards().a(this.player); -- if (advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat() && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { -- this.playerList.broadcastMessage(new TranslatableComponent("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), new Object[]{this.player.getDisplayName(), advancement.getChatComponent()}), ChatType.SYSTEM, Util.NIL_UUID); -+ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent -+ if (message != null && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { -+ this.playerList.broadcastMessage(PaperAdventure.asVanilla(message), ChatType.SYSTEM, Util.getNullUUID()); -+ // Paper end - } - } - } diff --git a/patches/server-remapped/Add-Mob-lookAt-API.patch b/patches/server-remapped/Add-Mob-lookAt-API.patch deleted file mode 100644 index 3811a38199..0000000000 --- a/patches/server-remapped/Add-Mob-lookAt-API.patch +++ /dev/null @@ -1,127 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: BillyGalbreath -Date: Fri, 14 May 2021 13:42:17 -0500 -Subject: [PATCH] Add Mob#lookAt API - - -diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/Mob.java -+++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity { - - protected void customServerAiStep() {} - -+ public int getMaxHeadXRot() { return getMaxHeadXRot(); } // Paper - OBFHELPER - public int getMaxHeadXRot() { - return 40; - } - -+ public int getMaxHeadYRot() { return getMaxHeadYRot(); } // Paper - OBFHELPER - public int getMaxHeadYRot() { - return 75; - } - -+ public int getHeadRotSpeed() { return getHeadRotSpeed(); } // Paper - OBFHELPER - public int getHeadRotSpeed() { - return 10; - } -diff --git a/src/main/java/net/minecraft/world/entity/ai/control/LookControl.java b/src/main/java/net/minecraft/world/entity/ai/control/LookControl.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/control/LookControl.java -+++ b/src/main/java/net/minecraft/world/entity/ai/control/LookControl.java -@@ -0,0 +0,0 @@ public class LookControl { - this.mob = entity; - } - -+ public void lookAt(Vec3 vec3d) { setLookAt(vec3d); } // Paper - OBFHELPER - public void setLookAt(Vec3 direction) { - this.setLookAt(direction.x, direction.y, direction.z); - } - -+ // Paper start -+ public void lookAt(Entity entity) { -+ this.lookAt(entity.getX(), getWantedY(entity), entity.getZ()); -+ } -+ // Paper end -+ -+ public void lookAt(Entity entity, float f, float f1) { setLookAt(entity, f, f1); } // Paper - OBFHELPER - public void setLookAt(Entity entity, float yawSpeed, float pitchSpeed) { - this.setLookAt(entity.getX(), getWantedY(entity), entity.getZ(), yawSpeed, pitchSpeed); - } - -+ public void lookAt(double d0, double d1, double d2) { setLookAt(d0, d1, d2); } // Paper - OBFHELPER - public void setLookAt(double x, double y, double z) { - this.setLookAt(x, y, z, (float) this.mob.getHeadRotSpeed(), (float) this.mob.getMaxHeadXRot()); - } - -+ public void lookAt(double d0, double d1, double d2, float f, float f1) { setLookAt(d0, d1, d2, f, f1); } // Paper - OBFHELPER - public void setLookAt(double x, double y, double z, float yawSpeed, float pitchSpeed) { - this.wantedX = x; - this.wantedY = y; -@@ -0,0 +0,0 @@ public class LookControl { - return from + f4; - } - -+ public static double getWantedY(Entity entity) { return getWantedY(entity); } // Paper - OBFHELPER - private static double getWantedY(Entity entity) { - return entity instanceof LivingEntity ? entity.getEyeY() : (entity.getBoundingBox().minY + entity.getBoundingBox().maxY) / 2.0D; - } -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java -@@ -0,0 +0,0 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { - public boolean isInDaylight() { - return getHandle().isInDaylight(); - } -+ -+ @Override -+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.Location location) { -+ com.google.common.base.Preconditions.checkNotNull(location, "location cannot be null"); -+ com.google.common.base.Preconditions.checkArgument(location.getWorld().equals(getWorld()), "location in a different world"); -+ getHandle().getLookControl().lookAt(location.getX(), location.getY(), location.getZ()); -+ } -+ -+ @Override -+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.Location location, float headRotationSpeed, float maxHeadPitch) { -+ com.google.common.base.Preconditions.checkNotNull(location, "location cannot be null"); -+ com.google.common.base.Preconditions.checkArgument(location.getWorld().equals(getWorld()), "location in a different world"); -+ getHandle().getLookControl().lookAt(location.getX(), location.getY(), location.getZ(), headRotationSpeed, maxHeadPitch); -+ } -+ -+ @Override -+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.entity.Entity entity) { -+ com.google.common.base.Preconditions.checkNotNull(entity, "entity cannot be null"); -+ com.google.common.base.Preconditions.checkArgument(entity.getWorld().equals(getWorld()), "entity in a different world"); -+ getHandle().getLookControl().lookAt(((CraftEntity) entity).getHandle()); -+ } -+ -+ @Override -+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.entity.Entity entity, float headRotationSpeed, float maxHeadPitch) { -+ com.google.common.base.Preconditions.checkNotNull(entity, "entity cannot be null"); -+ com.google.common.base.Preconditions.checkArgument(entity.getWorld().equals(getWorld()), "entity in a different world"); -+ getHandle().getLookControl().lookAt(((CraftEntity) entity).getHandle(), headRotationSpeed, maxHeadPitch); -+ } -+ -+ @Override -+ public void lookAt(double x, double y, double z) { -+ getHandle().getLookControl().lookAt(x, y, z); -+ } -+ -+ @Override -+ public void lookAt(double x, double y, double z, float headRotationSpeed, float maxHeadPitch) { -+ getHandle().getLookControl().lookAt(x, y, z, headRotationSpeed, maxHeadPitch); -+ } -+ -+ @Override -+ public int getHeadRotationSpeed() { -+ return getHandle().getHeadRotSpeed(); -+ } -+ -+ @Override -+ public int getMaxHeadPitch() { -+ return getHandle().getMaxHeadXRot(); -+ } - // Paper end - } diff --git a/patches/server-remapped/Clear-SyncLoadInfo.patch b/patches/server-remapped/Clear-SyncLoadInfo.patch deleted file mode 100644 index 6b97609186..0000000000 --- a/patches/server-remapped/Clear-SyncLoadInfo.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Tom -Date: Fri, 26 Feb 2021 16:10:53 -0600 -Subject: [PATCH] Clear SyncLoadInfo - -This patch merely adds the extra argument "clear" after /paper syncloadinfo to clear currently stored syncload info. - -diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/com/destroystokyo/paper/PaperCommand.java -+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java -@@ -0,0 +0,0 @@ public class PaperCommand extends Command { - sender.sendMessage(ChatColor.RED + "This command requires the server startup flag '-Dpaper.debug-sync-loads=true' to be set."); - return; - } -+ -+ if (args.length > 1 && args[1].equals("clear")) { -+ SyncLoadFinder.clear(); -+ sender.sendMessage(ChatColor.GRAY + "Sync load data cleared."); -+ return; -+ } -+ - File file = new File(new File(new File("."), "debug"), - "sync-load-info" + DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss").format(LocalDateTime.now()) + ".txt"); - file.getParentFile().mkdirs(); -diff --git a/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java b/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java -+++ b/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java -@@ -0,0 +0,0 @@ public class SyncLoadFinder { - public final Long2IntOpenHashMap coordinateTimes = new Long2IntOpenHashMap(); - } - -+ public static void clear() { -+ SYNC_LOADS.clear(); -+ } -+ - public static void logSyncLoad(final Level world, final int chunkX, final int chunkZ) { - if (!ENABLED) { - return; diff --git a/patches/server-remapped/Expose-Tracked-Players.patch b/patches/server-remapped/Expose-Tracked-Players.patch deleted file mode 100644 index 54d3f61fa5..0000000000 --- a/patches/server-remapped/Expose-Tracked-Players.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Tom -Date: Fri, 26 Feb 2021 16:24:25 -0600 -Subject: [PATCH] Expose Tracked Players - - -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s - public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper - private CraftEntity bukkitEntity; - -- ChunkMap.TrackedEntity tracker; // Paper -+ public ChunkMap.TrackedEntity tracker; // Paper package private -> public - public boolean collisionLoadChunks = false; // Paper - public Throwable addedToWorldStack; // Paper - entity debug - public CraftEntity getBukkitEntity() { -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -0,0 +0,0 @@ import java.net.InetSocketAddress; - import java.net.SocketAddress; - import java.util.ArrayList; - import java.util.Collection; -+import java.util.Collections; // Paper - import java.util.HashMap; - import java.util.HashSet; - import java.util.LinkedHashMap; -@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - } - // Paper end - -+ // Paper start -+ @Override -+ public Set getTrackedPlayers() { -+ if (entity.tracker == null) { -+ return Collections.emptySet(); -+ } -+ -+ Set set = new HashSet<>(entity.tracker.seenBy.size()); -+ for (ServerPlayer entityPlayer : entity.tracker.seenBy) { -+ set.add(entityPlayer.getBukkitEntity().getPlayer()); -+ } -+ return set; -+ } -+ // Paper end -+ - // Spigot start - private final Player.Spigot spigot = new Player.Spigot() - { diff --git a/patches/server-remapped/Fix-MC-148809-Increase-structure-block-data-length-t.patch b/patches/server-remapped/Fix-MC-148809-Increase-structure-block-data-length-t.patch deleted file mode 100644 index 2160990bec..0000000000 --- a/patches/server-remapped/Fix-MC-148809-Increase-structure-block-data-length-t.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: SamB440 -Date: Fri, 21 May 2021 00:22:09 +0100 -Subject: [PATCH] Fix MC-148809: Increase structure block data length to 128 - - -diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetStructureBlockPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetStructureBlockPacket.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetStructureBlockPacket.java -+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetStructureBlockPacket.java -@@ -0,0 +0,0 @@ public class ServerboundSetStructureBlockPacket implements Packet -Date: Mon, 10 May 2021 15:46:57 -0700 -Subject: [PATCH] Fix incorrect status dataconverter for pre 1.13 chunks - -Vanilla was setting non-populated OR non-lit chunks to empty, but -really this is just completely wrong. It should be set to "carved" -at minmum, because pre 1.13 chunks went through 3 distinct stages -of generation: carving, population, and lighting - in this order. -There is no "empty" status, because a chunk was simply carved -or it didn't exist. So mapping any chunk data to empty is simply -invalid. - -If the chunk is terrain populated, then obviously it must be at -minmum "decorated." If the chunk is lit and populated, then it is marked -"mobs_spawned" (which is what Vanilla is doing, and this is the last -stage before moving to full so it looks correct). - -So now here is a table representing the new status conversion: - -Chunk is lit Chunk is populated Vanilla - F F empty - T F empty - F T empty - T T mobs_spawned - -Chunk is lit Chunk is populated Paper - F F carved - T F carved - F T decorated - T T mobs_spawned - -This should fix some problems converting old data, as the -changes here are going to prevent the chunk from being regenerated -incorrectly. - -diff --git a/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java b/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java -+++ b/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java -@@ -0,0 +0,0 @@ public class ChunkToProtochunkFix extends DataFix { - return dynamic.asStreamOpt().result(); - }); - Dynamic dynamic = (Dynamic) typed1.get(DSL.remainderFinder()); -- boolean flag = dynamic.get("TerrainPopulated").asBoolean(false) && (!dynamic.get("LightPopulated").asNumber().result().isPresent() || dynamic.get("LightPopulated").asBoolean(false)); -- -- dynamic = dynamic.set("Status", dynamic.createString(flag ? "mobs_spawned" : "empty")); -+ // Paper start - fix incorrect status conversion -+ // Vanilla is setting chunks to incorrect status here, they should be using at minimum carved. -+ // for populated chunks, it should be at minimum decorated -+ // and for lit and populated, mobs_spawned is correct (technically mobs_spawned should be for populated, -+ // but if it's not lit then it can't be set above lit) -+ final boolean terrainPopulated = dynamic.get("TerrainPopulated").asBoolean(false); -+ final boolean lightPopulated = dynamic.get("LightPopulated").asBoolean(false) || dynamic.get("LightPopulated").asNumber().result().isPresent(); -+ final String newStatus = !terrainPopulated ? "carved" : (lightPopulated ? "mobs_spawned" : "decorated"); -+ -+ dynamic = dynamic.set("Status", dynamic.createString(newStatus)); - dynamic = dynamic.set("hasLegacyStructureData", dynamic.createBoolean(true)); -- Dynamic dynamic1; -+ // Paper end - fix incorrect status conversion -+ Dynamic dynamic1; // Paper - decompile fix - -- if (flag) { -+ if (true) { // Paper - fix incorrect status conversion - Optional optional1 = dynamic.get("Biomes").asByteBufferOpt().result(); - - if (optional1.isPresent()) { -@@ -0,0 +0,0 @@ public class ChunkToProtochunkFix extends DataFix { - }).collect(Collectors.toList()); - - if (optional.isPresent()) { -- ((Stream) optional.get()).forEach((dynamic2) -> { -+ optional.get().forEach((dynamic2) -> { // Paper - decompile fix - int j = dynamic2.get("x").asInt(0); - int k = dynamic2.get("y").asInt(0); - int l = dynamic2.get("z").asInt(0); -@@ -0,0 +0,0 @@ public class ChunkToProtochunkFix extends DataFix { - - ((ShortList) list.get(k >> 4)).add(short0); - }); -+ Dynamic finalDynamic = dynamic; // Paper - decompile fix - dynamic = dynamic.set("ToBeTicked", dynamic.createList(list.stream().map((shortlist) -> { -- Stream stream = shortlist.stream(); -+ Stream stream = shortlist.stream(); // Paper - decompile fix - -- dynamic.getClass(); -- return dynamic.createList(stream.map(dynamic::createShort)); -+ return finalDynamic.createList(stream.map(finalDynamic::createShort)); - }))); - } - diff --git a/patches/server-remapped/Implement-Keyed-on-World.patch b/patches/server-remapped/Implement-Keyed-on-World.patch deleted file mode 100644 index 0367060789..0000000000 --- a/patches/server-remapped/Implement-Keyed-on-World.patch +++ /dev/null @@ -1,110 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Wed, 6 Jan 2021 00:34:04 -0800 -Subject: [PATCH] Implement Keyed on World - - -diff --git a/src/main/java/net/minecraft/core/Registry.java b/src/main/java/net/minecraft/core/Registry.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/core/Registry.java -+++ b/src/main/java/net/minecraft/core/Registry.java -@@ -0,0 +0,0 @@ public abstract class Registry implements Codec, Keyable, IdMap { - public static final ResourceKey> LOOT_FUNCTION_REGISTRY = createRegistryKey("loot_function_type"); - public static final ResourceKey> LOOT_ITEM_REGISTRY = createRegistryKey("loot_condition_type"); - public static final ResourceKey> DIMENSION_TYPE_REGISTRY = createRegistryKey("dimension_type"); -- public static final ResourceKey> DIMENSION_REGISTRY = createRegistryKey("dimension"); -+ public static final ResourceKey> DIMENSION_REGISTRY = createRegistryKey("dimension"); public static final ResourceKey> getWorldRegistry() { return DIMENSION_REGISTRY; } // Paper - OBFHELPER - public static final ResourceKey> LEVEL_STEM_REGISTRY = createRegistryKey("dimension"); - public static final Registry SOUND_EVENT = registerSimple(Registry.SOUND_EVENT_REGISTRY, () -> { - return SoundEvents.ITEM_PICKUP; -@@ -0,0 +0,0 @@ public abstract class Registry implements Codec, Keyable, IdMap { - ResourceLocation minecraftkey = resourcekey.location(); - - Registry.LOADERS.put(minecraftkey, defaultEntry); -- WritableRegistry iregistrywritable = Registry.WRITABLE_REGISTRY; -+ WritableRegistry iregistrywritable = Registry.WRITABLE_REGISTRY; // Paper - decompile fix - -- return (WritableRegistry) iregistrywritable.register(resourcekey, (Object) registry, lifecycle); -+ return (R) iregistrywritable.register(resourcekey, (Object) registry, lifecycle); // Paper - decompile fix - } - - protected Registry(ResourceKey> key, Lifecycle lifecycle) { -@@ -0,0 +0,0 @@ public abstract class Registry implements Codec, Keyable, IdMap { - } - - public static T register(Registry registry, ResourceLocation id, T entry) { -- return ((WritableRegistry) registry).register(ResourceKey.create(registry.key, id), entry, Lifecycle.stable()); -+ return ((WritableRegistry) registry).register(ResourceKey.create(registry.key, id), entry, Lifecycle.stable()); // Paper - decompile fix - } - - public static T registerMapping(Registry registry, int rawId, String id, T entry) { -- return ((WritableRegistry) registry).registerMapping(rawId, ResourceKey.create(registry.key, new ResourceLocation(id)), entry, Lifecycle.stable()); -+ return ((WritableRegistry) registry).registerMapping(rawId, ResourceKey.create(registry.key, new ResourceLocation(id)), entry, Lifecycle.stable()); // Paper - decompile fix - } - - static { -diff --git a/src/main/java/net/minecraft/resources/ResourceKey.java b/src/main/java/net/minecraft/resources/ResourceKey.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/resources/ResourceKey.java -+++ b/src/main/java/net/minecraft/resources/ResourceKey.java -@@ -0,0 +0,0 @@ public class ResourceKey { - private final ResourceLocation registryName; - private final ResourceLocation location; - -+ public static ResourceKey newResourceKey(ResourceKey> registryKey, ResourceLocation minecraftKey) { return create(registryKey, minecraftKey); } // Paper - OBFHELPER - public static ResourceKey create(ResourceKey> registry, ResourceLocation value) { - return create(registry.location, value); - } -@@ -0,0 +0,0 @@ public class ResourceKey { - return this.registryName.equals(registry.location()); - } - -+ public ResourceLocation getLocation() { return location(); } // Paper - OBFHELPER - public ResourceLocation location() { - return this.location; - } -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -0,0 +0,0 @@ public final class CraftServer implements Server { - } else if (name.equals(levelName + "_the_end")) { - worldKey = net.minecraft.world.level.Level.END; - } else { -- worldKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(name.toLowerCase(java.util.Locale.ENGLISH))); -+ worldKey = ResourceKey.newResourceKey(Registry.getWorldRegistry(), new net.minecraft.resources.ResourceLocation(creator.key().getNamespace().toLowerCase(java.util.Locale.ENGLISH), creator.key().getKey().toLowerCase(java.util.Locale.ENGLISH))); // Paper - } - - ServerLevel internal = (ServerLevel) new ServerLevel(console, console.executor, worldSession, worlddata, worldKey, dimensionmanager, getServer().progressListenerFactory.create(11), -@@ -0,0 +0,0 @@ public final class CraftServer implements Server { - return null; - } - -+ // Paper start -+ @Override -+ public World getWorld(NamespacedKey worldKey) { -+ ServerLevel worldServer = console.getLevel(ResourceKey.newResourceKey(Registry.getWorldRegistry(), CraftNamespacedKey.toMinecraft(worldKey))); -+ if (worldServer == null) return null; -+ return worldServer.getWorld(); -+ } -+ // Paper end -+ - public void addWorld(World world) { - // Check if a World already exists with the UID. - if (getWorld(world.getUID()) != null) { -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -0,0 +0,0 @@ public class CraftWorld implements World { - return CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk()); - }, net.minecraft.server.MinecraftServer.getServer()); - } -+ -+ @Override -+ public org.bukkit.NamespacedKey getKey() { -+ return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(world.dimension().getLocation()); -+ } - // Paper end - - // Spigot start diff --git a/patches/server-remapped/Make-sure-to-remove-correct-TE-during-TE-tick.patch b/patches/server-remapped/Make-sure-to-remove-correct-TE-during-TE-tick.patch deleted file mode 100644 index 71eb1ebcf1..0000000000 --- a/patches/server-remapped/Make-sure-to-remove-correct-TE-during-TE-tick.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Spottedleaf -Date: Mon, 29 Mar 2021 09:07:25 +0200 -Subject: [PATCH] Make sure to remove correct TE during TE tick - -This looks like it can cause premature TE removal. - -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - //this.tileEntityList.remove(tileentity); // Paper - remove unused list - // Paper - prevent double chunk lookups - LevelChunk chunk; if ((chunk = this.getChunkIfLoaded(tileentity.getBlockPos())) != null) { // inlined contents of this.isLoaded(BlockPosition). Reuse the returned chunk instead of looking it up again -- chunk.removeBlockEntity(tileentity.getBlockPos()); -+ chunk.removeTileEntity(tileentity.getBlockPos(), tileentity); // Paper - remove correct TE - } - // Paper end - } -diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -0,0 +0,0 @@ public class LevelChunk implements ChunkAccess { - - @Override - public void removeBlockEntity(BlockPos pos) { -+ // Paper start - remove correct TE -+ removeTileEntity(pos, null); -+ } -+ public void removeTileEntity(BlockPos blockposition, BlockEntity match) { -+ // Paper end - if (this.loaded || this.world.isClientSide()) { -- BlockEntity tileentity = (BlockEntity) this.blockEntities.remove(pos); -+ // Paper start -+ BlockEntity tileentity = (BlockEntity) this.blockEntities.get(blockposition); - -- if (tileentity != null) { -+ if (tileentity != null && (match == null || match == tileentity)) { -+ this.blockEntities.remove(blockposition); -+ // Paper end - tileentity.setRemoved(); - } - } diff --git a/patches/server-remapped/More-World-API.patch b/patches/server-remapped/More-World-API.patch deleted file mode 100644 index acf8b33db4..0000000000 --- a/patches/server-remapped/More-World-API.patch +++ /dev/null @@ -1,146 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Tue, 7 Jul 2020 10:52:34 -0700 -Subject: [PATCH] More World API - - -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl - return !this.worldDataServer.worldGenSettings().generateFeatures() ? null : this.getChunkSource().getGenerator().findNearestMapFeature(this, feature, pos, radius, skipExistingChunks); // CraftBukkit - } - -+ public BlockPos getNearestBiome(Biome biomeBase, BlockPos blockPosition, int radius, int step) { return this.findNearestBiome(biomeBase, blockPosition, radius, step); } // Paper - OBFHELPER - @Nullable - public BlockPos findNearestBiome(Biome biome, BlockPos pos, int radius, int j) { - return this.getChunkSource().getGenerator().getBiomeSource().findBiomeHorizontal(pos.getX(), pos.getY(), pos.getZ(), radius, j, (biomebase1) -> { -@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl - return this.noSave; - } - -+ public RegistryAccess getWorldCustomRegistry() { return registryAccess(); } // Paper - OBFHELPER - @Override - public RegistryAccess registryAccess() { - return this.server.registryAccess(); -diff --git a/src/main/java/net/minecraft/world/level/dimension/DimensionType.java b/src/main/java/net/minecraft/world/level/dimension/DimensionType.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/dimension/DimensionType.java -+++ b/src/main/java/net/minecraft/world/level/dimension/DimensionType.java -@@ -0,0 +0,0 @@ public class DimensionType { - public static RegistryAccess.RegistryHolder registerBuiltin(RegistryAccess.RegistryHolder registryManager) { - WritableRegistry iregistrywritable = registryManager.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY); - -- iregistrywritable.register(DimensionType.OVERWORLD_LOCATION, (Object) DimensionType.DEFAULT_OVERWORLD, Lifecycle.stable()); -- iregistrywritable.register(DimensionType.OVERWORLD_CAVES_LOCATION, (Object) DimensionType.DEFAULT_OVERWORLD_CAVES, Lifecycle.stable()); -- iregistrywritable.register(DimensionType.NETHER_LOCATION, (Object) DimensionType.DEFAULT_NETHER, Lifecycle.stable()); -- iregistrywritable.register(DimensionType.END_LOCATION, (Object) DimensionType.DEFAULT_END, Lifecycle.stable()); -+ iregistrywritable.register(DimensionType.OVERWORLD_LOCATION, DimensionType.DEFAULT_OVERWORLD, Lifecycle.stable()); // Paper - decompile fix -+ iregistrywritable.register(DimensionType.OVERWORLD_CAVES_LOCATION, DimensionType.DEFAULT_OVERWORLD_CAVES, Lifecycle.stable()); // Paper - decompile fix -+ iregistrywritable.register(DimensionType.NETHER_LOCATION, DimensionType.DEFAULT_NETHER, Lifecycle.stable()); // Paper - decompile fix -+ iregistrywritable.register(DimensionType.END_LOCATION, DimensionType.DEFAULT_END, Lifecycle.stable()); // Paper - decompile fix - return registryManager; - } - -@@ -0,0 +0,0 @@ public class DimensionType { - public static MappedRegistry defaultDimensions(Registry dimensionRegistry, Registry biomeRegistry, Registry chunkGeneratorSettingsRegistry, long seed) { - MappedRegistry registrymaterials = new MappedRegistry<>(Registry.LEVEL_STEM_REGISTRY, Lifecycle.experimental()); - -- registrymaterials.register(LevelStem.NETHER, (Object) (new LevelStem(() -> { -+ registrymaterials.register(LevelStem.NETHER, (new LevelStem(() -> { // Paper - decompile fix - return (DimensionType) dimensionRegistry.getOrThrow(DimensionType.NETHER_LOCATION); - }, defaultNetherGenerator(biomeRegistry, chunkGeneratorSettingsRegistry, seed))), Lifecycle.stable()); -- registrymaterials.register(LevelStem.END, (Object) (new LevelStem(() -> { -+ registrymaterials.register(LevelStem.END, (new LevelStem(() -> { // Paper - decompile fix - return (DimensionType) dimensionRegistry.getOrThrow(DimensionType.END_LOCATION); - }, defaultEndGenerator(biomeRegistry, chunkGeneratorSettingsRegistry, seed))), Lifecycle.stable()); - return registrymaterials; -@@ -0,0 +0,0 @@ public class DimensionType { - return this.brightnessRamp[i]; - } - -+ public Tag getInfiniburnTag() { return infiniburn(); } // Paper - OBFHELPER - public Tag infiniburn() { - Tag tag = BlockTags.getAllTags().getTag(this.infiniburn); - -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -0,0 +0,0 @@ public class CraftWorld implements World { - return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ()); - } - -+ // Paper start -+ @Override -+ public Location locateNearestBiome(Location origin, Biome biome, int radius) { -+ return this.locateNearestBiome(origin, biome, radius, 8); -+ } -+ -+ @Override -+ public Location locateNearestBiome(Location origin, Biome biome, int radius, int step) { -+ BlockPos originPos = new BlockPos(origin.getX(), origin.getY(), origin.getZ()); -+ BlockPos nearest = getHandle().getNearestBiome(CraftBlock.biomeToBiomeBase(getHandle().getWorldCustomRegistry().registryOrThrow(Registry.BIOME_REGISTRY), biome), originPos, radius, step); -+ return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ()); -+ } -+ -+ @Override -+ public boolean isUltrawarm() { -+ return getHandle().dimensionType().ultraWarm(); -+ } -+ -+ @Override -+ public boolean isNatural() { -+ return getHandle().dimensionType().natural(); -+ } -+ -+ @Override -+ public double getCoordinateScale() { -+ return getHandle().dimensionType().coordinateScale(); -+ } -+ -+ @Override -+ public boolean hasSkylight() { -+ return getHandle().dimensionType().hasSkyLight(); -+ } -+ -+ @Override -+ public boolean hasBedrockCeiling() { -+ return getHandle().dimensionType().hasSkyLight(); -+ } -+ -+ @Override -+ public boolean isPiglinSafe() { -+ return getHandle().dimensionType().piglinSafe(); -+ } -+ -+ @Override -+ public boolean doesBedWork() { -+ return getHandle().dimensionType().bedWorks(); -+ } -+ -+ @Override -+ public boolean doesRespawnAnchorWork() { -+ return getHandle().dimensionType().respawnAnchorWorks(); -+ } -+ -+ @Override -+ public boolean hasRaids() { -+ return getHandle().dimensionType().hasRaids(); -+ } -+ -+ @Override -+ public boolean isFixedTime() { -+ return getHandle().dimensionType().hasFixedTime(); -+ } -+ -+ @Override -+ public Collection getInfiniburn() { -+ return com.google.common.collect.Sets.newHashSet(com.google.common.collect.Iterators.transform(getHandle().dimensionType().getInfiniburnTag().getTagged().iterator(), CraftMagicNumbers::getMaterial)); -+ } -+ // Paper end -+ - @Override - public Raid locateNearestRaid(Location location, int radius) { - Validate.notNull(location, "Location cannot be null"); diff --git a/patches/server-remapped/additions-to-PlayerGameModeChangeEvent.patch b/patches/server-remapped/additions-to-PlayerGameModeChangeEvent.patch deleted file mode 100644 index b43161b56a..0000000000 --- a/patches/server-remapped/additions-to-PlayerGameModeChangeEvent.patch +++ /dev/null @@ -1,138 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Sat, 15 May 2021 10:04:43 -0700 -Subject: [PATCH] additions to PlayerGameModeChangeEvent - - -diff --git a/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java b/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java -+++ b/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java -@@ -0,0 +0,0 @@ public class DefaultGameModeCommands { - ServerPlayer entityplayer = (ServerPlayer) iterator.next(); - - if (entityplayer.gameMode.getGameModeForPlayer() != defaultGameMode) { -- entityplayer.setGameMode(defaultGameMode); -+ // Paper start - handle event cancelling the change -+ org.bukkit.event.player.PlayerGameModeChangeEvent event = entityplayer.setGamemode(defaultGameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, net.kyori.adventure.text.Component.text("Failed to set the gamemode of '" + entityplayer.getScoreboardName() + "'", net.kyori.adventure.text.format.NamedTextColor.RED)); -+ if (event != null && event.isCancelled()) { -+ source.sendSuccess(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.cancelMessage()), false); -+ continue; -+ } -+ // Paper end - ++i; - } - } -diff --git a/src/main/java/net/minecraft/server/commands/GameModeCommand.java b/src/main/java/net/minecraft/server/commands/GameModeCommand.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/commands/GameModeCommand.java -+++ b/src/main/java/net/minecraft/server/commands/GameModeCommand.java -@@ -0,0 +0,0 @@ public class GameModeCommand { - ServerPlayer entityplayer = (ServerPlayer) iterator.next(); - - if (entityplayer.gameMode.getGameModeForPlayer() != gameMode) { -- entityplayer.setGameMode(gameMode); -- // CraftBukkit start - handle event cancelling the change -- if (entityplayer.gameMode.getGameModeForPlayer() != gameMode) { -- context.getSource().sendFailure(new net.minecraft.network.chat.TextComponent("Failed to set the gamemode of '" + entityplayer.getScoreboardName() + "'")); -+ // Paper start - handle event cancelling the change -+ org.bukkit.event.player.PlayerGameModeChangeEvent event = entityplayer.setGamemode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.COMMAND, net.kyori.adventure.text.Component.text("Failed to set the gamemode of '" + entityplayer.getScoreboardName() + "'", net.kyori.adventure.text.format.NamedTextColor.RED)); -+ if (event != null && event.isCancelled()) { -+ context.getSource().sendSuccess(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.cancelMessage()), false); - continue; - } -- // CraftBukkit end -+ // Paper end - logGamemodeChange((CommandSourceStack) context.getSource(), entityplayer, gameMode); - ++i; - } -diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/level/ServerPlayer.java -+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener { - if (this.getY() > 300) this.setPosRaw(getX(), 257, getZ()); // Paper - bring down to a saner Y level if out of world - if (tag.contains("playerGameType", 99)) { - if (this.getServer().getForceGameType()) { -+ // Paper start - call PlayerGameModeChangeEvent on join for players that do not have the correct gamemode -+ if (this.getServer().getDefaultGameType() != GameType.byId(tag.getInt("playerGameType"))) { -+ if (new org.bukkit.event.player.PlayerGameModeChangeEvent(this.getBukkitEntity(), GameMode.getByValue(this.getServer().getDefaultGameType().getId()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null).callEvent()) { - this.gameMode.setGameModeForPlayer(this.getServer().getDefaultGameType(), GameType.NOT_SET); -+ } else { -+ this.gameMode.setGameModeForPlayer(GameType.byId(tag.getInt("playerGameType")), tag.contains("previousPlayerGameType", 3) ? GameType.byId(tag.getInt("previousPlayerGameType")) : GameType.NOT_SET); // copied from below; if cancelled, set gamemode normally -+ } -+ } else { -+ this.gameMode.setGameModeForPlayer(GameType.byId(tag.getInt("playerGameType")), tag.contains("previousPlayerGameType", 3) ? GameType.byId(tag.getInt("previousPlayerGameType")) : GameType.NOT_SET); // copied from below; if no change needed, set gamemode normally -+ } // Paper end - } else { - this.gameMode.setGameModeForPlayer(GameType.byId(tag.getInt("playerGameType")), tag.contains("previousPlayerGameType", 3) ? GameType.byId(tag.getInt("previousPlayerGameType")) : GameType.NOT_SET); - } -@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener { - - @Override - public void setGameMode(GameType gameMode) { -+ // Paper start - Add cause and nullable message to event -+ setGamemode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.UNKNOWN, null); -+ } -+ -+ public PlayerGameModeChangeEvent setGamemode(GameType enumgamemode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause cause, net.kyori.adventure.text.Component message) { -+ // Paper end - // CraftBukkit start -- if (gameMode == this.gameMode.getGameModeForPlayer()) { -- return; -+ if (enumgamemode == this.gameMode.getGameModeForPlayer()) { -+ return null; // Paper - } - -- PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(getBukkitEntity(), GameMode.getByValue(gameMode.getId())); -+ PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(getBukkitEntity(), GameMode.getByValue(enumgamemode.getId()), cause, message); // Paper - level.getCraftServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { -- return; -+ return event; // Paper - } - // CraftBukkit end - -- this.gameMode.setGameModeForPlayer(gameMode); -- this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float) gameMode.getId())); -- if (gameMode == GameType.SPECTATOR) { -+ this.gameMode.setGameModeForPlayer(enumgamemode); -+ this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float) enumgamemode.getId())); -+ if (enumgamemode == GameType.SPECTATOR) { - this.removeEntitiesOnShoulder(); - this.stopRiding(); - } else { -@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener { - - this.onUpdateAbilities(); - this.updateEffectVisibility(); -+ return event; // Paper - } - - @Override -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { - - this.player = this.server.getPlayerList().respawn(this.player, false); - if (this.server.isHardcore()) { -- this.player.setGameMode(GameType.SPECTATOR); -+ this.player.setGamemode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper - ((GameRules.BooleanValue) this.player.getLevel().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server); - } - } -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - throw new IllegalArgumentException("Mode cannot be null"); - } - -- getHandle().setGameMode(GameType.byId(mode.getValue())); -+ getHandle().setGamemode(GameType.byId(mode.getValue()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.PLUGIN, null); // Paper - } - - @Override diff --git a/patches/server-remapped/do-not-create-unnecessary-copies-of-passenger-list.patch b/patches/server-remapped/do-not-create-unnecessary-copies-of-passenger-list.patch deleted file mode 100644 index 8e858b2948..0000000000 --- a/patches/server-remapped/do-not-create-unnecessary-copies-of-passenger-list.patch +++ /dev/null @@ -1,239 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: lukas81298 -Date: Sun, 13 Dec 2020 13:42:55 +0100 -Subject: [PATCH] do not create unnecessary copies of passenger list - - -diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPassengersPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPassengersPacket.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPassengersPacket.java -+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPassengersPacket.java -@@ -0,0 +0,0 @@ public class ClientboundSetPassengersPacket implements Packet list = entity.getPassengers(); -+ List list = entity.passengers; // Paper - do not create a copy of the list - - this.passengers = new int[list.size()]; - -diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -0,0 +0,0 @@ Sections go from 0..16. Now whenever a section is not empty, it can potentially - list.add(entity); - } - -- if (!entity.getPassengers().isEmpty()) { -+ if (!entity.passengers.isEmpty()) { // Paper - do not copy list - list1.add(entity); - } - } -diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/level/ServerEntity.java -+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -0,0 +0,0 @@ public class ServerEntity { - - public final void tick() { this.sendChanges(); } // Paper - OBFHELPER - public void sendChanges() { -- List list = this.entity.getPassengers(); -+ List list = this.entity.passengers; // Paper - do not copy list - - if (!list.equals(this.lastPassengers)) { -- this.lastPassengers = list; -+ this.lastPassengers = com.google.common.collect.ImmutableList.copyOf(list); // Paper - only copy list if something has changed - this.broadcastAndSend(new ClientboundSetPassengersPacket(this.entity)); // CraftBukkit - } - -@@ -0,0 +0,0 @@ public class ServerEntity { - } - } - -- if (!this.entity.getPassengers().isEmpty()) { -+ if (!this.entity.passengers.isEmpty()) { // Paper - do not create copy of list - consumer.accept(new ClientboundSetPassengersPacket(this.entity)); - } - -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s - } - - protected boolean canAddPassenger(Entity passenger) { -- return this.getPassengers().size() < 1; -+ return this.passengers.size() < 1; // Paper - do not copy list - } - - public final float getCollisionBorderSize() { return getPickRadius(); } // Paper - OBFHELPER -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s - } - - public boolean isVehicle() { -- return !this.getPassengers().isEmpty(); -+ return !this.passengers.isEmpty(); // Paper - do not copy list - } - - public boolean rideableUnderWater() { -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s - } - - public boolean hasPassenger(Entity passenger) { -- Iterator iterator = this.getPassengers().iterator(); -+ Iterator iterator = this.passengers.iterator(); // Paper - do not copy list - - Entity entity1; - -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s - } - - public boolean hasPassenger(Class clazz) { -- Iterator iterator = this.getPassengers().iterator(); -+ Iterator iterator = this.passengers.iterator(); // Paper - do not copy list - - Entity entity; - -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s - - public Collection getIndirectPassengers() { - Set set = Sets.newHashSet(); -- Iterator iterator = this.getPassengers().iterator(); -+ Iterator iterator = this.passengers.iterator(); // Paper - do not copy list - - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s - private void fillIndirectPassengers(boolean playersOnly, Set output) { - Entity entity; - -- for (Iterator iterator = this.getPassengers().iterator(); iterator.hasNext(); entity.fillIndirectPassengers(playersOnly, output)) { -+ for (Iterator iterator = this.passengers.iterator(); iterator.hasNext(); entity.fillIndirectPassengers(playersOnly, output)) { // Paper - do not copy list - entity = (Entity) iterator.next(); - if (!playersOnly || ServerPlayer.class.isAssignableFrom(entity.getClass())) { - output.add(entity); -diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java -+++ b/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java -@@ -0,0 +0,0 @@ public class RunAroundLikeCrazyGoal extends Goal { - @Override - public void tick() { - if (!this.horse.isTamed() && this.horse.getRandom().nextInt(50) == 0) { -- Entity entity = (Entity) this.horse.getPassengers().get(0); -+ Entity entity = this.horse.passengers.isEmpty() ? null : this.horse.passengers.get(0); // Paper - do not copy list, fixed array out of bounds exception as well - - if (entity == null) { - return; -diff --git a/src/main/java/net/minecraft/world/entity/animal/Pig.java b/src/main/java/net/minecraft/world/entity/animal/Pig.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/Pig.java -+++ b/src/main/java/net/minecraft/world/entity/animal/Pig.java -@@ -0,0 +0,0 @@ public class Pig extends Animal implements ItemSteerable, Saddleable { - @Nullable - @Override - public Entity getControllingPassenger() { -- return this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0); -+ return this.passengers.isEmpty() ? null : (Entity) this.passengers.get(0); // Paper - do not copy list - } - - @Override -diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java -+++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java -@@ -0,0 +0,0 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, - @Nullable - @Override - public Entity getControllingPassenger() { -- return this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0); -+ return this.passengers.isEmpty() ? null : (Entity) this.passengers.get(0); // Paper - do not copy list - } - - @Nullable -diff --git a/src/main/java/net/minecraft/world/entity/monster/Ravager.java b/src/main/java/net/minecraft/world/entity/monster/Ravager.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/Ravager.java -+++ b/src/main/java/net/minecraft/world/entity/monster/Ravager.java -@@ -0,0 +0,0 @@ public class Ravager extends Raider { - @Nullable - @Override - public Entity getControllingPassenger() { -- return this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0); -+ return this.passengers.isEmpty() ? null : (Entity) this.passengers.get(0); // Paper - do not copy list - } - - @Override -diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java -+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java -@@ -0,0 +0,0 @@ public abstract class AbstractMinecart extends Entity { - - vec3d1 = new Vec3(d8 * d4 / d6, vec3d1.y, d8 * d5 / d6); - this.setDeltaMovement(vec3d1); -- Entity entity = this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0); -+ Entity entity = this.passengers.isEmpty() ? null : (Entity) this.passengers.get(0); // Paper - do not copy list - - if (entity instanceof Player) { - Vec3 vec3d2 = entity.getDeltaMovement(); -diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java -+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java -@@ -0,0 +0,0 @@ public class Boat extends Entity { - super.tick(); - this.tickLerp(); - if (this.isControlledByLocalInstance()) { -- if (this.getPassengers().isEmpty() || !(this.getPassengers().get(0) instanceof Player)) { -+ if (this.passengers.isEmpty() || !(this.passengers.get(0) instanceof Player)) { // Paper - do not copy list - this.setPaddleState(false, false); - } - -@@ -0,0 +0,0 @@ public class Boat extends Entity { - Entity entity = (Entity) list.get(j); - - if (!entity.hasPassenger(this)) { -- if (flag && this.getPassengers().size() < 2 && !entity.isPassenger() && entity.getBbWidth() < this.getBbWidth() && entity instanceof LivingEntity && !(entity instanceof WaterAnimal) && !(entity instanceof Player)) { -+ if (flag && this.passengers.size() < 2 && !entity.isPassenger() && entity.getBbWidth() < this.getBbWidth() && entity instanceof LivingEntity && !(entity instanceof WaterAnimal) && !(entity instanceof Player)) { // Paper - do not copy passenger list - entity.startRiding(this); - } else { - this.push(entity); -@@ -0,0 +0,0 @@ public class Boat extends Entity { - float f = 0.0F; - float f1 = (float) ((this.removed ? 0.009999999776482582D : this.getPassengersRidingOffset()) + passenger.getMyRidingOffset()); - -- if (this.getPassengers().size() > 1) { -- int i = this.getPassengers().indexOf(passenger); -+ if (this.passengers.size() > 1) { // Paper - do not copy list -+ int i = this.passengers.indexOf(passenger); // Paper - do not copy list - - if (i == 0) { - f = 0.2F; -@@ -0,0 +0,0 @@ public class Boat extends Entity { - passenger.yRot += this.deltaRotation; - passenger.setYHeadRot(passenger.getYHeadRot() + this.deltaRotation); - this.clampRotation(passenger); -- if (passenger instanceof Animal && this.getPassengers().size() > 1) { -+ if (passenger instanceof Animal && this.passengers.size() > 1) { // Paper - do not copy list - int j = passenger.getId() % 2 == 0 ? 90 : 270; - - passenger.setYBodyRot(((Animal) passenger).yBodyRot + (float) j); -@@ -0,0 +0,0 @@ public class Boat extends Entity { - - @Override - protected boolean canAddPassenger(Entity passenger) { -- return this.getPassengers().size() < 2 && !this.isEyeInFluid((Tag) FluidTags.WATER); -+ return this.passengers.size() < 2 && !this.isEyeInFluid((Tag) FluidTags.WATER); // Paper - do not copy list - } - - @Nullable - @Override - public Entity getControllingPassenger() { -- List list = this.getPassengers(); -+ List list = this.passengers; // Paper - do not copy list - - return list.isEmpty() ? null : (Entity) list.get(0); - } diff --git a/patches/server-remapped/don-t-throw-when-loading-invalid-TEs.patch b/patches/server-remapped/don-t-throw-when-loading-invalid-TEs.patch deleted file mode 100644 index 5cbf57947d..0000000000 --- a/patches/server-remapped/don-t-throw-when-loading-invalid-TEs.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Shane Freeder -Date: Tue, 20 Apr 2021 01:15:04 +0100 -Subject: [PATCH] don't throw when loading invalid TEs - - -diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -0,0 +0,0 @@ package net.minecraft.world.level.block.entity; - - import javax.annotation.Nullable; - import net.minecraft.CrashReportCategory; -+import net.minecraft.ResourceLocationException; - import net.minecraft.core.BlockPos; - import net.minecraft.core.Registry; - import net.minecraft.nbt.CompoundTag; -@@ -0,0 +0,0 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject { - public static BlockEntity loadStatic(BlockState state, CompoundTag tag) { - String s = tag.getString("id"); - -- return (BlockEntity) Registry.BLOCK_ENTITY_TYPE.getOptional(new ResourceLocation(s)).map((tileentitytypes) -> { -+ // Paper -+ ResourceLocation minecraftKey = null; -+ try { -+ minecraftKey = new ResourceLocation(s); -+ } catch (ResourceLocationException ex) {} -+ // Paper end -+ return (BlockEntity) Registry.BLOCK_ENTITY_TYPE.getOptional(minecraftKey).map((tileentitytypes) -> { - try { - return tileentitytypes.create(); - } catch (Throwable throwable) { diff --git a/patches/server-remapped/fix-PlayerItemHeldEvent-firing-twice.patch b/patches/server-remapped/fix-PlayerItemHeldEvent-firing-twice.patch deleted file mode 100644 index cbe63ced57..0000000000 --- a/patches/server-remapped/fix-PlayerItemHeldEvent-firing-twice.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: chickeneer -Date: Thu, 22 Apr 2021 19:02:07 -0700 -Subject: [PATCH] fix PlayerItemHeldEvent firing twice - - -diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java -+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java -@@ -0,0 +0,0 @@ public class ServerboundSetCarriedItemPacket implements Packet= 0 && packet.getSlot() < Inventory.getSelectionSize()) { -+ if (packet.getItemInHandIndex() == this.player.inventory.selected) { return; } // Paper - don't fire itemheldevent when there wasn't a slot change - PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.selected, packet.getSlot()); - this.craftServer.getPluginManager().callEvent(event); - if (event.isCancelled()) { diff --git a/patches/server/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch b/patches/server/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch new file mode 100644 index 0000000000..69390f83ec --- /dev/null +++ b/patches/server/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch @@ -0,0 +1,32 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Alvinn8 <42838560+Alvinn8@users.noreply.github.com> +Date: Fri, 8 Jan 2021 20:31:13 +0100 +Subject: [PATCH] Add Adventure message to PlayerAdvancementDoneEvent + + +diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java ++++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java +@@ -0,0 +0,0 @@ public class PlayerAdvancements { + this.progressChanged.add(advancement); + flag = true; + if (!flag1 && advancementprogress.isDone()) { +- this.player.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit ++ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent ++ boolean announceToChat = advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat(); ++ net.kyori.adventure.text.Component message = announceToChat ? io.papermc.paper.adventure.PaperAdventure.asAdventure(new TranslatableComponent("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), this.player.getDisplayName(), advancement.getChatComponent())) : null; ++ org.bukkit.event.player.PlayerAdvancementDoneEvent event = new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit, message); ++ this.player.level.getCraftServer().getPluginManager().callEvent(event); ++ message = event.message(); ++ // Paper end + advancement.getRewards().grant(this.player); +- if (advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat() && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { +- this.playerList.broadcastMessage(new TranslatableComponent("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), new Object[]{this.player.getDisplayName(), advancement.getChatComponent()}), ChatType.SYSTEM, Util.NIL_UUID); ++ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent ++ if (message != null && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { ++ this.playerList.broadcastMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), ChatType.SYSTEM, Util.NIL_UUID); ++ // Paper end + } + } + } diff --git a/patches/server-remapped/Add-Block-isValidTool.patch b/patches/server/Add-Block-isValidTool.patch similarity index 100% rename from patches/server-remapped/Add-Block-isValidTool.patch rename to patches/server/Add-Block-isValidTool.patch diff --git a/patches/server-remapped/Add-Channel-initialization-listeners.patch b/patches/server/Add-Channel-initialization-listeners.patch similarity index 97% rename from patches/server-remapped/Add-Channel-initialization-listeners.patch rename to patches/server/Add-Channel-initialization-listeners.patch index 8da1b9d013..af89c5c7fe 100644 --- a/patches/server-remapped/Add-Channel-initialization-listeners.patch +++ b/patches/server/Add-Channel-initialization-listeners.patch @@ -110,7 +110,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java +++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java @@ -0,0 +0,0 @@ public class ServerConnectionListener { - pending.add((Connection) object); // Paper + ServerConnectionListener.this.connections.add((Connection) object); // CraftBukkit - decompile error channel.pipeline().addLast("packet_handler", (ChannelHandler) object); ((Connection) object).setListener(new ServerHandshakePacketListenerImpl(ServerConnectionListener.this.server, (Connection) object)); + io.papermc.paper.network.ChannelInitializeListenerHolder.callListeners(channel); // Paper diff --git a/patches/server-remapped/Add-EntityBlockStorage-clearEntities.patch b/patches/server/Add-EntityBlockStorage-clearEntities.patch similarity index 98% rename from patches/server-remapped/Add-EntityBlockStorage-clearEntities.patch rename to patches/server/Add-EntityBlockStorage-clearEntities.patch index 5e46f93c86..04569f62f8 100644 --- a/patches/server-remapped/Add-EntityBlockStorage-clearEntities.patch +++ b/patches/server/Add-EntityBlockStorage-clearEntities.patch @@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEn index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -@@ -0,0 +0,0 @@ public class BeehiveBlockEntity extends BlockEntity implements TickableBlockEnti +@@ -0,0 +0,0 @@ public class BeehiveBlockEntity extends BlockEntity { return this.stored.size(); } diff --git a/patches/server-remapped/Add-EntityInsideBlockEvent.patch b/patches/server/Add-EntityInsideBlockEvent.patch similarity index 85% rename from patches/server-remapped/Add-EntityInsideBlockEvent.patch rename to patches/server/Add-EntityInsideBlockEvent.patch index d2b1570771..0a4c58a87b 100644 --- a/patches/server-remapped/Add-EntityInsideBlockEvent.patch +++ b/patches/server/Add-EntityInsideBlockEvent.patch @@ -37,9 +37,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - BlockState iblockdata1 = world.getBlockState(pos.above()); - - if (iblockdata1.isAir()) { + BlockState blockState = world.getBlockState(pos.above()); + if (blockState.isAir()) { + entity.onAboveBubbleCol(state.getValue(DRAG_DOWN)); diff --git a/src/main/java/net/minecraft/world/level/block/ButtonBlock.java b/src/main/java/net/minecraft/world/level/block/ButtonBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/ButtonBlock.java @@ -76,18 +76,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (!entity.fireImmune() && (Boolean) state.getValue(CampfireBlock.LIT) && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity) entity)) { entity.hurt(DamageSource.IN_FIRE, (float) this.fireDamage); } -diff --git a/src/main/java/net/minecraft/world/level/block/CauldronBlock.java b/src/main/java/net/minecraft/world/level/block/CauldronBlock.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/CauldronBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/CauldronBlock.java -@@ -0,0 +0,0 @@ public class CauldronBlock extends Block { - - @Override - public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { -+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - int i = (Integer) state.getValue(CauldronBlock.LEVEL); - float f = (float) pos.getY() + (6.0F + (float) (3 * i)) / 16.0F; - diff --git a/src/main/java/net/minecraft/world/level/block/CropBlock.java b/src/main/java/net/minecraft/world/level/block/CropBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/CropBlock.java @@ -145,9 +133,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - BlockEntity tileentity = world.getBlockEntity(pos); + BlockEntity blockEntity = world.getBlockEntity(pos); + if (blockEntity instanceof HopperBlockEntity) { + HopperBlockEntity.entityInside(world, pos, state, entity, (HopperBlockEntity)blockEntity); +diff --git a/src/main/java/net/minecraft/world/level/block/LavaCauldronBlock.java b/src/main/java/net/minecraft/world/level/block/LavaCauldronBlock.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/LavaCauldronBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/LavaCauldronBlock.java +@@ -0,0 +0,0 @@ public class LavaCauldronBlock extends AbstractCauldronBlock { - if (tileentity instanceof HopperBlockEntity) { + @Override + public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { ++ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper + if (this.isEntityInsideContent(state, pos, entity)) { + entity.lavaHurt(); + } +diff --git a/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java b/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java +@@ -0,0 +0,0 @@ public class LayeredCauldronBlock extends AbstractCauldronBlock { + + @Override + public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { ++ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper + if (!world.isClientSide && entity.isOnFire() && this.isEntityInsideContent(state, pos, entity)) { + // CraftBukkit start + if (entity.mayInteract(world, pos)) { diff --git a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java b/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java @@ -160,6 +172,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (!entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions()) { // CraftBukkit start - Entity in portal EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ())); +diff --git a/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java b/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java +@@ -0,0 +0,0 @@ public class PowderSnowBlock extends Block implements BucketPickup { + + @Override + public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { ++ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper + if (!(entity instanceof LivingEntity) || entity.getFeetBlockState().is((Block) this)) { + entity.makeStuckInBlock(state, new Vec3(0.8999999761581421D, 1.5D, 0.8999999761581421D)); + if (world.isClientSide) { diff --git a/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java b/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java @@ -205,7 +229,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - entity.makeStuckInBlock(state, new Vec3(0.25D, 0.05000000074505806D, 0.25D)); + entity.makeStuckInBlock(state, new Vec3(0.25D, (double)0.05F, 0.25D)); } } diff --git a/src/main/java/net/minecraft/world/level/block/WitherRoseBlock.java b/src/main/java/net/minecraft/world/level/block/WitherRoseBlock.java diff --git a/patches/server/Add-Mob-lookAt-API.patch b/patches/server/Add-Mob-lookAt-API.patch new file mode 100644 index 0000000000..fd6cb3e2d7 --- /dev/null +++ b/patches/server/Add-Mob-lookAt-API.patch @@ -0,0 +1,64 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: BillyGalbreath +Date: Fri, 14 May 2021 13:42:17 -0500 +Subject: [PATCH] Add Mob#lookAt API + + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +@@ -0,0 +0,0 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { + public boolean isInDaylight() { + return getHandle().isSunBurnTick(); + } ++ ++ @Override ++ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.Location location) { ++ com.google.common.base.Preconditions.checkNotNull(location, "location cannot be null"); ++ com.google.common.base.Preconditions.checkArgument(location.getWorld().equals(getWorld()), "location in a different world"); ++ getHandle().getLookControl().setLookAt(location.getX(), location.getY(), location.getZ()); ++ } ++ ++ @Override ++ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.Location location, float headRotationSpeed, float maxHeadPitch) { ++ com.google.common.base.Preconditions.checkNotNull(location, "location cannot be null"); ++ com.google.common.base.Preconditions.checkArgument(location.getWorld().equals(getWorld()), "location in a different world"); ++ getHandle().getLookControl().setLookAt(location.getX(), location.getY(), location.getZ(), headRotationSpeed, maxHeadPitch); ++ } ++ ++ @Override ++ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.entity.Entity entity) { ++ com.google.common.base.Preconditions.checkNotNull(entity, "entity cannot be null"); ++ com.google.common.base.Preconditions.checkArgument(entity.getWorld().equals(getWorld()), "entity in a different world"); ++ getHandle().getLookControl().setLookAt(((CraftEntity) entity).getHandle()); ++ } ++ ++ @Override ++ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.entity.Entity entity, float headRotationSpeed, float maxHeadPitch) { ++ com.google.common.base.Preconditions.checkNotNull(entity, "entity cannot be null"); ++ com.google.common.base.Preconditions.checkArgument(entity.getWorld().equals(getWorld()), "entity in a different world"); ++ getHandle().getLookControl().setLookAt(((CraftEntity) entity).getHandle(), headRotationSpeed, maxHeadPitch); ++ } ++ ++ @Override ++ public void lookAt(double x, double y, double z) { ++ getHandle().getLookControl().setLookAt(x, y, z); ++ } ++ ++ @Override ++ public void lookAt(double x, double y, double z, float headRotationSpeed, float maxHeadPitch) { ++ getHandle().getLookControl().setLookAt(x, y, z, headRotationSpeed, maxHeadPitch); ++ } ++ ++ @Override ++ public int getHeadRotationSpeed() { ++ return getHandle().getHeadRotSpeed(); ++ } ++ ++ @Override ++ public int getMaxHeadPitch() { ++ return getHandle().getMaxHeadXRot(); ++ } + // Paper end + } diff --git a/patches/server-remapped/Add-PufferFishStateChangeEvent.patch b/patches/server/Add-PufferFishStateChangeEvent.patch similarity index 100% rename from patches/server-remapped/Add-PufferFishStateChangeEvent.patch rename to patches/server/Add-PufferFishStateChangeEvent.patch diff --git a/patches/server-remapped/Add-Unix-domain-socket-support.patch b/patches/server/Add-Unix-domain-socket-support.patch similarity index 95% rename from patches/server-remapped/Add-Unix-domain-socket-support.patch rename to patches/server/Add-Unix-domain-socket-support.patch index c6e582d9dc..6f62cbd640 100644 --- a/patches/server-remapped/Add-Unix-domain-socket-support.patch +++ b/patches/server/Add-Unix-domain-socket-support.patch @@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist); - // this.saveData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading + // this.worldData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode); + // Paper start - Unix domain socket support + java.net.SocketAddress bindAddress; @@ -129,11 +129,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL //if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above! String[] split = packet.hostName.split("\00"); - if ( ( split.length == 3 || split.length == 4 ) && ( BYPASS_HOSTCHECK || HOST_PATTERN.matcher( split[1] ).matches() ) ) { // Paper + if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.BYPASS_HOSTCHECK || ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) { // Paper + // Paper start - Unix domain socket support + java.net.SocketAddress socketAddress = connection.getRemoteAddress(); packet.hostName = split[0]; -- connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) connection.getRemoteAddress()).getPort()); +- connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getPort()); + connection.address = new java.net.InetSocketAddress(split[1], socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getPort() : 0); + // Paper end connection.spoofedUUID = com.mojang.util.UUIDTypeAdapter.fromString( split[2] ); diff --git a/patches/server-remapped/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch b/patches/server/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch similarity index 83% rename from patches/server-remapped/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch rename to patches/server/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch index f01e24cc03..b6d7845697 100644 --- a/patches/server-remapped/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch +++ b/patches/server/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch @@ -27,17 +27,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (flag) { ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); @@ -0,0 +0,0 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo - public void readAdditionalSaveData(CompoundTag tag) { - super.readAdditionalSaveData(tag); + public void readAdditionalSaveData(CompoundTag nbt) { + super.readAdditionalSaveData(nbt); this.reassessWeaponGoal(); -+ this.shouldBurnInDay = tag.getBoolean("Paper.ShouldBurnInDay"); // Paper ++ this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay"); // Paper + } + + // Paper start + @Override -+ public void addAdditionalSaveData(CompoundTag tag) { -+ super.addAdditionalSaveData(tag); -+ tag.putBoolean("Paper.ShouldBurnInDay", shouldBurnInDay); ++ public void addAdditionalSaveData(CompoundTag nbt) { ++ super.addAdditionalSaveData(nbt); ++ nbt.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay); } + // Paper end @@ -57,18 +57,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } @@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy { - if (tag.hasUUID("Paper.SpawningEntity")) { - this.spawningEntity = tag.getUUID("Paper.SpawningEntity"); + if (nbt.hasUUID("Paper.SpawningEntity")) { + this.spawningEntity = nbt.getUUID("Paper.SpawningEntity"); } -+ this.shouldBurnInDay = tag.getBoolean("Paper.ShouldBurnInDay"); ++ this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay"); // Paper end } @@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy { if (this.spawningEntity != null) { - tag.setUUID("Paper.SpawningEntity", this.spawningEntity); + nbt.setUUID("Paper.SpawningEntity", this.spawningEntity); } -+ tag.putBoolean("Paper.ShouldBurnInDay", shouldBurnInDay); ++ nbt.putBoolean("Paper.ShouldBurnInDay", shouldBurnInDay); // Paper end } @@ -81,8 +81,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public boolean shouldBurnInDay() { return shouldBurnInDay; } + public void setShouldBurnInDay(boolean shouldBurnInDay) { this.shouldBurnInDay = shouldBurnInDay; } // Paper end + private static enum AttackPhase { - class PhantomAttackPlayerTargetGoal extends Goal { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java @@ -107,9 +107,9 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java b/sr index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java -@@ -0,0 +0,0 @@ public class CraftSkeleton extends CraftMonster implements Skeleton, com.destroy - public void setSkeletonType(SkeletonType type) { - throw new UnsupportedOperationException("Not supported."); +@@ -0,0 +0,0 @@ public class CraftSkeleton extends CraftAbstractSkeleton implements Skeleton, co + public SkeletonType getSkeletonType() { + return SkeletonType.NORMAL; } + + // Paper start diff --git a/patches/server-remapped/Add-basic-Datapack-API.patch b/patches/server/Add-basic-Datapack-API.patch similarity index 51% rename from patches/server-remapped/Add-basic-Datapack-API.patch rename to patches/server/Add-basic-Datapack-API.patch index 3a88c62106..0b3fce60b2 100644 --- a/patches/server-remapped/Add-basic-Datapack-API.patch +++ b/patches/server/Add-basic-Datapack-API.patch @@ -12,7 +12,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.datapack; + -+import Compatibility; +import io.papermc.paper.event.server.ServerResourcesReloadedEvent; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.packs.repository.Pack; @@ -25,8 +24,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final boolean enabled; + + PaperDatapack(Pack loader, boolean enabled) { -+ this.name = loader.getName(); -+ this.compatibility = Compatibility.valueOf(loader.getVersion().name()); ++ this.name = loader.getId(); ++ this.compatibility = Compatibility.valueOf(loader.getCompatibility().name()); + this.enabled = enabled; + } + @@ -52,13 +51,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + MinecraftServer server = MinecraftServer.getServer(); -+ List enabledKeys = server.getPackRepository().getEnabledPacks().stream().map(Pack::getName).collect(Collectors.toList()); ++ List enabledKeys = server.getPackRepository().getSelectedPacks().stream().map(Pack::getId).collect(Collectors.toList()); + if (enabled) { + enabledKeys.add(this.name); + } else { + enabledKeys.remove(this.name); + } -+ server.reloadServerResources(enabledKeys, ServerResourcesReloadedEvent.Cause.PLUGIN); ++ server.reloadResources(enabledKeys, ServerResourcesReloadedEvent.Cause.PLUGIN); + } +} diff --git a/src/main/java/io/papermc/paper/datapack/PaperDatapackManager.java b/src/main/java/io/papermc/paper/datapack/PaperDatapackManager.java @@ -83,80 +82,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public Collection getPacks() { -+ Collection enabledPacks = repository.getEnabledPacks(); -+ return repository.getPacks().stream().map(loader -> new PaperDatapack(loader, enabledPacks.contains(loader))).collect(Collectors.toList()); ++ Collection enabledPacks = repository.getSelectedPacks(); ++ return repository.getAvailablePacks().stream().map(loader -> new PaperDatapack(loader, enabledPacks.contains(loader))).collect(Collectors.toList()); + } + + @Override + public Collection getEnabledPacks() { -+ return repository.getEnabledPacks().stream().map(loader -> new PaperDatapack(loader, true)).collect(Collectors.toList()); ++ return repository.getSelectedPacks().stream().map(loader -> new PaperDatapack(loader, true)).collect(Collectors.toList()); + } +} -diff --git a/src/main/java/net/minecraft/server/packs/repository/Pack.java b/src/main/java/net/minecraft/server/packs/repository/Pack.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/packs/repository/Pack.java -+++ b/src/main/java/net/minecraft/server/packs/repository/Pack.java -@@ -0,0 +0,0 @@ public class Pack implements AutoCloseable { - }); - } - -+ public final PackCompatibility getVersion() { return this.getCompatibility(); } // Paper - OBFHELPER - public PackCompatibility getCompatibility() { - return this.compatibility; - } -@@ -0,0 +0,0 @@ public class Pack implements AutoCloseable { - return (PackResources) this.supplier.get(); - } - -+ public final String getName() { return this.getId(); } // Paper - OBFHELPER - public String getId() { - return this.id; - } -diff --git a/src/main/java/net/minecraft/server/packs/repository/PackRepository.java b/src/main/java/net/minecraft/server/packs/repository/PackRepository.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/packs/repository/PackRepository.java -+++ b/src/main/java/net/minecraft/server/packs/repository/PackRepository.java -@@ -0,0 +0,0 @@ public class PackRepository implements AutoCloseable { - return this.available.keySet(); - } - -+ public final Collection getPacks() { return this.getAvailablePacks(); } // Paper - OBFHELPER - public Collection getAvailablePacks() { - return this.available.values(); - } -@@ -0,0 +0,0 @@ public class PackRepository implements AutoCloseable { - return (Collection) this.selected.stream().map(Pack::getId).collect(ImmutableSet.toImmutableSet()); - } - -+ public final Collection getEnabledPacks() { return this.getSelectedPacks(); } // Paper - OBFHELPER - public Collection getSelectedPacks() { - return this.selected; - } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -0,0 +0,0 @@ import com.mojang.serialization.Lifecycle; - import io.netty.buffer.ByteBuf; - import io.netty.buffer.ByteBufOutputStream; - import io.netty.buffer.Unpooled; -+import io.papermc.paper.datapack.PaperDatapackManager; // Paper - import io.papermc.paper.util.TraceUtil; - import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; - import java.awt.image.BufferedImage; @@ -0,0 +0,0 @@ public final class CraftServer implements Server { public boolean ignoreVanillaPermissions = false; private final List playerView; public int reloadCount; -+ private final PaperDatapackManager datapackManager; // Paper ++ private final io.papermc.paper.datapack.PaperDatapackManager datapackManager; // Paper public static Exception excessiveVelEx; // Paper - Velocity warnings static { @@ -0,0 +0,0 @@ public final class CraftServer implements Server { - TicketType.PLUGIN.timeout = Math.min(20, configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second - minimumAPI = configuration.getString("settings.minimum-api"); - loadIcon(); -+ datapackManager = new PaperDatapackManager(console.getPackRepository()); // Paper + TicketType.PLUGIN.timeout = Math.min(20, this.configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second + this.minimumAPI = this.configuration.getString("settings.minimum-api"); + this.loadIcon(); ++ datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper } public boolean getCommandBlockOverride(String command) { @@ -166,7 +117,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + + @Override -+ public PaperDatapackManager getDatapackManager() { ++ public io.papermc.paper.datapack.PaperDatapackManager getDatapackManager() { + return datapackManager; + } + diff --git a/patches/server-remapped/Add-bypass-host-check.patch b/patches/server/Add-bypass-host-check.patch similarity index 82% rename from patches/server-remapped/Add-bypass-host-check.patch rename to patches/server/Add-bypass-host-check.patch index dcf3137c47..9e706e3fc5 100644 --- a/patches/server-remapped/Add-bypass-host-check.patch +++ b/patches/server/Add-bypass-host-check.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL private static final Component IGNORE_STATUS_REASON = new TextComponent("Ignoring status request"); private final MinecraftServer server; - private final Connection connection; final Connection getNetworkManager() { return this.connection; } // Paper - OBFHELPER + private final Connection connection; + private static final boolean BYPASS_HOSTCHECK = Boolean.getBoolean("Paper.bypassHostCheck"); // Paper public ServerHandshakePacketListenerImpl(MinecraftServer server, Connection connection) { @@ -23,8 +23,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Spigot Start //if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above! String[] split = packet.hostName.split("\00"); -- if ( ( split.length == 3 || split.length == 4 ) && ( HOST_PATTERN.matcher( split[1] ).matches() ) ) { -+ if ( ( split.length == 3 || split.length == 4 ) && ( BYPASS_HOSTCHECK || HOST_PATTERN.matcher( split[1] ).matches() ) ) { // Paper +- if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) { ++ if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.BYPASS_HOSTCHECK || ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) { // Paper packet.hostName = split[0]; - connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) connection.getRemoteAddress()).getPort()); + connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getPort()); connection.spoofedUUID = com.mojang.util.UUIDTypeAdapter.fromString( split[2] ); diff --git a/patches/server-remapped/Add-cause-to-Weather-ThunderChangeEvents.patch b/patches/server/Add-cause-to-Weather-ThunderChangeEvents.patch similarity index 67% rename from patches/server-remapped/Add-cause-to-Weather-ThunderChangeEvents.patch rename to patches/server/Add-cause-to-Weather-ThunderChangeEvents.patch index a73d784b65..e5ad404dbf 100644 --- a/patches/server-remapped/Add-cause-to-Weather-ThunderChangeEvents.patch +++ b/patches/server/Add-cause-to-Weather-ThunderChangeEvents.patch @@ -9,24 +9,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl - this.worldDataServer.setClearWeatherTime(clearDuration); - this.worldDataServer.setRainTime(rainDuration); - this.worldDataServer.setThunderTime(rainDuration); -- this.worldDataServer.setRaining(raining); -- this.worldDataServer.setThundering(thundering); -+ this.worldDataServer.setRaining(raining, org.bukkit.event.weather.WeatherChangeEvent.Cause.COMMAND); // Paper -+ this.worldDataServer.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.COMMAND); // Paper + this.serverLevelData.setClearWeatherTime(clearDuration); + this.serverLevelData.setRainTime(rainDuration); + this.serverLevelData.setThunderTime(rainDuration); +- this.serverLevelData.setRaining(raining); +- this.serverLevelData.setThundering(thundering); ++ this.serverLevelData.setRaining(raining, org.bukkit.event.weather.WeatherChangeEvent.Cause.COMMAND); // Paper ++ this.serverLevelData.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.COMMAND); // Paper } - public Biome getBiomeBySeed(int i, int j, int k) { return getUncachedNoiseBiome(i, j, k); } // Paper - OBFHELPER + @Override @@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl - this.worldDataServer.setThunderTime(j); - this.worldDataServer.setRainTime(k); - this.worldDataServer.setClearWeatherTime(i); -- this.worldDataServer.setThundering(flag1); -- this.worldDataServer.setRaining(flag2); -+ this.worldDataServer.setThundering(flag1, org.bukkit.event.weather.ThunderChangeEvent.Cause.NATURAL); // Paper -+ this.worldDataServer.setRaining(flag2, org.bukkit.event.weather.WeatherChangeEvent.Cause.NATURAL); // Paper + this.serverLevelData.setThunderTime(j); + this.serverLevelData.setRainTime(k); + this.serverLevelData.setClearWeatherTime(i); +- this.serverLevelData.setThundering(flag1); +- this.serverLevelData.setRaining(flag2); ++ this.serverLevelData.setThundering(flag1, org.bukkit.event.weather.ThunderChangeEvent.Cause.NATURAL); // Paper ++ this.serverLevelData.setRaining(flag2, org.bukkit.event.weather.WeatherChangeEvent.Cause.NATURAL); // Paper } this.oThunderLevel = this.thunderLevel; @@ -34,16 +34,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private void stopWeather() { // CraftBukkit start -- this.worldDataServer.setRaining(false); -+ this.worldDataServer.setRaining(false, org.bukkit.event.weather.WeatherChangeEvent.Cause.SLEEP); // Paper - when passing the night +- this.serverLevelData.setRaining(false); ++ this.serverLevelData.setRaining(false, org.bukkit.event.weather.WeatherChangeEvent.Cause.SLEEP); // Paper - when passing the night // If we stop due to everyone sleeping we should reset the weather duration to some other random value. // Not that everyone ever manages to get the whole server to sleep at the same time.... - if (!this.worldDataServer.isRaining()) { - this.worldDataServer.setRainTime(0); + if (!this.serverLevelData.isRaining()) { + this.serverLevelData.setRainTime(0); } // CraftBukkit end -- this.worldDataServer.setThundering(false); -+ this.worldDataServer.setThundering(false, org.bukkit.event.weather.ThunderChangeEvent.Cause.SLEEP); // Paper - when passing the night +- this.serverLevelData.setThundering(false); ++ this.serverLevelData.setThundering(false, org.bukkit.event.weather.ThunderChangeEvent.Cause.SLEEP); // Paper - when passing the night // CraftBukkit start // If we stop due to everyone sleeping we should reset the weather duration to some other random value. // Not that everyone ever manages to get the whole server to sleep at the same time.... @@ -66,7 +66,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return; } - org.bukkit.World world = Bukkit.getWorld(getLevelName()); + org.bukkit.World world = Bukkit.getWorld(this.getLevelName()); if (world != null) { - ThunderChangeEvent thunder = new ThunderChangeEvent(world, thundering); + ThunderChangeEvent thunder = new ThunderChangeEvent(world, flag, cause); // Paper @@ -89,29 +89,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.setRaining(raining, org.bukkit.event.weather.WeatherChangeEvent.Cause.UNKNOWN); + } + -+ public void setStorm(boolean flag, org.bukkit.event.weather.WeatherChangeEvent.Cause cause) { ++ public void setRaining(boolean raining, org.bukkit.event.weather.WeatherChangeEvent.Cause cause) { + // Paper end // CraftBukkit start -- if (this.raining == raining) { -+ if (this.raining == flag) { + if (this.raining == raining) { return; - } +@@ -0,0 +0,0 @@ public class PrimaryLevelData implements ServerLevelData, WorldData { - org.bukkit.World world = Bukkit.getWorld(getLevelName()); + org.bukkit.World world = Bukkit.getWorld(this.getLevelName()); if (world != null) { - WeatherChangeEvent weather = new WeatherChangeEvent(world, raining); -+ WeatherChangeEvent weather = new WeatherChangeEvent(world, flag, cause); // Paper ++ WeatherChangeEvent weather = new WeatherChangeEvent(world, raining, cause); // Paper Bukkit.getServer().getPluginManager().callEvent(weather); if (weather.isCancelled()) { return; - } - } - // CraftBukkit end -- this.raining = raining; -+ this.raining = flag; - } - - @Override diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -121,16 +112,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void setStorm(boolean hasStorm) { - world.levelData.setRaining(hasStorm); -+ world.worldDataServer.setRaining(hasStorm, org.bukkit.event.weather.WeatherChangeEvent.Cause.PLUGIN); // Paper - setWeatherDuration(0); // Reset weather duration (legacy behaviour) - setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) ++ world.serverLevelData.setRaining(hasStorm, org.bukkit.event.weather.WeatherChangeEvent.Cause.PLUGIN); // Paper + this.setWeatherDuration(0); // Reset weather duration (legacy behaviour) + this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) } @@ -0,0 +0,0 @@ public class CraftWorld implements World { @Override public void setThundering(boolean thundering) { -- world.worldDataServer.setThundering(thundering); -+ world.worldDataServer.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.PLUGIN); // Paper - setThunderDuration(0); // Reset weather duration (legacy behaviour) - setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) +- world.serverLevelData.setThundering(thundering); ++ world.serverLevelData.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.PLUGIN); // Paper + this.setThunderDuration(0); // Reset weather duration (legacy behaviour) + this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) } diff --git a/patches/server-remapped/Add-command-line-option-to-load-extra-plugin-jars-no.patch b/patches/server/Add-command-line-option-to-load-extra-plugin-jars-no.patch similarity index 93% rename from patches/server-remapped/Add-command-line-option-to-load-extra-plugin-jars-no.patch rename to patches/server/Add-command-line-option-to-load-extra-plugin-jars-no.patch index de900ec33c..35ae529878 100644 --- a/patches/server-remapped/Add-command-line-option-to-load-extra-plugin-jars-no.patch +++ b/patches/server/Add-command-line-option-to-load-extra-plugin-jars-no.patch @@ -15,13 +15,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 File pluginFolder = (File) console.options.valueOf("plugins"); - if (pluginFolder.exists()) { -- Plugin[] plugins = pluginManager.loadPlugins(pluginFolder); +- Plugin[] plugins = this.pluginManager.loadPlugins(pluginFolder); + // Paper start + if (true || pluginFolder.exists()) { + if (!pluginFolder.exists()) { + pluginFolder.mkdirs(); + } -+ Plugin[] plugins = pluginManager.loadPlugins(pluginFolder, this.extraPluginJars()); ++ Plugin[] plugins = this.pluginManager.loadPlugins(pluginFolder, this.extraPluginJars()); + // Paper end for (Plugin plugin : plugins) { try { @@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void enablePlugins(PluginLoadOrder type) { if (type == PluginLoadOrder.STARTUP) { - helpMap.clear(); + this.helpMap.clear(); diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java diff --git a/patches/server-remapped/Add-environment-variable-to-disable-server-gui.patch b/patches/server/Add-environment-variable-to-disable-server-gui.patch similarity index 100% rename from patches/server-remapped/Add-environment-variable-to-disable-server-gui.patch rename to patches/server/Add-environment-variable-to-disable-server-gui.patch diff --git a/patches/server-remapped/Add-fast-alternative-constructor-for-Vector3f.patch b/patches/server/Add-fast-alternative-constructor-for-Rotations.patch similarity index 87% rename from patches/server-remapped/Add-fast-alternative-constructor-for-Vector3f.patch rename to patches/server/Add-fast-alternative-constructor-for-Rotations.patch index 1a93fdb3d5..81a66d2f29 100644 --- a/patches/server-remapped/Add-fast-alternative-constructor-for-Vector3f.patch +++ b/patches/server/Add-fast-alternative-constructor-for-Rotations.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Irmo van den Berge Date: Wed, 10 Mar 2021 21:26:31 +0100 -Subject: [PATCH] Add fast alternative constructor for Vector3f +Subject: [PATCH] Add fast alternative constructor for Rotations Signed-off-by: Irmo van den Berge @@ -26,5 +26,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end + public ListTag save() { - ListTag nbttaglist = new ListTag(); - + ListTag listTag = new ListTag(); + listTag.add(FloatTag.valueOf(this.x)); diff --git a/patches/server-remapped/Add-getMainThreadExecutor-to-BukkitScheduler.patch b/patches/server/Add-getMainThreadExecutor-to-BukkitScheduler.patch similarity index 100% rename from patches/server-remapped/Add-getMainThreadExecutor-to-BukkitScheduler.patch rename to patches/server/Add-getMainThreadExecutor-to-BukkitScheduler.patch diff --git a/patches/server-remapped/Add-more-WanderingTrader-API.patch b/patches/server/Add-more-WanderingTrader-API.patch similarity index 92% rename from patches/server-remapped/Add-more-WanderingTrader-API.patch rename to patches/server/Add-more-WanderingTrader-API.patch index 51db9464e0..3f9ee2352e 100644 --- a/patches/server-remapped/Add-more-WanderingTrader-API.patch +++ b/patches/server/Add-more-WanderingTrader-API.patch @@ -23,8 +23,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 protected void registerGoals() { this.goalSelector.addGoal(0, new FloatGoal(this)); this.goalSelector.addGoal(0, new UseItemGoal<>(this, PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.INVISIBILITY), SoundEvents.WANDERING_TRADER_DISAPPEARED, (entityvillagertrader) -> { -- return this.world.isNight() && !entityvillagertrader.isInvisible(); -+ return canDrinkPotion && this.world.isNight() && !entityvillagertrader.isInvisible(); // Paper - Add more WanderingTrader API +- return this.level.isNight() && !entityvillagertrader.isInvisible(); ++ return this.canDrinkPotion && this.level.isNight() && !entityvillagertrader.isInvisible(); // Paper - Add more WanderingTrader API })); this.goalSelector.addGoal(0, new UseItemGoal<>(this, new ItemStack(Items.MILK_BUCKET), SoundEvents.WANDERING_TRADER_REAPPEARED, (entityvillagertrader) -> { - return this.level.isDay() && entityvillagertrader.isInvisible(); @@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java @@ -0,0 +0,0 @@ public class CraftWanderingTrader extends CraftAbstractVillager implements Wande public void setDespawnDelay(int despawnDelay) { - getHandle().setDespawnDelay(despawnDelay); + this.getHandle().setDespawnDelay(despawnDelay); } + + // Paper start - Add more WanderingTrader API diff --git a/patches/server-remapped/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch b/patches/server/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch similarity index 79% rename from patches/server-remapped/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch rename to patches/server/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch index dd4c18bf8d..247114d7a6 100644 --- a/patches/server-remapped/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch +++ b/patches/server/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch @@ -9,15 +9,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener - // Paper end - String playerName = gameProfile.getName(); - java.net.InetAddress address = ((java.net.InetSocketAddress) connection.getRemoteAddress()).getAddress(); + // Paper end + String playerName = ServerLoginPacketListenerImpl.this.gameProfile.getName(); + java.net.InetAddress address = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(); + java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) connection.getRawAddress()).getAddress(); // Paper - java.util.UUID uniqueId = gameProfile.getId(); + java.util.UUID uniqueId = ServerLoginPacketListenerImpl.this.gameProfile.getId(); final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server; // Paper start - PlayerProfile profile = CraftPlayerProfile.asBukkitMirror(getGameProfile()); + PlayerProfile profile = CraftPlayerProfile.asBukkitMirror(ServerLoginPacketListenerImpl.this.gameProfile); - AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile); + AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile); server.getPluginManager().callEvent(asyncEvent); diff --git a/patches/server-remapped/Add-recipe-to-cook-events.patch b/patches/server/Add-recipe-to-cook-events.patch similarity index 65% rename from patches/server-remapped/Add-recipe-to-cook-events.patch rename to patches/server/Add-recipe-to-cook-events.patch index 3d66e43c3b..4585456c82 100644 --- a/patches/server-remapped/Add-recipe-to-cook-events.patch +++ b/patches/server/Add-recipe-to-cook-events.patch @@ -12,33 +12,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 CraftItemStack source = CraftItemStack.asCraftMirror(itemstack); org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1); -- FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.level.getWorld().getBlockAt(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()), source, result); -+ FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.level.getWorld().getBlockAt(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()), source, result, (org.bukkit.inventory.CookingRecipe) recipe.toBukkitRecipe()); // Paper - this.level.getCraftServer().getPluginManager().callEvent(furnaceSmeltEvent); +- FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(CraftBlock.at(world, blockposition), source, result); ++ FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(CraftBlock.at(world, blockposition), source, result, (org.bukkit.inventory.CookingRecipe) irecipe.toBukkitRecipe()); // Paper + world.getCraftServer().getPluginManager().callEvent(furnaceSmeltEvent); if (furnaceSmeltEvent.isCancelled()) { diff --git a/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java -@@ -0,0 +0,0 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable, Ticka +@@ -0,0 +0,0 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable { - if (this.cookingProgress[i] >= this.cookingTime[i]) { + if (campfire.cookingProgress[i] >= campfire.cookingTime[i]) { SimpleContainer inventorysubcontainer = new SimpleContainer(new ItemStack[]{itemstack}); -- ItemStack itemstack1 = (ItemStack) this.level.getRecipeManager().getRecipeFor(RecipeType.CAMPFIRE_COOKING, inventorysubcontainer, this.level).map((recipecampfire) -> { +- ItemStack itemstack1 = (ItemStack) world.getRecipeManager().getRecipeFor(RecipeType.CAMPFIRE_COOKING, inventorysubcontainer, world).map((recipecampfire) -> { + // Paper start -+ Optional recipe = this.level.getRecipeManager().getRecipeFor(RecipeType.CAMPFIRE_COOKING, inventorysubcontainer, this.level); ++ Optional recipe = world.getRecipeManager().getRecipeFor(RecipeType.CAMPFIRE_COOKING, inventorysubcontainer, world); + ItemStack itemstack1 = (ItemStack) recipe.map((recipecampfire) -> { + // Paper end return recipecampfire.assemble(inventorysubcontainer); }).orElse(itemstack); - BlockPos blockposition = this.getBlockPos(); -@@ -0,0 +0,0 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable, Ticka + +@@ -0,0 +0,0 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable { CraftItemStack source = CraftItemStack.asCraftMirror(itemstack); org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1); -- BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(this.level, this.worldPosition), source, result); -+ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(this.level, this.worldPosition), source, result, (org.bukkit.inventory.CookingRecipe) recipe.map(CampfireCookingRecipe::toBukkitRecipe).orElse(null)); // Paper - this.level.getCraftServer().getPluginManager().callEvent(blockCookEvent); +- BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, pos), source, result); ++ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, pos), source, result, (org.bukkit.inventory.CookingRecipe) recipe.map(CampfireCookingRecipe::toBukkitRecipe).orElse(null)); // Paper + world.getCraftServer().getPluginManager().callEvent(blockCookEvent); if (blockCookEvent.isCancelled()) { diff --git a/patches/server-remapped/Add-support-for-hex-color-codes-in-console.patch b/patches/server/Add-support-for-hex-color-codes-in-console.patch similarity index 93% rename from patches/server-remapped/Add-support-for-hex-color-codes-in-console.patch rename to patches/server/Add-support-for-hex-color-codes-in-console.patch index ca4d56563e..1eeab1c72f 100644 --- a/patches/server-remapped/Add-support-for-hex-color-codes-in-console.patch +++ b/patches/server/Add-support-for-hex-color-codes-in-console.patch @@ -5,6 +5,18 @@ Subject: [PATCH] Add support for hex color codes in console Converts upstream's hex color code legacy format into actual hex color codes in the console. +diff --git a/build.gradle.kts b/build.gradle.kts +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/build.gradle.kts ++++ b/build.gradle.kts +@@ -0,0 +0,0 @@ dependencies { + Scanning takes about 1-2 seconds so adding this speeds up the server start. + */ + implementation("org.apache.logging.log4j:log4j-core:2.14.1") // Paper - implementation ++ annotationProcessor("org.apache.logging.log4j:log4j-core:2.14.1") // Paper - Needed to generate meta for out hex color converter plugin + // Paper end + implementation("org.apache.logging.log4j:log4j-iostreams:2.14.1") // Paper + implementation("org.apache.logging.log4j:log4j-api:2.14.1") // Paper diff --git a/src/main/java/io/papermc/paper/console/HexFormattingConverter.java b/src/main/java/io/papermc/paper/console/HexFormattingConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 diff --git a/patches/server-remapped/Add-worldborder-events.patch b/patches/server/Add-worldborder-events.patch similarity index 56% rename from patches/server-remapped/Add-worldborder-events.patch rename to patches/server/Add-worldborder-events.patch index 505f6304e1..adbe3853c3 100644 --- a/patches/server-remapped/Add-worldborder-events.patch +++ b/patches/server/Add-worldborder-events.patch @@ -8,16 +8,6 @@ diff --git a/src/main/java/net/minecraft/world/level/border/WorldBorder.java b/s index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/border/WorldBorder.java +++ b/src/main/java/net/minecraft/world/level/border/WorldBorder.java -@@ -0,0 +0,0 @@ import net.minecraft.world.phys.AABB; - import net.minecraft.world.phys.shapes.BooleanOp; - import net.minecraft.world.phys.shapes.Shapes; - import net.minecraft.world.phys.shapes.VoxelShape; -+import io.papermc.paper.event.world.border.WorldBorderBoundsChangeFinishEvent; // Paper -+import io.papermc.paper.event.world.border.WorldBorderCenterChangeEvent; // Paper -+import io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent; // Paper - - public class WorldBorder { - @@ -0,0 +0,0 @@ public class WorldBorder { } @@ -25,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - this.centerX = x; - this.centerZ = z; + // Paper start -+ WorldBorderCenterChangeEvent event = new WorldBorderCenterChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), new org.bukkit.Location(world.getWorld(), this.getCenterX(), 0, this.getCenterZ()), new org.bukkit.Location(world.getWorld(), x, 0, z)); ++ io.papermc.paper.event.world.border.WorldBorderCenterChangeEvent event = new io.papermc.paper.event.world.border.WorldBorderCenterChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), new org.bukkit.Location(world.getWorld(), this.getCenterX(), 0, this.getCenterZ()), new org.bukkit.Location(world.getWorld(), x, 0, z)); + if (!event.callEvent()) return; + this.centerX = event.getNewCenter().getX(); + this.centerZ = event.getNewCenter().getZ(); @@ -47,9 +37,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void setSize(double size) { - this.extent = new WorldBorder.StaticBorderExtent(size); + // Paper start -+ WorldBorderBoundsChangeEvent event = new WorldBorderBoundsChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), WorldBorderBoundsChangeEvent.Type.INSTANT_MOVE, getSize(), size, 0); ++ 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() == WorldBorderBoundsChangeEvent.Type.STARTED_MOVE && event.getDuration() > 0) { // If changed to a timed transition ++ 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()); + return; + } @@ -69,13 +59,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void lerpSizeBetween(double fromSize, double toSize, long time) { - this.extent = (WorldBorder.BorderExtent) (fromSize == toSize ? new WorldBorder.StaticBorderExtent(toSize) : new WorldBorder.MovingBorderExtent(fromSize, toSize, time)); + // Paper start -+ WorldBorderBoundsChangeEvent.Type type; ++ io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type type; + if (fromSize == toSize) { // new size = old size -+ type = WorldBorderBoundsChangeEvent.Type.INSTANT_MOVE; // Use INSTANT_MOVE because below it creates a Static border if they are equal. ++ type = io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type.INSTANT_MOVE; // Use INSTANT_MOVE because below it creates a Static border if they are equal. + } else { -+ type = WorldBorderBoundsChangeEvent.Type.STARTED_MOVE; ++ type = io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type.STARTED_MOVE; + } -+ WorldBorderBoundsChangeEvent event = new WorldBorderBoundsChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), type, fromSize, toSize, time); ++ io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent event = new io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), type, fromSize, toSize, time); + if (!event.callEvent()) return; + this.extent = (WorldBorder.BorderExtent) (fromSize == event.getNewSize() ? new WorldBorder.StaticBorderExtent(event.getNewSize()) : new WorldBorder.MovingBorderExtent(fromSize, event.getNewSize(), event.getDuration())); + // Paper end @@ -91,32 +81,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } @@ -0,0 +0,0 @@ public class WorldBorder { - class MovingBorderExtent implements WorldBorder.BorderExtent { - -- private final double from; -- private final double to; -+ private final double from; public final double getOldSize() { return this.from; } // Paper - OBFHELPER -+ private final double to; public final double getNewSize() { return this.to; } // Paper - OBFHELPER - private final long lerpEnd; - private final long lerpBegin; -- private final double lerpDuration; -+ private final double lerpDuration; public final double getDuration() { return this.lerpDuration; } // Paper - OBFHELPER - - private MovingBorderExtent(double d0, double d1, long i) { - this.from = d0; -@@ -0,0 +0,0 @@ public class WorldBorder { - @Override public WorldBorder.BorderExtent update() { -+ if (this.getLerpTimeRemaining() <= 0L) new WorldBorderBoundsChangeFinishEvent(world.getWorld(), world.getWorld().getWorldBorder(), getOldSize(), getNewSize(), getDuration()).callEvent(); // Paper ++ if (this.getLerpRemainingTime() <= 0L) new io.papermc.paper.event.world.border.WorldBorderBoundsChangeFinishEvent(world.getWorld(), world.getWorld().getWorldBorder(), this.from, this.to, this.lerpDuration).callEvent(); // Paper return (WorldBorder.BorderExtent) (this.getLerpRemainingTime() <= 0L ? WorldBorder.this.new StaticBorderExtent(this.to) : this); } -@@ -0,0 +0,0 @@ public class WorldBorder { - - double getSize(); - -+ default long getLerpTimeRemaining() { return getLerpRemainingTime(); } // Paper - OBFHELPER - long getLerpRemainingTime(); - - double getLerpTarget(); diff --git a/patches/server-remapped/Added-PlayerBedFailEnterEvent.patch b/patches/server/Added-PlayerBedFailEnterEvent.patch similarity index 54% rename from patches/server-remapped/Added-PlayerBedFailEnterEvent.patch rename to patches/server/Added-PlayerBedFailEnterEvent.patch index f78fdfebfe..65a2f0c540 100644 --- a/patches/server-remapped/Added-PlayerBedFailEnterEvent.patch +++ b/patches/server/Added-PlayerBedFailEnterEvent.patch @@ -4,38 +4,17 @@ Date: Thu, 24 Dec 2020 12:27:41 -0800 Subject: [PATCH] Added PlayerBedFailEnterEvent -diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/player/Player.java -+++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { - this.message = ichatbasecomponent; - } - -+ public @Nullable Component getChatComponent() { return this.getMessage(); }; // Paper - OBFHELPER - @Nullable - public Component getMessage() { - return this.message; diff --git a/src/main/java/net/minecraft/world/level/block/BedBlock.java b/src/main/java/net/minecraft/world/level/block/BedBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/BedBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BedBlock.java -@@ -0,0 +0,0 @@ import net.minecraft.world.phys.shapes.CollisionContext; - import net.minecraft.world.phys.shapes.Shapes; - import net.minecraft.world.phys.shapes.VoxelShape; - import org.apache.commons.lang3.ArrayUtils; -+import io.papermc.paper.event.player.PlayerBedFailEnterEvent; // Paper -+import io.papermc.paper.adventure.PaperAdventure; // Paper - - public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock { - @@ -0,0 +0,0 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock BlockPos finalblockposition = pos; // CraftBukkit end player.startSleepInBed(pos).ifLeft((entityhuman_enumbedresult) -> { + // Paper start - PlayerBedFailEnterEvent + if (entityhuman_enumbedresult != null) { -+ PlayerBedFailEnterEvent event = new PlayerBedFailEnterEvent((org.bukkit.entity.Player) player.getBukkitEntity(), PlayerBedFailEnterEvent.FailReason.VALUES[entityhuman_enumbedresult.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(world, finalblockposition), entityhuman_enumbedresult == Player.BedSleepingProblem.NOT_POSSIBLE_HERE, PaperAdventure.asAdventure(entityhuman_enumbedresult.getChatComponent())); ++ 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[entityhuman_enumbedresult.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(world, finalblockposition), entityhuman_enumbedresult == Player.BedSleepingProblem.NOT_POSSIBLE_HERE, io.papermc.paper.adventure.PaperAdventure.asAdventure(entityhuman_enumbedresult.getMessage())); + if (!event.callEvent()) { + return; + } @@ -49,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (entityhuman_enumbedresult != null) { - player.displayClientMessage(entityhuman_enumbedresult.getMessage(), true); + final net.kyori.adventure.text.Component message = event.getMessage(); // Paper -+ if(message != null) player.displayClientMessage(PaperAdventure.asVanilla(message), true); // Paper ++ if(message != null) player.displayClientMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), true); // Paper } + } // Paper diff --git a/patches/server-remapped/Added-PlayerDeepSleepEvent.patch b/patches/server/Added-PlayerDeepSleepEvent.patch similarity index 100% rename from patches/server-remapped/Added-PlayerDeepSleepEvent.patch rename to patches/server/Added-PlayerDeepSleepEvent.patch diff --git a/patches/server-remapped/Allow-adding-items-to-BlockDropItemEvent.patch b/patches/server/Allow-adding-items-to-BlockDropItemEvent.patch similarity index 100% rename from patches/server-remapped/Allow-adding-items-to-BlockDropItemEvent.patch rename to patches/server/Allow-adding-items-to-BlockDropItemEvent.patch diff --git a/patches/server-remapped/Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch b/patches/server/Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch similarity index 97% rename from patches/server-remapped/Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch rename to patches/server/Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch index 31e0f65006..ee0a8f0493 100644 --- a/patches/server-remapped/Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch +++ b/patches/server/Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch @@ -9,14 +9,14 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser // Paper start - async tab completion com.destroystokyo.paper.event.server.AsyncTabCompleteEvent event; - java.util.List completions = new java.util.ArrayList<>(); String buffer = packet.getCommand(); -- event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getPlayer(), completions, -+ event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getPlayer(), +- event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getCraftPlayer(), completions, ++ event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getCraftPlayer(), buffer, true, null); event.callEvent(); - completions = event.isCancelled() ? com.google.common.collect.ImmutableList.of() : event.getCompletions(); @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // If the event isn't handled, we can assume that we have no completions, and so we'll ask the server if (!event.isHandled()) { if (!event.isCancelled()) { -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser }); } } else if (!completions.isEmpty()) { @@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + }); com.mojang.brigadier.suggestion.Suggestions suggestions = builder.buildFuture().join(); - com.destroystokyo.paper.event.brigadier.AsyncPlayerSendSuggestionsEvent suggestEvent = new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendSuggestionsEvent(this.getPlayer(), suggestions, buffer); + com.destroystokyo.paper.event.brigadier.AsyncPlayerSendSuggestionsEvent suggestEvent = new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendSuggestionsEvent(this.getCraftPlayer(), suggestions, buffer); suggestEvent.setCancelled(suggestions.isEmpty()); diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/patches/server-remapped/Allow-using-signs-inside-spawn-protection.patch b/patches/server/Allow-using-signs-inside-spawn-protection.patch similarity index 78% rename from patches/server-remapped/Allow-using-signs-inside-spawn-protection.patch rename to patches/server/Allow-using-signs-inside-spawn-protection.patch index cf768c453e..b47c9531e7 100644 --- a/patches/server-remapped/Allow-using-signs-inside-spawn-protection.patch +++ b/patches/server/Allow-using-signs-inside-spawn-protection.patch @@ -18,24 +18,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + allowUsingSignsInsideSpawnProtection = getBoolean("allow-using-signs-inside-spawn-protection", allowUsingSignsInsideSpawnProtection); + } } + diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -0,0 +0,0 @@ import net.minecraft.world.level.Level; - import net.minecraft.world.level.LevelReader; - import net.minecraft.world.level.block.Blocks; - import net.minecraft.world.level.block.CommandBlock; -+import net.minecraft.world.level.block.SignBlock; - import net.minecraft.world.level.block.entity.BlockEntity; - import net.minecraft.world.level.block.entity.CommandBlockEntity; - import net.minecraft.world.level.block.entity.JigsawBlockEntity; -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser + int i = this.player.level.getMaxBuildHeight(); - this.player.resetLastActionTime(); - if (blockposition.getY() < this.server.getMaxBuildHeight()) { + if (blockposition.getY() < i) { - if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract((net.minecraft.world.entity.player.Player) this.player, blockposition)) { -+ if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && (worldserver.mayInteract((net.minecraft.world.entity.player.Player) this.player, blockposition) || (worldserver.paperConfig.allowUsingSignsInsideSpawnProtection && worldserver.getBlockState(blockposition).getBlock() instanceof SignBlock))) { // Paper ++ if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && (worldserver.mayInteract((net.minecraft.world.entity.player.Player) this.player, blockposition) || (worldserver.paperConfig.allowUsingSignsInsideSpawnProtection && worldserver.getBlockState(blockposition).getBlock() instanceof net.minecraft.world.level.block.SignBlock))) { // Paper // CraftBukkit start - Check if we can actually do something over this large a distance // Paper - move check up this.player.stopUsingItem(); // SPIGOT-4706 diff --git a/patches/server-remapped/Attributes-API-for-item-defaults.patch b/patches/server/Attributes-API-for-item-defaults.patch similarity index 61% rename from patches/server-remapped/Attributes-API-for-item-defaults.patch rename to patches/server/Attributes-API-for-item-defaults.patch index 5682c37df5..cdb47e52a3 100644 --- a/patches/server-remapped/Attributes-API-for-item-defaults.patch +++ b/patches/server/Attributes-API-for-item-defaults.patch @@ -4,34 +4,22 @@ Date: Sat, 8 May 2021 15:01:54 -0700 Subject: [PATCH] Attributes API for item defaults -diff --git a/src/main/java/net/minecraft/world/item/Item.java b/src/main/java/net/minecraft/world/item/Item.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/item/Item.java -+++ b/src/main/java/net/minecraft/world/item/Item.java -@@ -0,0 +0,0 @@ public class Item implements ItemLike { - return false; - } - -+ public Multimap getAttributesForSlot(EquipmentSlot enumItemSlot) { return getDefaultAttributeModifiers(enumItemSlot); } // Paper - OBFHELPER - public Multimap getDefaultAttributeModifiers(EquipmentSlot slot) { - return ImmutableMultimap.of(); - } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { - return this.getItem(itemToBeRepaired.getType()).canRepair(CraftItemStack.asNMSCopy(itemToBeRepaired), CraftItemStack.asNMSCopy(repairMaterial)); + return CraftMagicNumbers.getItem(itemToBeRepaired.getType()).isValidRepairItem(CraftItemStack.asNMSCopy(itemToBeRepaired), CraftItemStack.asNMSCopy(repairMaterial)); } + @Override + public com.google.common.collect.Multimap getItemAttributes(org.bukkit.Material material, org.bukkit.inventory.EquipmentSlot equipmentSlot) { -+ Item item = this.getItem(material); ++ Item item = CraftMagicNumbers.getItem(material); + if (item == null) { + throw new IllegalArgumentException(material + " is not an item and therefore does not have attributes"); + } + com.google.common.collect.ImmutableMultimap.Builder attributeMapBuilder = com.google.common.collect.ImmutableMultimap.builder(); -+ item.getAttributesForSlot(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(equipmentSlot)).forEach((attributeBase, attributeModifier) -> { ++ item.getDefaultAttributeModifiers(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(equipmentSlot)).forEach((attributeBase, attributeModifier) -> { + attributeMapBuilder.put(org.bukkit.Registry.ATTRIBUTE.get(CraftNamespacedKey.fromMinecraft(net.minecraft.core.Registry.ATTRIBUTE.getKey(attributeBase))), org.bukkit.craftbukkit.attribute.CraftAttributeInstance.convert(attributeModifier)); + }); + return attributeMapBuilder.build(); diff --git a/patches/server-remapped/Don-t-ignore-result-of-PlayerEditBookEvent.patch b/patches/server/Don-t-ignore-result-of-PlayerEditBookEvent.patch similarity index 58% rename from patches/server-remapped/Don-t-ignore-result-of-PlayerEditBookEvent.patch rename to patches/server/Don-t-ignore-result-of-PlayerEditBookEvent.patch index 6f175ed199..019ada27a5 100644 --- a/patches/server-remapped/Don-t-ignore-result-of-PlayerEditBookEvent.patch +++ b/patches/server/Don-t-ignore-result-of-PlayerEditBookEvent.patch @@ -8,12 +8,12 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { - list.stream().map(StringTag::valueOf).forEach(nbttaglist::add); - ItemStack old = itemstack.copy(); // CraftBukkit - itemstack.addTagElement("pages", (Tag) nbttaglist); -- CraftEventFactory.handleEditBookEvent(player, i, old, itemstack); // CraftBukkit -+ this.player.inventory.setItem(i, CraftEventFactory.handleEditBookEvent(player, i, old, itemstack)); // CraftBukkit // Paper - Don't ignore result (see other callsite for handleEditBookEvent) +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser } + + itemstack.addTagElement("pages", (Tag) nbttaglist); +- CraftEventFactory.handleEditBookEvent(player, slot, old, itemstack); // CraftBukkit ++ this.player.containerMenu.setItem(slot, CraftEventFactory.handleEditBookEvent(player, slot, old, itemstack)); // CraftBukkit // Paper - Don't ignore result (see other callsite for handleEditBookEvent) } + @Override diff --git a/patches/server-remapped/Drop-carried-item-when-player-has-disconnected.patch b/patches/server/Drop-carried-item-when-player-has-disconnected.patch similarity index 64% rename from patches/server-remapped/Drop-carried-item-when-player-has-disconnected.patch rename to patches/server/Drop-carried-item-when-player-has-disconnected.patch index 9dfc2e4b1d..05eb06b90c 100644 --- a/patches/server-remapped/Drop-carried-item-when-player-has-disconnected.patch +++ b/patches/server/Drop-carried-item-when-player-has-disconnected.patch @@ -10,22 +10,14 @@ diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/ma index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -0,0 +0,0 @@ import net.minecraft.world.effect.MobEffectInstance; - import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.EntityType; - import net.minecraft.world.entity.npc.AbstractVillager; -+import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.ChunkPos; - import net.minecraft.world.level.GameRules; - import net.minecraft.world.level.GameType; @@ -0,0 +0,0 @@ public abstract class PlayerList { } // Paper end + // Paper - Drop carried item when player has disconnected -+ if (!entityplayer.inventory.getCarried().isEmpty()) { -+ ItemStack carried = entityplayer.inventory.getCarried(); -+ entityplayer.inventory.setCarried(ItemStack.NULL_ITEM); ++ if (!entityplayer.containerMenu.getCarried().isEmpty()) { ++ net.minecraft.world.item.ItemStack carried = entityplayer.containerMenu.getCarried(); ++ entityplayer.containerMenu.setCarried(net.minecraft.world.item.ItemStack.EMPTY); + entityplayer.drop(carried, false); + } + // Paper end diff --git a/patches/server-remapped/Enhance-console-tab-completions-for-brigadier-comman.patch b/patches/server/Enhance-console-tab-completions-for-brigadier-comman.patch similarity index 82% rename from patches/server-remapped/Enhance-console-tab-completions-for-brigadier-comman.patch rename to patches/server/Enhance-console-tab-completions-for-brigadier-comman.patch index dddb336aeb..4376fdf3c8 100644 --- a/patches/server-remapped/Enhance-console-tab-completions-for-brigadier-comman.patch +++ b/patches/server/Enhance-console-tab-completions-for-brigadier-comman.patch @@ -24,14 +24,6 @@ diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/s index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java +++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java -@@ -0,0 +0,0 @@ - package com.destroystokyo.paper.console; - -+import com.destroystokyo.paper.PaperConfig; -+import io.papermc.paper.console.BrigadierCommandHighlighter; - import net.minecraft.server.dedicated.DedicatedServer; - import net.minecrell.terminalconsole.SimpleTerminalConsole; - import org.bukkit.craftbukkit.command.ConsoleCommandCompleter; @@ -0,0 +0,0 @@ public final class PaperConsole extends SimpleTerminalConsole { @Override @@ -43,8 +35,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 .completer(new ConsoleCommandCompleter(this.server)) - ); + .option(LineReader.Option.COMPLETE_IN_WORD, true); -+ if (PaperConfig.enableBrigadierConsoleHighlighting) { -+ builder.highlighter(new BrigadierCommandHighlighter(this.server, this.server.createCommandSourceStack())); ++ if (com.destroystokyo.paper.PaperConfig.enableBrigadierConsoleHighlighting) { ++ builder.highlighter(new io.papermc.paper.console.BrigadierCommandHighlighter(this.server, this.server.createCommandSourceStack())); + } + return super.buildReader(builder); } @@ -92,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.addCandidates(candidates, Collections.emptyList(), existing); + return; + } -+ final CommandDispatcher dispatcher = this.server.getCommands().dispatcher(); ++ final CommandDispatcher dispatcher = this.server.getCommands().getDispatcher(); + final ParseResults results = dispatcher.parse(prepareStringReader(line.line()), this.commandSourceStack); + this.addCandidates( + candidates, @@ -184,7 +176,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public AttributedString highlight(final @NonNull LineReader reader, final @NonNull String buffer) { + final AttributedStringBuilder builder = new AttributedStringBuilder(); -+ final ParseResults results = this.server.getCommands().dispatcher().parse(BrigadierCommandCompleter.prepareStringReader(buffer), this.commandSourceStack); ++ final ParseResults results = this.server.getCommands().getDispatcher().parse(BrigadierCommandCompleter.prepareStringReader(buffer), this.commandSourceStack); + int pos = 0; + if (buffer.startsWith("/")) { + builder.append("/", AttributedStyle.DEFAULT); @@ -214,41 +206,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return builder.toAttributedString(); + } +} -diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/commands/Commands.java -+++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -0,0 +0,0 @@ public class Commands { - }; - } - -- public com.mojang.brigadier.CommandDispatcher getDispatcher() { -+ public com.mojang.brigadier.CommandDispatcher getDispatcher() { return this.dispatcher(); } public com.mojang.brigadier.CommandDispatcher dispatcher() { // Paper - OBFHELPER - return this.dispatcher; - } - -diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java -+++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java -@@ -0,0 +0,0 @@ public class ComponentUtils { - TextComponent chatcomponenttext = new TextComponent(""); - boolean flag = true; - -- for (Iterator iterator = elements.iterator(); iterator.hasNext(); flag = false) { -+ for (Iterator iterator = elements.iterator(); iterator.hasNext(); flag = false) { // Paper - decompile fix - T t0 = iterator.next(); - - if (!flag) { -@@ -0,0 +0,0 @@ public class ComponentUtils { - return new TranslatableComponent("chat.square_brackets", new Object[]{text}); - } - -- public static Component fromMessage(Message message) { -+ public static Component fromMessage(Message message) { return fromMessage(message); } public static Component fromMessage(final @org.checkerframework.checker.nullness.qual.NonNull Message message) { // Paper - OBFHELPER - return (Component) (message instanceof Component ? (Component) message : new TextComponent(message.getString())); - } - } diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java diff --git a/patches/server/Expose-Tracked-Players.patch b/patches/server/Expose-Tracked-Players.patch new file mode 100644 index 0000000000..da89eb153d --- /dev/null +++ b/patches/server/Expose-Tracked-Players.patch @@ -0,0 +1,32 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tom +Date: Fri, 26 Feb 2021 16:24:25 -0600 +Subject: [PATCH] Expose Tracked Players + + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + } + // Paper end + ++ // Paper start ++ @Override ++ public Set getTrackedPlayers() { ++ if (entity.tracker == null) { ++ return java.util.Collections.emptySet(); ++ } ++ ++ Set set = new HashSet<>(entity.tracker.seenBy.size()); ++ for (net.minecraft.server.network.ServerPlayerConnection connection : entity.tracker.seenBy) { ++ set.add(connection.getPlayer().getBukkitEntity().getPlayer()); ++ } ++ return set; ++ } ++ // Paper end ++ + // Spigot start + private final Player.Spigot spigot = new Player.Spigot() + { diff --git a/patches/server-remapped/Expose-protocol-version.patch b/patches/server/Expose-protocol-version.patch similarity index 91% rename from patches/server-remapped/Expose-protocol-version.patch rename to patches/server/Expose-protocol-version.patch index 35619bb347..4f55ae6f04 100644 --- a/patches/server-remapped/Expose-protocol-version.patch +++ b/patches/server/Expose-protocol-version.patch @@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { public io.papermc.paper.inventory.ItemRarity getItemStackRarity(org.bukkit.inventory.ItemStack itemStack) { - return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getItemStackRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()]; + return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()]; } + + @Override diff --git a/patches/server-remapped/Fix-CraftPotionBrewer-cache.patch b/patches/server/Fix-CraftPotionBrewer-cache.patch similarity index 76% rename from patches/server-remapped/Fix-CraftPotionBrewer-cache.patch rename to patches/server/Fix-CraftPotionBrewer-cache.patch index 2a713575f9..6dc8d06ff2 100644 --- a/patches/server-remapped/Fix-CraftPotionBrewer-cache.patch +++ b/patches/server/Fix-CraftPotionBrewer-cache.patch @@ -17,15 +17,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public Collection getEffects(PotionType damage, boolean upgraded, boolean extended) { -- if (cache.containsKey(damage)) -- return cache.get(damage); +- if (CraftPotionBrewer.cache.containsKey(damage)) +- return CraftPotionBrewer.cache.get(damage); + // Paper start + int key = damage.ordinal() << 2; + key |= (upgraded ? 1 : 0) << 1; + key |= extended ? 1 : 0; + -+ if (cache.containsKey(key)) -+ return cache.get(key); ++ if (CraftPotionBrewer.cache.containsKey(key)) ++ return CraftPotionBrewer.cache.get(key); + // Paper end List mcEffects = Potion.byName(CraftPotionUtil.fromBukkit(new PotionData(damage, extended, upgraded))).getEffects(); @@ -34,11 +34,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 builder.add(CraftPotionUtil.toBukkit(effect)); } -- cache.put(damage, builder.build()); -+ cache.put(key, builder.build()); // Paper +- CraftPotionBrewer.cache.put(damage, builder.build()); ++ CraftPotionBrewer.cache.put(key, builder.build()); // Paper -- return cache.get(damage); -+ return cache.get(key); // Paper +- return CraftPotionBrewer.cache.get(damage); ++ return CraftPotionBrewer.cache.get(key); // Paper } @Override diff --git a/patches/server/Fix-Entity-Teleportation-and-cancel-velocity-if-tele.patch b/patches/server/Fix-Entity-Teleportation-and-cancel-velocity-if-tele.patch index c4ee2d8add..0c7be35d3b 100644 --- a/patches/server/Fix-Entity-Teleportation-and-cancel-velocity-if-tele.patch +++ b/patches/server/Fix-Entity-Teleportation-and-cancel-velocity-if-tele.patch @@ -27,9 +27,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.awaitingTeleportTime = this.tickCount; - this.player.absMoveTo(d0, d1, d2, f, f1); + this.player.moveTo(d0, d1, d2, f, f1); // Paper - use proper setPositionRotation for teleportation + this.player.forceCheckHighPriority(); // Paper this.player.connection.send(new ClientboundPlayerPositionPacket(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag)); } - diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/patches/server-remapped/Fix-PlayerItemConsumeEvent-cancelling-properly.patch b/patches/server/Fix-PlayerItemConsumeEvent-cancelling-properly.patch similarity index 100% rename from patches/server-remapped/Fix-PlayerItemConsumeEvent-cancelling-properly.patch rename to patches/server/Fix-PlayerItemConsumeEvent-cancelling-properly.patch diff --git a/patches/server-remapped/Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch b/patches/server/Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch similarity index 92% rename from patches/server-remapped/Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch rename to patches/server/Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch index e27f667614..bf294523a7 100644 --- a/patches/server-remapped/Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch +++ b/patches/server/Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch @@ -28,9 +28,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public abstract class PlayerList { } - Player respawnPlayer = cserver.getPlayer(entityplayer1); + Player respawnPlayer = this.cserver.getPlayer(entityplayer1); - PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !flag2, flag2); + PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !isAnchorSpawn, isAnchorSpawn); // Paper - Fix anchor respawn acting as a bed respawn from the end portal - cserver.getPluginManager().callEvent(respawnEvent); + this.cserver.getPluginManager().callEvent(respawnEvent); // Spigot Start if (entityplayer.connection.isDisconnected()) { diff --git a/patches/server-remapped/Fix-and-optimise-world-force-upgrading.patch b/patches/server/Fix-and-optimise-world-force-upgrading.patch similarity index 87% rename from patches/server-remapped/Fix-and-optimise-world-force-upgrading.patch rename to patches/server/Fix-and-optimise-world-force-upgrading.patch index 0e771b5504..492fea82ec 100644 --- a/patches/server-remapped/Fix-and-optimise-world-force-upgrading.patch +++ b/patches/server/Fix-and-optimise-world-force-upgrading.patch @@ -104,7 +104,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + LOGGER.info("Force upgrading " + this.worldName); + LOGGER.info("Counting regionfiles for " + this.worldName); + final File[] regionFiles = regionFolder.listFiles((final File dir, final String name) -> { -+ return WorldUpgrader.getRegionfileRegex().matcher(name).matches(); ++ return WorldUpgrader.REGEX.matcher(name).matches(); + }); + if (regionFiles == null) { + LOGGER.info("Found no regionfiles to convert for world " + this.worldName); @@ -270,8 +270,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 worlddata = new PrimaryLevelData(worldsettings, generatorsettings, Lifecycle.stable()); } worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end) -- if (options.has("forceUpgrade")) { -- net.minecraft.server.Main.forceUpgrade(worldSession, DataFixers.getDataFixer(), options.has("eraseCache"), () -> { +- if (this.options.has("forceUpgrade")) { +- net.minecraft.server.Main.forceUpgrade(worldSession, DataFixers.getDataFixer(), this.options.has("eraseCache"), () -> { - return true; - }, worlddata.worldGenSettings().dimensions().entrySet().stream().map((entry1) -> { - return ResourceKey.create(Registry.DIMENSION_TYPE_REGISTRY, ((ResourceKey) entry1.getKey()).location()); @@ -296,57 +296,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ResourceKey worldKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, dimensionKey.location()); if (dimensionKey == LevelStem.OVERWORLD) { -diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java -+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java -@@ -0,0 +0,0 @@ public class WorldUpgrader { - private volatile int skipped; - private final Object2FloatMap> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(Util.identityStrategy())); // CraftBukkit - private volatile Component status = new TranslatableComponent("optimizeWorld.stage.counting"); -- private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$"); -+ private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$"); public static final Pattern getRegionfileRegex() { return REGEX; } // Paper - OBFHELPER - private final DimensionDataStorage overworldDataStorage; - - public WorldUpgrader(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, ImmutableSet> worlds, boolean eraseCache) { // CraftBukkit diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - return typeKey; + return this.typeKey; } + // Paper start - fix and optimise world upgrading + // copied from below + public static ResourceKey getDimensionKey(DimensionType manager) { -+ return ((org.bukkit.craftbukkit.CraftServer)org.bukkit.Bukkit.getServer()).getHandle().getServer().registryHolder.dimensionTypes().getResourceKey(manager).orElseThrow(() -> { ++ return ((org.bukkit.craftbukkit.CraftServer)org.bukkit.Bukkit.getServer()).getHandle().getServer().registryHolder.ownedRegistryOrThrow(net.minecraft.core.Registry.DIMENSION_TYPE_REGISTRY).getResourceKey(manager).orElseThrow(() -> { + return new IllegalStateException("Unregistered dimension type: " + manager); + }); + } + // Paper end - fix and optimise world upgrading -+ - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, final DimensionType dimensionmanager, Supplier supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env, java.util.concurrent.Executor executor) { // Paper + protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, final DimensionType dimensionmanager, Supplier supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) { this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName(), this.spigotConfig); // Paper -diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java -+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java -@@ -0,0 +0,0 @@ public class ChunkStorage implements AutoCloseable { - return nbttagcompound; - } - -+ public static int getVersion(CompoundTag nbttagcompound) { return getVersion(nbttagcompound); } // Paper - OBFHELPER - public static int getVersion(CompoundTag tag) { - return tag.contains("DataVersion", 99) ? tag.getInt("DataVersion") : -1; - } diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { // Paper - no final - + } // Paper start + public static ChunkPos getRegionFileCoordinates(File file) { @@ -371,7 +345,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + - public synchronized RegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) { // Paper - synchronize for async io + public synchronized RegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) { return this.regionCache.getAndMoveToFirst(ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ())); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -381,7 +355,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public final class CraftServer implements Server { } worlddata.checkName(name); - worlddata.setModdedInfo(console.getServerModName(), console.getModdedStatus().isPresent()); + worlddata.setModdedInfo(this.console.getServerModName(), this.console.getModdedStatus().isPresent()); - - if (console.options.has("forceUpgrade")) { - net.minecraft.server.Main.forceUpgrade(worldSession, DataFixers.getDataFixer(), console.options.has("eraseCache"), () -> { diff --git a/patches/server-remapped/Fix-checkReach-check-for-Shulker-boxes.patch b/patches/server/Fix-checkReach-check-for-Shulker-boxes.patch similarity index 100% rename from patches/server-remapped/Fix-checkReach-check-for-Shulker-boxes.patch rename to patches/server/Fix-checkReach-check-for-Shulker-boxes.patch diff --git a/patches/server-remapped/Fix-duplicating-give-items-on-item-drop-cancel.patch b/patches/server/Fix-duplicating-give-items-on-item-drop-cancel.patch similarity index 53% rename from patches/server-remapped/Fix-duplicating-give-items-on-item-drop-cancel.patch rename to patches/server/Fix-duplicating-give-items-on-item-drop-cancel.patch index 795f320078..9044440a08 100644 --- a/patches/server-remapped/Fix-duplicating-give-items-on-item-drop-cancel.patch +++ b/patches/server/Fix-duplicating-give-items-on-item-drop-cancel.patch @@ -33,14 +33,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/commands/GiveCommand.java +++ b/src/main/java/net/minecraft/server/commands/GiveCommand.java @@ -0,0 +0,0 @@ public class GiveCommand { - - if (flag && itemstack.isEmpty()) { - itemstack.setCount(1); -- entityitem = entityplayer.drop(itemstack, false); -+ entityitem = entityplayer.drop(itemstack, false, false, true); // Paper - Fix duplicating /give items on item drop cancel - if (entityitem != null) { - entityitem.makeFakeItem(); - } + boolean bl = serverPlayer.getInventory().add(itemStack); + if (bl && itemStack.isEmpty()) { + itemStack.setCount(1); +- ItemEntity itemEntity2 = serverPlayer.drop(itemStack, false); ++ ItemEntity itemEntity2 = serverPlayer.drop(itemStack, false, false, true); // Paper - Fix duplicating /give items on item drop cancel + if (itemEntity2 != null) { + itemEntity2.makeFakeItem(); + } diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java @@ -49,39 +49,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Nullable public ItemEntity drop(ItemStack stack, boolean throwRandomly, boolean retainOwnership) { -- if (stack.isEmpty()) { + // Paper start - Fix duplicating /give items on item drop cancel + return this.drop(stack, throwRandomly, retainOwnership, false); + } + + @Nullable -+ public ItemEntity drop(ItemStack itemstack, boolean flag, boolean flag1, boolean alwaysSucceed) { ++ public ItemEntity drop(ItemStack stack, boolean throwRandomly, boolean retainOwnership, boolean alwaysSucceed) { + // Paper end -+ if (itemstack.isEmpty()) { + if (stack.isEmpty()) { return null; } else { - if (this.level.isClientSide) { -@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { - } - - double d0 = this.getEyeY() - 0.30000001192092896D; -- ItemEntity entityitem = new ItemEntity(this.level, this.getX(), d0, this.getZ(), stack); -+ ItemEntity entityitem = new ItemEntity(this.level, this.getX(), d0, this.getZ(), itemstack); - - entityitem.setPickUpDelay(40); -- if (retainOwnership) { -+ if (flag1) { - entityitem.setThrower(this.getUUID()); - } - - float f; - float f1; - -- if (throwRandomly) { -+ if (flag) { - f = this.random.nextFloat() * 0.5F; - f1 = this.random.nextFloat() * 6.2831855F; - entityitem.setDeltaMovement((double) (-Mth.sin(f1) * f), 0.20000000298023224D, (double) (Mth.cos(f1) * f)); @@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); this.level.getCraftServer().getPluginManager().callEvent(event); @@ -89,25 +66,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if (event.isCancelled()) { + if (event.isCancelled() && !alwaysSucceed) { // Paper - Fix duplicating /give items on item drop cancel org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand(); -- if (retainOwnership && (cur == null || cur.getAmount() == 0)) { -+ if (flag1 && (cur == null || cur.getAmount() == 0)) { + if (retainOwnership && (cur == null || cur.getAmount() == 0)) { // The complete stack was dropped - player.getInventory().setItemInHand(drop.getItemStack()); -- } else if (retainOwnership && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) { -+ } else if (flag1 && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) { - // Only one item is dropped - cur.setAmount(cur.getAmount() + 1); - player.getInventory().setItemInHand(cur); -@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { - } - // CraftBukkit end - // Paper start - remove player from map on drop -- if (stack.getItem() == Items.FILLED_MAP) { -- MapItemSavedData worldmap = MapItem.getOrCreateSavedData(stack, this.level); -- worldmap.updateSeenPlayers(this, stack); -+ if (itemstack.getItem() == Items.FILLED_MAP) { -+ MapItemSavedData worldmap = MapItem.getOrCreateSavedData(itemstack, this.level); -+ worldmap.updateSeenPlayers(this, itemstack); - } - // Paper end - diff --git a/patches/server-remapped/Have-CraftMerchantCustom-emit-PlayerPurchaseEvent.patch b/patches/server/Have-CraftMerchantCustom-emit-PlayerPurchaseEvent.patch similarity index 79% rename from patches/server-remapped/Have-CraftMerchantCustom-emit-PlayerPurchaseEvent.patch rename to patches/server/Have-CraftMerchantCustom-emit-PlayerPurchaseEvent.patch index c8f7c1ccc1..456703fca0 100644 --- a/patches/server-remapped/Have-CraftMerchantCustom-emit-PlayerPurchaseEvent.patch +++ b/patches/server/Have-CraftMerchantCustom-emit-PlayerPurchaseEvent.patch @@ -4,19 +4,6 @@ Date: Thu, 6 May 2021 13:01:25 +0100 Subject: [PATCH] Have CraftMerchantCustom emit PlayerPurchaseEvent -diff --git a/src/main/java/net/minecraft/world/item/trading/Merchant.java b/src/main/java/net/minecraft/world/item/trading/Merchant.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/item/trading/Merchant.java -+++ b/src/main/java/net/minecraft/world/item/trading/Merchant.java -@@ -0,0 +0,0 @@ public interface Merchant { - - MerchantOffers getOffers(); - -- void notifyTrade(MerchantOffer offer); -+ void notifyTrade(MerchantOffer offer); default void handlePurchase(MerchantOffer merchantRecipe) { notifyTrade(merchantRecipe); } // Paper - OBFHELPER - - void notifyTradeUpdated(ItemStack stack); - diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java diff --git a/patches/server/Implement-Keyed-on-World.patch b/patches/server/Implement-Keyed-on-World.patch new file mode 100644 index 0000000000..4e27476c78 --- /dev/null +++ b/patches/server/Implement-Keyed-on-World.patch @@ -0,0 +1,51 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Wed, 6 Jan 2021 00:34:04 -0800 +Subject: [PATCH] Implement Keyed on World + + +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +@@ -0,0 +0,0 @@ public final class CraftServer implements Server { + } else if (name.equals(levelName + "_the_end")) { + worldKey = net.minecraft.world.level.Level.END; + } else { +- worldKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(name.toLowerCase(java.util.Locale.ENGLISH))); ++ worldKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, new net.minecraft.resources.ResourceLocation(creator.key().getNamespace().toLowerCase(java.util.Locale.ENGLISH), creator.key().getKey().toLowerCase(java.util.Locale.ENGLISH))); // Paper + } + + ServerLevel internal = (ServerLevel) new ServerLevel(this.console, console.executor, worldSession, worlddata, worldKey, dimensionmanager, this.getServer().progressListenerFactory.create(11), +@@ -0,0 +0,0 @@ public final class CraftServer implements Server { + return null; + } + ++ // Paper start ++ @Override ++ public World getWorld(NamespacedKey worldKey) { ++ ServerLevel worldServer = console.getLevel(ResourceKey.create(Registry.DIMENSION_REGISTRY, CraftNamespacedKey.toMinecraft(worldKey))); ++ if (worldServer == null) return null; ++ return worldServer.getWorld(); ++ } ++ // Paper end ++ + public void addWorld(World world) { + // Check if a World already exists with the UID. + if (this.getWorld(world.getUID()) != null) { +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +@@ -0,0 +0,0 @@ public class CraftWorld implements World { + return java.util.concurrent.CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk()); + }, net.minecraft.server.MinecraftServer.getServer()); + } ++ ++ @Override ++ public org.bukkit.NamespacedKey getKey() { ++ return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(world.dimension().location()); ++ } + // Paper end + + // Spigot start diff --git a/patches/server-remapped/Implement-methods-to-convert-between-Component-and-B.patch b/patches/server/Implement-methods-to-convert-between-Component-and-B.patch similarity index 100% rename from patches/server-remapped/Implement-methods-to-convert-between-Component-and-B.patch rename to patches/server/Implement-methods-to-convert-between-Component-and-B.patch diff --git a/patches/server-remapped/Improve-ServerGUI.patch b/patches/server/Improve-ServerGUI.patch similarity index 95% rename from patches/server-remapped/Improve-ServerGUI.patch rename to patches/server/Improve-ServerGUI.patch index 2db5064b91..7324158763 100644 --- a/patches/server-remapped/Improve-ServerGUI.patch +++ b/patches/server/Improve-ServerGUI.patch @@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } vector.add("Memory use: " + (data.getUsedMem() / 1024L / 1024L) + " mb (" + (data.getFree() * 100L / data.getMax()) + "% free)"); vector.add("Heap: " + (data.getTotal() / 1024L / 1024L) + " / " + (data.getMax() / 1024L / 1024L) + " mb"); - vector.add("Avg tick: " + DECIMAL_FORMAT.format(getAverage(server.getTickTimes())) + " ms"); + vector.add("Avg tick: " + DECIMAL_FORMAT.format(getAverage(server.tickTimes)) + " ms"); + vector.add("TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg)); + setListData(vector); @@ -34,8 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return ((double) total / (double) tickTimes.length) * 1.0E-6D; } + -+ private static String format(double tps) -+ { ++ private static String format(double tps) { + return ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 ); + } } @@ -76,18 +75,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/gui/StatsComponent.java +++ b/src/main/java/net/minecraft/server/gui/StatsComponent.java @@ -0,0 +0,0 @@ public class StatsComponent extends JComponent { - }); - private final int[] values = new int[256]; - private int vp; -- private final String[] msgs = new String[11]; -+ private final String[] msgs = new String[12]; public String[] getStatEntries() { return this.msgs; } // Paper - change size, OBFHELPER - private final MinecraftServer server; - private final Timer timer; -@@ -0,0 +0,0 @@ public class StatsComponent extends JComponent { private void tick() { - long i = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); - + long l = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + // Paper start - Add tps entry + double[] tps = org.bukkit.Bukkit.getTPS(); + String[] tpsAvg = new String[tps.length]; @@ -95,12 +85,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + for ( int g = 0; g < tps.length; g++) { + tpsAvg[g] = format( tps[g] ); + } - this.msgs[0] = "Memory use: " + i / 1024L / 1024L + " mb (" + Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() + "% free)"; - this.msgs[1] = "Avg tick: " + StatsComponent.DECIMAL_FORMAT.format(this.getAverage(this.server.tickTimes) * 1.0E-6D) + " ms"; -+ getStatEntries()[2] = "TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg); + this.msgs[0] = "Memory use: " + l / 1024L / 1024L + " mb (" + Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() + "% free)"; + this.msgs[1] = "Avg tick: " + DECIMAL_FORMAT.format(this.getAverage(this.server.tickTimes) * 1.0E-6D) + " ms"; ++ this.msgs[2] = "TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg); + // Paper end -+ - this.values[this.vp++ & 255] = (int) (i * 100L / Runtime.getRuntime().maxMemory()); + this.values[this.vp++ & 255] = (int)(l * 100L / Runtime.getRuntime().maxMemory()); this.repaint(); } @@ -0,0 +0,0 @@ public class StatsComponent extends JComponent { @@ -110,7 +99,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + // Paper - start Add tps entry + private static String format(double tps) { -+ return ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 ); // only print * at 21, we commonly peak to 20.02 as the tick sleep is not accurate enough, stop the noise ++ return (( tps > 21.0 ) ? "*" : "") + Math.min(Math.round(tps * 100.0) / 100.0, 20.0); // only print * at 21, we commonly peak to 20.02 as the tick sleep is not accurate enough, stop the noise + } + // Paper end } diff --git a/patches/server-remapped/Inline-shift-direction-fields.patch b/patches/server/Inline-shift-direction-fields.patch similarity index 73% rename from patches/server-remapped/Inline-shift-direction-fields.patch rename to patches/server/Inline-shift-direction-fields.patch index e493362808..2fc3f9a14a 100644 --- a/patches/server-remapped/Inline-shift-direction-fields.patch +++ b/patches/server/Inline-shift-direction-fields.patch @@ -11,7 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/core/Direction.java +++ b/src/main/java/net/minecraft/core/Direction.java @@ -0,0 +0,0 @@ public enum Direction implements StringRepresentable { - }, (enumdirection, enumdirection1) -> { + }, (direction1, direction2) -> { throw new IllegalArgumentException("Duplicate keys"); }, Long2ObjectOpenHashMap::new)); + // Paper start @@ -20,16 +20,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final int adjZ; + // Paper end - private Direction(int i, int j, int k, String s, Direction.AxisDirection enumdirection_enumaxisdirection, Direction.Axis enumdirection_enumaxis, Vec3i baseblockposition) { - this.data3d = i; + private Direction(int id, int idOpposite, int idHorizontal, String name, Direction.AxisDirection direction, Direction.Axis axis, Vec3i vector) { + this.data3d = id; @@ -0,0 +0,0 @@ public enum Direction implements StringRepresentable { - this.axis = enumdirection_enumaxis; - this.axisDirection = enumdirection_enumaxisdirection; - this.normal = baseblockposition; + this.axis = axis; + this.axisDirection = direction; + this.normal = vector; + // Paper start -+ this.adjX = baseblockposition.getX(); -+ this.adjY = baseblockposition.getY(); -+ this.adjZ = baseblockposition.getZ(); ++ this.adjX = vector.getX(); ++ this.adjY = vector.getY(); ++ this.adjZ = vector.getZ(); + // Paper end } @@ -52,4 +52,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return this.adjZ; // Paper } - public String getName() { + public Vector3f step() { diff --git a/patches/server-remapped/Introduce-beacon-activation-deactivation-events.patch b/patches/server/Introduce-beacon-activation-deactivation-events.patch similarity index 74% rename from patches/server-remapped/Introduce-beacon-activation-deactivation-events.patch rename to patches/server/Introduce-beacon-activation-deactivation-events.patch index b1a3ed70a9..e95e748b1f 100644 --- a/patches/server-remapped/Introduce-beacon-activation-deactivation-events.patch +++ b/patches/server/Introduce-beacon-activation-deactivation-events.patch @@ -8,23 +8,23 @@ diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEnt index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Tick - this.playSound(SoundEvents.BEACON_AMBIENT); +@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider { + BeaconBlockEntity.playSound(world, pos, SoundEvents.BEACON_AMBIENT); } } + // Paper start - beacon activation/deactivation events -+ if (!(i1 > 0) && this.levels > 0) { -+ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, worldPosition); ++ if (i1 <= 0 && blockEntity.levels > 0) { ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); + new io.papermc.paper.event.block.BeaconActivatedEvent(block).callEvent(); -+ } else if (i1 > 0 && !(this.levels > 0)) { -+ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, worldPosition); ++ } else if (i1 > 0 && blockEntity.levels <= 0) { ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); + new io.papermc.paper.event.block.BeaconDeactivatedEvent(block).callEvent(); + } + // Paper end - if (this.lastCheckY >= l) { - this.lastCheckY = -1; -@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Tick + if (blockEntity.lastCheckY >= l) { + blockEntity.lastCheckY = world.getMinBuildHeight() - 1; +@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider { @Override public void setRemoved() { @@ -32,6 +32,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, worldPosition); + new io.papermc.paper.event.block.BeaconDeactivatedEvent(block).callEvent(); + // Paper end - this.playSound(SoundEvents.BEACON_DEACTIVATE); + BeaconBlockEntity.playSound(this.level, this.worldPosition, SoundEvents.BEACON_DEACTIVATE); super.setRemoved(); } diff --git a/patches/server-remapped/Inventory-close.patch b/patches/server/Inventory-close.patch similarity index 97% rename from patches/server-remapped/Inventory-close.patch rename to patches/server/Inventory-close.patch index 8218375461..05cebcc0bb 100644 --- a/patches/server-remapped/Inventory-close.patch +++ b/patches/server/Inventory-close.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -0,0 +0,0 @@ public class CraftInventory implements Inventory { - clear(i); + this.clear(i); } } + // Paper start diff --git a/patches/server-remapped/Item-Rarity-API.patch b/patches/server/Item-Rarity-API.patch similarity index 51% rename from patches/server-remapped/Item-Rarity-API.patch rename to patches/server/Item-Rarity-API.patch index 8e3dc0396c..57e2716634 100644 --- a/patches/server-remapped/Item-Rarity-API.patch +++ b/patches/server/Item-Rarity-API.patch @@ -4,27 +4,6 @@ Date: Fri, 12 Mar 2021 17:09:42 -0800 Subject: [PATCH] Item Rarity API -diff --git a/src/main/java/net/minecraft/world/item/Item.java b/src/main/java/net/minecraft/world/item/Item.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/item/Item.java -+++ b/src/main/java/net/minecraft/world/item/Item.java -@@ -0,0 +0,0 @@ public class Item implements ItemLike { - protected static final UUID BASE_ATTACK_SPEED_UUID = UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3"); - protected static final Random random = new Random(); - protected final CreativeModeTab category; -- private final Rarity rarity; -+ private final Rarity rarity; public final Rarity getItemRarity() { return rarity; } // Paper - OBFHELPER - private final int maxStackSize; - private final int maxDamage; - private final boolean isFireResistant; -@@ -0,0 +0,0 @@ public class Item implements ItemLike { - return stack.isEnchanted(); - } - -+ public Rarity getItemStackRarity(ItemStack itemStack) { return getRarity(itemStack); } // Paper - OBFHELPER - public Rarity getRarity(ItemStack stack) { - if (!stack.isEnchanted()) { - return this.rarity; diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -40,12 +19,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (item == null) { + throw new IllegalArgumentException(material + " is not an item, and rarity does not apply to blocks"); + } -+ return io.papermc.paper.inventory.ItemRarity.values()[item.getItemRarity().ordinal()]; ++ return io.papermc.paper.inventory.ItemRarity.values()[item.rarity.ordinal()]; + } + + @Override + public io.papermc.paper.inventory.ItemRarity getItemStackRarity(org.bukkit.inventory.ItemStack itemStack) { -+ return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getItemStackRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()]; ++ return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()]; + } // Paper end diff --git a/patches/server-remapped/ItemStack-repair-check-API.patch b/patches/server/ItemStack-repair-check-API.patch similarity index 77% rename from patches/server-remapped/ItemStack-repair-check-API.patch rename to patches/server/ItemStack-repair-check-API.patch index 5adb1314e8..69f1d264c9 100644 --- a/patches/server-remapped/ItemStack-repair-check-API.patch +++ b/patches/server/ItemStack-repair-check-API.patch @@ -4,24 +4,12 @@ Date: Sat, 15 May 2021 22:11:11 -0700 Subject: [PATCH] ItemStack repair check API -diff --git a/src/main/java/net/minecraft/world/item/Item.java b/src/main/java/net/minecraft/world/item/Item.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/item/Item.java -+++ b/src/main/java/net/minecraft/world/item/Item.java -@@ -0,0 +0,0 @@ public class Item implements ItemLike { - return this.category; - } - -+ public boolean canRepair(ItemStack toBeRepaired, ItemStack repairMaterial) { return isValidRepairItem(toBeRepaired, repairMaterial); } // Paper - OBFHELPER - public boolean isValidRepairItem(ItemStack stack, ItemStack ingredient) { - return false; - } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { - return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getItemStackRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()]; + return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()]; } + @Override @@ -29,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (!itemToBeRepaired.getType().isItem() || !repairMaterial.getType().isItem()) { + return false; + } -+ return this.getItem(itemToBeRepaired.getType()).canRepair(CraftItemStack.asNMSCopy(itemToBeRepaired), CraftItemStack.asNMSCopy(repairMaterial)); ++ return CraftMagicNumbers.getItem(itemToBeRepaired.getType()).isValidRepairItem(CraftItemStack.asNMSCopy(itemToBeRepaired), CraftItemStack.asNMSCopy(repairMaterial)); + } + @Override diff --git a/patches/server-remapped/Limit-item-frame-cursors-on-maps.patch b/patches/server/Limit-item-frame-cursors-on-maps.patch similarity index 99% rename from patches/server-remapped/Limit-item-frame-cursors-on-maps.patch rename to patches/server/Limit-item-frame-cursors-on-maps.patch index 998b423b14..aac43baa02 100644 --- a/patches/server-remapped/Limit-item-frame-cursors-on-maps.patch +++ b/patches/server/Limit-item-frame-cursors-on-maps.patch @@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + mapItemFrameCursorLimit = getInt("map-item-frame-cursor-limit", mapItemFrameCursorLimit); + } } + diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java diff --git a/patches/server-remapped/MC-29274-Fix-Wither-hostility-towards-players.patch b/patches/server/MC-29274-Fix-Wither-hostility-towards-players.patch similarity index 98% rename from patches/server-remapped/MC-29274-Fix-Wither-hostility-towards-players.patch rename to patches/server/MC-29274-Fix-Wither-hostility-towards-players.patch index 87587ad6c4..8e65af4a92 100644 --- a/patches/server-remapped/MC-29274-Fix-Wither-hostility-towards-players.patch +++ b/patches/server/MC-29274-Fix-Wither-hostility-towards-players.patch @@ -19,11 +19,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + log("Withers properly target players: " + fixWitherTargetingBug); + } } + diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java -@@ -0,0 +0,0 @@ public class WitherBoss extends Monster implements RangedAttackMob { +@@ -0,0 +0,0 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 8.0F)); this.goalSelector.addGoal(7, new RandomLookAroundGoal(this)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this, new Class[0])); diff --git a/patches/server-remapped/Merchant-getRecipes-should-return-an-immutable-list.patch b/patches/server/Merchant-getRecipes-should-return-an-immutable-list.patch similarity index 69% rename from patches/server-remapped/Merchant-getRecipes-should-return-an-immutable-list.patch rename to patches/server/Merchant-getRecipes-should-return-an-immutable-list.patch index b5e346008e..d31191d03a 100644 --- a/patches/server-remapped/Merchant-getRecipes-should-return-an-immutable-list.patch +++ b/patches/server/Merchant-getRecipes-should-return-an-immutable-list.patch @@ -12,8 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public List getRecipes() { -- return Collections.unmodifiableList(Lists.transform(merchant.getOffers(), new Function() { -+ return com.google.common.collect.ImmutableList.copyOf(Lists.transform(merchant.getOffers(), new Function() { // Paper - javadoc says 'an immutable list of trades' - not 'an unmodifiable view of a list of trades'. fixes issue with setRecipes(getRecipes()) +- return Collections.unmodifiableList(Lists.transform(this.merchant.getOffers(), new Function() { ++ return com.google.common.collect.ImmutableList.copyOf(Lists.transform(this.merchant.getOffers(), new Function() { // Paper - javadoc says 'an immutable list of trades' - not 'an unmodifiable view of a list of trades'. fixes issue with setRecipes(getRecipes()) @Override public MerchantRecipe apply(net.minecraft.world.item.trading.MerchantOffer recipe) { return recipe.asBukkit(); diff --git a/patches/server-remapped/More-Enchantment-API.patch b/patches/server/More-Enchantment-API.patch similarity index 63% rename from patches/server-remapped/More-Enchantment-API.patch rename to patches/server/More-Enchantment-API.patch index 998cc6ae13..7bd645b8b6 100644 --- a/patches/server-remapped/More-Enchantment-API.patch +++ b/patches/server/More-Enchantment-API.patch @@ -4,72 +4,16 @@ Date: Thu, 6 May 2021 19:57:58 -0700 Subject: [PATCH] More Enchantment API -diff --git a/src/main/java/net/minecraft/world/item/enchantment/Enchantment.java b/src/main/java/net/minecraft/world/item/enchantment/Enchantment.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/item/enchantment/Enchantment.java -+++ b/src/main/java/net/minecraft/world/item/enchantment/Enchantment.java -@@ -0,0 +0,0 @@ import net.minecraft.world.item.ItemStack; - - public abstract class Enchantment { - -- private final EquipmentSlot[] slots; -+ private final EquipmentSlot[] slots; public final EquipmentSlot[] getSlots() { return this.slots; } // Paper - OBFHELPER - private final Enchantment.Rarity rarity; - public final EnchantmentCategory category; - @Nullable -@@ -0,0 +0,0 @@ public abstract class Enchantment { - return map; - } - -+ public Enchantment.Rarity getRarity() { return getRarity(); } // Paper - OBFHELPER - public Enchantment.Rarity getRarity() { - return this.rarity; - } -@@ -0,0 +0,0 @@ public abstract class Enchantment { - return 0; - } - -+ public float getDamageIncrease(int level, MobType enumMonsterType) { return getDamageBonus(level, enumMonsterType); } // Paper - OBFHELPER - public float getDamageBonus(int level, MobType group) { - return 0.0F; - } -@@ -0,0 +0,0 @@ public abstract class Enchantment { - return false; - } - -+ public boolean isCursed() { return isCurse(); } // Paper - OBFHELPER - public boolean isCurse() { - return false; - } - -+ public boolean isTradeable() { return isTradeable(); } // Paper - OBFHELPER - public boolean isTradeable() { - return true; - } - -+ public boolean isDiscoverable() { return isDiscoverable(); } // Paper - OBFHELPER - public boolean isDiscoverable() { - return true; - } diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java -@@ -0,0 +0,0 @@ - package org.bukkit.craftbukkit.enchantments; - - import net.minecraft.core.Registry; --import net.minecraft.world.item.enchantment.BindingCurseEnchantment; --import net.minecraft.world.item.enchantment.VanishingCurseEnchantment; - import org.bukkit.craftbukkit.inventory.CraftItemStack; - import org.bukkit.craftbukkit.util.CraftNamespacedKey; - import org.bukkit.enchantments.Enchantment; @@ -0,0 +0,0 @@ public class CraftEnchantment extends Enchantment { @Override public boolean isCursed() { -- return target instanceof BindingCurseEnchantment || target instanceof VanishingCurseEnchantment; -+ return target.isCursed(); // Paper +- return this.target instanceof BindingCurseEnchantment || this.target instanceof VanishingCurseEnchantment; ++ return this.target.isCurse(); // Paper } @Override @@ -95,12 +39,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public float getDamageIncrease(int level, org.bukkit.entity.EntityCategory entityCategory) { -+ return target.getDamageIncrease(level, org.bukkit.craftbukkit.entity.CraftLivingEntity.fromBukkitEntityCategory(entityCategory)); ++ return target.getDamageBonus(level, org.bukkit.craftbukkit.entity.CraftLivingEntity.fromBukkitEntityCategory(entityCategory)); + } + + @Override + public java.util.Set getActiveSlots() { -+ return java.util.stream.Stream.of(target.getSlots()).map(org.bukkit.craftbukkit.CraftEquipmentSlot::getSlot).collect(java.util.stream.Collectors.toSet()); ++ return java.util.stream.Stream.of(target.slots).map(org.bukkit.craftbukkit.CraftEquipmentSlot::getSlot).collect(java.util.stream.Collectors.toSet()); + } + + public static io.papermc.paper.enchantments.EnchantmentRarity fromNMSRarity(net.minecraft.world.item.enchantment.Enchantment.Rarity nmsRarity) { @@ -125,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public void setHurtDirection(float hurtDirection) { - getHandle().setHurtDirection(hurtDirection); + getHandle().hurtDir = hurtDirection; } + + public static MobType fromBukkitEntityCategory(EntityCategory entityCategory) { @@ -180,7 +124,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import com.google.common.base.Joiner; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; -+import net.minecraft.world.entity.EnumMonsterType; ++import net.minecraft.world.entity.MobType; +import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.entity.EntityCategory; +import org.junit.Test; @@ -196,16 +140,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Test + public void test() throws IllegalAccessException { + -+ Map enumMonsterTypeFieldMap = Maps.newHashMap(); -+ for (Field field : EnumMonsterType.class.getDeclaredFields()) { -+ if (field.getType() == EnumMonsterType.class) { -+ enumMonsterTypeFieldMap.put( (EnumMonsterType) field.get(null), field.getName()); ++ Map enumMonsterTypeFieldMap = Maps.newHashMap(); ++ for (Field field : MobType.class.getDeclaredFields()) { ++ if (field.getType() == MobType.class) { ++ enumMonsterTypeFieldMap.put( (MobType) field.get(null), field.getName()); + } + } + + for (EntityCategory entityCategory : EntityCategory.values()) { + enumMonsterTypeFieldMap.remove(CraftLivingEntity.fromBukkitEntityCategory(entityCategory)); + } -+ assertTrue(EnumMonsterType.class.getName() + " instance(s): " + Joiner.on(", ").join(enumMonsterTypeFieldMap.values()) + " do not have bukkit equivalents", enumMonsterTypeFieldMap.size() == 0); ++ assertTrue(MobType.class.getName() + " instance(s): " + Joiner.on(", ").join(enumMonsterTypeFieldMap.values()) + " do not have bukkit equivalents", enumMonsterTypeFieldMap.size() == 0); + } +} diff --git a/patches/server-remapped/More-Lidded-Block-API.patch b/patches/server/More-Lidded-Block-API.patch similarity index 70% rename from patches/server-remapped/More-Lidded-Block-API.patch rename to patches/server/More-Lidded-Block-API.patch index 3578e7af64..0d370cfd2b 100644 --- a/patches/server-remapped/More-Lidded-Block-API.patch +++ b/patches/server/More-Lidded-Block-API.patch @@ -4,49 +4,19 @@ Date: Sun, 23 May 2021 17:49:51 +0900 Subject: [PATCH] More Lidded Block API -diff --git a/src/main/java/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java -@@ -0,0 +0,0 @@ public class EnderChestBlockEntity extends BlockEntity { // Paper - Remove ITick - - public float openness; - public float oOpenness; -- public int openCount; -+ public int openCount; public int getViewerCount() { return openCount; } // Paper - OBFHELPER - private int tickInterval; -+ public boolean opened; // Paper - More Lidded Block API - - public EnderChestBlockEntity() { - super(BlockEntityType.ENDER_CHEST); -@@ -0,0 +0,0 @@ public class EnderChestBlockEntity extends BlockEntity { // Paper - Remove ITick - - public void startOpen() { - ++this.openCount; -+ if (opened) return; // Paper - More Lidded Block API - this.level.blockEvent(this.worldPosition, Blocks.ENDER_CHEST, 1, this.openCount); - doOpenLogic(); // Paper - } - - public void stopOpen() { - --this.openCount; -+ if (opened) return; // Paper - More Lidded Block API - this.level.blockEvent(this.worldPosition, Blocks.ENDER_CHEST, 1, this.openCount); - doCloseLogic(); // Paper - } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java @@ -0,0 +0,0 @@ public class CraftBarrel extends CraftLootable implements Bar } - getTileEntity().opened = false; + getTileEntity().openersCounter.opened = false; } + + // Paper start - More Lidded Block API + @Override + public boolean isOpen() { -+ return getTileEntity().opened; ++ return getTileEntity().openersCounter.opened; + } + // Paper end - More Lidded Block API } @@ -56,13 +26,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java @@ -0,0 +0,0 @@ public class CraftChest extends CraftLootable implements Chest } - getTileEntity().opened = false; + getTileEntity().openersCounter.opened = false; } + + // Paper start - More Lidded Block API + @Override + public boolean isOpen() { -+ return getTileEntity().opened; ++ return getTileEntity().openersCounter.opened; + } + // Paper end - More Lidded Block API } @@ -79,28 +49,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public void open() { + requirePlaced(); -+ if (!getTileEntity().opened) { ++ if (!getTileEntity().openersCounter.opened) { + net.minecraft.world.level.Level world = getTileEntity().getLevel(); + world.blockEvent(getTileEntity().getBlockPos(), getTileEntity().getBlockState().getBlock(), 1, getTileEntity().getViewerCount() + 1); + world.playSound(null, getPosition(), net.minecraft.sounds.SoundEvents.ENDER_CHEST_OPEN, net.minecraft.sounds.SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); + } -+ getTileEntity().opened = true; ++ getTileEntity().openersCounter.opened = true; + } + + @Override + public void close() { + requirePlaced(); -+ if (getTileEntity().opened) { ++ if (getTileEntity().openersCounter.opened) { + net.minecraft.world.level.Level world = getTileEntity().getLevel(); + world.blockEvent(getTileEntity().getBlockPos(), getTileEntity().getBlockState().getBlock(), 1, 0); + world.playSound(null, getPosition(), net.minecraft.sounds.SoundEvents.ENDER_CHEST_CLOSE, net.minecraft.sounds.SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); + } -+ getTileEntity().opened = false; ++ getTileEntity().openersCounter.opened = false; + } + + @Override + public boolean isOpen() { -+ return getTileEntity().opened; ++ return getTileEntity().openersCounter.opened; + } + // Paper end - More Lidded Block API } diff --git a/patches/server/More-World-API.patch b/patches/server/More-World-API.patch new file mode 100644 index 0000000000..db9e514674 --- /dev/null +++ b/patches/server/More-World-API.patch @@ -0,0 +1,86 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Tue, 7 Jul 2020 10:52:34 -0700 +Subject: [PATCH] More World API + + +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +@@ -0,0 +0,0 @@ public class CraftWorld implements World { + return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ()); + } + ++ // Paper start ++ @Override ++ public Location locateNearestBiome(Location origin, Biome biome, int radius) { ++ return this.locateNearestBiome(origin, biome, radius, 8); ++ } ++ ++ @Override ++ public Location locateNearestBiome(Location origin, Biome biome, int radius, int step) { ++ BlockPos originPos = new BlockPos(origin.getX(), origin.getY(), origin.getZ()); ++ BlockPos nearest = getHandle().findNearestBiome(CraftBlock.biomeToBiomeBase(getHandle().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), biome), originPos, radius, step); ++ return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ()); ++ } ++ ++ @Override ++ public boolean isUltrawarm() { ++ return getHandle().dimensionType().ultraWarm(); ++ } ++ ++ @Override ++ public boolean isNatural() { ++ return getHandle().dimensionType().natural(); ++ } ++ ++ @Override ++ public double getCoordinateScale() { ++ return getHandle().dimensionType().coordinateScale(); ++ } ++ ++ @Override ++ public boolean hasSkylight() { ++ return getHandle().dimensionType().hasSkyLight(); ++ } ++ ++ @Override ++ public boolean hasBedrockCeiling() { ++ return getHandle().dimensionType().hasSkyLight(); ++ } ++ ++ @Override ++ public boolean isPiglinSafe() { ++ return getHandle().dimensionType().piglinSafe(); ++ } ++ ++ @Override ++ public boolean doesBedWork() { ++ return getHandle().dimensionType().bedWorks(); ++ } ++ ++ @Override ++ public boolean doesRespawnAnchorWork() { ++ return getHandle().dimensionType().respawnAnchorWorks(); ++ } ++ ++ @Override ++ public boolean hasRaids() { ++ return getHandle().dimensionType().hasRaids(); ++ } ++ ++ @Override ++ public boolean isFixedTime() { ++ return getHandle().dimensionType().hasFixedTime(); ++ } ++ ++ @Override ++ public Collection getInfiniburn() { ++ return com.google.common.collect.Sets.newHashSet(com.google.common.collect.Iterators.transform(getHandle().dimensionType().infiniburn().getValues().iterator(), CraftMagicNumbers::getMaterial)); ++ } ++ // Paper end ++ + @Override + public Raid locateNearestRaid(Location location, int radius) { + Validate.notNull(location, "Location cannot be null"); diff --git a/patches/server-remapped/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch b/patches/server/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch similarity index 83% rename from patches/server-remapped/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch rename to patches/server/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch index 6ffc4cab6f..afa74a6379 100644 --- a/patches/server-remapped/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch +++ b/patches/server/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch @@ -9,7 +9,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java +++ b/src/main/java/net/minecraft/world/entity/EntityType.java -@@ -0,0 +0,0 @@ public class EntityType { +@@ -0,0 +0,0 @@ public class EntityType implements EntityTypeTest { @Nullable public T spawnCreature(ServerLevel worldserver, @Nullable CompoundTag nbttagcompound, @Nullable Component ichatbasecomponent, @Nullable Player entityhuman, BlockPos blockposition, MobSpawnType enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { @@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper start - Call PreCreatureSpawnEvent org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(EntityType.getKey(this).getPath()); if (type != null) { -@@ -0,0 +0,0 @@ public class EntityType { +@@ -0,0 +0,0 @@ public class EntityType implements EntityTypeTest { } // Paper end T t0 = this.create(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1); @@ -35,9 +35,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java +++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java @@ -0,0 +0,0 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill + public WanderingTrader(EntityType type, Level world) { super(type, world); - this.forcedLoading = true; - this.setDespawnDelay(48000); // CraftBukkit - set default from MobSpawnerTrader + //this.setDespawnDelay(48000); // CraftBukkit - set default from MobSpawnerTrader // Paper - move back to MobSpawnerTrader - Vanilla behavior is that only traders spawned by it have this value set. } @@ -51,8 +51,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return false; } -- WanderingTrader entityvillagertrader = (WanderingTrader) EntityType.WANDERING_TRADER.spawnCreature(worldserver, (CompoundTag) null, (Component) null, (Player) null, blockposition2, MobSpawnType.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit -+ WanderingTrader entityvillagertrader = EntityType.WANDERING_TRADER.spawnCreature(worldserver, null, null, null, blockposition2, MobSpawnType.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL, trader -> trader.setDespawnDelay(48000)); // CraftBukkit // Paper - set despawnTimer before spawn events called +- WanderingTrader entityvillagertrader = (WanderingTrader) EntityType.WANDERING_TRADER.spawnCreature(world, (CompoundTag) null, (Component) null, (Player) null, blockposition2, MobSpawnType.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit ++ WanderingTrader entityvillagertrader = EntityType.WANDERING_TRADER.spawnCreature(world, null, null, null, blockposition2, MobSpawnType.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL, trader -> trader.setDespawnDelay(48000)); // CraftBukkit // Paper - set despawnTimer before spawn events called if (entityvillagertrader != null) { for (int i = 0; i < 2; ++i) { diff --git a/patches/server-remapped/Prevent-grindstones-from-overstacking-items.patch b/patches/server/Prevent-grindstones-from-overstacking-items.patch similarity index 100% rename from patches/server-remapped/Prevent-grindstones-from-overstacking-items.patch rename to patches/server/Prevent-grindstones-from-overstacking-items.patch diff --git a/patches/server-remapped/Remove-streams-from-SensorNearest.patch b/patches/server/Remove-streams-from-SensorNearest.patch similarity index 55% rename from patches/server-remapped/Remove-streams-from-SensorNearest.patch rename to patches/server/Remove-streams-from-SensorNearest.patch index 9d50468cc9..cda6bfea63 100644 --- a/patches/server-remapped/Remove-streams-from-SensorNearest.patch +++ b/patches/server/Remove-streams-from-SensorNearest.patch @@ -23,31 +23,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java +++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java @@ -0,0 +0,0 @@ public class NearestItemSensor extends Sensor { - List list = world.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(8.0D, 4.0D, 8.0D), (entityitem) -> { return true; }); -- -- entity.getClass(); -+ // Paper start - remove streams in favour of lists list.sort(Comparator.comparingDouble(entity::distanceToSqr)); -- Stream stream = list.stream().filter((entityitem) -> { -- return entity.wantsToPickUp(entityitem.getItem()); -- }).filter((entityitem) -> { -- return entityitem.closerThan((Entity) entity, 9.0D); -- }); -- -- entity.getClass(); -- Optional optional = stream.filter(entity::hasLineOfSight).findFirst(); -- -- behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, optional); +- Optional optional = list.stream().filter((itemEntity) -> { +- return entity.wantsToPickUp(itemEntity.getItem()); +- }).filter((itemEntity) -> { +- return itemEntity.closerThan(entity, 9.0D); +- }).filter(entity::hasLineOfSight).findFirst(); +- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, optional); ++ // Paper start - remove streams in favour of lists + ItemEntity nearest = null; + for (ItemEntity entityItem : list) { -+ if (entity.wantsToPickUp(entityItem.getItem()) && entityItem.closerThan(entity, 9.0D) && entity.canSee(entityItem)) { ++ if (entity.wantsToPickUp(entityItem.getItem()) && entityItem.closerThan(entity, 9.0D) && entity.hasLineOfSight(entityItem)) { + nearest = entityItem; + break; + } + } -+ behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, Optional.ofNullable(nearest)); ++ brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, Optional.ofNullable(nearest)); + // Paper end } } @@ -57,17 +50,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java @@ -0,0 +0,0 @@ public class NearestLivingEntitySensor extends Sensor { list.sort(Comparator.comparingDouble(entity::distanceToSqr)); - Brain behaviorcontroller = entity.getBrain(); - -- behaviorcontroller.setMemory(MemoryModuleType.MOBS, (Object) list); -- behaviorcontroller.setMemory(MemoryModuleType.VISIBLE_MOBS, list.stream().filter((entityliving1) -> { -- return doTick(entity, entityliving1); + Brain brain = entity.getBrain(); + brain.setMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES, list); +- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, list.stream().filter((livingEntity2) -> { +- return isEntityTargetable(entity, livingEntity2); - }).collect(Collectors.toList())); -+ behaviorcontroller.setMemory(MemoryModuleType.MOBS, list); // Paper - decompile error + // Paper start - remove streams in favour of lists + List visibleMobs = new java.util.ArrayList<>(list); -+ visibleMobs.removeIf(otherEntityLiving -> !Sensor.a(entity, otherEntityLiving)); -+ behaviorcontroller.setMemory(MemoryModuleType.VISIBLE_MOBS, visibleMobs); ++ visibleMobs.removeIf(otherEntityLiving -> !Sensor.isEntityTargetable(entity, otherEntityLiving)); ++ brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, visibleMobs); + // Paper end } @@ -80,41 +71,37 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override protected void doTick(ServerLevel world, LivingEntity entity) { -- Stream stream = world.players().stream().filter(EntitySelector.NO_SPECTATORS).filter((entityplayer) -> { -- return entity.closerThan((Entity) entityplayer, 16.0D); -- }); +- List list = world.players().stream().filter(EntitySelector.NO_SPECTATORS).filter((serverPlayer) -> { +- return entity.closerThan(serverPlayer, 16.0D); +- }).sorted(Comparator.comparingDouble(entity::distanceToSqr)).collect(Collectors.toList()); + // Paper start - remove streams in favour of lists + List players = new java.util.ArrayList<>(world.players()); -+ players.removeIf(player -> !EntitySelector.notSpectator().test(player) || !entity.closerThan(player, 16.0D)); // Paper - removeIf only re-allocates once compared to iterator -+ players.sort(Comparator.comparingDouble(entity::distanceToSqr)); - -- entity.getClass(); -- List list = (List) stream.sorted(Comparator.comparingDouble(entity::h)).collect(Collectors.toList()); - Brain behaviorcontroller = entity.getBrain(); -- -- behaviorcontroller.setMemory(MemoryModuleType.NEAREST_PLAYERS, (Object) list); -- List list1 = (List) list.stream().filter((entityhuman) -> { -- return doTick(entity, (LivingEntity) entityhuman); ++ players.removeIf(player -> !EntitySelector.NO_SPECTATORS.test(player) || !entity.closerThan(player, 16.0D)); // Paper - removeIf only re-allocates once compared to iterator + Brain brain = entity.getBrain(); +- brain.setMemory(MemoryModuleType.NEAREST_PLAYERS, list); +- List list2 = list.stream().filter((player) -> { +- return isEntityTargetable(entity, player); - }).collect(Collectors.toList()); -- -- behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, (Object) (list1.isEmpty() ? null : (Player) list1.get(0))); -- Optional optional = list1.stream().filter(EntitySelector.ATTACK_ALLOWED).findFirst(); -- -- behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_PLAYER, optional); -+ behaviorcontroller.setMemory(MemoryModuleType.NEAREST_PLAYERS, players); +- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, list2.isEmpty() ? null : list2.get(0)); +- Optional optional = list2.stream().filter((player) -> { +- return isEntityAttackable(entity, player); +- }).findFirst(); +- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, optional); ++ ++ brain.setMemory(MemoryModuleType.NEAREST_PLAYERS, players); + + Player nearest = null, nearestTargetable = null; + for (Player player : players) { -+ if (Sensor.a(entity, player)) { ++ if (Sensor.isEntityTargetable(entity, player)) { + if (nearest == null) nearest = player; -+ if (EntitySelector.canAITarget().test(player)) { ++ if (Sensor.isEntityAttackable(entity, player)) { + nearestTargetable = player; + break; // Both variables are assigned, no reason to loop further + } + } + } -+ behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, nearest); -+ behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_PLAYER, nearestTargetable); ++ brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, nearest); ++ brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, nearestTargetable); + // Paper end } } diff --git a/patches/server-remapped/Send-empty-commands-if-tab-completion-is-disabled.patch b/patches/server/Send-empty-commands-if-tab-completion-is-disabled.patch similarity index 100% rename from patches/server-remapped/Send-empty-commands-if-tab-completion-is-disabled.patch rename to patches/server/Send-empty-commands-if-tab-completion-is-disabled.patch diff --git a/patches/server-remapped/Set-area-affect-cloud-rotation.patch b/patches/server/Set-area-affect-cloud-rotation.patch similarity index 86% rename from patches/server-remapped/Set-area-affect-cloud-rotation.patch rename to patches/server/Set-area-affect-cloud-rotation.patch index 4a1cdd8a24..b3da40d3d8 100644 --- a/patches/server-remapped/Set-area-affect-cloud-rotation.patch +++ b/patches/server/Set-area-affect-cloud-rotation.patch @@ -11,8 +11,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class CraftWorld implements World { entity = net.minecraft.world.entity.EntityType.LIGHTNING_BOLT.create(world); } else if (AreaEffectCloud.class.isAssignableFrom(clazz)) { - entity = new net.minecraft.world.entity.AreaEffectCloud(world, x, y, z); + entity = new net.minecraft.world.entity.AreaEffectCloud(this.world, x, y, z); + entity.moveTo(x, y, z, yaw, pitch); // Paper - Set area effect cloud Rotation } else if (EvokerFangs.class.isAssignableFrom(clazz)) { - entity = new net.minecraft.world.entity.projectile.EvokerFangs(world, x, y, z, (float) Math.toRadians(yaw), 0, null); - } + entity = new net.minecraft.world.entity.projectile.EvokerFangs(this.world, x, y, z, (float) Math.toRadians(yaw), 0, null); + } else if (Marker.class.isAssignableFrom(clazz)) { diff --git a/patches/server/Significantly-improve-performance-of-the-end-generat.patch b/patches/server/Significantly-improve-performance-of-the-end-generat.patch index d93a523b24..40d0e81bba 100644 --- a/patches/server/Significantly-improve-performance-of-the-end-generat.patch +++ b/patches/server/Significantly-improve-performance-of-the-end-generat.patch @@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if (q * q + r * r > 4096L && simplexNoise.getValue((double)q, (double)r) < (double)-0.9F) { - float g = (Mth.abs((float)q) * 3439.0F + Mth.abs((float)r) * 147.0F) % 13.0F + 9.0F; + // Paper start - Significantly improve end generation performance by using a noise cache -+ long key = net.minecraft.world.level.ChunkPos.asLong((int) q, (int) q); ++ long key = net.minecraft.world.level.ChunkPos.asLong((int) q, (int) r); + int index = (int) it.unimi.dsi.fastutil.HashCommon.mix(key) & 8191; + float g = Float.MIN_VALUE; + if (cache.keys[index] == key) { diff --git a/patches/server-remapped/Throw-proper-exception-on-empty-JsonList-file.patch b/patches/server/Throw-proper-exception-on-empty-JsonList-file.patch similarity index 100% rename from patches/server-remapped/Throw-proper-exception-on-empty-JsonList-file.patch rename to patches/server/Throw-proper-exception-on-empty-JsonList-file.patch diff --git a/patches/server-remapped/add-RespawnFlags-to-PlayerRespawnEvent.patch b/patches/server/add-RespawnFlags-to-PlayerRespawnEvent.patch similarity index 91% rename from patches/server-remapped/add-RespawnFlags-to-PlayerRespawnEvent.patch rename to patches/server/add-RespawnFlags-to-PlayerRespawnEvent.patch index 6ef2252568..34ea6c0ada 100644 --- a/patches/server-remapped/add-RespawnFlags-to-PlayerRespawnEvent.patch +++ b/patches/server/add-RespawnFlags-to-PlayerRespawnEvent.patch @@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; @@ -22,11 +22,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { - return this.moveToWorld(player, this.server.getLevel(player.getRespawnDimension()), alive, null, true); } -+ // Paper start public ServerPlayer moveToWorld(ServerPlayer entityplayer, ServerLevel worldserver, boolean flag, Location location, boolean avoidSuffocation) { ++ // Paper start + return moveToWorld(entityplayer, worldserver, flag, location, avoidSuffocation, new org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag[0]); + } + @@ -38,9 +37,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public abstract class PlayerList { } - Player respawnPlayer = cserver.getPlayer(entityplayer1); + Player respawnPlayer = this.cserver.getPlayer(entityplayer1); - PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !isAnchorSpawn, isAnchorSpawn); // Paper - Fix anchor respawn acting as a bed respawn from the end portal + PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !isAnchorSpawn, isAnchorSpawn, com.google.common.collect.ImmutableSet.builder().add(respawnFlags)); // Paper - Fix anchor respawn acting as a bed respawn from the end portal - cserver.getPluginManager().callEvent(respawnEvent); + this.cserver.getPluginManager().callEvent(respawnEvent); // Spigot Start if (entityplayer.connection.isDisconnected()) { diff --git a/patches/server-remapped/add-consumeFuel-to-FurnaceBurnEvent.patch b/patches/server/add-consumeFuel-to-FurnaceBurnEvent.patch similarity index 64% rename from patches/server-remapped/add-consumeFuel-to-FurnaceBurnEvent.patch rename to patches/server/add-consumeFuel-to-FurnaceBurnEvent.patch index 2800673db4..a6434c40c9 100644 --- a/patches/server-remapped/add-consumeFuel-to-FurnaceBurnEvent.patch +++ b/patches/server/add-consumeFuel-to-FurnaceBurnEvent.patch @@ -9,11 +9,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java @@ -0,0 +0,0 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit - if (this.isLit() && furnaceBurnEvent.isBurning()) { - // CraftBukkit end - flag1 = true; -- if (!itemstack.isEmpty()) { -+ if (!itemstack.isEmpty() && furnaceBurnEvent.willConsumeFuel()) { // Paper - Item item = itemstack.getItem(); + if (blockEntity.isLit() && furnaceBurnEvent.isBurning()) { + // CraftBukkit end + flag1 = true; +- if (!itemstack.isEmpty()) { ++ if (!itemstack.isEmpty() && furnaceBurnEvent.willConsumeFuel()) { // Paper + Item item = itemstack.getItem(); - itemstack.shrink(1); + itemstack.shrink(1); diff --git a/patches/server-remapped/add-get-set-drop-chance-to-EntityEquipment.patch b/patches/server/add-get-set-drop-chance-to-EntityEquipment.patch similarity index 96% rename from patches/server-remapped/add-get-set-drop-chance-to-EntityEquipment.patch rename to patches/server/add-get-set-drop-chance-to-EntityEquipment.patch index 2866e73912..a3b38854b9 100644 --- a/patches/server-remapped/add-get-set-drop-chance-to-EntityEquipment.patch +++ b/patches/server/add-get-set-drop-chance-to-EntityEquipment.patch @@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java @@ -0,0 +0,0 @@ public class CraftEntityEquipment implements EntityEquipment { public void setBootsDropChance(float chance) { - setDropChance(net.minecraft.world.entity.EquipmentSlot.FEET, chance); + this.setDropChance(net.minecraft.world.entity.EquipmentSlot.FEET, chance); } + // Paper start + @Override diff --git a/patches/server-remapped/add-isDeeplySleeping-to-HumanEntity.patch b/patches/server/add-isDeeplySleeping-to-HumanEntity.patch similarity index 95% rename from patches/server-remapped/add-isDeeplySleeping-to-HumanEntity.patch rename to patches/server/add-isDeeplySleeping-to-HumanEntity.patch index 449cc69938..e911b3d4ae 100644 --- a/patches/server-remapped/add-isDeeplySleeping-to-HumanEntity.patch +++ b/patches/server/add-isDeeplySleeping-to-HumanEntity.patch @@ -21,4 +21,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public int getSleepTicks() { - return getHandle().sleepCounter; + return this.getHandle().sleepCounter; diff --git a/patches/server-remapped/added-PlayerNameEntityEvent.patch b/patches/server/added-PlayerNameEntityEvent.patch similarity index 88% rename from patches/server-remapped/added-PlayerNameEntityEvent.patch rename to patches/server/added-PlayerNameEntityEvent.patch index 22c0bfa090..757009a9bc 100644 --- a/patches/server-remapped/added-PlayerNameEntityEvent.patch +++ b/patches/server/added-PlayerNameEntityEvent.patch @@ -15,7 +15,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.adventure.PaperAdventure; +import io.papermc.paper.event.player.PlayerNameEntityEvent; +// Paper end -+import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.LivingEntity; @@ -25,17 +24,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (!user.level.isClientSide && entity.isAlive()) { - entity.setCustomName(stack.getHoverName()); - if (entity instanceof Mob) { -- ((Mob) entity).setPersistenceRequired(); +- ((Mob)entity).setPersistenceRequired(); + // Paper start -+ PlayerNameEntityEvent event = new PlayerNameEntityEvent(((ServerPlayer) user).getBukkitEntity(), entity.getBukkitLivingEntity(), PaperAdventure.asAdventure(stack.getHoverName()), true); ++ PlayerNameEntityEvent event = new PlayerNameEntityEvent(((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity(), entity.getBukkitLivingEntity(), PaperAdventure.asAdventure(stack.getHoverName()), true); + if (!event.callEvent()) return InteractionResult.PASS; + LivingEntity newEntityLiving = ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getEntity()).getHandle(); + newEntityLiving.setCustomName(event.getName() != null ? PaperAdventure.asVanilla(event.getName()) : null); + if (event.isPersistent() && newEntityLiving instanceof Mob) { + ((Mob) newEntityLiving).setPersistenceRequired(); - } -- + // Paper end - stack.shrink(1); - } + } + stack.shrink(1); diff --git a/patches/server-remapped/added-option-to-disable-pathfinding-updates-on-block.patch b/patches/server/added-option-to-disable-pathfinding-updates-on-block.patch similarity index 97% rename from patches/server-remapped/added-option-to-disable-pathfinding-updates-on-block.patch rename to patches/server/added-option-to-disable-pathfinding-updates-on-block.patch index 627f6c7cdc..5e644cf687 100644 --- a/patches/server-remapped/added-option-to-disable-pathfinding-updates-on-block.patch +++ b/patches/server/added-option-to-disable-pathfinding-updates-on-block.patch @@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + updatePathfindingOnBlockUpdate = getBoolean("update-pathfinding-on-block-update", this.updatePathfindingOnBlockUpdate); + } } + diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -31,8 +32,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 VoxelShape voxelshape1 = newState.getCollisionShape(this, pos); @@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl + } - this.tickingEntities = wasTicking; // Paper } + } // Paper } diff --git a/patches/server/additions-to-PlayerGameModeChangeEvent.patch b/patches/server/additions-to-PlayerGameModeChangeEvent.patch new file mode 100644 index 0000000000..d57a20a9a6 --- /dev/null +++ b/patches/server/additions-to-PlayerGameModeChangeEvent.patch @@ -0,0 +1,150 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Sat, 15 May 2021 10:04:43 -0700 +Subject: [PATCH] additions to PlayerGameModeChangeEvent + + +diff --git a/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java b/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java ++++ b/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java +@@ -0,0 +0,0 @@ public class DefaultGameModeCommands { + GameType gameType = minecraftServer.getForcedGameType(); + if (gameType != null) { + for(ServerPlayer serverPlayer : minecraftServer.getPlayerList().getPlayers()) { +- if (serverPlayer.setGameMode(gameType)) { +- ++i; ++ // Paper start - extend PlayerGameModeChangeEvent ++ org.bukkit.event.player.PlayerGameModeChangeEvent event = serverPlayer.setGameMode(gameType, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, net.kyori.adventure.text.Component.empty()); ++ if (event != null && event.isCancelled()) { ++ source.sendSuccess(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.cancelMessage()), false); + } ++ // Paper end ++ ++i; + } + } + +diff --git a/src/main/java/net/minecraft/server/commands/GameModeCommand.java b/src/main/java/net/minecraft/server/commands/GameModeCommand.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/commands/GameModeCommand.java ++++ b/src/main/java/net/minecraft/server/commands/GameModeCommand.java +@@ -0,0 +0,0 @@ public class GameModeCommand { + int i = 0; + + for(ServerPlayer serverPlayer : targets) { +- if (serverPlayer.setGameMode(gameMode)) { ++ // Paper start - extend PlayerGameModeChangeEvent ++ org.bukkit.event.player.PlayerGameModeChangeEvent event = serverPlayer.setGameMode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.COMMAND, net.kyori.adventure.text.Component.empty()); ++ if (event != null && !event.isCancelled()) { + logGamemodeChange(context.getSource(), serverPlayer, gameMode); + ++i; ++ } else if (event != null && event.cancelMessage() != null) { ++ context.getSource().sendSuccess(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.cancelMessage()), true); ++ // Paper end + } + } + +diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java ++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { + } + + public boolean setGameMode(GameType gameMode) { +- if (!this.gameMode.changeGameModeForPlayer(gameMode)) { +- return false; ++ // Paper start - Add cause and nullable message to event ++ PlayerGameModeChangeEvent event = this.setGameMode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.UNKNOWN, null); ++ return event == null ? false : event.isCancelled(); ++ } ++ public PlayerGameModeChangeEvent setGameMode(GameType gameMode, PlayerGameModeChangeEvent.Cause cause, net.kyori.adventure.text.Component message) { ++ PlayerGameModeChangeEvent event = this.gameMode.changeGameModeForPlayer(gameMode, cause, message); ++ if (event == null || event.isCancelled()) { ++ // Paper end ++ return null; + } else { + this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float) gameMode.getId())); + if (gameMode == GameType.SPECTATOR) { +@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { + + this.onUpdateAbilities(); + this.updateEffectVisibility(); +- return true; ++ return event; // Paper + } + } + +@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { + } + + public void loadGameTypes(@Nullable CompoundTag nbt) { ++ if (this.server.getForcedGameType() != null && this.server.getForcedGameType() != ServerPlayer.readPlayerMode(nbt, "playerGameType")) { ++ if (new PlayerGameModeChangeEvent(this.getBukkitEntity(), GameMode.getByValue(this.server.getDefaultGameType().getId()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null).callEvent()) { ++ this.gameMode.setGameModeForPlayer(this.server.getForcedGameType(), GameType.DEFAULT_MODE); ++ } else { ++ this.gameMode.setGameModeForPlayer(ServerPlayer.readPlayerMode(nbt,"playerGameType"), ServerPlayer.readPlayerMode(nbt, "previousPlayerGameType")); ++ } ++ return; ++ } + this.gameMode.setGameModeForPlayer(this.calculateGameModeForNewPlayer(ServerPlayer.readPlayerMode(nbt, "playerGameType")), ServerPlayer.readPlayerMode(nbt, "previousPlayerGameType")); + } + +diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java ++++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +@@ -0,0 +0,0 @@ public class ServerPlayerGameMode { + } + + public boolean changeGameModeForPlayer(GameType gameMode) { ++ // Paper end ++ PlayerGameModeChangeEvent event = this.changeGameModeForPlayer(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.UNKNOWN, null); ++ return event == null ? false : event.isCancelled(); ++ } ++ public PlayerGameModeChangeEvent changeGameModeForPlayer(GameType gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause cause, net.kyori.adventure.text.Component component) { ++ // Paper end + if (gameMode == this.gameModeForPlayer) { +- return false; ++ return null; // Paper + } else { + // CraftBukkit start + PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(this.player.getBukkitEntity(), GameMode.getByValue(gameMode.getId())); + this.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { +- return false; ++ return event; // Paper + } + // CraftBukkit end + this.setGameModeForPlayer(gameMode, this.gameModeForPlayer); +- return true; ++ return event; // Paper + } + } + +diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser + + this.player = this.server.getPlayerList().respawn(this.player, false); + if (this.server.isHardcore()) { +- this.player.setGameMode(GameType.SPECTATOR); ++ this.player.setGameMode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper + ((GameRules.BooleanValue) this.player.getLevel().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server); + } + } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + throw new IllegalArgumentException("Mode cannot be null"); + } + +- this.getHandle().setGameMode(GameType.byId(mode.getValue())); ++ this.getHandle().setGameMode(GameType.byId(mode.getValue()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.PLUGIN, null); // Paper + } + + @Override diff --git a/patches/server-remapped/call-PortalCreateEvent-players-and-end-platform.patch b/patches/server/call-PortalCreateEvent-players-and-end-platform.patch similarity index 93% rename from patches/server-remapped/call-PortalCreateEvent-players-and-end-platform.patch rename to patches/server/call-PortalCreateEvent-players-and-end-platform.patch index 8cf8c63ab4..b5fae41987 100644 --- a/patches/server-remapped/call-PortalCreateEvent-players-and-end-platform.patch +++ b/patches/server/call-PortalCreateEvent-players-and-end-platform.patch @@ -20,7 +20,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener { +@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { private void createEndPlatform(ServerLevel world, BlockPos centerPos) { BlockPos.MutableBlockPos blockposition_mutableblockposition = centerPos.mutable(); @@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 BlockState iblockdata = k == -1 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState(); - world.setBlockAndUpdate(blockposition_mutableblockposition.set(centerPos).move(j, k, i), iblockdata); -+ blockList.setBlock(blockposition_mutableblockposition.setValues(centerPos).withOffset(j, k, i), iblockdata, 3); // Paper ++ blockList.setBlock(blockposition_mutableblockposition.set(centerPos).move(j, k, i), iblockdata, 3); // Paper } } } diff --git a/patches/server-remapped/copy-TESign-isEditable-from-snapshots.patch b/patches/server/copy-TESign-isEditable-from-snapshots.patch similarity index 100% rename from patches/server-remapped/copy-TESign-isEditable-from-snapshots.patch rename to patches/server/copy-TESign-isEditable-from-snapshots.patch diff --git a/patches/server-remapped/fix-PigZombieAngerEvent-cancellation.patch b/patches/server/fix-PigZombieAngerEvent-cancellation.patch similarity index 70% rename from patches/server-remapped/fix-PigZombieAngerEvent-cancellation.patch rename to patches/server/fix-PigZombieAngerEvent-cancellation.patch index 53c110306b..930286d797 100644 --- a/patches/server-remapped/fix-PigZombieAngerEvent-cancellation.patch +++ b/patches/server/fix-PigZombieAngerEvent-cancellation.patch @@ -4,25 +4,13 @@ Date: Thu, 18 Mar 2021 21:38:01 +0100 Subject: [PATCH] fix PigZombieAngerEvent cancellation -diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java b/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java -+++ b/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java -@@ -0,0 +0,0 @@ public abstract class Goal { - - public void start() { this.start(); } public void start() {} // Paper - OBFHELPER - -+ public final void onTaskResetObfHelper() { stop(); } // Paper - OBFHELPER - public void stop() { - onTaskReset(); // Paper - } diff --git a/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java b/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java +++ b/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java @@ -0,0 +0,0 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob { - private UUID persistentAngerTarget; - private static final IntRange ALERT_INTERVAL = TimeUtil.rangeOfSeconds(4, 6); + private static final int ALERT_RANGE_Y = 10; + private static final UniformInt ALERT_INTERVAL = TimeUtil.rangeOfSeconds(4, 6); private int ticksUntilNextAlert; + private HurtByTargetGoal pathfinderGoalHurtByTarget; // Paper @@ -41,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.level.getCraftServer().getPluginManager().callEvent(event); if (event.isCancelled()) { this.setPersistentAngerTarget(null); -+ pathfinderGoalHurtByTarget.onTaskResetObfHelper(); // Paper - clear goalTargets to fix cancellation ++ pathfinderGoalHurtByTarget.stop(); // Paper - clear goalTargets to fix cancellation return; } this.setRemainingPersistentAngerTime(event.getNewAnger()); diff --git a/patches/server/fix-PlayerItemHeldEvent-firing-twice.patch b/patches/server/fix-PlayerItemHeldEvent-firing-twice.patch new file mode 100644 index 0000000000..3b2c2d38b4 --- /dev/null +++ b/patches/server/fix-PlayerItemHeldEvent-firing-twice.patch @@ -0,0 +1,18 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: chickeneer +Date: Thu, 22 Apr 2021 19:02:07 -0700 +Subject: [PATCH] fix PlayerItemHeldEvent firing twice + + +diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser + PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); + if (this.player.isImmobile()) return; // CraftBukkit + if (packet.getSlot() >= 0 && packet.getSlot() < Inventory.getSelectionSize()) { ++ if (packet.getSlot() == this.player.getInventory().selected) { return; } // Paper - don't fire itemheldevent when there wasn't a slot change + PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getCraftPlayer(), this.player.getInventory().selected, packet.getSlot()); + this.cserver.getPluginManager().callEvent(event); + if (event.isCancelled()) { diff --git a/patches/server-remapped/fix-cancelling-block-falling-causing-client-desync.patch b/patches/server/fix-cancelling-block-falling-causing-client-desync.patch similarity index 50% rename from patches/server-remapped/fix-cancelling-block-falling-causing-client-desync.patch rename to patches/server/fix-cancelling-block-falling-causing-client-desync.patch index f64b51e964..87e06ec1f6 100644 --- a/patches/server-remapped/fix-cancelling-block-falling-causing-client-desync.patch +++ b/patches/server/fix-cancelling-block-falling-causing-client-desync.patch @@ -8,22 +8,6 @@ diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -0,0 +0,0 @@ import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; - import net.minecraft.network.syncher.EntityDataAccessor; - import net.minecraft.network.syncher.EntityDataSerializers; - import net.minecraft.network.syncher.SynchedEntityData; -+import net.minecraft.server.level.ServerLevel; - import net.minecraft.tags.BlockTags; - import net.minecraft.tags.FluidTags; - import net.minecraft.tags.Tag; -@@ -0,0 +0,0 @@ import net.minecraft.world.level.material.Fluids; - import net.minecraft.world.phys.BlockHitResult; - import net.minecraft.world.phys.HitResult; - import net.minecraft.world.phys.Vec3; -+import org.bukkit.craftbukkit.block.CraftBlock; - import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - - public class FallingBlockEntity extends Entity { @@ -0,0 +0,0 @@ public class FallingBlockEntity extends Entity { if (this.time++ == 0) { @@ -31,29 +15,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if (this.level.getBlockState(blockposition).is(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { - this.level.removeBlock(blockposition, false); + // Paper start - fix cancelling block falling causing client desync -+ if (this.level.getBlockState(blockposition).isSameInstance(block)) { ++ if (this.level.getBlockState(blockposition).is(block)) { + if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { -+ if (this.level.getBlockState(blockposition).isSameInstance(block)) { //if listener didn't update the block ++ if (this.level.getBlockState(blockposition).is(block)) { //if listener didn't update the block + ((ServerLevel) level).getChunkSource().blockChanged(blockposition); + } -+ this.remove(); ++ this.discard(); + return; + } else { + this.level.setAir(blockposition, false); + } + // Paper end - fix cancelling block falling causing client desync } else if (!this.level.isClientSide) { - this.remove(); + this.discard(); return; -diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -0,0 +0,0 @@ public abstract class BlockBehaviour { - return this.getBlock().is(tag) && predicate.test(this); - } - -+ public final boolean isSameInstance(Block block) { return is(block); } // Paper - OBFHELPER - public boolean is(Block block) { - return this.getBlock().is(block); - } diff --git a/patches/server-remapped/fix-converting-txt-to-json-file.patch b/patches/server/fix-converting-txt-to-json-file.patch similarity index 77% rename from patches/server-remapped/fix-converting-txt-to-json-file.patch rename to patches/server/fix-converting-txt-to-json-file.patch index ebf9e73fd6..d1be4a99df 100644 --- a/patches/server-remapped/fix-converting-txt-to-json-file.patch +++ b/patches/server/fix-converting-txt-to-json-file.patch @@ -9,9 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java @@ -0,0 +0,0 @@ public class DedicatedPlayerList extends PlayerList { - - this.setViewDistance(dedicatedserverproperties.viewDistance); - super.setUsingWhiteList((Boolean) dedicatedserverproperties.whiteList.get()); + DedicatedServerProperties dedicatedServerProperties = server.getProperties(); + this.setViewDistance(dedicatedServerProperties.viewDistance); + super.setUsingWhiteList(dedicatedServerProperties.whiteList.get()); + // Paper start - moved from constructor + } + @Override @@ -42,24 +42,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - if (this.convertOldUsers()) { -- this.getProfileCache().b(false); // Paper +- this.getProfileCache().save(false); // Paper - } -- + if (!OldUsersConverter.serverReadyAfterUserconversion(this)) { return false; - } else { -diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/players/GameProfileCache.java -+++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java -@@ -0,0 +0,0 @@ public class GameProfileCache { - return arraylist; - } - -+ public void save(boolean asyncSave) { b(asyncSave); } // Paper - OBFHELPER - public void b(boolean asyncSave) { // Paper - JsonArray jsonarray = new JsonArray(); - DateFormat dateformat = createDateFormat(); diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java diff --git a/patches/server-remapped/fix-dead-slime-setSize-invincibility.patch b/patches/server/fix-dead-slime-setSize-invincibility.patch similarity index 80% rename from patches/server-remapped/fix-dead-slime-setSize-invincibility.patch rename to patches/server/fix-dead-slime-setSize-invincibility.patch index f98f485947..ba340689e1 100644 --- a/patches/server-remapped/fix-dead-slime-setSize-invincibility.patch +++ b/patches/server/fix-dead-slime-setSize-invincibility.patch @@ -12,8 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void setSize(int size) { -- getHandle().setSize(size, true); -+ getHandle().setSize(size, /* true */ getHandle().isAlive()); // Paper - fix dead slime setSize invincibility +- this.getHandle().setSize(size, true); ++ this.getHandle().setSize(size, /* true */ getHandle().isAlive()); // Paper - fix dead slime setSize invincibility } @Override diff --git a/patches/server-remapped/forced-whitelist-use-configurable-kick-message.patch b/patches/server/forced-whitelist-use-configurable-kick-message.patch similarity index 100% rename from patches/server-remapped/forced-whitelist-use-configurable-kick-message.patch rename to patches/server/forced-whitelist-use-configurable-kick-message.patch diff --git a/patches/server-remapped/living-entity-allow-attribute-registration.patch b/patches/server/living-entity-allow-attribute-registration.patch similarity index 80% rename from patches/server-remapped/living-entity-allow-attribute-registration.patch rename to patches/server/living-entity-allow-attribute-registration.patch index 9651074438..7919856caa 100644 --- a/patches/server-remapped/living-entity-allow-attribute-registration.patch +++ b/patches/server/living-entity-allow-attribute-registration.patch @@ -8,15 +8,6 @@ diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java +++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java -@@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger; - public class AttributeMap { - - private static final Logger LOGGER = LogManager.getLogger(); -- private final Map attributes = Maps.newHashMap(); -+ private final Map attributes = Maps.newHashMap(); private final Map attributeMap = attributes; // Paper - OBFHELPER - private final Set dirtyAttributes = Sets.newHashSet(); - private final AttributeSupplier supplier; - @@ -0,0 +0,0 @@ public class AttributeMap { } @@ -25,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper - start + public void registerAttribute(Attribute attributeBase) { + AttributeInstance attributeModifiable = new AttributeInstance(attributeBase, AttributeInstance::getAttribute); -+ attributeMap.put(attributeBase, attributeModifiable); ++ attributes.put(attributeBase, attributeModifiable); + } + // Paper - end + @@ -54,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { - return getHandle().craftAttributes.getAttribute(attribute); + return this.getHandle().craftAttributes.getAttribute(attribute); } + // Paper start diff --git a/patches/server-remapped/misc-debugging-dumps.patch b/patches/server/misc-debugging-dumps.patch similarity index 70% rename from patches/server-remapped/misc-debugging-dumps.patch rename to patches/server/misc-debugging-dumps.patch index ff9cbd7c50..c27cd1046d 100644 --- a/patches/server-remapped/misc-debugging-dumps.patch +++ b/patches/server/misc-debugging-dumps.patch @@ -32,14 +32,6 @@ diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -0,0 +0,0 @@ import io.netty.buffer.ByteBufOutputStream; - import io.netty.buffer.Unpooled; - import io.papermc.paper.adventure.PaperAdventure; // Paper - import io.papermc.paper.event.entity.EntityMoveEvent; -+import io.papermc.paper.util.TraceUtil; - import it.unimi.dsi.fastutil.longs.LongIterator; - import java.awt.image.BufferedImage; - import java.io.BufferedWriter; @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop