Templates and forms

Every project has the prelude: Templates, Types and Blueprint kinds written in MMS, and the built-in templates the compiler supplies. Call a template like any helper.

Templates

book_pages

Lays out book markup as a book's pages: a --- line starts the next page. The text is a list of lines, or TextFile("books/guide.mmsbook").

book_pages(text: BookText): [Text]
text
BookText
cos

The cosine of an angle in degrees.

cos(degrees: double): double
degrees
double
sin

The sine of an angle in degrees.

sin(degrees: double): double
degrees
double
len

The number of items in a list, fields in an object, or characters in a string.

len(value: any): int
value
any
by_language

A LangText as an object of language code to text; plain text is English.

by_language(text: LangText?): {string: string}
textoptional
LangText?
english

The English text of a LangText, or its first text when it has no English.

english(text: LangText): string
text
LangText
contains

Whether a list holds a value.

contains(list: [any], value: any): bool
list
[any]
value
any
matches

Whether a string matches a regular expression, as a whole.

matches(text: string, pattern: string): bool
text
string
pattern
string
replace

A string with every old replaced by new.

replace(text: string, old: string, new: string): string
text
string
old
string
new
string
named

An asset call such as Texture("art/ruby.png") with an id name, unless it has one: named(texture, "item/ruby").

named(asset: any, name: string): any
asset
any
name
string
kind_of

The kind of a value: "none", "bool", "number", "string", "name", "list", "object", "range", "commands", or "runtime" for a value only known when the pack runs.

kind_of(value: any): string
value
any
hash

A whole number from 0 to 2147483647 made from a string, the same in every build: hash("dungeon:dungeon").

hash(text: string): int
text
string
tell

Sends message to the chat of each player target selects: tell(@a, "Wave ${wave} begins"). The message is text markup, and ${...} in it shows a score, a Global, a selector's names or a constant.

tell(target: Selector, message: Text): Commands
target
Selector
message
Text
title

Shows message in large text in the middle of the screen of each player target selects, with subtitle under it.

title(target: Selector, message: Text, subtitle: Text?): Commands
target
Selector
message
Text
subtitleoptional
Text?
exists

Whether target selects at least one entity, in a function: if (exists(@e[tag=boss])) { ... }.

exists(target: Selector): bool
target
Selector
count

How many entities target selects, in a function: let n = count(@e[type=zombie, distance=..16]).

count(target: Selector): int
target
Selector
actionbar

Shows message just above the hotbar of each player target selects.

actionbar(target: Selector, message: Text): Commands
target
Selector
message
Text
Piece

One structure file as a weighted pool entry: Piece("halls/hall", 3) reads structures/halls/hall.nbt and gives it weight 3. The file becomes the structure <namespace>:halls/hall in the pack. processors is a processor list's id, or the processors written inline: Piece("halls/hall", processors = [BlockRot(integrity = 0.8)]).

Piece(path: string, weight: int = 1, processors: Id<worldgen/processor_list> | ProcessorList = minecraft:empty, projection: Projection = rigid): WeightedElement
path
string
weightdefault 1
int
processorsdefault minecraft:empty
Id<worldgen/processor_list> | ProcessorList
projectiondefault rigid
Projection

Types

BookGeneration

How many times a written book has been copied.

Type BookGeneration = "original" | "copy" | "copy_of_copy" | "tattered"
LangText

Text in English, or one text per language: { en_us = "Ruby", de_de = "Rubin" }.

Type LangText = string | {string: string}

Forms of expression

Operators and literals are forms of expression. What one means depends on the type expected where it is written, so 1..3 is a uniform number in a loot pool's rolls and bounds in a predicate. This is the shorthand the language builds in.

Range

lo..hi, a range. Either end can be left out.

where IntNumberProviderRef goes

1..3 where a number provider goes: a uniform number from 1 to 3.

where FloatNumberProviderRef goes

0.5..2 where a number provider goes: a uniform number from 0.5 to 2.

where IntRange goes

1..3, 1.. or ..3 where bounds go.

where FloatRange goes

0.5..2, 0.5.. or ..2 where bounds go.

where MinMaxBounds goes

1..3, 1.. or ..3 where bounds go.

Not

!x.

where LootCondition goes
where MaterialCondition goes

!a on a surface condition.

And

a && b && .... A chain of && is one form, with every term; parentheses keep a group.

where LootCondition goes

a && b on loot conditions: true when every term is.

Or

a || b || .... A chain of || is one form, with every term; parentheses keep a group.

where LootCondition goes

a || b on loot conditions: true when any term is.

Sum

a + b.

where DensityFunction goes
Difference

a - b.

where DensityFunction goes
Product

a * b.

where DensityFunction goes
where ItemStackTemplate goes

diamond * 4: a stack of four diamonds.

Quotient

a / b.

where DensityFunction goes
Negation

-x, where x is not a number.

where DensityFunction goes
BareId

A bare id, such as diamond or minecraft:diamond.

where LootPoolEntry goes
TagRef

A tag, such as #logs.

where LootPoolEntry goes
NumberLiteral

A number.

where VerticalAnchor goes
ListLiteral

A list. Lists inside it are flattened into it.

where MaterialRule goes

[a, b] where a surface rule goes: the first rule that applies.