# CreativeItemStackHelper

`com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper`

**Since:** 1.8.4

Wraps an [ItemStackHelper](ItemStackHelper.md) stack with methods for changing its components. It holds the
same stack, not a copy; setters mutate it and return this helper for chaining.  
```js
// build a named, enchanted, glowing tool
const stack = Client.getRegistryManager().getItemStack("minecraft:diamond_sword")
  .getCreative()
  .setName("Excalibur")
  .addEnchantment("minecraft:sharpness", 5)
  .addEnchantment("minecraft:unbreaking", 3)
  .setDurability(1200)
  .hideEnchantments(false);  

Chat.log(`${stack.getName()} at ${stack.getDurability()} durability`);  
for (const ench of stack.getEnchantments()) {
  Chat.log(`  ${ench.getRomanLevelName()}`);  
}

// the helper and original refer to the same stack
Chat.log(`${stack.getCount()} of ${stack.getItemId()}`);  
```

## Constructors

### new CreativeItemStackHelper {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_constructor-ItemStack-}

```js
new CreativeItemStackHelper(ItemStack itemStack)
```

Wraps the supplied stack for component editing; the helper retains the same stack reference.

**Parameters:**
- `itemStack`: the stack to wrap and edit

## Methods

### addEnchantment {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_addEnchantment-String-int-}

```js
addEnchantment(String id, int level): CreativeItemStackHelper
```

Upgrades or adds the identified enchantment at the requested level. The id may omit its
namespace; the enchantment component handles level replacement and compatibility.

**Parameters:**
- `id`: the id of the enchantment
- `level`: the level of the enchantment

**Returns:** self for chaining.

**Since:** 1.8.4

### addEnchantment {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_addEnchantment-EnchantmentHelper-}

```js
addEnchantment(EnchantmentHelper enchantment): CreativeItemStackHelper
```

Adds or upgrades the enchantment using the level carried by the helper. Registry-only
helpers have no level; use the id-and-level overload when specifying one.

**Parameters:**
- `enchantment`: the enchantment to add

**Returns:** self for chaining.

**Since:** 1.8.4

### addLore {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_addLore-Object[]-}

```js
addLore(Object... lore): CreativeItemStackHelper
```

Appends lore lines. A [TextHelper](../TextHelper.md) retains its styling, a [TextBuilder](../../classes/TextBuilder.md) is built
first, and other values are converted to literal text using `toString`.

**Parameters:**
- `lore`: the lore to add

**Returns:** self for chaining.

**Since:** 1.8.4

### clearEnchantments {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_clearEnchantments-}

```js
clearEnchantments(): CreativeItemStackHelper
```

Replaces this stack's enchantments component with the empty component.

**Returns:** self for chaining.

**Since:** 1.8.4

### clearLore {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_clearLore-}

```js
clearLore(): CreativeItemStackHelper
```

Sets this stack's lore to an empty list.

**Returns:** self for chaining.

**Since:** 1.8.4

### hideCanDestroy {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_hideCanDestroy-boolean-}

```js
hideCanDestroy(boolean hide): CreativeItemStackHelper
```

Hides or shows this stack's can-destroy component in its tooltip without changing the
restriction itself.

**Parameters:**
- `hide`: whether to hide the restriction in the tooltip

**Returns:** self for chaining.

**Since:** 1.8.4

### hideCanPlace {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_hideCanPlace-boolean-}

```js
hideCanPlace(boolean hide): CreativeItemStackHelper
```

Hides or shows this stack's can-place-on component in its tooltip without changing the
restriction itself.

**Parameters:**
- `hide`: whether to hide the restriction in the tooltip

**Returns:** self for chaining.

**Since:** 1.8.4

### hideDye {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_hideDye-boolean-}

```js
hideDye(boolean hide): CreativeItemStackHelper
```

Hides or shows this stack's dyed-color component in its tooltip without changing its color.

**Parameters:**
- `hide`: whether to hide the dyed color in the tooltip

**Returns:** self for chaining.

**Since:** 1.8.4

### hideEnchantments {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_hideEnchantments-boolean-}

```js
hideEnchantments(boolean hide): CreativeItemStackHelper
```

Hides or shows the enchantment component in the stack's tooltip; this does not remove its enchantments.

**Parameters:**
- `hide`: whether to hide the enchantments or not

**Returns:** self for chaining.

**Since:** 1.8.4

### hideModifiers {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_hideModifiers-boolean-}

```js
hideModifiers(boolean hide): CreativeItemStackHelper
```

Hides or shows the stack's attribute modifiers in its tooltip.

**Parameters:**
- `hide`: whether to hide attributes and modifiers or not

**Returns:** self for chaining.

**Since:** 1.8.4

### hideUnbreakable {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_hideUnbreakable-boolean-}

```js
hideUnbreakable(boolean hide): CreativeItemStackHelper
```

Hides or shows the unbreakable component in the tooltip without changing whether the stack is unbreakable.

**Parameters:**
- `hide`: whether to hide the unbreakable flag or not

**Returns:** self for chaining.

**Since:** 1.8.4

### removeEnchantment {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_removeEnchantment-EnchantmentHelper-}

```js
removeEnchantment(EnchantmentHelper enchantment): CreativeItemStackHelper
```

Removes all levels of the enchantment identified by the helper, preserving other enchantments.

**Parameters:**
- `enchantment`: the enchantment to remove

**Returns:** self for chaining.

**Since:** 1.8.4

### removeEnchantment {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_removeEnchantment-String-}

```js
removeEnchantment(String id): CreativeItemStackHelper
```

Removes all levels of the enchantment with this identifier, preserving other enchantments.  
The identifier must include its namespace.

**Parameters:**
- `id`: the id of the enchantment to remove

**Returns:** self for chaining.

**Since:** 1.8.4

### setCount {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_setCount-int-}

```js
setCount(int count): CreativeItemStackHelper
```

Sets the stack count without clamping it to the item's maximum stack size.

**Parameters:**
- `count`: the new count of the item

**Returns:** self for chaining.

**Since:** 1.8.4

### setDamage {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_setDamage-int-}

```js
setDamage(int damage): CreativeItemStackHelper
```

Sets the damage value on this stack. Damage counts up; use [setDurability(int)](#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_setDurability-int-) to
specify the remaining durability instead.

**Parameters:**
- `damage`: the damage the item should take

**Returns:** self for chaining.

**Since:** 1.8.4

### setDurability {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_setDurability-int-}

```js
setDurability(int durability): CreativeItemStackHelper
```

Sets remaining durability by storing the item's maximum damage minus this value.

**Parameters:**
- `durability`: the new durability of this item

**Returns:** self for chaining.

**Since:** 1.8.4

### setLore {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_setLore-Object[]-}

```js
setLore(Object... lore): CreativeItemStackHelper
```

Replaces this stack's lore with the supplied lines.  

Each argument is a line. A [TextHelper](../TextHelper.md) is taken as text with whatever styling it
carries, a [TextBuilder](../../classes/TextBuilder.md) is built and taken that way, and anything else is turned into
literal text through its own `toString`.

**Parameters:**
- `lore`: the new lore

**Returns:** self for chaining.

**Since:** 1.8.4

### setName {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_setName-String-}

```js
setName(String name): CreativeItemStackHelper
```

Sets this stack's custom name to literal text; the item type's name is unchanged.

**Parameters:**
- `name`: the new name of the item

**Returns:** self for chaining.

**Since:** 1.8.4

### setName {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_setName-TextHelper-}

```js
setName(TextHelper name): CreativeItemStackHelper
```

Sets this stack's custom name to the supplied text, including its styling.

**Parameters:**
- `name`: the new name of the item

**Returns:** self for chaining.

**Since:** 1.8.4

### setUnbreakable {#com.jsmacrosce.jsmacros.client.api.helper.inventory.CreativeItemStackHelper_setUnbreakable-boolean-}

```js
setUnbreakable(boolean unbreakable): CreativeItemStackHelper
```

Sets or removes the unbreakable component on this stack.

**Parameters:**
- `unbreakable`: whether the item should be unbreakable or not

**Returns:** self for chaining.

**Since:** 1.8.4
