Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 04:20:08 +01:00
SPIGOT-2795: InventoryClickEvent issues
Dieser Commit ist enthalten in:
Ursprung
26377b763b
Commit
32048c4690
@ -1154,7 +1154,7 @@
|
|||||||
+ if (packetplayinwindowclick.c() == 0 || packetplayinwindowclick.c() == 1) {
|
+ if (packetplayinwindowclick.c() == 0 || packetplayinwindowclick.c() == 1) {
|
||||||
+ action = InventoryAction.NOTHING; // Don't want to repeat ourselves
|
+ action = InventoryAction.NOTHING; // Don't want to repeat ourselves
|
||||||
+ if (packetplayinwindowclick.b() == -999) {
|
+ if (packetplayinwindowclick.b() == -999) {
|
||||||
+ if (player.inventory.getCarried() != null) {
|
+ if (!player.inventory.getCarried().isEmpty()) {
|
||||||
+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR;
|
+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR;
|
||||||
+ }
|
+ }
|
||||||
+ } else if (packetplayinwindowclick.b() < 0) {
|
+ } else if (packetplayinwindowclick.b() < 0) {
|
||||||
@ -1164,12 +1164,12 @@
|
|||||||
+ if (slot != null) {
|
+ if (slot != null) {
|
||||||
+ ItemStack clickedItem = slot.getItem();
|
+ ItemStack clickedItem = slot.getItem();
|
||||||
+ ItemStack cursor = player.inventory.getCarried();
|
+ ItemStack cursor = player.inventory.getCarried();
|
||||||
+ if (clickedItem == null) {
|
+ if (clickedItem.isEmpty()) {
|
||||||
+ if (cursor != null) {
|
+ if (!cursor.isEmpty()) {
|
||||||
+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE;
|
+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE;
|
||||||
+ }
|
+ }
|
||||||
+ } else if (slot.isAllowed(player)) {
|
+ } else if (slot.isAllowed(player)) {
|
||||||
+ if (cursor == null) {
|
+ if (cursor.isEmpty()) {
|
||||||
+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF;
|
+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF;
|
||||||
+ } else if (slot.isAllowed(cursor)) {
|
+ } else if (slot.isAllowed(cursor)) {
|
||||||
+ if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) {
|
+ if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) {
|
||||||
@ -1227,7 +1227,7 @@
|
|||||||
+ Slot clickedSlot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
+ Slot clickedSlot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
||||||
+ if (clickedSlot.isAllowed(player)) {
|
+ if (clickedSlot.isAllowed(player)) {
|
||||||
+ ItemStack hotbar = this.player.inventory.getItem(packetplayinwindowclick.c());
|
+ ItemStack hotbar = this.player.inventory.getItem(packetplayinwindowclick.c());
|
||||||
+ boolean canCleanSwap = hotbar == null || (clickedSlot.inventory == player.inventory && clickedSlot.isAllowed(hotbar)); // the slot will accept the hotbar item
|
+ boolean canCleanSwap = hotbar.isEmpty() || (clickedSlot.inventory == player.inventory && clickedSlot.isAllowed(hotbar)); // the slot will accept the hotbar item
|
||||||
+ if (clickedSlot.hasItem()) {
|
+ if (clickedSlot.hasItem()) {
|
||||||
+ if (canCleanSwap) {
|
+ if (canCleanSwap) {
|
||||||
+ action = InventoryAction.HOTBAR_SWAP;
|
+ action = InventoryAction.HOTBAR_SWAP;
|
||||||
@ -1239,7 +1239,7 @@
|
|||||||
+ action = InventoryAction.NOTHING; // This is not sane! Mojang: You should test for other slots of same type
|
+ action = InventoryAction.NOTHING; // This is not sane! Mojang: You should test for other slots of same type
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ } else if (!clickedSlot.hasItem() && hotbar != null && clickedSlot.isAllowed(hotbar)) {
|
+ } else if (!clickedSlot.hasItem() && !hotbar.isEmpty() && clickedSlot.isAllowed(hotbar)) {
|
||||||
+ action = InventoryAction.HOTBAR_SWAP;
|
+ action = InventoryAction.HOTBAR_SWAP;
|
||||||
+ } else {
|
+ } else {
|
||||||
+ action = InventoryAction.NOTHING;
|
+ action = InventoryAction.NOTHING;
|
||||||
@ -1256,7 +1256,7 @@
|
|||||||
+ action = InventoryAction.NOTHING;
|
+ action = InventoryAction.NOTHING;
|
||||||
+ } else {
|
+ } else {
|
||||||
+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
||||||
+ if (slot != null && slot.hasItem() && player.abilities.canInstantlyBuild && player.inventory.getCarried() == null) {
|
+ if (slot != null && slot.hasItem() && player.abilities.canInstantlyBuild && player.inventory.getCarried().isEmpty()) {
|
||||||
+ action = InventoryAction.CLONE_STACK;
|
+ action = InventoryAction.CLONE_STACK;
|
||||||
+ } else {
|
+ } else {
|
||||||
+ action = InventoryAction.NOTHING;
|
+ action = InventoryAction.NOTHING;
|
||||||
@ -1272,7 +1272,7 @@
|
|||||||
+ if (packetplayinwindowclick.c() == 0) {
|
+ if (packetplayinwindowclick.c() == 0) {
|
||||||
+ click = ClickType.DROP;
|
+ click = ClickType.DROP;
|
||||||
+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
||||||
+ if (slot != null && slot.hasItem() && slot.isAllowed(player) && slot.getItem() != null && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
|
+ if (slot != null && slot.hasItem() && slot.isAllowed(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
|
||||||
+ action = InventoryAction.DROP_ONE_SLOT;
|
+ action = InventoryAction.DROP_ONE_SLOT;
|
||||||
+ } else {
|
+ } else {
|
||||||
+ action = InventoryAction.NOTHING;
|
+ action = InventoryAction.NOTHING;
|
||||||
@ -1280,7 +1280,7 @@
|
|||||||
+ } else if (packetplayinwindowclick.c() == 1) {
|
+ } else if (packetplayinwindowclick.c() == 1) {
|
||||||
+ click = ClickType.CONTROL_DROP;
|
+ click = ClickType.CONTROL_DROP;
|
||||||
+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
||||||
+ if (slot != null && slot.hasItem() && slot.isAllowed(player) && slot.getItem() != null && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
|
+ if (slot != null && slot.hasItem() && slot.isAllowed(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
|
||||||
+ action = InventoryAction.DROP_ALL_SLOT;
|
+ action = InventoryAction.DROP_ALL_SLOT;
|
||||||
+ } else {
|
+ } else {
|
||||||
+ action = InventoryAction.NOTHING;
|
+ action = InventoryAction.NOTHING;
|
||||||
@ -1301,7 +1301,7 @@
|
|||||||
+ case PICKUP_ALL:
|
+ case PICKUP_ALL:
|
||||||
+ click = ClickType.DOUBLE_CLICK;
|
+ click = ClickType.DOUBLE_CLICK;
|
||||||
+ action = InventoryAction.NOTHING;
|
+ action = InventoryAction.NOTHING;
|
||||||
+ if (packetplayinwindowclick.b() >= 0 && this.player.inventory.getCarried() != null) {
|
+ if (packetplayinwindowclick.b() >= 0 && !this.player.inventory.getCarried().isEmpty()) {
|
||||||
+ ItemStack cursor = this.player.inventory.getCarried();
|
+ ItemStack cursor = this.player.inventory.getCarried();
|
||||||
+ action = InventoryAction.NOTHING;
|
+ action = InventoryAction.NOTHING;
|
||||||
+ // Quick check for if we have any of the item
|
+ // Quick check for if we have any of the item
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren