From 9774a52d110f29e4be956d1aad7bb4c99b50d21d Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sun, 26 May 2024 12:51:15 -0700 Subject: [PATCH] fix and cleanup loot table patches (#10100) * fix and cleanup loot table patches * fixes --- patches/api/0041-LootTable-API.patch | 60 +- patches/api/0056-Fix-upstream-javadocs.patch | 2 +- patches/api/0147-Mob-Pathfinding-API.patch | 2 +- patches/api/0155-Add-sun-related-API.patch | 2 +- patches/api/0279-Add-Mob-lookAt-API.patch | 2 +- patches/api/0292-Missing-Entity-API.patch | 14 +- patches/api/0310-Left-handed-API.patch | 10 +- .../0400-Add-Mob-Experience-reward-API.patch | 10 +- ...able-API-and-replenishable-lootables.patch | 904 ++++++++++-------- .../server/0128-Cap-Entity-Collisions.patch | 4 +- .../server/0143-Entity-fromMobSpawner.patch | 8 +- ...ackByEntityEvent-and-EntityPushedByE.patch | 4 +- ...-more-information-to-Entity.toString.patch | 4 +- ...ies-option-to-debug-dupe-uuid-issues.patch | 6 +- ...entity-dismount-during-teleportation.patch | 10 +- .../0284-Entity-getEntitySpawnReason.patch | 8 +- ...n-to-nerf-pigmen-from-nether-portals.patch | 8 +- ...pawn-point-if-spawn-in-unloaded-worl.patch | 4 +- ...item-duplication-and-teleport-issues.patch | 12 +- ...-position-and-AABB-are-never-invalid.patch | 8 +- ...ortation-and-cancel-velocity-if-tele.patch | 4 +- ...y-Counter-to-allow-plugins-to-use-va.patch | 4 +- patches/server/0423-Entity-isTicking.patch | 4 +- ...-should-not-bypass-cramming-gamerule.patch | 4 +- .../0460-MC-4-Fix-item-position-desync.patch | 4 +- ...n-for-requiring-a-player-participant.patch | 4 +- .../server/0553-More-Lidded-Block-API.patch | 4 +- .../0563-Fix-dangerous-end-portal-logic.patch | 6 +- ...ptimize-indirect-passenger-iteration.patch | 6 +- .../0597-Add-back-EntityPortalExitEvent.patch | 6 +- ...08-Add-Raw-Byte-Entity-Serialization.patch | 4 +- ...date-head-rotation-in-missing-places.patch | 6 +- ...-t-attempt-to-teleport-dead-entities.patch | 4 +- ...ward-CraftEntity-in-teleport-command.patch | 6 +- .../server/0671-Freeze-Tick-Lock-API.patch | 10 +- ...assenger-world-matches-ridden-entity.patch | 4 +- ...entity-loading-causing-async-lookups.patch | 4 +- ...us-missing-EntityDropItemEvent-calls.patch | 4 +- .../0740-Add-EntityPortalReadyEvent.patch | 6 +- ...tEvent-cancellation-cant-fully-preve.patch | 4 +- .../0794-Player-Entity-Tracking-Events.patch | 4 +- .../server/0803-Improve-PortalEvents.patch | 4 +- ...sion-moving-velocity-to-VehicleBlock.patch | 6 +- ...esh-ProjectileSource-for-projectiles.patch | 4 +- ...d-chunks-for-supporting-block-checks.patch | 4 +- ...Folia-scheduler-and-owned-region-API.patch | 10 +- patches/server/0889-Expand-Pose-API.patch | 6 +- ...n-t-fire-sync-events-during-worldgen.patch | 4 +- ...estore-vanilla-entity-drops-behavior.patch | 6 +- ...date-ResourceLocation-in-NBT-reading.patch | 27 +- .../0943-Fixup-NamespacedKey-handling.patch | 39 +- ...944-Expose-LootTable-of-DecoratedPot.patch | 14 +- .../server/0965-Fix-DamageSource-API.patch | 4 +- .../server/0977-Rewrite-chunk-system.patch | 22 +- .../0986-Entity-Activation-Range-2.0.patch | 8 +- ...ptimize-Collision-to-not-load-chunks.patch | 6 +- ...tance-map-to-optimise-entity-tracker.patch | 4 +- ...l-more-information-in-watchdog-dumps.patch | 10 +- .../server/1009-Collision-optimisations.patch | 8 +- .../1015-Properly-resend-entities.patch | 4 +- patches/server/1016-Optimize-Hoppers.patch | 4 +- .../server/1041-More-Chest-Block-API.patch | 4 +- 62 files changed, 746 insertions(+), 636 deletions(-) diff --git a/patches/api/0041-LootTable-API.patch b/patches/api/0041-LootTable-API.patch index ced8fe4885..d500927ae8 100644 --- a/patches/api/0041-LootTable-API.patch +++ b/patches/api/0041-LootTable-API.patch @@ -58,10 +58,10 @@ index 0000000000000000000000000000000000000000..b387894fe8001edb41ad2ad2b70ebabe +} diff --git a/src/main/java/com/destroystokyo/paper/loottable/LootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/LootableInventory.java new file mode 100644 -index 0000000000000000000000000000000000000000..2b01a50b6e18856f4c9e28340a7a111cae646a0a +index 0000000000000000000000000000000000000000..b18a0b50c12fe8d8c954e5c070f2ecd1854a2583 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/loottable/LootableInventory.java -@@ -0,0 +1,125 @@ +@@ -0,0 +1,124 @@ +package com.destroystokyo.paper.loottable; + +import org.bukkit.entity.Player; @@ -101,8 +101,8 @@ index 0000000000000000000000000000000000000000..2b01a50b6e18856f4c9e28340a7a111c + * @param player The player to check + * @return Whether or not this player has looted this block + */ -+ default boolean hasPlayerLooted(@NotNull Player player) { -+ return hasPlayerLooted(player.getUniqueId()); ++ default boolean hasPlayerLooted(final @NotNull Player player) { ++ return this.hasPlayerLooted(player.getUniqueId()); + } + + /** @@ -127,9 +127,8 @@ index 0000000000000000000000000000000000000000..2b01a50b6e18856f4c9e28340a7a111c + * @param player The player to check + * @return Timestamp last looted, or null if player has not looted this object + */ -+ @Nullable -+ default Long getLastLooted(@NotNull Player player) { -+ return getLastLooted(player.getUniqueId()); ++ default @Nullable Long getLastLooted(final @NotNull Player player) { ++ return this.getLastLooted(player.getUniqueId()); + } + + /** @@ -147,8 +146,8 @@ index 0000000000000000000000000000000000000000..2b01a50b6e18856f4c9e28340a7a111c + * @param looted true to add player to looted list, false to remove + * @return The previous state of whether the player had looted this or not + */ -+ default boolean setHasPlayerLooted(@NotNull Player player, boolean looted) { -+ return setHasPlayerLooted(player.getUniqueId(), looted); ++ default boolean setHasPlayerLooted(final @NotNull Player player, final boolean looted) { ++ return this.setHasPlayerLooted(player.getUniqueId(), looted); + } + + /** @@ -271,6 +270,19 @@ index b451191312e4fb19f2131c2d0a0c0337953f6c7c..db6affbc78106b2d93b41953b624a0bc /** * Gets the inventory of the chest block represented by this block state. +diff --git a/src/main/java/org/bukkit/block/Crafter.java b/src/main/java/org/bukkit/block/Crafter.java +index 05d6af1681351844a6673a6d0dfca2038dafa7b6..8b2a315ed5dd1c57ce60fc41fd5e83a6495028e6 100644 +--- a/src/main/java/org/bukkit/block/Crafter.java ++++ b/src/main/java/org/bukkit/block/Crafter.java +@@ -10,7 +10,7 @@ import org.jetbrains.annotations.ApiStatus; + */ + @ApiStatus.Experimental + @MinecraftExperimental(Requires.UPDATE_1_21) +-public interface Crafter extends Container, Lootable { ++public interface Crafter extends Container, com.destroystokyo.paper.loottable.LootableBlockInventory { // Paper - LootTable API + + /** + * Gets the number of ticks which this block will remain in the crafting diff --git a/src/main/java/org/bukkit/block/Dispenser.java b/src/main/java/org/bukkit/block/Dispenser.java index 74cd194c9a98245dc52e7e352d7d6c046e1e5cf3..07af1a3f011d4b96275f919d302ac367198e923e 100644 --- a/src/main/java/org/bukkit/block/Dispenser.java @@ -355,6 +367,23 @@ index 5b5c3be107fdaa6c55ceb1bca2c223ebc6ab7f43..4ebe1033c55dbd58d0794809435c9352 -public interface ChestBoat extends Boat, InventoryHolder, Lootable { +public interface ChestBoat extends Boat, InventoryHolder, com.destroystokyo.paper.loottable.LootableEntityInventory { // Paper } +diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java +index 2926fa6071bc7640cc10280b5c3962b0ce7686f1..f3f62e13cc1b6172808c52f2d5f520f1f584e6db 100644 +--- a/src/main/java/org/bukkit/entity/Mob.java ++++ b/src/main/java/org/bukkit/entity/Mob.java +@@ -61,4 +61,12 @@ public interface Mob extends LivingEntity, Lootable { + */ + @Nullable + public Sound getAmbientSound(); ++ ++ // Paper start - LootTable API ++ @Override ++ default void setLootTable(final @Nullable org.bukkit.loot.LootTable table, final long seed) { ++ this.setLootTable(table); ++ this.setSeed(seed); ++ } ++ // Paper end - LootTable API + } diff --git a/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java b/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java index 937b99f8734d71b2ad33af142afbc251b81d9745..db69687a7ad4b18d17ab1677cae5d8dd4dcd3678 100644 --- a/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java @@ -394,10 +423,10 @@ index 9ea403e6fd8e960d017660e0aec118abeda2c42b..238d118f7788b13cd86b7e9ea3a0fc38 +public interface StorageMinecart extends Minecart, InventoryHolder, LootableEntityInventory { // Paper } diff --git a/src/main/java/org/bukkit/loot/Lootable.java b/src/main/java/org/bukkit/loot/Lootable.java -index 24a3d989db3bc67e7afe8459a3d4bb132f448ea7..901db852498e0658c79a57582508dab29bf0a798 100644 +index 24a3d989db3bc67e7afe8459a3d4bb132f448ea7..ad4b0fb7f55ed44dc74fb5a4bd36be6004231116 100644 --- a/src/main/java/org/bukkit/loot/Lootable.java +++ b/src/main/java/org/bukkit/loot/Lootable.java -@@ -36,6 +36,34 @@ public interface Lootable { +@@ -36,6 +36,31 @@ public interface Lootable { @Nullable LootTable getLootTable(); @@ -408,24 +437,21 @@ index 24a3d989db3bc67e7afe8459a3d4bb132f448ea7..901db852498e0658c79a57582508dab2 + * @param table the Loot Table this {@link org.bukkit.block.Container} or {@link org.bukkit.entity.Mob} will have. + * @param seed the seed to used to generate loot. Default is 0. + */ -+ default void setLootTable(@Nullable LootTable table, long seed) { -+ setLootTable(table); -+ setSeed(seed); -+ } ++ void setLootTable(final @Nullable LootTable table, final long seed); + + /** + * Returns whether or not this object has a Loot Table + * @return Has a loot table + */ + default boolean hasLootTable() { -+ return getLootTable() != null; ++ return this.getLootTable() != null; + } + + /** + * Clears the associated Loot Table to this object + */ + default void clearLootTable() { -+ setLootTable(null); ++ this.setLootTable(null); + } + // Paper end + diff --git a/patches/api/0056-Fix-upstream-javadocs.patch b/patches/api/0056-Fix-upstream-javadocs.patch index d25bff0a4b..c88af4e8bf 100644 --- a/patches/api/0056-Fix-upstream-javadocs.patch +++ b/patches/api/0056-Fix-upstream-javadocs.patch @@ -411,7 +411,7 @@ index b688b3856cb3068a539fcecfbfa113f8ab4160a9..c275b881cbd11307a6dcc7190d7a7d40 * @return whether the item frame is visible or not */ diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java -index 2926fa6071bc7640cc10280b5c3962b0ce7686f1..4f63988848443aff55619bc12ef12c925642a3f9 100644 +index f3f62e13cc1b6172808c52f2d5f520f1f584e6db..ad5dbf310fe7b34c997bb339f09697222f862005 100644 --- a/src/main/java/org/bukkit/entity/Mob.java +++ b/src/main/java/org/bukkit/entity/Mob.java @@ -9,6 +9,10 @@ import org.jetbrains.annotations.Nullable; diff --git a/patches/api/0147-Mob-Pathfinding-API.patch b/patches/api/0147-Mob-Pathfinding-API.patch index 83fb575817..1c0b6088a4 100644 --- a/patches/api/0147-Mob-Pathfinding-API.patch +++ b/patches/api/0147-Mob-Pathfinding-API.patch @@ -238,7 +238,7 @@ index 0000000000000000000000000000000000000000..3c1e2c93d923a683cc0455af77c43784 + } +} diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java -index 4f63988848443aff55619bc12ef12c925642a3f9..6de4344931b2e3d570346b800186c44a0d5782cc 100644 +index ad5dbf310fe7b34c997bb339f09697222f862005..63a14bec00d0b23431d1d002139f48a7d0bc2a88 100644 --- a/src/main/java/org/bukkit/entity/Mob.java +++ b/src/main/java/org/bukkit/entity/Mob.java @@ -2,6 +2,7 @@ package org.bukkit.entity; diff --git a/patches/api/0155-Add-sun-related-API.patch b/patches/api/0155-Add-sun-related-API.patch index 7132b29be0..6b6e2476a0 100644 --- a/patches/api/0155-Add-sun-related-API.patch +++ b/patches/api/0155-Add-sun-related-API.patch @@ -26,7 +26,7 @@ index 5efe33cef4d9c153d760fc71606721ff8abafbfc..b6ca63afb74b345e381d35646cc8faf5 * Gets the full in-game time on this world since the world generation * diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java -index 6de4344931b2e3d570346b800186c44a0d5782cc..7eee2e561346ac1d672f9652edb78e76c910fc9d 100644 +index 63a14bec00d0b23431d1d002139f48a7d0bc2a88..ef89a82669a6c5bf911827b90facf36a2ff26e91 100644 --- a/src/main/java/org/bukkit/entity/Mob.java +++ b/src/main/java/org/bukkit/entity/Mob.java @@ -20,6 +20,13 @@ public interface Mob extends LivingEntity, Lootable { diff --git a/patches/api/0279-Add-Mob-lookAt-API.patch b/patches/api/0279-Add-Mob-lookAt-API.patch index 0dd5126905..e1164a0f3e 100644 --- a/patches/api/0279-Add-Mob-lookAt-API.patch +++ b/patches/api/0279-Add-Mob-lookAt-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add Mob#lookAt API diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java -index 7eee2e561346ac1d672f9652edb78e76c910fc9d..11b6d1aba7d1f6ae1f3c822193486f5a1478e105 100644 +index ef89a82669a6c5bf911827b90facf36a2ff26e91..5fd723c9fdda81595db8b150d967ff3bd5cea608 100644 --- a/src/main/java/org/bukkit/entity/Mob.java +++ b/src/main/java/org/bukkit/entity/Mob.java @@ -27,6 +27,88 @@ public interface Mob extends LivingEntity, Lootable { diff --git a/patches/api/0292-Missing-Entity-API.patch b/patches/api/0292-Missing-Entity-API.patch index 26800f488d..4dcfc5d27a 100644 --- a/patches/api/0292-Missing-Entity-API.patch +++ b/patches/api/0292-Missing-Entity-API.patch @@ -738,15 +738,15 @@ index d23226ccb0f6c25028f000ce31346cd0a8898e6a..bc84b892cae5fe7019a3ad481e9da799 + // Paper end } diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java -index 11b6d1aba7d1f6ae1f3c822193486f5a1478e105..709c8fc3dde786f45ff13d6ee6c405ffdc765282 100644 +index 5fd723c9fdda81595db8b150d967ff3bd5cea608..91d31e5418a5ab7cefd7c02a41bbec8464fe7ab1 100644 --- a/src/main/java/org/bukkit/entity/Mob.java +++ b/src/main/java/org/bukkit/entity/Mob.java -@@ -162,4 +162,38 @@ public interface Mob extends LivingEntity, Lootable { - */ - @Nullable - public Sound getAmbientSound(); +@@ -170,4 +170,38 @@ public interface Mob extends LivingEntity, Lootable { + this.setSeed(seed); + } + // Paper end - LootTable API + -+ // Paper start ++ // Paper start - Missing Entity API + /** + * Some mobs will raise their arm(s) when aggressive: + *