summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/mining
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-06-15 22:12:24 +0200
committerGitHub <noreply@github.com>2024-06-15 22:12:24 +0200
commitbfe43b7ebffab551740d32cf919db27504d27ffb (patch)
tree7fb570635c88d98f122d2752be78f135868a9843 /src/main/java/at/hannibal2/skyhanni/features/mining
parent8c91a9b8bf63059e1a8a099ccbdadea8a3676948 (diff)
downloadskyhanni-bfe43b7ebffab551740d32cf919db27504d27ffb.tar.gz
skyhanni-bfe43b7ebffab551740d32cf919db27504d27ffb.tar.bz2
skyhanni-bfe43b7ebffab551740d32cf919db27504d27ffb.zip
Feature: Mineshaft Pity Display + OreMinedEvent (#1655)
Co-authored-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Co-authored-by: Empa <42304516+ItsEmpa@users.noreply.github.com> Co-authored-by: Thunderblade73 <gaidermarkus@gmail.com> Co-authored-by: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Co-authored-by: Cal <cwolfson58@gmail.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/mining')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt340
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt197
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/MiningNotifications.kt29
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/OreBlock.kt279
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/OreType.kt213
5 files changed, 889 insertions, 169 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
new file mode 100644
index 000000000..731a8ca4a
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt
@@ -0,0 +1,340 @@
+package at.hannibal2.skyhanni.features.mining
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.api.event.HandleEvent
+import at.hannibal2.skyhanni.data.HotmData
+import at.hannibal2.skyhanni.data.HotmReward
+import at.hannibal2.skyhanni.data.IslandType
+import at.hannibal2.skyhanni.data.MiningAPI
+import at.hannibal2.skyhanni.data.ProfileStorageData
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.IslandChangeEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.SecondPassedEvent
+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.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
+import at.hannibal2.skyhanni.utils.LorenzUtils.round
+import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.RegexUtils.matches
+import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.TimeUtils.format
+import at.hannibal2.skyhanni.utils.chat.Text
+import at.hannibal2.skyhanni.utils.chat.Text.hover
+import at.hannibal2.skyhanni.utils.renderables.Renderable
+import com.google.gson.annotations.Expose
+import net.minecraft.block.BlockStone
+import net.minecraft.init.Blocks
+import net.minecraft.item.EnumDyeColor
+import net.minecraft.item.ItemStack
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+@SkyHanniModule
+object MineshaftPityDisplay {
+ private val config get() = SkyHanniMod.feature.mining.mineshaftPityDisplay
+
+ private val profileStorage get() = ProfileStorageData.profileSpecific?.mining?.mineshaft
+
+ private var minedBlocks: MutableList<PityData>
+ get() = profileStorage?.blocksBroken ?: mutableListOf()
+ set(value) {
+ profileStorage?.blocksBroken = value
+ }
+
+ private var PityBlock.efficientMiner: Int
+ get() = minedBlocks.firstOrNull { it.pityBlock == this }?.efficientMiner ?: 0
+ set(value) {
+ minedBlocks.firstOrNull { it.pityBlock == this }?.let { it.efficientMiner = value } ?: run {
+ minedBlocks.add(PityData(this, efficientMiner = value))
+ }
+ }
+
+ private var PityBlock.blocksBroken: Int
+ get() = minedBlocks.firstOrNull { it.pityBlock == this }?.blocksBroken ?: 0
+ set(value) {
+ minedBlocks.firstOrNull { it.pityBlock == this }?.let { it.blocksBroken = value } ?: run {
+ minedBlocks.add(PityData(this, blocksBroken = value))
+ }
+ }
+
+ private var mineshaftTotalBlocks: Long
+ get() = profileStorage?.mineshaftTotalBlocks ?: 0L
+ set(value) {
+ profileStorage?.mineshaftTotalBlocks = value
+ }
+
+ private var mineshaftTotalCount: Int
+ get() = profileStorage?.mineshaftTotalCount ?: 0
+ set(value) {
+ profileStorage?.mineshaftTotalCount = value
+ }
+
+ var lastMineshaftSpawn = SimpleTimeMark.farPast()
+
+ private var display = listOf<Renderable>()
+
+ private const val MAX_COUNTER = 2000
+
+ @HandleEvent(onlyOnSkyblock = true)
+ fun onOreMined(event: OreMinedEvent) {
+ if (!isEnabled()) return
+
+ event.originalOre.getOreType()?.getPityBlock()?.let { it.blocksBroken++ }
+ event.extraBlocks.toMutableMap()
+ .apply { addOrPut(event.originalOre, -1) }
+ .map { (block, amount) ->
+ block.getOreType()?.getPityBlock()?.let { it.efficientMiner += amount }
+ }
+
+ update()
+ }
+
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ if (!isEnabled()) return
+ if (MiningNotifications.mineshaftSpawn.matches(event.message)) {
+ val pityCounter = calculateCounter()
+ val chance = calculateChance(pityCounter)
+ val counterUntilPity = MAX_COUNTER - pityCounter
+ val totalBlocks = PityBlock.entries.sumOf { it.blocksBroken + it.efficientMiner }
+
+ mineshaftTotalBlocks += totalBlocks
+ mineshaftTotalCount++
+
+ 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()})",
+ )
+ }
+ hover.add("")
+ hover.add(
+ "§7Average Blocks/Mineshaft: " +
+ "§e${(mineshaftTotalBlocks / mineshaftTotalCount.toDouble()).addSeparators()}",
+ )
+
+ if (!lastMineshaftSpawn.isFarPast()) {
+ hover.add("")
+ hover.add("§7Time since Last Mineshaft: §e${lastMineshaftSpawn.passedSince().format()}")
+ }
+
+ resetCounter()
+
+ val newComponent = Text.text(message) {
+ this.hover = Text.multiline(hover)
+ }
+
+ if (config.modifyChatMessage) event.chatComponent = newComponent
+ }
+ }
+
+ @SubscribeEvent
+ fun onSecondPassed(event: SecondPassedEvent) {
+ if (!isDisplayEnabled()) return
+ update()
+ }
+
+ private fun calculateCounter(): Int {
+ val counter = MAX_COUNTER
+ if (minedBlocks.isEmpty()) return counter
+ val difference = minedBlocks.sumOf { it.pityBlock.getPity() }
+ return (counter - difference).toInt().coerceAtLeast(0)
+ }
+
+ // if the chance is 1/1500, it will return 1500
+ private fun calculateChance(counter: Int): Double {
+ val surveyorPercent = HotmData.SURVEYOR.getReward()[HotmReward.MINESHAFT_CHANCE] ?: 0.0
+ val peakMountainPercent = HotmData.PEAK_OF_THE_MOUNTAIN.getReward()[HotmReward.MINESHAFT_CHANCE] ?: 0.0
+ val chance = counter / (1 + surveyorPercent / 100 + peakMountainPercent / 100)
+ return chance
+ }
+
+ private fun update() {
+ val pityCounter = calculateCounter()
+ val chance = calculateChance(pityCounter)
+ val counterUntilPity = MAX_COUNTER - pityCounter
+
+ val blocksToPityList = buildList {
+ val multipliers = PityBlock.entries.map { it.multiplier }.toSet().sorted()
+
+ multipliers.forEach { multiplier ->
+ val iconsList = PityBlock.entries
+ .filter { it.multiplier == multiplier }
+ .map { Renderable.itemStack(it.displayItem) }
+ add(
+ Renderable.horizontalContainer(
+ listOf(
+ Renderable.horizontalContainer(iconsList),
+ Renderable.string("§b${pityCounter / multiplier}"),
+ ),
+ 2,
+ ),
+ )
+ }
+ }
+
+
+ val neededToPityRenderable = Renderable.verticalContainer(
+ listOf(
+ Renderable.string("§3Needed to pity:"),
+ Renderable.horizontalContainer(
+ listOf(
+ Renderable.placeholder(10, 0),
+ Renderable.verticalContainer(blocksToPityList),
+ ),
+ ),
+ ),
+ )
+
+ val map = buildMap {
+ put(MineshaftPityLines.TITLE, Renderable.string("§9§lMineshaft Pity Counter"))
+ put(MineshaftPityLines.COUNTER, Renderable.string("§3Pity Counter: §e$counterUntilPity§6/§e$MAX_COUNTER"))
+ put(
+ MineshaftPityLines.CHANCE,
+ Renderable.string(
+ "§3Chance: §e1§6/§e${chance.round(1)} §7(§b${((1.0 / chance) * 100).addSeparators()}%§7)",
+ ),
+ )
+ put(MineshaftPityLines.NEEDED_TO_PITY, neededToPityRenderable)
+ put(
+ MineshaftPityLines.TIME_SINCE_MINESHAFT,
+ Renderable.string("§3Last Mineshaft: §e${lastMineshaftSpawn.passedSince().format()}"),
+ )
+ put(
+ MineshaftPityLines.AVERAGE_BLOCKS_MINESHAFT,
+ Renderable.string(
+ "§3Average Blocks/Mineshaft: §e${(mineshaftTotalBlocks / mineshaftTotalCount.toDouble()).addSeparators()}",
+ ),
+ )
+ }
+
+ display = config.mineshaftPityLines.filter { it.shouldDisplay() }.mapNotNull { map[it] }
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
+ if (!isDisplayEnabled()) return
+ display.ifEmpty { update() }
+ if (display.isEmpty()) return
+ config.position.renderRenderables(
+ listOf(Renderable.verticalContainer(display, 2)),
+ posLabel = "Mineshaft Pity Display",
+ )
+ }
+
+ private fun resetCounter() {
+ minedBlocks = mutableListOf()
+ lastMineshaftSpawn = SimpleTimeMark.now()
+ update()
+ }
+
+ fun fullResetCounter() {
+ resetCounter()
+ mineshaftTotalBlocks = 0
+ mineshaftTotalCount = 0
+ lastMineshaftSpawn = SimpleTimeMark.farPast()
+ update()
+ }
+
+ @SubscribeEvent
+ fun onIslandChange(event: IslandChangeEvent) {
+ if (event.newIsland == IslandType.MINESHAFT || event.oldIsland == IslandType.MINESHAFT) {
+ resetCounter()
+ }
+ }
+
+ fun isEnabled() = MiningAPI.inGlacialTunnels() && config.enabled
+
+ private fun isDisplayEnabled() = (MiningAPI.inGlacialTunnels() || MiningAPI.inDwarvenBaseCamp()) && config.enabled
+
+ enum class MineshaftPityLines(private val display: String, val shouldDisplay: () -> Boolean = { true }) {
+ TITLE("§3§lMineshaft Pity Counter"),
+ COUNTER("§3Counter: §e561§6/§e2000"),
+ CHANCE("§3Chance: §e1§6/§e1439 §7(§b0.069%§7)"),
+ NEEDED_TO_PITY("§3Needed to pity:\n§7 <blocks>"),
+ TIME_SINCE_MINESHAFT("§3Last Mineshaft: §e21m 5s", { !lastMineshaftSpawn.isFarPast() }),
+ AVERAGE_BLOCKS_MINESHAFT("§3Average Blocks/Mineshaft: §e361.5", { mineshaftTotalCount != 0 })
+ ;
+
+ override fun toString() = display
+ }
+
+ data class PityData(
+ @Expose val pityBlock: PityBlock,
+ @Expose var blocksBroken: Int = 0,
+ @Expose var efficientMiner: Int = 0,
+ )
+
+ enum class PityBlock(
+ val displayName: String,
+ val oreTypes: List<OreType>,
+ val multiplier: Int,
+ val displayItem: ItemStack,
+ ) {
+ MITHRIL(
+ "Mithril",
+ listOf(OreType.MITHRIL),
+ 2,
+ ItemStack(Blocks.wool, 1, EnumDyeColor.LIGHT_BLUE.metadata),
+ ),
+
+ GEMSTONE(
+ "Gemstone",
+ 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,
+ ),
+ 4,
+ ItemStack(Blocks.stained_glass, 1, EnumDyeColor.BLUE.metadata),
+ ),
+ GLACITE(
+ "Glacite",
+ listOf(OreType.GLACITE),
+ 4,
+ ItemStack(Blocks.packed_ice),
+ ),
+ TUNGSTEN(
+ "Tungsten",
+ listOf(OreType.TUNGSTEN),
+ 4,
+ ItemStack(Blocks.clay),
+ ),
+ UMBER(
+ "Umber",
+ listOf(OreType.UMBER),
+ 4,
+ ItemStack(Blocks.red_sandstone),
+ ),
+
+ TITANIUM(
+ "Titanium",
+ listOf(OreType.TITANIUM),
+ 8,
+ ItemStack(Blocks.stone, 1, BlockStone.EnumType.DIORITE_SMOOTH.metadata),
+ ),
+ ;
+
+ companion object {
+
+ fun OreType.getPityBlock() = entries.firstOrNull { this in it.oreTypes }
+
+ fun PityBlock.getPity() = (blocksBroken + efficientMiner / 2.0) * multiplier
+ }
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt
index 92ba5fc13..bf7c8c2ac 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt
@@ -1,20 +1,18 @@
package at.hannibal2.skyhanni.features.mining
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.HypixelData
-import at.hannibal2.skyhanni.data.IslandType
-import at.hannibal2.skyhanni.data.MiningAPI
+import at.hannibal2.skyhanni.data.MiningAPI.inCrystalHollows
+import at.hannibal2.skyhanni.data.MiningAPI.inDwarvenMines
+import at.hannibal2.skyhanni.data.MiningAPI.inGlacite
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.TabListUpdateEvent
+import at.hannibal2.skyhanni.features.mining.OreType.Companion.isGemstone
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
-import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf
import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.TimeLimitedSet
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
@@ -41,68 +39,39 @@ object MiningCommissionsBlocksColor {
*/
private val commissionCompletePattern by patternGroup.pattern(
"complete",
- "§a§l(?<name>.*) §r§eCommission Complete! Visit the King §r§eto claim your rewards!"
+ "§a§l(?<name>.*) §r§eCommission Complete! Visit the King §r§eto claim your rewards!",
)
var color: EnumDyeColor = EnumDyeColor.RED
- private fun glass() = { state: IBlockState, result: Boolean ->
+ private fun glass(state: IBlockState, result: Boolean): IBlockState =
if (result) {
state.withProperty(BlockCarpet.COLOR, color)
} else {
state.withProperty(BlockCarpet.COLOR, EnumDyeColor.GRAY)
}
- }
- private fun block() = { _: IBlockState, result: Boolean ->
+ private fun block(result: Boolean): IBlockState {
val wool = Blocks.wool.defaultState
- if (result) {
+ return if (result) {
wool.withProperty(BlockCarpet.COLOR, color)
} else {
wool.withProperty(BlockCarpet.COLOR, EnumDyeColor.GRAY)
}
}
- val aquamarine = Blocks.stained_glass
- val aquamarine_2 = Blocks.stained_glass_pane
-
- val citrine = Blocks.stained_glass
- val citrine_2 = Blocks.stained_glass_pane
-
- val glacite = Blocks.packed_ice
-
- val onyx = Blocks.stained_glass
- val onyx_2 = Blocks.stained_glass_pane
-
- val umber = Blocks.hardened_clay
- val umber_2 = Blocks.stained_hardened_clay
- val umber_3 = Blocks.double_stone_slab2 // red sandstone
-
- val peridot = Blocks.stained_glass
- val peridot_2 = Blocks.stained_glass_pane
-
- val tungston = Blocks.cobblestone
- val tungston_2 = Blocks.stone_stairs
- val tungston_3 = Blocks.clay
-
- val mithril = Blocks.stained_hardened_clay
- val mithril_2 = Blocks.wool
- val mithril_3 = Blocks.prismarine
-
private var oldSneakState = false
private var dirty = false
private var forceDirty = false
- private var inDwarvenMines = false
- private var inCrystalHollows = false
- private var inGlaciteArea = false
+ var replaceBlocksMapCache = mutableMapOf<IBlockState, IBlockState>()
- // TODO Commissin API
+ // TODO Commission API
@SubscribeEvent
fun onTabListUpdate(event: TabListUpdateEvent) {
- for (block in MiningBlock.entries) {
- val tabList = " §r§f${block.displayName}: "
+ for (block in CommissionBlock.entries) {
+ val tabList = " §r§f${block.commissionName}: "
val newValue = event.tabList.any { it.startsWith(tabList) && !it.contains("DONE") }
if (block.highlight != newValue) {
if (newValue && block in ignoredTabListCommissions) continue
@@ -112,15 +81,15 @@ object MiningCommissionsBlocksColor {
}
}
- private val ignoredTabListCommissions = TimeLimitedSet<MiningBlock>(5.seconds)
+ private val ignoredTabListCommissions = TimeLimitedSet<CommissionBlock>(5.seconds)
- // TODO Commissin API
+ // TODO Commission API
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
if (!enabled) return
commissionCompletePattern.matchMatcher(event.message) {
val name = group("name")
- val block = MiningBlock.entries.find { it.displayName.equals(name, ignoreCase = true) } ?: return
+ val block = CommissionBlock.entries.find { it.commissionName.equals(name, ignoreCase = true) } ?: return
block.highlight = false
dirty = true
ignoredTabListCommissions.add(block)
@@ -129,16 +98,7 @@ object MiningCommissionsBlocksColor {
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
- if (LorenzUtils.lastWorldSwitch.passedSince() > 4.seconds) {
- inGlaciteArea = MiningAPI.inGlaciteArea() && !IslandType.MINESHAFT.isInIsland()
- inDwarvenMines = IslandType.DWARVEN_MINES.isInIsland() &&
- !(inGlaciteArea || HypixelData.skyBlockArea.equalsOneOf("Dwarven Base Camp", "Fossil Research Center"))
- inCrystalHollows = IslandType.CRYSTAL_HOLLOWS.isInIsland() && HypixelData.skyBlockArea != "Crystal Nucleus"
- }
-
- // TODO add dwarven mines support
-// val newEnabled = (inDwarvenMines || inCrystalHollows || inGlaciteArea) && config.enabled
- val newEnabled = (inCrystalHollows || inGlaciteArea) && config.enabled
+ val newEnabled = (inCrystalHollows || inGlacite) && config.enabled
var reload = false
if (newEnabled != enabled) {
enabled = newEnabled
@@ -165,6 +125,7 @@ object MiningCommissionsBlocksColor {
}
if (reload) {
+ replaceBlocksMapCache = mutableMapOf()
Minecraft.getMinecraft().renderGlobal.loadRenderers()
dirty = false
}
@@ -191,7 +152,8 @@ object MiningCommissionsBlocksColor {
enabled = false
inDwarvenMines = false
inCrystalHollows = false
- inGlaciteArea = false
+ inGlacite = false
+ replaceBlocksMapCache = mutableMapOf()
}
@SubscribeEvent
@@ -205,157 +167,82 @@ object MiningCommissionsBlocksColor {
event.addData {
add("inDwarvenMines: $inDwarvenMines")
add("inCrystalHollows: $inCrystalHollows")
- add("inGlaciteArea: $inGlaciteArea")
+ add("inGlaciteArea: $inGlacite")
add("active: $active")
}
}
- enum class MiningBlock(
- val displayName: String,
- val onCheck: (IBlockState) -> Boolean,
- val onColor: (IBlockState, Boolean) -> IBlockState,
+ enum class CommissionBlock(
+ val commissionName: String,
+ val oreType: OreType,
var highlight: Boolean = false,
- val checkIsland: () -> Boolean,
) {
// Dwarven Mines
MITHRIL(
"Mithril Everywhere",
- onCheck = { state ->
- (state.block == mithril && state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.CYAN)) ||
- (state.block == mithril_2 && (state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.GRAY) ||
- state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.LIGHT_BLUE))) ||
- state.block == mithril_3
- },
- onColor = block(),
- checkIsland = { true }
+ OreType.MITHRIL,
),
// Crystal Hollows
AMBER(
"Amber Gemstone Collector",
- onCheck = { state ->
- (state.block == aquamarine || state.block == aquamarine_2) &&
- state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.ORANGE)
- },
- onColor = glass(),
- checkIsland = { !inDwarvenMines }
+ OreType.AMBER,
),
TOPAZ(
"Topaz Gemstone Collector",
- onCheck = { state ->
- (state.block == aquamarine || state.block == aquamarine_2) &&
- state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.YELLOW)
- },
- onColor = glass(),
- checkIsland = { !inDwarvenMines }
+ OreType.TOPAZ,
),
AMETHYST(
"Amethyst Gemstone Collector",
- onCheck = { state ->
- (state.block == aquamarine || state.block == aquamarine_2) &&
- state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.PURPLE)
- },
- onColor = glass(),
- checkIsland = { !inDwarvenMines }
+ OreType.AMETHYST,
),
RUBY(
"Ruby Gemstone Collector",
- onCheck = { state ->
- (state.block == aquamarine || state.block == aquamarine_2) &&
- state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.RED)
- },
- onColor = glass(),
- checkIsland = { !inDwarvenMines }
+ OreType.RUBY,
),
JADE(
"Jade Gemstone Collector",
- onCheck = { state ->
- (state.block == aquamarine || state.block == aquamarine_2) &&
- state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.LIME)
- },
- onColor = glass(),
- checkIsland = { !inDwarvenMines }
+ OreType.JADE,
),
SAPPHIRE(
"Sapphire Gemstone Collector",
- onCheck = { state ->
- (state.block == aquamarine || state.block == aquamarine_2) &&
- state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.LIGHT_BLUE)
- },
- onColor = glass(),
- checkIsland = { !inDwarvenMines }
- ),
- HARD_STONE(
- "Hardstone Miner",
- onCheck = { state ->
- state.block == glacite
- },
- onColor = block(),
- checkIsland = { !inDwarvenMines }
+ OreType.SAPPHIRE,
),
// Glacite Tunnels
GLACITE(
"Glacite Collector",
- onCheck = { state ->
- state.block == glacite
- },
- onColor = block(),
- checkIsland = { inGlaciteArea }
+ OreType.GLACITE,
),
UMBER(
"Umber Collector",
- onCheck = { state ->
- (state.block == umber || state.block == umber_3) ||
- (state.block == umber_2 && state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.BROWN))
- },
- onColor = block(),
- checkIsland = { inGlaciteArea }
+ OreType.UMBER,
),
TUNGSTON(
"Tungsten Collector",
- onCheck = { state ->
- state.block == tungston || state.block == tungston_2 || state.block == tungston_3
- },
- onColor = block(),
- checkIsland = { inGlaciteArea }
+ OreType.TUNGSTEN,
),
PERIDOT(
"Peridot Gemstone Collector",
- onCheck = { state ->
- (state.block == peridot || state.block == peridot_2) &&
- state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.GREEN)
- },
- onColor = glass(),
- checkIsland = { inGlaciteArea }
+ OreType.PERIDOT,
),
AQUAMARINE(
"Aquamarine Gemstone Collector",
- onCheck = { state ->
- (state.block == aquamarine || state.block == aquamarine_2) &&
- state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.BLUE)
- },
- onColor = glass(),
- checkIsland = { inGlaciteArea }
+ OreType.AQUAMARINE,
),
CITRINE(
"Citrine Gemstone Collector",
- onCheck = { state ->
- (state.block == citrine || state.block == citrine_2) &&
- state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.BROWN)
- },
- onColor = glass(),
- checkIsland = { inGlaciteArea }
+ OreType.CITRINE,
),
ONYX(
"Onyx Gemstone Collector",
- onCheck = { state ->
- (state.block == onyx || state.block == onyx_2) &&
- state.getValue(BlockCarpet.COLOR).equalsOneOf(EnumDyeColor.BLACK)
- },
- onColor = glass(),
- checkIsland = { inGlaciteArea }
+ OreType.ONYX,
),
;
+
+ companion object {
+ fun CommissionBlock.onColor(state: IBlockState): IBlockState =
+ if (oreType.isGemstone()) glass(state, highlight) else block(highlight)
+ }
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/MiningNotifications.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/MiningNotifications.kt
index 527c9d4c7..ae50308e9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/MiningNotifications.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/MiningNotifications.kt
@@ -2,9 +2,8 @@ package at.hannibal2.skyhanni.features.mining
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.GetFromSackAPI
-import at.hannibal2.skyhanni.data.IslandType
-import at.hannibal2.skyhanni.data.MiningAPI.getCold
-import at.hannibal2.skyhanni.data.MiningAPI.inColdIsland
+import at.hannibal2.skyhanni.data.MiningAPI
+import at.hannibal2.skyhanni.data.MiningAPI.inGlaciteArea
import at.hannibal2.skyhanni.data.MiningAPI.lastColdReset
import at.hannibal2.skyhanni.events.ColdUpdateEvent
import at.hannibal2.skyhanni.events.ConfigLoadEvent
@@ -14,7 +13,6 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ConditionalUtils
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack
import at.hannibal2.skyhanni.utils.RegexUtils.matches
@@ -27,7 +25,7 @@ import kotlin.time.Duration.Companion.seconds
@SkyHanniModule
object MiningNotifications {
- private val ASCENSION_ROPE = "ASCENSION_ROPE".asInternalName().makePrimitiveStack(1)
+ private val ASCENSION_ROPE by lazy { "ASCENSION_ROPE".asInternalName().makePrimitiveStack(1) }
enum class MiningNotificationList(val str: String, val notification: String) {
MINESHAFT_SPAWN("§bGlacite Mineshaft", "§bMineshaft"),
@@ -40,26 +38,27 @@ object MiningNotifications {
}
private val patternGroup = RepoPattern.group("mining.notifications")
- private val mineshaftSpawn by patternGroup.pattern(
+ val mineshaftSpawn by patternGroup.pattern(
"mineshaft.spawn",
- "§5§lWOW! §r§aYou found a §r§bGlacite Mineshaft §r§aportal!"
+ "§5§lWOW! §r§aYou found a §r§bGlacite Mineshaft §r§aportal!",
)
private val scrapDrop by patternGroup.pattern(
"scrapdrop",
- "§6§lEXCAVATOR! §r§fYou found a §r§9Suspicious Scrap§r§f!"
+ "§6§lEXCAVATOR! §r§fYou found a §r§9Suspicious Scrap§r§f!",
)
val goldenGoblinSpawn by patternGroup.pattern(
"goblin.goldspawn",
- "§6A Golden Goblin has spawned!"
+ "§6A Golden Goblin has spawned!",
)
val diamondGoblinSpawn by patternGroup.pattern(
"goblin.diamondspawn",
- "§6A §r§bDiamond Goblin §r§6has spawned!"
+ "§6A §r§bDiamond Goblin §r§6has spawned!",
)
private val config get() = SkyHanniMod.feature.mining.notifications
private var hasSentCold = false
+ private var hasSentAscensionRope = false
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
@@ -76,7 +75,7 @@ object MiningNotifications {
@SubscribeEvent
fun onColdUpdate(event: ColdUpdateEvent) {
- if (!inColdIsland()) return
+ if (!inGlaciteArea()) return
if (!config.enabled) return
if (lastColdReset.passedSince() < 1.seconds) return
@@ -84,7 +83,8 @@ object MiningNotifications {
hasSentCold = true
sendNotification(MiningNotificationList.COLD)
}
- if (IslandType.MINESHAFT.isInIsland() && config.getAscensionRope && config.coldAmount == event.cold) {
+ if (MiningAPI.inMineshaft() && config.getAscensionRope && event.cold >= config.coldAmount && !hasSentAscensionRope) {
+ hasSentAscensionRope = true
DelayedRun.runDelayed(0.5.seconds) {
GetFromSackAPI.getFromChatMessageSackItems(ASCENSION_ROPE)
}
@@ -94,17 +94,18 @@ object MiningNotifications {
@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
hasSentCold = false
+ hasSentAscensionRope = false
}
@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
ConditionalUtils.onToggle(config.coldThreshold) {
- if (getCold() != config.coldThreshold.get()) hasSentCold = false
+ if (MiningAPI.cold != config.coldThreshold.get()) hasSentCold = false
}
}
private fun sendNotification(type: MiningNotificationList) {
- if (!config.notifications.contains(type)) return
+ if (type !in config.notifications) return
LorenzUtils.sendTitle(type.notification, 1500.milliseconds)
if (config.playSound) SoundUtils.playPlingSound()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/OreBlock.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/OreBlock.kt
new file mode 100644
index 000000000..3457d2566
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/OreBlock.kt
@@ -0,0 +1,279 @@
+package at.hannibal2.skyhanni.features.mining
+
+import at.hannibal2.skyhanni.data.MiningAPI.currentAreaOreBlocks
+import at.hannibal2.skyhanni.data.MiningAPI.inCrimsonIsle
+import at.hannibal2.skyhanni.data.MiningAPI.inCrystalHollows
+import at.hannibal2.skyhanni.data.MiningAPI.inDwarvenMines
+import at.hannibal2.skyhanni.data.MiningAPI.inEnd
+import at.hannibal2.skyhanni.data.MiningAPI.inGlacite
+import at.hannibal2.skyhanni.data.MiningAPI.inSpidersDen
+import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf
+import net.minecraft.block.BlockColored
+import net.minecraft.block.BlockSand
+import net.minecraft.block.BlockStainedGlass
+import net.minecraft.block.BlockStainedGlassPane
+import net.minecraft.block.BlockStone
+import net.minecraft.block.BlockStoneSlabNew
+import net.minecraft.block.state.IBlockState
+import net.minecraft.init.Blocks
+import net.minecraft.item.EnumDyeColor
+
+enum class OreBlock(
+ val checkBlock: (IBlockState) -> Boolean,
+ val checkArea: () -> Boolean,
+) {
+ // MITHRIL
+ LOW_TIER_MITHRIL(
+ checkBlock = ::isLowTierMithril,
+ checkArea = { inGlacite },
+ ),
+ MID_TIER_MITHRIL(
+ checkBlock = { it.block == Blocks.prismarine },
+ checkArea = { inDwarvenMines || inCrystalHollows || inGlacite },
+ ),
+ HIGH_TIER_MITHRIL(
+ checkBlock = ::isHighTierMithril,
+ checkArea = { inDwarvenMines || inCrystalHollows || inGlacite },
+ ),
+
+ // TITANIUM
+ TITANIUM(
+ checkBlock = ::isTitanium,
+ checkArea = { inDwarvenMines || inGlacite },
+ ),
+
+ // VANILLA ORES
+ STONE(
+ checkBlock = ::isStone,
+ checkArea = { inDwarvenMines },
+ ),
+ COBBLESTONE(
+ checkBlock = { it.block == Blocks.cobblestone },
+ checkArea = { inDwarvenMines },
+ ),
+ COAL_ORE(
+ checkBlock = { it.block == Blocks.coal_ore },
+ checkArea = { inDwarvenMines || inCrystalHollows },
+ ),
+ IRON_ORE(
+ checkBlock = { it.block == Blocks.iron_ore },
+ checkArea = { inDwarvenMines || inCrystalHollows },
+ ),
+ GOLD_ORE(
+ checkBlock = {