Skip to content

Player Inventory

The inventory system manages player item storage including hotbar, main storage, armor, utility slots, and backpack.

com.hypixel.hytale.server.core.inventory

Player inventory is divided into sections, each with a unique section ID. Active slots track which item the player currently has selected in each section.

Section IDConstantCapacityPurpose
-1HOTBAR_SECTION_ID9Main hotbar (0-8)
-2STORAGE_SECTION_ID36Main storage (4x9 grid)
-3ARMOR_SECTION_ID6Armor equipment
-5UTILITY_SECTION_ID4Consumables (food, potions)
-8TOOLS_SECTION_ID23Tools (deprecated)
-9BACKPACK_SECTION_IDVariableExpandable storage

Main inventory management class:

package com.hypixel.hytale.server.core.inventory;
public class Inventory {
// Section ID constants
public static final int HOTBAR_SECTION_ID = -1;
public static final int STORAGE_SECTION_ID = -2;
public static final int ARMOR_SECTION_ID = -3;
public static final int UTILITY_SECTION_ID = -5;
public static final int TOOLS_SECTION_ID = -8;
public static final int BACKPACK_SECTION_ID = -9;
// Container access
public ItemContainer getHotbar();
public ItemContainer getStorage();
public ItemContainer getArmor();
public ItemContainer getUtility();
public ItemContainer getTools();
public ItemContainer getBackpack();
public ItemContainer getSectionById(int sectionId);
// Active slot management - Hotbar
public byte getActiveHotbarSlot();
public void setActiveHotbarSlot(byte slot);
public ItemStack getActiveHotbarItem();
public ItemStack getItemInHand();
// Active slot management - Utility
public byte getActiveUtilitySlot();
public void setActiveUtilitySlot(byte slot);
public ItemStack getUtilityItem();
// Active slot management - Tools (deprecated)
public byte getActiveToolsSlot();
public void setActiveToolsSlot(byte slot);
public ItemStack getToolsItem();
// Item operations
public void moveItem(
int fromSectionId, int fromSlotId,
int quantity,
int toSectionId, int toSlotId
);
public void smartMoveItem(
int fromSectionId, int fromSlotId,
int quantity,
SmartMoveType moveType
);
// Bulk operations
public ListTransaction<MoveTransaction<ItemStackTransaction>> takeAll(
int inventorySectionId
);
public ListTransaction<MoveTransaction<ItemStackTransaction>> putAll(
int inventorySectionId
);
public ListTransaction<MoveTransaction<ItemStackTransaction>> quickStack(
int inventorySectionId
);
public List<ItemStack> dropAllItemStacks();
public void clear();
// Combined containers
public CombinedItemContainer getCombinedHotbarFirst();
public CombinedItemContainer getCombinedStorageFirst();
public CombinedItemContainer getCombinedArmorHotbarStorage();
public CombinedItemContainer getCombinedEverything();
}

The armor section has 6 slots corresponding to ItemArmorSlot:

Slot IndexPosition
0Head
1Chest
2Legs
3Feet
4Cape
5Accessory
import com.hypixel.hytale.server.core.inventory.Inventory;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.inventory.container.ItemContainer;
// Get player inventory
Player player = /* player reference */;
Inventory inventory = player.getInventory();
// Access containers
ItemContainer hotbar = inventory.getHotbar(); // 9 slots
ItemContainer storage = inventory.getStorage(); // 36 slots
ItemContainer armor = inventory.getArmor(); // 6 slots
ItemContainer utility = inventory.getUtility(); // 4 slots
ItemContainer backpack = inventory.getBackpack(); // Variable size
// Access by section ID
ItemContainer section = inventory.getSectionById(Inventory.HOTBAR_SECTION_ID);
// Get currently held item (main hand)
ItemStack heldItem = inventory.getItemInHand();
// Get active hotbar slot (0-8)
byte activeSlot = inventory.getActiveHotbarSlot();
// Change active slot
inventory.setActiveHotbarSlot((byte) 3);
// Get specific hotbar item
ItemStack hotbarItem = inventory.getActiveHotbarItem();
// Utility items
ItemStack utilityItem = inventory.getUtilityItem();
inventory.setActiveUtilitySlot((byte) 1);
// Move 1 item from hotbar slot 0 to storage slot 10
inventory.moveItem(
Inventory.HOTBAR_SECTION_ID, 0, // From
1, // Quantity
Inventory.STORAGE_SECTION_ID, 10 // To
);
// Move entire stack
ItemContainer hotbar = inventory.getHotbar();
ItemStack item = hotbar.getItemAt(0);
int quantity = item != null ? item.getQuantity() : 0;
inventory.moveItem(
Inventory.HOTBAR_SECTION_ID, 0,
quantity,
Inventory.STORAGE_SECTION_ID, 10
);
import com.hypixel.hytale.server.core.inventory.SmartMoveType;
// Auto-equip armor or merge stacks
inventory.smartMoveItem(
Inventory.STORAGE_SECTION_ID, 15,
1,
SmartMoveType.EquipOrMergeStack
);
// Move to hotbar if possible, otherwise storage
inventory.smartMoveItem(
Inventory.STORAGE_SECTION_ID, 20,
1,
SmartMoveType.ToHotbar
);
// Take all items from a container (e.g., chest)
var takeTransaction = inventory.takeAll(externalContainerId);
// Put all storage items into container
var putTransaction = inventory.putAll(externalContainerId);
// Quick stack matching items to container
var quickTransaction = inventory.quickStack(externalContainerId);
// Drop all items (on death)
List<ItemStack> droppedItems = inventory.dropAllItemStacks();
// Clear entire inventory
inventory.clear();
// Search hotbar first, then storage
CombinedItemContainer hotbarFirst = inventory.getCombinedHotbarFirst();
// Search storage first, then hotbar
CombinedItemContainer storageFirst = inventory.getCombinedStorageFirst();
// Search armor, hotbar, storage
CombinedItemContainer armorHotbarStorage = inventory.getCombinedArmorHotbarStorage();
// Search everything
CombinedItemContainer everything = inventory.getCombinedEverything();
// Find item in combined container
ItemStack foundItem = everything.findItem(item ->
item.getItem().getId().equals("iron_sword")
);
// Get armor container
ItemContainer armor = inventory.getArmor();
// Get specific armor piece
ItemStack helmet = armor.getItemAt(0); // Head
ItemStack chest = armor.getItemAt(1); // Chest
ItemStack legs = armor.getItemAt(2); // Legs
ItemStack feet = armor.getItemAt(3); // Feet
ItemStack cape = armor.getItemAt(4); // Cape
ItemStack accessory = armor.getItemAt(5); // Accessory
// Check if slot is empty
if (armor.isEmpty(0)) {
// No helmet equipped
}
// Get currently held item
ItemStack heldItem = inventory.getItemInHand();
if (heldItem != null) {
Item item = heldItem.getItem();
String itemId = item.getId();
int quantity = heldItem.getQuantity();
// Check item type
if (item.getWeapon() != null) {
// Holding a weapon
} else if (item.getTool() != null) {
// Holding a tool
} else if (item.getBlock() != null) {
// Holding a placeable block
}
}

Options for intelligent item placement:

TypeDescription
EquipOrMergeStackAuto-equip armor/tools, or merge with existing stacks
ToHotbarMove to hotbar if possible
ToStorageMove to main storage
ToArmorEquip in appropriate armor slot
  • Hotbar: 0-8 (9 slots)
  • Storage: 0-35 (36 slots, 4 rows x 9 columns)
  • Armor: 0-5 (Head, Chest, Legs, Feet, Cape, Accessory)
  • Utility: 0-3 (4 slots)
  • Inactive indicator: -1 (no active slot)