1
1
/* eslint-env mocha */
2
2
3
- const versions = [ 'bedrock_1.16.220' , 'bedrock_1.17.40' , 'bedrock_1.18.0' , '1.8' , '1.9' , '1.10' , '1.11' , '1.12' , '1.13.2' , '1.14.4' , '1.15.2' , '1.16.1' , '1.17' , '1.18' ]
3
+ const { allVersions } = require ( './versions' )
4
4
const constants = require ( '../src/pc/common/constants' )
5
5
const { Vec3 } = require ( 'vec3' )
6
6
const assert = require ( 'assert' )
7
7
const expect = require ( 'expect' ) . default
8
8
9
- for ( const version of versions ) {
9
+ for ( const version of allVersions ) {
10
10
const registry = require ( 'prismarine-registry' ) ( version )
11
11
const Block = require ( 'prismarine-block' ) ( registry )
12
12
const ChunkColumn = require ( 'prismarine-chunk' ) ( registry )
13
13
14
+ // TODO: fix 2 bugs: node-mc-data feature checks fail on bedrock 0.14, is missing some functions and bedrock v1.0 chunk impl fails here
15
+ // let chunkHeight
16
+ const chunkHeight = constants . CHUNK_HEIGHT
17
+ if ( version === 'bedrock_0.14' || version === 'bedrock_1.0' ) continue
18
+
14
19
describe ( 'ChunkColumn on ' + version , ( ) => {
15
20
it ( 'use function to initialize the chunk column' , ( ) => {
16
21
const stateId = 20
17
22
const block = Block . fromStateId ( stateId , 1 )
23
+ assert ( block . stateId === stateId )
18
24
const column = new ChunkColumn ( )
19
25
column . initialize ( ( ) => { return block } )
20
26
21
27
const p = new Vec3 ( 0 , 0 , 0 )
22
28
for ( p . x = 0 ; p . x < constants . SECTION_WIDTH ; p . x ++ ) {
23
- for ( p . y = 0 ; p . y < constants . CHUNK_HEIGHT ; p . y ++ ) {
29
+ for ( p . y = 0 ; p . y < chunkHeight ; p . y ++ ) {
24
30
for ( p . z = 0 ; p . z < constants . SECTION_WIDTH ; p . z ++ ) {
25
31
if ( column . getBlock ( p ) . stateId !== stateId ) {
26
32
throw new Error ( 'id mismatch: expected ' + stateId + ' got ' + column . getBlock ( p ) . stateId )
@@ -35,7 +41,7 @@ for (const version of versions) {
35
41
36
42
let different = 0
37
43
const p = new Vec3 ( 0 , 0 , 0 )
38
- for ( p . y = 0 ; p . y < constants . CHUNK_HEIGHT ; p . y ++ ) {
44
+ for ( p . y = 0 ; p . y < chunkHeight ; p . y ++ ) {
39
45
for ( p . z = 0 ; p . z < constants . SECTION_WIDTH ; p . z ++ ) {
40
46
for ( p . x = 0 ; p . x < constants . SECTION_WIDTH ; p . x ++ ) {
41
47
// 0 cannot be assumed as air, bedrock assigns stateIds alphabetically
@@ -61,7 +67,7 @@ for (const version of versions) {
61
67
it ( 'Defaults to all blocks being air' , function ( ) {
62
68
const chunk = new ChunkColumn ( )
63
69
assert . strictEqual ( registry . blocksByName . air . id , chunk . getBlock ( new Vec3 ( 0 , 0 , 0 ) ) . type )
64
- assert . strictEqual ( registry . blocksByName . air . id , chunk . getBlock ( new Vec3 ( 15 , constants . CHUNK_HEIGHT - 1 , 15 ) ) . type )
70
+ assert . strictEqual ( registry . blocksByName . air . id , chunk . getBlock ( new Vec3 ( 15 , chunkHeight - 1 , 15 ) ) . type )
65
71
} )
66
72
67
73
it ( 'Out of bounds blocks being air' , function ( ) {
@@ -97,11 +103,11 @@ for (const version of versions) {
97
103
98
104
// Everything should have a stateId
99
105
{
100
- const birchPlanksId = registry . blocksByName . planks ?. defaultState || registry . blocksByName . birch_planks . defaultState
106
+ const birchPlanksId = registry . blocksByName . planks ?. defaultState || registry . blocksByName . wood_planks ?. defaultState || registry . blocksByName . birch_planks . defaultState
101
107
chunk . setBlock ( new Vec3 ( 0 , 0 , 0 ) , Block . fromStateId ( birchPlanksId ) )
102
108
assert . strictEqual ( birchPlanksId , chunk . getBlock ( new Vec3 ( 0 , 0 , 0 ) ) . stateId )
103
109
104
- const ironBlockId = registry . blocksByName . iron_block . defaultState
110
+ const ironBlockId = registry . blocksByName . iron_block ?. defaultState || registry . blocksByName . block_of_iron . defaultState
105
111
chunk . setBlock ( new Vec3 ( 0 , 37 , 0 ) , Block . fromStateId ( ironBlockId ) )
106
112
assert . strictEqual ( ironBlockId , chunk . getBlock ( new Vec3 ( 0 , 37 , 0 ) ) . stateId )
107
113
}
0 commit comments