Skip to content

Commit

Permalink
Add elytra docs and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lkwilson committed Aug 22, 2023
1 parent ac78003 commit e0de329
Show file tree
Hide file tree
Showing 4 changed files with 484 additions and 3 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ const player = {
isInWeb: false,
isCollidedHorizontally: false,
isCollidedVertically: false,
yaw: 0
yaw: 0,
pitch: 0
},
jumpTicks: 0,
jumpQueued: false
jumpQueued: false,
elytraFlying: false,
fireworkRocketDuration: 0
}
const playerState = new PlayerState(player, controls)

while (!player.entity.onGround) {
// simulate 1 tick of player physic, then apply the result to the player
const playerState = new PlayerState(player, controls)
physics.simulatePlayer(playerState, world).apply(player)
}
```
Expand Down Expand Up @@ -78,6 +81,8 @@ Read / Write properties:
- isCollidedVertically : (boolean) is the player collided vertically with a solid block ?
- jumpTicks : (integer) number of ticks before the player can auto-jump again
- jumpQueued : (boolean) true if the jump control state was true between the last tick and the current one
- elytraFlying : (boolean) is the player elytra flying ?
- fireworkRocketDuration : (number) how many ticks of firework boost are remaining ?

Read only properties:
- yaw : (float) the yaw angle, in radians, of the player entity
Expand Down
3 changes: 3 additions & 0 deletions examples/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ function fakePlayer (pos, baseVersion) {
isCollidedHorizontally: false,
isCollidedVertically: false,
yaw: 0,
pitch: 0,
effects: []
},
inventory: {
slots: []
},
jumpTicks: 0,
jumpQueued: false,
elytraFlying: false,
fireworkRocketDuration: 0,
version: baseVersion
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ function fakePlayer (pos) {
isCollidedHorizontally: false,
isCollidedVertically: false,
yaw: 0,
pitch: 0,
effects: {}
},
jumpTicks: 0,
jumpQueued: false,
elytraFlying: false,
fireworkRocketDuration: 0,
version: '1.13.2',
inventory: {
slots: []
Expand Down
Loading

0 comments on commit e0de329

Please sign in to comment.