meter - a block is 1 meter cubed, or 1x1x1.
The id of blocks and items. See the output of examples/reflect.js for a full listing of names.
Which side of a block, if any.
North
South
Down
Up
East
West
Represents a 3D coordinate/location in meters.
Example:
var point = new mf.Point(0, 0, 0);
Number, south
Number, up
Number, west
Return type: | Point |
---|---|
Returns: | A new point with each coordinate rounded down to the nearest integer. |
Return type: | |
---|---|
Returns: | A new Point offset by the amount specified. |
Parameters: |
|
Return type: | Point |
---|---|
Returns: | A new point with each term offset by other. |
Parameters: | other (mf.Point) – The point to add. |
Return type: | Point |
---|---|
Returns: | A new point with each term subtracted by other. |
Parameters: | other (mf.Point) – The point to subtract. |
Return type: | Point |
---|---|
Returns: | A new point with each term multiplied by scalar. |
Parameters: | other (Number) – The number to multiply by. |
Return type: | Number |
---|---|
Returns: | The Euclidean distance from the point to other. |
Parameters: | other (mf.Point) – The point to compute the distance to. |
Return type: | Boolean |
---|---|
Returns: | Whether or not the points are equal. |
Parameters: | other (mf.Point) – The point to check. |
Return type: | String |
---|---|
Returns: | The point represented in text form. |
Contains a snapshot of an entity’s state.
Number, the id of this entity.
Number, range [0, 2pi], rotation around vertical axis. 0 is -z (east). pi/2 is -x (north), etc.
Number, range [-pi/2, pi/2], 0 is parallel to the ground. pi/2 is up. -pi/2 is down.
Boolean, true if you are not free-falling.
Number, distance from ground to eyes. 0 for non-humanoid entities.
Additional properties when type is mf.EntityType.Player:
- username¶
String
- held_item¶
mf.ItemType, the item the player is holding in their hand
- effects¶
Object, maps mf.StatusEffectType to mf.StatusEffect
Additional properties when type is mf.EntityType.Mob:
- mob_type¶
Additional properties when type is mf.EntityType.Pickup:
Represents an item or stack of items.
Number, defaults to 1
Number, defaults to 0
Examples:
var item1 = new mf.Item(mf.ItemType.Dirt, 64)
var item2 = new mf.Item(mf.ItemType.StoneSword)
Represents a block placed in the world
Number, defaults to 0
Number, defaults to 0, light from local sources (not the sky)
Number, defaults to 0, potential light from sky if it was daytime
Represents the health and food status of the player
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
Number, currently always 0
Parameters: | path (String) – The filepath to the script including the extension. |
---|
Runs a script with a path relative to the current script. Modularize your bot by using this function to import components. This method will not run a script twice.
Call a function later.
Parameters: |
|
---|---|
Returns: | an ID which you can use to cancel the timeout. |
Return type: | Number |
Stop a timeout that is in progress
Parameters: | id (Number) – The ID which you got from setTimeout(). |
---|
Execute a function on a set internal.
Parameters: |
|
---|
Stop an interval that is in progress
Parameters: | id (Number) – The ID which you got from setInterval(). |
---|
Returns the number of milliseconds since some arbitrary fixed event in the past.
Prints a line of text to stderr. Useful for debugging.
Parameters: | line (String) – |
---|
Prints a string to stdout. Does not put a newline character at the end. :param String string:
Reads a text file and returns the contents as a string. Returns undefined if the file cannot be opened.
Parameters: | path (String) – The path to the file. |
---|---|
Return type: | String or undefined |
Returns: | Contents of the file as a String. |
Writes a text file with the specified contents.
Parameters: |
|
---|
Return type: | Array of Strings |
---|---|
Returns: | the script’s arguments from the command line invocation. |
Sends a publicly broadcast chat message. Breaks up big messages into multiple chat messages as necessary. If message begins with “/tell <username> ”, then all split messages will be whispered as well.
Parameters: | message (String) – |
---|
Disconnects from server and exits the program.
Parameters: | return_code (Number) – Optional. Defaults to 0. |
---|
Gets the number of items you can stack together.
Parameters: | item (mf.ItemType) – The ID of the item you want to check the stack height of. |
---|---|
Returns: | The number of items of type item you can stack together, or -1 if that item doesn’t exist. |
Return type: | Number |
Returns whether the block type has any physical presence with respect to physics. This is false for air, flowers, torches, etc.
Example:
if (mf.isPhysical(mf.blockAt(some_point).type)) {
// water physics
}
Parameters: | block_type (mf.ItemType) – |
---|---|
Return type: | Boolean |
Returns whether the block type is non-physical and safe to stand in. This returns false for lava, fire, and everything that isPhysical() returns true for.
Parameters: | block_type (mf.ItemType) – |
---|---|
Return type: | Boolean |
Returns whether the block type is diggable. This returns false for air, bedrock, water, lava, etc.
Parameters: | block_type (mf.ItemType) – |
---|---|
Return type: | Boolean |
Return type: | HealthStatus |
---|---|
Returns: | A snapshot of your current health and food status |
Returns the block at the absolute location in the world. If isBlockLoaded() returns false for the point, this function will return some kind of Air.
Parameters: | point (mf.Point) – Coordinates do not need to be rounded. |
---|---|
Return type: | Block |
Parameters: | point (Number) – Coordinates do not need to be rounded. |
---|---|
Return type: | Boolean |
Returns: | whether the map is loaded at the specified point. |
Returns the text of the sign at the specified location, or undefined if the block at the location is not a sign. Lines are separated by ‘n’.
Parameters: | point (mf.Point) – The location of the sign |
---|---|
Return type: | String or undefined |
Returns whether or not you’re able to place your currently equipped item on the face of the block at point. Takes into account distance, whether something is in your way, whether the target block is activatable, and what you’re equipped with.
Parameters: |
---|
Returns a snapshot of your state in the world as an entity. Modifying the object does nothing.
Return type: | Entity |
---|
Sets the input state of a control. Use this to move around, jump, and place and activate blocks. It is as if you are virtually pressing keys on a keyboard. Your actions will be bound by the physics engine, (unless you use the mf.hax functions).
Parameters: |
|
---|
Sets all control states to false.
Looks at the given point specified in absolute coordinates. See also mf.look().
Parameters: |
|
---|
Call this when you’re dead to respawn.
Eat, shoot, throw, etc. your currently equipped item. Throws an exception if your currently equipped item can’t be activated.
An object containing all the online players and their pings. Includes yourself.
Return type: | Object mapping names to Number pings in milliseconds. |
---|
Place the currently equipped block. If the block at point is a chest, furnace, workbench, etc, this will throw an exception. See activateBlock(). If the equipped item is food, this will throw an exception. See setControlState(). This method is considered cheating. See description of canPlaceBlock() for an example of how to place blocks without cheating.
Parameters: |
---|
Same as right-clicking. This is for chests, furnaces, note blocks, etc. Throws an exception if the block is not activatable. This method is considered cheating. See description of canPlaceBlock() for an example of how to activate blocks without cheating.
Parameters: | block (mf.Point) – The coordinates of the block that you want to activate |
---|
Instantly moves you to the position specified. NOTE: Your movement may be rejected by the server. This can happen if you try to go through a wall.
Parameters: | point (mf.Point) – |
---|
Turns on/off gravity. When gravity is off, you will not take fall damage.
Parameters: | value (Boolean) – |
---|
Pretend that water is solid.
Parameters: | value (Boolean) – |
---|
Sends a single attack message to the server.
Parameters: | entity_id (Number) – |
---|
Parameters: | entity_id (Number) – |
---|---|
Return type: | mf.Entity or undefined: |
Returns: | a snapshot of the entity with the given entity id or undefined if the entity id cannot be found. Modifying the object does nothing. |
Begin digging into a block with the currently equipped item. When you finally break through the block, or you are interrupted for any reason, you will get an onStoppedDigging() event.
Parameters: | point (mf.Point) – The location of the block to dig. |
---|
Stops digging.
Looks in a direction.
Parameters: |
|
---|
Returns: | The slot id [0-8] of the selected equipment. |
---|
See the diagrams in clickUniqueSlot().
Selects an equipment slot.
Parameters: | slot (Number) – The id of the slot [0-8] you wish to select. |
---|
See the diagrams in clickUniqueSlot().
Simulates clicking the mouse button as with the real client. Make sure you use openInventoryWindow() and get the onWindowOpened() event before using this function.
Parameters: |
|
---|
See the diagrams in clickUniqueSlot().
Simulates clicking the mouse button as with the real client. Make sure you get the onWindowOpened() event with the correct window id before using this function.
Parameters: |
|
---|
The slot ids are as follows:
Double chest slot ids. Single chest is the top half only.
Furnace slot ids.
Dispenser slot ids.
Crafting Table slot ids.
Inventory slot ids.
Simulates clicking outside of the open window.
Parameters: | button (mf.MouseButton) – Which mouse button to simulate clicking with. |
---|
Opens the inventory window. Will cause an onWindowOpened() event.
Closes the open window.
Returns: | The item in slot. |
---|---|
Return type: | mf.Item |
Parameters: | slot (Number) – The slot id to return the item for. |
See the diagrams in clickUniqueSlot().
Returns: | The item in slot. |
---|---|
Return type: | Item |
See the diagrams in clickUniqueSlot().
Tells what time it is, also known as where the sun or moon is in the sky.
Return type: | Number |
---|---|
Returns: | The number of real life seconds since dawn (6:00am). This ranges from 0 to 1200 since a day is 20 minutes. |
Fill in the ... part of the function. See examples for more information.
Called when the bot successfully logs into a server.
Called when the bot hears a publicly broadcast chat message.
Parameters: |
|
---|
Called when a chat is received that was no spoken by a player. This includes player joined messages, teleporting notifications, etc.
Parameters: | message (String) – All color codes will be removed |
---|
Called every second. See timeOfDay().
Parameters: | seconds (Number) – Number of seconds since dawn. |
---|
Called when blocks are updated. Updated region is a rectangular solid even if not all of the blocks in the region have actually changed.
Parameters: |
---|
Called when a sign is discovered or destroyed or when a sign’s text changes.
Parameters: |
|
---|
Called when you spawn. Happens after connecting and after respawning after death.
Parameters: | world (mf.Dimension) – Either mf.Dimension.Normal or mf.Dimension.Nether. |
---|
Called when your health/food status changes. See also healthStatus().
Called when you die.
Called when an entity is discovered. This can happen when an entity is created or when it comes into view.
Parameters: | entity (mf.Entity) – |
---|
Called when an entity vanishes from known existence. This can happen when an entity is destroyed or when it goes out of view.
Parameters: | entity (mf.Entity) – |
---|
Called when an entity moves or in some other way changes state.
Parameters: | entity (mf.Entity) – |
---|
Called when an entity animates
Parameters: |
|
---|
Called when an effect is observerd on an entity, possibly yourself.
Parameters: |
|
---|
Called when an effect is observerd to have stopped on an entity, possibly yourself.
TODO: Issue #37: this callback is unreliable.
Parameters: |
|
---|
Called when you have stopped digging for some reason.
Parameters: | reason (mf.StoppedDiggingReason) – |
---|
Called when what you are currently equipped with changes. For example, if your pickaxe breaks or you eat food. See also equippedItem(). TODO: equippedItem is not documented
Called when anything in your inventory changes. See also inventoryItem().
Called when you can begin messing with a chest or your inventory.
Parameters: | window_type (mf.WindowType) – |
---|
Called when a line of stardard input is typed in the console.
Parameters: | line (String) – |
---|
Removes the handler from the event.
Example:
mf.onChat(function handleChat(username, message) {
mf.debug("got first chat");
mf.removeHandler(mf.onChat, handleChat);
});
Parameters: |
|
---|