9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-20 15:39:31 +00:00

Fixed spawn totems some more

This commit is contained in:
Auxilor
2022-02-28 10:12:12 +00:00
parent fed6dcafd7
commit be4d6156e3

View File

@@ -16,30 +16,30 @@ class SpawnTotemHandler : Listener {
) )
fun handle(event: BlockPlaceEvent) { fun handle(event: BlockPlaceEvent) {
for (i in 0..2) { for (i in 0..2) {
lateinit var block1: Block lateinit var top: Block
lateinit var block2: Block lateinit var middle: Block
lateinit var block3: Block lateinit var bottom: Block
// I know this code sucks ass, but I can't be arsed to write it nicely // I know this code sucks ass, but I can't be arsed to write it nicely
when (i) { when (i) {
0 -> { 0 -> {
block3 = event.block top = event.block
block2 = event.block.getRelative(0, -1, 0) middle = event.block.getRelative(0, -1, 0)
block1 = event.block.getRelative(0, -2, 0) bottom = event.block.getRelative(0, -2, 0)
} }
1 -> { 1 -> {
block1 = event.block top = event.block.getRelative(0, 2, 0)
block2 = event.block.getRelative(0, 1, 0) middle = event.block.getRelative(0, 1, 0)
block3 = event.block.getRelative(0, 2, 0) bottom = event.block
} }
2 -> { 2 -> {
block2 = event.block top = event.block.getRelative(0, 1, 0)
block1 = event.block.getRelative(0, -1, 0) middle = event.block
block3 = event.block.getRelative(0, 1, 0) bottom = event.block.getRelative(0, -1, 0)
} }
} }
val placedTotem = SpawnTotem(block1.type, block2.type, block3.type) val placedTotem = SpawnTotem(top.type, middle.type, bottom.type)
for (boss in Bosses.values()) { for (boss in Bosses.values()) {
if (boss.totem == null || boss.disabledTotemWorlds.containsIgnoreCase(event.block.world.name)) { if (boss.totem == null || boss.disabledTotemWorlds.containsIgnoreCase(event.block.world.name)) {
continue continue
@@ -58,9 +58,9 @@ class SpawnTotemHandler : Listener {
val spawnEvent = BossSpawnEvent(boss, event.block.location, BossSpawnEvent.SpawnReason.TOTEM, player) val spawnEvent = BossSpawnEvent(boss, event.block.location, BossSpawnEvent.SpawnReason.TOTEM, player)
if (!spawnEvent.isCancelled) { if (!spawnEvent.isCancelled) {
block1.type = Material.AIR top.type = Material.AIR
block2.type = Material.AIR middle.type = Material.AIR
block3.type = Material.AIR bottom.type = Material.AIR
boss.spawn(event.block.location.add(0.0, 1.5, 0.0)) boss.spawn(event.block.location.add(0.0, 1.5, 0.0))
} }