@@ -645,20 +645,25 @@ export const commands = commandList({
645
645
} ,
646
646
647
647
spawn : {
648
- args : [ "type:unittype" , "x:number?" , "y:number?" , "team:team?" , "effects:string?" ] ,
648
+ args : [ "type:unittype" , "x:number?" , "y:number?" , "count:number?" , " team:team?", "effects:string?" , "stack:boolean ?"] ,
649
649
description : "Spawns a unit of specified type at your position. [scarlet]Usage will be logged.[]" ,
650
650
perm : Perm . admin ,
651
651
data : [ ] ,
652
652
handler ( { sender, args, data, outputSuccess, f} ) {
653
653
const x = args . x ? ( args . x * 8 ) : sender . player ! . x ;
654
654
const y = args . y ? ( args . y * 8 ) : sender . player ! . y ;
655
655
const team = args . team ?? sender . team ( ) ;
656
- const unit = args . type . create ( team ) ;
657
- unit . set ( x , y ) ;
658
- if ( args . effects ) applyEffectMode ( args . effects , unit , 1e12 ) ;
659
- unit . add ( ) ;
660
- data . push ( unit ) ;
661
- if ( ! Gamemode . sandbox ( ) ) logAction ( `spawned unit ${ args . type . name } at ${ Math . round ( x / 8 ) } , ${ Math . round ( y / 8 ) } ` , sender ) ;
656
+ const count = Math . min ( args . count ?? 1 , 1000 ) ;
657
+ for ( let i = 0 ; i < count ; i ++ ) {
658
+ const unit = args . type . create ( team ) ;
659
+ const xOffset = args . stack ? 0 : 0.01 * i ;
660
+ const yOffset = args . stack ? 0 : 0.5 * ( i % 10 ) ;
661
+ unit . set ( x + xOffset , y + yOffset ) ;
662
+ if ( args . effects ) applyEffectMode ( args . effects , unit , 1e12 ) ;
663
+ unit . add ( ) ;
664
+ data . push ( unit ) ;
665
+ }
666
+ if ( ! Gamemode . sandbox ( ) && args . effects !== 'paper' ) logAction ( `spawned unit ${ args . type . name } ${ count == 1 ? '' : ` x${ count } ` } at ${ Math . round ( x / 8 ) } , ${ Math . round ( y / 8 ) } ` + ( args . effects ? `with ${ args . effects } effects` : '' ) , sender ) ;
662
667
outputSuccess ( f `Spawned unit ${ args . type } at (${ Math . round ( x / 8 ) } , ${ Math . round ( y / 8 ) } )` ) ;
663
668
}
664
669
} ,
0 commit comments