Skip to content

PlayerInventory ​

com.jsmacrosce.jsmacros.client.api.classes.inventory.PlayerInventory

Since1.8.4

The player's inventory screen, including its crafting result, input grid, equipment, and hotbar.

js
const inv = Player.openInventory();  
if (inv instanceof Inventories.Player) {
 Chat.log(`${inv.getOutput().getItemId()} in the crafting result, `
   + `${inv.getOffhand().getItemId()} in the offhand`);  
}

Available in scripts as Inventories.Player.

Methods ​

getBoots ​

getBoots(): ItemStackHelperSince1.8.4#
Returns: the item in the boots slot

getChestplate ​

getChestplate(): ItemStackHelperSince1.8.4#
Returns: the item in the chestplate slot

getCraftingHeight ​

getCraftingHeight(): intSince1.8.4#
Returns 0; this value does not describe the player's 2-by-2 crafting grid. Use getInput(int, int) to read its cells.

Returns: int

getCraftingSlotCount ​

getCraftingSlotCount(): intSince1.8.4#
Returns 0 despite the four crafting cells; getInput() therefore returns an empty grid.

Returns: int

getCraftingWidth ​

getCraftingWidth(): intSince1.8.4#
Returns 0; this value does not describe the player's 2-by-2 crafting grid. Use getInput(int, int) to read its cells.

Returns: int

getHelmet ​

getHelmet(): ItemStackHelperSince1.8.4#
Returns: the item in the helmet slot

getInput ​

getInput(int x, int y): ItemStackHelperSince1.8.4#
Returns the item in the player's 2-by-2 crafting grid. Coordinates are zero-based, with x increasing left to right and y top to bottom.

Parameters:

  • x: column in the grid, from 0 to 1
  • y: row in the grid, from 0 to 1
Returns: the item in the selected grid slot
getInput(): ItemStackHelper[][]Since1.8.4#
Returns input cells in an array indexed by column, then row. Its dimensions are the reported width and height, so it is empty when either dimension is zero.
Returns: the grid as [column][row]

getLeggings ​

getLeggings(): ItemStackHelperSince1.8.4#
Returns: the item in the leggings slot

getOffhand ​

getOffhand(): ItemStackHelperSince1.8.4#
Returns: the item in menu slot 45 (the offhand)

getOutput ​

getOutput(): ItemStackHelperSince1.8.4#
Returns the item currently in the player's crafting result slot. Read the 2-by-2 input grid with getInput(int, int); the crafting dimensions reported by this class are zero.
Returns: the current crafting result

isInHotbar ​

isInHotbar(int slot): booleanSince1.8.4#
Checks whether a player-inventory menu slot is in the hotbar or offhand.

Parameters:

  • slot: menu slot index
Returns: true for hotbar slots 36 through 44 or offhand slot 45; false otherwise

toString ​

toString(): String#
Returns the fixed diagnostic label PlayerInventory:{}.
Returns: the fixed diagnostic label PlayerInventory:{}