aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2022-08-06 22:58:03 -0400
committerbowser0000 <bowser0000@gmail.com>2022-08-06 22:58:03 -0400
commit4431e9eddd09e4d43c42f6e541810c47c83efdcb (patch)
tree929faa03f3c5a6210f7ead836ed734ddd5f9b3f4
parent66fa83a1942b4ec79c5fa94168c04b84c60c628a (diff)
downloadSkyblockMod-4431e9eddd09e4d43c42f6e541810c47c83efdcb.tar.gz
SkyblockMod-4431e9eddd09e4d43c42f6e541810c47c83efdcb.tar.bz2
SkyblockMod-4431e9eddd09e4d43c42f6e541810c47c83efdcb.zip
Use sound packet for slayer token drop tracking
Fixes token drops not being tracked when volume is off.
-rw-r--r--src/main/java/me/Danker/features/loot/LootTracker.java25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/main/java/me/Danker/features/loot/LootTracker.java b/src/main/java/me/Danker/features/loot/LootTracker.java
index 7fa223d..13599a0 100644
--- a/src/main/java/me/Danker/features/loot/LootTracker.java
+++ b/src/main/java/me/Danker/features/loot/LootTracker.java
@@ -1,13 +1,11 @@
package me.Danker.features.loot;
+import me.Danker.events.PacketReadEvent;
import me.Danker.handlers.ConfigHandler;
-import me.Danker.handlers.ScoreboardHandler;
import me.Danker.utils.Utils;
-import net.minecraftforge.client.event.sound.PlaySoundEvent;
-import net.minecraftforge.fml.common.eventhandler.EventPriority;
+import net.minecraft.network.play.server.S29PacketSoundEffect;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -16,20 +14,17 @@ public class LootTracker {
public static long itemsChecked = 0;
static Pattern dropPattern = Pattern.compile(".*? \\((?<amount>\\d+)x .*\\).*");
- @SubscribeEvent(priority = EventPriority.HIGHEST)
- public void onSound(PlaySoundEvent event) {
+ @SubscribeEvent
+ public void onPacketRead(PacketReadEvent event) {
if (!Utils.inSkyblock) return;
- if (event.name.equals("note.pling")) {
- // Don't check twice within 3 seconds
- long checkItemsNow = System.currentTimeMillis() / 1000;
- if (checkItemsNow - itemsChecked < 3) return;
- List<String> scoreboard = ScoreboardHandler.getSidebarLines();
+ if (event.packet instanceof S29PacketSoundEffect) {
+ S29PacketSoundEffect packet = (S29PacketSoundEffect) event.packet;
- for (String line : scoreboard) {
- String cleanedLine = ScoreboardHandler.cleanSB(line);
- // If Hypixel lags and scoreboard doesn't update
- if (cleanedLine.contains("Boss slain!") || cleanedLine.contains("Slay the boss!")) {
+ if (packet.getSoundName().equals("note.pling")) {
+ if (System.currentTimeMillis() / 1000 - itemsChecked < 3) return;
+
+ if (Utils.isInScoreboard("Boss slain!") || Utils.isInScoreboard("Slay the boss!")) {
int itemTeeth = Utils.getItems("Wolf Tooth");
int itemWebs = Utils.getItems("Tarantula Web");
int itemRev = Utils.getItems("Revenant Flesh");