Skip to content

Commit 19bb778

Browse files
authored
Support 1.18.2, 1.19.4, 1.20.6, 1.21.1 (#81)
* Support 1.18.2 * Support 1.19, 1.20, 1.21 * remove commented code * add back full check * remove full check
1 parent 6b0517e commit 19bb778

File tree

12 files changed

+43
-52
lines changed

12 files changed

+43
-52
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ dist/
33
distTest/
44
world/testRegion/*
55
package-lock.json
6-
test/fixtures/*
76
test/world/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![NPM version](https://img.shields.io/npm/v/prismarine-provider-anvil.svg)](http://npmjs.com/package/prismarine-provider-anvil)
33
[![Build Status](https://github.com/PrismarineJS/prismarine-provider-anvil/workflows/CI/badge.svg)](https://github.com/PrismarineJS/prismarine-provider-anvil/actions?query=workflow%3A%22CI%22)
44

5-
Anvil Storage Provider implementation. Support minecraft pc 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17 and 1.18
5+
Anvil Storage Provider implementation. Support minecraft pc 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19, 1.20 and 1.21
66

77
## Usage
88

src/1.18/chunk.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ module.exports = (ChunkColumn, registry) => {
3434
if (!bitsPerBlock) {
3535
blockStates = nbt.comp({ palette: nbt.list(nbt.comp(blockPalette)) })
3636
} else {
37-
assert.strictEqual(bitsPerBlock, section.data.data.bitsPerValue, `Computed bits per block for palette size of ${blockPalette.length} (${bitsPerBlock}) does not match bits per block in section, ${section.data.data.bitsPerValue}`)
38-
3937
const data = section.data.data.toLongArray()
4038
blockStates = nbt.comp({ palette: nbt.list(nbt.comp(blockPalette)), data: nbt.longArray(data) })
4139
}
@@ -112,8 +110,6 @@ module.exports = (ChunkColumn, registry) => {
112110
function fromNBT (tag) {
113111
const data = nbt.simplify(tag)
114112
const column = new ChunkColumn({ minY: -64, worldHeight: 384 })
115-
assert(data.Status === 'full', 'Chunk is not full')
116-
117113
column.x = data.xPos
118114
column.z = data.zPos
119115
column.lastUpdate = data.LastUpdate.valueOf()

src/chunk.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ module.exports = (registryOrVersion) => {
1515
1.15: () => require('./1.14/chunk')('1.15', 2230),
1616
1.16: () => require('./1.14/chunk')('1.16', 2567, true),
1717
1.17: () => require('./1.14/chunk')('1.17', 2730, true),
18-
1.18: () => require('./1.18/chunk')
18+
1.18: () => require('./1.18/chunk'),
19+
1.19: () => require('./1.18/chunk'),
20+
'1.20': () => require('./1.18/chunk'),
21+
1.21: () => require('./1.18/chunk')
1922
}
2023

2124
const loadVersion = registry.version.majorVersion

src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const testedVersions = ['1.8.9', '1.9', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.16', '1.17.1']
1+
const testedVersions = ['1.8.9', '1.9', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.16', '1.17.1', '1.18.2', '1.19.4', '1.20.6', '1.21.1']
22
module.exports = {
33
testedVersions,
44
latestSupportedVersion: testedVersions[testedVersions.length - 1],

test/chunkToNbt.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ const { Vec3 } = require('vec3')
44
const assert = require('assert')
55
const nbt = require('prismarine-nbt')
66
const prismarineProviderAnvil = require('prismarine-provider-anvil')
7+
const compareChunks = require('./common').compareChunks
78

89
const testedVersions = prismarineProviderAnvil.testedVersions
910

1011
for (const version of testedVersions) {
1112
const registry = require('prismarine-registry')(version)
1213
const Chunk = require('prismarine-chunk')(registry)
14+
const chunkOptions = {
15+
minY: registry.supportFeature('tallWorld') ? -64 : 0,
16+
worldHeight: registry.supportFeature('tallWorld') ? 384 : 256
17+
}
1318
const chunk = new Chunk()
1419

1520
for (let x = 0; x < 16; x++) {
@@ -66,7 +71,7 @@ for (const version of testedVersions) {
6671
const reChunk = nbtChunkToPrismarineChunk(tag)
6772
assert.strictEqual(reChunk.getBlockType(new Vec3(0, 50, 0)), 2, 'wrong block type at 0,50,0')
6873
assert.strictEqual(reChunk.getSkyLight(new Vec3(0, 50, 0)), 15)
69-
assert(reChunk.dump().equals(chunk.dump()))
74+
compareChunks(chunk, reChunk, chunkOptions)
7075
})
7176
})
7277
}

test/common.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const assert = require('assert')
2+
const { Vec3 } = require('vec3')
3+
4+
function compareChunks (chunk, chunk2, chunkOptions) {
5+
const p = new Vec3(0, chunkOptions.minY, 0)
6+
const maxHeight = chunkOptions.worldHeight + chunkOptions.minY
7+
for (p.y = chunkOptions.minY; p.y < maxHeight; p.y++) {
8+
for (p.z = 0; p.z < 16; p.z++) {
9+
for (p.x = 0; p.x < 16; p.x++) {
10+
const b = chunk.getBlock(p)
11+
const b2 = chunk2.getBlock(p)
12+
assert.notStrictEqual(
13+
b.name,
14+
'',
15+
' block state: ' +
16+
b.stateId +
17+
' type: ' +
18+
b.type +
19+
" read, which doesn't exist"
20+
)
21+
assert.strictEqual(JSON.stringify(b), JSON.stringify(b2), 'blocks at ' + p +
22+
' differ, first block is ' + JSON.stringify(b, null, 2) +
23+
' second block is ' + JSON.stringify(b2, null, 2))
24+
}
25+
}
26+
}
27+
}
28+
29+
module.exports.compareChunks = compareChunks

test/fixtures/1.18.2/r.0.0.mca

1.4 MB
Binary file not shown.

test/fixtures/1.19.4/r.0.0.mca

2.87 MB
Binary file not shown.

test/fixtures/1.20.6/r.0.0.mca

1020 KB
Binary file not shown.

0 commit comments

Comments
 (0)