Skip to content

Writing Functions

RedSponge edited this page Sep 22, 2018 · 1 revision

Writing Functions

Once you've got a FunctionContainer set up, creating a function is as easy as creating a C# Method! So to define a function called "Hello", you'll create a method named "Hello" inside your FunctionContainer class.

public class MyFunctions : FunctionContainer {
    public void Hello() {
        //function code goes here!
    }
}

Now try adding the line Say("Hello!") to the function (will be explained later) and run it!

public void Hello() {
    Say("Hello!");
}

The output should be something like this:

[/hello] say hello

As you can see, MCFunctionAPI translated the code into Minecraft commands! As well as that, if you check the output folder, you'll see that it created all the files for your datapack! You can now load it in Minecraft!

Clone this wiki locally