Contents
- Description
- Nested Class Summary
- Field Summary
- Constructor Summary
- Method Summary
- Field Details
- INACTIVE_SLOT_INDEX
- DEFAULT_HOTBAR_CAPACITY
- DEFAULT_UTILITY_CAPACITY
- DEFAULT_TOOLS_CAPACITY
- DEFAULT_ARMOR_CAPACITY
- DEFAULT_STORAGE_ROWS
- DEFAULT_STORAGE_COLUMNS
- DEFAULT_STORAGE_CAPACITY
- ABILITIES_LINE_WIDTH
- ABILITIES_LINES
- DEFAULT_ABILITIES_CAPACITY
- DEFAULT_RUNE_BAG_CAPACITY
- HOTBAR_SECTION_ID
- STORAGE_SECTION_ID
- ARMOR_SECTION_ID
- UTILITY_SECTION_ID
- TOOLS_SECTION_ID
- BACKPACK_SECTION_ID
- DUMMY_SECTION_ID
- ABILITIES_SECTION_ID
- RUNE_BAG_SECTION_ID
- CODEC
- HOTBAR_STORAGE_BACKPACK
- HOTBAR_FIRST
- STORAGE_FIRST
- BACKPACK_STORAGE_HOTBAR
- BACKPACK_HOTBAR_STORAGE
- STORAGE_HOTBAR_BACKPACK
- ARMOR_HOTBAR_UTILITY_STORAGE
- HOTBAR_UTILITY_CONSUMABLE_STORAGE
- EVERYTHING
- Constructor Details
- Method Details
- ensureCapacity(short, List)
- markDirty()
- consumeIsDirty()
- consumeNeedsSaving()
- getInventory()
- getChangeEvents()
- clone()
- setupCombined(ComponentType, ComponentType, ComponentType, ComponentType, ComponentType, ComponentType)
- getComponentTypeById(int)
- getCombined(ComponentAccessor, Ref, ComponentType...)
- getCombined(CommandBuffer, ArchetypeChunk, int, ComponentType...)
- getItemInHand(ComponentAccessor, Ref)
- getItemInHand(Holder)
Class InventoryComponent
java.lang.Object
com.hypixel.hytale.server.core.inventory.InventoryComponent
- All Implemented Interfaces:
Component<EntityStore>, Cloneable
- Direct Known Subclasses:
ActiveSlotInventoryComponent, InventoryComponent.AbilitySlots, InventoryComponent.Armor, InventoryComponent.Backpack, InventoryComponent.RuneBag, InventoryComponent.Storage
Base component for all inventory types on an entity. Each inventory type (hotbar, armor, etc.)
is a separate ECS component, allowing entities to have any combination of inventories.
The static combined-type arrays (e.g. HOTBAR_FIRST, EVERYTHING) define
priority-ordered groupings used by operations that span multiple inventories, such as item
insertion or sorting. The array order determines which inventory is tried first.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAbility rune slots laid out inABILITIES_LINESlines ofABILITIES_LINE_WIDTH: the first slot of each line holds the castable Primary ability (line 1 casts on Ability2, line 2 on Ability3), the remaining slots hold Support abilities.static classArmor equipment slots (helmet, chestplate, leggings, boots).static classExtended overflow storage (backpack).static classNon-serialized helper component that cachesCombinedItemContainerinstances keyed by the component-type arrays used to create them.static classQuick-access hotbar slots with a tracked active (selected) slot.static classThe player's rune bag: general storage for ability rune items, shown in the ability bench.static classGeneral-purpose storage inventory (main inventory grid).static classTool slots with a tracked active slot and a flag indicating whether the tool item is currently being used.static classUtility item slots (e.g. torches) with a tracked active slot. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final shortstatic final shortstatic final intstatic ComponentType<EntityStore, ? extends InventoryComponent>[]static final intstatic ComponentType<EntityStore, ? extends InventoryComponent>[]static final intstatic ComponentType<EntityStore, ? extends InventoryComponent>[]static final BuilderCodec<InventoryComponent> static final shortstatic final shortstatic final shortstatic final shortstatic final shortstatic final shortstatic final shortstatic final shortstatic final shortstatic final intstatic ComponentType<EntityStore, ? extends InventoryComponent>[]static ComponentType<EntityStore, ? extends InventoryComponent>[]static final intstatic ComponentType<EntityStore, ? extends InventoryComponent>[]static ComponentType<EntityStore, ? extends InventoryComponent>[]static final bytestatic final intstatic ComponentType<EntityStore, ? extends InventoryComponent>[]static ComponentType<EntityStore, ? extends InventoryComponent>[]static final intstatic final intstatic final intFields inherited from interface Component
EMPTY_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Component<EntityStore> clone()booleanbooleanvoidensureCapacity(short capacity, List<ItemStack> remainder) static CombinedItemContainergetCombined(CommandBuffer<EntityStore> commandBuffer, ArchetypeChunk<EntityStore> archetypeChunk, int index, ComponentType<EntityStore, ? extends InventoryComponent>... types) Overload ofgetCombined(ComponentAccessor, Ref, ComponentType[])for use within ECS systems that operate onArchetypeChunkdirectly.static CombinedItemContainergetCombined(ComponentAccessor<EntityStore> accessor, Ref<EntityStore> ref, ComponentType<EntityStore, ? extends InventoryComponent>... types) Returns aCombinedItemContainerthat wraps the inventories of the given component types on the specified entity.static ComponentType<EntityStore, ? extends InventoryComponent> getComponentTypeById(int id) Returns theComponentTypethat corresponds to the built-in inventory section with the given negative section ID (e.g.static ItemStackgetItemInHand(ComponentAccessor<EntityStore> accessor, Ref<EntityStore> ref) Returns the item the entity is currently holding.static ItemStackgetItemInHand(Holder<EntityStore> holder) Returns the item the entity is currently holding, using holder-based component access.voidstatic voidsetupCombined(ComponentType<EntityStore, InventoryComponent.Storage> storageInventoryComponentType, ComponentType<EntityStore, InventoryComponent.Armor> armorInventoryComponentType, ComponentType<EntityStore, InventoryComponent.Hotbar> hotbarInventoryComponentType, ComponentType<EntityStore, InventoryComponent.Utility> utilityInventoryComponentType, ComponentType<EntityStore, InventoryComponent.Backpack> backpackInventoryComponentType, ComponentType<EntityStore, InventoryComponent.Tool> ignoredToolInventoryComponentType) Initializes the combined-type arrays after all inventory component types have been registered.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Component
cloneSerializable
-
Field Details
-
INACTIVE_SLOT_INDEX
public static final byte INACTIVE_SLOT_INDEX- See Also:
-
DEFAULT_HOTBAR_CAPACITY
public static final short DEFAULT_HOTBAR_CAPACITY- See Also:
-
DEFAULT_UTILITY_CAPACITY
public static final short DEFAULT_UTILITY_CAPACITY- See Also:
-
DEFAULT_TOOLS_CAPACITY
public static final short DEFAULT_TOOLS_CAPACITY- See Also:
-
DEFAULT_ARMOR_CAPACITY
public static final short DEFAULT_ARMOR_CAPACITY -
DEFAULT_STORAGE_ROWS
public static final short DEFAULT_STORAGE_ROWS- See Also:
-
DEFAULT_STORAGE_COLUMNS
public static final short DEFAULT_STORAGE_COLUMNS- See Also:
-
DEFAULT_STORAGE_CAPACITY
public static final short DEFAULT_STORAGE_CAPACITY- See Also:
-
ABILITIES_LINE_WIDTH
public static final short ABILITIES_LINE_WIDTH- See Also:
-
ABILITIES_LINES
public static final short ABILITIES_LINES- See Also:
-
DEFAULT_ABILITIES_CAPACITY
public static final short DEFAULT_ABILITIES_CAPACITY- See Also:
-
DEFAULT_RUNE_BAG_CAPACITY
public static final short DEFAULT_RUNE_BAG_CAPACITY- See Also:
-
HOTBAR_SECTION_ID
public static final int HOTBAR_SECTION_ID- See Also:
-
STORAGE_SECTION_ID
public static final int STORAGE_SECTION_ID- See Also:
-
ARMOR_SECTION_ID
public static final int ARMOR_SECTION_ID- See Also:
-
UTILITY_SECTION_ID
public static final int UTILITY_SECTION_ID- See Also:
-
TOOLS_SECTION_ID
public static final int TOOLS_SECTION_ID- See Also:
-
BACKPACK_SECTION_ID
public static final int BACKPACK_SECTION_ID- See Also:
-
DUMMY_SECTION_ID
public static final int DUMMY_SECTION_ID- See Also:
-
ABILITIES_SECTION_ID
public static final int ABILITIES_SECTION_ID- See Also:
-
RUNE_BAG_SECTION_ID
public static final int RUNE_BAG_SECTION_ID- See Also:
-
CODEC
-
HOTBAR_STORAGE_BACKPACK
-
HOTBAR_FIRST
-
STORAGE_FIRST
-
BACKPACK_STORAGE_HOTBAR
-
BACKPACK_HOTBAR_STORAGE
-
STORAGE_HOTBAR_BACKPACK
-
ARMOR_HOTBAR_UTILITY_STORAGE
public static ComponentType<EntityStore, ? extends InventoryComponent>[] ARMOR_HOTBAR_UTILITY_STORAGE -
HOTBAR_UTILITY_CONSUMABLE_STORAGE
public static ComponentType<EntityStore, ? extends InventoryComponent>[] HOTBAR_UTILITY_CONSUMABLE_STORAGE -
EVERYTHING
-
-
Constructor Details
-
InventoryComponent
public InventoryComponent() -
InventoryComponent
public InventoryComponent(short capacity)
-
-
Method Details
-
ensureCapacity
-
markDirty
public void markDirty() -
consumeIsDirty
public boolean consumeIsDirty() -
consumeNeedsSaving
public boolean consumeNeedsSaving() -
getInventory
-
getChangeEvents
-
clone
- Specified by:
clonein interfaceComponent<EntityStore>- Returns:
- a clone instance of the original component instance.
-
setupCombined
public static void setupCombined(@Nonnull ComponentType<EntityStore, InventoryComponent.Storage> storageInventoryComponentType, @Nonnull ComponentType<EntityStore, InventoryComponent.Armor> armorInventoryComponentType, @Nonnull ComponentType<EntityStore, InventoryComponent.Hotbar> hotbarInventoryComponentType, @Nonnull ComponentType<EntityStore, InventoryComponent.Utility> utilityInventoryComponentType, @Nonnull ComponentType<EntityStore, InventoryComponent.Backpack> backpackInventoryComponentType, @Nonnull ComponentType<EntityStore, InventoryComponent.Tool> ignoredToolInventoryComponentType) Initializes the combined-type arrays after all inventory component types have been registered. Called duringEntityModulesetup. -
getComponentTypeById
@Nullable public static ComponentType<EntityStore, ? extends InventoryComponent> getComponentTypeById(int id) Returns theComponentTypethat corresponds to the built-in inventory section with the given negative section ID (e.g.HOTBAR_SECTION_ID). Returnsnullfor non-negative IDs (window IDs) or unrecognised section IDs.- Parameters:
id- The section ID to look up.- Returns:
- the matching
ComponentType, ornullif there is no built-in section forid.
-
getCombined
@Nonnull @SafeVarargs public static CombinedItemContainer getCombined(@Nonnull ComponentAccessor<EntityStore> accessor, @Nonnull Ref<EntityStore> ref, @Nonnull ComponentType<EntityStore, ? extends InventoryComponent>... types) Returns aCombinedItemContainerthat wraps the inventories of the given component types on the specified entity. Results are cached on the entity'sInventoryComponent.Combinedcomponent so repeated calls with the same type array instance within a tick are free.- Parameters:
accessor- TheComponentAccessorfor component access.ref- The entity reference of the associated entity.types- The inventory component types to combine, in priority order.- Returns:
- a combined view over the specified inventories.
-
getCombined
@Nonnull @SafeVarargs public static CombinedItemContainer getCombined(@Nonnull CommandBuffer<EntityStore> commandBuffer, @Nonnull ArchetypeChunk<EntityStore> archetypeChunk, int index, @Nonnull ComponentType<EntityStore, ? extends InventoryComponent>... types) Overload ofgetCombined(ComponentAccessor, Ref, ComponentType[])for use within ECS systems that operate onArchetypeChunkdirectly.- Parameters:
commandBuffer- The command buffer used to add theInventoryComponent.Combinedcache component if absent.archetypeChunk- The chunk containing the entity.index- The index of the entity withinarchetypeChunk.types- The inventory component types to combine, in priority order.- Returns:
- a combined view over the specified inventories.
-
getItemInHand
@Nullable public static ItemStack getItemInHand(@Nonnull ComponentAccessor<EntityStore> accessor, @Nonnull Ref<EntityStore> ref) Returns the item the entity is currently holding.If the entity has a
InventoryComponent.Toolcomponent and is actively using a tool item, the active tool item is returned; otherwise the activeInventoryComponent.Hotbaritem is returned.- Parameters:
accessor- TheComponentAccessorfor component access.ref- The entity reference.- Returns:
- the held
ItemStack, ornullif no item is held.
-
getItemInHand
Returns the item the entity is currently holding, using holder-based component access.If the entity has a
InventoryComponent.Toolcomponent and is actively using a tool item, the active tool item is returned; otherwise the activeInventoryComponent.Hotbaritem is returned.- Parameters:
holder- The entity holder.- Returns:
- the held
ItemStack, ornullif no item is held.
-