Handles slot click. @param mode 0 = basic click, 1 = shift click, 2 = hotbar, 3 = pick block, 4 = drop, 5 = ?, 6 = double click
(int slotId, int clickedButton, int mode, EntityPlayer playerIn)
| 140 | * @param mode 0 = basic click, 1 = shift click, 2 = hotbar, 3 = pick block, 4 = drop, 5 = ?, 6 = double click |
| 141 | */ |
| 142 | public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer playerIn) |
| 143 | { |
| 144 | ItemStack itemstack = null; |
| 145 | InventoryPlayer inventoryplayer = playerIn.inventory; |
| 146 | |
| 147 | if (mode == 5) |
| 148 | { |
| 149 | int i = this.dragEvent; |
| 150 | this.dragEvent = getDragEvent(clickedButton); |
| 151 | |
| 152 | if ((i != 1 || this.dragEvent != 2) && i != this.dragEvent) |
| 153 | { |
| 154 | this.resetDrag(); |
| 155 | } |
| 156 | else if (inventoryplayer.getItemStack() == null) |
| 157 | { |
| 158 | this.resetDrag(); |
| 159 | } |
| 160 | else if (this.dragEvent == 0) |
| 161 | { |
| 162 | this.dragMode = extractDragMode(clickedButton); |
| 163 | |
| 164 | if (isValidDragMode(this.dragMode, playerIn)) |
| 165 | { |
| 166 | this.dragEvent = 1; |
| 167 | this.dragSlots.clear(); |
| 168 | } |
| 169 | else |
| 170 | { |
| 171 | this.resetDrag(); |
| 172 | } |
| 173 | } |
| 174 | else if (this.dragEvent == 1) |
| 175 | { |
| 176 | Slot slot = this.inventorySlots.get(slotId); |
| 177 | |
| 178 | if (slot != null && canAddItemToSlot(slot, inventoryplayer.getItemStack(), true) && slot.isItemValid(inventoryplayer.getItemStack()) && inventoryplayer.getItemStack().stackSize > this.dragSlots.size() && this.canDragIntoSlot(slot)) |
| 179 | { |
| 180 | this.dragSlots.add(slot); |
| 181 | } |
| 182 | } |
| 183 | else if (this.dragEvent == 2) |
| 184 | { |
| 185 | if (!this.dragSlots.isEmpty()) |
| 186 | { |
| 187 | ItemStack itemstack3 = inventoryplayer.getItemStack().copy(); |
| 188 | int j = inventoryplayer.getItemStack().stackSize; |
| 189 | |
| 190 | for (Slot slot1 : this.dragSlots) |
| 191 | { |
| 192 | if (slot1 != null && canAddItemToSlot(slot1, inventoryplayer.getItemStack(), true) && slot1.isItemValid(inventoryplayer.getItemStack()) && inventoryplayer.getItemStack().stackSize >= this.dragSlots.size() && this.canDragIntoSlot(slot1)) |
| 193 | { |
| 194 | ItemStack itemstack1 = itemstack3.copy(); |
| 195 | int k = slot1.getHasStack() ? slot1.getStack().stackSize : 0; |
| 196 | computeStackSize(this.dragSlots, this.dragMode, itemstack1, k); |
| 197 | |
| 198 | if (itemstack1.stackSize > itemstack1.getMaxStackSize()) |
| 199 | { |
no test coverage detected