{"name":"prismarine-chunk","version":"1.41.0","description":"A class to hold chunk data for prismarine","main":"index.js","types":"./types/index.d.ts","scripts":{"test":"mocha --reporter spec --exit","fix":"standard --fix","lint":"standard","pretest":"npm run lint"},"repository":{"type":"git","url":"git+https://github.com/PrismarineJS/prismarine-chunk.git"},"keywords":["minecraft","voxel","chunk","world"],"contributors":[{"name":"Will Franzen","email":"wtfranzen@gmail.com","url":"http://will.xyz/"},{"name":"Romain Beaumont","email":"romain.rom1@gmail.com"},{"name":"Georges Oates Larsen","url":"flynnn"},{"name":"mhsjlw"},{"name":"hornta"},{"name":"Karang"},{"name":"Vito Gamberini","email":"vito@gamberini.email"}],"license":"MIT","bugs":{"url":"https://github.com/PrismarineJS/prismarine-chunk/issues"},"homepage":"https://github.com/PrismarineJS/prismarine-chunk","devDependencies":{"@types/node":"^24.1.0","expect":"^30.0.5","mocha":"^11.0.1","prismarine-chunk":"file:.","standard":"^17.0.0-2","typescript":"^5.0.4"},"dependencies":{"prismarine-biome":"^1.2.0","prismarine-block":"^1.14.1","prismarine-nbt":"^2.2.1","prismarine-registry":"^1.1.0","smart-buffer":"^4.1.0","uint4":"^0.1.2","vec3":"^0.1.3","xxhash-wasm":"^0.4.2"},"engines":{"node":">=14"},"gitHead":"ce60c5fcd09c6198e28de011eec3f8811b96923d","_id":"prismarine-chunk@1.41.0","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-KldSl3pDzPU7jcttxSYWNJ40rJMdiUxYvTpqXzqiQ3lIdNL1HAuJHPdscHcqlKJRB9Hw/cbFcROR1h5ncavY+Q==","shasum":"02de63c46bedc7439ccb22e36baf00dee5c3040d","tarball":"http://registry-npm.ywwl.com/prismarine-chunk/download/prismarine-chunk-1.41.0.tgz","fileCount":59,"unpackedSize":238169,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/prismarine-chunk@1.41.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGlmwVIG7D2Kepr7Xe88eNDVE0Y+ONEIr1tYMseeGTZDAiEA9MCZQpjSaqo8I1Ezhu27fu9QokG2A7XJwRuwioZQneg="}],"size":40729,"noattachment":false,"key":"/prismarine-chunk/-/prismarine-chunk-1.41.0.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9624b745-f5f8-4a4c-8881-f087a6639684"}},"directories":{},"maintainers":[{"name":"rom1504","email":"romain.rom1@gmail.com"},{"name":"wtfaremyinitials","email":"wtfranzen@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/prismarine-chunk_1.41.0_1785461592131_0.41779279649774526"},"_hasShrinkwrap":false,"readme":"# prismarine-chunk\n\n[![NPM version](https://img.shields.io/npm/v/prismarine-chunk.svg)](http://npmjs.com/package/prismarine-chunk)\n[![Build Status](https://github.com/PrismarineJS/prismarine-chunk/workflows/CI/badge.svg)](https://github.com/PrismarineJS/prismarine-chunk/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-chunk)\n\nA class to hold chunk data for Minecraft: PC 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16 and 26.1 and Bedrock Edition 0.14 and 1.0, 1.16, 1.17, 1.18, 1.19, 1.20 and 1.21\n\n## Usage\n\n```js\nconst registry = require('prismarine-registry')('1.8')\nconst ChunkColumn = require('prismarine-chunk')(registry)\nconst { Vec3 } = require(\"vec3\")\n\nconst chunk = new ChunkColumn()\n\nfor (let x = 0; x < 16;x++) {\n  for (let z = 0; z < 16; z++) {\n    chunk.setBlockType(new Vec3(x, 50, z), 2)\n    for (let y = 0; y < 256; y++) {\n      chunk.setSkyLight(new Vec3(x, y, z), 15)\n    }\n  }\n}\n\nconsole.log(JSON.stringify(chunk.getBlock(new Vec3(3,50,3)),null,2))\n```\n\n## Test data\n\n### pc\n\nTest data can be generated with [minecraftChunkDumper](https://github.com/PrismarineJS/minecraft-chunk-dumper).\n\nInstall it globally with `npm install minecraft-chunk-dumper -g` then run :\n\n`minecraftChunkDumper saveChunks 1.20 \"1_20\" 10`\n\n### bedrock\n\nRun tests in [bedrock-provider](https://github.com/PrismarineJS/bedrock-provider/) (which loads chunks through a client as part of its tests) and copy the generated data from `fixtures/$version/pchunk` into `tests/bedrock_$version`.\n\nFor the version, copy one chunk column of `level_chunk` without caching, `level_chunk` with caching, `level_chunk CacheMissResponse`, `subchunk` without caching, `subchunk cached` and `subchunk CacheMissResponse` into the test/version folder.\n\nNote: bedrock-provider tests network decoding and loading chunks from a save database. The tests in prismarine-chunk test other parts of the chunk API, such as\nsetting and getting block light, type, biome, entity and block entity data.\n\n# API\n\n## Chunk\n\n#### Chunk(initData: { minY?: number, worldHeight?: number })\n\nBuild a new chunk. initData is only for 1.18+, and if not given or null the world will default to an old-style 0-256 world.\n\n#### Chunk.initialize(iniFunc)\n\nInitialize a chunk.\n* `iniFunc` is a function(x,y,z) returning a prismarine-block.\n\nThat function is faster than iterating and calling the setBlock* manually. It is useful to generate a whole chunk and load a whole chunk.\n\n#### Chunk.version\n\nreturns the version the chunk loader was called with\n\n#### Chunk.section\n\nreturns ChunkSection class for version\n\n#### Chunk.getBlock(pos)\n\nGet the [Block](https://github.com/PrismarineJS/prismarine-block) at [pos](https://github.com/andrewrk/node-vec3)\n\n`.entity` will have entity NBT data for this block, if it exists\n\n#### Chunk.setBlock(pos,block)\n\nSet the [Block](https://github.com/PrismarineJS/prismarine-block) at [pos](https://github.com/andrewrk/node-vec3)\n\nSet `.entity` property with NBT data for this block to load block entity data for the block\n\n#### Chunk.getBlockType(pos)\n\nGet the block type at `pos`\n\n#### Chunk.getBlockStateId(pos)\n\nGet the block state id at `pos`\n\n#### Chunk.getBlockData(pos)\n\nGet the block data (metadata) at `pos`\n\n#### Chunk.getBlockLight(pos)\n\nGet the block light at `pos`\n\n#### Chunk.getSkyLight(pos)\n\nGet the block sky light at `pos`\n\n#### Chunk.getBiome(pos)\n\nGet the block biome id at `pos`\n\n#### Chunk.getBiomeColor(pos)\n\nGet the block biome color at `pos`. Does nothing for PC.\n\n#### Chunk.setBlockStateId(pos, stateId)\n\nSet the block type `stateId` at `pos`\n\n#### Chunk.setBlockType(pos, id)\n\nSet the block type `id` at `pos`\n\n#### Chunk.setBlockData(pos, data)\n\nSet the block `data` (metadata) at `pos`\n\n#### Chunk.setBlockLight(pos, light)\n\nSet the block `light` at `pos`\n\n#### Chunk.setSkyLight(pos, light)\n\nSet the block sky `light` at `pos`\n\n#### Chunk.setBiome(pos, biome)\n\nSet the block `biome` id at `pos`\n\n#### Chunk.setBiomeColor(pos, biomeColor)\n\nSet the block `biomeColor` at `pos`. Does nothing for PC.\n\n#### Chunk.getBlockEntity(pos)\n\nReturns the block entity data at position if it exists\n\n#### Chunk.setBlockEntity(pos, nbt)\n\nSets block entity data at position\n\n#### Chunk.loadBlockEntities(nbt)\n\nLoads an array of NBT data into the chunk column\n\n#### Chunk.toJson()\n\nReturns the chunk as json\n\n#### Chunk.fromJson(j)\n\nLoad chunk from json\n\n#### Chunk.sections\n\nAvailable for pc chunk implementation.\nArray of y => section\nCan be used to identify whether a section is empty or not (will be null if it's the case)\nFor version >= 1.9, contains a .palette property which contains all the stateId of this section, can be used to check quickly whether a given block\nis in this section.\n\n### pc\n\n#### Chunk.getMask()\n\nReturn the chunk bitmap 0b0000_0000_0000_0000(0x0000) means no chunks are set while 0b1111_1111_1111_1111(0xFFFF) means all chunks are set\n\n#### Chunk.dump()\n\nReturns the chunk raw data\n\n#### Chunk.load(data, bitmap = 0xFFFF, skyLightSent = true, fullChunk = true)\n\nLoad raw `data` into the chunk\n\n#### Chunk.dumpLight()\n\nReturns the chunk raw light data (starting from 1.14)\n\n#### Chunk.loadLight(data, skyLightMask, blockLightMask, emptySkyLightMask = 0, emptyBlockLightMask = 0)\n\nLoad lights into the chunk (starting from 1.14)\n\n#### Chunk.loadParsedLight (skyLight, blockLight, skyLightMask, blockLightMask, emptySkyLightMask, emptyBlockLightMask)\n\nLoad lights into the chunk (starting from 1.17)\n\n#### Chunk.dumpBiomes()\n\nReturns the biomes as an array (starting from 1.15)\n\n#### Chunk.loadBiomes(biomes)\n\nLoad biomes into the chunk (starting from 1.15)\n\n### bedrock\n\nSee [index.d.ts](https://github.com/PrismarineJS/prismarine-chunk/blob/master/types/index.d.ts#L56)\n\n## ChunkSection\n\n### pc\n\n#### static fromJson(j: any): ChunkSection\n#### static sectionSize(skyLightSent?: boolean): number\n#### constructor(skyLightSent?: boolean)\n#### data: Buffer\n#### toJson(): { type: \"Buffer\"; data: number[]; }\n#### initialize(iniFunc: any): void\n#### getBiomeColor(pos: Vec3): { r: number; g: number; b: number; }\n#### setBiomeColor(pos: Vec3, r: number, g: number, b: number): void\n#### getBlockStateId(pos: Vec3): number\n#### getBlockType(pos: Vec3): number\n#### getBlockData(pos: Vec3): number\n#### getBlockLight(pos: Vec3): number\n#### getSkyLight(pos: Vec3): number\n#### setBlockStateId(pos: Vec3, stateId: number): void\n#### setBlockType(pos: Vec3, id: number): void\n#### setBlockData(pos: Vec3, data: Buffer): void\n#### setBlockLight(pos: Vec3, light: number): void\n#### setSkyLight(pos: Vec3, light: number): void\n#### dump(): Buffer\n#### load(data: Buffer, skyLightSent?: boolean): void\n\n### bedrock\n\nSee [index.d.ts](https://github.com/PrismarineJS/prismarine-chunk/blob/master/types/index.d.ts#L56)\n\n#### compact()\nShrinks the size of the SubChunk if possible after setBlock operations are done\n\n#### getPalette()\n\nReturns a list of unique block states that make up the chunk section\n","publish_time":1785461592299,"_cnpm_publish_time":1785461592299,"dist-tags":{"latest":"1.41.0"}}