From d04e9fafa422c96c7fb3cfc6dcced747c31cd276 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Sun, 16 Jun 2024 17:21:14 +0200 Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 2b4b6d14 PR-1023: Convert InventoryView to interface CraftBukkit Changes: 68603b1c1 Use expanded interaction ranges for traced interact events eae9f760c PR-1414: Convert InventoryView to interface ee9eafe67 Fix Implementation for DamageSource#isIndirect for internal custom causing entity --- patches/api/Adventure.patch | 10 ++--- .../api/Fix-Spigot-annotation-mistakes.patch | 23 ++++++++--- ...the-experimental-smithing-inventory-.patch | 39 ------------------- patches/server/Adventure.patch | 2 +- patches/server/Fix-DamageSource-API.patch | 2 +- ...y-type-tags-suggestions-in-selectors.patch | 2 +- ...act-event-not-being-called-sometimes.patch | 4 +- ...the-experimental-smithing-inventory-.patch | 26 +++++++++++++ ...store-custom-InventoryHolder-support.patch | 2 +- work/Bukkit | 2 +- work/CraftBukkit | 2 +- 11 files changed, 57 insertions(+), 57 deletions(-) delete mode 100644 patches/api/Properly-remove-the-experimental-smithing-inventory-.patch create mode 100644 patches/server/Properly-remove-the-experimental-smithing-inventory-.patch diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index fd4e38868c..51e10f7c04 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -4310,9 +4310,9 @@ diff --git a/src/main/java/org/bukkit/inventory/InventoryView.java b/src/main/ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/InventoryView.java +++ b/src/main/java/org/bukkit/inventory/InventoryView.java -@@ -0,0 +0,0 @@ public abstract class InventoryView { - return getPlayer().setWindowProperty(prop, value); - } +@@ -0,0 +0,0 @@ public interface InventoryView { + */ + public boolean setProperty(@NotNull Property prop, int value); + // Paper start /** @@ -4321,7 +4321,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * @return The title. */ @NotNull -+ public /*abstract*/ net.kyori.adventure.text.Component title() { ++ default net.kyori.adventure.text.Component title() { + return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.getTitle()); + } + // Paper end @@ -4334,7 +4334,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @Deprecated // Paper + @NotNull - public abstract String getTitle(); + public String getTitle(); /** diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java diff --git a/patches/api/Fix-Spigot-annotation-mistakes.patch b/patches/api/Fix-Spigot-annotation-mistakes.patch index babf660a57..f20e6a0052 100644 --- a/patches/api/Fix-Spigot-annotation-mistakes.patch +++ b/patches/api/Fix-Spigot-annotation-mistakes.patch @@ -1139,6 +1139,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public ItemStack getCursor() { return getView().getCursor(); } +diff --git a/src/main/java/org/bukkit/event/inventory/InventoryType.java b/src/main/java/org/bukkit/event/inventory/InventoryType.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/inventory/InventoryType.java ++++ b/src/main/java/org/bukkit/event/inventory/InventoryType.java +@@ -0,0 +0,0 @@ public enum InventoryType { + * + * @deprecated use {@link #SMITHING} + */ +- @Deprecated ++ @Deprecated(forRemoval = true) // Paper + SMITHING_NEW(4, "Upgrade Gear"), + ; + diff --git a/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java b/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java @@ -1372,7 +1385,7 @@ diff --git a/src/main/java/org/bukkit/inventory/InventoryView.java b/src/main/ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/InventoryView.java +++ b/src/main/java/org/bukkit/inventory/InventoryView.java -@@ -0,0 +0,0 @@ public abstract class InventoryView { +@@ -0,0 +0,0 @@ public interface InventoryView { * Gets the id of this view. * * @return the id of this view @@ -1384,7 +1397,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public int getId() { return id; } -@@ -0,0 +0,0 @@ public abstract class InventoryView { +@@ -0,0 +0,0 @@ public interface InventoryView { /** * Get the item on the cursor of one of the viewing players. * @@ -1395,9 +1408,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 */ - @Nullable + @NotNull // Paper - fix nullability - public final ItemStack getCursor() { - return getPlayer().getItemOnCursor(); - } + public ItemStack getCursor(); + + /** diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/ItemFactory.java diff --git a/patches/api/Properly-remove-the-experimental-smithing-inventory-.patch b/patches/api/Properly-remove-the-experimental-smithing-inventory-.patch deleted file mode 100644 index 6d3ec058c9..0000000000 --- a/patches/api/Properly-remove-the-experimental-smithing-inventory-.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Thu, 8 Jun 2023 14:45:30 -0700 -Subject: [PATCH] Properly remove the experimental smithing inventory type - - -diff --git a/src/main/java/org/bukkit/event/inventory/InventoryType.java b/src/main/java/org/bukkit/event/inventory/InventoryType.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/event/inventory/InventoryType.java -+++ b/src/main/java/org/bukkit/event/inventory/InventoryType.java -@@ -0,0 +0,0 @@ public enum InventoryType { - * - * @deprecated use {@link #SMITHING} - */ -- @Deprecated -+ @Deprecated(forRemoval = true) // Paper - SMITHING_NEW(4, "Upgrade Gear"), - ; - -diff --git a/src/main/java/org/bukkit/inventory/InventoryView.java b/src/main/java/org/bukkit/inventory/InventoryView.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/inventory/InventoryView.java -+++ b/src/main/java/org/bukkit/inventory/InventoryView.java -@@ -0,0 +0,0 @@ public abstract class InventoryView { - type = InventoryType.SlotType.CRAFTING; - break; - case ANVIL: -- case SMITHING: - case CARTOGRAPHY: - case GRINDSTONE: - case MERCHANT: -@@ -0,0 +0,0 @@ public abstract class InventoryView { - } - break; - case LOOM: -+ case SMITHING: // Paper - case SMITHING_NEW: - if (slot == 3) { - type = InventoryType.SlotType.RESULT; diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 548b6abdcd..3836b094d6 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -4783,7 +4783,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.j index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java -@@ -0,0 +0,0 @@ public class CraftInventoryView extends InventoryView { +@@ -0,0 +0,0 @@ public class CraftInventoryView extends CraftAbstractInventoryView { return CraftItemStack.asCraftMirror(this.container.getSlot(slot).getItem()); } diff --git a/patches/server/Fix-DamageSource-API.patch b/patches/server/Fix-DamageSource-API.patch index d7429ac00d..8cb536a507 100644 --- a/patches/server/Fix-DamageSource-API.patch +++ b/patches/server/Fix-DamageSource-API.patch @@ -198,7 +198,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public boolean isIndirect() { -- return this.getHandle().getEntity() != this.getHandle().getDamager(); +- return this.getHandle().getCausingDamager() != this.getHandle().getDamager(); + return !this.getHandle().isDirect(); // Paper - fix DamageSource API } diff --git a/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch b/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch index d47499b76e..a57d5a8df2 100644 --- a/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch +++ b/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch @@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public Collection getSelectedEntities() { + if (io.papermc.paper.configuration.GlobalConfiguration.get().commands.fixTargetSelectorTagCompletion && this.source instanceof ServerPlayer player) { + final Entity cameraEntity = player.getCamera(); -+ final double pickDistance = player.gameMode.getGameModeForPlayer().isCreative() ? 6.0F : 4.5F; ++ final double pickDistance = player.entityInteractionRange(); + final Vec3 min = cameraEntity.getEyePosition(1.0F); + final Vec3 viewVector = cameraEntity.getViewVector(1.0F); + final Vec3 max = min.add(viewVector.x * pickDistance, viewVector.y * pickDistance, viewVector.z * pickDistance); diff --git a/patches/server/Fix-interact-event-not-being-called-sometimes.patch b/patches/server/Fix-interact-event-not-being-called-sometimes.patch index 9b69bf1750..10ce5822d9 100644 --- a/patches/server/Fix-interact-event-not-being-called-sometimes.patch +++ b/patches/server/Fix-interact-event-not-being-called-sometimes.patch @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - double d3 = this.player.gameMode.getGameModeForPlayer() == GameType.CREATIVE ? 5.0D : 4.5D; + double d3 = Math.max(this.player.blockInteractionRange(), this.player.entityInteractionRange()); // SPIGOT-5607: Only call interact event if no block or entity is being clicked. Use bukkit ray trace method, because it handles blocks and entities at the same time // SPIGOT-7429: Make sure to call PlayerInteractEvent for spectators and non-pickable entities - org.bukkit.util.RayTraceResult result = this.player.level().getWorld().rayTrace(origin, origin.getDirection(), d3, org.bukkit.FluidCollisionMode.NEVER, false, 0.1, entity -> { @@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + GameType gameType = this.player.gameMode.getGameModeForPlayer(); + if (gameType == GameType.ADVENTURE && result.getHitBlock() != null) { + CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, ((org.bukkit.craftbukkit.block.CraftBlock) result.getHitBlock()).getPosition(), org.bukkit.craftbukkit.block.CraftBlock.blockFaceToNotch(result.getHitBlockFace()), this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); -+ } else if (gameType != GameType.CREATIVE && result.getHitEntity() != null && origin.toVector().distanceSquared(result.getHitPosition()) > 3.0D * 3.0D) { ++ } else if (gameType != GameType.CREATIVE && result.getHitEntity() != null && origin.toVector().distanceSquared(result.getHitPosition()) > this.player.entityInteractionRange() * this.player.entityInteractionRange()) { + CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); + } + } // Paper end - Call interact event diff --git a/patches/server/Properly-remove-the-experimental-smithing-inventory-.patch b/patches/server/Properly-remove-the-experimental-smithing-inventory-.patch new file mode 100644 index 0000000000..d36cfd40d3 --- /dev/null +++ b/patches/server/Properly-remove-the-experimental-smithing-inventory-.patch @@ -0,0 +1,26 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Thu, 8 Jun 2023 14:45:18 -0700 +Subject: [PATCH] Properly remove the experimental smithing inventory type + + +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftAbstractInventoryView.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftAbstractInventoryView.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftAbstractInventoryView.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftAbstractInventoryView.java +@@ -0,0 +0,0 @@ public abstract class CraftAbstractInventoryView implements InventoryView { + type = InventoryType.SlotType.CRAFTING; + break; + case ANVIL: +- case SMITHING: + case CARTOGRAPHY: + case GRINDSTONE: + case MERCHANT: +@@ -0,0 +0,0 @@ public abstract class CraftAbstractInventoryView implements InventoryView { + } + break; + case LOOM: ++ case SMITHING: // Paper - properly remove experimental smithing inventory + case SMITHING_NEW: + if (slot == 3) { + type = InventoryType.SlotType.RESULT; diff --git a/patches/server/Restore-custom-InventoryHolder-support.patch b/patches/server/Restore-custom-InventoryHolder-support.patch index 662f545089..652320d859 100644 --- a/patches/server/Restore-custom-InventoryHolder-support.patch +++ b/patches/server/Restore-custom-InventoryHolder-support.patch @@ -166,7 +166,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java @@ -0,0 +0,0 @@ public class CraftContainer extends AbstractContainerMenu { public CraftContainer(final Inventory inventory, final Player player, int id) { - this(new InventoryView() { + this(new CraftAbstractInventoryView() { - private final String originalTitle = (inventory instanceof CraftInventoryCustom) ? ((CraftInventoryCustom.MinecraftInventory) ((CraftInventory) inventory).getInventory()).getTitle() : inventory.getType().getDefaultTitle(); + private final String originalTitle = inventory instanceof CraftInventoryCustom ? ((CraftInventoryCustom) inventory).getTitle() : inventory.getType().getDefaultTitle(); // Paper diff --git a/work/Bukkit b/work/Bukkit index e2160a1865..2b4b6d1424 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit e2160a18658bb7d19d303abd7a24605848d6912c +Subproject commit 2b4b6d14241d3d96eb6b7d1888176146dc5895d4 diff --git a/work/CraftBukkit b/work/CraftBukkit index 6ce1726424..68603b1c11 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 6ce17264243172b5e3d14309388e131f025d90f4 +Subproject commit 68603b1c1162f168efdfe8d989d8795587ef9842