{"name":"prismarine-physics","version":"1.11.0","keywords":["physics","prismarine","minecraft"],"author":{"name":"Romain Beaumont"},"license":"MIT","_id":"prismarine-physics@1.11.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":"e17c1445e2446315006049f5b7a7119448a81375","tarball":"http://registry-npm.ywwl.com/prismarine-physics/download/prismarine-physics-1.11.0.tgz","fileCount":18,"integrity":"sha512-P25VSDi3kJHQAb/AJBiJCQuxyRCVXRSdEiDjx56ywocgt65N/exatVTiJjOK5HgEKHJSfw0sXSAohQhvutnGAA==","signatures":[{"sig":"MEYCIQDlRPlFDMvV1XTz5raTGgHyLLDIAyZGw/L7Pbh8fUYHfgIhAJ4KvrTg3Qipx14Njap4rmusD8DZwpsuvuyP8MSGHVzg","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/prismarine-physics@1.11.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":76490,"size":17118,"noattachment":false,"key":"/prismarine-physics/-/prismarine-physics-1.11.0.tgz"},"main":"index.js","gitHead":"61f69d789bdf8b6a85d8bbea2cad02b388231a72","scripts":{"fix":"standard --fix","lint":"standard","test":"mocha --reporter spec --exit","pretest":"npm run lint"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:ac0d3e60-aa7c-4db8-8120-2c9476bcb7c8"}},"repository":{"url":"git+https://github.com/PrismarineJS/prismarine-physics.git","type":"git"},"_npmVersion":"11.9.0","description":"Provide the physics engine for minecraft entities","directories":{"test":"test"},"_nodeVersion":"24.14.0","dependencies":{"vec3":"^0.1.7","minecraft-data":"^3.0.0","prismarine-nbt":"^2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^11.0.1","expect":"^27.3.1","standard":"^17.0.0","prismarine-block":"^1.7.3","prismarine-physics":"file:./"},"_npmOperationalInternal":{"tmp":"tmp/prismarine-physics_1.11.0_1774833500526_0.7485801266290342","host":"s3://npm-registry-packages-npm-production"},"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":1774833500653,"_cnpm_publish_time":1774833500653,"dist-tags":{"latest":"1.11.1"}}