From 8b51cb356a7e03f28a2cf41442d0c7e02f760607 Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Sun, 23 Jun 2024 13:31:21 +0200 Subject: [PATCH 001/721] Fix: Ore Event (#2115) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../at/hannibal2/skyhanni/data/MiningAPI.kt | 63 ++++++++++--------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt index 940b4ea35fac..be36bc11b61a 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt @@ -46,7 +46,7 @@ object MiningAPI { "§c ☠ §r§7§r§.(?.+)§r§7 (?.+)", ) - data class MinedBlock(val ore: OreBlock, var position: LorenzVec, var confirmed: Boolean, val time: SimpleTimeMark) + private data class MinedBlock(val ore: OreBlock, var confirmed: Boolean, val time: SimpleTimeMark = SimpleTimeMark.now()) private var lastInitSound = SimpleTimeMark.farPast() @@ -68,9 +68,9 @@ object MiningAPI { private var lastSkyblockArea: String? = null - private var recentClickedBlocks = mutableListOf() - private var surroundingMinedBlocks = mutableListOf() - private val allowedSoundNames = listOf("dig.glass", "dig.stone", "dig.gravel", "dig.cloth") + private var recentClickedBlocks = mutableMapOf() + private var surroundingMinedBlocks = mutableMapOf() + private val allowedSoundNames = listOf("dig.glass", "dig.stone", "dig.gravel", "dig.cloth", "random.orb") var cold: Int = 0 private set @@ -119,7 +119,7 @@ object MiningAPI { val position = event.position val blockState = event.getBlockState val ore = OreBlock.getByStateOrNull(blockState) ?: return - recentClickedBlocks.add(MinedBlock(ore, position, false, SimpleTimeMark.now())) + recentClickedBlocks[position] = MinedBlock(ore, false) } @SubscribeEvent @@ -142,10 +142,11 @@ object MiningAPI { @SubscribeEvent fun onPlaySound(event: PlaySoundEvent) { if (!inCustomMiningIsland()) return + if (event.soundName !in allowedSoundNames) return if (waitingForInitSound) { - if (event.soundName in allowedSoundNames && event.pitch == 0.7936508f) { + if (event.soundName != "random.orb" && event.pitch == 0.7936508f) { val pos = event.location.roundLocationToBlock() - if (recentClickedBlocks.none { it.position == pos }) return + if (pos !in recentClickedBlocks) return waitingForInitSound = false waitingForInitBlock = true waitingForInitBlockPos = event.location.roundLocationToBlock() @@ -155,12 +156,11 @@ object MiningAPI { } if (waitingForEffMinerSound) { if (surroundingMinedBlocks.isEmpty()) return - if (event.soundName in allowedSoundNames || event.soundName == "random.orb") { - if (surroundingMinedBlocks.last().confirmed) return - waitingForEffMinerSound = false - surroundingMinedBlocks.last().confirmed = true - waitingForEffMinerBlock = true - } + val lastBlock = surroundingMinedBlocks.values.minByOrNull { it.time.passedSince() } ?: return + if (lastBlock.confirmed) return + waitingForEffMinerSound = false + lastBlock.confirmed = true + waitingForEffMinerBlock = true } } @@ -178,14 +178,14 @@ object MiningAPI { if (waitingForInitBlock) { if (waitingForInitBlockPos != event.location) return waitingForInitBlock = false - surroundingMinedBlocks.add(MinedBlock(ore, event.location, true, SimpleTimeMark.now())) + surroundingMinedBlocks[event.location] = MinedBlock(ore, true) waitingForEffMinerBlock = true return } if (waitingForEffMinerBlock) { - if (surroundingMinedBlocks.any { it.position == event.location }) return + if (event.location in surroundingMinedBlocks) return waitingForEffMinerBlock = false - surroundingMinedBlocks.add(MinedBlock(ore, event.location, false, SimpleTimeMark.now())) + surroundingMinedBlocks[event.location] = MinedBlock(ore, false) waitingForEffMinerSound = true return } @@ -201,34 +201,37 @@ object MiningAPI { if (currentAreaOreBlocks.isEmpty()) return // if somehow you take more than 20 seconds to mine a single block, congrats - recentClickedBlocks.removeIf { it.time.passedSince() > 20.seconds } - surroundingMinedBlocks.removeIf { it.time.passedSince() > 20.seconds } + recentClickedBlocks = recentClickedBlocks.filter { it.value.time.passedSince() <= 20.seconds }.toMutableMap() + surroundingMinedBlocks = surroundingMinedBlocks.filter { it.value.time.passedSince() <= 20.seconds }.toMutableMap() - if (surroundingMinedBlocks.isEmpty()) return + if (waitingForInitSound) return if (lastInitSound.passedSince() < 200.milliseconds) return resetOreEvent() - val originalBlock = surroundingMinedBlocks.firstOrNull { it.confirmed } ?: run { - surroundingMinedBlocks = mutableListOf() - recentClickedBlocks = mutableListOf() - return - } + if (surroundingMinedBlocks.isEmpty()) return + + val originalBlock = surroundingMinedBlocks.maxByOrNull { it.value.time.passedSince() }?.takeIf { it.value.confirmed }?.value + ?: run { + surroundingMinedBlocks.clear() + recentClickedBlocks.clear() + return + } - val extraBlocks = surroundingMinedBlocks.filter { it.confirmed }.countBy { it.ore } + val extraBlocks = surroundingMinedBlocks.values.filter { it.confirmed }.countBy { it.ore } OreMinedEvent(originalBlock.ore, extraBlocks).post() - surroundingMinedBlocks = mutableListOf() - recentClickedBlocks.removeIf { it.time.passedSince() >= originalBlock.time.passedSince() } + surroundingMinedBlocks.clear() + recentClickedBlocks = recentClickedBlocks.filter { it.value.time.passedSince() < originalBlock.time.passedSince() }.toMutableMap() } @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { if (cold != 0) updateCold(0) lastColdReset = SimpleTimeMark.now() - recentClickedBlocks = mutableListOf() - surroundingMinedBlocks = mutableListOf() + recentClickedBlocks.clear() + surroundingMinedBlocks.clear() currentAreaOreBlocks = setOf() resetOreEvent() } @@ -261,7 +264,7 @@ object MiningAPI { add("waitingForInitBlockPos: $waitingForInitBlockPos") add("waitingForEffMinerSound: $waitingForEffMinerSound") add("waitingForEffMinerBlock: $waitingForEffMinerBlock") - add("recentClickedBlocks: ${recentClickedBlocks.joinToString { it.position.toCleanString() }}") + add("recentClickedBlocks: ${recentClickedBlocks.entries.joinToString { it.key.toCleanString() }}") } } From 7ff28af498fdba6e5a2a1150c3e2620c613c2c48 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sun, 23 Jun 2024 07:45:28 -0400 Subject: [PATCH 002/721] Feature & Fix: Powder Tracker Hard Stone & Goblin Eggs (#2138) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/mining/PowderTrackerConfig.java | 8 +++- .../mining/powdertracker/PowderTracker.kt | 37 ++++++++++++++++--- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/PowderTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/PowderTrackerConfig.java index 2f277d92500b..1c32cabc2e95 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/PowderTrackerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/PowderTrackerConfig.java @@ -22,6 +22,7 @@ import static at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry.FTX; import static at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry.GEMSTONE_POWDER; import static at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry.GOLD_ESSENCE; +import static at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry.HARD_STONE; import static at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry.JADE; import static at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry.MITHRIL_POWDER; import static at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry.ROBOTRON; @@ -29,6 +30,7 @@ import static at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry.SAPPHIRE; import static at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry.SPACER_1; import static at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry.SPACER_2; +import static at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry.SPACER_3; import static at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry.TOPAZ; import static at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry.TOTAL_CHESTS; @@ -60,6 +62,8 @@ public class PowderTrackerConfig { DIAMOND_ESSENCE, GOLD_ESSENCE, SPACER_2, + HARD_STONE, + SPACER_3, RUBY, SAPPHIRE, AMBER, @@ -80,6 +84,8 @@ public enum PowderDisplayEntry implements HasLegacyId { DIAMOND_ESSENCE("§b129 §bDiamond Essence §7(600/h)", 7), GOLD_ESSENCE("§b234 §6Gold Essence §7(700/h)", 8), SPACER_2("", 9), + HARD_STONE("§b1000 §fHard Stone §bCompacted §7(500/h)"), + SPACER_3(""), RUBY("§50§7-§90§7-§a0§f-0 §cRuby Gemstone", 10), SAPPHIRE("§50§7-§90§7-§a0§f-0 §bSapphire Gemstone", 11), AMBER("§50§7-§90§7-§a0§f-0 §6Amber Gemstone", 12), @@ -93,7 +99,7 @@ public enum PowderDisplayEntry implements HasLegacyId { CONTROL_SWITCH("§b14 §9Control Switch", 20), SYNTHETIC_HEART("§b14 §9Synthetic Heart", 21), TOTAL_ROBOT_PARTS("§b14 §9Total Robot Parts", 22), - GOBLIN_EGGS("§90§7-§a0§7-§c0§f-§e0§f-§30 §fGoblin Egg", 23), + GOBLIN_EGGS("§30§7-§c0§7-§e0§f-§a0§f-§90 §fGoblin Egg", 23), WISHING_COMPASS("§b12 §aWishing Compass", 24), SLUDGE_JUICE("§b320 §aSludge Juice", 25), ASCENSION_ROPE("§b2 §9Ascension Rope", 26), diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt index a936f963622a..f302b669b3be 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt @@ -57,6 +57,14 @@ object PowderTracker { "§e§lPASSIVE EVENT §b§l2X POWDER §e§lRUNNING FOR §a§l(?