From bfe43b7ebffab551740d32cf919db27504d27ffb Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Sat, 15 Jun 2024 22:12:24 +0200 Subject: 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 Co-authored-by: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Co-authored-by: Cal Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/mining/MineshaftPityDisplay.kt | 340 +++++++++++++++++++++ .../mining/MiningCommissionsBlocksColor.kt | 197 +++--------- .../features/mining/MiningNotifications.kt | 29 +- .../hannibal2/skyhanni/features/mining/OreBlock.kt | 279 +++++++++++++++++ .../hannibal2/skyhanni/features/mining/OreType.kt | 213 +++++++++++++ 5 files changed, 889 insertions(+), 169 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/mining/OreBlock.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/mining/OreType.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features/mining') 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 + 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() + + 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() + 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 "), + 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, + 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(?.*) §r§eCommission Complete! Visit the King §r§eto claim your rewards!" + "§a§l(?.*) §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() - // 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(5.seconds) + private val ignoredTabListCommissions = TimeLimitedSet(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 = { it.block == Blocks.gold_ore }, + checkArea = { inDwarvenMines || inCrystalHollows }, + ), + LAPIS_ORE( + checkBlock = { it.block == Blocks.lapis_ore }, + checkArea = { inDwarvenMines || inCrystalHollows }, + ), + REDSTONE_ORE( + checkBlock = { it.block.equalsOneOf(Blocks.redstone_ore, Blocks.lit_redstone_ore) }, + checkArea = { inDwarvenMines || inCrystalHollows }, + ), + EMERALD_ORE( + checkBlock = { it.block == Blocks.emerald_ore }, + checkArea = { inDwarvenMines || inCrystalHollows }, + ), + DIAMOND_ORE( + checkBlock = { it.block == Blocks.diamond_ore }, + checkArea = { inDwarvenMines || inCrystalHollows }, + ), + + // NETHER + NETHERRACK( + checkBlock = { it.block == Blocks.netherrack }, + checkArea = { inCrimsonIsle }, + ), + QUARTZ_ORE( + checkBlock = { it.block == Blocks.quartz_ore }, + checkArea = { inCrystalHollows || inCrimsonIsle }, + ), + GLOWSTONE( + checkBlock = { it.block == Blocks.glowstone }, + checkArea = { inCrimsonIsle }, + ), + MYCELIUM( + checkBlock = { it.block == Blocks.mycelium }, + checkArea = { inCrimsonIsle }, + ), + RED_SAND( + checkBlock = ::isRedSand, + checkArea = { inCrimsonIsle }, + ), + SULPHUR( + checkBlock = { it.block == Blocks.sponge }, + checkArea = { inCrimsonIsle }, + ), + + // SPIDER'S DEN + GRAVEL( + checkBlock = { it.block == Blocks.gravel }, + checkArea = { inSpidersDen }, + ), + + //END + END_STONE( + checkBlock = { it.block == Blocks.end_stone }, + checkArea = { inEnd }, + ), + OBSIDIAN( + checkBlock = { it.block == Blocks.obsidian }, + checkArea = { inCrystalHollows || inEnd }, + ), + + // HARD STONE + HARD_STONE_HOLLOWS( + checkBlock = ::isHardStoneHollows, + checkArea = { inCrystalHollows }, + ), + HARD_STONE_GLACIAL( + checkBlock = ::isHardstoneGlacite, + checkArea = { inGlacite }, + ), + + // DWARVEN BLOCKS + DWARVEN_REDSTONE( + checkBlock = { it.block == Blocks.redstone_block }, + checkArea = { inCrystalHollows }, + ), + DWARVEN_GOLD( + checkBlock = { it.block == Blocks.gold_block }, + checkArea = { inDwarvenMines || inCrystalHollows }, + ), + DWARVEN_EMERALD( + checkBlock = { it.block == Blocks.emerald_block }, + checkArea = { inCrystalHollows }, + ), + DWARVEN_DIAMOND( + checkBlock = { it.block == Blocks.diamond_block }, + checkArea = { inCrystalHollows }, + ), + + // GEMSTONES + RUBY( + checkBlock = { it.isGemstoneWithColor(EnumDyeColor.RED) }, + checkArea = { inCrystalHollows || inGlacite }, + ), + AMBER( + checkBlock = { it.isGemstoneWithColor(EnumDyeColor.ORANGE) }, + checkArea = { inCrystalHollows || inGlacite }, + ), + AMETHYST( + checkBlock = { it.isGemstoneWithColor(EnumDyeColor.PURPLE) }, + checkArea = { inCrystalHollows || inGlacite }, + ), + JADE( + checkBlock = { it.isGemstoneWithColor(EnumDyeColor.LIME) }, + checkArea = { inCrystalHollows || inGlacite }, + ), + SAPPHIRE( + checkBlock = { it.isGemstoneWithColor(EnumDyeColor.LIGHT_BLUE) }, + checkArea = { inCrystalHollows || inGlacite }, + ), + TOPAZ( + checkBlock = { it.isGemstoneWithColor(EnumDyeColor.YELLOW) }, + checkArea = { inCrystalHollows || inGlacite }, + ), + JASPER( + checkBlock = { it.isGemstoneWithColor(EnumDyeColor.PINK) }, + checkArea = { inCrystalHollows || inGlacite }, + ), + OPAL( + checkBlock = { it.isGemstoneWithColor(EnumDyeColor.WHITE) }, + checkArea = { inGlacite || inCrimsonIsle }, + ), + AQUAMARINE( + checkBlock = { it.isGemstoneWithColor(EnumDyeColor.BLUE) }, + checkArea = { inGlacite }, + ), + CITRINE( + checkBlock = { it.isGemstoneWithColor(EnumDyeColor.BROWN) }, + checkArea = { inGlacite }, + ), + ONYX( + checkBlock = { it.isGemstoneWithColor(EnumDyeColor.BLACK) }, + checkArea = { inGlacite }, + ), + PERIDOT( + checkBlock = { it.isGemstoneWithColor(EnumDyeColor.GREEN) }, + checkArea = { inGlacite }, + ), + + // GLACIAL + LOW_TIER_UMBER( + checkBlock = ::isLowTierUmber, + checkArea = { inGlacite }, + ), + HIGH_TIER_UMBER( + checkBlock = ::isHighTierUmber, + checkArea = { inGlacite }, + ), + LOW_TIER_TUNGSTEN( + checkBlock = { it.block == Blocks.cobblestone }, + checkArea = { inGlacite }, + ), + HIGH_TIER_TUNGSTEN( + checkBlock = { it.block == Blocks.clay }, + checkArea = { inGlacite }, + ), + GLACITE( + checkBlock = { it.block == Blocks.packed_ice }, + checkArea = { inGlacite }, + ), + ; + + companion object { + fun getByStateOrNull(state: IBlockState): OreBlock? = currentAreaOreBlocks.firstOrNull { it.checkBlock(state) } + } +} + +private fun isLowTierMithril(state: IBlockState): Boolean { + return when (state.block) { + Blocks.wool -> state.getValue(BlockColored.COLOR) == EnumDyeColor.GRAY + Blocks.stained_hardened_clay -> state.getValue(BlockColored.COLOR) == EnumDyeColor.CYAN + else -> false + } +} + +private fun isHighTierMithril(state: IBlockState): Boolean { + return (state.block == Blocks.wool && state.getValue(BlockColored.COLOR) == EnumDyeColor.LIGHT_BLUE) +} + +private fun isTitanium(state: IBlockState): Boolean { + return (state.block == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH) +} + +private fun isStone(state: IBlockState): Boolean { + return (state.block == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.STONE) +} + +private fun isHardStoneHollows(state: IBlockState): Boolean { + return when (state.block) { + Blocks.wool -> (state.getValue(BlockColored.COLOR) == EnumDyeColor.GRAY) + Blocks.stained_hardened_clay -> (state.getValue(BlockColored.COLOR) == EnumDyeColor.CYAN) + Blocks.stone -> (state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.STONE) + else -> false + } +} + +private fun isHardstoneGlacite(state: IBlockState): Boolean = + (state.block == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.STONE) || + (state.block == Blocks.wool && state.getValue(BlockColored.COLOR) == EnumDyeColor.GRAY) + +private fun isRedSand(state: IBlockState): Boolean = + (state.block == Blocks.stone && state.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND) + +private fun isLowTierUmber(state: IBlockState): Boolean = state.block == Blocks.hardened_clay || + (state.block == Blocks.stained_hardened_clay && state.getValue(BlockColored.COLOR) == EnumDyeColor.BROWN) + +private fun isHighTierUmber(state: IBlockState): Boolean = + (state.block == Blocks.double_stone_slab2 && state.getValue(BlockStoneSlabNew.VARIANT) == BlockStoneSlabNew.EnumType.RED_SANDSTONE) + +private fun IBlockState.isGemstoneWithColor(color: EnumDyeColor): Boolean { + return when (this.block) { + Blocks.stained_glass -> color == this.getValue(BlockStainedGlass.COLOR) + Blocks.stained_glass_pane -> color == this.getValue(BlockStainedGlassPane.COLOR) + else -> false + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/OreType.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/OreType.kt new file mode 100644 index 000000000..9e47a5a45 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/OreType.kt @@ -0,0 +1,213 @@ +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 + +enum class OreType( + val oreName: String, + private val internalNameString: String, + val oreBlocks: List, + val internalName: NEUInternalName = internalNameString.asInternalName() +) { + MITHRIL( + "Mithril", + "MITHRIL_ORE", + listOf(OreBlock.LOW_TIER_MITHRIL, OreBlock.MID_TIER_MITHRIL, OreBlock.HIGH_TIER_MITHRIL) + ), + TITANIUM( + "Titanium", + "TITANIUM_ORE", + listOf(OreBlock.TITANIUM) + ), + COBBLESTONE( + "Cobblestone", + "COBBLESTONE", + listOf(OreBlock.STONE, OreBlock.COBBLESTONE) + ), + COAL( + "Coal", + "COAL", + listOf(OreBlock.COAL_ORE) + ), + IRON( + "Iron", + "IRON_INGOT", + listOf(OreBlock.IRON_ORE) + ), + GOLD( + "Gold", + "GOLD_INGOT", + listOf(OreBlock.GOLD_ORE, OreBlock.DWARVEN_GOLD) + ), + LAPIS( + "Lapis Lazuli", + "INK_SACK-4", + listOf(OreBlock.LAPIS_ORE) + ), + REDSTONE( + "Redstone", + "REDSTONE", + listOf(OreBlock.REDSTONE_ORE, OreBlock.DWARVEN_REDSTONE) + ), + EMERALD( + "Emerald", + "EMERALD", + listOf(OreBlock.EMERALD_ORE, OreBlock.DWARVEN_EMERALD) + ), + DIAMOND( + "Diamond", + "DIAMOND", + listOf(OreBlock.DIAMOND_ORE, OreBlock.DWARVEN_DIAMOND) + ), + NETHERRACK( + "Netherrack", + "NETHERRACK", + listOf(OreBlock.NETHERRACK) + ), + QUARTZ( + "Nether Quartz", + "QUARTZ", + listOf(OreBlock.QUARTZ_ORE) + ), + GLOWSTONE( + "Glowstone", + "GLOWSTONE_DUST", + listOf(OreBlock.GLOWSTONE) + ), + MYCELIUM( + "Mycelium", + "MYCEL", + listOf(OreBlock.MYCELIUM) + ), + RED_SAND( + "Red Sand", + "SAND-1", + listOf(OreBlock.RED_SAND) + ), + SULPHUR( + "Sulphur", + "SULPHUR_ORE", + listOf(OreBlock.SULPHUR) + ), + GRAVEL( + "Gravel", + "GRAVEL", + listOf(OreBlock.GRAVEL) + ), + END_STONE( + "End Stone", + "ENDER_STONE", + listOf(OreBlock.END_STONE) + ), + OBSIDIAN( + "Obsidian", + "OBSIDIAN", + listOf(OreBlock.OBSIDIAN) + ), + HARD_STONE( + "Hard Stone", + "HARD_STONE", + listOf(OreBlock.HARD_STONE_HOLLOWS, OreBlock.HARD_STONE_GLACIAL) + ), + RUBY( + "Ruby", + "ROUGH_RUBY_GEM", + listOf(OreBlock.RUBY) + ), + AMBER( + "Amber", + "ROUGH_AMBER_GEM", + listOf(OreBlock.AMBER) + ), + AMETHYST( + "Amethyst", + "ROUGH_AMETHYST_GEM", + listOf(OreBlock.AMETHYST) + ), + JADE( + "Jade", + "ROUGH_JADE_GEM", + listOf(OreBlock.JADE) + ), + SAPPHIRE( + "Sapphire", + "ROUGH_SAPPHIRE_GEM", + listOf(OreBlock.SAPPHIRE) + ), + TOPAZ( + "Topaz", + "ROUGH_TOPAZ_GEM", + listOf(OreBlock.TOPAZ) + ), + JASPER( + "Jasper", + "ROUGH_JASPER_GEM", + listOf(OreBlock.JASPER) + ), + OPAL( + "Opal", + "ROUGH_OPAL_GEM", + listOf(OreBlock.OPAL) + ), + AQUAMARINE( + "Aquamarine", + "ROUGH_AQUAMARINE_GEM", + listOf(OreBlock.AQUAMARINE) + ), + CITRINE( + "Citrine", + "ROUGH_CITRINE_GEM", + listOf(OreBlock.CITRINE) + ), + ONYX( + "Onyx", + "ROUGH_ONYX_GEM", + listOf(OreBlock.ONYX) + ), + PERIDOT( + "Peridot", + "ROUGH_PERIDOT_GEM", + listOf(OreBlock.PERIDOT) + ), + UMBER( + "Umber", + "UMBER", + listOf(OreBlock.LOW_TIER_UMBER, OreBlock.HIGH_TIER_UMBER) + ), + TUNGSTEN( + "Tungsten", + "TUNGSTEN", + listOf(OreBlock.LOW_TIER_TUNGSTEN, OreBlock.HIGH_TIER_TUNGSTEN) + ), + GLACITE( + "Glacite", + "GLACITE", + listOf(OreBlock.GLACITE) + ), + ; + + companion object { + + 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 OreBlock.getOreType(): OreType? { + return OreType.entries.firstOrNull { + it.oreBlocks.contains(this) + } + } + } +} -- cgit