Compare commits

...
2 Commits
Author SHA1 Message Date
bdew 3b31e285d2 Added a slot trait that intercepts clicks 2013-12-31 12:35:34 +02:00
bdew 041f570109 Fixed crash on dedicated servers 2013-12-24 10:25:13 +02:00
4 changed files with 32 additions and 7 deletions

No files matched your search

+1 -1
View File
@@ -14,7 +14,7 @@ buildscript {
apply plugin: 'forge'
apply plugin: 'scala'
version = "0.9.3"
version = "0.9.5"
if (project.hasProperty('buildnum')) {
project.version = project.version + '.' + project.buildnum
+9
View File
@@ -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) {
+4 -6
View File
@@ -11,8 +11,6 @@ package net.bdew.lib.gui
import net.minecraft.tileentity.TileEntity
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.client.gui.inventory.GuiContainer
import net.minecraft.inventory.Container
import cpw.mods.fml.relauncher.{Side, SideOnly}
trait GuiProvider {
@@ -21,10 +19,10 @@ trait GuiProvider {
type TEClass
@SideOnly(Side.CLIENT)
def getGui(te: TEClass, player: EntityPlayer): GuiContainer
def getContainer(te: TEClass, player: EntityPlayer): Container
def getGui(te: TEClass, player: EntityPlayer): AnyRef
def getContainer(te: TEClass, player: EntityPlayer): AnyRef
@SideOnly(Side.CLIENT)
def getGui(te: TileEntity, player: EntityPlayer): GuiContainer = getGui(te.asInstanceOf[TEClass], player)
def getContainer(te: TileEntity, player: EntityPlayer): Container = getContainer(te.asInstanceOf[TEClass], player)
def getGui(te: TileEntity, player: EntityPlayer): AnyRef = getGui(te.asInstanceOf[TEClass], player)
def getContainer(te: TileEntity, player: EntityPlayer): AnyRef = getContainer(te.asInstanceOf[TEClass], player)
}
+18
View File
@@ -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
}