You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# function foo:bar
say This is a normal non-macro command
$say This is a macro line, using $(key_1)!
$teleport @s ~ ~$(key_2) ~
Expected code
NBT structure
Function arguments are represented as NBT compounds. Spigot does not have a data structure to represent an NBT compound, so we have options on how we want to represent this data structure.
Or to save a lot of hassle, we could take inspiration from Rtag and use standard Java objects and primitive types. This would look something like this:
For 1.20.2 compatibility, we can call the execute(CommandFunction, CommandSourceStack, TraceCallbacks, CompoundTag) method instead of having to instantiate the command explicitly
The text was updated successfully, but these errors were encountered:
Description
In Minecraft 1.20.2, Minecraft added support for "macros" (more info here) which lets you run functions with parameters:
Expected code
NBT structure
Function arguments are represented as NBT compounds. Spigot does not have a data structure to represent an NBT compound, so we have options on how we want to represent this data structure.
Say we have the following NBT compound:
CommandAPI NBT compound structure
We could create our own NBT compound data structure:
This would look something like this:
Using Java's Maps
Or to save a lot of hassle, we could take inspiration from Rtag and use standard Java objects and primitive types. This would look something like this:
Usage
This can be used with the CommandAPI's existing
FunctionWrapper.getFunction().execute()
method:Extra details
On an implementation note, we can call functions by instantiating them directly using the
instantiate
method which accepts the tag:We currently use this method here:
CommandAPI/commandapi-platforms/commandapi-bukkit/commandapi-bukkit-nms/commandapi-bukkit-1.20.3/src/main/java/dev/jorel/commandapi/nms/NMS_1_20_R3.java
Lines 331 to 350 in c1399a1
However, we don't call this in 1.20.2:
CommandAPI/commandapi-platforms/commandapi-bukkit/commandapi-bukkit-nms/commandapi-bukkit-1.20.2/src/main/java/dev/jorel/commandapi/nms/NMS_1_20_R2.java
Lines 272 to 282 in c1399a1
For 1.20.2 compatibility, we can call the
execute(CommandFunction, CommandSourceStack, TraceCallbacks, CompoundTag)
method instead of having to instantiate the command explicitlyThe text was updated successfully, but these errors were encountered: