Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added packet APIs:
`Packet::sendTo`, `Packet::sendToClients`, `Packet::sendToServer` @zimuya4153
- Added `BinaryStream` APIs:
`getReadPointer`, `setReadPointer`, `setData`, `writeBytes`, `readBytes`,
`writeUuid` @zimuya4153
- Added server APIs:
`mc.getMotd`, `mc.getOnlinePlayerNum`, `mc.getMaxNumPlayers`,
`mc.getDimensionId`, `mc.getDimensionName` @zimuya4153
- Added gameplay helpers:
`en.setCustomName`, `mc.summonMob`, `mc.loadMob`, `it.addCount`,
`it.removeCount`, `it.setCount`, `system.randomUuid` @zimuya4153

### Changed

- Improved `BinaryStream`:
`getData([clear])` now supports the optional `clear` parameter and returns
`ByteBuffer`; `createPacket(pktid[,raw])` now supports raw packets; several
numeric `write*` APIs now accept `String` for BigInt-friendly input
@zimuya4153
- Improved file and item behavior:
`File.readFrom(path[,isBinary])` now supports binary reads;
`File.writeTo(path, text)` now accepts `ByteBuffer`;
`it.setLore([])` now clears custom lore instead of failing @zimuya4153

## [0.18.2] - 2026-04-17

### Fixed
Expand Down
59 changes: 59 additions & 0 deletions docs/apis/GameAPI/Entity.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,52 @@ Through this function, generate a new creature at the specified location and get
> Therefore, if there is a need to operate an entity for a long time, please obtain the real-time entity object through
> the above methods.

#### Summon New Creature and Get Its Entity Object

!!! warning
This function is only available in 0.19.0 and later.

Through this function, summon a new creature at the specified location and get its corresponding entity object.

`mc.summonMob(name,pos[,event])`
`mc.summonMob(name,x,y,z,dimid[,event])`

- Parameters:
- name : `String`
The namespace name of the creature, such as `minecraft:creeper`
- pos : `IntPos `/ `FloatPos`
A coordinate object of where the mob is spawned (or use x, y, z, dimid to determine where to spawn).
- event : `String`
Optional initialization event name
- Return value: The generated entity object.
- Return value type: `Entity`
- If the return value is `Null` it means that the generation failed

> Note: Do not save an entity object **long-term**.
> When the entity corresponding to the entity object is destroyed, the corresponding entity object will become invalid.
> Therefore, if there is a need to operate an entity for a long time, please obtain the real-time entity object through
> the above methods.

#### Load Creature From NBT and Get Its Entity Object

!!! warning
This function is only available in 0.19.0 and later.

Through this function, spawn a creature with the specified NBT data at the specified location and get its corresponding
entity object.

`mc.loadMob(nbt,pos)`
`mc.loadMob(nbt,x,y,z,dimid)`

- Parameters:
- nbt : `NbtCompound`
Creature NBT object
- pos : `IntPos `/ `FloatPos`
A coordinate object of where the mob is spawned (or use x, y, z, dimid to determine where to spawn).
- Return value: The generated entity object.
- Return value type: `Entity`
- If the return value is `Null` it means that the generation failed

#### Clone A Creature and Get Its Entity Object

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

#### Set Entity Custom Name

!!! warning
This function is only available in 0.19.0 and later.

`en.setCustomName(name)`

- Parameters:
- name : `String`
The entity's new custom name
- Return value: Whether setting was successful
- Return value type: `Boolean`

#### Get Entity Distance To Pos

`en.distanceTo(pos)`
Expand Down
56 changes: 56 additions & 0 deletions docs/apis/GameAPI/Entity.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,49 @@
> 注意:不要**长期保存**一个实体对象
> 当实体对象对应的实体被销毁时,对应的实体对象将同时释放。因此,如果有长期操作某个实体的需要,请通过上述途径获取实时的实体对象

#### 召唤新生物并获取

!!! warning
此函数仅在0.19.0及以后版本可用

通过此函数,在指定的位置召唤一个新生物,并获取它对应的实体对象

`mc.summonMob(name,pos[,event])`
`mc.summonMob(name,x,y,z,dimid[,event])`

- 参数:
- name : `String`
生物的命名空间名称,如 `minecraft:creeper`
- pos : `IntPos `/ `FloatPos`
生成生物的位置的坐标对象(或者使用x, y, z, dimid来确定生成位置)
- event : `String`
可选的初始化事件名称
- 返回值:生成的实体对象
- 返回值类型:`Entity`
- 如返回值为 `Null` 则表示生成失败

> 注意:不要**长期保存**一个实体对象
> 当实体对象对应的实体被销毁时,对应的实体对象将同时释放。因此,如果有长期操作某个实体的需要,请通过上述途径获取实时的实体对象

#### 通过NBT加载生物并获取

!!! warning
此函数仅在0.19.0及以后版本可用

通过此函数,使用指定的NBT数据在指定位置生成一个生物,并获取它对应的实体对象

`mc.loadMob(nbt,pos)`
`mc.loadMob(nbt,x,y,z,dimid)`

- 参数:
- nbt : `NbtCompound`
生物的NBT对象
- pos : `IntPos `/ `FloatPos`
生成生物的位置的坐标对象(或者使用x, y, z, dimid来确定生成位置)
- 返回值:生成的实体对象
- 返回值类型:`Entity`
- 如返回值为 `Null` 则表示生成失败

#### 复制生物并获取

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

#### 设置实体自定义名称

!!! warning
此函数仅在0.19.0及以后版本可用

`en.setCustomName(name)`

- 参数:
- name : `String`
实体新的自定义名称
- 返回值: 是否设置成功
- 返回值类型: `Boolean`

#### 获取实体到坐标的距离

`en.distanceTo(pos)`
Expand Down
42 changes: 42 additions & 0 deletions docs/apis/GameAPI/Item.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ For more usage of NBT objects, please refer to [NBT Interface Documentation](../
- Return value: Whether setting the lore was successful.
- Return value type: `Boolean`

!!! warning
In 0.19.0 and later, passing an empty array will clear the item's lore.



#### Set Custom Item Name
Expand All @@ -229,4 +232,43 @@ For more usage of NBT objects, please refer to [NBT Interface Documentation](../
- Return value: is the same kind of item
- Return value type: `Boolean`

#### Increase Item Count

!!! warning
This function is only available in 0.19.0 and later.

`it.addCount(count)`

- Parameters:
- count : `Integer`
Amount to add
- Return value: Whether setting was successful
- Return value type: `Boolean`

#### Decrease Item Count

!!! warning
This function is only available in 0.19.0 and later.

`it.removeCount(count)`

- Parameters:
- count : `Integer`
Amount to remove
- Return value: Whether setting was successful
- Return value type: `Boolean`

#### Set Item Count

!!! warning
This function is only available in 0.19.0 and later.

`it.setCount(count)`

- Parameters:
- count : `Integer`
Amount to set
- Return value: Whether setting was successful
- Return value type: `Boolean`


42 changes: 42 additions & 0 deletions docs/apis/GameAPI/Item.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@
- 返回值:是否设置成功
- 返回值类型: `Boolean`

!!! warning
在0.19.0及以后版本中,传入空数组会清空物品Lore。



#### 设置自定义物品名称
Expand All @@ -230,4 +233,43 @@
- 返回值: 是否为同类物品
- 返回值类型: `Boolean`

#### 增加物品数量

!!! warning
此函数仅在0.19.0及以后版本可用

`it.addCount(count)`

- 参数:
- count : `Integer`
要增加的数量
- 返回值: 是否设置成功
- 返回值类型: `Boolean`

#### 减少物品数量

!!! warning
此函数仅在0.19.0及以后版本可用

`it.removeCount(count)`

- 参数:
- count : `Integer`
要减少的数量
- 返回值: 是否设置成功
- 返回值类型: `Boolean`

#### 设置物品数量

!!! warning
此函数仅在0.19.0及以后版本可用

`it.setCount(count)`

- 参数:
- count : `Integer`
要设置的数量
- 返回值: 是否设置成功
- 返回值类型: `Boolean`


Loading
Loading