Skip to content

Commit 515e12c

Browse files
authored
Check if BUNDLE_CONTENTS is present in InventoryClickEvent (#12321)
1 parent 37b9ca1 commit 515e12c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch

+4-4
Original file line numberDiff line numberDiff line change
@@ -2104,15 +2104,15 @@
21042104
+ ItemStack cursor = this.player.containerMenu.getCarried();
21052105
+ if (clickedItem.isEmpty()) {
21062106
+ if (!cursor.isEmpty()) {
2107-
+ if (cursor.getItem() instanceof net.minecraft.world.item.BundleItem && packet.getButtonNum() != 0) {
2107+
+ if (cursor.getItem() instanceof net.minecraft.world.item.BundleItem && cursor.has(DataComponents.BUNDLE_CONTENTS) && packet.getButtonNum() != 0) {
21082108
+ action = cursor.get(DataComponents.BUNDLE_CONTENTS).isEmpty() ? InventoryAction.NOTHING : InventoryAction.PLACE_FROM_BUNDLE;
21092109
+ } else {
21102110
+ action = packet.getButtonNum() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE;
21112111
+ }
21122112
+ }
21132113
+ } else if (slot.mayPickup(this.player)) {
21142114
+ if (cursor.isEmpty()) {
2115-
+ if (slot.getItem().getItem() instanceof net.minecraft.world.item.BundleItem && packet.getButtonNum() != 0) {
2115+
+ if (slot.getItem().getItem() instanceof net.minecraft.world.item.BundleItem && slot.getItem().has(DataComponents.BUNDLE_CONTENTS) && packet.getButtonNum() != 0) {
21162116
+ action = slot.getItem().get(DataComponents.BUNDLE_CONTENTS).isEmpty() ? InventoryAction.NOTHING : InventoryAction.PICKUP_FROM_BUNDLE;
21172117
+ } else {
21182118
+ action = packet.getButtonNum() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF;
@@ -2132,7 +2132,7 @@
21322132
+ action = InventoryAction.PLACE_SOME;
21332133
+ }
21342134
+ } else if (cursor.getCount() <= slot.getMaxStackSize()) {
2135-
+ if (cursor.getItem() instanceof net.minecraft.world.item.BundleItem && packet.getButtonNum() == 0) {
2135+
+ if (cursor.getItem() instanceof net.minecraft.world.item.BundleItem && cursor.has(DataComponents.BUNDLE_CONTENTS) && packet.getButtonNum() == 0) {
21362136
+ int toPickup = cursor.get(DataComponents.BUNDLE_CONTENTS).getMaxAmountToAdd(slot.getItem());
21372137
+ if (toPickup >= slot.getItem().getCount()) {
21382138
+ action = InventoryAction.PICKUP_ALL_INTO_BUNDLE;
@@ -2141,7 +2141,7 @@
21412141
+ } else {
21422142
+ action = InventoryAction.PICKUP_SOME_INTO_BUNDLE;
21432143
+ }
2144-
+ } else if (slot.getItem().getItem() instanceof net.minecraft.world.item.BundleItem && packet.getButtonNum() == 0) {
2144+
+ } else if (slot.getItem().getItem() instanceof net.minecraft.world.item.BundleItem && slot.getItem().has(DataComponents.BUNDLE_CONTENTS) && packet.getButtonNum() == 0) {
21452145
+ int toPickup = slot.getItem().get(DataComponents.BUNDLE_CONTENTS).getMaxAmountToAdd(cursor);
21462146
+ if (toPickup >= cursor.getCount()) {
21472147
+ action = InventoryAction.PLACE_ALL_INTO_BUNDLE;

0 commit comments

Comments
 (0)