Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue #229 #231

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/bedrock/1.18/ChunkColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,28 @@ class ChunkColumn180 extends ChunkColumn13 {
networkDecodeNoCache (buffer, sectionCount) {
const stream = buffer instanceof Buffer ? new Stream(buffer) : buffer

if (sectionCount === -1 || sectionCount === -2) { // In 1.18+, with sectionCount as -1/-2 we only get the biomes here
this.loadBiomes(stream, StorageType.Runtime)
const borderblocks = stream.readBuffer(stream.readZigZagVarInt())
if (borderblocks.length) {
throw new Error(`Can't handle border blocks (length: ${borderblocks.length})`)
if (sectionCount !== -1 && sectionCount !== -2) { // In 1.18+, with sectionCount as -1/-2 we only get the biomes here
this.sections = []
for (let i = 0; i < sectionCount; i++) {
// in 1.17.30+, chunk index is sent in payload
const section = new SubChunk(this.registry, this.Block, { y: i, subChunkVersion: this.subChunkVersion })
section.decode(StorageType.Runtime, stream)
this.setSection(i, section)
}
} else {
// Possible some servers may send us a 1.17 chunk with 1.18 server version
super.networkDecodeNoCache(stream, sectionCount)
}

this.loadBiomes(stream, StorageType.Runtime)
const borderBlocks = stream.readBuffer(stream.readZigZagVarInt())
if (borderBlocks.length) {
throw new Error(`Can't handle border blocks (length: ${borderBlocks.length})`)
}

let startOffset = stream.readOffset
while (stream.peek() === 0x0A) {
const { data, metadata } = nbt.protos.littleVarint.parsePacketBuffer('nbt', stream.buffer, startOffset)
stream.readOffset += metadata.size
startOffset += metadata.size
this.addBlockEntity(data)
}
}

Expand Down