Skip to content

Commit 6831a2b

Browse files
zimuya4153xianyubb
andauthored
feat: fix and enhance some things (#376)
* refactor: fix and enhance BinaryStream and Packet * fix: fix command parameter result * feat: add some apis * feat(legacy api): add VaillanI18n internationalization api * chore: update CHANGELOG.md * feat: add error output for SQLiteSession::backup * fix: fix the NbtCompound::setTag --------- Co-authored-by: xianyubb <2149656630@qq.com>
1 parent a906639 commit 6831a2b

61 files changed

Lines changed: 2646 additions & 411 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,61 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.19.1] - 2026-07-05
11+
12+
### Added
13+
14+
- Added packet APIs:
15+
`Packet::sendTo`, `Packet::sendToClients`, `Packet::sendToServer`,
16+
`Packet` / `LXL_Packet` global aliases @zimuya4153
17+
- Added `BinaryStream` APIs:
18+
`getReadPointer`, `setReadPointer`, `setData`, `writeBytes`, `readBytes`,
19+
`writeUuid` @zimuya4153
20+
- Added server APIs:
21+
`mc.getMotd`, `mc.getOnlinePlayerNum`, `mc.getMaxNumPlayers`,
22+
`mc.getDimensionId`, `mc.getDimensionName` @zimuya4153
23+
- Added gameplay helpers:
24+
`en.setCustomName`, `mc.summonMob`, `mc.loadMob`, `it.addCount`,
25+
`it.removeCount`, `it.setCount`, `system.randomUuid` @zimuya4153
26+
- Added player state APIs:
27+
`pl.isSwimming`, `pl.isCrawling` @zimuya4153
28+
- Added name access APIs:
29+
`be.setCustomName`, `be.getCustomName`, `en.getCustomName`,
30+
`it.getDisplayName` @zimuya4153
31+
- Added player data API:
32+
`mc.getAllPlayerUuids([isOnlineMode])` for enumerating saved player UUIDs
33+
- Added database API:
34+
`DBSession::backup(path)` for backing up SQL sessions
35+
- Added `VaillanI18n` API for modifying Minecraft vanilla language data
36+
@zimuya4153 @xianyubb
37+
- Added `toSNBT([space[,format]])` to all NBT object types @zimuya4153
38+
39+
### Changed
40+
41+
- Improved `BinaryStream`:
42+
`getData([release])` now returns `ByteBuffer`, does not clear by default, and
43+
optionally releases data after reading; `createPacket(pktid[,raw])` now
44+
supports raw packets; scalar `read*` APIs were added; several numeric
45+
`write*` APIs now accept `String` for BigInt-friendly input
46+
@zimuya4153
47+
- Improved file and item behavior:
48+
`File.readFrom(path[,isBinary])` now supports binary reads;
49+
`File.writeTo(path, text)` now accepts `ByteBuffer`;
50+
`it.setLore([])` now clears custom lore instead of failing @zimuya4153
51+
- Improved player NBT APIs:
52+
`mc.getPlayerNbt(uuid)` now returns `Null` when no saved data exists and can
53+
read online players directly; `mc.setPlayerNbt(uuid, nbt[, forceCreate,
54+
isOnlineMode])` now supports optional offline record creation; player NBT
55+
APIs now validate UUID input more strictly @zimuya4153
56+
- Improved NBT serialization:
57+
`NbtCompound::toSNBT([space[,format]])` now supports explicitly selecting
58+
`SnbtFormat`; one-argument usage still defaults to `SnbtFormat::ForceQuote`
59+
@zimuya4153
60+
61+
### Fixed
62+
63+
- Fixed `NbtCompound::setTag` @zimuya4153
64+
1065
## [0.19.0] - 2026-07-04
1166

1267
### Changed
@@ -1263,7 +1318,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
12631318
[#353]: https://github.com/LiteLDev/LegacyScriptEngine/issues/353
12641319
[#358]: https://github.com/LiteLDev/LegacyScriptEngine/issues/358
12651320

1266-
[Unreleased]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.19.0...HEAD
1321+
[Unreleased]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.19.1...HEAD
1322+
[0.19.1]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.19.0...v0.19.1
12671323
[0.19.0]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.18.2...v0.19.0
12681324
[0.18.2]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.18.1...v0.18.2
12691325
[0.18.1]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.18.0...v0.18.1

docs/apis/DataAPI/DataBase.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,22 @@ The `query` method returns:
209209

210210
---
211211

212+
### Backup Database
213+
214+
`session.backup(path)`
215+
216+
* **Parameters:**
217+
* `path`: `String`
218+
Destination path of the backup database file.
219+
220+
221+
* **Returns:** Whether the backup operation succeeded.
222+
* **Return Type:** `Boolean`
223+
224+
> Currently this is implemented for SQLite sessions.
225+
226+
---
227+
212228
### Close Database Session
213229

214230
`session.close()`
@@ -432,4 +448,4 @@ mc.regPlayerCmd("getcoin", "Get a coin!", (pl, args)=>{
432448
dat[pl.realName]++;
433449
modified[pl.realName]++;
434450
});
435-
```
451+
```

docs/apis/DataAPI/DataBase.zh.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,20 @@ SQL数据库适用于使用SQL语句处理大量的关系型数据。接口底
203203

204204

205205

206+
### 备份数据库
207+
208+
`session.backup(path)`
209+
210+
- 参数:
211+
- path : `String`
212+
备份数据库文件的目标路径
213+
- 返回值:备份操作是否成功
214+
- 返回值类型:`Boolean`
215+
216+
> 目前该接口只为 SQLite 会话实现。
217+
218+
219+
206220
### 关闭数据库会话
207221

208222
`session.close()`

docs/apis/GameAPI/BlockEntity.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,27 @@ For more usage of NBT objects, please refer to [NBT Interface Documentation](../
7070
- Return type: The block entity's block object.
7171
- Return value type: `Block`
7272

73+
#### Set Block Entity Custom Name
74+
75+
!!! warning
76+
This function is only available in 0.19.1 and later.
77+
78+
`be.setCustomName(name)`
79+
80+
- Parameters:
81+
- name : `String`
82+
New block entity custom name.
83+
- Return type: Whether setting was successful.
84+
- Return value type: `Boolean`
85+
86+
#### Get Block Entity Custom Name
87+
88+
!!! warning
89+
This function is only available in 0.19.1 and later.
90+
91+
`be.getCustomName()`
92+
93+
- Return type: The block entity's custom name.
94+
- Return value type: `String`
95+
7396

docs/apis/GameAPI/BlockEntity.zh.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,27 @@
7070
- 返回值:方块实体对应的方块对象
7171
- 返回值类型:`Block`
7272

73+
#### 设置方块实体自定义名称
74+
75+
!!! warning
76+
此函数仅在0.19.1及以后版本可用
77+
78+
`be.setCustomName(name)`
79+
80+
- 参数:
81+
- name : `String`
82+
新的方块实体自定义名称
83+
- 返回值:是否设置成功
84+
- 返回值类型:`Boolean`
85+
86+
#### 获取方块实体自定义名称
87+
88+
!!! warning
89+
此函数仅在0.19.1及以后版本可用
90+
91+
`be.getCustomName()`
92+
93+
- 返回值:方块实体自定义名称
94+
- 返回值类型:`String`
95+
7396

docs/apis/GameAPI/Entity.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,52 @@ Through this function, generate a new creature at the specified location and get
7373
> Therefore, if there is a need to operate an entity for a long time, please obtain the real-time entity object through
7474
> the above methods.
7575
76+
#### Summon New Creature and Get Its Entity Object
77+
78+
!!! warning
79+
This function is only available in 0.19.1 and later.
80+
81+
Through this function, summon a new creature at the specified location and get its corresponding entity object.
82+
83+
`mc.summonMob(name,pos[,event])`
84+
`mc.summonMob(name,x,y,z,dimid[,event])`
85+
86+
- Parameters:
87+
- name : `String`
88+
The namespace name of the creature, such as `minecraft:creeper`
89+
- pos : `IntPos `/ `FloatPos`
90+
A coordinate object of where the mob is spawned (or use x, y, z, dimid to determine where to spawn).
91+
- event : `String`
92+
Optional initialization event name
93+
- Return value: The generated entity object.
94+
- Return value type: `Entity`
95+
- If the return value is `Null` it means that the generation failed
96+
97+
> Note: Do not save an entity object **long-term**.
98+
> When the entity corresponding to the entity object is destroyed, the corresponding entity object will become invalid.
99+
> Therefore, if there is a need to operate an entity for a long time, please obtain the real-time entity object through
100+
> the above methods.
101+
102+
#### Load Creature From NBT and Get Its Entity Object
103+
104+
!!! warning
105+
This function is only available in 0.19.1 and later.
106+
107+
Through this function, spawn a creature with the specified NBT data at the specified location and get its corresponding
108+
entity object.
109+
110+
`mc.loadMob(nbt,pos)`
111+
`mc.loadMob(nbt,x,y,z,dimid)`
112+
113+
- Parameters:
114+
- nbt : `NbtCompound`
115+
Creature NBT object
116+
- pos : `IntPos `/ `FloatPos`
117+
A coordinate object of where the mob is spawned (or use x, y, z, dimid to determine where to spawn).
118+
- Return value: The generated entity object.
119+
- Return value type: `Entity`
120+
- If the return value is `Null` it means that the generation failed
121+
76122
#### Clone A Creature and Get Its Entity Object
77123

78124
Through this function, generate a new creature at the specified location and get its corresponding entity object.
@@ -393,6 +439,29 @@ Note that the damage dealt here is real damage and cannot be reduced by protecti
393439
- Return value: Whether the entity was scaled.
394440
- Return value type: `Boolean`
395441

442+
#### Set Entity Custom Name
443+
444+
!!! warning
445+
This function is only available in 0.19.1 and later.
446+
447+
`en.setCustomName(name)`
448+
449+
- Parameters:
450+
- name : `String`
451+
The entity's new custom name
452+
- Return value: Whether setting was successful
453+
- Return value type: `Boolean`
454+
455+
#### Get Entity Custom Name
456+
457+
!!! warning
458+
This function is only available in 0.19.1 and later.
459+
460+
`en.getCustomName()`
461+
462+
- Return value: The entity's custom name
463+
- Return value type: `String`
464+
396465
#### Get Entity Distance To Pos
397466

398467
`en.distanceTo(pos)`

docs/apis/GameAPI/Entity.zh.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,49 @@
6969
> 注意:不要**长期保存**一个实体对象
7070
> 当实体对象对应的实体被销毁时,对应的实体对象将同时释放。因此,如果有长期操作某个实体的需要,请通过上述途径获取实时的实体对象
7171
72+
#### 召唤新生物并获取
73+
74+
!!! warning
75+
此函数仅在0.19.1及以后版本可用
76+
77+
通过此函数,在指定的位置召唤一个新生物,并获取它对应的实体对象
78+
79+
`mc.summonMob(name,pos[,event])`
80+
`mc.summonMob(name,x,y,z,dimid[,event])`
81+
82+
- 参数:
83+
- name : `String`
84+
生物的命名空间名称,如 `minecraft:creeper`
85+
- pos : `IntPos `/ `FloatPos`
86+
生成生物的位置的坐标对象(或者使用x, y, z, dimid来确定生成位置)
87+
- event : `String`
88+
可选的初始化事件名称
89+
- 返回值:生成的实体对象
90+
- 返回值类型:`Entity`
91+
- 如返回值为 `Null` 则表示生成失败
92+
93+
> 注意:不要**长期保存**一个实体对象
94+
> 当实体对象对应的实体被销毁时,对应的实体对象将同时释放。因此,如果有长期操作某个实体的需要,请通过上述途径获取实时的实体对象
95+
96+
#### 通过NBT加载生物并获取
97+
98+
!!! warning
99+
此函数仅在0.19.1及以后版本可用
100+
101+
通过此函数,使用指定的NBT数据在指定位置生成一个生物,并获取它对应的实体对象
102+
103+
`mc.loadMob(nbt,pos)`
104+
`mc.loadMob(nbt,x,y,z,dimid)`
105+
106+
- 参数:
107+
- nbt : `NbtCompound`
108+
生物的NBT对象
109+
- pos : `IntPos `/ `FloatPos`
110+
生成生物的位置的坐标对象(或者使用x, y, z, dimid来确定生成位置)
111+
- 返回值:生成的实体对象
112+
- 返回值类型:`Entity`
113+
- 如返回值为 `Null` 则表示生成失败
114+
72115
#### 复制生物并获取
73116

74117
通过此函数,在指定的位置复制另一个实体,并获取它对应的实体对象
@@ -383,6 +426,29 @@
383426
- 返回值: 实体是否成功地被缩放
384427
- 返回值类型: `Boolean`
385428

429+
#### 设置实体自定义名称
430+
431+
!!! warning
432+
此函数仅在0.19.1及以后版本可用
433+
434+
`en.setCustomName(name)`
435+
436+
- 参数:
437+
- name : `String`
438+
实体新的自定义名称
439+
- 返回值: 是否设置成功
440+
- 返回值类型: `Boolean`
441+
442+
#### 获取实体自定义名称
443+
444+
!!! warning
445+
此函数仅在0.19.1及以后版本可用
446+
447+
`en.getCustomName()`
448+
449+
- 返回值: 实体自定义名称
450+
- 返回值类型: `String`
451+
386452
#### 获取实体到坐标的距离
387453

388454
`en.distanceTo(pos)`

0 commit comments

Comments
 (0)