Skip to content

Commit 9a9673b

Browse files
authored
Fix pc1.18 light index (#271)
Fix #267 removing the +1 offset for light
1 parent c1e088a commit 9a9673b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/pc/1.18/ChunkColumn.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ const CommonChunkColumn = require('../common/CommonChunkColumn')
66
const constants = require('../common/constants')
77
const neededBits = require('../common/neededBits')
88

9-
const AQUATIC_UPDATE_MIN_Y = -64
10-
const AQUATIC_UPDATE_WORLD_HEIGHT = 384
9+
const CAVES_UPDATE_MIN_Y = -64
10+
const CAVES_UPDATE_WORLD_HEIGHT = 384
1111

1212
// wrap with func to provide version specific Block
1313
module.exports = (Block, mcData) => {
1414
return class ChunkColumn extends CommonChunkColumn {
1515
static get section () { return ChunkSection }
1616
constructor (options) {
1717
super(mcData)
18-
this.minY = options?.minY ?? AQUATIC_UPDATE_MIN_Y
19-
this.worldHeight = options?.worldHeight ?? AQUATIC_UPDATE_WORLD_HEIGHT
18+
this.minY = options?.minY ?? CAVES_UPDATE_MIN_Y
19+
this.worldHeight = options?.worldHeight ?? CAVES_UPDATE_WORLD_HEIGHT
2020
this.numSections = this.worldHeight >> 4
2121
this.maxBitsPerBlock = neededBits(Object.values(mcData.blocks).reduce((high, block) => Math.max(high, block.maxStateId), 0))
2222
this.maxBitsPerBiome = neededBits(Object.values(mcData.biomes).length)
@@ -287,8 +287,8 @@ module.exports = (Block, mcData) => {
287287

288288
_loadBlockLightNibbles (y, buffer) {
289289
if (buffer.length !== 2048) throw new Error('Invalid light nibble buffer length ' + buffer.length)
290-
const minCY = Math.abs(this.minY >> 4)
291-
this.blockLightMask.set(y + minCY, 1) // minCY + 1 extra layer below
290+
const minCY = Math.abs(this.minY >> 4) + 1 // minCY + 1 extra layer below
291+
this.blockLightMask.set(y + minCY, 1)
292292
this.blockLightSections[y + minCY] = new BitArray({
293293
bitsPerValue: 4,
294294
capacity: 4096,
@@ -298,8 +298,8 @@ module.exports = (Block, mcData) => {
298298

299299
_loadSkyLightNibbles (y, buffer) {
300300
if (buffer.length !== 2048) throw new Error('Invalid light nibble buffer length: ' + buffer.length)
301-
const minCY = Math.abs(this.minY >> 4)
302-
this.skyLightMask.set(y + minCY, 1) // minCY + 1 extra layer below
301+
const minCY = Math.abs(this.minY >> 4) + 1 // minCY + 1 extra layer below
302+
this.skyLightMask.set(y + minCY, 1)
303303
this.skyLightSections[y + minCY] = new BitArray({
304304
bitsPerValue: 4,
305305
capacity: 4096,

0 commit comments

Comments
 (0)