net.minecraft.inventory
Class Slot

java.lang.Object
  extended by net.minecraft.inventory.Slot
Direct Known Subclasses:
SlotCrafting, SlotFurnace, SlotMerchantResult

public class Slot
extends Object


Field Summary
 IInventory inventory
          The inventory we want to extract a slot from.
 int slotNumber
          the id of the slot(also the index in the inventory arraylist)
 int xDisplayPosition
          display position of the inventory slot on the screen x axis
 int yDisplayPosition
          display position of the inventory slot on the screen y axis
 
Constructor Summary
Slot(IInventory par1IInventory, int par2, int par3, int par4)
           
 
Method Summary
 boolean canTakeStack(EntityPlayer par1EntityPlayer)
          Return whether this slot's stack can be taken from this slot.
 ItemStack decrStackSize(int par1)
          Decrease the size of the stack in slot (first int arg) by the amount of the second int arg.
 int getBackgroundIconIndex()
           
 String getBackgroundIconTexture()
          Gets the path of the texture file to use for the background image of this slot when drawing the GUI.
 boolean getHasStack()
          Returns if this slot contains a stack.
 int getSlotIndex()
          Retrieves the index in the inventory for this slot, this value should typically not be used, but can be useful for some occasions.
 int getSlotStackLimit()
          Returns the maximum stack size for a given slot (usually the same as getInventoryStackLimit(), but 1 in the case of armor slots)
 ItemStack getStack()
          Helper fnct to get the stack in the slot.
 boolean isItemValid(ItemStack par1ItemStack)
          Check if the stack is a valid item for this slot.
 boolean isSlotInInventory(IInventory par1IInventory, int par2)
          returns true if this slot is in par2 of par1
 void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
           
 void onSlotChange(ItemStack par1ItemStack, ItemStack par2ItemStack)
          if par2 has more items than par1, onCrafting(item,countIncrease) is called
 void onSlotChanged()
          Called when the stack in a Slot changes
 void putStack(ItemStack par1ItemStack)
          Helper method to put a stack in the slot.
 void setBackgroundIconIndex(int iconIndex)
          Sets which icon index to use as the background image of the slot when it's empty.
 void setBackgroundIconTexture(String textureFilename)
          Sets the texture file to use for the background image of the slot when it's empty.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inventory

public final IInventory inventory
The inventory we want to extract a slot from.


slotNumber

public int slotNumber
the id of the slot(also the index in the inventory arraylist)


xDisplayPosition

public int xDisplayPosition
display position of the inventory slot on the screen x axis


yDisplayPosition

public int yDisplayPosition
display position of the inventory slot on the screen y axis

Constructor Detail

Slot

public Slot(IInventory par1IInventory,
            int par2,
            int par3,
            int par4)
Method Detail

onSlotChange

public void onSlotChange(ItemStack par1ItemStack,
                         ItemStack par2ItemStack)
if par2 has more items than par1, onCrafting(item,countIncrease) is called


onPickupFromSlot

public void onPickupFromSlot(EntityPlayer par1EntityPlayer,
                             ItemStack par2ItemStack)

isItemValid

public boolean isItemValid(ItemStack par1ItemStack)
Check if the stack is a valid item for this slot. Always true beside for the armor slots.


getStack

public ItemStack getStack()
Helper fnct to get the stack in the slot.


getHasStack

public boolean getHasStack()
Returns if this slot contains a stack.


putStack

public void putStack(ItemStack par1ItemStack)
Helper method to put a stack in the slot.


onSlotChanged

public void onSlotChanged()
Called when the stack in a Slot changes


getSlotStackLimit

public int getSlotStackLimit()
Returns the maximum stack size for a given slot (usually the same as getInventoryStackLimit(), but 1 in the case of armor slots)


decrStackSize

public ItemStack decrStackSize(int par1)
Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new stack.


isSlotInInventory

public boolean isSlotInInventory(IInventory par1IInventory,
                                 int par2)
returns true if this slot is in par2 of par1


canTakeStack

public boolean canTakeStack(EntityPlayer par1EntityPlayer)
Return whether this slot's stack can be taken from this slot.


getBackgroundIconIndex

public int getBackgroundIconIndex()

getBackgroundIconTexture

public String getBackgroundIconTexture()
Gets the path of the texture file to use for the background image of this slot when drawing the GUI.

Returns:
String: The texture file that will be used in GuiContainer.drawSlotInventory for the slot background.

setBackgroundIconIndex

public void setBackgroundIconIndex(int iconIndex)
Sets which icon index to use as the background image of the slot when it's empty.

Parameters:
iconIndex - int: The index into the texture file, 0-255, or -1 for no background.

setBackgroundIconTexture

public void setBackgroundIconTexture(String textureFilename)
Sets the texture file to use for the background image of the slot when it's empty.

Parameters:
textureFilename - String: Path of texture file to use, or null to use "/gui/items.png"

getSlotIndex

public int getSlotIndex()
Retrieves the index in the inventory for this slot, this value should typically not be used, but can be useful for some occasions.

Returns:
Index in associated inventory for this slot.