CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PrismarineJS

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: PrismarineJS/mineflayer
Path: blob/master/lib/location.js
Views: 789
1
const { Vec3 } = require('vec3')
2
const CHUNK_SIZE = new Vec3(16, 16, 16)
3
4
class Location {
5
constructor (absoluteVector) {
6
this.floored = absoluteVector.floored()
7
this.blockPoint = this.floored.modulus(CHUNK_SIZE)
8
this.chunkCorner = this.floored.minus(this.blockPoint)
9
this.blockIndex = this.blockPoint.x + CHUNK_SIZE.x * this.blockPoint.z + CHUNK_SIZE.x * CHUNK_SIZE.z * this.blockPoint.y
10
this.biomeBlockIndex = this.blockPoint.x + CHUNK_SIZE.x * this.blockPoint.z
11
this.chunkYIndex = Math.floor(absoluteVector.y / 16)
12
}
13
}
14
module.exports = Location
15
16