Scripting
asie edited this page 3 months ago

StackUp, as of 0.2.0, adds a rudimentary/barebones scripting system meant for en-masse stack size changes.

Format

The script files have the extension “.stackup” and are put in:

  • ./config/stackup/ (create the directory if it doesn’t exist!) on 1.12.2. They are processed in alphabetical order.
  • data/minecraft/scripts/*.stackup inside datapacks on 1.13+.

They can also be put in subdirectories. Please note that directory names starting with an underscore are reserved for future expansion. The format is as follows:

key1=value1, key2=value2 -> new_stack_size
... (one per line)

As of 0.2.1, you can also use # comment to signify comments.

The key-value pairs are used to filter items which are to be resized by a given line. A few types of them exist:

  • number - supports “=”, “!=”, “>=”, “>”, “<=“, “<” operators, allows comparing against a number.
  • string - supports “=”, “!=”, “~=” operators, allows comparing against a string. Requires wrapping the value in quotes. The “~=” operator is an “approximately equal” operator, it allows you to add asterisks at the beginning and end of compared string (”*apple” will match any string ending in “apple”, say).
  • class - supports “=”, “!=”, “>=”, “>” operators. “>” means that the item’s class extends or implements the class being compared against.
  • boolean - just the key, without a value; can be prefixed with “!” to invert the condition

In addition, keys which point at resource locations (say, “minecraft:sponge”) will evaluate the two parts of it - the domain and path - separately. They also support “*”, which matches all strings in a given part - regardless of “approximately equal” being set or not.

The types of keys currently available are as follows:

  • (0.2.0+) id - string (resource location), compares against the item’s ID, such as “minecraft:apple”.
  • (0.2.0+) size - number, compares against the item’s stack size as it was before entering the script file.
  • (0.2.0+) itemClass - class, compares against the item’s class only.
  • (0.2.0+) blockClass - class, compares against the block’s class only.
  • (0.2.2+) isBlock - boolean, is true if the item has an equivalent block (so if a given item corresponds to a block).
  • (0.3.0+, Minecraft 1.13+) tag - string (resource location), compares against the item’s tag collection.

In additon, there are multiple types of assignments:

  • -> means “set the new stack size to the given value”,
  • += means “add the value to the stack size”,
  • -= means “subtract …”,
  • *= means “multiply by …”
  • /= means “divide by …”

The assigned new stack size values are always clamped to match the maxStackSize value in stackup.cfg!

Tips

  • You can use /stackup reload in-game to reload the stack size rules in single-player. Useful for modpack development! (The values are restored to their original ones before a reload, so don’t worry about that!)

Examples

Set the stack size of all items whose stack size is currently between 48 and 64 to 127:

size>=48, size<=64 -> 127

Multiply the stack size of all items in Quark by 2:

id="quark:*" *= 2

Add 8 to the stack size of all Minecraft items whose IDs end in “apple”:

id~="minecraft:*apple" += 8

Set the stack size of all stackable items whose block extends net.minecraft.block.BlockWall (inclusive) to 16:

itemClass>="net.minecraft.block.BlockWall", size>1 -> 16

(0.2.2+) Set the stack size of all non-blocks added by Rustic to 42:

id="rustic:*", !isBlock -> 42