aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-08-26 12:54:08 +0200
committerGitHub <noreply@github.com>2024-08-26 12:54:08 +0200
commitef804948e0c6f66634926765d301f19ce6d9aee7 (patch)
tree9809f8c1be106d500fb215d2675a5cf2c1f76121 /src/main/java/at
parent8db1b0a2394a9a804af0df87f10f12b91906ec74 (diff)
downloadskyhanni-ef804948e0c6f66634926765d301f19ce6d9aee7.tar.gz
skyhanni-ef804948e0c6f66634926765d301f19ce6d9aee7.tar.bz2
skyhanni-ef804948e0c6f66634926765d301f19ce6d9aee7.zip
Improvement: Mineshaft Message (#2308)
Co-authored-by: ItsEmpa <itsempa@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt70
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/OreType.kt19
2 files changed, 45 insertions, 44 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt
index e67341f44..fd034d9b9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt
@@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.events.mining.OreMinedEvent
import at.hannibal2.skyhanni.features.mining.MineshaftPityDisplay.PityBlock.Companion.getPity
import at.hannibal2.skyhanni.features.mining.MineshaftPityDisplay.PityBlock.Companion.getPityBlock
import at.hannibal2.skyhanni.features.mining.OreType.Companion.getOreType
+import at.hannibal2.skyhanni.features.mining.OreType.Companion.isGemstone
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.LorenzUtils.round
@@ -83,13 +84,13 @@ object MineshaftPityDisplay {
@HandleEvent(onlyOnSkyblock = true)
fun onOreMined(event: OreMinedEvent) {
- if (!isEnabled()) return
+ if (!MiningAPI.inGlacialTunnels()) return
- event.originalOre.getOreType()?.getPityBlock()?.let { it.blocksBroken++ }
+ event.originalOre.getPityBlock()?.let { it.blocksBroken++ }
event.extraBlocks.toMutableMap()
.apply { addOrPut(event.originalOre, -1) }
.map { (block, amount) ->
- block.getOreType()?.getPityBlock()?.let { it.efficientMiner += amount }
+ block.getPityBlock()?.let { it.efficientMiner += amount }
}
update()
@@ -97,7 +98,7 @@ object MineshaftPityDisplay {
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
- if (!isEnabled()) return
+ if (!MiningAPI.inGlacialTunnels()) return
if (MiningNotifications.mineshaftSpawn.matches(event.message)) {
val pityCounter = calculateCounter()
val chance = calculateChance(pityCounter)
@@ -110,36 +111,37 @@ object MineshaftPityDisplay {
val message = event.message + " §e($counterUntilPity)"
- val hover = mutableListOf<String>()
- hover.add("§7Blocks mined: §e$totalBlocks")
- hover.add("§7Pity Counter: §e$pityCounter")
- hover.add(
- "§7Chance: " +
- "§e1§6/§e${chance.round(1)} " +
- "§7(§b${((1.0 / chance) * 100).addSeparators()}%§7)",
- )
- minedBlocks.forEach {
- hover.add(
- " §7${it.pityBlock.displayName} mined: " +
- "§e${it.blocksBroken.addSeparators()} [+${it.efficientMiner.addSeparators()} efficient miner]" +
- " §6(${it.pityBlock.getPity().addSeparators()}/${counterUntilPity.addSeparators()})",
+ val hoverText = buildList {
+ add("§7Blocks mined: §e$totalBlocks")
+ add("§7Pity Counter: §e$pityCounter")
+ add(
+ "§7Chance: " +
+ "§e1§6/§e${chance.round(1)} " +
+ "§7(§b${((1.0 / chance) * 100).addSeparators()}%§7)",
)
- }
- hover.add("")
- hover.add(
- "§7Average Blocks/Mineshaft: " +
- "§e${(mineshaftTotalBlocks / mineshaftTotalCount.toDouble()).addSeparators()}",
- )
-
- if (!lastMineshaftSpawn.isFarPast()) {
- hover.add("")
- hover.add("§7Time since Last Mineshaft: §b${lastMineshaftSpawn.passedSince().format()}")
+ minedBlocks.forEach {
+ add(
+ " §7${it.pityBlock.displayName} mined: " +
+ "§e${it.blocksBroken.addSeparators()} [+${it.efficientMiner.addSeparators()} efficient miner]" +
+ " §6(${it.pityBlock.getPity().addSeparators()}/${counterUntilPity.addSeparators()})",
+ )
+ }
+ add("")
+ add(
+ "§7Average Blocks/Mineshaft: " +
+ "§e${(mineshaftTotalBlocks / mineshaftTotalCount.toDouble()).addSeparators()}",
+ )
+
+ if (!lastMineshaftSpawn.isFarPast()) {
+ add("")
+ add("§7Time since Last Mineshaft: §b${lastMineshaftSpawn.passedSince().format()}")
+ }
}
resetCounter()
val newComponent = Text.text(message) {
- this.hover = Text.multiline(hover)
+ hover = Text.multiline(hoverText)
}
if (config.modifyChatMessage) event.chatComponent = newComponent
@@ -259,8 +261,6 @@ object MineshaftPityDisplay {
}
}
- fun isEnabled() = MiningAPI.inGlacialTunnels() && config.enabled
-
private fun isDisplayEnabled() = (MiningAPI.inGlacialTunnels() || MiningAPI.inDwarvenBaseCamp()) && config.enabled
enum class MineshaftPityLine(private val display: String, val shouldDisplay: () -> Boolean = { true }) {
@@ -298,11 +298,12 @@ object MineshaftPityDisplay {
GEMSTONE(
"Gemstone",
- listOf(
+ /*listOf(
OreType.RUBY, OreType.AMBER, OreType.AMETHYST, OreType.JADE,
OreType.SAPPHIRE, OreType.TOPAZ, OreType.JASPER, OreType.OPAL,
OreType.AQUAMARINE, OreType.CITRINE, OreType.ONYX, OreType.PERIDOT,
- ),
+ ),*/
+ OreType.entries.filter { it.isGemstone() },
4,
ItemStack(Blocks.stained_glass, 1, EnumDyeColor.BLUE.metadata),
),
@@ -335,7 +336,10 @@ object MineshaftPityDisplay {
companion object {
- fun OreType.getPityBlock() = entries.firstOrNull { this in it.oreTypes }
+ fun OreBlock.getPityBlock(): PityBlock? {
+ val oreType = getOreType() ?: return null
+ return entries.firstOrNull { oreType in it.oreTypes }
+ }
fun PityBlock.getPity() = (blocksBroken + efficientMiner / 2.0) * multiplier
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/OreType.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/OreType.kt
index 1c286097e..5f9743b68 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/OreType.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/OreType.kt
@@ -1,7 +1,6 @@
package at.hannibal2.skyhanni.features.mining
import at.hannibal2.skyhanni.data.MiningAPI
-import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import net.minecraft.block.state.IBlockState
@@ -191,23 +190,21 @@ enum class OreType(
companion object {
+ private val gemstones = setOf(
+ RUBY, AMBER, AMETHYST, JADE,
+ SAPPHIRE, TOPAZ, JASPER, OPAL,
+ AQUAMARINE, CITRINE, ONYX, PERIDOT,
+ )
+
fun IBlockState.isOreType(oreType: OreType): Boolean {
return oreType.oreBlocks.intersect(MiningAPI.currentAreaOreBlocks)
.any { it.checkBlock.invoke(this) }
}
- fun OreType.isGemstone(): Boolean {
- return this.equalsOneOf(
- RUBY, AMBER, AMETHYST, JADE,
- SAPPHIRE, TOPAZ, JASPER, OPAL,
- AQUAMARINE, CITRINE, ONYX, PERIDOT,
- )
- }
+ fun OreType.isGemstone(): Boolean = this in gemstones
fun OreBlock.getOreType(): OreType? {
- return OreType.entries.firstOrNull {
- it.oreBlocks.contains(this)
- }
+ return OreType.entries.firstOrNull { this in it.oreBlocks }
}
}
}