Skip to content

Expressions & Generation Logic

Tempest051 edited this page Apr 20, 2024 · 19 revisions

Basics

Expressions and logic control all the rule sets that determine whether a structure generates or not, and what happens when one does. The principal is running boolean evaluations, and when an expression's output is true, then the action is allowed ("booleans" are variables which store a "true" or "false" value). An expression will only be true if all variables inside it are also true.
Note: Algebraic variables (a, b, c, etc) will be used to represent values you would use with operators.

You can use the "pages" column to the right to jump to sections within this page as it's rather long, or use the repository search function.

Logic Operators

  • !a - NOT. Inverts the value. Returns true when the variable is false.
  • a & b - AND. Returns true if both a and b are true.
  • a | b - OR. Returns true if either a or b is true.
  • a ?? b :: c - IF ELSE. If a is true, return b, else return c.
  • (a) - Parentheses. Groups variables and validates it (like in normal algebra).

IF statement Examples.

Global Variables

These are constants, used in complex expressions, such as IF ELSE statements.

  • true - Always returns true.
  • false - Always returns false.
  • global:a - Evaluates the global toggle a. These can be set in the config file. For example, by default, the expression global:decayTreeLeaves is used in the tree transformer to determine whether tree leaves should be decayable after spawn.

WIP

/ Special Character: Quotes ""
/
/ If you need any of these characters inside a variable, use quotes. Example: "VariableWithAn&" | "VariableWithQuotes()" or "Variable with spaces".
/
/ Special Character: Backslash \ /
/ You can also use a backslash \ to mark the next character to be used literally instead. Example: VariableWithAn& | VariableWithQuotes() | Variable\ with\ spaces becomes VariableWithAmpersand& | VariableWithQuotes() | Variable with spaces
/
/ To use backslashes or quotes inside variable names, you can of course escape them too, e.g. VariableWithQuotes" and VariableWithBackslash\.
/
/ Also, note that whitespace is optional and notes the beginning of the next token. Example: Some\ Variable & Some\ Other\ Variable becomes Some Variable & Some Other Variable.

Dependency Expressions

Used to determine whether a structure or loot table will load, based on its dependencies.

  • mod:a - Returns true if the mod with the Mod ID 'a' is currently installed.
  • strc:a - Returns true if a structure with ID 'a' is currently loaded.
  • reg:a.b - Finds the registry with ID 'a', and evaluates the variable 'b' in it.

Examples

Biome And Dimension Expressions

Used to evaluate biome checks.

  • id=a - Returns true if the ID matches 'a'. Takes an alphabetical ID for biomes and numerical for dimensions.
  • type=a - Returns true if the biome matches the biome dictionary type 'a'. You can find out biome types with /#biome.
  • name=a - Returns true if the biome has the name 'a'.
    Note: The "type" expression, when used for dimensions, is supposed to call on a library which assigns type tags to dimensions. Currently though, no mods utilize this system so it is effectively useless in the dimensions tab outside of vanilla ones. Also, RC can't generate structures in the End, so -1 is an invalid value.

Examples

Block Expressions

Used to evaluate block checks.

  • metadata=a-b - Returns true if the metadata is within the specified range (a to b).
  • metadata=a - Returns true if the metadata is exactly the specified value.
  • property[a]=b - Returns true if the block has the property with name a, and its value is b.
  • id=a - Returns true if the block has the specified ID.

If the block is positioned (e.g using rays in the placer window), the following variables are also available:

  • is:a - Returns true if the block matches the criteria. Valid values for 'a' are: leaves, air, foliage, replaceable, liquid, water, lava.
  • sustains.a (Note the ".") - Returns true if the block sustains a given plant type. 'a' can be either of: trees, mushrooms, cacti.
  • blocks:a - Returns true if 'a' blocks the designated thing. Valid values for 'a' are: movement, light.

Examples

A command expression defines if a command is matched (e.g. should be executed).

  • name=a - Returns true if the executing player / block has the specified name.
  • canUseLevel:a - Returns true if the executing player / block has the specified permission level.

Environment Expressions

An environment expression defines if a certain environment matches the given criteria (e.g. biome, village type etc.). These expressions are mostly used in Transformers.

  • biome.a - Followed by a biome expression variable.
  • dim.a - Followed by a dimension expression variable.
  • dep.a - Followed by a dependency expression variable.
  • vtype=a - Returns true if the environment is a village with the specified type. Enter "None" to match environments outside villages.
  • gen.a - Followed by a structure generation info expression variable (of the generation info currently in use).
  • variable.a - Returns the value of one of the local variables (WIP) declared for the structure.

Examples can be found in Transformers.

Generation Info Expressions (WIP)

Registry Expressions (WIP)

Examples

Dependency Examples

mod:mekanism - only load the structure of Mekanism is installed.

mod:mekanism & mod:ebwizardry - only load the structure of both Mekanism and Electroblob's Wizardry is installed, if the structure uses blocks from both.

(mod:mekanism | mod:ic2) & !mod:ebwizardry - Only load the structure if Mekanism or IC2 is installed, and Electroblob's Wizardry is not installed. Can be used for only enabling structures themed around these two tech mods, but not if that magic mod is installed.

strc:LargeOak - Only load the structure if another structure called LargeOak is also loaded. Can be used for things like dynamic structure pieces which depend on a parent structure being present.

strc:DarkTower | mod:sakura | strc:LightTower - Only load the structure if either the structures DarkTower or LightTower are loaded, or if the Sakura mod is installed.

Back

Biome Examples

id=plains - Only allow the structure to generate in the plains biome.

!id=plains | !id=forest- Do not allow the structure to generate in the plains or forests biome.

type=BEACH | id=minecraft:desert - Only allow the structure to generate in beach type biomes, or specifically in Minecraft's desert biome.

(type=OCEAN | type=BEACH) & !id=deep_ocean | name=lagoon - Only allow the structure to generate in ocean or beach type biomes, except when that biome has the ID "deep_ocean" or the name "lagoon."

Back

Dimension Examples

id=0 - Only allow the structure to generate in the Overworld.

id=0 | id=-1 - Only allow the structure to generate in the Overworld and the Nether.

!id=0 | id=5 - Allow the structure to generate in every dimension except the Overworld and dimension 5.

Back

Block Examples

id=minecraft:stone - Only allow the structure to generate if the blocks it generates on is Minecraft stone.

!(id=minecraft:wool & metadata=0) - Only allow the structure to generate if the block it generates on is not white wool.

id=minecraft:wool & metadata=1-15 - Only allow the structure to generate on wool blocks of any colour except white.

sustains.trees & !bop:loamy_dirt - Only allow the structure to generate on grass blocks that trees can grow on as long as it isn't Biomes O Plenty loamy dirt.

Back

Positioned Block Examples

!id=minecraft:leaves & is:foliage - Only allow the structure to generate if the block is foliage, but only if it isn't Minecraft leaves.

(!blocks:movement & !is:liquid) | id=minecraft:sand - Used with something like a dynamic movement ray in the placer to look for the surface of the world when generating a structure. The ray will continue moving down as long as it doesn't encounter any solid or liquid blocks, unless that block is sand. Used for something like generating a structure on the surface unless it generates on sand/ in a desert, in which case it keeps tracing until it hits stone/ sandstone and generates it half buried.

Back

IF ELSE Statements

global:decayTreeLeaves ?? true :: false - If the config option decayTreeLeaves is set to true, then allow the structure to generate, otherwise return false and block this structure from generating.

Back

WIP

Clone this wiki locally