A class to hold chunk data for Minecraft: PC 1.8, 1.9, 1.10, 1.11 and 1.12, Pocket Edition 0.14 and 1.0
1.13 and 1.14 support are not available, if you're interested to contribute on that, read PrismarineJS#57
const Chunk = require('prismarine-chunk')("1.8")
const Vec3 = require("vec3")
const chunk=new Chunk()
for (let x = 0; x < 16;x++) {
for (let z = 0; z < 16; z++) {
chunk.setBlockType(new Vec3(x, 50, z), 2)
for (let y = 0; y < 256; y++) {
chunk.setSkyLight(new Vec3(x, y, z), 15)
}
}
}
console.log(JSON.stringify(chunk.getBlock(new Vec3(3,50,3)),null,2))
Test data can be generated with minecraftChunkDumper.
Install it globally with npm install minecraft-chunk-dumper -g
then run :
minecraftChunkDumper saveChunk 1.8.8 1.8/chunk.dump 1.8/chunk.meta
Benchmarks may be run by using:
# run benchmarks once
npm run benchmark
# run benchmarks continuously, reloading changes as they are made
npm run benchmark -- --watch
The output of the benchmarking will be placed in the file benchmarks/results/chunk-1.9.csv
Build a new chunk
Initialize a chunk.
iniFunc
is a function(x,y,z) returning a prismarine-block.
That function is faster than iterating and calling the setBlock* manually. It is useful to generate a whole chunk and load a whole chunk.
Get the block type at pos
Get the block state id at pos
Get the block data (metadata) at pos
Get the block light at pos
Get the block sky light at pos
Get the block biome id at pos
Get the block biome color at pos
. Does nothing for PC.
Set the block type stateId
at pos
Set the block type id
at pos
Set the block data
(metadata) at pos
Set the block light
at pos
Set the block sky light
at pos
Set the block biome
id at pos
Set the block biomeColor
at pos
. Does nothing for PC.
Returns the chunk raw data
Load raw data
into the chunk