CreativeInventory
com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory
Handles the creative inventory screen and its item tabs.
js
const inv = Player.openInventory();
if (inv instanceof Inventories.Creative) {
Chat.log(`${inv.getShownItems().size()} items on the selected tab`);
}Available in scripts as Inventories.Creative.
Methods
destroyAllItems
Clears every slot in this inventory menu by sending an empty stack for each slot through the creative item-add operation.
Returns: self for chaining.
destroyHeldItem
Clears the item stack carried by the creative inventory menu.
Returns: self for chaining.
getBoots
Returns: the item in creative-menu slot
36getChestplate
Returns: the item in creative-menu slot
38getHelmet
Returns: the item in creative-menu slot
39getLeggings
Returns: the item in creative-menu slot
37getOffhand
Returns: the item in creative-menu slot
40getSavedHotbar
Returns the item stacks stored in a saved hotbar.
Parameters:
index: saved-hotbar index, from 0 to 8
Returns: the saved hotbar's item stacks
getShownItems
Returns: the items currently displayed in the creative item list.
getTabNames
Returns the current localized display name of each creative tab, in CreativeModeTabs.allTabs() order. These names are not tab IDs and are the values matched by selectTab(String).
Returns: the tab display names
getTabTexts
Returns each creative tab's current localized display name as a text object, in the same order as getTabNames().
Returns: the tab display names as text objects
isInHotbar
Tests whether a menu slot is one of the player's nine hotbar slots or the offhand slot.
Parameters:
slot: menu slot index
Returns:
true for hotbar slots 36..44 or offhand slot 45; false otherwiserestoreHotbar
Restores a saved hotbar to the player's current hotbar.
Parameters:
index: saved-hotbar index, from 0 to 8
Returns: self for chaining.
saveHotbar
Saves the player's current hotbar to a saved-hotbar slot.
Parameters:
index: saved-hotbar index, from 0 to 8
Returns: self for chaining.
scroll
Scrolls the creative item list by a relative amount when it has a scrollbar.
Parameters:
amount: relative change to the current scroll position; the resulting position is clamped to0..1
Returns: self for chaining.
scrollTo
Sets the creative item list's scroll position when it has a scrollbar; otherwise, does nothing.
Parameters:
position: scroll position, clamped to0..1
Returns: self for chaining.
search
Sets the search text and refreshes results only while the search tab is selected. Otherwise, it does nothing.
Parameters:
search: text to search for
Returns: self for chaining.
selectHotbar
Selects the hotbar tab asynchronously on the client executor.
Returns: self for chaining.
selectInventory
Selects the inventory tab asynchronously on the client executor.
Returns: self for chaining.
selectSearch
Selects the search tab asynchronously on the client executor.
Returns: self for chaining.
selectTab
Selects the tab whose current display name exactly matches the argument. The selection is scheduled on the client executor; comparison uses the localized display name.
Parameters:
tabName: the display name of the tab to select
Returns: self for chaining.
setCursorStack
Sets the stack carried by the creative inventory menu.
Parameters:
stack: the stack to carry
Returns: self for chaining.
setStack
Sets a slot through the creative item-add operation.
Parameters:
slot: the menu slot to setstack: the stack to set
Returns: self for chaining.