Skip to content
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added some api and event [#220]

## [0.9.4] - 2025-02-02

### Changed
Expand Down Expand Up @@ -766,6 +770,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[#219]: https://github.com/LiteLDev/LegacyScriptEngine/issues/219

[#220]: https://github.com/LiteLDev/LegacyScriptEngine/issues/220

[Unreleased]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.9.4...HEAD

[0.9.4]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.9.3...v0.9.4
Expand Down
17 changes: 17 additions & 0 deletions docs/apis/EventAPI/PlayerEvents.md
Original file line number Diff line number Diff line change
Expand Up @@ -576,3 +576,20 @@ Note: This event is so powerful that it can even intercept and open backpacks.
- pos : `IntPos`
The position of the bed used.
- Intercept events: function returns `false`



#### `"onPlayerInteractEntity"` - Player Interact with Entity

!!! tip "Added in 0.9.5"

- Listener function prototype
`function(player, entity, pos)`
- Parameters:
- player : `Player`
Players who interact with entity
- entity : `Entity`
Entity that player interact with
- pos : `FloatPos`
Interaction position
- Intercept events: function returns `false`
17 changes: 17 additions & 0 deletions docs/apis/EventAPI/PlayerEvents.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -592,3 +592,20 @@
- pos : `IntPos`
床的位置
- 拦截事件:函数返回`false`



#### `"onPlayerInteractEntity"` - 玩家交互实体

!!! tip "此事件在 0.9.5 中加入"

- 监听函数原型
`function(player, entity, pos)`
- 参数:
- player : `Player`
交互实体的玩家对象
- entity : `Entity`
被交互的实体对象
- pos : `FloatPos`
交互坐标
- 拦截事件:函数返回`false`
18 changes: 18 additions & 0 deletions docs/apis/GameAPI/Entity.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ This function returns an array of entity objects, each of which corresponds to a
- Return value: List of entity objects
- Return value type: `Array<Entity,Entity,...>`

#### Acquired From Existing Entitys

Manually generate entity objects by **entity information**
Use this function to manually generate objects. Note that the entity you want to get must be online, otherwise the
generation will fail.

!!! tip "Added in 0.9.5"

`mc.getEntity(info)`

- Parameters:
- info : `Number`
Entity's UniqueId or RuntimeId.
- Return value: The generated entity object.
- Return value type: `Entity`
- If the return value is `Null`, it means that getting the entity failed.

#### Spawn New 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 @@ -105,6 +122,7 @@ properties:
| en.speed | Entity's current speed | `Float` |
| en.direction | Entity's orientation | `DirectionAngle` |
| en.uniqueId | Entity's unique identifier | `String` |
| en.runtimeId | Entity's runtime identifier (Added in 0.9.5) | `String` |
| en.isInvisible | Whether the entity is invisible | `Boolean` |
| en.isInsidePortal | Whether the entity is inside the portal | `Boolean` |
| en.isTrusting | Whether the entity is trusted | `Boolean` |
Expand Down
95 changes: 56 additions & 39 deletions docs/apis/GameAPI/Entity.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@
- 返回值: 实体对象列表
- 返回值类型: `Array<Entity,Entity,...>`

#### 从现有实体获取

通过**实体信息**手动生成实体对象
通过此函数来手动生成对象,注意,你要获取的实体必须是在线状态,否则会生成失败

!!! tip "此接口在 0.9.5 版本加入"

`mc.getEntity(info)`

- 参数:
- info : `Number`
实体的UniqueId或者RuntimeId
- 返回值:生成的实体对象
- 返回值类型:`Entity`
- 如返回值为 `Null` 则表示获取实体失败

#### 生成新生物并获取

通过此函数,在指定的位置生成一个新生物,并获取它对应的实体对象
Expand Down Expand Up @@ -74,45 +90,46 @@

每一个实体对象都包含一些固定的对象属性。对于某个特定的实体对象`en`,有以下这些属性

| 属性 | 含义 | 类型 |
|--------------------------|-------------|------------------|
| en.name | 实体名称 | `String` |
| en.type | 实体标准类型名 | `String` |
| en.id | 实体的游戏内id | `Integer` |
| en.pos | 实体所在坐标 | `FloatPos` |
| en.feetPos | 实体腿部所在坐标 | `FloatPos` |
| en.blockPos | 实体所在的方块坐标 | `IntPos` |
| en.maxHealth | 实体最大生命值 | `Integer` |
| en.health | 实体当前生命值 | `Integer` |
| en.canFly | 实体是否能飞行 | `Boolean` |
| en.canFreeze | 实体是否能被冻结 | `Boolean` |
| en.canSeeDaylight | 实体是否能看到天空 | `Boolean` |
| en.canPickupItems | 实体是否能拾取物品 | `Boolean` |
| en.inAir | 实体是否悬空 | `Boolean` |
| en.inWater | 实体是否在水中 | `Boolean` |
| en.inLava | 实体是否在岩浆中 | `Boolean` |
| en.inRain | 实体是否在雨中 | `Boolean` |
| en.inSnow | 实体是否在雪中 | `Boolean` |
| en.inWall | 实体是否在墙上 | `Boolean` |
| en.inWaterOrRain | 实体是否在水中或雨中 | `Boolean` |
| en.inWorld | 实体是否在世界中 | `Boolean` |
| en.speed | 实体当前速度 | `Float` |
| en.direction | 实体当前朝向 | `DirectionAngle` |
| en.uniqueId | 实体唯一标识符 | `String` |
| en.isInvisible | 实体是否不可见 | `Boolean` |
| en.isInsidePortal | 实体是否在门户内 | `Boolean` |
| en.isTrusting | 实体是否信任 | `Boolean` |
| en.isTouchingDamageBlock | 实体是否接触到伤害方块 | `Boolean` |
| en.isOnFire | 实体是否着火 | `Boolean` |
| en.isOnGround | 实体是否在地面 | `Boolean` |
| en.isOnHotBlock | 实体是否在热块上 | `Boolean` |
| en.isTrading | 实体是否在交易 | `Boolean` |
| en.isRiding | 实体是否正在骑行 | `Boolean` |
| en.isDancing | 实体是否在跳舞 | `Boolean` |
| en.isSleeping | 实体是否在睡觉 | `Boolean` |
| en.isAngry | 实体是否生气 | `Boolean` |
| en.isBaby | 实体是否为幼体 | `Boolean` |
| en.isMoving | 实体是否移动 | `Boolean` |
| 属性 | 含义 | 类型 |
| ------------------------ | ----------------------------------- | ---------------- |
| en.name | 实体名称 | `String` |
| en.type | 实体标准类型名 | `String` |
| en.id | 实体的游戏内 id | `Integer` |
| en.pos | 实体所在坐标 | `FloatPos` |
| en.feetPos | 实体腿部所在坐标 | `FloatPos` |
| en.blockPos | 实体所在的方块坐标 | `IntPos` |
| en.maxHealth | 实体最大生命值 | `Integer` |
| en.health | 实体当前生命值 | `Integer` |
| en.canFly | 实体是否能飞行 | `Boolean` |
| en.canFreeze | 实体是否能被冻结 | `Boolean` |
| en.canSeeDaylight | 实体是否能看到天空 | `Boolean` |
| en.canPickupItems | 实体是否能拾取物品 | `Boolean` |
| en.inAir | 实体是否悬空 | `Boolean` |
| en.inWater | 实体是否在水中 | `Boolean` |
| en.inLava | 实体是否在岩浆中 | `Boolean` |
| en.inRain | 实体是否在雨中 | `Boolean` |
| en.inSnow | 实体是否在雪中 | `Boolean` |
| en.inWall | 实体是否在墙上 | `Boolean` |
| en.inWaterOrRain | 实体是否在水中或雨中 | `Boolean` |
| en.inWorld | 实体是否在世界中 | `Boolean` |
| en.speed | 实体当前速度 | `Float` |
| en.direction | 实体当前朝向 | `DirectionAngle` |
| en.uniqueId | 实体唯一标识符 | `String` |
| en.runtimeId | 实体运行时标识符(在 0.9.5 时被加入) | `String` |
| en.isInvisible | 实体是否不可见 | `Boolean` |
| en.isInsidePortal | 实体是否在门户内 | `Boolean` |
| en.isTrusting | 实体是否信任 | `Boolean` |
| en.isTouchingDamageBlock | 实体是否接触到伤害方块 | `Boolean` |
| en.isOnFire | 实体是否着火 | `Boolean` |
| en.isOnGround | 实体是否在地面 | `Boolean` |
| en.isOnHotBlock | 实体是否在热块上 | `Boolean` |
| en.isTrading | 实体是否在交易 | `Boolean` |
| en.isRiding | 实体是否正在骑行 | `Boolean` |
| en.isDancing | 实体是否在跳舞 | `Boolean` |
| en.isSleeping | 实体是否在睡觉 | `Boolean` |
| en.isAngry | 实体是否生气 | `Boolean` |
| en.isBaby | 实体是否为幼体 | `Boolean` |
| en.isMoving | 实体是否移动 | `Boolean` |

这些对象属性都是只读的,无法被修改

Expand Down
44 changes: 23 additions & 21 deletions docs/apis/GameAPI/Packet.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,29 @@ Every binary stream object contains some member functions (member methods) that
- Return value:success or not
- Return value type: `Boolean`

| Available functions | Parameter Type |
| ----------------------- | -------------- |
| writeBool | `Boolean` |
| writeByte | `Integer` |
| writeDouble | `Number` |
| writeFloat | `Float` |
| writeSignedBigEndianInt | `Number` |
| writeSignedInt | `Number` |
| writeSignedInt64 | `Number` |
| writeSignedShort | `Integer` |
| writeString | `String` |
| writeUnsignedChar | `Integer` |
| writeUnsignedInt | `Number` |
| writeUnsignedInt64 | `Number` |
| writeUnsignedShort | `Integer` |
| writeUnsignedVarInt | `Number` |
| writeUnsignedVarInt64 | `Number` |
| writeVarInt | `Number` |
| writeVarInt64 | `Number` |
| writeVec3 | `FloatPos` |
| writeCompoundTag | `NbtCompound` |
| Available functions | Parameter Type |
| ------------------------------ | -------------- |
| writeBool | `Boolean` |
| writeByte | `Integer` |
| writeDouble | `Number` |
| writeFloat | `Float` |
| writeSignedBigEndianInt | `Number` |
| writeSignedInt | `Number` |
| writeSignedInt64 | `Number` |
| writeSignedShort | `Integer` |
| writeString | `String` |
| writeUnsignedChar | `Integer` |
| writeUnsignedInt | `Number` |
| writeUnsignedInt64 | `Number` |
| writeUnsignedShort | `Integer` |
| writeUnsignedVarInt | `Number` |
| writeUnsignedVarInt64 | `Number` |
| writeVarInt | `Number` |
| writeVarInt64 | `Number` |
| writeVec3 | `FloatPos` |
| writeBlockPos (Added in 0.9.5) | `BlockPos` |
| writeCompoundTag | `NbtCompound` |
| writeItem (Added in 0.9.5) | `Item` |



Expand Down
46 changes: 24 additions & 22 deletions docs/apis/GameAPI/Packet.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,29 @@
- 返回值:是否成功
- 返回值类型: `Boolean`

| 可用函数 | 参数类型 |
| ----------------------- | ------------- |
| writeBool | `Boolean` |
| writeByte | `Integer` |
| writeDouble | `Number` |
| writeFloat | `Float` |
| writeSignedBigEndianInt | `Number` |
| writeSignedInt | `Number` |
| writeSignedInt64 | `Number` |
| writeSignedShort | `Integer` |
| writeString | `String` |
| writeUnsignedChar | `Integer` |
| writeUnsignedInt | `Number` |
| writeUnsignedInt64 | `Number` |
| writeUnsignedShort | `Integer` |
| writeUnsignedVarInt | `Number` |
| writeUnsignedVarInt64 | `Number` |
| writeVarInt | `Number` |
| writeVarInt64 | `Number` |
| writeVec3 | `FloatPos` |
| writeCompoundTag | `NbtCompound` |
| 可用函数 | 参数类型 |
| ---------------------------- | ------------- |
| writeBool | `Boolean` |
| writeByte | `Integer` |
| writeDouble | `Number` |
| writeFloat | `Float` |
| writeSignedBigEndianInt | `Number` |
| writeSignedInt | `Number` |
| writeSignedInt64 | `Number` |
| writeSignedShort | `Integer` |
| writeString | `String` |
| writeUnsignedChar | `Integer` |
| writeUnsignedInt | `Number` |
| writeUnsignedInt64 | `Number` |
| writeUnsignedShort | `Integer` |
| writeUnsignedVarInt | `Number` |
| writeUnsignedVarInt64 | `Number` |
| writeVarInt | `Number` |
| writeVarInt64 | `Number` |
| writeVec3 | `FloatPos` |
| writeBlockPos (0.9.5 时加入) | `BlockPos` |
| writeCompoundTag | `NbtCompound` |
| writeItem (0.9.5 时加入) | `Item` |



Expand Down Expand Up @@ -135,5 +137,5 @@ mc.listen("onChat",function(pl,msg){
bs.writeString("")
var pkt = bs.createPacket(9)
pl.sendPacket(pkt)
})
});
```
17 changes: 14 additions & 3 deletions docs/apis/GameAPI/Player.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ generation will fail.

`mc.getPlayer(info)`

!!! tip
Versions before 0.8.13 could not get player by UUID
!!! tip "Versions before 0.8.13 could not get player by UUID<br>Versions before 0.9.5 could not get player by RuntimeId"

- Parameters:
- info : `String`
Player's name, XUID or UniqueId or UUID.
Player's name, XUID or UniqueId or RuntimeId or UUID.
- Return value: The generated player object.
- Return value type: `Player`
- If the return value is `Null`, it means that getting the player failed.
Expand Down Expand Up @@ -79,6 +78,7 @@ properties.
| pl.speed | Player's current speed | `Float` |
| pl.direction | Player's current orientation | `DirectionAngle` |
| pl.uniqueId | Player's (entity's) unique identifier | `String` |
| pl.runtimeId | Player's (entity's) runtime identifier (Added in 0.9.5) | `String` |
| pl.isLoading | Player is loading | `Boolean` |
| pl.isInvisible | Player is invisible | `Boolean` |
| pl.isInsidePortal | Player is inside portal | `Boolean` |
Expand Down Expand Up @@ -1334,6 +1334,17 @@ such as `Base` `Current` `DefaultMax` `DefaultMin` `Max` `Min` `Name` by default
| village_hero | 29 |
| darkness | 30 |

#### Convert Player Object to Entity Object

`en.toEntity()`

- Return value: The converted `Entity` object.
- Return value type: `Entity`
- Returns `Null` if the transition fails.

If the current entity object points to a player, you can use this function to convert the entity object to a player
object to use more player-related APIs.

### Determine whether it is a simulated player

`pl.isSimulatedPlayer()`
Expand Down
Loading