Skip to content

Commit

Permalink
Fix pc1.18 light index (#271)
Browse files Browse the repository at this point in the history
Fix #267 removing the +1 offset for light
  • Loading branch information
extremeheat authored Jan 15, 2025
1 parent c1e088a commit 9a9673b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/pc/1.18/ChunkColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ const CommonChunkColumn = require('../common/CommonChunkColumn')
const constants = require('../common/constants')
const neededBits = require('../common/neededBits')

const AQUATIC_UPDATE_MIN_Y = -64
const AQUATIC_UPDATE_WORLD_HEIGHT = 384
const CAVES_UPDATE_MIN_Y = -64
const CAVES_UPDATE_WORLD_HEIGHT = 384

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

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

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

0 comments on commit 9a9673b

Please sign in to comment.