diff options
author | Kevin <92656833+kevinthegreat1@users.noreply.github.com> | 2023-11-06 10:54:25 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-06 10:54:25 -0500 |
commit | 32aac90083bbf5a8a2a2844a3fbddf0168d564bd (patch) | |
tree | 54ff8958c96d5a18c168a64a9b5ec754485e791e /src/main/java/de/hysky/skyblocker/skyblock/dungeon | |
parent | ed1acb41e51ae96e17c3729a9617c9cad6f9b912 (diff) | |
parent | e066cf77479c374c3f2f62f44c42204d69846db0 (diff) | |
download | Skyblocker-32aac90083bbf5a8a2a2844a3fbddf0168d564bd.tar.gz Skyblocker-32aac90083bbf5a8a2a2844a3fbddf0168d564bd.tar.bz2 Skyblocker-32aac90083bbf5a8a2a2844a3fbddf0168d564bd.zip |
Merge pull request #406 from kevinthegreat1/livid-color
Livid Color Highlight
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/dungeon')
3 files changed, 122 insertions, 64 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 762a6e17..f40b7859 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java @@ -1,18 +1,49 @@ package de.hysky.skyblocker.skyblock.dungeon; +import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.scheduler.MessageScheduler; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; +import net.minecraft.registry.Registries; +import net.minecraft.util.Formatting; import net.minecraft.util.math.BlockPos; +import java.util.Map; + public class LividColor { + private static final Map<Block, Formatting> WOOL_TO_FORMATTING = Map.of( + Blocks.RED_WOOL, Formatting.RED, + Blocks.YELLOW_WOOL, Formatting.YELLOW, + Blocks.LIME_WOOL, Formatting.GREEN, + Blocks.GREEN_WOOL, Formatting.DARK_GREEN, + Blocks.BLUE_WOOL, Formatting.BLUE, + Blocks.MAGENTA_WOOL, Formatting.LIGHT_PURPLE, + Blocks.PURPLE_WOOL, Formatting.DARK_PURPLE, + Blocks.GRAY_WOOL, Formatting.GRAY, + Blocks.WHITE_WOOL, Formatting.WHITE + ); + private static final Map<String, Formatting> LIVID_TO_FORMATTING = Map.of( + "Hockey Livid", Formatting.RED, + "Arcade Livid", Formatting.YELLOW, + "Smile Livid", Formatting.GREEN, + "Frog Livid", Formatting.DARK_GREEN, + "Scream Livid", Formatting.BLUE, + "Crossed Livid", Formatting.LIGHT_PURPLE, + "Purple Livid", Formatting.DARK_PURPLE, + "Doctor Livid", Formatting.GRAY, + "Vendetta Livid", Formatting.WHITE + ); private static int tenTicks = 0; + private static Formatting color; public static void init() { ClientReceiveMessageEvents.GAME.register((message, overlay) -> { - if (SkyblockerConfigManager.get().locations.dungeons.lividColor.enableLividColor && message.getString().equals("[BOSS] Livid: I respect you for making it to here, but I'll be your undoing.")) { + SkyblockerConfig.LividColor config = SkyblockerConfigManager.get().locations.dungeons.lividColor; + if ((config.enableLividColorText || config.enableLividColorGlow) && message.getString().equals("[BOSS] Livid: I respect you for making it to here, but I'll be your undoing.")) { tenTicks = 8; } }); @@ -21,16 +52,15 @@ public class LividColor { public static void update() { MinecraftClient client = MinecraftClient.getInstance(); if (tenTicks != 0) { - if (SkyblockerConfigManager.get().locations.dungeons.lividColor.enableLividColor && Utils.isInDungeons() && client.world != null) { + SkyblockerConfig.LividColor config = SkyblockerConfigManager.get().locations.dungeons.lividColor; + if ((config.enableLividColorText || config.enableLividColorGlow) && Utils.isInDungeons() && client.world != null) { if (tenTicks == 1) { - MessageScheduler.INSTANCE.sendMessageAfterCooldown(SkyblockerConfigManager.get().locations.dungeons.lividColor.lividColorText.replace("[color]", "red")); - tenTicks = 0; + onLividColorFound(Blocks.RED_WOOL); return; } - String key = client.world.getBlockState(new BlockPos(5, 110, 42)).getBlock().getTranslationKey(); - if (key.startsWith("block.minecraft.") && key.endsWith("wool") && !key.endsWith("red_wool")) { - MessageScheduler.INSTANCE.sendMessageAfterCooldown(SkyblockerConfigManager.get().locations.dungeons.lividColor.lividColorText.replace("[color]", key.substring(16, key.length() - 5))); - tenTicks = 0; + Block color = client.world.getBlockState(new BlockPos(5, 110, 42)).getBlock(); + if (WOOL_TO_FORMATTING.containsKey(color) && !color.equals(Blocks.RED_WOOL)) { + onLividColorFound(color); return; } tenTicks--; @@ -39,4 +69,22 @@ public class LividColor { } } } + + private static void onLividColorFound(Block color) { + LividColor.color = WOOL_TO_FORMATTING.get(color); + if (SkyblockerConfigManager.get().locations.dungeons.lividColor.enableLividColorText) { + String colorString = Registries.BLOCK.getId(color).getPath(); + MessageScheduler.INSTANCE.sendMessageAfterCooldown(SkyblockerConfigManager.get().locations.dungeons.lividColor.lividColorText.replaceAll("\\[color]", colorString.substring(0, colorString.length() - 5))); + } + tenTicks = 0; + } + + public static boolean shouldGlow(String name) { + return SkyblockerConfigManager.get().locations.dungeons.lividColor.enableLividColorGlow && color == LIVID_TO_FORMATTING.get(name); + } + + @SuppressWarnings("DataFlowIssue") + public static int getGlowColor(String name) { + return LIVID_TO_FORMATTING.containsKey(name) ? LIVID_TO_FORMATTING.get(name).getColorValue() : Formatting.WHITE.getColorValue(); + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/MobGlow.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/MobGlow.java new file mode 100644 index 00000000..523b7a98 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/MobGlow.java @@ -0,0 +1,66 @@ +package de.hysky.skyblocker.skyblock.dungeon; + +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.Utils; +import de.hysky.skyblocker.utils.render.culling.OcclusionCulling; +import net.minecraft.entity.Entity; +import net.minecraft.entity.decoration.ArmorStandEntity; +import net.minecraft.entity.passive.BatEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.predicate.entity.EntityPredicates; +import net.minecraft.util.math.Box; +import net.minecraft.world.World; + +import java.util.List; + +public class MobGlow { + public static boolean shouldMobGlow(Entity entity) { + Box box = entity.getBoundingBox(); + + if (Utils.isInDungeons() && !entity.isInvisible() && OcclusionCulling.isVisible(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ)) { + String name = entity.getName().getString(); + + // Minibosses + if (entity instanceof PlayerEntity) { + switch (name) { + case "Lost Adventurer", "Shadow Assassin", "Diamond Guy": return SkyblockerConfigManager.get().locations.dungeons.starredMobGlow; + case "Arcade Livid", "Crossed Livid", "Doctor Livid", "Frog Livid", "Hockey Livid", + "Purple Livid", "Scream Livid", "Smile Livid", "Vendetta Livid": return LividColor.shouldGlow(name); + } + } + + // Regular Mobs + if (!(entity instanceof ArmorStandEntity)) { + List<ArmorStandEntity> armorStands = getArmorStands(entity.getWorld(), box); + + if (!armorStands.isEmpty() && armorStands.get(0).getName().getString().contains("✯")) return SkyblockerConfigManager.get().locations.dungeons.starredMobGlow; + } + + // Bats + return SkyblockerConfigManager.get().locations.dungeons.starredMobGlow && entity instanceof BatEntity; + } + + return false; + } + + private static List<ArmorStandEntity> getArmorStands(World world, Box box) { + return world.getEntitiesByClass(ArmorStandEntity.class, box.expand(0, 2, 0), EntityPredicates.NOT_MOUNTED); + } + + public static int getGlowColor(Entity entity) { + String name = entity.getName().getString(); + + if (entity instanceof PlayerEntity) { + return switch (name) { + case "Lost Adventurer" -> 0xfee15c; + case "Shadow Assassin" -> 0x5b2cb2; + case "Diamond Guy" -> 0x57c2f7; + case "Arcade Livid", "Crossed Livid", "Doctor Livid", "Frog Livid", "Hockey Livid", + "Purple Livid", "Scream Livid", "Smile Livid", "Vendetta Livid" -> LividColor.getGlowColor(name); + default -> 0xf57738; + }; + } + + return 0xf57738; + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/StarredMobGlow.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/StarredMobGlow.java deleted file mode 100644 index 2072017d..00000000 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/StarredMobGlow.java +++ /dev/null @@ -1,56 +0,0 @@ -package de.hysky.skyblocker.skyblock.dungeon; - -import de.hysky.skyblocker.utils.Utils; -import de.hysky.skyblocker.utils.render.culling.OcclusionCulling; -import net.minecraft.entity.Entity; -import net.minecraft.entity.decoration.ArmorStandEntity; -import net.minecraft.entity.passive.BatEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.predicate.entity.EntityPredicates; -import net.minecraft.util.math.Box; - -import java.util.List; - -public class StarredMobGlow { - - public static boolean shouldMobGlow(Entity entity) { - Box box = entity.getBoundingBox(); - - if (Utils.isInDungeons() && !entity.isInvisible() && OcclusionCulling.isVisible(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ)) { - // Minibosses - if (entity instanceof PlayerEntity) { - switch (entity.getName().getString()) { - case "Lost Adventurer", "Shadow Assassin", "Diamond Guy" -> { - return true; - } - } - } - - // Regular Mobs - if (!(entity instanceof ArmorStandEntity)) { - Box searchBox = box.expand(0, 2, 0); - List<ArmorStandEntity> armorStands = entity.getWorld().getEntitiesByClass(ArmorStandEntity.class, searchBox, EntityPredicates.NOT_MOUNTED); - - if (!armorStands.isEmpty() && armorStands.get(0).getName().getString().contains("✯")) return true; - } - - // Bats - return entity instanceof BatEntity; - } - - return false; - } - - public static int getGlowColor(Entity entity) { - if (entity instanceof PlayerEntity) { - return switch (entity.getName().getString()) { - case "Lost Adventurer" -> 0xfee15c; - case "Shadow Assassin" -> 0x5b2cb2; - case "Diamond Guy" -> 0x57c2f7; - default -> 0xf57738; - }; - } - - return 0xf57738; - } -} |