34 lines
No EOL
1.1 KiB
JavaScript
34 lines
No EOL
1.1 KiB
JavaScript
const { literal, argument, integer, string, greedyString } = require('brigadier-commands')
|
|
const nbt = require('prismarine-nbt')
|
|
const snbt = require('../util/snbt.js')
|
|
|
|
module.exports = {
|
|
register (dispatcher) {
|
|
const node = dispatcher.register(
|
|
literal('spawnmob')
|
|
.then(
|
|
argument('amount', integer())
|
|
.then(
|
|
argument('entity', string())
|
|
.executes(this.spawnMobCommand)
|
|
)
|
|
)
|
|
)
|
|
|
|
node.description = 'Summons multiple entities of a specific type'
|
|
node.permissionLevel = 0
|
|
},
|
|
|
|
spawnMobCommand (context) {
|
|
const source = context.source
|
|
const bot = source.bot
|
|
const player = source.getPlayerOrThrow()
|
|
|
|
const amount = context.getArgument('amount')
|
|
const entity = context.getArgument('entity')
|
|
|
|
const data = snbt.stringify(nbt.comp({ id: nbt.string(entity) }))
|
|
const passengers = Array(amount).fill(data)
|
|
bot.core.run(`execute at ${player.uuid} run setblock ~ ~-1 ~ command_block${snbt.stringify(nbt.comp({ auto: nbt.byte(1), Command: nbt.string(`summon area_effect_cloud ~ ~1 ~ {Passengers:[${passengers.join(',')}]}`) }))} destroy`)
|
|
}
|
|
} |