Class Inventory
java.lang.Object
fr.hytale.loader.api.inventory.Inventory
- Direct Known Subclasses:
InventoryPlayer
HytaleLoader wrapper for the native Hytale Inventory class.
This class provides a simplified API for interacting with inventories.
- Since:
- 1.0.1
- Version:
- 1.0.4
- Author:
- HytaleLoader
-
Constructor Summary
ConstructorsConstructorDescriptionInventory(com.hypixel.hytale.server.core.inventory.Inventory nativeInventory) Constructs a new Inventory wrapper. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an item to the inventory.voidclear()Clears the inventory.getItem(int slot) Return the item at the slot givengetItems()Gets the items in the inventory.com.hypixel.hytale.server.core.inventory.InventoryGets the native Hytale inventory instance.voidSets the item at the specified slot in the inventory.
-
Constructor Details
-
Inventory
public Inventory(com.hypixel.hytale.server.core.inventory.Inventory nativeInventory) Constructs a new Inventory wrapper.- Parameters:
nativeInventory- the native Hytale inventory instance
-
-
Method Details
-
getNativeInventory
public com.hypixel.hytale.server.core.inventory.Inventory getNativeInventory()Gets the native Hytale inventory instance.- Returns:
- the wrapped native inventory
-
clear
public void clear()Clears the inventory.Note: This method manually clears each slot to avoid issues with the native clear() method which may trigger events before the player is fully initialized in the world.
-
addItem
-
getItem
Return the item at the slot given- Parameters:
slot- the slot of the inventory- Returns:
- item the item at the slot given
-
getItems
-
setItem
Sets the item at the specified slot in the inventory.This method automatically determines whether to place the item in the hotbar (slots 0-8) or the main storage (slots 9+) based on the slot index provided.
- Parameters:
item- the item to place in the inventoryslot- the target slot index (0-8 for hotbar, 9+ for storage)
-