diff --git a/build.gradle b/build.gradle index 38cba6c..acd0743 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { apply plugin: 'forge' apply plugin: 'scala' -version = "0.9.4" +version = "0.9.5" if (project.hasProperty('buildnum')) { project.version = project.version + '.' + project.buildnum diff --git a/src/net/bdew/lib/gui/BaseContainer.scala b/src/net/bdew/lib/gui/BaseContainer.scala index 85becfe..a12005d 100644 --- a/src/net/bdew/lib/gui/BaseContainer.scala +++ b/src/net/bdew/lib/gui/BaseContainer.scala @@ -29,6 +29,15 @@ abstract class BaseContainer(te: IInventory) extends Container { addSlotToContainer(new Slot(inv, i, xOffs + i * 18, yOffsHotbar)) } + override def slotClick(slotnum: Int, button: Int, modifiers: Int, player: EntityPlayer): ItemStack = { + if (inventorySlots.isDefinedAt(slotnum)) { + val slot = getSlot(slotnum) + if (slot != null && slot.isInstanceOf[SlotClickable]) + return slot.asInstanceOf[SlotClickable].onClick(button, modifiers, player) + } + return super.slotClick(slotnum, button, modifiers, player) + } + override def transferStackInSlot(player: EntityPlayer, slot: Int): ItemStack = { var stack = getSlot(slot).getStack if (getSlot(slot).inventory == player.inventory) { diff --git a/src/net/bdew/lib/gui/SlotClickable.scala b/src/net/bdew/lib/gui/SlotClickable.scala new file mode 100644 index 0000000..de097ca --- /dev/null +++ b/src/net/bdew/lib/gui/SlotClickable.scala @@ -0,0 +1,18 @@ +/* + * Copyright (c) bdew, 2013 + * https://github.com/bdew/bdlib + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/bdlib/master/MMPL-1.0.txt + */ + +package net.bdew.lib.gui + +import net.minecraft.item.ItemStack +import net.minecraft.inventory.Slot +import net.minecraft.entity.player.EntityPlayer + +trait SlotClickable extends Slot { + def onClick(button: Int, mods: Int, player: EntityPlayer): ItemStack +}