在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):PrismarineJS/prismarine-chunk开源软件地址(OpenSource Url):https://github.com/PrismarineJS/prismarine-chunk开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):prismarine-chunkA class to hold chunk data for Minecraft: PC 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15 and 1.16 and Bedrock Edition 0.14 and 1.0, 1.16, 1.17 and 1.18 Usageconst registry = require('prismarine-registry')('1.8')
const ChunkColumn = require('prismarine-chunk')(registry)
const { Vec3 } = require("vec3")
const chunk = new ChunkColumn()
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 datapcTest data can be generated with minecraftChunkDumper. Install it globally with
bedrockRun tests in bedrock-provider (which loads chunks through a client as part of its tests) and copy the generated data from For the version, copy one chunk column of Note: 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 setting and getting block light, type, biome, entity and block entity data. APIChunkChunk(initData: { minY?: number, worldHeight?: number })Build 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. Chunk.initialize(iniFunc)Initialize a chunk.
That function is faster than iterating and calling the setBlock* manually. It is useful to generate a whole chunk and load a whole chunk. Chunk.versionreturns the version the chunk loader was called with Chunk.sectionreturns ChunkSection class for version Chunk.getBlock(pos)
Chunk.setBlock(pos,block)Set Chunk.getBlockType(pos)Get the block type at Chunk.getBlockStateId(pos)Get the block state id at Chunk.getBlockData(pos)Get the block data (metadata) at Chunk.getBlockLight(pos)Get the block light at Chunk.getSkyLight(pos)Get the block sky light at Chunk.getBiome(pos)Get the block biome id at Chunk.getBiomeColor(pos)Get the block biome color at Chunk.setBlockStateId(pos, stateId)Set the block type Chunk.setBlockType(pos, id)Set the block type Chunk.setBlockData(pos, data)Set the block Chunk.setBlockLight(pos, light)Set the block Chunk.setSkyLight(pos, light)Set the block sky Chunk.setBiome(pos, biome)Set the block Chunk.setBiomeColor(pos, biomeColor)Set the block Chunk.getBlockEntity(pos)Returns the block entity data at position if it exists Chunk.setBlockEntity(pos, nbt)Sets block entity data at position Chunk.loadBlockEntities(nbt)Loads an array of NBT data into the chunk column Chunk.toJson()Returns the chunk as json Chunk.fromJson(j)Load chunk from json Chunk.sectionsAvailable for pc chunk implementation. Array of y => section Can be used to identify whether a section is empty or not (will be null if it's the case) For 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 is in this section. pcChunk.getMask()Return the chunk bitmap 0b0000_0000_0000_0000(0x0000) means no chunks are set while 0b1111_1111_1111_1111(0xFFFF) means all chunks are set Chunk.dump()Returns the chunk raw data Chunk.load(data, bitmap = 0xFFFF, skyLightSent = true, fullChunk = true)Load raw Chunk.dumpLight()Returns the chunk raw light data (starting from 1.14) Chunk.loadLight(data, skyLightMask, blockLightMask, emptySkyLightMask = 0, emptyBlockLightMask = 0)Load lights into the chunk (starting from 1.14) Chunk.loadParsedLight (skyLight, blockLight, skyLightMask, blockLightMask, emptySkyLightMask, emptyBlockLightMask)Load lights into the chunk (starting from 1.17) Chunk.dumpBiomes()Returns the biomes as an array (starting from 1.15) Chunk.loadBiomes(biomes)Load biomes into the chunk (starting from 1.15) bedrockSee index.d.ts ChunkSectionpcstatic fromJson(j: any): ChunkSectionstatic sectionSize(skyLightSent?: boolean): numberconstructor(skyLightSent?: boolean)data: BuffertoJson(): { type: "Buffer"; data: number[]; }initialize(iniFunc: any): voidgetBiomeColor(pos: Vec3): { r: number; g: number; b: number; }setBiomeColor(pos: Vec3, r: number, g: number, b: number): voidgetBlockStateId(pos: Vec3): numbergetBlockType(pos: Vec3): numbergetBlockData(pos: Vec3): numbergetBlockLight(pos: Vec3): numbergetSkyLight(pos: Vec3): numbersetBlockStateId(pos: Vec3, stateId: number): voidsetBlockType(pos: Vec3, id: number): voidsetBlockData(pos: Vec3, data: Buffer): voidsetBlockLight(pos: Vec3, light: number): voidsetSkyLight(pos: Vec3, light: number): voiddump(): Bufferload(data: Buffer, skyLightSent?: boolean): voidbedrockSee index.d.ts compact()Shrinks the size of the SubChunk if possible after setBlock operations are done getPalette()Returns a list of unique block states that make up the chunk section |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论