Skip to content

Commit 9af2514

Browse files
committed
更新文档,修正注释和示例,添加新功能说明
1 parent 9850e05 commit 9af2514

29 files changed

+238
-65
lines changed

docs/en/quickstart/01project/01create-project.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,40 @@
22
lastUpdated: true
33
---
44

5-
# Create a Project
5+
# Getting Started
66

7-
TODO
7+
MCFPP currently offers two usage methods: directly using the command line or building with Gradle. For simple functionalities, the command line is recommended. Gradle provides more extensive support, such as MNI.
8+
9+
## Compiling with Command Line
10+
11+
You can download the latest version of the MCFPP compiler from the release page on [GitHub](https://github.com/MinecraftFunctionPlusPlus/MCFPP/releases), which should be a Jar file. MCFPP requires Java 21 or higher. You can place it anywhere as long as you can locate it in the command line.
12+
13+
First, create a project folder and a project configuration file. You can find the detailed format of the project configuration file in the next section. In this example, we create an `example.json` as the project configuration file.
14+
15+
```json
16+
{
17+
"description": "",
18+
"namespace": "mcfpp",
19+
"targetPath": "D:\\.minecraft\\saves\\MCFPP Example\\datapacks"
20+
}
21+
```
22+
23+
Next, create a simple mcfpp file, such as `example.mcfpp`:
24+
25+
```mcfpp
26+
func hello(){
27+
print("Hello World");
28+
}
29+
```
30+
31+
Then, compile the project using the command line:
32+
33+
```shell
34+
java -jar mcfpp.jar example.json
35+
```
36+
37+
This command compiles `example.mcfpp` into a data pack and outputs it to the `D:\.minecraft\saves\MCFPP Example\datapacks` directory. You can then load the data pack in the game and run `function mcfpp:hello` to see the effect.
38+
39+
## Building with Gradle
40+
41+
TODO

docs/en/quickstart/01project/02config-file.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,27 @@ The project configuration file for MCFPP is a JSON file, typically stored in the
88

99
```json
1010
{
11-
// List of project file paths. Use wildcard symbols to select all files.
12-
"files": [
13-
"src/main/mcfpp/**"
14-
],
11+
// The target Minecraft version to compile for. Only official version numbers are supported.
12+
"version": "1.21.4",
1513
// The source code directory of the project. The namespace of the files is determined by their relative path to the source code directory.
16-
"sourcePath": "src/main/mcfpp",
14+
"sourcePath": "src/main/mcfpp/**",
1715
// Description of the datapack. This is a raw JSON text.
1816
"description": "",
1917
// The default namespace for the datapack, which will determine the namespace for datas, for instance storage in the package.
2018
"namespace": "test",
19+
// The jar-packaged libraries to be called.
20+
"jar": [],
2121
// The output path for the datapack. The datapack and library files will be output to this directory.
22-
"targetPath": "src/main/resources/lib",
22+
"targetPath": "build",
2323
// Whether to *not* generate a datapack. Default is false.
2424
"noDatapack": false,
25-
// Whether to *ignore* the standard library. Default is false. If set to true, the MCFPP standard library will not be referenced.
26-
"ignoreStdLib": false,
27-
// Whether it is a library. Default is false. Libraries do not need to have an entry function.
28-
"isLib": false
25+
// Compilation arguments
26+
"compileArgs": [
27+
// Compile in debug mode (for compiler development)
28+
"-debug",
29+
// Ignore the standard library
30+
"-ignoreStdLib",
31+
// Whether it is a library
32+
"-isLib"
33+
]
2934
}

docs/en/quickstart/02base/02comments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ This is a document comment
3838
}#
3939
```
4040

41-
Document comment can include some special tags used to tag the content of the comment. Details in the Document chapter (TODO).
41+
Document comment can include some special tags used to tag the content of the comment. Details in the [Document](../13doc/01doc-comment.md)

docs/en/quickstart/02base/03logic-statements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ for (int i = 0; i < 10; i++){
100100

101101
In this example, when the value of `i` is `5`, `break`will jump out of the loop; when the value of `i` is `3`, `continue` will jump this loop, go to the next loop directly. So, the change of I in each loop are:`0``1``2``4``5`, and finally jump out.
102102

103-
`break` and `continue` statement only can be used in the loop
103+
`break` and `continue` only can be used in the loop

docs/en/quickstart/02base/04top-statements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
lastUpdated: true
33
---
44

5-
# Top statement<Badge type="warning">May Change</Badge>
5+
# Top statement<Badge type="tip">Future Feature</Badge>
66

77
MCFPP allows programming statements at the start of the file and don't need to define any function, that's the top statement. Top statement places in a hidden function, each file have one and only one of this function, and it cannot be called externally. Its returned value’s type is `void`.
88

docs/en/quickstart/02base/05original-command.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ func test(){
2929
```
3030

3131
This will insert the raw text from the `insert` function's parameter into the `test` function. It's important to note that the `insert` function's parameter is a string, so you can insert any content. This also means that the compiler will not perform any checks on the command format.
32+
33+
## Command Interpolation
34+
35+
See [JVM Accessors](../11mni/05access.md) for more information.

docs/en/quickstart/04function/01define-and-call.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ lastUpdate: true
44

55
# Define and call
66

7-
The way of define function in MCFPP has some differences with C/Java, and more similar to the grammar of Python.
8-
97
## Function definition
108

119
In MCFPP, the grammar of define a function is shown below:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
lastUpdate: true
3+
---
4+
5+
# Miscellaneous
6+
7+
## Base Entity
8+
9+
In the example at the beginning of this chapter, you may have noticed the line `@Base<"creeper">`. This line of code is called an **annotation**, which we will discuss in later chapters. Using the `@Base<"creeper">` annotation on the line before the class definition specifies which entity this entity template is based on. This entity is the base entity.
10+
11+
Generally, most entities cannot store custom data well directly, so when the base entity is not `item_display` or `marker`, a `marker` entity will ride on this entity to store the custom fields of the entity template.
12+
13+
The base entity has the tag `<namespace>_class_<classname>_pointer`, while the entity used to store data has the tag `<namespace>_class_<classname>_pointer_data`.
14+
15+
::: info
16+
After 24w10a, all entities can store custom data through the `minecraft:custom_data` entity component. This means that in future versions of mcfpp, classes composed of any type of base entity will store data uniformly in the `minecraft:custom_data` component.
17+
:::
18+
19+
## Lifecycle of Entity Templates
20+
21+
The lifecycle of an entity template is consistent with that of the base entity. When the base entity is removed, the entity template is also removed. This process is automatically handled by the garbage collector (GC).
22+
23+
Of course, you can manually release memory using the `dispose` function <Badge type="tip">Future Feature</Badge>:
24+
25+
```mcfpp
26+
27+
SuperCreeper p = SuperCreeper("Super Creeper");
28+
29+
p.dispose();
30+
31+
```

docs/en/quickstart/08nbt/02list.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ The MCFPP standard library provides a series of functions for list operations.
4141
| `addAll` | `list<T> elements` | `void` | Adds a group of elements to the list |
4242
| `insert` | `int index, T element` | `void` | Inserts an element at a specified position |
4343
| `removeAt` | `int index` | `void` | Removes the element at the specified position |
44+
| `remove` | `T element` | `void` | Removes the specified element |
4445
| `indexOf` | `T element` | `int` | Returns the index of the specified element |
4546
| `lastIndexOf` | `T element` | `int` | Returns the last index of the specified element |
4647
| `contains` | `T element` | `bool` | Checks if the list contains the specified element |

docs/en/quickstart/08nbt/03dict.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ Dictionaries cannot be iterated over, and you cannot retrieve a list of keys or
4545
| `containsKey` | `string key` | `bool` | Checks if the dictionary contains a specified key |
4646
| `merge` | `dict dict` | `void` | Merges two dictionaries |
4747
| `remove` | `string key` | `void` | Removes the key-value pair for the specified key |
48+
| `clear` | `void` | `void` | Clears the dictionary |

0 commit comments

Comments
 (0)