diff options
| author | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2024-07-26 14:53:46 +0800 |
|---|---|---|
| committer | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2024-07-26 15:09:20 +0800 |
| commit | 8f27eb76273fe8424d44c2a1e08e45454e76b77c (patch) | |
| tree | 300bef4c49905a4c2c439c8471e6a68ade4e526c /src/main/java/de/hysky/skyblocker/skyblock/dungeon | |
| parent | 9f7fdb2a5e37907e7e4a5dd2400748b4a8e5f991 (diff) | |
| download | Skyblocker-8f27eb76273fe8424d44c2a1e08e45454e76b77c.tar.gz Skyblocker-8f27eb76273fe8424d44c2a1e08e45454e76b77c.tar.bz2 Skyblocker-8f27eb76273fe8424d44c2a1e08e45454e76b77c.zip | |
Refactor LividColor and Nukekubi head detection
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/dungeon')
| -rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java index d360ae2e..b6a035aa 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java @@ -19,7 +19,6 @@ import net.minecraft.util.Formatting; import net.minecraft.util.math.BlockPos; import java.util.Map; -import java.util.Set; public class LividColor { private static final Map<Block, Formatting> WOOL_TO_FORMATTING = Map.of( @@ -44,14 +43,16 @@ public class LividColor { "Doctor Livid", Formatting.GRAY, "Vendetta Livid", Formatting.WHITE ); - public static final Set<String> LIVID_NAMES = Set.copyOf(LIVID_TO_FORMATTING.keySet()); public static final DungeonsConfig.Livid CONFIG = SkyblockerConfigManager.get().dungeons.livid; private static Formatting color = Formatting.AQUA; private static Block lastColor = Blocks.AIR; - private static int lividID = 0; private static boolean isInitialized = false; - private static boolean originLividFound = false; + /** + * The correct livid may change color in M5, so we use the entity id to track the correct original livid. + */ + private static boolean correctLividIdFound = false; + private static int correctLividId = 0; private static final long OFFSET_DURATION = 2000; private static long toggleTime = 0; @@ -76,7 +77,7 @@ public class LividColor { isInitialized = true; } else if (isInitialized && System.currentTimeMillis() - toggleTime >= OFFSET_DURATION) { onLividColorFound(client, currentColor); - if (!originLividFound) { + if (!correctLividIdFound) { String lividName = LIVID_TO_FORMATTING.entrySet().stream() .filter(entry -> entry.getValue() == color) .map(Map.Entry::getKey) @@ -85,8 +86,8 @@ public class LividColor { client.world.getPlayers().stream() .filter(entity -> entity.getName().getString().equals(lividName)) .findFirst() - .ifPresent(entity -> lividID = entity.getId()); - originLividFound = true; + .ifPresent(entity -> correctLividId = entity.getId()); + correctLividIdFound = true; } lastColor = currentColor; } @@ -128,16 +129,16 @@ public class LividColor { return Formatting.WHITE.getColorValue(); } - public static int getLividID(){ - return lividID; + public static int getCorrectLividId() { + return correctLividId; } private static void reset() { lastColor = Blocks.AIR; toggleTime = 0; isInitialized = false; - originLividFound = false; - lividID = 0; + correctLividIdFound = false; + correctLividId = 0; color = Formatting.AQUA; } } |
