mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 15:17:17 +01:00
update
This commit is contained in:
parent
1958431988
commit
98019d9bf3
2 changed files with 7 additions and 23 deletions
|
@ -5,18 +5,10 @@ Subject: [PATCH] Fix InventoryAction wrong for Bundles
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/event/inventory/InventoryAction.java b/src/main/java/org/bukkit/event/inventory/InventoryAction.java
|
diff --git a/src/main/java/org/bukkit/event/inventory/InventoryAction.java b/src/main/java/org/bukkit/event/inventory/InventoryAction.java
|
||||||
index b2bcc891196d487cf4c1962b51ec439e921f49f6..22224c71f628808bff25c2b0868973f9c05bd7c2 100644
|
index b2bcc891196d487cf4c1962b51ec439e921f49f6..f5abc15444e0d6b50e3a82d0a452fc237be155a0 100644
|
||||||
--- a/src/main/java/org/bukkit/event/inventory/InventoryAction.java
|
--- a/src/main/java/org/bukkit/event/inventory/InventoryAction.java
|
||||||
+++ b/src/main/java/org/bukkit/event/inventory/InventoryAction.java
|
+++ b/src/main/java/org/bukkit/event/inventory/InventoryAction.java
|
||||||
@@ -1,5 +1,7 @@
|
@@ -93,5 +93,38 @@ public enum InventoryAction {
|
||||||
package org.bukkit.event.inventory;
|
|
||||||
|
|
||||||
+import org.jetbrains.annotations.ApiStatus; // Paper - Fix InventoryAction wrong for Bundles
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* An estimation of what the result will be.
|
|
||||||
*/
|
|
||||||
@@ -93,5 +95,46 @@ public enum InventoryAction {
|
|
||||||
* An unrecognized ClickType.
|
* An unrecognized ClickType.
|
||||||
*/
|
*/
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
|
@ -25,42 +17,34 @@ index b2bcc891196d487cf4c1962b51ec439e921f49f6..22224c71f628808bff25c2b0868973f9
|
||||||
+ /**
|
+ /**
|
||||||
+ * The first stack of items in the clicked bundle is moved to the cursor.
|
+ * The first stack of items in the clicked bundle is moved to the cursor.
|
||||||
+ */
|
+ */
|
||||||
+ @ApiStatus.Internal
|
|
||||||
+ PICKUP_FROM_BUNDLE,
|
+ PICKUP_FROM_BUNDLE,
|
||||||
+ /**
|
+ /**
|
||||||
+ * All of the items on the clicked slot are moved into the bundle on the cursor.
|
+ * All of the items on the clicked slot are moved into the bundle on the cursor.
|
||||||
+ */
|
+ */
|
||||||
+ @ApiStatus.Internal
|
|
||||||
+ PICKUP_ALL_INTO_BUNDLE,
|
+ PICKUP_ALL_INTO_BUNDLE,
|
||||||
+ /**
|
+ /**
|
||||||
+ * Some of the items on the clicked slot are moved into the bundle on the cursor.
|
+ * Some of the items on the clicked slot are moved into the bundle on the cursor.
|
||||||
+ */
|
+ */
|
||||||
+ @ApiStatus.Internal
|
|
||||||
+ PICKUP_SOME_INTO_BUNDLE,
|
+ PICKUP_SOME_INTO_BUNDLE,
|
||||||
+ /**
|
+ /**
|
||||||
+ * One of the items on the clicked slot is moved into the bundle on the cursor.
|
+ * One of the items on the clicked slot is moved into the bundle on the cursor.
|
||||||
+ */
|
+ */
|
||||||
+ @ApiStatus.Internal
|
|
||||||
+ PICKUP_ONE_INTO_BUNDLE,
|
+ PICKUP_ONE_INTO_BUNDLE,
|
||||||
+ /**
|
+ /**
|
||||||
+ * The first stack of items is moved to the clicked slot.
|
+ * The first stack of items is moved to the clicked slot.
|
||||||
+ */
|
+ */
|
||||||
+ @ApiStatus.Internal
|
|
||||||
+ PLACE_FROM_BUNDLE,
|
+ PLACE_FROM_BUNDLE,
|
||||||
+ /**
|
+ /**
|
||||||
+ * All of the items on the cursor are moved into the bundle in the clicked slot.
|
+ * All of the items on the cursor are moved into the bundle in the clicked slot.
|
||||||
+ */
|
+ */
|
||||||
+ @ApiStatus.Internal
|
|
||||||
+ PLACE_ALL_INTO_BUNDLE,
|
+ PLACE_ALL_INTO_BUNDLE,
|
||||||
+ /**
|
+ /**
|
||||||
+ * Some of the items on the cursor are moved into the bundle in the clicked slot.
|
+ * Some of the items on the cursor are moved into the bundle in the clicked slot.
|
||||||
+ */
|
+ */
|
||||||
+ @ApiStatus.Internal
|
|
||||||
+ PLACE_SOME_INTO_BUNDLE,
|
+ PLACE_SOME_INTO_BUNDLE,
|
||||||
+ /**
|
+ /**
|
||||||
+ * One of the items on the cursor is moved into the bundle in the clicked slot.
|
+ * One of the items on the cursor is moved into the bundle in the clicked slot.
|
||||||
+ */
|
+ */
|
||||||
+ @ApiStatus.Internal
|
|
||||||
+ PLACE_ONE_INTO_BUNDLE,
|
+ PLACE_ONE_INTO_BUNDLE,
|
||||||
+ // Paper end - Fix InventoryAction wrong for Bundles
|
+ // Paper end - Fix InventoryAction wrong for Bundles
|
||||||
}
|
}
|
|
@ -7,10 +7,10 @@ Subject: [PATCH] Fix InventoryAction wrong for Bundles
|
||||||
public net/minecraft/world/item/component/BundleContents$Mutable getMaxAmountToAdd(Lnet/minecraft/world/item/ItemStack;)I;
|
public net/minecraft/world/item/component/BundleContents$Mutable getMaxAmountToAdd(Lnet/minecraft/world/item/ItemStack;)I;
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
index b13057c0792067cc6b0abdf0d64a9be2cc9389a4..8762e480f439598ab54e8621ac8a0358dfecfc14 100644
|
index b5d5dbc50a7b8c40739a15f164ffd08fdc534f9c..4f4e3a027a1e67a0c93413c91afd525738c95056 100644
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
@@ -3003,11 +3003,23 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
@@ -3041,11 +3041,23 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
ItemStack cursor = this.player.containerMenu.getCarried();
|
ItemStack cursor = this.player.containerMenu.getCarried();
|
||||||
if (clickedItem.isEmpty()) {
|
if (clickedItem.isEmpty()) {
|
||||||
if (!cursor.isEmpty()) {
|
if (!cursor.isEmpty()) {
|
||||||
|
@ -36,13 +36,13 @@ index b13057c0792067cc6b0abdf0d64a9be2cc9389a4..8762e480f439598ab54e8621ac8a0358
|
||||||
} else if (slot.mayPlace(cursor)) {
|
} else if (slot.mayPlace(cursor)) {
|
||||||
if (ItemStack.isSameItemSameComponents(clickedItem, cursor)) {
|
if (ItemStack.isSameItemSameComponents(clickedItem, cursor)) {
|
||||||
int toPlace = packet.getButtonNum() == 0 ? cursor.getCount() : 1;
|
int toPlace = packet.getButtonNum() == 0 ? cursor.getCount() : 1;
|
||||||
@@ -3023,7 +3035,34 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
@@ -3061,7 +3073,34 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
action = InventoryAction.PLACE_SOME;
|
action = InventoryAction.PLACE_SOME;
|
||||||
}
|
}
|
||||||
} else if (cursor.getCount() <= slot.getMaxStackSize()) {
|
} else if (cursor.getCount() <= slot.getMaxStackSize()) {
|
||||||
- action = InventoryAction.SWAP_WITH_CURSOR;
|
- action = InventoryAction.SWAP_WITH_CURSOR;
|
||||||
+ // Paper start - Fix InventoryAction wrong for Bundles
|
+ // Paper start - Fix InventoryAction wrong for Bundles
|
||||||
+ if (cursor.is(Items.BUNDLE) && packet.getButtonNum() != 0) {
|
+ if (cursor.is(Items.BUNDLE) && packet.getButtonNum() == 0) {
|
||||||
+ int toPickup = new net.minecraft.world.item.component.BundleContents.Mutable(cursor.get(DataComponents.BUNDLE_CONTENTS)).getMaxAmountToAdd(slot.getItem());
|
+ int toPickup = new net.minecraft.world.item.component.BundleContents.Mutable(cursor.get(DataComponents.BUNDLE_CONTENTS)).getMaxAmountToAdd(slot.getItem());
|
||||||
+ if (toPickup >= slot.getItem().getCount()) {
|
+ if (toPickup >= slot.getItem().getCount()) {
|
||||||
+ action = InventoryAction.PICKUP_ALL_INTO_BUNDLE;
|
+ action = InventoryAction.PICKUP_ALL_INTO_BUNDLE;
|
||||||
|
@ -53,7 +53,7 @@ index b13057c0792067cc6b0abdf0d64a9be2cc9389a4..8762e480f439598ab54e8621ac8a0358
|
||||||
+ } else {
|
+ } else {
|
||||||
+ action = InventoryAction.PICKUP_SOME_INTO_BUNDLE;
|
+ action = InventoryAction.PICKUP_SOME_INTO_BUNDLE;
|
||||||
+ }
|
+ }
|
||||||
+ } else if (slot.getItem().is(Items.BUNDLE) && packet.getButtonNum() != 0) {
|
+ } else if (slot.getItem().is(Items.BUNDLE) && packet.getButtonNum() == 0) {
|
||||||
+ int toPickup = new net.minecraft.world.item.component.BundleContents.Mutable(slot.getItem().get(DataComponents.BUNDLE_CONTENTS)).getMaxAmountToAdd(cursor);
|
+ int toPickup = new net.minecraft.world.item.component.BundleContents.Mutable(slot.getItem().get(DataComponents.BUNDLE_CONTENTS)).getMaxAmountToAdd(cursor);
|
||||||
+ if (toPickup >= cursor.getCount()) {
|
+ if (toPickup >= cursor.getCount()) {
|
||||||
+ action = InventoryAction.PLACE_ALL_INTO_BUNDLE;
|
+ action = InventoryAction.PLACE_ALL_INTO_BUNDLE;
|
Loading…
Reference in a new issue