@@ -4,6 +4,7 @@ const assert = require('assert')
4
4
const testedVersions = require ( '..' ) . testedVersions
5
5
6
6
describe ( 'Block From Properties' , ( ) => {
7
+ // PC (Java)
7
8
it ( 'spruce half slab: waterlogged, upper (pc_1.16.4)' , ( ) => {
8
9
const registry = require ( 'prismarine-registry' ) ( '1.16.4' )
9
10
const Block = require ( 'prismarine-block' ) ( registry )
@@ -14,6 +15,18 @@ describe('Block From Properties', () => {
14
15
expect ( block . stateId ) . toBe ( 8310 )
15
16
expect ( block . getProperties ( ) ) . toMatchObject ( properties )
16
17
} )
18
+ it ( 'Boolean properties are string (1.18.2, ...)' , ( ) => {
19
+ const registry = require ( 'prismarine-registry' ) ( '1.18.2' )
20
+ const Block = require ( 'prismarine-block' ) ( registry )
21
+ const signId = registry . blocksByName . oak_sign . id
22
+ const sourceProperties = { waterlogged : 'false' , rotation : '8' }
23
+
24
+ const block = Block . fromProperties ( signId , sourceProperties , 0 )
25
+ expect ( block . stateId ) . toBe ( 3455 )
26
+ expect ( block . getProperties ( ) ) . toMatchObject ( { waterlogged : false , rotation : 8 } )
27
+ } )
28
+
29
+ // Bedrock
17
30
it ( 'spruce half slab: waterlogged, upper (bedrock_1.17.10)' , ( ) => {
18
31
const registry = require ( 'prismarine-registry' ) ( 'bedrock_1.17.10' )
19
32
const Block = require ( 'prismarine-block' ) ( registry )
@@ -42,10 +55,16 @@ describe('versions should return block state and properties', () => {
42
55
// make sure that .fromProperties works
43
56
{
44
57
const blockData = registry . blocksByName . light_weighted_pressure_plate
45
- const properties = { pc : { power : 2 } , bedrock : { redstone_signal : 2 } } [ e ]
58
+ const properties = { pc : { power : '2' } , bedrock : { redstone_signal : 2 } } [ e ]
46
59
const block = Block . fromProperties ( blockData . name , properties , 0 )
47
60
assert ( block . stateId >= blockData . minStateId && block . stateId <= blockData . maxStateId )
48
- expect ( block . getProperties ( ) ) . toMatchObject ( properties )
61
+ const propertiesNormalized = block . getProperties ( )
62
+ if ( e === 'pc' ) {
63
+ for ( const key in propertiesNormalized ) {
64
+ propertiesNormalized [ key ] = propertiesNormalized [ key ] . toString ( )
65
+ }
66
+ }
67
+ expect ( propertiesNormalized ) . toMatchObject ( properties )
49
68
}
50
69
51
70
// Make sure type IDs work
0 commit comments