Leaf Nodes - Lyinginbedmon/TricksyFoxes GitHub Wiki
Leaf nodes perform an action, typically something simple like dropping a held item or sleeping, and never have child nodes. They are akin to the leaves on the branches of a tree, and are also known as "action" nodes.
Since a behaviour tree system can largely be said to be only as useful as the extent of its available leaf nodes, there are numerous potential actions that enlightened mobs can undertake.
Index
Combat
These variants all relate to committing adorable violence. Enlightenment is rarely safeguarded solely through pacifism after all.
-
Bow Attack
Inputs: An entity (default: the mob's current attack target), a minimum number of seconds to draw before firing (default: 1)
Makes the mob attack the given entity with a bow held in its main hand.
-
Crossbow Attack
Inputs: An entity (default: the mob's current attack target)
Makes the mob attack the given entity with a crossbow in its main hand. This includes drawing the crossbow before firing if necessary.
-
Melee Attack
Inputs: An entity (default: the mob's current attack target)
Makes the mob attack the given entity with whatever is held in its main hand. Returns failure if the entity is too far away or the attack was otherwise unsuccessful, as well as if the target entity is the mob itself.
-
Potion Attack
Inputs: An entity (default: the mob's current attack target)
Makes the mob throw a splash or lingering potion in its main hand at the given entity.
-
Set Target
Inputs: An entity
Sets or clears the mob's attack target. This has no effect by itself but serves as a means of altering the corresponding system variable. Returns failure if the given entity is a non-viable target (such as an item entity).
-
Shield Against
Inputs: An entity (default: the mob's current attack target)
Makes the mob use a shield in its main-hand to defend against the given entity. Note that this action will run indefinitely, so is best used with a reactive control flow node.
-
Trident Attack
Inputs: An entity (default: the mob's current attack target)
Makes the mob throw a trident held in its main hand at the given entity after a 1 second draw time.
Complex
These actions simulate a predefined behaviour tree, reducing the need to build a necessary behaviour yourself at the cost of lacking finesse.
-
Generic Combat
Inputs: An entity
Attempts to attack the given entity with whatever the mob has available in its main hand, including throwing potions, shooting bows or crossbows, or throwing a trident.
-
Go Break Block
Inputs: A position
Attempts to approach and break the block at the given position, if possible.
-
Go Pick Up
Inputs: An entity
Attempts to approach and pick up the given item, if possible.
Getter
"Getter" actions are so called because they "get" a value from somewhere else, such as by scanning the vicinity of the mob or retrieving a specific detail about someone else. Each of these variants requires an appropriate non-system local whiteboard entry to output their result in.
-
Distance To
Inputs: One position, and the position to measure from (default: the mob's current position)
Outputs: A number
Returns the distance between the two positions.
-
Get Assailant
Inputs: An entity (default: the mob)
Outputs: An entity (default: the mob)
Retrieves the most recent entity that attacked the given entity, if any.
-
Get Bark
Inputs: An entity (default: the mob)
Outputs: A number between 0 and 4
Retrieves the current bark of the given entity, if it is a tricksy mob. This can be used to make tricksy mobs to react to one another's behaviour.
-
Get Health
Inputs: An entity (default: the mob)
Outputs: A number
Retrieves the current health of the given entity.
-
Get Held Item
Inputs: An entity (default: the mob), and a yes/no (default: no) if it should check the offhand instead of the main-hand
Outputs: An item
Retrieves the current held item in the given entity's main-hand (optionally: its offhand instead).
Interact
These actions typically concentrate on interacting with blocks and other mobs, most commonly as though they were a player right-clicking on them.
-
Activate Block
Inputs: A position
Activates the given block as though it were right-clicked by a player, provided it is within range. Returns failure if it is too far away or the right-click didn't do anything.
-
Break Block
Inputs: A position
Attempts to break the block at the given position, if it is within reach and the mob has at least the minimum capacity to break it.
-
Use Item
Inputs: A yes/no (default: no) to stop using the item instead
Attempts to use the item held in the main hand, if any. Returns failure if it does not have a use functionality.
-
Use Item On
Inputs: A block position or entity
Interacts with the given position or entity using the mainhand item, such as to bonemeal crops, place blocks, or shear sheep. Affects the held item accordingly and returns failure if the interaction failed, such as due to distance, or the specified entity was invalid.
Items
These actions deal with manipulating inventories, both in the context of the mob's equipment and held items and inside of inventories like furnaces and chests.
-
Drop Held Item
Inputs: An optional amount of items to drop
Causes the mob to drop the item held in its mainhand (either the entire stack or up to N units of it, depending on the input number).
-
Equip Item
Inputs: An optional item filter
Makes the mob attempt to equip the armour item in its mainhand, returning failure if it can't for whatever reason or the item doesn't match the filter.
-
Extract Item
Inputs: The block position of the inventory to extract from, the side of the inventory to extract from (default: down), and an optional item filter
Makes the mob extract one (1) item matching the filter from whatever slot(s) are available from the given side of the given inventory. Returns failure if the inventory is too far away, if there's nothing to extract or that matches the filter, or if the mob's mainhand cannot hold the item that would be extracted.
-
Insert Item
Inputs: The block position of the inventory to insert into, the side of the inventory to insert into (default: up), an optional amount of items to insert, and an optional item filter
Makes the mob attempt to insert the contents of its mainhand into the given face of the given inventory, provided it matches the filter. Returns failure if the inventory is too far away, if it has nothing to insert or not enough to meet the amount set, or if the item just won't fit in the inventory.
-
Pick Up
Inputs: A target item entity
The mob attempts to pick up the specified item, either entirely or as much as it can based on what it is currently holding in its main hand. Returns failure if the entity isn't an item, if the entity is too far away, or if the mob can't pick up the item at all because of its current held item.
-
Swap Held Items
Simply put, this causes the mob to swap the item in its mainhand with the item in its offhand.
-
Unequip Item
Inputs: The optional index of the armour slot to unequip
Causes the equipped armour item in the given slot, or the first occupied item (helmet -> boots) if no slot is provided, to be dropped as an item entity. Returns failure if the item cannot be unequipped or the slot is empty.
- 0 = Boots
- 1 = Pants
- 2 = Chestplate
- 3 = Helmet
Values above 3 or below 0 are clamped to be 3 or 0 respectively.
Miscellaneous
-
Bark
Inputs: A number between 0 and 4
Causes the mob to issue an audible and visible alert, corresponding to the input number, discernible for up to 3 seconds
-
0 = None
-
1 = Happy
-
2 = Curious
-
3 = Confused
-
4 = Alert
-
Go To
Inputs: A block position
Causes the mob to move towards the given position, if possible. Only returns failure if no path to the position exists.
-
Look Around
Inputs: A number (default: 4)
Causes the mob to look at a random position for a given number of seconds.
-
Look At
Inputs: A position or entity (default: the mob's attack target)
Makes the mob look at the given target. Note that this does not update their looking afterwards, should they or the target move from their initial position.
-
Set Home
Inputs: A block position
Sets or clears the mob's home position. This has no effect by itself but serves as a means of altering the corresponding system variable.
-
Sleep
Puts the mob to sleep. Whilst in this state undisturbed, they regain health at a rate of half a heart per second. This variant fails if the mob takes damage or is no longer on solid ground, but otherwise will continue endlessly. It's therefore best to tie it together with a condition inside of a Reactive control node.
-
Stop
Ceases any active pathfinding activity, causing the mob to stop wherever it is currently standing
-
Wait
Inputs: A duration integer (1 by default)
Makes the mob take no action for a number of seconds. This can be useful when an external process needs time to complete before the mob does something else, like waiting for a furnace to smelt.
-
Wander
Inputs: A position or region and a number (default: 4) defining how far to wander from the position
Makes the mob try to move to a random accessible position within the area. Returns failure if it cannot readily find anywhere to go.
Numbers
These actions perform numerical operations vital to more complex calculations.
-
Get Coordinate
Inputs: A position and a number between 0 and 2 (default: 0)
Outputs: A number
Returns the coordinate of the position in the order of: 0 = X, 1 = Y, 2 = Z
-
Increment (add)
Inputs: Two number or position values, and a yes/no (default: no) if the action should instead decrement (subtract)
Outputs: A number or position
Combines the two values and outputs the result. Optionally, can subtract the second value from the first instead.
-
Make Position
Inputs: Three numbers (default: 0 for each)
Outputs: A position
Creates a position in 3D space with the corresponding coordinates.
-
Modulus
Inputs: Two number values
Outputs: A number
Returns the remainder when all multiples of the second number are subtracted from the first number. For example: 8 % 3 = 2
-
Multiply
Inputs: Two number or position values, and a yes/no (default: no) if the action should instead divide
Outputs: A number or position
Multiplies the two values together and outputs the result. Optionally, can divide the first value by the second value instead.
-
Offset Position
Inputs: Two position values, and a number (default: 1)
Outputs: A position
Offsets the first position a number of steps by the direction of the second. For example: [8, 6, 1][NORTH] offset [9] by [7, 4, 5][UP] = [8, 15, 1][NORTH]
Search
These actions scan an area in the world and return what they can find.
-
Get Blocks
Inputs: A region or position around which to search (default: the mob's position), a range to search (default: 4 blocks)
Outputs: A list of positions
Cooldown: 1 second
Identifies all blocks within the search area.
-
Get Crops
Inputs: A region or position around which to search (default: the mob's position), a range to search (default: 4 blocks)
Outputs: A list of positions
Cooldown: 1 second
Identifies all blocks within the search area with the #crops
block tag. Note that this does not discriminate between freshly-planted seeds and fully-grown crops, nor between stems and fruits.
-
Nearby Blocks
Inputs: A region or position around which to search (default: the mob's position), a range to search (default: 4 blocks), and an optional position or item filter (default: stone)
Outputs: A list of positions
Cooldown: 1 second
Identifies all matching blocks (or all stone blocks if no filter is provided) around the given position or within the given region. The filter will match by item stack (ie. the block's state when in your inventory) or by matching to a position in the same world (eg. a diamond ore block deliberately placed nearby). Note that the filter does NOT try to match blockstate values, such as whether a given crop block is fully grown.
-
Nearby Creatures
Inputs: A region or position around which to search (default: the mob's position), a range to search (default: 4 blocks), and an optional entity filter (default: monsters)
Outputs: A list of entities
Cooldown: 1 second
Identifies all matching mobs (or all monsters if no filter is provided) around the given position or within the given region.
-
Nearby Inventories
Inputs: A region or position around which to search (default: the mob's position), a range to search (default: 4 blocks)
Outputs: A list of positions
Cooldown: 1 second
Identifies all inventories (chests, barrels, furnaces, etc) around the given position or within the given region.
-
Nearby Items
Inputs: A region or position around which to search (default: the mob's position), a range to search (default: 4 blocks), and an optional item filter
Outputs: A list of entities
Cooldown: 1 second
Identifies the all matching item entities (or all if no filter is provided) around the given position or within the given region.
-
Nearby Minables
Inputs: A region or position around which to search (default: the mob's position), a range to search (default: 4 blocks)
Outputs: A list of positions
Cooldown: 1 second
Identifies all minable blocks (blocks with hardness of 0 or greater and a collision box) around the given position or within the given region.
-
Nearby Spaces
Inputs: A region or position around which to search (default: the mob's position), a range to search (default: 4 blocks)
Outputs: A list of positions
Cooldown: 1 second
Identifies all unoccupied or replaceable block positions around the given position or within the given region.
Special
These actions are usually exclusive to specific mobs and have significantly more dramatic flair.
-
Blockade
Exclusivity: Only available to Tricksy Goats
Cooldown: 5-10 minutes
Renders the goat immune to all damage and knockback, as well as preventing all physical movement through its position, for the next 15 seconds.
-
Charge Attack
Exclusivity: Only available to Tricksy Goats
Inputs: An entity
Cooldown: 30-300 seconds, or 5-15 seconds for screaming goats
Performs a ramming charge at the given entity, as long as they are reachable and within 4-16 blocks of the goat, causing significant knockback on the first entity encountered while doing so.
-
Foxfire
Exclusivity: Only available to Tricksy Foxes
Inputs: A position
Cooldown: 3-6 seconds
Launches a flaming projectile at a visible position within 16 blocks, either placing a temporary light source at the position or igniting candles, campfires, etc. there instead. The projectile flies for up to 5 seconds and can bounce off of intervening blocks in its path.
-
Long Jump
Exclusivity: Only available to Tricksy Goats
Inputs: A position
Cooldown: 1 second
Causes the goat to launch itself into the air with the goal of hopefully landing at the given position within 5 blocks. Accuracy not guaranteed.
-
Pray
Exclusivity: Only available to Tricksy Foxes
Inputs: A position and a number (default: 1)
Cooldown: 1 second
Causes the fox to pray at a prescient candle at the given position, altering its redstone signal output to the given number.
-
Stance
Exclusivity: Only available to Tricksy Foxes
Inputs: A yes/no (default: no) if the fox should stand back up instead of crouch
Causes the fox to adopt its original quadrupedal stance, allowing it to move faster and pass through 1-block-tall openings.
Values
These actions manipulate values stored in a whiteboard, usually exclusively the personal whiteboard of the mob executing it.
-
Clear Value
Inputs: A non-system local whiteboard reference
Erases the contents of the given reference.
-
Columnar Sort
Inputs: A non-system position or entity reference and a position (default: the mob's current position)
Cooldown: 1 second
Organises the contents of the given reference into a series of ascending columns radiating away from the given position. This is useful for contexts like branch mining. Returns failure if there is nothing to sort.
-
Contiguous Sort
Inputs: A non-system position or entity reference and a position (default: the mob's current position)
Cooldown: 1 second
Organises the contents of the given reference to minimise distance between points. This is useful for most common generic mining contexts, such as chopping down trees or harvesting crops, as it minimises the amount the mob has to move around. Returns failure if there is nothing to sort.
-
Copy Value
Inputs: A non-system whiteboard reference (default: empty)
Outputs: A non-system local whiteboard reference
Copies the current value of the input reference over that of the output. Fails if the references are of different types.
-
Cycle Value
Inputs: A local whiteboard reference
Cycles the value of the given reference, placing the first entry in the list at the bottom and shuffling all others accordingly. Returns failure if the given value is not a list.
-
Nearest Sort
Inputs: A non-system position or entity reference, a position (default: the mob's current position), and a yes/no (default: no) to sort descending instead of ascending
Cooldown: 1 second
Organises the contents of the given reference by distance to the given point, either ascending or descending. Returns failure if there is nothing to sort.
-
Vertical Sort
Inputs: A non-system position or entity reference and a yes/no (default: no) to sort bottom->up instead of top->down
Cooldown: 1 second
Organises the contents of the given reference by X and Z value with descending (optionally: ascending) Y values. This is useful for digging shafts and strip mining. Returns failure if there is nothing to sort.