mirror of
https://github.com/GTNewHorizons/bdlib.git
synced 2026-11-13 16:54:11 +00:00
Added a slot trait that intercepts clicks
This commit is contained in:
1 parent
041f570109
commit
3b31e285d2
3 files changed
+28
-1
No files matched your search
+1
-1
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user