Fixed crash when moving a wireless item with the number keys. Fixes #1766

This commit is contained in:
raoulvdberge
2018-06-26 23:56:39 +02:00
parent f69feacd68
commit 89b7d2bfc8
2 changed files with 8 additions and 1 deletions

View File

@@ -49,7 +49,7 @@ public abstract class ContainerBase extends Container {
int x = xInventory + i * 18;
int y = yInventory + 4 + (3 * 18);
if (i == player.inventory.currentItem && isHeldItemDisabled()) {
if (isHeldItemDisabled() && i == player.inventory.currentItem) {
addSlotToContainer(new SlotDisabled(player.inventory, id, x, y));
} else {
addSlotToContainer(new Slot(player.inventory, id, x, y));
@@ -71,6 +71,12 @@ public abstract class ContainerBase extends Container {
public ItemStack slotClick(int id, int dragType, ClickType clickType, EntityPlayer player) {
Slot slot = id >= 0 ? getSlot(id) : null;
// Prevent swapping disabled held item with the number keys
// (dragType is the slot we're swapping with)
if (isHeldItemDisabled() && clickType == ClickType.SWAP && dragType == player.inventory.currentItem) {
return ItemStack.EMPTY;
}
if (slot instanceof SlotFilter) {
if (slot.getStack().getItem() == RSItems.FILTER) {
return super.slotClick(id, dragType, clickType, player);