@@ -8,7 +8,7 @@ describe('test based on examples', () => {
8
8
const ironShovelItem = new Item ( 256 , 1 )
9
9
10
10
it ( 'constructor makes item correctly' , ( ) => {
11
- const val = { type : 256 , count : 1 , metadata : 0 , nbt : null , name : 'iron_shovel' , displayName : 'Iron Shovel' , stackSize : 1 , stackId : null }
11
+ const val = { type : 256 , count : 1 , metadata : 0 , nbt : null , name : 'iron_shovel' , displayName : 'Iron Shovel' , stackSize : 1 , stackId : null , maxDurability : 250 }
12
12
expect ( JSON . parse ( JSON . stringify ( ironShovelItem ) ) ) . toStrictEqual ( val )
13
13
} )
14
14
@@ -19,7 +19,7 @@ describe('test based on examples', () => {
19
19
it ( 'use .fromNotch' , ( ) => {
20
20
const toNotch = Item . toNotch ( ironShovelItem )
21
21
const fromNotch = Item . fromNotch ( toNotch )
22
- const expectedObj = { count : 1 , displayName : 'Iron Shovel' , metadata : 0 , name : 'iron_shovel' , nbt : null , stackSize : 1 , type : 256 , stackId : null }
22
+ const expectedObj = { count : 1 , displayName : 'Iron Shovel' , metadata : 0 , name : 'iron_shovel' , nbt : null , stackSize : 1 , type : 256 , stackId : null , maxDurability : 250 }
23
23
expect ( JSON . parse ( JSON . stringify ( fromNotch ) ) ) . toStrictEqual ( expectedObj )
24
24
} )
25
25
} )
@@ -28,19 +28,19 @@ describe('test based on examples', () => {
28
28
const ironShovelItem = new Item ( 472 , 1 )
29
29
30
30
it ( 'constructor makes item correctly' , ( ) => {
31
- const expectedObj = { count : 1 , displayName : 'Iron Shovel' , metadata : 0 , name : 'iron_shovel' , nbt : { name : '' , type : 'compound' , value : { Damage : { type : 'int' , value : 0 } } } , stackSize : 1 , type : 472 , stackId : null }
31
+ const expectedObj = { count : 1 , displayName : 'Iron Shovel' , metadata : 0 , name : 'iron_shovel' , nbt : null , stackSize : 1 , type : 472 , stackId : null , maxDurability : 250 }
32
32
expect ( JSON . parse ( JSON . stringify ( ironShovelItem ) ) ) . toStrictEqual ( expectedObj )
33
33
} )
34
34
35
35
it ( 'use .toNotch' , ( ) => {
36
- const expectedObj = { itemCount : 1 , itemId : 472 , present : true , nbtData : { name : '' , type : 'compound' , value : { Damage : { type : 'int' , value : 0 } } } }
36
+ const expectedObj = { itemCount : 1 , itemId : 472 , present : true , nbtData : undefined }
37
37
expect ( Item . toNotch ( ironShovelItem ) ) . toStrictEqual ( expectedObj )
38
38
} )
39
39
40
40
it ( 'use .fromNotch' , ( ) => {
41
41
const toNotch = Item . toNotch ( ironShovelItem )
42
42
const fromNotch = Item . fromNotch ( toNotch )
43
- const expectedObj = { count : 1 , displayName : 'Iron Shovel' , metadata : 0 , name : 'iron_shovel' , nbt : { name : '' , type : 'compound' , value : { Damage : { type : 'int' , value : 0 } } } , stackSize : 1 , type : 472 , stackId : null }
43
+ const expectedObj = { count : 1 , displayName : 'Iron Shovel' , metadata : 0 , name : 'iron_shovel' , nbt : null , stackSize : 1 , type : 472 , stackId : null , maxDurability : 250 }
44
44
expect ( JSON . parse ( JSON . stringify ( fromNotch ) ) ) . toStrictEqual ( expectedObj )
45
45
} )
46
46
} )
@@ -50,7 +50,7 @@ describe('test based on examples', () => {
50
50
const ironShovelItem = new Item ( registry . itemsByName . iron_shovel . id , 1 )
51
51
52
52
it ( 'constructor makes item correctly' , ( ) => {
53
- const val = { type : registry . itemsByName . iron_shovel . id , count : 1 , metadata : 0 , nbt : { name : '' , type : 'compound' , value : { Damage : { type : 'int' , value : 0 } } } , name : 'iron_shovel' , displayName : 'Iron Shovel' , stackSize : 1 , stackId : 0 }
53
+ const val = { type : registry . itemsByName . iron_shovel . id , count : 1 , metadata : 0 , nbt : { name : '' , type : 'compound' , value : { Damage : { type : 'int' , value : 0 } } } , name : 'iron_shovel' , displayName : 'Iron Shovel' , stackSize : 1 , stackId : 0 , maxDurability : 250 }
54
54
expect ( JSON . parse ( JSON . stringify ( ironShovelItem ) ) ) . toStrictEqual ( val )
55
55
} )
56
56
@@ -61,7 +61,7 @@ describe('test based on examples', () => {
61
61
it ( 'use .fromNotch' , ( ) => {
62
62
const toNotch = Item . toNotch ( ironShovelItem )
63
63
const fromNotch = Item . fromNotch ( toNotch )
64
- const expectedObj = { count : 1 , displayName : 'Iron Shovel' , metadata : 0 , name : 'iron_shovel' , nbt : { name : '' , type : 'compound' , value : { Damage : { type : 'int' , value : 0 } } } , stackSize : 1 , type : registry . itemsByName . iron_shovel . id , stackId : 0 }
64
+ const expectedObj = { count : 1 , displayName : 'Iron Shovel' , metadata : 0 , name : 'iron_shovel' , nbt : { name : '' , type : 'compound' , value : { Damage : { type : 'int' , value : 0 } } } , stackSize : 1 , type : registry . itemsByName . iron_shovel . id , stackId : 0 , maxDurability : 250 }
65
65
expect ( JSON . parse ( JSON . stringify ( fromNotch ) ) ) . toStrictEqual ( expectedObj )
66
66
} )
67
67
} )
@@ -350,30 +350,30 @@ describe('set item.enchants', () => {
350
350
const Item = require ( 'prismarine-item' ) ( registry )
351
351
352
352
it ( 'unenchanted stone sword' , ( ) => {
353
- const newItem = new Item ( 704 , 1 )
353
+ const newItem = new Item ( 704 , 1 , undefined , undefined , 0 , true )
354
354
const item = Item . fromNotch ( { network_id : 704 , count : 1 , metadata : 0 , stack_id : 0 , has_stack_id : true , extra : { has_nbt : false , can_place_on : [ ] , can_destroy : [ ] } } )
355
355
const enchs = item . enchants
356
356
newItem . enchants = enchs
357
357
expect ( newItem ) . toStrictEqual ( item )
358
358
} )
359
359
it ( 'unbreaking 1 iron pickaxe' , ( ) => {
360
- const newItem = new Item ( 716 , 1 )
360
+ const newItem = new Item ( 716 , 1 , undefined , undefined , 1 , true )
361
361
const item = Item . fromNotch ( { network_id : 716 , count : 1 , metadata : 0 , stack_id : 1 , has_stack_id : true , extra : { has_nbt : true , nbt : { version : 1 , nbt : { name : '' , type : 'compound' , value : { ench : { type : 'list' , value : { type : 'compound' , value : [ { id : { type : 'short' , value : 17 } , lvl : { type : 'short' , value : 1 } } ] } } , RepairCost : { type : 'int' , value : 3 } } } } , can_place_on : [ ] , can_destroy : [ ] } } )
362
362
const enchs = item . enchants
363
363
newItem . enchants = enchs
364
364
newItem . repairCost = 3
365
365
expect ( newItem ) . toStrictEqual ( item )
366
366
} )
367
367
it ( 'efficiency 5 diamond shovel' , ( ) => {
368
- const newItem = new Item ( 720 , 1 )
368
+ const newItem = new Item ( 720 , 1 , undefined , undefined , 2 , true )
369
369
const item = Item . fromNotch ( { network_id : 720 , count : 1 , metadata : 0 , stack_id : 2 , has_stack_id : true , extra : { has_nbt : true , nbt : { version : 1 , nbt : { name : '' , type : 'compound' , value : { ench : { type : 'list' , value : { type : 'compound' , value : [ { id : { type : 'short' , value : 15 } , lvl : { type : 'short' , value : 5 } } ] } } , RepairCost : { type : 'int' , value : 2 } } } } , can_place_on : [ ] , can_destroy : [ ] } } )
370
370
const enchs = item . enchants
371
371
newItem . enchants = enchs
372
372
newItem . repairCost = 2
373
373
expect ( newItem ) . toStrictEqual ( item )
374
374
} )
375
375
it ( 'protection 4, mending diamond leggings' , ( ) => {
376
- const newItem = new Item ( 752 , 1 )
376
+ const newItem = new Item ( 752 , 1 , undefined , undefined , 3 , true )
377
377
const item = Item . fromNotch ( { network_id : 752 , count : 1 , metadata : 0 , stack_id : 3 , has_stack_id : true , extra : { has_nbt : true , nbt : { version : 1 , nbt : { name : '' , type : 'compound' , value : { ench : { type : 'list' , value : { type : 'compound' , value : [ { id : { type : 'short' , value : 0 } , lvl : { type : 'short' , value : 4 } } , { id : { type : 'short' , value : 26 } , lvl : { type : 'short' , value : 1 } } ] } } , RepairCost : { type : 'int' , value : 3 } } } } , can_place_on : [ ] , can_destroy : [ ] } } )
378
378
const enchs = item . enchants
379
379
newItem . enchants = enchs
@@ -385,30 +385,30 @@ describe('set item.enchants', () => {
385
385
const Item = require ( 'prismarine-item' ) ( 'bedrock_1.19.1' )
386
386
387
387
it ( 'unenchanted iron hoe' , ( ) => {
388
- const newItem = new Item ( 754 , 1 )
388
+ const newItem = new Item ( 754 , 1 , undefined , undefined , 0 , true )
389
389
const item = Item . fromNotch ( { network_id : 754 , count : 1 , metadata : 0 , stack_id : 0 , has_stack_id : true , extra : { has_nbt : false , can_place_on : [ ] , can_destroy : [ ] } } )
390
390
const enchs = item . enchants
391
391
newItem . enchants = enchs
392
392
expect ( newItem ) . toStrictEqual ( item )
393
393
} )
394
394
it ( 'silk touch stone axe' , ( ) => {
395
- const newItem = new Item ( 743 , 1 )
395
+ const newItem = new Item ( 743 , 1 , undefined , undefined , 1 , true )
396
396
const item = Item . fromNotch ( { network_id : 743 , count : 1 , metadata : 0 , stack_id : 1 , has_stack_id : true , extra : { has_nbt : true , nbt : { version : 1 , nbt : { name : '' , type : 'compound' , value : { ench : { type : 'list' , value : { type : 'compound' , value : [ { id : { type : 'short' , value : 16 } , lvl : { type : 'short' , value : 1 } } ] } } , RepairCost : { type : 'int' , value : 1 } } } } , can_place_on : [ ] , can_destroy : [ ] } } )
397
397
const enchs = item . enchants
398
398
newItem . enchants = enchs
399
399
newItem . repairCost = 1
400
400
expect ( newItem ) . toStrictEqual ( item )
401
401
} )
402
402
it ( 'lure 3 fishing rod' , ( ) => {
403
- const newItem = new Item ( 836 , 1 )
403
+ const newItem = new Item ( 836 , 1 , undefined , undefined , 2 , true )
404
404
const item = Item . fromNotch ( { network_id : 836 , count : 1 , metadata : 0 , stack_id : 2 , has_stack_id : true , extra : { has_nbt : true , nbt : { version : 1 , nbt : { name : '' , type : 'compound' , value : { ench : { type : 'list' , value : { type : 'compound' , value : [ { id : { type : 'short' , value : 24 } , lvl : { type : 'short' , value : 3 } } ] } } , RepairCost : { type : 'int' , value : 2 } } } } , can_place_on : [ ] , can_destroy : [ ] } } )
405
405
const enchs = item . enchants
406
406
newItem . enchants = enchs
407
407
newItem . repairCost = 2
408
408
expect ( newItem ) . toStrictEqual ( item )
409
409
} )
410
410
it ( 'fire prot 3, unbreaking 2, respiration 3 diamond helmet' , ( ) => {
411
- const newItem = new Item ( 786 , 1 )
411
+ const newItem = new Item ( 786 , 1 , undefined , undefined , 3 , true )
412
412
const item = Item . fromNotch ( { network_id : 786 , count : 1 , metadata : 0 , stack_id : 3 , has_stack_id : true , extra : { has_nbt : true , nbt : { version : 1 , nbt : { name : '' , type : 'compound' , value : { ench : { type : 'list' , value : { type : 'compound' , value : [ { id : { type : 'short' , value : 1 } , lvl : { type : 'short' , value : 3 } } , { id : { type : 'short' , value : 17 } , lvl : { type : 'short' , value : 2 } } , { id : { type : 'short' , value : 6 } , lvl : { type : 'short' , value : 3 } } ] } } , RepairCost : { type : 'int' , value : 3 } } } } , can_place_on : [ ] , can_destroy : [ ] } } )
413
413
const enchs = item . enchants
414
414
newItem . enchants = enchs
0 commit comments