-
Notifications
You must be signed in to change notification settings - Fork 0
dpconfig methods
A method describes what value in the data pack to modify, how, and where to find it. It takes input from a dpconfig widget, and then uses that to change a value somewhere in the data pack.
A method is an object made up of a transformer and accessors.
A transformer transforms the input into a different, final value. If the users inputs, say, 1, i.e. "True", we can change that to, say, 76 - that's what a transformer does.
A transformer argument can either be an integer, a float, a string, or a function object.
Use either "$input"
or "$in"
for method input.
Use "$slot_name"
to get the value of a slot, $
being a prefix to the slot name.
Anything else will be taken literally, i.e. "owo"
will be "owo"
.
Function objects need a function
key specifying the function name. Here's the list of supported functions and the arguments they require:
Compares argument
and argument1
together.
Uses the key operator
as the comparison operator. Value can be either "=="
(full equality), ">"
(more than) or ">="
.
If the result is true, outputs value in key true
. If false, outputs value in key false
.
Rounds and converts argument
into an integer.
Adds argument
and argument1
together.
Multiplies argument
by argument1
.
Returns the argument
squared.
Returns the square root of argument
.
An accessor describes how to change a value in a particular file - it accesses the value. A method may have multiple accessors if it needs to change multiple different values in either one file or many.
An accessor is described by the following settings:
A value transformer. Not required - if present in an accessor, overwrites the method-wide transformer for this accessor.
Describes the way the value should be modified by the input.
Must be one of the following things:
-
multiply
multiplies the original value by the input -
divide
divides the original value by the input -
add
adds the input to the original value -
subtract
subtracts the input from the original value -
set
overwrites the value with the input -
multiply_int
- multiplies the original value by the input, then converts to an integer -
divide_int
- does a full division, then converts to an integer -
add_int
- adds, then converts to an integer -
subtract_int
- subtracts, then converts to an integer -
remove
- removes a value from an array -
pop
- removes an index from an array
⚠ 0
is the index of the first member of a list/array, not 1
.
Either a single string or a list of strings describing the file path(s).
All files whose paths end in the described file_path
will match and be edited.
For an exact match, add ./
to the beginning of the path string.
For example, data/foo/bar/my_file.json
is acceptable as a file path.
It will match files whose paths look like this: data/foo/bar/my_file.json
AND this: overlay/data/foo/bar/my_file.json
.
If ./overlay/data/foo/bar/my_file.json
is used as a file path, only this one file will match.
my_file.json
is also acceptable, but it will match every file named this way, which is potentially risky.
my_file
is not acceptable as a file path.
The path to the key in the JSON file whose value we're trying to change. The forward slash (/
) is used as the dividing character.
For the sky color in a biome file it would look like this: effects/sky_color
If there's a list/array in the way, use an integer describing the index of the element. In a placed feature file it might look like this: placement/3/max_water_depth
.
⚠ 0
is the index of the first member of a list/array, not 1
.