Table of Contents generated with DocToc
- API
- Enums
- Classes
- vec3
- mineflayer.Location
- Entity
- Block
- Biome
- Item
- windows.Window (base class)
- Recipe
- mineflayer.Chest
- mineflayer.Furnace
- furnace "open"
- furnace "close"
- furnace "update"
- furnace "updateSlot" (oldItem, newItem)
- furnace.close()
- furnace.takeInput([callback])
- furnace.takeFuel([callback])
- furnace.takeOutput([callback])
- furnace.putInput(itemType, metadata, count, [cb])
- furnace.putFuel(itemType, metadata, count, [cb])
- furnace.inputItem()
- furnace.fuelItem()
- furnace.outputItem()
- furnace.fuel
- furnace.progress
- mineflayer.Dispenser
- mineflayer.EnchantmentTable
- enchantmentTable "open"
- enchantmentTable "close"
- enchantmentTable "updateSlot" (oldItem, newItem)
- enchantmentTable "ready"
- enchantmentTable.close()
- enchantmentTable.targetItem()
- enchantmentTable.enchantments
- enchantmentTable.enchant(choice, [callback])
- enchantmentTable.takeTargetItem([callback])
- enchantmentTable.putTargetItem(item, [callback])
- mineflayer.Villager
- mineflayer.ScoreBoard
- mineflayer.BossBar
- Bot
- mineflayer.createBot(options)
- Properties
- bot.player
- bot.players
- bot.isRaining
- bot.chatPatterns
- bot.settings.chat
- bot.settings.colorsEnabled
- bot.settings.viewDistance
- bot.settings.difficulty
- bot.settings.showCape
- bot.experience.level
- bot.experience.points
- bot.experience.progress
- bot.health
- bot.food
- bot.foodSaturation
- bot.physics
- bot.time.day
- bot.time.age
- bot.quickBarSlot
- bot.inventory
- bot.targetDigBlock
- bot.isSleeping
- bot.scoreboards
- bot.scoreboard
- bot.controlState
- Events
- "chat" (username, message, translate, jsonMsg, matches)
- "whisper" (username, message, translate, jsonMsg, matches)
- "actionBar" (jsonMsg)
- "message" (jsonMsg)
- "login"
- "spawn"
- "respawn"
- "game"
- "title"
- "rain"
- "time"
- "kicked" (reason, loggedIn)
- "end"
- "spawnReset"
- "death"
- "health"
- "entitySwingArm" (entity)
- "entityHurt" (entity)
- "entityWake" (entity)
- "entityEat" (entity)
- "entityCrouch" (entity)
- "entityUncrouch" (entity)
- "entityEquipmentChange" (entity)
- "entitySleep" (entity)
- "entitySpawn" (entity)
- "playerCollect" (collector, collected)
- "entityGone" (entity)
- "entityMoved" (entity)
- "entityDetach" (entity, vehicle)
- "entityAttach" (entity, vehicle)
- "entityUpdate" (entity)
- "entityEffect" (entity, effect)
- "entityEffectEnd" (entity, effect)
- "playerJoined" (player)
- "playerLeft" (player)
- "blockUpdate" (oldBlock, newBlock)
- "blockUpdate:(x, y, z)" (oldBlock, newBlock)
- "chunkColumnLoad" (point)
- "chunkColumnUnload" (point)
- "soundEffectHeard" (soundName, position, volume, pitch)
- "hardcodedSoundEffectHeard" (soundId, soundCategory, position, volume, pitch)
- "noteHeard" (block, instrument, pitch)
- "pistonMove" (block, isPulling, direction)
- "chestLidMove" (block, isOpen)
- "blockBreakProgressObserved" (block, destroyStage)
- "blockBreakProgressEnd" (block)
- "diggingCompleted" (block)
- "diggingAborted" (block)
- "move"
- "forcedMove"
- "mount"
- "dismount" (vehicle)
- "windowOpen" (window)
- "windowClose" (window)
- "sleep"
- "wake"
- "experience"
- "scoreboardCreated" (scoreboard)
- "scoreboardDeleted" (scoreboard)
- "scoreboardTitleChanged" (scoreboard)
- "scoreUpdated" (scoreboard, item)
- "scoreRemoved" (scoreboard, item)
- "scoreboardPosition" (position, scoreboard)
- "bossBarCreated" (bossBar)
- "bossBarDeleted" (bossBar)
- "bossBarUpdated" (bossBar)
- Functions
- Methods
- bot.end()
- bot.quit(reason)
- bot.tabComplete(str, cb, [assumeCommand], [sendBlockInSight])
- bot.chat(message)
- bot.whisper(username, message)
- bot.chatAddPattern(pattern, chatType, description)
- bot.setSettings(options)
- bot.loadPlugin(plugin)
- bot.loadPlugins(plugins)
- bot.sleep(bedBlock, [cb])
- bot.isABed(bedBlock)
- bot.wake([cb])
- bot.setControlState(control, state)
- bot.clearControlStates()
- bot.lookAt(point, [force], [callback])
- bot.look(yaw, pitch, [force], [callback])
- bot.updateSign(block, text)
- bot.equip(item, destination, [callback])
- bot.unequip(destination, [callback])
- bot.tossStack(item, [callback])
- bot.toss(itemType, metadata, count, [callback])
- bot.dig(block, [callback])
- bot.stopDigging()
- bot.digTime(block)
- bot.placeBlock(referenceBlock, faceVector, cb)
- bot.activateBlock(block, [callback])
- bot.activateEntity(entity, [callback])
- bot.consume(callback)
- bot.fish(callback)
- bot.activateItem()
- bot.deactivateItem()
- bot.useOn(targetEntity)
- bot.attack(entity)
- bot.swingArm([hand])
- bot.mount(entity)
- bot.dismount()
- bot.moveVehicle(left,forward)
- bot.setQuickBarSlot(slot)
- bot.craft(recipe, count, craftingTable, [callback])
- bot.writeBook(slot, pages, [callback])
- bot.openChest(chestBlock or minecartchestEntity)
- bot.openFurnace(furnaceBlock)
- bot.openDispenser(dispenserBlock)
- bot.openEnchantmentTable(enchantmentTableBlock)
- bot.openVillager(villagerEntity)
- bot.trade(villagerInstance, tradeIndex, [times], [cb])
- bot.setCommandBlock(pos, command, track_output)
- Lower level inventory methods
- bot.creative
These enums are stored in the language independent minecraft-data project, and accessed through node-minecraft-data.
The data is available in node-minecraft-data module
require('minecraft-data')(bot.version)
gives you access to it.
blocks indexed by id
items indexed by id
The key is the material. The value is an object with the key as the item id of the tool and the value as the efficiency multiplier.
recipes indexed by id
instruments indexed by id
biomes indexed by id
entities indexed by id
All points in mineflayer are supplied as instances of this class.
- x - south
- y - up
- z - west
Functions and methods which require a point argument accept Vec3
instances
as well as an array with 3 values, and an object with x
, y
, and z
properties.
Entities represent players, mobs, and objects. They are emitted
in many events, and you can access your own entity with bot.entity
.
See prismarine-entity
See prismarine-block
Also block.blockEntity
is additional field with block entity data as Object
// sign.blockEntity
{
x: -53,
y: 88,
z: 66,
id: 'minecraft:sign', // 'Sign' in 1.10
Text1: { toString: Function }, // ChatMessage object
Text2: { toString: Function }, // ChatMessage object
Text3: { toString: Function }, // ChatMessage object
Text4: { toString: Function }, // ChatMessage object
}
See prismarine-biome
See prismarine-item
Represents a single session of opening and closing a chest.
See bot.openChest(chestBlock or minecartchestEntity)
.
If the chest is open, this property is a ChestWindow
instance.
If the chest is closed, this property is null
.
Fires when the chest has successfully been opened.
Fires when the chest closes.
Fires when the chest you are looking at is updated.
itemType
- numerical item idmetadata
- numerical value.null
means match anything.count
- how many to deposit.null
is an alias to 1.callback(err)
- (optional) - called when done depositing
itemType
- numerical item idmetadata
- numerical value.null
means match anything.count
- how many to withdraw.null
is an alias to 1.callback(err)
- (optional) - called when done withdrawing
Return how many of a certain type of item are in the chest.
itemType
- numerical item idmetadata
- (optional) numerical value.null
means match anything.
Returns a list of Item
instances from the chest.
See bot.openFurnace(furnaceBlock)
.
Fires when the furnace has successfully been opened.
Fires when the furnace closes.
Fires when furnace.fuel
and/or furnace.progress
update.
Fires when a slot in the furnace you have open has updated.
callback(err, item)
callback(err, item)
callback(err, item)
Returns Item
instance which is the input.
Returns Item
instance which is the fuel.
Returns Item
instance which is the output.
How much fuel is left between 0 and 1.
How much cooked the input is between 0 and 1.
See bot.openDispenser(dispenserBlock)
.
Fires when the dispenser has successfully been opened.
Fires when the dispenser closes.
Fires when a slot in the dispenser you have open has updated.
Returns a list of Item
instances from the dispenser.
itemType
- numerical item idmetadata
- numerical value.null
means match anything.count
- how many to deposit.null
is an alias to 1.callback(err)
- (optional) - called when done depositing
itemType
- numerical item idmetadata
- numerical value.null
means match anything.count
- how many to withdraw.null
is an alias to 1.callback(err)
- (optional) - called when done withdrawing
Return how many of a certain type of item are in the dispenser.
itemType
- numerical item idmetadata
- (optional) numerical value.null
means match anything.
See bot.openEnchantmentTable(enchantmentTableBlock)
.
Fires when the enchantment table has successfully been opened.
Fires when the enchantment table closes.
Fires when a slot in the enchantment table you have open has updated.
Fires when enchantmentTable.enchantments
is fully populated and you
may make a selection by calling enchantmentTable.enchant(choice)
.
Gets the target item. This is both the input and the output of the enchantment table.
Array of length 3 which are the 3 enchantments to choose from.
level
can be null
if the server has not sent the data yet.
Looks like:
[
{
"level": 3
},
{
"level": 4
},
{
"level": 9
}
]
choice
- [0-2], the index of the enchantment you want to pick.callback(err, item)
- (optional) called when the item has been enchanted
callback(err, item)
callback(err)
See bot.openVillager(villagerEntity)
.
Fires when the trading window has successfully been opened.
Fires when the trading window closes.
Fires when a slot in the trading window has updated.
Fires when villager.trades
is loaded.
Array of trades.
Looks like:
[
{
firstInput: Item,
output: Item,
hasSecondItem: false,
secondaryInput: null,
disabled: false,
tooluses: 0,
maxTradeuses: 7
},
{
firstInput: Item,
output: Item,
hasSecondItem: false,
secondaryInput: null,
disabled: false,
tooluses: 0,
maxTradeuses: 7
},
{
firstInput: Item,
output: Item,
hasSecondItem: true,
secondaryInput: Item,
disabled: false,
tooluses: 0,
maxTradeuses: 7
}
]
Name of the scoreboard.
The title of the scoreboard (does not always equal the name)
An object with all items in the scoreboard in it
{
wvffle: { name: 'wvffle', value: 3 },
dzikoysk: { name: 'dzikoysk', value: 6 }
}
An array with all sorted items in the scoreboard in it
[
{ name: 'dzikoysk', value: 6 },
{ name: 'wvffle', value: 3 }
]
Title of boss bar, instance of ChatMessage
Percent of boss health, from 0
to 1
Number of boss bar dividers, one of 0
, 6
, 10
, 12
, 20
Boss bar entity uuid
Determines whether or not to darken the sky
Determines whether or not boss bar is dragon bar
Determines whether or not boss bar creates fog
Determines what color the boss bar color is, one of pink
, blue
, red
, green
, yellow
, purple
, white
Create and return an instance of the class bot.
options
is an object containing the optional properties :
- username : default to 'Player'
- port : default to 25565
- password : can be omitted (if the tokens are also omitted then it tries to connect in offline mode)
- host : default to localhost
- version : default to automatically guessing the version of the server. Example of value : "1.12.2"
- clientToken : generated if a password is given
- accessToken : generated if a password is given
- logErrors : true by default, catch errors and log them
- keepAlive : send keep alive packets : default to true
- checkTimeoutInterval : default to
30*1000
(30s), check if keepalive received at that period, disconnect otherwise. - loadInternalPlugins : defaults to true
- plugins : object : defaults to {}
- pluginName : false : don't load internal plugin with given name ie.
pluginName
- pluginName : true : load internal plugin with given name ie.
pluginName
even though loadInternalplugins is set to false - pluginName : external plugin inject function : loads external plugin, overrides internal plugin with given name ie.
pluginName
- pluginName : false : don't load internal plugin with given name ie.
- chat
- colorsEnabled
- viewDistance
- difficulty
- showCape
- chatLengthLimit : the maximum amount of characters that can be sent in a single message. If this is not set, it will be 100 in < 1.11 and 256 in >= 1.11.
Your own entity. See Entity
.
All nearby entities. This object is a map of entityId to entity.
Use this to find out your own name.
Coordinates to the main spawn point, where all compasses point to.
Bot's player object
{
username: 'player',
displayName: { toString: Function }, // ChatMessage object.
gamemode: 0,
ping: 28,
entity: entity, // null if you are too far away
}
Map of username to people playing the game.
This is an array of pattern objects, of the following format: { /regex/, "chattype", "description")
- /regex/ - a regular expression pattern, that should have at least two capture groups
- 'chattype' - the type of chat the pattern matches, ex "chat" or "whisper", but can be anything.
- 'description' - description of what the pattern is for, optional.
Choices:
enabled
(default)commandsOnly
disabled
Default true, whether or not you receive color codes in chats from the server.
Choices:
far
(default)normal
short
tiny
Same as from server.properties.
If you have a cape you can turn it off by setting this to false.
Total experience points.
Between 0 and 1 - amount to get to the next level.
Number in the range [0, 20] representing the number of half-hearts.
Number, in the range [0, 20] representing the number of half-turkey-legs.
Food saturation acts as a food "overcharge". Food values will not decrease while the saturation is over zero. Players logging in automatically get a saturation of 5.0. Eating food increases the saturation as well as the food bar.
Edit these numbers to tweak gravity, jump speed, terminal velocity, etc. Do this at your own risk.
Time of the day, in ticks.
Time is based on ticks, where 20 ticks happen every second. There are 24000 ticks in a day, making Minecraft days exactly 20 minutes long.
The time of day is based on the timestamp modulo 24000. 0 is sunrise, 6000 is noon, 12000 is sunset, and 18000 is midnight.
Age of the world, in ticks.
Which quick bar slot is selected (0 - 8).
A Window
instance representing your inventory.
The block
that you are currently digging, or null
.
Boolean, whether or not you are in bed.
All scoreboards known to the bot in an object scoreboard name -> scoreboard.
All scoreboards known to the bot in an object scoreboard displaySlot -> scoreboard.
belowName
- scoreboard placed in belowNamesidebar
- scoreboard placed in sidebarlist
- scoreboard placed in list0-18
- slots defined in protocol
An object whose keys are the main control states: ['forward', 'back', 'left', 'right', 'jump', 'sprint', 'sneak'].
Setting values for this object internally calls bot.setControlState.
Only emitted when a player chats publicly.
username
- who said the message (compare withbot.username
to ignore your own chat)message
- stripped of all color and control characterstranslate
- chat message type. Null for most bukkit chat messagesjsonMsg
- unmodified JSON message from the servermatches
- array of returned matches from regular expressions. May be null
Only emitted when a player chats to you privately.
username
- who said the messagemessage
- stripped of all color and control characterstranslate
- chat message type. Null for most bukkit chat messagesjsonMsg
- unmodified JSON message from the servermatches
- array of returned matches from regular expressions. May be null
Emitted for every server message which appears on the Action Bar.
jsonMsg
- unmodified JSON message from the server
Emitted for every server message, including chats.
jsonMsg
- unmodified JSON message from the server
Fires after you successfully login to the server.
You probably want to wait for the spawn
event
before doing anything though.
Emitted once after you log in and spawn for the first time and then emitted when you respawn after death.
This is usually the event that you want to listen to before doing anything on the server.
Emitted when you change dimensions and just before you spawn. Usually you want to ignore this event and wait until the "spawn" event instead.
Emitted when the server changes any of the game properties.
Emitted when the server sends a title
text
- title's text
Emitted when it starts or stops raining. If you join a server where it is already raining, this event will fire.
Emitted when the server sends a time update. See bot.time
.
Emitted when the bot is kicked from the server. reason
is a chat message explaining why you were kicked. loggedIn
is true
if the client was kicked after successfully logging in,
or false
if the kick occurred in the login phase.
Emitted when you are no longer connected to the server.
Fires when you cannot spawn in your bed and your spawn point gets reset.
Fires when you die.
Fires when your hp or food change.
An entity picked up an item.
collector
- entity that picked up the item.collected
- the entity that was the item on the ground.
An entity is attached to a vehicle, such as a mine cart or boat.
entity
- the entity hitching a ridevehicle
- the entity that is the vehicle
Fires when a block updates. Both oldBlock
and newBlock
provided for
comparison.
Note that oldBlock
may be null
.
Fires for a specific point. Both oldBlock
and newBlock
provided for
comparison.
Note that oldBlock
may be null
.
Fires when a chunk has updated. point
is the coordinates to the corner
of the chunk with the smallest x, y, and z values.
Fires when the client hears a named sound effect.
soundName
: name of the sound effectposition
: a Vec3 instance where the sound originatesvolume
: floating point volume, 1.0 is 100%pitch
: integer pitch, 63 is 100%
Fires when the client hears a hardcoded sound effect.
soundId
: id of the sound effectsoundCategory
: category of the sound effectposition
: a Vec3 instance where the sound originatesvolume
: floating point volume, 1.0 is 100%pitch
: integer pitch, 63 is 100%
Fires when a note block goes off somewhere.
block
: a Block instance, the block that emitted the noiseinstrument
:id
: integer idname
: one of [harp
,doubleBass
,snareDrum
,sticks
,bassDrum
].
pitch
: The pitch of the note (between 0-24 inclusive where 0 is the lowest and 24 is the highest). More information about how the pitch values correspond to notes in real life are available on the official Minecraft wiki.
Fires when the client observes a block in the process of being broken.
block
: a Block instance, the block being brokendestroyStage
: integer corresponding to the destroy progress (0-9)
Fires when the client observes a block stops being broken. This occurs whether the process was completed or aborted.
block
: a Block instance, the block no longer being broken
block
- the block that no longer exists
block
- the block that still exists
Fires when the bot moves. If you want the current position, use
bot.entity.position
and for normal moves if you want the previous position, use
bot.entity.position.minus(bot.entity.velocity)
.
Fires when the bot is force moved by the server (teleport, spawning, ...). If you want the current position, use
bot.entity.position
.
Fires when you mount an entity such as a minecart. To get access
to the entity, use bot.vehicle
.
To mount an entity, use mount
.
Fires when you dismount from an entity.
Fires when you begin using a workbench, chest, brewing stand, etc.
Fires when you may no longer work with a workbench, chest, etc.
Fires when you sleep.
Fires when you wake up.
Fires when bot.experience.*
has updated.
Fires when a scoreboard is added.
Fires when a scoreboard is deleted.
Fires when a scoreboard's title is updated.
Fires when the score of a item in a scoreboard is updated.
Fires when the score of a item in a scoreboard is removed.
Fires when the position of a scoreboard is updated.
Fires when new boss bar is created.
Fires when new boss bar is deleted.
Fires when new boss bar is updated.
Returns the block at point
or null
if that point is not loaded.
See Block
.
Returns the block at which bot is looking at or null
maxSteps
- Number of steps to raytrace, defaults to 256.vectorLength
- Length of raytracing vector, defaults to5/16
.
Returns true or false depending on whether the bot can see the specified block
.
Finds the nearest block to the given point.
options
- Additional options for the search:point
- The start position of the search.matching
- A function that returns true if the given block is a match. Also supports this value being a block id or array of block ids.maxDistance
- The furthest distance for the search, defaults to 16.
This is a simple function, to be used for simple things, for a more complete search using more optimals algorithm, use mineflayer-blockfinder instead which have a very similar API.
Returns whether block
is diggable and within range.
Returns a list of Recipe
instances that you could use to craft itemType
with metadata
.
itemType
- numerical item id of the thing you want to craftmetadata
- the numerical metadata value of the item you want to craftnull
matches any metadata.minResultCount
- based on your current inventory, any recipe from the returned list will be able to produce this many items.null
is an alias for1
.craftingTable
- aBlock
instance. Ifnull
, only recipes that can be performed in your inventory window will be included in the list.
The same as bot.recipesFor except that it does not check wether the bot has enough materials for the recipe.
End the connection with the server.
Gracefully disconnect from the server with the given reason (defaults to 'disconnect.quitting').
Requests chat completion from the server.
str
- String to complete.callback(matches)
matches
- Array of matching strings.
assumeCommand
- Field sent to server, defaults to false.sendBlockInSight
- Field sent to server, defaults to true. Set this option to false if you want more performance.
Sends a publicly broadcast chat message. Breaks up big messages into multiple chat messages as necessary.
Shortcut for "/tell ". All split messages will be whispered to username.
Adds a regex pattern to the bot's chat matching. Useful for bukkit servers where the chat format changes a lot.
pattern
- regular expression to match chatchatType
- the event the bot emits when the pattern matches. Eg: "chat" or "whisper"- 'description ' - Optional, describes what the pattern is for
See the bot.settings
property.
Injects a Plugin.
plugin
- function
function somePlugin(bot, options) {
function someFunction() {
bot.chat('Yay!');
}
bot.someFunction = someFunction;
}
var bot = mineflayer.createBot(...);
bot.loadPlugin(somePlugin);
bot.once('login', function() {
bot.someFunction(); // Yay!
});
Injects plugins see bot.loadPlugin
.
plugins
- array of functions
Sleep in a bed. bedBlock
should be a Block
instance which is a bed. cb
can have an err parameter if the bot cannot sleep.
Return true if bedBlock
is a bed
Get out of bed. cb
can have an err parameter if the bot cannot wake up.
control
- one of ['forward', 'back', 'left', 'right', 'jump', 'sprint', 'sneak']state
-true
orfalse
Sets all controls to off.
point
- tilts your head so that it is directly facing this point.force
- Seeforce
inbot.look
callback()
optional, called when you are looking atpoint
Set the direction your head is facing.
yaw
- The number of radians to rotate around the vertical axis, starting from due east. Counter clockwise.pitch
- Number of radians to point up or down. 0 means straight forward. pi / 2 means straight up. -pi / 2 means straight down.force
- If present and true, skips the smooth server-side transition. Specify this to true if you need the server to know exactly where you are looking, such as for dropping items or shooting arrows. This is not needed for client-side calculation such as walking direction.callback()
optional, called when you are looking atyaw
andpitch
Changes the text on the sign.
Equips an item from your inventory.
item
-Item
instance. Seewindow.items()
.destination
"hand"
-null
aliases to this"head"
"torso"
"legs"
"feet"
callback(error)
- optional. called when you have successfully equipped the item or when you learn that you have failed to equip the item.
Remove an article of equipment.
item
- the stack of items you wish to tosscallback(error)
- optional, called when tossing is done. if error is truthy, you were not able to complete the toss.
itemType
- numerical id of the item you wish to tossmetadata
- metadata of the item you wish to toss. Usenull
to match any metadatacount
- how many you want to toss.null
is an alias for1
.callback(err)
- (optional) called once tossing is complete
Begin digging into block
with the currently equipped item.
See also "diggingCompleted" and "diggingAborted" events.
Note that once you begin digging into a block, you may not
dig any other blocks until the block has been broken, or you call
bot.stopDigging()
.
block
- the block to start digging intocallback(err)
- (optional) called when the block is broken or you are interrupted.
Tells you how long it will take to dig the block, in milliseconds.
referenceBlock
- the block you want to place a new block next tofaceVector
- one of the six cardinal directions, such asnew Vec3(0, 1, 0)
for the top face, indicating which face of thereferenceBlock
to place the block against.cb
will be called when the server confirms that the block has indeed been placed
The new block will be placed at referenceBlock.position.plus(faceVector)
.
Punch a note block, open a door, etc.
block
- the block to activatecallback(err)
- (optional) called when the block has been activated
Activate an entity, useful for villager for example.
entity
- the entity to activatecallback(err)
- (optional) called when the entity has been activated
Eat / drink currently held item
callback(error)
- called when consume ends
Use fishing rod
callback(error)
- called when fishing ends
Activates the currently held item. This is how you eat, shoot bows, throw an egg, etc.
Deactivates the currently held item. This is how you release an arrow, stop eating, etc.
Use the currently held item on an Entity
instance. This is how you apply a saddle and
use shears.
Attack a player or a mob.
Play an arm swing animation.
hand
can takeleft
orright
which is arm that is animated. Default:right
Mount a vehicle. To get back out, use bot.dismount
.
Dismounts from the vehicle you are in.
Moves the vehicle :
- left can take -1 or 1 : -1 means right, 1 means left
- forward can take -1 or 1 : -1 means backward, 1 means forward
All the direction are relative to where the bot is looking at
slot
- 0-8 the quick bar slot to select.
recipe
- ARecipe
instance. Seebot.recipesFor
.count
- How many times you wish to perform the operation. If you want to craft planks into8
sticks, you would setcount
to2
.null
is an alias for1
.craftingTable
- ABlock
instance, the crafting table you wish to use. If the recipe does not require a crafting table, you may usenull
for this argument.callback
- (optional) Called when the crafting is complete and your inventory is updated.
slot
is in inventory window coordinates (where 36 is the first quickbar slot, etc.).pages
is an array of strings represents the pages.callback(error)
- optional. called when the writing was successfully or an error occurred.
Returns a Chest
instance which represents the chest you are opening.
Returns a Furnace
instance which represents the furnace you are opening.
Returns a Dispenser
instance which represents the dispenser you are opening.
Returns an EnchantmentTable
instance which represents the enchantment table
you are opening.
Returns an Villager
instance which represents the trading window you are opening.
Uses the open villagerInstance
to trade.
Set a command block command
at pos
.
These are lower level methods for the inventory, they can be useful sometimes but prefer the inventory methods presented above if you can.
Click on the current window.
Put the item at slot
in the specified range.
Put the item at slot
in the inventory.
Close the window
.
Transfer some kind of item from one range to an other. options
is an object containing :
window
: the window where the item will be moveditemType
: the type of the moved itemsmetadata
: the metadata of the moved itemssourceStart
andsourceEnd
: the source rangedestStart
anddestEnd
: the dest Range
Open a block, for example a chest.
block
is the block the bot will openClass
is the type of window that will be opened
Open an entity with an inventory, for example a villager.
entity
is the entity the bot will openClass
is the type of window that will be opened
Move an item from sourceSlot
to destSlot
in the current window.
Update bot.heldItem
.
This collection of apis is useful in creative mode. Detecting and changing gamemodes is not implemented here, but it is assumed and often required that the bot be in creative mode for these features to work.
Gives the bot the specified item in the specified inventory slot. If called twice on the same slot before first callback exceeds, first callback will have an error parameter
slot
is in inventory window coordinates (where 36 is the first quickbar slot, etc.).item
can presumably be anything, specified with arbitrary metadata, nbtdata, etc. Ifitem
isnull
, the item at the specified slot is deleted.callback(err)
(optional) is a callback which gets fired when the servers sets the slot
If this method changes anything, you can be notified via bot.inventory.on("windowUpdate")
.
Calls startFlying()
and moves at a constant speed through 3d space in a straight line to the destination.
destination
is a Vec3
, and often the x
and z
coordinates will end with .5
.
This operation will not work if there is an obstacle in the way,
so it is advised to fly very short distances at a time.
When the bot arrives at the destination, cb
is called.
This method does not attempt any path finding. It is expected that a path finding implementation will use this method to move < 2 blocks at a time.
To resume normal physics, call stopFlying()
.
Sets bot.physics.gravity
to 0
.
To resume normal physics, call stopFlying()
.
This method is useful if you want to hover while digging the ground below you.
It is not necessary to call this function before calling flyTo()
.
Note that while flying, bot.entity.velocity
will not be accurate.
Restores bot.physics.gravity
to it's original value.