From 702b64ecc08aaeb93228e421a6a3d0c4bfee3d03 Mon Sep 17 00:00:00 2001 From: Mutzi Date: Thu, 11 May 2023 19:39:44 +0200 Subject: [PATCH] Fixed small upgrades needed display bug --- src/main/kotlin/de/mattv/quarry/QuarryTile.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/de/mattv/quarry/QuarryTile.kt b/src/main/kotlin/de/mattv/quarry/QuarryTile.kt index f22797e..acdc543 100644 --- a/src/main/kotlin/de/mattv/quarry/QuarryTile.kt +++ b/src/main/kotlin/de/mattv/quarry/QuarryTile.kt @@ -98,6 +98,8 @@ class QuarryTile(private val myPos: BlockPos, state: BlockState) : BlockEntity(Q return super.getCapability(cap, side) } + private fun upgradesNeededForLevel(level: Int): Int = level.toFloat().pow(1.5f).toInt() + private fun getPickaxe(): ItemStack = Items.NETHERITE_PICKAXE.defaultInstance.apply { if (fortuneLevel > 0) enchant(Enchantments.BLOCK_FORTUNE, fortuneLevel) } @@ -174,7 +176,7 @@ class QuarryTile(private val myPos: BlockPos, state: BlockState) : BlockEntity(Q speedUpgradesNeeded -= used if (speedUpgradesNeeded == 0) { speedLevel++ - speedUpgradesNeeded = speedLevel.toFloat().pow(1.5f).toInt() + speedUpgradesNeeded = upgradesNeededForLevel(speedLevel) player.displayClientMessage(TextComponent("New speed level: $speedLevel, upgrades needed for next level: $speedUpgradesNeeded"), true) } else player.displayClientMessage(TextComponent("Upgrades needed for next level: $speedUpgradesNeeded"), true) @@ -184,7 +186,7 @@ class QuarryTile(private val myPos: BlockPos, state: BlockState) : BlockEntity(Q fortuneUpgradesNeeded -= used if (fortuneUpgradesNeeded == 0) { fortuneLevel++ - fortuneUpgradesNeeded = fortuneLevel.toFloat().pow(1.5f).toInt() + fortuneUpgradesNeeded = upgradesNeededForLevel(fortuneLevel) player.displayClientMessage(TextComponent("New fortune level: $fortuneLevel, upgrades needed for next level: $fortuneUpgradesNeeded"), true) } else player.displayClientMessage(TextComponent("Upgrades needed for next level: $fortuneUpgradesNeeded"), true) @@ -265,9 +267,9 @@ class QuarryTile(private val myPos: BlockPos, state: BlockState) : BlockEntity(Q override fun getUpdatePacket(): Packet? = ClientboundBlockEntityDataPacket.create(this) fun probeInfo(info: IProbeInfo) { - val speedMax = (2.0).pow(speedLevel).toInt() + val speedMax = upgradesNeededForLevel(speedLevel) info.text("Speed: level $speedLevel, ${speedMax - speedUpgradesNeeded}/$speedMax") - val fortuneMax = (2.0).pow(fortuneLevel).toInt() + val fortuneMax = upgradesNeededForLevel(fortuneLevel) info.text("Fortune: level $fortuneLevel, ${fortuneMax - fortuneUpgradesNeeded}/$fortuneMax") if (itemsToDrop.isNotEmpty()) info.text("Waiting to extract items...")