# prismarine-physics

> Provide the physics engine for minecraft entities

Latest version **1.11.1** (published 2026-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install prismarine-physics
pnpm add prismarine-physics
yarn add prismarine-physics
bun add prismarine-physics
```

## Health

**Score 60/100 (C)** — status: active.

Positive: no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.11.1 |
| Published | 2026-07-28 |
| First published | 2020-07-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 75.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 41 |
| Author | Romain Beaumont |
| Maintainers | rom1504 |
| Keywords | physics, prismarine, minecraft |

## Links

- npm: https://www.npmjs.com/package/prismarine-physics
- Repository: https://github.com/PrismarineJS/prismarine-physics
- Homepage: https://github.com/PrismarineJS/prismarine-physics#readme
- Issues: https://github.com/PrismarineJS/prismarine-physics/issues
- npm.io page: https://npm.io/package/prismarine-physics

## Dependencies (3)

- [vec3](https://npm.io/package/vec3.md) ^0.2.0
- [minecraft-data](https://npm.io/package/minecraft-data.md) ^3.0.0
- [prismarine-nbt](https://npm.io/package/prismarine-nbt.md) ^2.0.0

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 1.11.1 (latest) — 2026-07-28
- 1.11.0 — 2026-03-30
- 1.10.0 — 2025-01-24
- 1.9.0 — 2024-10-26
- 1.8.0 — 2023-08-31
- 1.7.0 — 2023-06-27
- 1.6.0 — 2023-01-19
- 1.5.2 — 2022-06-23
- 1.5.1 — 2022-06-23
- 1.5.0 — 2022-04-11
- 1.4.0 — 2022-01-25
- 1.3.1 — 2021-09-29
- 1.3.0 — 2021-07-06
- 1.2.2 — 2021-01-27
- 1.2.1 — 2021-01-21
- … 11 more at https://npm.io/package/prismarine-physics/versions

## README

# prismarine-physics

[![NPM version](https://img.shields.io/npm/v/prismarine-physics.svg)](http://npmjs.com/package/prismarine-physics)
[![Build Status](https://github.com/PrismarineJS/prismarine-physics/workflows/CI/badge.svg)](https://github.com/PrismarineJS/prismarine-physics/actions?query=workflow%3A%22CI%22)
[![Discord](https://img.shields.io/badge/chat-on%20discord-brightgreen.svg)](https://discord.gg/GsEFRM8)
[![Gitter](https://img.shields.io/badge/chat-on%20gitter-brightgreen.svg)](https://gitter.im/PrismarineJS/general)
[![Irc](https://img.shields.io/badge/chat-on%20irc-brightgreen.svg)](https://irc.gitter.im/)

[![Try it on gitpod](https://img.shields.io/badge/try-on%20gitpod-brightgreen.svg)](https://gitpod.io/#https://github.com/PrismarineJS/prismarine-physics)

Provide the physics engine for minecraft entities

## Usage

```js
const { Physics, PlayerState } = require('prismarine-physics')
const { Vec3 } = require('vec3')

const mcData = require('minecraft-data')('1.13.2')
const Block = require('prismarine-block')('1.13.2')

const physics = Physics(mcData, world)
const controls = {
  forward: false,
  back: false,
  left: false,
  right: false,
  jump: false,
  sprint: false,
  sneak: false
}
const player = {
    entity: {
      position: pos,
      velocity: new Vec3(0, 0, 0),
      onGround: false,
      isInWater: false,
      isInLava: false,
      isInWeb: false,
      isCollidedHorizontally: false,
      isCollidedVertically: false,
      elytraFlying: false,
      yaw: 0,
      pitch: 0
    },
    jumpTicks: 0,
    jumpQueued: 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
  physics.simulatePlayer(playerState, world).apply(player)
}
```

See `examples/` for more.


## API

### Physics

#### simulatePlayer(playerState, world)
- playerState : instance of the PlayerState class
- world : interface with a function `getBlock(position)` returning the prismarine-block at the given position

### PlayerState

A player state is an object containing the properties:

Read / Write properties:
- pos : position (vec3) of the player entity
- vel : velocity (vec3) of the player entity
- onGround : (boolean) is the player touching ground ?
- isInWater : (boolean) is the player in water ?
- isInLava : (boolean) is the player in lava ?
- isInWeb : (boolean) is the player in a web ?
- isCollidedHorizontally : (boolean) is the player collided horizontally with a solid block ?
- isCollidedVertically : (boolean) is the player collided vertically with a solid block ?
- elytraFlying : (boolean) is the player elytra flying ?
- 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
- fireworkRocketDuration : (number) how many ticks of firework boost are remaining ?

Read only properties:
- yaw : (float) the yaw angle, in radians, of the player entity
- pitch: (float) the pitch angle, in radians, of the player entity
- control : (object) control states vector with properties:
  - forward
  - back
  - left
  - right
  - jump
  - sprint
  - sneak

---
_Source: https://npm.io/package/prismarine-physics · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
