diff options
author | Empa <42304516+ItsEmpa@users.noreply.github.com> | 2024-09-20 22:48:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-20 22:48:17 +0200 |
commit | 40288e4d66dd53ab6865ac08a90ea843c1bc0f62 (patch) | |
tree | 34d389fc320b77e02d88669a7d71e2dd027b9d8a /src/main/java/at/hannibal2 | |
parent | 8f7042f1e286890255b7a6f803a2414440be3df2 (diff) | |
download | skyhanni-40288e4d66dd53ab6865ac08a90ea843c1bc0f62.tar.gz skyhanni-40288e4d66dd53ab6865ac08a90ea843c1bc0f62.tar.bz2 skyhanni-40288e4d66dd53ab6865ac08a90ea843c1bc0f62.zip |
Fix: Hardstone and Tungsten detection in Mineshafts (#2536)
Co-authored-by: ItsEmpa <itsempa@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2')
5 files changed, 113 insertions, 66 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt index fd399ae8b..758294ffc 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt @@ -8,7 +8,6 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.PlaySoundEvent import at.hannibal2.skyhanni.events.ScoreboardUpdateEvent -import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.ServerBlockChangeEvent import at.hannibal2.skyhanni.events.mining.OreMinedEvent import at.hannibal2.skyhanni.events.player.PlayerDeathEvent @@ -59,6 +58,8 @@ object MiningAPI { private var waitingForEffMinerBlock = false var inGlacite = false + var inTunnels = false + var inMineshaft = false var inDwarvenMines = false var inCrystalHollows = false var inCrimsonIsle = false @@ -66,12 +67,13 @@ object MiningAPI { var inSpidersDen = false var currentAreaOreBlocks = setOf<OreBlock>() + private set private var lastSkyblockArea: String? = null private val recentClickedBlocks = ConcurrentSet<Pair<LorenzVec, SimpleTimeMark>>() private val surroundingMinedBlocks = ConcurrentLinkedQueue<Pair<MinedBlock, LorenzVec>>() - private val allowedSoundNames = listOf("dig.glass", "dig.stone", "dig.gravel", "dig.cloth", "random.orb") + private val allowedSoundNames = setOf("dig.glass", "dig.stone", "dig.gravel", "dig.cloth", "random.orb") var cold: Int = 0 private set @@ -117,6 +119,7 @@ object MiningAPI { fun onBlockClick(event: BlockClickEvent) { if (!inCustomMiningIsland()) return if (event.clickType != ClickType.LEFT_CLICK) return + //println(event.getBlockState.properties) if (OreBlock.getByStateOrNull(event.getBlockState) == null) return recentClickedBlocks += event.position to SimpleTimeMark.now() } @@ -142,6 +145,7 @@ object MiningAPI { fun onPlaySound(event: PlaySoundEvent) { if (!inCustomMiningIsland()) return if (event.soundName !in allowedSoundNames) return + //println("Sound: ${event.soundName} ${event.pitch} ${event.volume} ${event.location.toCleanString()}") if (waitingForInitSound) { if (event.soundName != "random.orb" && event.pitch == 0.7936508f) { val pos = event.location.roundLocationToBlock() @@ -176,6 +180,7 @@ object MiningAPI { val pos = event.location if (pos.distanceToPlayer() > 7) return + //println("Block change: $oldState -> $newState ${pos.toCleanString()}") if (lastInitSound.passedSince() > 100.milliseconds) return @@ -288,6 +293,8 @@ object MiningAPI { lastSkyblockArea = currentArea inGlacite = inGlaciteArea() + inTunnels = inGlacialTunnels() + inMineshaft = inMineshaft() inDwarvenMines = inRegularDwarven() inCrystalHollows = inCrystalHollows() inCrimsonIsle = IslandType.CRIMSON_ISLE.isInIsland() 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 3b89ae246..8497951fe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/MineshaftPityDisplay.kt @@ -15,7 +15,6 @@ 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 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 bf7c8c2ac..5eaff2b44 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt @@ -10,7 +10,6 @@ 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.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/OreBlock.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/OreBlock.kt index d9b76a35b..8acf4fc86 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/OreBlock.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/OreBlock.kt @@ -6,7 +6,9 @@ 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.inMineshaft import at.hannibal2.skyhanni.data.MiningAPI.inSpidersDen +import at.hannibal2.skyhanni.data.MiningAPI.inTunnels import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf import net.minecraft.block.BlockColored import net.minecraft.block.BlockSand @@ -14,11 +16,13 @@ import net.minecraft.block.BlockSilverfish import net.minecraft.block.BlockStainedGlass import net.minecraft.block.BlockStainedGlassPane import net.minecraft.block.BlockStone +import net.minecraft.block.BlockStoneSlab 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, @@ -128,9 +132,13 @@ enum class OreBlock( checkBlock = ::isHardStoneHollows, checkArea = { inCrystalHollows }, ), - HARD_STONE_GLACIAL( - checkBlock = ::isHardstoneGlacite, - checkArea = { inGlacite }, + HARD_STONE_TUNNELS( + checkBlock = ::isHardstoneTunnels, + checkArea = { inTunnels }, + ), + HARD_STONE_MINESHAFT( + checkBlock = ::isHardstoneMineshaft, + checkArea = { inMineshaft }, ), // DWARVEN BLOCKS @@ -139,10 +147,12 @@ enum class OreBlock( checkArea = { inDwarvenMines || inCrystalHollows }, ), PURE_IRON( + // currently not detected checkBlock = { it.block == Blocks.iron_block }, checkArea = { inDwarvenMines || inCrystalHollows }, ), PURE_GOLD( + // currently not detected checkBlock = { it.block == Blocks.gold_block }, checkArea = { inDwarvenMines || inCrystalHollows }, ), @@ -151,14 +161,17 @@ enum class OreBlock( checkArea = { inDwarvenMines || inCrystalHollows }, ), PURE_REDSTONE( + // currently not detected checkBlock = { it.block == Blocks.redstone_block }, checkArea = { inDwarvenMines || inCrystalHollows }, ), PURE_EMERALD( + // currently not detected checkBlock = { it.block == Blocks.emerald_block }, checkArea = { inDwarvenMines || inCrystalHollows }, ), PURE_DIAMOND( + // currently not detected checkBlock = { it.block == Blocks.diamond_block }, checkArea = { inDwarvenMines || inCrystalHollows }, ), @@ -222,14 +235,20 @@ enum class OreBlock( checkBlock = ::isHighTierUmber, checkArea = { inGlacite }, ), - LOW_TIER_TUNGSTEN( - checkBlock = ::isLowTierTungsten, - checkArea = { inGlacite }, + + LOW_TIER_TUNGSTEN_TUNNELS( + checkBlock = ::isLowTierTungstenTunnels, + checkArea = { inTunnels }, + ), + LOW_TIER_TUNGSTEN_MINESHAFT( + checkBlock = ::isLowTierTungstenMineshaft, + checkArea = { inMineshaft }, ), HIGH_TIER_TUNGSTEN( checkBlock = { it.block == Blocks.clay }, checkArea = { inGlacite }, ), + GLACITE( checkBlock = { it.block == Blocks.packed_ice }, checkArea = { inGlacite }, @@ -261,33 +280,50 @@ private fun isStone(state: IBlockState): Boolean { 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) + Blocks.wool -> { + val color = state.getValue(BlockColored.COLOR) + color == EnumDyeColor.GRAY || color == EnumDyeColor.GREEN + } + Blocks.stained_hardened_clay -> when (state.getValue(BlockColored.COLOR)) { + EnumDyeColor.CYAN, EnumDyeColor.BROWN, EnumDyeColor.GRAY, EnumDyeColor.BLACK, + EnumDyeColor.LIME, EnumDyeColor.GREEN, EnumDyeColor.BLUE, EnumDyeColor.RED, + EnumDyeColor.SILVER -> true + else -> false + } + Blocks.clay, Blocks.stonebrick, Blocks.stone -> true else -> false } } -private fun isHardstoneGlacite(state: IBlockState): Boolean = +private fun isHardstoneTunnels(state: IBlockState): Boolean = (state.block == Blocks.monster_egg && state.getValue(BlockSilverfish.VARIANT) == BlockSilverfish.EnumType.STONE) || - (state.block == Blocks.wool && state.getValue(BlockColored.COLOR) == EnumDyeColor.GRAY) + (state.block == Blocks.wool && state.getValue(BlockColored.COLOR) == EnumDyeColor.SILVER) + +private fun isHardstoneMineshaft(state: IBlockState): Boolean = + (state.block == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.STONE) || + (state.block == Blocks.wool && state.getValue(BlockColored.COLOR) == EnumDyeColor.SILVER) private fun isRedSand(state: IBlockState): Boolean = (state.block == Blocks.sand && 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) + 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 isLowTierTungsten(state: IBlockState): Boolean = - state.block == Blocks.monster_egg && state.getValue(BlockSilverfish.VARIANT) == BlockSilverfish.EnumType.COBBLESTONE +private fun isLowTierTungstenTunnels(state: IBlockState): Boolean = + state.block == Blocks.monster_egg && state.getValue(BlockSilverfish.VARIANT) == BlockSilverfish.EnumType.STONE -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 - } +private fun isLowTierTungstenMineshaft(state: IBlockState): Boolean = when (state.block) { + Blocks.stone_slab -> state.getValue(BlockStoneSlab.VARIANT) == BlockStoneSlab.EnumType.COBBLESTONE + Blocks.cobblestone, Blocks.stone_stairs -> true + else -> false +} + +private fun IBlockState.isGemstoneWithColor(color: EnumDyeColor): Boolean = when (block) { + Blocks.stained_glass -> color == getValue(BlockStainedGlass.COLOR) + Blocks.stained_glass_pane -> color == 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 index 5f9743b68..66c128371 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/OreType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/OreType.kt @@ -7,187 +7,190 @@ import net.minecraft.block.state.IBlockState enum class OreType( val oreName: String, - private val internalNameString: String, - val oreBlocks: List<OreBlock>, - val internalName: NEUInternalName = internalNameString.asInternalName(), + internalName: String, + vararg val oreBlocks: OreBlock, ) { MITHRIL( "Mithril", "MITHRIL_ORE", - listOf(OreBlock.LOW_TIER_MITHRIL, OreBlock.MID_TIER_MITHRIL, OreBlock.HIGH_TIER_MITHRIL), + OreBlock.LOW_TIER_MITHRIL, OreBlock.MID_TIER_MITHRIL, OreBlock.HIGH_TIER_MITHRIL, ), TITANIUM( "Titanium", "TITANIUM_ORE", - listOf(OreBlock.TITANIUM), + OreBlock.TITANIUM, ), COBBLESTONE( "Cobblestone", "COBBLESTONE", - listOf(OreBlock.STONE, OreBlock.COBBLESTONE), + OreBlock.STONE, OreBlock.COBBLESTONE, ), COAL( "Coal", "COAL", - listOf(OreBlock.COAL_ORE, OreBlock.PURE_COAL), + OreBlock.COAL_ORE, OreBlock.PURE_COAL, ), IRON( "Iron", "IRON_INGOT", - listOf(OreBlock.IRON_ORE, OreBlock.PURE_IRON), + OreBlock.IRON_ORE, OreBlock.PURE_IRON, ), GOLD( "Gold", "GOLD_INGOT", - listOf(OreBlock.GOLD_ORE, OreBlock.PURE_GOLD), + OreBlock.GOLD_ORE, OreBlock.PURE_GOLD, ), LAPIS( "Lapis Lazuli", "INK_SACK-4", - listOf(OreBlock.LAPIS_ORE, OreBlock.PURE_LAPIS), + OreBlock.LAPIS_ORE, OreBlock.PURE_LAPIS, ), REDSTONE( "Redstone", "REDSTONE", - listOf(OreBlock.REDSTONE_ORE, OreBlock.PURE_REDSTONE), + OreBlock.REDSTONE_ORE, OreBlock.PURE_REDSTONE, ), EMERALD( "Emerald", "EMERALD", - listOf(OreBlock.EMERALD_ORE, OreBlock.PURE_EMERALD), + OreBlock.EMERALD_ORE, OreBlock.PURE_EMERALD, ), DIAMOND( "Diamond", "DIAMOND", - listOf(OreBlock.DIAMOND_ORE, OreBlock.PURE_DIAMOND), + OreBlock.DIAMOND_ORE, OreBlock.PURE_DIAMOND, ), NETHERRACK( "Netherrack", "NETHERRACK", - listOf(OreBlock.NETHERRACK), + OreBlock.NETHERRACK, ), QUARTZ( "Nether Quartz", "QUARTZ", - listOf(OreBlock.QUARTZ_ORE), + OreBlock.QUARTZ_ORE, ), GLOWSTONE( "Glowstone", "GLOWSTONE_DUST", - listOf(OreBlock.GLOWSTONE), + OreBlock.GLOWSTONE, ), MYCELIUM( "Mycelium", "MYCEL", - listOf(OreBlock.MYCELIUM), + OreBlock.MYCELIUM, ), RED_SAND( "Red Sand", "SAND-1", - listOf(OreBlock.RED_SAND), + OreBlock.RED_SAND, ), SULPHUR( "Sulphur", "SULPHUR_ORE", - listOf(OreBlock.SULPHUR), + OreBlock.SULPHUR, ), GRAVEL( "Gravel", "GRAVEL", - listOf(OreBlock.GRAVEL), + OreBlock.GRAVEL, ), END_STONE( "End Stone", "ENDER_STONE", - listOf(OreBlock.END_STONE), + OreBlock.END_STONE, ), OBSIDIAN( "Obsidian", "OBSIDIAN", - listOf(OreBlock.OBSIDIAN), + OreBlock.OBSIDIAN, ), HARD_STONE( "Hard Stone", "HARD_STONE", - listOf(OreBlock.HARD_STONE_HOLLOWS, OreBlock.HARD_STONE_GLACIAL), + OreBlock.HARD_STONE_HOLLOWS, OreBlock.HARD_STONE_TUNNELS, OreBlock.HARD_STONE_MINESHAFT, ), RUBY( "Ruby", "ROUGH_RUBY_GEM", - listOf(OreBlock.RUBY), + OreBlock.RUBY, ), AMBER( "Amber", "ROUGH_AMBER_GEM", - listOf(OreBlock.AMBER), + OreBlock.AMBER, ), AMETHYST( "Amethyst", "ROUGH_AMETHYST_GEM", - listOf(OreBlock.AMETHYST), + OreBlock.AMETHYST, ), JADE( "Jade", "ROUGH_JADE_GEM", - listOf(OreBlock.JADE), + OreBlock.JADE, ), SAPPHIRE( "Sapphire", "ROUGH_SAPPHIRE_GEM", - listOf(OreBlock.SAPPHIRE), + OreBlock.SAPPHIRE, ), TOPAZ( "Topaz", "ROUGH_TOPAZ_GEM", - listOf(OreBlock.TOPAZ), + OreBlock.TOPAZ, ), JASPER( "Jasper", "ROUGH_JASPER_GEM", - listOf(OreBlock.JASPER), + OreBlock.JASPER, ), OPAL( "Opal", "ROUGH_OPAL_GEM", - listOf(OreBlock.OPAL), + OreBlock.OPAL, ), AQUAMARINE( "Aquamarine", "ROUGH_AQUAMARINE_GEM", - listOf(OreBlock.AQUAMARINE), + OreBlock.AQUAMARINE, ), CITRINE( "Citrine", "ROUGH_CITRINE_GEM", - listOf(OreBlock.CITRINE), + OreBlock.CITRINE, ), ONYX( "Onyx", "ROUGH_ONYX_GEM", - listOf(OreBlock.ONYX), + OreBlock.ONYX, ), PERIDOT( "Peridot", "ROUGH_PERIDOT_GEM", - listOf(OreBlock.PERIDOT), + OreBlock.PERIDOT, ), UMBER( "Umber", "UMBER", - listOf(OreBlock.LOW_TIER_UMBER, OreBlock.HIGH_TIER_UMBER), + OreBlock.LOW_TIER_UMBER, OreBlock.HIGH_TIER_UMBER, ), TUNGSTEN( "Tungsten", "TUNGSTEN", - listOf(OreBlock.LOW_TIER_TUNGSTEN, OreBlock.HIGH_TIER_TUNGSTEN), + OreBlock.LOW_TIER_TUNGSTEN_TUNNELS, OreBlock.LOW_TIER_TUNGSTEN_MINESHAFT, OreBlock.HIGH_TIER_TUNGSTEN, ), GLACITE( "Glacite", "GLACITE", - listOf(OreBlock.GLACITE), + OreBlock.GLACITE, ), ; + val internalName: NEUInternalName = internalName.asInternalName() + + fun isGemstone(): Boolean = this in gemstones + companion object { private val gemstones = setOf( @@ -197,12 +200,15 @@ enum class OreType( ) fun IBlockState.isOreType(oreType: OreType): Boolean { - return oreType.oreBlocks.intersect(MiningAPI.currentAreaOreBlocks) - .any { it.checkBlock.invoke(this) } + for (oreBlock in oreType.oreBlocks) { + if (oreBlock !in MiningAPI.currentAreaOreBlocks) continue + if (oreBlock.checkBlock(this)) { + return true + } + } + return false } - fun OreType.isGemstone(): Boolean = this in gemstones - fun OreBlock.getOreType(): OreType? { return OreType.entries.firstOrNull { this in it.oreBlocks } } |