diff --git a/build-data/paper.at b/build-data/paper.at index fc06d593c438..0ef9b3431958 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -560,6 +560,7 @@ public net.minecraft.world.item.ItemStackLinkedSet TYPE_AND_TAG public net.minecraft.world.item.JukeboxSongPlayer song public net.minecraft.world.item.MapItem createNewSavedData(Lnet/minecraft/server/level/ServerLevel;IIIZZLnet/minecraft/resources/ResourceKey;)Lnet/minecraft/world/level/saveddata/maps/MapId; public net.minecraft.world.item.StandingAndWallBlockItem wallBlock +public net.minecraft.world.item.component.BundleContents$Mutable indexIsOutsideAllowedBounds(I)Z public net.minecraft.world.item.component.ItemContainerContents MAX_SIZE public net.minecraft.world.item.component.ItemContainerContents items public net.minecraft.world.item.component.ResolvableProfile unpack()Lcom/mojang/datafixers/util/Either; diff --git a/paper-api/src/main/java/io/papermc/paper/event/inventory/PlayerBundleItemSelectEvent.java b/paper-api/src/main/java/io/papermc/paper/event/inventory/PlayerBundleItemSelectEvent.java new file mode 100644 index 000000000000..f27f7cde6259 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/event/inventory/PlayerBundleItemSelectEvent.java @@ -0,0 +1,130 @@ +package io.papermc.paper.event.inventory; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; + +/** + * Called when a {@link Player} selects an item inside a bundle. + *
+ * NOTE: This event does not fire for bundle item selections in creative mode player inventories.
+ */
+@NullMarked
+public final class PlayerBundleItemSelectEvent extends InventoryEvent {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final ItemStack bundle;
+ private final int rawSlot;
+ private final int slot;
+
+ private final ItemStack previousItem;
+ private final ItemStack selectedItem;
+
+ private final int previousIndex;
+ private final int selectedIndex;
+
+ @ApiStatus.Internal
+ public PlayerBundleItemSelectEvent(final InventoryView view, final ItemStack bundle, final int rawSlot, final ItemStack previousItem, final ItemStack selectedItem, final int previousIndex, final int selectedIndex) {
+ super(view);
+
+ this.bundle = bundle;
+ this.rawSlot = rawSlot;
+ this.slot = view.convertSlot(rawSlot);
+
+ this.previousItem = previousItem;
+ this.selectedItem = selectedItem;
+
+ this.previousIndex = previousIndex;
+ this.selectedIndex = selectedIndex;
+ }
+
+ /**
+ * Gets the player who triggered the event.
+ *
+ * @return the player
+ */
+ public Player getPlayer() {
+ return (Player) this.getView().getPlayer();
+ }
+
+ /**
+ * Gets the bundle item.
+ *
+ * @return the bundle item
+ */
+ public ItemStack getBundle() {
+ return this.bundle;
+ }
+
+ /**
+ * Gets the slot number of the bundle, depending on which {@link Inventory} it is located in.
+ *
+ * @return the slot number
+ * @see InventoryClickEvent#getSlot()
+ */
+ public int getSlot() {
+ return this.slot;
+ }
+
+ /**
+ * Gets the raw slot number of the bundle inside the {@link InventoryView}.
+ *
+ * @return the raw slot number
+ * @see InventoryClickEvent#getRawSlot()
+ */
+ public int getRawSlot() {
+ return this.rawSlot;
+ }
+
+ /**
+ * Gets the previously selected item inside the bundle. If no item was previously selected, this will return an empty item.
+
+ * @return the previously selected item
+ */
+ public ItemStack getPreviousItem() {
+ return this.previousItem;
+ }
+
+ /**
+ * Gets the selected item inside the bundle.
+ *
+ * @return the selected item
+ */
+ public ItemStack getSelectedItem() {
+ return this.selectedItem;
+ }
+
+ /**
+ * Gets the previously selected index. If no item was previously selected, this will be -1.
+ *
+ * @return the previously selected index
+ */
+ public int getPreviousIndex() {
+ return this.previousIndex;
+ }
+
+ /**
+ * Gets the selected index.
+ *
+ * @return the selected index
+ */
+ public int getSelectedIndex() {
+ return this.selectedIndex;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+}
diff --git a/paper-server/patches/features/0022-Optimise-collision-checking-in-player-move-packet-ha.patch b/paper-server/patches/features/0022-Optimise-collision-checking-in-player-move-packet-ha.patch
index 068477b5ba1f..abeae4a7c8de 100644
--- a/paper-server/patches/features/0022-Optimise-collision-checking-in-player-move-packet-ha.patch
+++ b/paper-server/patches/features/0022-Optimise-collision-checking-in-player-move-packet-ha.patch
@@ -6,7 +6,7 @@ Subject: [PATCH] Optimise collision checking in player move packet handling
Move collision logic to just the hasNewCollision call instead of getCubes + hasNewCollision
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-index fad017de5d9fc31988aa4edf97fb3f9bcbee56c8..06132bde0aed9dd9088c884ee31056b9176b6f90 100644
+index e8ec4da3241c2cb212efdb75974e942b5d434695..5933a3a25954c0c7a2eac2361a805c751f286684 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -633,6 +633,7 @@ public class ServerGamePacketListenerImpl
@@ -72,7 +72,7 @@ index fad017de5d9fc31988aa4edf97fb3f9bcbee56c8..06132bde0aed9dd9088c884ee31056b9
}
@Override
-@@ -1541,7 +1575,7 @@ public class ServerGamePacketListenerImpl
+@@ -1542,7 +1576,7 @@ public class ServerGamePacketListenerImpl
}
}
@@ -81,7 +81,7 @@ index fad017de5d9fc31988aa4edf97fb3f9bcbee56c8..06132bde0aed9dd9088c884ee31056b9
xDist = targetX - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above
yDist = targetY - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above
zDist = targetZ - this.lastGoodZ; // Paper - diff on change, used for checking large move vectors above
-@@ -1580,6 +1614,7 @@ public class ServerGamePacketListenerImpl
+@@ -1581,6 +1615,7 @@ public class ServerGamePacketListenerImpl
boolean playerStandsOnSomething = this.player.verticalCollisionBelow;
this.player.move(MoverType.PLAYER, new Vec3(xDist, yDist, zDist));
this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move
@@ -89,7 +89,7 @@ index fad017de5d9fc31988aa4edf97fb3f9bcbee56c8..06132bde0aed9dd9088c884ee31056b9
// Paper start - prevent position desync
if (this.awaitingPositionFromClient != null) {
return; // ... thanks Mojang for letting move calls teleport across dimensions.
-@@ -1613,7 +1648,17 @@ public class ServerGamePacketListenerImpl
+@@ -1614,7 +1649,17 @@ public class ServerGamePacketListenerImpl
}
// Paper start - Add fail move event
@@ -108,7 +108,7 @@ index fad017de5d9fc31988aa4edf97fb3f9bcbee56c8..06132bde0aed9dd9088c884ee31056b9
if (!allowMovement) {
io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK,
targetX, targetY, targetZ, targetYRot, targetXRot, false);
-@@ -1751,7 +1796,7 @@ public class ServerGamePacketListenerImpl
+@@ -1752,7 +1797,7 @@ public class ServerGamePacketListenerImpl
private boolean updateAwaitingTeleport() {
if (this.awaitingPositionFromClient != null) {
@@ -117,7 +117,7 @@ index fad017de5d9fc31988aa4edf97fb3f9bcbee56c8..06132bde0aed9dd9088c884ee31056b9
this.awaitingTeleportTime = this.tickCount;
this.teleport(
this.awaitingPositionFromClient.x,
-@@ -1770,6 +1815,34 @@ public class ServerGamePacketListenerImpl
+@@ -1771,6 +1816,34 @@ public class ServerGamePacketListenerImpl
}
}
diff --git a/paper-server/patches/features/0026-DataConverter-Moonrise-co-fixes.patch b/paper-server/patches/features/0026-DataConverter-Moonrise-co-fixes.patch
index 900a854dba73..e10ebdbe87f6 100644
--- a/paper-server/patches/features/0026-DataConverter-Moonrise-co-fixes.patch
+++ b/paper-server/patches/features/0026-DataConverter-Moonrise-co-fixes.patch
@@ -42,10 +42,10 @@ index d2877c20f389d0131e1dd208b464f590671e5d82..27bdc70d861ca39487ad16cb3afb89d6
updateComponent(root, "minecraft:trim", hiddenComponents);
updateComponent(root, "minecraft:unbreakable", hiddenComponents);
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-index 06132bde0aed9dd9088c884ee31056b9176b6f90..08374da2d9b84e8ff13c670d7f45867fb0bdd897 100644
+index 5933a3a25954c0c7a2eac2361a805c751f286684..be4c9d9d70f0bac382f008ab9decc9023dbc5e57 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-@@ -1819,9 +1819,14 @@ public class ServerGamePacketListenerImpl
+@@ -1820,9 +1820,14 @@ public class ServerGamePacketListenerImpl
private boolean hasNewCollision(final ServerLevel level, final Entity entity, final AABB oldBox, final AABB newBox) {
final List