# CreativeInventory

`com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory`

**Since:** 1.8.4

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 {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_destroyAllItems-}

```js
destroyAllItems(): CreativeInventory
```

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.

**Since:** 1.8.4

### destroyHeldItem {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_destroyHeldItem-}

```js
destroyHeldItem(): CreativeInventory
```

Clears the item stack carried by the creative inventory menu.

**Returns:** self for chaining.

**Since:** 1.8.4

### getBoots {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_getBoots-}

```js
getBoots(): ItemStackHelper
```

**Returns:** the item in creative-menu slot `36`

**Since:** 1.8.4

### getChestplate {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_getChestplate-}

```js
getChestplate(): ItemStackHelper
```

**Returns:** the item in creative-menu slot `38`

**Since:** 1.8.4

### getHelmet {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_getHelmet-}

```js
getHelmet(): ItemStackHelper
```

**Returns:** the item in creative-menu slot `39`

**Since:** 1.8.4

### getLeggings {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_getLeggings-}

```js
getLeggings(): ItemStackHelper
```

**Returns:** the item in creative-menu slot `37`

**Since:** 1.8.4

### getOffhand {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_getOffhand-}

```js
getOffhand(): ItemStackHelper
```

**Returns:** the item in creative-menu slot `40`

**Since:** 1.8.4

### getSavedHotbar {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_getSavedHotbar-int-}

```js
getSavedHotbar(int index): List<ItemStackHelper>
```

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

**Since:** 1.8.4

### getShownItems {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_getShownItems-}

```js
getShownItems(): List<ItemStackHelper>
```

**Returns:** the items currently displayed in the creative item list.

**Since:** 1.8.4

### getTabNames {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_getTabNames-}

```js
getTabNames(): List<String>
```

Returns the current localized display name of each creative tab, in [CreativeModeTabs.allTabs()](https://mcsrc.dev/2/26.3/net/minecraft/world/item/CreativeModeTabs) order.  
These names are not tab IDs and are the values matched by [selectTab(String)](#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_selectTab-String-).

**Returns:** the tab display names

**Since:** 1.8.4

### getTabTexts {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_getTabTexts-}

```js
getTabTexts(): List<TextHelper>
```

Returns each creative tab's current localized display name as a text object, in the same order as [getTabNames()](#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_getTabNames-).

**Returns:** the tab display names as text objects

**Since:** 1.8.4

### isInHotbar {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_isInHotbar-int-}

```js
isInHotbar(int slot): boolean
```

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` otherwise

**Since:** 1.8.4

### restoreHotbar {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_restoreHotbar-int-}

```js
restoreHotbar(int index): CreativeInventory
```

Restores a saved hotbar to the player's current hotbar.

**Parameters:**
- `index`: saved-hotbar index, from 0 to 8

**Returns:** self for chaining.

**Since:** 1.8.4

### saveHotbar {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_saveHotbar-int-}

```js
saveHotbar(int index): CreativeInventory
```

Saves the player's current hotbar to a saved-hotbar slot.

**Parameters:**
- `index`: saved-hotbar index, from 0 to 8

**Returns:** self for chaining.

**Since:** 1.8.4

### scroll {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_scroll-double-}

```js
scroll(double amount): CreativeInventory
```

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 to `0..1`

**Returns:** self for chaining.

**Since:** 1.8.4

### scrollTo {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_scrollTo-double-}

```js
scrollTo(double position): CreativeInventory
```

Sets the creative item list's scroll position when it has a scrollbar; otherwise, does nothing.

**Parameters:**
- `position`: scroll position, clamped to `0..1`

**Returns:** self for chaining.

**Since:** 1.8.4

### search {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_search-String-}

```js
search(String search): CreativeInventory
```

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.

**Since:** 1.8.4

### selectHotbar {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_selectHotbar-}

```js
selectHotbar(): CreativeInventory
```

Selects the hotbar tab asynchronously on the client executor.

**Returns:** self for chaining.

**Since:** 1.8.4

### selectInventory {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_selectInventory-}

```js
selectInventory(): CreativeInventory
```

Selects the inventory tab asynchronously on the client executor.

**Returns:** self for chaining.

**Since:** 1.8.4

### selectSearch {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_selectSearch-}

```js
selectSearch(): CreativeInventory
```

Selects the search tab asynchronously on the client executor.

**Returns:** self for chaining.

**Since:** 1.8.4

### selectTab {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_selectTab-String-}

```js
selectTab(String tabName): CreativeInventory
```

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.

**Since:** 1.8.4

### setCursorStack {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_setCursorStack-ItemStackHelper-}

```js
setCursorStack(ItemStackHelper stack): CreativeInventory
```

Sets the stack carried by the creative inventory menu.

**Parameters:**
- `stack`: the stack to carry

**Returns:** self for chaining.

**Since:** 1.8.4

### setStack {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_setStack-int-ItemStackHelper-}

```js
setStack(int slot, ItemStackHelper stack): CreativeInventory
```

Sets a slot through the creative item-add operation.

**Parameters:**
- `slot`: the menu slot to set
- `stack`: the stack to set

**Returns:** self for chaining.

**Since:** 1.8.4

### toString {#com.jsmacrosce.jsmacros.client.api.classes.inventory.CreativeInventory_toString-}

```js
toString(): String
```

Returns the diagnostic label `CreativeInventory:{}`.

**Returns:** the fixed diagnostic label `CreativeInventory:{}`
