@@ -274,7 +274,7 @@ function composeFunctions(functions: any[]): LootFunction {
274
274
for ( const fn of functions ) {
275
275
if ( Array . isArray ( fn ) ) {
276
276
composeFunctions ( fn )
277
- } else if ( composeConditions ( fn . conditions ?? [ ] ) ( ctx ) ) {
277
+ } else if ( isObject ( fn ) && composeConditions ( fn . conditions ?? [ ] ) ( ctx ) ) {
278
278
const type = fn . function ?. replace ( / ^ m i n e c r a f t : / , '' ) ;
279
279
( LootFunctions [ type ] ?.( fn ) ?? ( i => i ) ) ( item , ctx )
280
280
}
@@ -349,7 +349,7 @@ const LootFunctions: Record<string, (params: any) => LootFunction> = {
349
349
set_attributes : ( { modifiers, replace } ) => ( item , ctx ) => {
350
350
if ( ! Array . isArray ( modifiers ) ) return
351
351
const newModifiers = modifiers . map < AttributeModifier > ( m => {
352
- if ( typeof m !== 'object' || m === null ) m = { }
352
+ if ( ! isObject ( m ) ) m = { }
353
353
return {
354
354
id : Identifier . parse ( typeof m . id === 'string' ? m . id : '' ) ,
355
355
type : Identifier . parse ( typeof m . attribute === 'string' ? m . attribute : '' ) ,
@@ -386,7 +386,7 @@ const LootFunctions: Record<string, (params: any) => LootFunction> = {
386
386
item . set ( 'written_book_content' , newContent )
387
387
} ,
388
388
set_components : ( { components } ) => ( item ) => {
389
- if ( typeof components !== 'object' || components === null ) {
389
+ if ( ! isObject ( components ) ) {
390
390
return
391
391
}
392
392
for ( const [ key , value ] of Object . entries ( components ) ) {
@@ -432,7 +432,7 @@ const LootFunctions: Record<string, (params: any) => LootFunction> = {
432
432
}
433
433
} ,
434
434
set_enchantments : ( { enchantments, add } ) => ( item , ctx ) => {
435
- if ( typeof enchantments !== 'object' || enchantments === null ) {
435
+ if ( ! isObject ( enchantments ) ) {
436
436
return
437
437
}
438
438
if ( item . is ( 'book' ) ) {
@@ -490,7 +490,9 @@ const LootFunctions: Record<string, (params: any) => LootFunction> = {
490
490
}
491
491
} ,
492
492
toggle_tooltips : ( { toggles } ) => ( item ) => {
493
- if ( typeof toggles !== 'object' || toggles === null ) return
493
+ if ( ! isObject ( toggles ) ) {
494
+ return
495
+ }
494
496
Object . entries ( toggles ) . forEach ( ( [ key , value ] ) => {
495
497
if ( typeof value !== 'boolean' ) return
496
498
const tag = item . get ( key , tag => tag )
0 commit comments