GrindStoneInventory
com.jsmacrosce.jsmacros.client.api.classes.inventory.GrindStoneInventory
Handle for an open grindstone screen.
getTopInput(), getBottomInput() and getOutput() read menu slots 0,
1 and 2 respectively; getMap() groups the input and output slots as input and output.
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
new GrindStoneInventory(GrindstoneScreen inventory)#Wraps the supplied grindstone screen; it does not open or create a screen. Use FPlayer.openInventory() to obtain a wrapper for the currently open inventory.
Parameters:
inventory: grindstone screen to wrap
Methods
getBottomInput
Returns the item in the bottom input slot (slot 1).
Returns: the bottom input item
getOutput
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().
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
getTopInput
Returns the item in the top input slot (slot 0).
Returns: the top input item
simulateXp
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. 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