mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-24 01:47:42 +01:00
SPIGOT-2795: InventoryClickEvent issues
This commit is contained in:
parent
26377b763b
commit
32048c4690
@ -1154,7 +1154,7 @@
|
||||
+ if (packetplayinwindowclick.c() == 0 || packetplayinwindowclick.c() == 1) {
|
||||
+ action = InventoryAction.NOTHING; // Don't want to repeat ourselves
|
||||
+ 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;
|
||||
+ }
|
||||
+ } else if (packetplayinwindowclick.b() < 0) {
|
||||
@ -1164,12 +1164,12 @@
|
||||
+ if (slot != null) {
|
||||
+ ItemStack clickedItem = slot.getItem();
|
||||
+ ItemStack cursor = player.inventory.getCarried();
|
||||
+ if (clickedItem == null) {
|
||||
+ if (cursor != null) {
|
||||
+ if (clickedItem.isEmpty()) {
|
||||
+ if (!cursor.isEmpty()) {
|
||||
+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE;
|
||||
+ }
|
||||
+ } else if (slot.isAllowed(player)) {
|
||||
+ if (cursor == null) {
|
||||
+ if (cursor.isEmpty()) {
|
||||
+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF;
|
||||
+ } else if (slot.isAllowed(cursor)) {
|
||||
+ if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) {
|
||||
@ -1227,7 +1227,7 @@
|
||||
+ Slot clickedSlot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
|
||||
+ if (clickedSlot.isAllowed(player)) {
|
||||
+ 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 (canCleanSwap) {
|
||||
+ 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
|
||||
+ }
|
||||
+ }
|
||||
+ } else if (!clickedSlot.hasItem() && hotbar != null && clickedSlot.isAllowed(hotbar)) {
|
||||
+ } else if (!clickedSlot.hasItem() && !hotbar.isEmpty() && clickedSlot.isAllowed(hotbar)) {
|
||||
+ action = InventoryAction.HOTBAR_SWAP;
|
||||
+ } else {
|
||||
+ action = InventoryAction.NOTHING;
|
||||
@ -1256,7 +1256,7 @@
|
||||
+ action = InventoryAction.NOTHING;
|
||||
+ } else {
|
||||
+ 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;
|
||||
+ } else {
|
||||
+ action = InventoryAction.NOTHING;
|
||||
@ -1272,7 +1272,7 @@
|
||||
+ if (packetplayinwindowclick.c() == 0) {
|
||||
+ click = ClickType.DROP;
|
||||
+ 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;
|
||||
+ } else {
|
||||
+ action = InventoryAction.NOTHING;
|
||||
@ -1280,7 +1280,7 @@
|
||||
+ } else if (packetplayinwindowclick.c() == 1) {
|
||||
+ click = ClickType.CONTROL_DROP;
|
||||
+ 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;
|
||||
+ } else {
|
||||
+ action = InventoryAction.NOTHING;
|
||||
@ -1301,7 +1301,7 @@
|
||||
+ case PICKUP_ALL:
|
||||
+ click = ClickType.DOUBLE_CLICK;
|
||||
+ 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();
|
||||
+ action = InventoryAction.NOTHING;
|
||||
+ // Quick check for if we have any of the item
|
||||
|
Loading…
Reference in New Issue
Block a user