Contents
Class ActiveSlotInventoryComponent
java.lang.Object
com.hypixel.hytale.server.core.inventory.InventoryComponent
com.hypixel.hytale.server.core.inventory.ActiveSlotInventoryComponent
- All Implemented Interfaces:
Component<EntityStore>, Cloneable
- Direct Known Subclasses:
InventoryComponent.Hotbar, InventoryComponent.Tool, InventoryComponent.Utility
Base class for
InventoryComponent subtypes that maintain a tracked active (selected) slot.-
Nested Class Summary
Nested classes/interfaces inherited from class InventoryComponent
InventoryComponent.AbilitySlots, InventoryComponent.Armor, InventoryComponent.Backpack, InventoryComponent.Combined, InventoryComponent.Hotbar, InventoryComponent.RuneBag, InventoryComponent.Storage, InventoryComponent.Tool, InventoryComponent.Utility -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BuilderCodec<ActiveSlotInventoryComponent> The codec used to parse theActiveSlotInventoryComponentcomponent.Fields inherited from class InventoryComponent
ABILITIES_LINE_WIDTH, ABILITIES_LINES, ABILITIES_SECTION_ID, ARMOR_HOTBAR_UTILITY_STORAGE, ARMOR_SECTION_ID, BACKPACK_HOTBAR_STORAGE, BACKPACK_SECTION_ID, BACKPACK_STORAGE_HOTBAR, DEFAULT_ABILITIES_CAPACITY, DEFAULT_ARMOR_CAPACITY, DEFAULT_HOTBAR_CAPACITY, DEFAULT_RUNE_BAG_CAPACITY, DEFAULT_STORAGE_CAPACITY, DEFAULT_STORAGE_COLUMNS, DEFAULT_STORAGE_ROWS, DEFAULT_TOOLS_CAPACITY, DEFAULT_UTILITY_CAPACITY, DUMMY_SECTION_ID, EVERYTHING, HOTBAR_FIRST, HOTBAR_SECTION_ID, HOTBAR_STORAGE_BACKPACK, HOTBAR_UTILITY_CONSUMABLE_STORAGE, INACTIVE_SLOT_INDEX, RUNE_BAG_SECTION_ID, STORAGE_FIRST, STORAGE_HOTBAR_BACKPACK, STORAGE_SECTION_ID, TOOLS_SECTION_ID, UTILITY_SECTION_IDFields inherited from interface Component
EMPTY_ARRAY -
Method Summary
Modifier and TypeMethodDescriptionvoidensureCapacity(short capacity, List<ItemStack> remainder) Resizes the inventory and clampsactiveSlottoInventoryComponent.INACTIVE_SLOT_INDEXif it falls out of range.byteabstract intReturns the inventory section ID that identifies this component (e.g.voidsetActiveSlot(byte slot, Holder<EntityStore> holder, ComponentAccessor<EntityStore> componentAccessor) Sets the active slot and fires aInventorySetActiveSlotEventvia the holder event system so registered ECS holder event systems can react.voidsetActiveSlot(byte slot, Ref<EntityStore> ref, ComponentAccessor<EntityStore> accessor) Sets the active slot and fires aInventorySetActiveSlotEventso registered ECS event systems can react.Methods inherited from class InventoryComponent
clone, consumeIsDirty, consumeNeedsSaving, getChangeEvents, getCombined, getCombined, getComponentTypeById, getInventory, getItemInHand, getItemInHand, markDirty, setupCombinedMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Component
cloneSerializable
-
Field Details
-
CODEC
The codec used to parse theActiveSlotInventoryComponentcomponent.
-
-
Method Details
-
getSectionId
public abstract int getSectionId()Returns the inventory section ID that identifies this component (e.g.InventoryComponent.HOTBAR_SECTION_ID).- Returns:
- The section ID for this inventory component.
-
ensureCapacity
Resizes the inventory and clampsactiveSlottoInventoryComponent.INACTIVE_SLOT_INDEXif it falls out of range.- Overrides:
ensureCapacityin classInventoryComponent- Parameters:
capacity- The new capacity.remainder- Items that no longer fit are added here.
-
getActiveSlot
public byte getActiveSlot()- Returns:
- the index of the currently active slot, or
InventoryComponent.INACTIVE_SLOT_INDEXif none.
-
setActiveSlot
public void setActiveSlot(byte slot, @Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> accessor) Sets the active slot and fires aInventorySetActiveSlotEventso registered ECS event systems can react.- Parameters:
slot- The slot index to make active.ref- The entity reference that owns this component.accessor- TheComponentAccessorfor component access.
-
setActiveSlot
public void setActiveSlot(byte slot, @Nonnull Holder<EntityStore> holder, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Sets the active slot and fires aInventorySetActiveSlotEventvia the holder event system so registered ECS holder event systems can react.- Parameters:
slot- The slot index to make active.holder- The holder that owns this component.componentAccessor- TheStoreto use for event dispatch.
-
getActiveItem
- Returns:
- the item currently in the active slot, or
nullif no slot is active or the slot is empty.
-