From e53e56c18788a02c1f99c226ec5905ce1958325c Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 15 Jul 2024 19:45:19 +0100 Subject: clean code --- .../skyblock/dwarven/CrystalsChestHighlighter.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsChestHighlighter.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsChestHighlighter.java index 1103008f..8cd75428 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsChestHighlighter.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsChestHighlighter.java @@ -14,7 +14,6 @@ import net.minecraft.network.packet.s2c.play.ParticleS2CPacket; import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket; import net.minecraft.particle.ParticleTypes; import net.minecraft.text.Text; -import net.minecraft.util.Formatting; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.BlockPos; @@ -82,12 +81,12 @@ public class CrystalsChestHighlighter { waitingForChest -= 1; } else if (state.isAir() && activeChests.contains(pos)) { currentLockCount = 0; - activeChests.remove(pos); + activeChests.remove(pos); } } /** - * When a particle is spawned add that particle to active particles + * When a particle is spawned add that particle to active particles if correct for lock picking * * @param packet particle spawn packet */ @@ -101,18 +100,24 @@ public class CrystalsChestHighlighter { } /** - * When sound is created to tell the user that they have done a stage of picking remove all old particles + * Updates {@link CrystalsChestHighlighter#currentLockCount} and clears {@link CrystalsChestHighlighter#activeParticles} based on lock pick related sound events. * * @param packet sound packet */ public static void onSound(PlaySoundS2CPacket packet) { + if (!Utils.isInCrystalHollows() || !SkyblockerConfigManager.get().mining.crystalHollows.chestHighlighter) { + return; + } String path = packet.getSound().value().getId().getPath(); + //lock picked sound if (path.equals("entity.experience_orb.pickup") && packet.getPitch() == 1) { currentLockCount += 1; activeParticles.clear(); + //lock pick fail sound } else if (path.equals("entity.villager.no")) { currentLockCount = 0; activeParticles.clear(); + //lock pick finish sound } else if (path.equals("block.chest.open")) { //set the needed lock count to the current, so we know how many locks a chest has neededLockCount = currentLockCount; @@ -120,7 +125,6 @@ public class CrystalsChestHighlighter { } } - /** * If enabled, renders a box around active treasure chests, taking the color from the config. * Additionally, calculates and displaces the highlight to indicate lock-picking spots on chests. -- cgit