public abstract class InventoryView extends Object
Note: If you implement this interface but fail to satisfy the expected contracts of certain methods, there's no guarantee that the game will work as it should.
Modifier and Type | Class and Description |
---|---|
static class |
InventoryView.Property
Represents various extra properties of certain inventory windows.
|
Modifier and Type | Field and Description |
---|---|
static int |
OUTSIDE |
Constructor and Description |
---|
InventoryView() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the inventory view.
|
int |
convertSlot(int rawSlot)
Converts a raw slot ID into its local slot ID into whichever of the two
inventories the slot points to.
|
int |
countSlots()
Check the total number of slots in this view, combining the upper and
lower inventories.
|
abstract Inventory |
getBottomInventory()
Get the lower inventory involved in this transaction.
|
ItemStack |
getCursor()
Get the item on the cursor of one of the viewing players.
|
ItemStack |
getItem(int slot)
Gets one item in this inventory view by its raw slot ID.
|
abstract HumanEntity |
getPlayer()
Get the player viewing.
|
String |
getTitle()
Get the title of this inventory window.
|
abstract Inventory |
getTopInventory()
Get the upper inventory involved in this transaction.
|
abstract InventoryType |
getType()
Determine the type of inventory involved in the transaction.
|
void |
setCursor(ItemStack item)
Sets the item on the cursor of one of the viewing players.
|
void |
setItem(int slot,
ItemStack item)
Sets one item in this inventory view by its raw slot ID.
|
boolean |
setProperty(InventoryView.Property prop,
int value)
Sets an extra property of this inventory if supported by that
inventory, for example the state of a progress bar.
|
public static final int OUTSIDE
public abstract Inventory getTopInventory()
public abstract Inventory getBottomInventory()
public abstract HumanEntity getPlayer()
public abstract InventoryType getType()
public void setItem(int slot, ItemStack item)
Note: If slot ID -999 is chosen, it may be expected that the item is dropped on the ground. This is not required behaviour, however.
slot
- The ID as returned by InventoryClickEvent.getRawSlot()item
- The new item to put in the slot, or null to clear it.public ItemStack getItem(int slot)
slot
- The ID as returned by InventoryClickEvent.getRawSlot()public final void setCursor(ItemStack item)
item
- The item to put on the cursor, or null to remove the item
on their cursor.public final ItemStack getCursor()
public final int convertSlot(int rawSlot)
If the raw slot refers to the upper inventory, it will be returned unchanged and thus be suitable for getTopInventory().getItem(); if it refers to the lower inventory, the output will differ from the input and be suitable for getBottomInventory().getItem().
rawSlot
- The raw slot ID.public final void close()
public final int countSlots()
Note though that it's possible for this to be greater than the sum of the two inventories if for example some slots are not being used.
public final boolean setProperty(InventoryView.Property prop, int value)
prop
- the window property to updatevalue
- the new value for the window propertypublic final String getTitle()
Copyright © 2015. All rights reserved.