{"name":"prismarine-physics","version":"1.9.0","keywords":["physics","prismarine","minecraft"],"author":{"name":"Romain Beaumont"},"license":"MIT","_id":"prismarine-physics@1.9.0","maintainers":[{"name":"rom1504","email":"romain.rom1@gmail.com"}],"homepage":"https://github.com/PrismarineJS/prismarine-physics#readme","bugs":{"url":"https://github.com/PrismarineJS/prismarine-physics/issues"},"dist":{"shasum":"0aa205578453cc7aaa7828ae0c67266f2fb5ba97","tarball":"http://registry-npm.ywwl.com/prismarine-physics/download/prismarine-physics-1.9.0.tgz","fileCount":17,"integrity":"sha512-4qYF6mQ9fOyONaJIF18eZBzsXPq9RD30gxiXoqFjB7sk/rtLIb5ye72YxeYZA3Q9PyBhGH1ANdrHwJ+21WEedQ==","signatures":[{"sig":"MEUCIA1jrV0NYmzSCf7mYxTOGCh4HUK7bjOnM+SuSz3t7HM6AiEAsOlOGp0lCmwpnXwpQ+MKG4eV8ymgDZrToOWFKatBzv0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":67870,"size":15031,"noattachment":false,"key":"/prismarine-physics/-/prismarine-physics-1.9.0.tgz"},"main":"index.js","gitHead":"4cdd93ea32b1b14cf34f7149bcc881b64945c061","scripts":{"fix":"standard --fix","lint":"standard","test":"mocha --reporter spec --exit","pretest":"npm run lint"},"_npmUser":{"name":"rom1504","email":"romain.rom1@gmail.com"},"repository":{"url":"git+https://github.com/PrismarineJS/prismarine-physics.git","type":"git"},"_npmVersion":"8.6.0","description":"Provide the physics engine for minecraft entities","directories":{"test":"test"},"_nodeVersion":"18.0.0","dependencies":{"vec3":"^0.1.7","minecraft-data":"^3.0.0","prismarine-nbt":"^2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^10.0.0","expect":"^27.3.1","standard":"^17.0.0","prismarine-block":"^1.7.3","prismarine-physics":"file:./"},"_npmOperationalInternal":{"tmp":"tmp/prismarine-physics_1.9.0_1729972098628_0.24736031995596064","host":"s3://npm-registry-packages"},"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":1729972098871,"_cnpm_publish_time":1729972098871,"dist-tags":{"latest":"1.11.1"}}