Fix filter slot shift clicking behavior

This commit is contained in:
Shadowfacts 2017-07-02 13:40:30 -04:00
parent 34e9671eb0
commit c2e96e62c0
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
2 changed files with 38 additions and 3 deletions

View File

@ -51,11 +51,40 @@ class ContainerInventoryHopper(val hopper: TileEntityInventoryHopper, playerInv:
return super.slotClick(id, dragType, type, player) return super.slotClick(id, dragType, type, player)
} }
override fun transferStackInSlot(player: EntityPlayer, index: Int): ItemStack { override fun transferStackInSlot(player: EntityPlayer?, index: Int): ItemStack {
if (index in hopper.inventory.slots..hopper.inventory.slots + 5) { // if the slot is a filter slot if (index in hopper.inventory.slots..hopper.inventory.slots + 5) { // if the slot is a filter slot
return ItemStack.EMPTY return ItemStack.EMPTY
} }
return super.transferStackInSlot(player, index)
var itemstack = ItemStack.EMPTY
val slot = inventorySlots[index]
if (slot != null && slot.hasStack) {
val itemstack1 = slot.stack
itemstack = itemstack1.copy()
if (index < hopper.inventory.slots) {
if (!this.mergeItemStack(itemstack1, hopper.inventory.slots + 6, inventorySlots.size, true)) {
return ItemStack.EMPTY
}
} else if (!this.mergeItemStack(itemstack1, 0, hopper.inventory.slots, false)) {
return ItemStack.EMPTY
}
if (itemstack1.count == 0) {
slot.putStack(ItemStack.EMPTY)
} else {
slot.onSlotChanged()
}
if (itemstack1.count == itemstack.count) {
return ItemStack.EMPTY
}
slot.onTake(player, itemstack1)
}
return itemstack
} }
private class SlotHopper(val hopper: TileEntityInventoryHopper, index: Int, x: Int, y: Int): SlotItemHandler(hopper.inventory, index, x, y) { private class SlotHopper(val hopper: TileEntityInventoryHopper, index: Int, x: Int, y: Int): SlotItemHandler(hopper.inventory, index, x, y) {

View File

@ -7,4 +7,10 @@ import net.shadowfacts.extrahoppers.util.filter.ItemFilter
/** /**
* @author shadowfacts * @author shadowfacts
*/ */
class SlotItemFilter(hopper: TileEntityInventoryHopper, id: Int, x: Int, y: Int): SlotItemHandler((hopper.filter as ItemFilter).inventory, id, x, y) class SlotItemFilter(val hopper: TileEntityInventoryHopper, id: Int, x: Int, y: Int): SlotItemHandler((hopper.filter as ItemFilter).inventory, id, x, y) {
override fun onSlotChanged() {
hopper.markDirty()
}
}