@@ -369,36 +369,25 @@ function inject (bot) {
369369 }
370370 if ( bot . fireworkRocketDuration !== 0 && entity . id === bot . entity ?. id && ! elytraFlying ) {
371371 bot . fireworkRocketDuration = 0
372- knownFireworks . splice ( 0 , knownFireworks . length )
372+ knownFireworks . clear ( )
373373 }
374374
375375 if ( startedFlying ) {
376376 bot . emit ( 'entityElytraFlew' , entity )
377377 }
378378 }
379379
380- const knownFireworks = [ ]
380+ const knownFireworks = new Set ( )
381381 function handleBotUsedFireworkRocket ( fireworkEntityId , fireworkInfo ) {
382- if ( knownFireworks . includes ( fireworkEntityId ) ) return
383- knownFireworks . push ( fireworkEntityId )
384- let flightDur = 1
385- if ( fireworkInfo ?. nbtData != null ) {
386- let nbt = fireworkInfo . nbtData
387- if ( nbt . type === 'compound' && nbt . value . Fireworks != null ) {
388- nbt = nbt . value . Fireworks
389- if ( nbt . type === 'compound' && nbt . value . Flight != null ) {
390- nbt = nbt . value . Flight
391- if ( nbt . type === 'int' ) {
392- flightDur += nbt . value
393- }
394- }
395- }
396- }
397- const baseDuration = 10 * flightDur
382+ if ( knownFireworks . has ( fireworkEntityId ) ) return
383+ knownFireworks . add ( fireworkEntityId )
384+ let flightDur = fireworkInfo ?. nbtData ?. value ?. Fireworks ?. value ?. Flight . value ?? 1
385+ if ( typeof flightDur !== 'number' ) { flightDur = 1 }
386+ const baseDuration = 10 * ( flightDur + 1 )
398387 const randomDuration = Math . floor ( Math . random ( ) * 6 ) + Math . floor ( Math . random ( ) * 7 )
399388 bot . fireworkRocketDuration = baseDuration + randomDuration
400389
401- bot . emit ( 'usedFirework' )
390+ bot . emit ( 'usedFirework' , fireworkEntityId )
402391 }
403392
404393 let fireworkEntityName
0 commit comments