Skip to content

Commit abb13e1

Browse files
committed
update language feature
1 parent 52e5f91 commit abb13e1

18 files changed

+370
-187
lines changed

docs/.vitepress/sidebar.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export const sidebar: DefaultTheme.Sidebar = {
3333
{
3434
text: "顶层语句",
3535
link: "/zh/quickstart/02base/04top-statements",
36+
},
37+
{
38+
text: "原生命令",
39+
link: "/zh/quickstart/02base/05original-command",
3640
}
3741
],
3842
},
@@ -59,6 +63,10 @@ export const sidebar: DefaultTheme.Sidebar = {
5963
{
6064
text: "内联函数",
6165
link: "/zh/quickstart/04function/03inline-function",
66+
},
67+
{
68+
text: "编译期函数",
69+
link: "/zh/quickstart/04function/04compiletime-function",
6270
}
6371
],
6472
},
@@ -73,9 +81,13 @@ export const sidebar: DefaultTheme.Sidebar = {
7381
text: "类的成员",
7482
link: "/zh/quickstart/05class/02member",
7583
},
84+
{
85+
text: "单例",
86+
link: "/zh/quickstart/05class/03object",
87+
},
7688
{
7789
text: "继承和抽象",
78-
link: "/zh/quickstart/05class/03inheritance-abstract",
90+
link: "/zh/quickstart/05class/04inheritance-abstract",
7991
}
8092
],
8193
},
@@ -166,6 +178,10 @@ export const sidebar: DefaultTheme.Sidebar = {
166178
{
167179
text: "JavaVar",
168180
link: "/zh/quickstart/11mni/03javavar",
181+
},
182+
{
183+
text: "注解",
184+
link: "/zh/quickstart/11mni/04annotation",
169185
}
170186
],
171187
},
@@ -235,11 +251,11 @@ export const sidebar: DefaultTheme.Sidebar = {
235251
link: "/en/quickstart/05class/01define-and-instantiate",
236252
},
237253
{
238-
text: "类的成员",
254+
text: "Member of class ",
239255
link: "/en/quickstart/05class/02member",
240256
},
241257
{
242-
text: "继承和抽象",
258+
text: "Inheritance and abstraction",
243259
link: "/en/quickstart/05class/03inheritance-abstract",
244260
}
245261
],
@@ -248,7 +264,7 @@ export const sidebar: DefaultTheme.Sidebar = {
248264
text: "Interface",
249265
"items": [
250266
{
251-
text: "定义和实现接口",
267+
text: "Define and implement ",
252268
link: "/en/quickstart/06interface/01define-and-implement",
253269
}
254270
],

docs/en/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ hero:
1111
text: QuickStart
1212
link: /en/quickstart/index
1313
- theme: alt
14-
text: Overview
15-
link: /en/overview
14+
text: GitHub
15+
link: https://github.com/MinecraftFunctionPlusPlus/MCFPP
1616

1717
features:
1818
- title: Ultimate Experience

docs/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ hero:
1111
text: 快速开始
1212
link: /zh/quickstart/index
1313
- theme: alt
14-
text: 语法总览
15-
link: /zh/overview
14+
text: GitHub
15+
link: https://github.com/MinecraftFunctionPlusPlus/MCFPP
1616

1717
features:
1818
- title: 极致体验
1919
details: 通过精心设计的语法,让数据包的开发体验更加流畅
2020
- title: 跨版本编译
2121
details: 一份代码,多版本支持,无需担心Mojang的一周一改
2222
- title: 无缝集成
23-
details: 强大的MNI框架,基于数据包编译期更多的可能
23+
details: 强大的MNI框架,基于数据包编译期,提供更多的可能
2424
---
2525

docs/zh/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ hero:
1111
text: 快速开始
1212
link: /zh/quickstart/index
1313
- theme: alt
14-
text: 语法总览
15-
link: /zh/overview
14+
text: GitHub
15+
link: https://github.com/MinecraftFunctionPlusPlus/MCFPP
1616

1717
features:
1818
- title: 极致体验

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,27 @@ lastUpdated: true
44

55
# 配置文件
66

7-
TODO
7+
MCFPP的工程配置文件是一个json文件,一般存放在这个工程的根目录下。它的Json格式如下:
8+
9+
```json
10+
{
11+
//项目文件的路径列表。使用通配符选择所有文件
12+
"files": [
13+
"src/main/mcfpp/**"
14+
],
15+
//项目的源代码目录。文件的命名空间根据文件相对于源代码目录的相对路径决定
16+
"sourcePath": "src/main/mcfpp",
17+
//数据包的描述。是一个原始JSON文本
18+
"description": "",
19+
//数据包的默认命名空间,将会决定数据包中storage等数据的命名空间
20+
"namespace": "test",
21+
//数据包的输出路径。数据包、库文件将会输出在此目录下
22+
"targetPath": "src/main/resources/lib",
23+
//是否 *不* 生成数据包。默认为false
24+
"noDatapack": false,
25+
//是否 *忽略* 标准库。默认为false。如果为true,将不会引用mcfpp的标准库。
26+
"ignoreStdLib": false,
27+
//是否是库。默认为false。库不需要拥有一个入口函数
28+
"isLib": false
29+
}
30+
```

docs/zh/quickstart/02base/01variables.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ int b = i * 6;
3232
|dict|表示一个字典|`{"a":1,"b":2,"c":3}`|
3333
|map|字典的更高级包装,拥有比字典更多的功能|同上|
3434
|string|表示一个字符串|`"mcfpp"`,`"qwq"`|
35-
|jtext|表示一个Json原始文本|`"mcfpp"`,`{"text":"mcfpp","color":"#114514"}`|
35+
|text|表示一个Json原始文本|`"mcfpp"`,`{"text":"mcfpp","color":"#114514"}`|
3636
|entity|表示一个实体。储存了一个实体的UUID||
37-
|selector|表示一个目标选择器|`@a`,`@p[limit=6]`|
37+
|selector|表示一个目标选择器|`@a`,`@p`|
3838

3939
以下是对类型的简要介绍,可以逐一展开查看:
4040

@@ -43,43 +43,43 @@ int b = i * 6;
4343
:::
4444

4545
::: details float
46-
**float**类型是MCFPP中表示一个单精度浮点数的类型。它可以是正数、负数、零,也可以是十进制、科学计数法等。MCFPP的浮点数运算依赖[小豆的数学库完成](https:#github.com/xiaodou8593/math2.0)。浮点数的运算为纯粹的记分板运算,因此占用量不会很大。
46+
表示MCFPP中的一个浮点数。它的精度和单精度浮点数相当。它可以是正数、负数、零,也可以是十进制、科学计数法等。MCFPP的浮点数运算依赖[小豆的数学库完成](https:#github.com/xiaodou8593/math2.0)。浮点数的运算为纯粹的记分板运算,因此占用量不会很大。
4747
:::
4848

4949
::: details bool
50-
**bool**类型是MCFPP中表示一个布尔型数据的类型。它只有两个值:`true``false`。bool类型的数据会被储存为一个记分板变量,因此它的大小和记分板的大小一样。
50+
表示一个布尔型数据。它只有两个值:`true``false`。bool类型的数据会被储存为一个记分板变量,因此它的大小和记分板的大小一样。
5151
:::
5252

5353
::: details nbt
54-
**nbt**类型表示一个NBT数据。不过实际上,NBT类型的数据更多情况下只是储存了一个NBT路径,因此把它们称作NBT指针也不足为过。值得注意的是,**nbt**类型的变量是大多数基本类型的基础,例如`list``map`等都依托NBT数据的操作实现。
54+
表示一个NBT数据。不过实际上,NBT类型的数据更多情况下只是储存了一个NBT路径,因此把它们称作NBT指针也不足为过。值得注意的是,**nbt**类型的变量是大多数基本类型的基础,例如`list``map`等都依托NBT数据的操作实现。
5555
:::
5656

5757
::: details list
58-
**list**类型表示一个列表`list`类型实现了java中`ArrayList`的大多数方法,详细可以参考标准库的API。`list`会被储存为一个NBT列表。
58+
表示一个列表`list`类型实现了java中`ArrayList`的大多数方法,详细可以参考标准库的API。`list`会被储存为一个NBT列表。
5959
:::
6060

6161
::: details dict
62-
**dict**类型表示一个字典,被储存为一个NBT复合标签。受MC的限制,`dict`类型只能进行基本的键值对插入和删除操作,无法进行遍历操作。你可以使用`map`来进行更多的操作。
62+
表示一个字典,被储存为一个NBT复合标签。受MC的限制,`dict`类型只能进行基本的键值对插入和删除操作,无法进行遍历操作。你可以使用`map`来进行更多的操作。
6363
:::
6464

6565
::: details map
66-
**map**类型是`dict`类型的更高级包装,拥有比`dict`更多的功能。`map`类型实现了java中`HashMap`的大多数方法,详细可以参考标准库的API。但是值得注意的是,`map`的更高级包装意味着`map`会拥有比`dict`更多的开销。
66+
`dict`类型的更高级包装,拥有比`dict`更多的功能。`map`类型实现了java中`HashMap`的大多数方法,详细可以参考标准库的API。但是值得注意的是,`map`的更高级包装意味着`map`会拥有比`dict`更多的开销。
6767
:::
6868

6969
::: details string
70-
TODO
70+
表示一个字符串,即NBT中的string标签。
7171
:::
7272

73-
::: details jtext
74-
TODO
73+
::: details text
74+
表示一个原始JSON文本,相较于`string`类型,`text`类型可以包含更多的格式信息,例如颜色、粗体等。`text`类型的数据会被储存为一个NBT复合标签。
7575
:::
7676

7777
::: details entity
78-
TODO
78+
表示单个实体。储存为一个UUID整数型NBT数组。
7979
:::
8080

8181
::: details selector
82-
TODO
82+
表示一个目标选择器。储存为一个字符串。
8383
:::
8484

8585
## var关键字
@@ -98,7 +98,7 @@ var i; # [!code error] #错误,缺少初始化表达式
9898

9999
## 变量修饰符
100100

101-
变量修饰符可以用来表示变量的类型,包括`dynamic``const``import`
101+
变量修饰符可以用来表示变量的类型,包括`dynamic``const`
102102

103103
- dynamic
104104

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
lastUpdated: true
3+
---
4+
5+
# 原生命令
6+
7+
MCFPP支持Minecraft原生命令的使用。有两种方法可以使用原生命令:
8+
9+
## 使用`/`插入命令
10+
11+
`/`开头的语句将会被认为是一个原生命令。例如:
12+
13+
```mcfpp
14+
func test(){
15+
/summon minecraft:armor_stand ~ ~ ~
16+
}
17+
```
18+
19+
将会直接在test函数中插入一个summon命令。
20+
21+
## 使用`insert`函数
22+
23+
`insert`函数可以将一个字符串插入到当前位置。例如:
24+
25+
```mcfpp
26+
func test(){
27+
insert("summon minecraft:armor_stand ~ ~ ~");
28+
}
29+
```
30+
31+
将会将`insert`参数中的原文插入到test函数中。值得注意的是,`insert`函数的参数是一个字符串,因此你可以在其中插入任何内容,这同时意味着编译器不会对命令格式进行任何检查。

docs/zh/quickstart/03namespace/01namespace.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,4 @@ func test(){ # test:test函数
1818

1919
一个文件中只能声明一次命名空间。
2020

21-
同样的,你也可以在项目配置文件中声明这个命名空间。
22-
23-
```json
24-
{
25-
"file":[
26-
"*"
27-
"D:/workspace/mcfpp/project/*"
28-
],
29-
"version":"1.19.4",
30-
"include":[
31-
"D:/workspace/mcfpp/another_project.json"
32-
],
33-
"targetPath":"./out",
34-
//工程的默认命名空间。可选,默认为default // [!code focus]
35-
"namespace":"mcfpp" // [!code focus]
36-
}
37-
```
21+
若没有声明命名空间,文件的命名空间将会由文件路径相对于源代码路径的相对路径决定。例如,假设源代码目录为`src/main/mcfpp`,那么文件`src/main/mcfpp/test/test.mcfpp`的命名空间将会是`test.test`。源代码路径通过工程配置文件中的`sourcePath`决定。

docs/zh/quickstart/04function/02static-params.md

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

5-
# static关键字
5+
# static关键字<Badge type="tip">可能更改</Badge>
66

77
`static`关键字用于声明一个静态参数。静态参数表示,在参数传递的过程中,是传递的参数本身而不是参数的值,因此在函数中对参数的修改会影响外部的变量。例如:
88

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
lastUpdate: true
3+
---
4+
5+
# 编译期函数
6+
7+
TODO

docs/zh/quickstart/05class/01define-and-instantiate.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class Person{
2525
}
2626
```
2727

28-
2928
## 类的定义
3029

3130
作为一个面向对象的编程语言,MCFPP有完善的面向对象的语法和功能。它的语法和Java/C#的语法非常相似,所以,如果你有相关的基础的话,你应该可以很轻松地上手。
@@ -45,14 +44,31 @@ class ClassName{
4544

4645
一般情况下,你可以使用`ClassName(参数列表)`来创建一个对象的实例。比如本篇开头的示例`Person`类可以用`Person p = Person("Alumopper",16)`来创建。在MCFPP中,你并不需要`new`关键字。它被省略掉了。
4746

48-
## 类的初始化器<Badge type="tip" text="未来特性" />
47+
## 类的初始化器
4948

5049
在创建类的时候,你可以使用类初始化器来对类的某些成员变量初始化,例如对于上文中的`Person`,有:
5150

5251
```mcfpp
53-
Person p = Person("Alumopper",16){
52+
Person p = Person("Alumopper",16)[
5453
sex = "女"
55-
};
54+
];
55+
```
56+
57+
这样,`p``sex`成员变量就被初始化为`"女"`了。
58+
59+
::: tip
60+
61+
### 不仅仅是类的初始化
62+
63+
事实上,类初始化器可以用在任何地方,而不只是在类的初始化的时候。比如
64+
65+
```mcfpp
66+
func main(){
67+
Test t = Test();
68+
t = t[a = 100];
69+
print(t.toText());
70+
}
5671
```
5772

58-
这样,`p``sex`成员变量就被初始化为`"女"`了。
73+
在这个例子中,类的初始化器实际上是域操作器。`t = t[a = 100]`将t中的a赋值为100。
74+
:::

docs/zh/quickstart/05class/03inheritance-abstract.md

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)