Skip to content

Inventory Class

wagyourtail edited this page Aug 19, 2020 · 9 revisions

The Inventory Class, methods are as follows:

getType() 1.1.3+

Example: inv.getType()

returns a string representation of the inventory type.

getContainerTitle() 1.2.3+

Example: inv.getContainerTitle()

returns string of the title text of the container.

getMap() 1.1.3+

Example: inv.getMap()

returns a HashMap<String, int[]> of the inventory mappings different depending on the type of open container/inventory (ie. python so i can make it smaller):

{
    main: range(0, 27),
    hotbar: range(27, 37)
}

getSelectedHotbarSlotIndex() 1.2.5+

Example: inv.getSelectedHotbarSlotIndex()

returns the index of the selected hotbar slot.

getSlotUnderMouse() 1.1.3+

Example: inv.getSlotUnderMouse()

returns the id of the slot under the mouse.

getLocation(int) 1.1.3+

Example: inv.getLocation(slot)

returns the part of the mapping the slot is in.

click(int, int)

Example: inv.click(slot_number, mouse_button)

clicks a slot with a mouse button.

dragClick(int[], int)

Example: inv.dragClick([slot1,slot2,slot3], mouse_button)

does a drag-click with a mouse button. (the slots don't have to be in order or even adjacent, but when vanilla minecraft calls the underlying function they're always sorted...)

closeAndDrop()

Example: inv.closeAndDrop()

closes the inventory, (if the inventory/container is visible it will close the gui). also drops any "held on mouse" items.

close()

Example: inv.close()

closes the inventory, and open gui if applicable.

quick(int)

Example: inv.quick(slot)

simulates a shift-click on a slot.

getHeld()

Example: inv.getHeld()

returns an ItemStackHelper of the held (by the mouse) item.

getSlot(int)

Example: inv.getSlot(slot)

returns an ItemStackHelper of the slot.

getTotalSlots(inv)

Example: inv.getTotalSlots()

returns the size of the container/inventory.

split(int, int)

Example: inv.split(slot1, slot2)

splits the held stack into two slots. can be alternatively done with drag-click if this one has issues on some servers.

grabAll(int)

Example: inv.grabAll(slot)

does that double click on a slot thingy to move all of a type into/out-of a chest.

swap(int, int)

Example: inv.swap(slot1, slot2)

swaps the items in two slots.

Clone this wiki locally