{"name":"prismarine-physics","version":"1.10.0","keywords":["physics","prismarine","minecraft"],"author":{"name":"Romain Beaumont"},"license":"MIT","_id":"prismarine-physics@1.10.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":"ef566a2b73bb7f843e09160de11e1c3dbcfc91a8","tarball":"http://registry-npm.ywwl.com/prismarine-physics/download/prismarine-physics-1.10.0.tgz","fileCount":17,"integrity":"sha512-FE2xUSDhrdgjlJFtBPMTQt1FX3uG2YvKceRvoMmhcCni0MrS8365ZlbIcW06SB1sKIpoNQWanS5LuefynzwdXQ==","signatures":[{"sig":"MEQCICxouh51YymDZRhH4ldTpSiXufLm8B2p3bIpckhr3HlDAiA0dB0MnhR2yprsO1HrSu9ZO/O4+rIRiNRd0CwBQKCOGA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":70653,"size":15705,"noattachment":false,"key":"/prismarine-physics/-/prismarine-physics-1.10.0.tgz"},"main":"index.js","gitHead":"5c6b7d2eaa4193a83b3308c8bb45a948d19ddb0c","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":"^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.10.0_1737757171933_0.4443028307679142","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":1737757172121,"_cnpm_publish_time":1737757172121,"dist-tags":{"latest":"1.11.1"}}