StructureContext()

A context scoped to a single structure.

new StructureContext()

Fires:
  • event:outOfFuel when a request from this context encounters an out-of-fuel error.
  • event:transact when a player uses the /transact command inside the structure associated with this context.
  • contextClosed when this context is closed,event: usually due to expiring or being invalidated.

Methods

close() → {Promise}

Closes the current context
Returns:
Promise

craft(target, ingredients) → {Promise}

Crafts an item, which is then stored into the given container
Parameters:
Name Type Description
target ContainerReference the output container
ingredients Array.<ItemReference> the ingredients for the recipe
Throws:
Returns:
Promise

fuelInfo() → {Promise.<FuelInfo>}

Obtains detailed fuel usage info for all connections
Throws:
Returns:
Promise.<FuelInfo>

getBlock(x, y, z) → {Promise.<Block>}

Retrieves a block at the given structure-local coordinates. Note that if obfuscation is enabled on the server, some blocks may be replaced with replcraft-native types instead of the expected minecraft types.
Parameters:
Name Type Description
x number the x coordinate of the block (container relative)
y number the y coordinate of the block (container relative)
z number the z coordinate of the block (container relative)
Throws:
Returns:
Promise.<Block>

getEntities() → {Promise.<Array.<Entity>>}

Gets all entities inside the region
Throws:
Returns:
Promise.<Array.<Entity>>

getInventory(target) → {Promise.<Array.<Item>>}

Gets all items from a container such as a chest or hopper
Parameters:
Name Type Description
target ContainerReference the container to target
Throws:
Returns:
Promise.<Array.<Item>>

getPowerLevel(x, y, z) → {Promise.<number>}

Gets a block's redstone power level
Parameters:
Name Type Description
x number the x coordinate of the block (container relative)
y number the y coordinate of the block (container relative)
z number the z coordinate of the block (container relative)
Throws:
Returns:
Promise.<number>

getSignText(x, y, z) → {Promise.<Array.<string>>}

Retrieves the text of a sign at the given coordinates
Parameters:
Name Type Description
x number the x coordinate of the sign (container relative)
y number the y coordinate of the sign (container relative)
z number the z coordinate of the sign (container relative)
Throws:
Returns:
Promise.<Array.<string>>

getSize() → {Promise.<XYZA>}

Retrieves the inner size of the structure
Throws:
Returns:
Promise.<XYZA>

location() → {Promise.<XYZ>}

Retrieves the world coordinate location of the (0,0,0) inner coordinate
Throws:
Returns:
Promise.<XYZ>

moveItem(source, target, amount) → {Promise}

Moves an item between containers
Parameters:
Name Type Default Description
source ItemReference the item to move
target ItemReference | ContainerReference where to move the item
amount number | null null the amount of items to move, or all if null
Throws:
Returns:
Promise

pay(target, amount) → {Promise}

Sends money to a player out of your own account
Parameters:
Name Type Description
target string the name or UUID of the player
amount number the amount of money to send
Throws:
Returns:
Promise

poll(x, y, z) → {Promise}

Begins polling a block for updates. Note that this catches all possible block updates, but only one block is polled per tick. The more blocks you poll, the slower each individual block will be checked. Additionally, if a block changes multiple times between polls, only the latest change will be reported.
Parameters:
Name Type Description
x number the x coordinate of the block (container relative)
y number the y coordinate of the block (container relative)
z number the z coordinate of the block (container relative)
Fires:
Throws:
Returns:
Promise

pollAll() → {Promise}

Begins polling all blocks in the structure for updates. Updates will be very slow!
Fires:
Throws:
Returns:
Promise

async request(args) → {Promise.<Object>}

Makes a request to the server and includes this context's ID. You probably shouldn't use this directly.
Parameters:
Name Type Description
args Object the request to make
Throws:
Returns:
Promise.<Object>

setBlock(x, y, z, blockData, sourcenullable, targetnullable) → {Promise}

Sets a block at the given structure-local coordinates. The block must be available in the specified source chest or the structure inventory. Any block replaced by this call is stored in the specified target chest or the structure inventory, or dropped in the world if there's no space.
Parameters:
Name Type Attributes Description
x number the x coordinate of the block (container relative)
y number the y coordinate of the block (container relative)
z number the z coordinate of the block (container relative)
blockData Block
source ContainerReference <nullable>
the container to take the block from. Defaults to structure inventory.
target ContainerReference <nullable>
the container to put drops into. Defaults to structure inventory.
Throws:
Returns:
Promise

setFuelLimit(strategy, limit) → {Promise}

Limits the amount of fuel that will be consumed from a given strategy for this context. Calling this multiple times will remember the previous amount used, so calling it twice with the same limit has no further effect. You must raise the limit to allow a strategy that has reached it to consume more fuel.
Parameters:
Name Type Description
strategy String the name of the strategy to set the limit for
limit number the maximum fuel that the strategy is allowed to generate
Throws:
Returns:
Promise

setSignText(x, y, z, lines) → {Promise}

Sets the text of a sign at the given coordinates
Parameters:
Name Type Description
x number the x coordinate of the sign (container relative)
y number the y coordinate of the sign (container relative)
z number the z coordinate of the sign (container relative)
lines Array.<string> the lines of text to set the sign to
Throws:
Returns:
Promise

tell(target, message) → {Promise}

Sends a message to a player. The player must be online and inside the structure.
Parameters:
Name Type Description
target string the name or UUID of the player
message string the message to send to the player
Throws:
Returns:
Promise

unpoll(x, y, z) → {Promise}

Stops watching a block for updates
Parameters:
Name Type Description
x number the x coordinate of the block (container relative)
y number the y coordinate of the block (container relative)
z number the z coordinate of the block (container relative)
Throws:
Returns:
Promise

unpollAll() → {Promise}

Stops polling all blocks in the structure.
Throws:
Returns:
Promise

unwatch(x, y, z) → {Promise}

Stops watching a block for updates
Parameters:
Name Type Description
x number the x coordinate of the block (container relative)
y number the y coordinate of the block (container relative)
z number the z coordinate of the block (container relative)
Throws:
Returns:
Promise

unwatchAll() → {Promise}

Stops watching all blocks for updates.
Throws:
Returns:
Promise

watch(x, y, z) → {Promise}

Begins watching a block for updates. Note that this isn't perfectly reliable and doesn't catch all possible updates.
Parameters:
Name Type Description
x number the x coordinate of the block (container relative)
y number the y coordinate of the block (container relative)
z number the z coordinate of the block (container relative)
Fires:
Throws:
Returns:
Promise

watchAll() → {Promise}

Begins watching all blocks in the structure for updates. Note that this isn't perfectly reliable and doesn't catch all possible updates.
Fires:
Throws:
Returns:
Promise