Check if BUNDLE_CONTENTS is present in InventoryClickEvent (#12321)

This commit is contained in:
Tamion
2025-03-24 00:38:25 +01:00
committed by GitHub
parent 37b9ca1f90
commit 515e12ca2d

View File

@@ -2104,7 +2104,7 @@
+ ItemStack cursor = this.player.containerMenu.getCarried();
+ if (clickedItem.isEmpty()) {
+ if (!cursor.isEmpty()) {
+ if (cursor.getItem() instanceof net.minecraft.world.item.BundleItem && packet.getButtonNum() != 0) {
+ if (cursor.getItem() instanceof net.minecraft.world.item.BundleItem && cursor.has(DataComponents.BUNDLE_CONTENTS) && packet.getButtonNum() != 0) {
+ action = cursor.get(DataComponents.BUNDLE_CONTENTS).isEmpty() ? InventoryAction.NOTHING : InventoryAction.PLACE_FROM_BUNDLE;
+ } else {
+ action = packet.getButtonNum() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE;
@@ -2112,7 +2112,7 @@
+ }
+ } else if (slot.mayPickup(this.player)) {
+ if (cursor.isEmpty()) {
+ if (slot.getItem().getItem() instanceof net.minecraft.world.item.BundleItem && packet.getButtonNum() != 0) {
+ if (slot.getItem().getItem() instanceof net.minecraft.world.item.BundleItem && slot.getItem().has(DataComponents.BUNDLE_CONTENTS) && packet.getButtonNum() != 0) {
+ action = slot.getItem().get(DataComponents.BUNDLE_CONTENTS).isEmpty() ? InventoryAction.NOTHING : InventoryAction.PICKUP_FROM_BUNDLE;
+ } else {
+ action = packet.getButtonNum() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF;
@@ -2132,7 +2132,7 @@
+ action = InventoryAction.PLACE_SOME;
+ }
+ } else if (cursor.getCount() <= slot.getMaxStackSize()) {
+ if (cursor.getItem() instanceof net.minecraft.world.item.BundleItem && packet.getButtonNum() == 0) {
+ if (cursor.getItem() instanceof net.minecraft.world.item.BundleItem && cursor.has(DataComponents.BUNDLE_CONTENTS) && packet.getButtonNum() == 0) {
+ int toPickup = cursor.get(DataComponents.BUNDLE_CONTENTS).getMaxAmountToAdd(slot.getItem());
+ if (toPickup >= slot.getItem().getCount()) {
+ action = InventoryAction.PICKUP_ALL_INTO_BUNDLE;
@@ -2141,7 +2141,7 @@
+ } else {
+ action = InventoryAction.PICKUP_SOME_INTO_BUNDLE;
+ }
+ } else if (slot.getItem().getItem() instanceof net.minecraft.world.item.BundleItem && packet.getButtonNum() == 0) {
+ } else if (slot.getItem().getItem() instanceof net.minecraft.world.item.BundleItem && slot.getItem().has(DataComponents.BUNDLE_CONTENTS) && packet.getButtonNum() == 0) {
+ int toPickup = slot.getItem().get(DataComponents.BUNDLE_CONTENTS).getMaxAmountToAdd(cursor);
+ if (toPickup >= cursor.getCount()) {
+ action = InventoryAction.PLACE_ALL_INTO_BUNDLE;