9.4 KiB
Table of Contents generated with DocToc
- windows.createWindow(id, type, title, slotCount = undefined)
- windows.Window (base class)
- properties
- Methods
- window.acceptClick(click)
- window.acceptOutsideWindowClick(click)
- window.acceptInventoryClick(click)
- window.acceptNonInventorySwapAreaClick(click)
- window.acceptSwapAreaRightClick(click)
- window.acceptSwapAreaLeftClick(click)
- window.acceptCraftingClick(click)
- window.updateSlot(slot, newItem)
- window.findItemRange(start, end, itemType, metadata, [notFull], null)
- window.findItemRangeName(start, end, itemName, metadata, [notFull])
- window.findInventoryItem(item, metadata, [notFull])
- window.findContainerItem(item, metadata, [notFull])
- window.firstEmptySlotRange(start, end)
- window.firstEmptyHotbarSlot()
- window.firstEmptyContainerSlot()
- window.firstEmptyInventorySlot(hotbarFirst = true)
- window.countRange (start, end, itemType, metadata)
- window.itemsRange (start, end)
- window.count(itemType, [metadata])
- window.items()
- window.containerCount(itemType, [metadata])
- window.containerItems()
- window.emptySlotCount()
- window.transactionRequiresConfirmation(click)
- Events
windows.createWindow(id, type, title, slotCount = undefined)
Create a window with:
id
- the window idtype
- this can be a string or a numeric id depending on the mcVersiontitle
- the title of the windowslotCount
- used to set the number of slots for mcVersion prior to 1.14, ignored in 1.14
windows.Window (base class)
properties
window.id
The protocol id of the window
window.type
Type of the window, can be a string or a numeric id depending on the mcVersion
window.title
Title of the window, shown in the gui.
window.slots
Map of slot index to Item
instance. null
if the slot is empty.
window.inventoryStart
Slot from where the player inventory start in the window.
window.inventoryEnd
Slot from where the player inventory end in the window.
window.hotbarStart
Slot from where the player hotbar start in the window.
window.craftingResultSlot
Slot for the crafting result if this window has one, -1
otherwise.
window.requiresConfirmation
boolean
only false for chests in pre-1.14 versions.
window.selectedItem
In vanilla client, this is the item you are holding with the mouse cursor.
Methods
window.acceptClick(click)
window.acceptOutsideWindowClick(click)
window.acceptInventoryClick(click)
window.acceptNonInventorySwapAreaClick(click)
window.acceptSwapAreaRightClick(click)
window.acceptSwapAreaLeftClick(click)
window.acceptCraftingClick(click)
Change the slot
to contain the newItem
. Emit the updateSlot
events.
Returns a list of changed slots mirroring the Window Click packet format
window.updateSlot(slot, newItem)
Change the slot
to contain the newItem
. Emit the updateSlot
events.
window.findItemRange(start, end, itemType, metadata, [notFull], nbt)
start
- start slot to begin the search fromend
- end slot to end the searchitem
- numerical id that you are looking for check the listmetadata
- metadata value that you are looking for.null
means unspecified.notFull
- (optional) - iftrue
, means that the returned item should not be at itsstackSize
.nbt
- nbt data for the item you are looking for.null
means unspecified
window.findItemRangeName(start, end, itemName, metadata, [notFull])
start
- start slot to begin the search fromend
- end slot to end the searchitem
- name that you are looking for check the listmetadata
- metadata value that you are looking for.null
means unspecified.notFull
- (optional) - iftrue
, means that the returned item should not be at itsstackSize
.
window.findInventoryItem(item, metadata, [notFull])
Search in the player inventory.
item
- numerical id or name that you are looking for check the listmetadata
- metadata value that you are looking for.null
means unspecified.notFull
- (optional) - iftrue
, means that the returned item should not be at itsstackSize
.
window.findContainerItem(item, metadata, [notFull])
Search in the container of the window.
item
- numerical id or name that you are looking for check the listmetadata
- metadata value that you are looking for.null
means unspecified.notFull
- (optional) - iftrue
, means that the returned item should not be at itsstackSize
.
window.firstEmptySlotRange(start, end)
Return the id of the first empty slot between start
and end
.
window.firstEmptyHotbarSlot()
Return the id of the first empty slot in the hotbar.
window.firstEmptyContainerSlot()
Return the id of the first empty slot in the container.
window.firstEmptyInventorySlot(hotbarFirst = true)
Return the id of the first empty slot in the inventory, start looking in the hotbar first if the flag is set.
window.countRange (start, end, itemType, metadata)
Returns how many item you have of the given type, between slots start
and end
.
itemType
- numerical id that you are looking formetadata
- (optional) metadata value that you are looking for. defaults to unspecified
window.itemsRange (start, end)
Returns a list of Item
instances between slots start
and end
.
window.count(itemType, [metadata])
Returns how many you have in the inventory section of the window.
itemType
- numerical id that you are looking formetadata
- (optional) metadata value that you are looking for. defaults to unspecified
window.items()
Returns a list of Item
instances from the inventory section of the window.
window.containerCount(itemType, [metadata])
Returns how many you have in the top section of the window.
itemType
- numerical id that you are looking formetadata
- (optional) metadata value that you are looking for. defaults to unspecified
window.containerItems()
Returns a list of Item
instances from the top section of the window.
window.emptySlotCount()
Returns how many empty slots you have in the inventory section of the window.
window.transactionRequiresConfirmation(click)
Returns the property: requiresConfirmation
.
window.clear([blockId], [count])
Sets all slots in the window to null (unless specified by args)
blockId
- (optional) numerical id of the block that you would like to clearcount
- (optional, requires blockId) only delete this number of the given block
Events
window "updateSlot" (slot, oldItem, newItem)
Fired whenever any slot in the window changes for any reason.
Watching bot.inventory.on("updateSlot")
is the best way to watch for changes in your inventory.
slot
- index of changed slot.oldItem
,newItem
- either anItem
instance ornull
.
newItem === window.slots[slot]
.
window "updateSlot:slot" (oldItem, newItem)
Fired whenever a specific slot in the window changes for any reason.
oldItem
,newItem
- either anItem
instance ornull
.
newItem === window.slots[slot]
.