Skip to content

Commit 790db07

Browse files
authored
Quick fix for pc1.17 masks (#85)
Keep the 1.14 impl for now and just overwrite the mask (previously an integer) to be a BitArray as expected by prismarine-chunk
1 parent 25da171 commit 790db07

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/1.14/chunk.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = (mcVersion, worldVersion, noSpan) => {
66
const ChunkSection = require('prismarine-chunk')(mcVersion).section
77

88
return (Chunk, mcData) => {
9+
const newFormat = mcData.supportFeature('newLightingDataFormat') // 1.17+
910
function nbtChunkToPrismarineChunk (data) {
1011
const nbtd = nbt.simplify(data)
1112
const chunk = new Chunk()
@@ -113,6 +114,17 @@ module.exports = (mcVersion, worldVersion, noSpan) => {
113114
})
114115
readByteArray(chunk.skyLightSections[section.Y + 1], section.SkyLight)
115116
}
117+
118+
if (newFormat) {
119+
chunk.blockLightMask = new BitArray({ bitsPerValue: 1, capacity: 16 })
120+
chunk.skyLightMask = new BitArray({ bitsPerValue: 1, capacity: 16 })
121+
chunk.sectionMask = new BitArray({ bitsPerValue: 1, capacity: 16 })
122+
for (let i = 0; i < 16; i++) {
123+
if (chunk.sections[i]) chunk.sectionMask.set(i, true)
124+
if (chunk.blockLightSections[i]) chunk.blockLightMask.set(i, true)
125+
if (chunk.skyLightSections[i]) chunk.skyLightMask.set(i, true)
126+
}
127+
}
116128
}
117129

118130
function parseValue (value, state) {

0 commit comments

Comments
 (0)