# GrindStoneInventory

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

**Since:** 1.8.4

Handle for an open grindstone screen.  
 
 [getTopInput()](#com.jsmacrosce.jsmacros.client.api.classes.inventory.GrindStoneInventory_getTopInput-), [getBottomInput()](#com.jsmacrosce.jsmacros.client.api.classes.inventory.GrindStoneInventory_getBottomInput-) and [getOutput()](#com.jsmacrosce.jsmacros.client.api.classes.inventory.GrindStoneInventory_getOutput-) read menu slots 0,  
 1 and 2 respectively; [getMap()](Inventory.md#com.jsmacrosce.jsmacros.client.api.classes.inventory.Inventory_getMap-) groups the input and output slots as `input`
 and `output`.  
 
 [simulateXp()](#com.jsmacrosce.jsmacros.client.api.classes.inventory.GrindStoneInventory_simulateXp-) returns the lower bound of the experience awarded when the result is
 taken; it does not take the result or change the inventory.  
 ```js
const inv = Player.openInventory();  
if (inv instanceof Inventories.GrindStone) {
  if (!inv.getOutput().isEmpty()) {
    const floor = inv.simulateXp();  
    Chat.log(`grinding to ${inv.getOutput().getName()} for ${floor} to ${2 * floor - 1} xp`);  
  }
}
 ```

Available in scripts as `Inventories.GrindStone`.

## Constructors

### new GrindStoneInventory {#com.jsmacrosce.jsmacros.client.api.classes.inventory.GrindStoneInventory_constructor-GrindstoneScreen-}

```js
new GrindStoneInventory(GrindstoneScreen inventory)
```

Wraps the supplied grindstone screen; it does not open or create a screen.  
 Use [FPlayer.openInventory()](../../../../../../../../libraries/com/jsmacrosce/jsmacros/client/api/library/impl/FPlayer.md#com.jsmacrosce.jsmacros.client.api.library.impl.FPlayer_openInventory-) to obtain
 a wrapper for the currently open inventory.

**Parameters:**
- `inventory`: grindstone screen to wrap

## Methods

### getBottomInput {#com.jsmacrosce.jsmacros.client.api.classes.inventory.GrindStoneInventory_getBottomInput-}

```js
getBottomInput(): ItemStackHelper
```

Returns the item in the bottom input slot (slot 1).

**Returns:** the bottom input item

**Since:** 1.8.4

### getOutput {#com.jsmacrosce.jsmacros.client.api.classes.inventory.GrindStoneInventory_getOutput-}

```js
getOutput(): ItemStackHelper
```

Returns the current item in the result slot (slot 2), or an empty item if there is no result.  
 Taking the result awards the experience estimated by [simulateXp()](#com.jsmacrosce.jsmacros.client.api.classes.inventory.GrindStoneInventory_simulateXp-).  
 
 ```js
const inv = Player.openInventory();  
if (inv instanceof Inventories.GrindStone) {
  const out = inv.getOutput();  
  if (!out.isEmpty()) {
    Chat.log(`grinding to ${out.getName()}`);  
  }
}
 ```

**Returns:** the result the grindstone is currently offering

**Since:** 1.8.4

### getTopInput {#com.jsmacrosce.jsmacros.client.api.classes.inventory.GrindStoneInventory_getTopInput-}

```js
getTopInput(): ItemStackHelper
```

Returns the item in the top input slot (slot 0).

**Returns:** the top input item

**Since:** 1.8.4

### simulateXp {#com.jsmacrosce.jsmacros.client.api.classes.inventory.GrindStoneInventory_simulateXp-}

```js
simulateXp(): int
```

Estimates the minimum experience awarded for enchantments in both input slots, or 0 if
 there are no non-curse enchantments to remove.  
 
 It sums each non-curse enchantment's minimum cost at its current level across both inputs,  
 then rounds half the sum up. Curses are retained and contribute nothing. When the result
 is taken, the actual award is randomized from this value (inclusive) to
 `2 * simulateXp() - 1`. This method only reads the inputs and does not change the
 inventory.  
 
 ```js
const inv = Player.openInventory();  
if (inv instanceof Inventories.GrindStone) {
  const floor = inv.simulateXp();  
  if (floor > 0) {
    Chat.log(`between ${floor} and ${2 * floor - 1} xp when the result is taken`);  
  }
}
 ```

**Returns:** the minimum experience award, or 0 when no non-curse enchantment contributes

**Since:** 1.8.4

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

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

Returns the fixed diagnostic string `GrindStoneInventory:{}`.

**Returns:** `GrindStoneInventory:{}`
