Skip to main content

Graphs

A special mob's behaviour is a graph. A graph is made of nodes (boxes) and wires (lines between them).

Your server turns each graph into Java code. That is why special mobs run fast, even with many of them.

The Mobs tab​

The Mobs tab has three columns. On the left is the list of your mobs. Click one to see its settings in the middle: its attributes, spawn rules, equipment, extension and drops. On the right is its graph, small and only to look at.

Click Edit on the graph to open it in full size and change it. Back takes you to the three columns again.

Three kinds of nodes​

Triggers start something. They have a red header. "On Hit" runs when the mob hits something. "On Tick" runs every tick, 20 times a second.

Actions do something. "Apply Effect" gives a potion effect. "Strike Lightning" calls lightning.

Values give you information. "Self" is the mob itself. "Nearest Player" finds the closest player.

Two kinds of wires​

  • White wires set the order. They go from one action to the next. A trigger starts the chain.
  • Coloured wires carry values, like an entity, a number or a location. The colour shows the kind of value.

A small example​

"When the mob hits a player, the player gets slow."

  1. Add On Hit. Its Entity is what the mob hit.
  2. Add As and set its type to Player. Connect On Hit's Entity to it. As gives the player in Result, and Matches says if it really was a player.
  3. Add Branch. Connect the white wire from On Hit to it, and Matches to its Condition.
  4. Add Apply Effect. Connect Branch's True to it, and As's Result to its Living Entity.
  5. Set the effect to minecraft:slowness and the seconds to 5.

The fearful_phantom does exactly this. Open it to compare.

Using the canvas​

Do thisTo
Double click the canvasAdd a node there
Drag from a pin and let go on empty spaceAdd a node that fits the wire
Double click a nodeSee its details
Double click a wireAdd a reroute point to tidy it
Drag on the canvasSelect nodes in a box
Space + dragMove the view
ScrollZoom
DeleteDelete what is selected

Arrange nodes in the toolbar lays out the whole graph neatly.

Handy nodes​

NodeWhat it does
BranchDoes one thing or another, by a true or false value
ChanceGives true with a given chance, for a Branch
CooldownGives true if enough time has passed since the last time, for a Branch
DelayWaits, then goes on
Do OnceGoes on only the first time
SwitchPicks one of several ways by a number
TimersRemember when something happened, shared by the whole mob
VariablesRemember a value, shared by the whole mob
MutateReads and changes the properties of something, like a creeper's fuse or a damage amount
Run CommandRuns a command as the console. This is how a mob uses other plugins, like giving money.
BroadcastSends a message to the players in the world or on the server

All nodes are listed in the node reference.

Nodes for other plugins​

Some nodes work with other plugins:

NodeNeedsWhat it does
Fill In PlaceholdersPlaceholderAPIFills placeholders like %player_name% into a text
Give Money, Take Money, BalanceVault and an economy pluginPays a player, takes money or reads how much they have
Cast Mythic SkillMythicMobsLets the mob cast a MythicMobs skill
Spawn Mythic MobMythicMobsSpawns a MythicMobs mob at a place

You can use these nodes on any server. If the plugin is missing, the node does nothing. The mob still works, and /bn problems and the editor show which plugin is missing.

Commands run as the console

Run Command can do anything the console can. Only give bloodnight.command.editor to people you trust.

On Folia​

Folia splits the world into regions. Each region runs on its own. A mob's graph runs in the mob's region, and it can only look at things in that region. Most graphs never notice this, because mobs act on things close to them.

What changes on Folia:

NodeWhat happens far away
Entities Near Location, Entities Near Entity, Nearest Player, Line Trace, Block AtFinds nothing
Has Line Of SightGives false
Launch ProjectileLaunches nothing
Strike Lightning, Spawn Particle, Spawn Potion Cloud, Mutate BlockHappen a tick later
Mutate World (time, weather, difficulty, ...)Happens a tick later
Read World: entities, players and countsAlways fails on Folia and shows a problem
Mutate, Apply Effect, Damage on an entity in another regionFails and shows a problem

On Paper all of these work right away, as always.

Problems​

If a graph has a mistake, the editor shows it in the Problems panel, next to the node it belongs to. A mob with problems does not get its behaviour until they are fixed.