{"name":"prismarine-physics","version":"1.11.1","description":"Provide the physics engine for minecraft entities","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha --reporter spec --exit","pretest":"npm run lint","lint":"standard","fix":"standard --fix"},"repository":{"type":"git","url":"git+https://github.com/PrismarineJS/prismarine-physics.git"},"keywords":["physics","prismarine","minecraft"],"author":{"name":"Romain Beaumont"},"license":"MIT","bugs":{"url":"https://github.com/PrismarineJS/prismarine-physics/issues"},"homepage":"https://github.com/PrismarineJS/prismarine-physics#readme","devDependencies":{"expect":"^27.3.1","mocha":"^11.0.1","prismarine-block":"^1.7.3","prismarine-physics":"file:./","standard":"^17.0.0"},"dependencies":{"minecraft-data":"^3.0.0","prismarine-nbt":"^2.0.0","vec3":"^0.2.0"},"gitHead":"a5353a922f1dee075aa797cb53be31919f9e1f46","_id":"prismarine-physics@1.11.1","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-GO9Pqqg5Khs0YxvPqRXYi3Ep3/OoxnL3RtfMknrgddY0ogpT91bTna6HDTQXVeBinfCB3WU9vXaFoTND/3xqyA==","shasum":"149321c449e50470daca650985a6134b28ca7764","tarball":"http://registry-npm.ywwl.com/prismarine-physics/download/prismarine-physics-1.11.1.tgz","fileCount":18,"unpackedSize":77118,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/prismarine-physics@1.11.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBCNvE7U5eS9UQ+1WXcVLJyZLAavhGUMcGfqZhjn2uAaAiBYgrLwM5gmKe3k3CkKvn4PJ3iToejOkCikSQZfJgIIzg=="}],"size":17320,"noattachment":false,"key":"/prismarine-physics/-/prismarine-physics-1.11.1.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:ac0d3e60-aa7c-4db8-8120-2c9476bcb7c8"}},"maintainers":[{"name":"rom1504","email":"romain.rom1@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/prismarine-physics_1.11.1_1785226617620_0.1974140736132819"},"_hasShrinkwrap":false,"readme":"# prismarine-physics\n\n[![NPM version](https://img.shields.io/npm/v/prismarine-physics.svg)](http://npmjs.com/package/prismarine-physics)\n[![Build Status](https://github.com/PrismarineJS/prismarine-physics/workflows/CI/badge.svg)](https://github.com/PrismarineJS/prismarine-physics/actions?query=workflow%3A%22CI%22)\n[![Discord](https://img.shields.io/badge/chat-on%20discord-brightgreen.svg)](https://discord.gg/GsEFRM8)\n[![Gitter](https://img.shields.io/badge/chat-on%20gitter-brightgreen.svg)](https://gitter.im/PrismarineJS/general)\n[![Irc](https://img.shields.io/badge/chat-on%20irc-brightgreen.svg)](https://irc.gitter.im/)\n\n[![Try it on gitpod](https://img.shields.io/badge/try-on%20gitpod-brightgreen.svg)](https://gitpod.io/#https://github.com/PrismarineJS/prismarine-physics)\n\nProvide the physics engine for minecraft entities\n\n## Usage\n\n```js\nconst { Physics, PlayerState } = require('prismarine-physics')\nconst { Vec3 } = require('vec3')\n\nconst mcData = require('minecraft-data')('1.13.2')\nconst Block = require('prismarine-block')('1.13.2')\n\nconst physics = Physics(mcData, world)\nconst controls = {\n  forward: false,\n  back: false,\n  left: false,\n  right: false,\n  jump: false,\n  sprint: false,\n  sneak: false\n}\nconst player = {\n    entity: {\n      position: pos,\n      velocity: new Vec3(0, 0, 0),\n      onGround: false,\n      isInWater: false,\n      isInLava: false,\n      isInWeb: false,\n      isCollidedHorizontally: false,\n      isCollidedVertically: false,\n      elytraFlying: false,\n      yaw: 0,\n      pitch: 0\n    },\n    jumpTicks: 0,\n    jumpQueued: false,\n    fireworkRocketDuration: 0\n  }\nconst playerState = new PlayerState(player, controls)\n\nwhile (!player.entity.onGround) {\n  // simulate 1 tick of player physic, then apply the result to the player\n  physics.simulatePlayer(playerState, world).apply(player)\n}\n```\n\nSee `examples/` for more.\n\n\n## API\n\n### Physics\n\n#### simulatePlayer(playerState, world)\n- playerState : instance of the PlayerState class\n- world : interface with a function `getBlock(position)` returning the prismarine-block at the given position\n\n### PlayerState\n\nA player state is an object containing the properties:\n\nRead / Write properties:\n- pos : position (vec3) of the player entity\n- vel : velocity (vec3) of the player entity\n- onGround : (boolean) is the player touching ground ?\n- isInWater : (boolean) is the player in water ?\n- isInLava : (boolean) is the player in lava ?\n- isInWeb : (boolean) is the player in a web ?\n- isCollidedHorizontally : (boolean) is the player collided horizontally with a solid block ?\n- isCollidedVertically : (boolean) is the player collided vertically with a solid block ?\n- elytraFlying : (boolean) is the player elytra flying ?\n- jumpTicks : (integer) number of ticks before the player can auto-jump again\n- jumpQueued : (boolean) true if the jump control state was true between the last tick and the current one\n- fireworkRocketDuration : (number) how many ticks of firework boost are remaining ?\n\nRead only properties:\n- yaw : (float) the yaw angle, in radians, of the player entity\n- pitch: (float) the pitch angle, in radians, of the player entity\n- control : (object) control states vector with properties:\n  - forward\n  - back\n  - left\n  - right\n  - jump\n  - sprint\n  - sneak","publish_time":1785226617781,"_cnpm_publish_time":1785226617781,"dist-tags":{"latest":"1.11.1"}}