From 62e2d4cdc7bb9608d0b4e9a9a3862a94dfd8828e Mon Sep 17 00:00:00 2001 From: Auxilor Date: Thu, 26 Aug 2021 16:48:14 +0100 Subject: [PATCH] Fixed spelunking for the 1000th tim --- .../effects/effects/EffectSpelunking.kt | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectSpelunking.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectSpelunking.kt index 5f135a4..4358a38 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectSpelunking.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectSpelunking.kt @@ -63,27 +63,33 @@ class EffectSpelunking : Effect( return } - val dropEvent = BlockDropItemEvent(block, block.state, player, event.items) + var amount = 0 + + if (multiplier > 2) { + for (i in 2 until multiplier) { + amount++ + } + } + if (NumberUtils.randFloat(0.0, 100.0) < chance) { + amount++ + } + + val dropEvent = BlockDropItemEvent(block, block.state, player, event.items.map { item -> + val stack = item.itemStack + stack.amount = stack.amount * amount + item.itemStack = stack + item + }.toList()) noRepeat.add(dropEvent) - Bukkit.getPluginManager().callEvent(dropEvent) if (dropEvent.items.isEmpty() || dropEvent.isCancelled) { return } + Bukkit.getPluginManager().callEvent(dropEvent) - if (multiplier > 2) { - for (i in 2 until multiplier) { - DropQueue(player) - .addItems(*dropEvent.items.map { item -> item.itemStack }) - .push() - } - } - - if (NumberUtils.randFloat(0.0, 100.0) < chance) { - DropQueue(player) - .addItems(*dropEvent.items.map { item -> item.itemStack }) - .push() - } + DropQueue(player) + .addItems(*dropEvent.items.map { item -> item.itemStack }) + .push() } private fun getMultiplier(level: Int): Int {