2.0 KiB
Cart-Node interactions
As the cart moves thru the environment, it can interact with the surrounding blocks thru a number of handlers in the block definitions. All these handlers are defined as:
function(node_position, cart_luaentity, cart_direction, cart_position)
Arguments:
node_position
- position of the node the cart is interacting withcart_luaentity
- The luaentity of the cart that is entering this block. Will be nil for minecarts moving thru unloaded blockscart_direction
- The direction the cart is movingcart_position
- The location of the cartcart_data
- Information about the cart. This will always be defined.
There are several variants of this handler:
_mcl_minecarts_on_enter
- The cart enters this block_mcl_minecarts_on_enter_below
- The cart enters above this block_mcl_minecarts_on_enter_above
- The cart enters below this block_mcl_minecarts_on_enter_side
- The cart enters beside this block
Mods can also define global handlers that are called for every node. These handlers are defined as:
function(node_position, cart_luaentity, cart_direction, node_definition, cart_data)
Arguments:
node_position
- position of the node the cart is interacting withcart_luaentity
- The luaentity of the cart that is entering this block. Will be nil for minecarts moving thru unloaded blockscart_direction
- The direction the cart is movingcart_position
- The location of the cartcart_data
- Information about the cart. This will always be defined.node_definition
- The definition of the node atnode_position
The available hooks are:
_mcl_minecarts.on_enter
- The cart enters this block
_mcl_minecarts.on_enter_below
- The cart enters above this block
_mcl_minecarts.on_enter_above
- The cart enters below this block
_mcl_minecarts.on_enter_side
- The cart enters beside this block
Only a single function can be installed in each of these handlers. Before installing,
preserve the existing handler and call it from inside your handler if not nil
.