$ npm install prismarine-physics
Provide the physics engine for minecraft entities
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.
getBlock(position)
returning the prismarine-block at the given positionA player state is an object containing the properties:
Read / Write properties:
Read only properties:
© 2010 - cnpmjs.org x YWFE | Home | YWFE