Импорт класса

Link to импорт-класса

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

ZenScript
Copy
import crafttweaker.api.inventory.PlayerInventory;

Implemented Interfaces

Link to implemented-interfaces

PlayerInventory implements the following interfaces. That means all methods defined in these interfaces are also available in PlayerInventory

Name: add

Adds the stack to the given slot in the player's inventory.

Returns: True if the stack was inserted. False otherwise.
Return Type: boolean

ZenScript
Copy
PlayerInventory.add(slot as int, stack as IItemStack) as boolean
ПараметрТипОписание
Параметр
slot
Тип
int
Описание
The slot to put the stack.
Параметр
stack
Тип
IItemStack
Описание
The stack to add.

Link to addIItemStackToInventory

Name: addIItemStackToInventory

Adds the stack to the first empty slot in the player's inventory.

Returns: True if the stack was added. False otherwise.
Return Type: boolean

ZenScript
Copy
// PlayerInventory.addIItemStackToInventory(stack as IItemStack) as boolean

myPlayerInventory.addIItemStackToInventory(<item:minecraft:diamond>);
ПараметрТипОписание
Параметр
stack
Тип
IItemStack
Описание
The stack to add.

Link to canStoreIItemStack

Name: canStoreIItemStack

Checks if a stack can be stored in the player's inventory. It first tries to place it in the selected slot in the player's hotbar, then the offhand slot, then any available/empty slot in the player's inventory.

Returns: The slot that the stack can be stored in, or -1 if it can't be stored.
Return Type: int

ZenScript
Copy
// PlayerInventory.canStoreIItemStack(stack as IItemStack) as int

myPlayerInventory.canStoreIItemStack(<item:minecraft:diamond>);
ПараметрТипОписание
Параметр
stack
Тип
IItemStack
Описание
The stack to store.

Name: deleteStack

Removes the first instance of the given stack from the inventory.

Return Type: void

ZenScript
Copy
// PlayerInventory.deleteStack(stack as IItemStack) as void

myPlayerInventory.deleteStack(<item:minecraft:diamond>);
ПараметрТипОписание
Параметр
stack
Тип
IItemStack
Описание
The stack to remove.

Name: dropAllItems

Drop all items in the inventory..

Return Type: void

ZenScript
Copy
// PlayerInventory.dropAllItems() as void

myPlayerInventory.dropAllItems();

Name: getCurrentItem

Gets the currently held item by the player.

Returns: The currently held stack by the player.
Return Type: IItemStack

ZenScript
Copy
// PlayerInventory.getCurrentItem() as IItemStack

myPlayerInventory.getCurrentItem();

Link to getFirstEmptyStack

Name: getFirstEmptyStack

Gets the first slot in the inventory that is empty.

If no slot is found, it returns -1.

Returns: The found slot or -1 if no slot is found.
Return Type: int

ZenScript
Copy
// PlayerInventory.getFirstEmptyStack() as int

myPlayerInventory.getFirstEmptyStack();

Name: getIItemStack

Gets the IItemStack that is being held by the mouse in a Gui/Container.

Returns: The held IItemStack
Return Type: IItemStack

ZenScript
Copy
// PlayerInventory.getIItemStack() as IItemStack

myPlayerInventory.getIItemStack();

Name: hasIItemStack

Checks if any of the ItemStacks in the inventory match the given ingredient.

Returns: True if any of the stacks match. False otherwise.
Return Type: boolean

ZenScript
Copy
PlayerInventory.hasIItemStack(ingredient as IIngredient) as boolean
ПараметрТипОписание
Параметр
ingredient
Тип
IIngredient
Описание
The ingredient to check against..

Name: remove

Removes all stacks that match the ingredient.

Returns: True if anything was removed. False otherwise.
Return Type: boolean

ZenScript
Copy
// PlayerInventory.remove(ingredient as IIngredient) as boolean

myPlayerInventory.remove(<item:minecraft:diamond>);
ПараметрТипОписание
Параметр
ingredient
Тип
IIngredient
Описание
The ingredient to match against.

Name: setIItemStack

Sets the IItemStack that is being held by the mouse in a Gui/Container.

Return Type: void

ZenScript
Copy
// PlayerInventory.setIItemStack(stack as IItemStack) as void

myPlayerInventory.setIItemStack(<item:minecraft:dirt>);
ПараметрТипОписание
Параметр
stack
Тип
IItemStack
Описание
The stack to hold.

Свойства

Link to свойства

НазваниеТипИмеет GetterИмеет SetterОписание
Название
currentItem
Тип
IItemStack
Имеет Getter
true
Имеет Setter
false
Описание
Gets the currently held item by the player.
Название
firstEmptyStack
Тип
int
Имеет Getter
true
Имеет Setter
false
Описание
Gets the first slot in the inventory that is empty.

If no slot is found, it returns -1.
Название
элемент Стек
Тип
IItemStack
Имеет Getter
true
Имеет Setter
true
Описание
Gets the IItemStack that is being held by the mouse in a Gui/Container.