@@ -274,7 +274,7 @@ function composeFunctions(functions: any[]): LootFunction {
274274 for ( const fn of functions ) {
275275 if ( Array . isArray ( fn ) ) {
276276 composeFunctions ( fn )
277- } else if ( composeConditions ( fn . conditions ?? [ ] ) ( ctx ) ) {
277+ } else if ( isObject ( fn ) && composeConditions ( fn . conditions ?? [ ] ) ( ctx ) ) {
278278 const type = fn . function ?. replace ( / ^ m i n e c r a f t : / , '' ) ;
279279 ( LootFunctions [ type ] ?.( fn ) ?? ( i => i ) ) ( item , ctx )
280280 }
@@ -349,7 +349,7 @@ const LootFunctions: Record<string, (params: any) => LootFunction> = {
349349 set_attributes : ( { modifiers, replace } ) => ( item , ctx ) => {
350350 if ( ! Array . isArray ( modifiers ) ) return
351351 const newModifiers = modifiers . map < AttributeModifier > ( m => {
352- if ( typeof m !== 'object' || m === null ) m = { }
352+ if ( ! isObject ( m ) ) m = { }
353353 return {
354354 id : Identifier . parse ( typeof m . id === 'string' ? m . id : '' ) ,
355355 type : Identifier . parse ( typeof m . attribute === 'string' ? m . attribute : '' ) ,
@@ -386,7 +386,7 @@ const LootFunctions: Record<string, (params: any) => LootFunction> = {
386386 item . set ( 'written_book_content' , newContent )
387387 } ,
388388 set_components : ( { components } ) => ( item ) => {
389- if ( typeof components !== 'object' || components === null ) {
389+ if ( ! isObject ( components ) ) {
390390 return
391391 }
392392 for ( const [ key , value ] of Object . entries ( components ) ) {
@@ -432,7 +432,7 @@ const LootFunctions: Record<string, (params: any) => LootFunction> = {
432432 }
433433 } ,
434434 set_enchantments : ( { enchantments, add } ) => ( item , ctx ) => {
435- if ( typeof enchantments !== 'object' || enchantments === null ) {
435+ if ( ! isObject ( enchantments ) ) {
436436 return
437437 }
438438 if ( item . is ( 'book' ) ) {
@@ -490,7 +490,9 @@ const LootFunctions: Record<string, (params: any) => LootFunction> = {
490490 }
491491 } ,
492492 toggle_tooltips : ( { toggles } ) => ( item ) => {
493- if ( typeof toggles !== 'object' || toggles === null ) return
493+ if ( ! isObject ( toggles ) ) {
494+ return
495+ }
494496 Object . entries ( toggles ) . forEach ( ( [ key , value ] ) => {
495497 if ( typeof value !== 'boolean' ) return
496498 const tag = item . get ( key , tag => tag )
0 commit comments