Skip to content
Hazel Rojas edited this page Sep 8, 2024 · 14 revisions

Create a Project

Classes references:
SteveSharp.Project

At your Program class, use the using SteveSharp to create a SteveSharp reference, then create a Project reference with a name, for example:

usingSteveSharp;namespaceExample{publicclassProgram{publicstaticvoidMain(){Projectp=newProject();}}}

Then, provide this arguments:

name: The output folder name for the project, this can be used as a relative directory.

description: This description is the pack description for the pack.mcmeta metadata file.

id: This is the namespace that will be created for the datapack.

pack_format: The pack format for the pack.mcmeta metadata file.

load: The function name for the Minecraft's load.json tag file. This is the load function for the project.

main: The function name for the Minecraft's tick.json tag file. This is the main function for the project.

functions: All your functions for your datapack!

matrix: A matrix of functions, if you want to create sequences of functions, be creative!

usingSteveSharp;namespaceExample{publicclassProgram{publicstaticvoidMain(){Projectp=newProject(name:"SteveSharp Project",description:"This is a SteveSharp Project",id:"stevesharp",pack_format:15,load:newFunction(name:"stevesharp:load",body:newList<string>{})
main:new Function(name:"stevesharp:load",body:newList<string>{}),functions:newList<Function>{},matrix:newList<List<Function>>{});}}}

Now you have your project ready for code!

Create a Function

Classes references:
SteveSharp.Function

Now that you have your project code ready, let's create a function. To create a new function, the project supports function nesting. For example, the parameter "load" of the project is a function. First, provide the name field for the function, for example: "stevesharp:load"

Projectp=newProject(name:"SteveSharp Project",description:"This is a SteveSharp Project",id:"stevesharp",pack_format:15,load:newFunction(name:"stevesharp:load",
...

And then, in the body parameter of the function, provide a list of strings, because inside of the function, we are writing lines of code, which are strings.

Projectp=newProject(name:"SteveSharp Project",description:"This is a SteveSharp Project",id:"stevesharp",pack_format:15,load:newFunction(name:"stevesharp:load",body:List<string>{}));

Pro Tip: You can create more functions in the functions field of your project!

Projectp=newProject(
...functions:new List<Function>{newFunction(name:"stevesharp:my_function",body:newList<string>{Chat.Say("Hello World!")})});

Pro Tip: You can create a matrix of functions, or a sequence of functions!

Projectp=newProject(
...matrix:new List<List<Function>>{For.Functions(from:1,to:15,block:(i)=>newFunction(name:"stevesharp:my_function_"+i,body:newList<string>{Chat.Say("Command for function "+i)}))});

Type commands in a function

Classes references:
SteveSharp.Function
SteveSharp.Core.Execute
SteveSharp.Core.Entity
SteveSharp.Core.Chat

You have created a function, now you will write your commands in a function.

How? In the body you can provide all the commands you want!

...
new Function(name:"stevesharp:my_new_function",body:newList<string>{Chat.Say("My first function!")}));

There are so much methods to write your commands, but you will need to import the SteveSharp.Core using For example:

executeas@aat@srunsay Hello World!executeas@aat@srunkill@s

You will write something like this:

...
new Function(name:"stevesharp:my_commands",body:newList<string>{Execute.Write(Execute.Asat(Entity.Everyone()),newstring[]{Entity.Kill(Entity.Self())})})

Finally, the entire code will look something like this:

usingSteveSharp;usingSteveSharp.Core;classProgram{staticvoidMain(){newProject(name:"SteveSharp Project",description:"This is a SteveSharp Project",id:"stevesharp",pack_format:15,load:newFunction(name:"stevesharp:load",body:newList<string>{}),main:newFunction(name:"stevesharp:main",body:newList<string>{}),functions:newList<Function>{newFunction(name:"stevesharp:my_function",body:newList<string>{Chat.Say("Hello World!")}),newFunction(name:"stevesharp:my_commands",body:newList<string>{Execute.Write(Execute.Asat(Entity.Everyone()),newstring[]{Entity.Kill(Entity.Self())})})},matrix:newList<List<Function>>{For.Functions(from:1,to:15,block:(i)=>newFunction(name:"stevesharp:my_function_"+i,body:newList<string>{Chat.Say("Command for function "+i)}))});}}

Now you have learned SteveSharp!

Clone this wiki locally