UNPKG

@magikcraft/mct1

Version:

Minecraft for Type 1 Diabetes

75 lines (63 loc) 2.04 kB
import { Logger } from '@magikcraft/mct1/log' const log = Logger(__filename) const Sound = Java.type('org.bukkit.Sound') import * as MobTools from '@magikcraft/mct1/mobs' export default class JailBrawl { log: any jailGuard: any jailGuardLure: any brawlSounds = [ 'ENTITY_LIGHTNING_IMPACT', 'ENTITY_LIGHTNING_IMPACT', 'ENTITY_LIGHTNING_IMPACT', 'ENTITY_ENDERDRAGON_FIREBALL_EXPLODE', 'ENTITY_WITHER_SKELETON_HURT', 'ENTITY_WOLF_GROWL', 'ENTITY_WOLF_GROWL', 'ENTITY_WOLF_GROWL', ] Locs: any timers: Array<any> = [] // all mobs stored in here. constructor(Locs, jailGuard) { this.Locs = Locs this.jailGuard = jailGuard } start() { this.initBrawl() this.timers.push( setTimeout(() => { log('Lure away guard') this.jailGuardLure = MobTools.spawn( 'armor_stand', this.Locs.locations.jailGuardLure ) // jailGuardLure.setVisible(false) this.jailGuard.setTarget(this.jailGuardLure) }, 3000) ) } stop() { if (this.jailGuardLure) this.jailGuardLure.remove() } initBrawl() { Array.from({ length: 20 }, (x, i) => i + 1).map(count => { this.queueBrawlSound(count) }) } queueBrawlSound(count) { const interval = Math.floor(Math.random() * 5) * 400 + count * 1000 const soundIndex = Math.floor(Math.random() * this.brawlSounds.length) setTimeout(() => { const sound = Sound[this.brawlSounds[soundIndex]] this.Locs.world.playSound( this.Locs.locations.jailBrawl, sound, 5, 1 ) if (this.brawlSounds[soundIndex] == 'ENTITY_LIGHTNING_IMPACT') { this.Locs.world.strikeLightning(this.Locs.locations.jailBrawl) } }, interval) } }