From 4acac061ce6274ecbf57564ac3b8f9fdc4582e4f Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 4 Nov 2023 11:02:00 -0400 Subject: Refactor MobGlow --- .../skyblocker/skyblock/dungeon/LividColor.java | 63 +++++++++------------ .../hysky/skyblocker/skyblock/dungeon/MobGlow.java | 66 ++++++++++++++++++++++ .../skyblock/dungeon/StarredMobGlow.java | 66 ---------------------- 3 files changed, 94 insertions(+), 101 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/dungeon/MobGlow.java delete mode 100644 src/main/java/de/hysky/skyblocker/skyblock/dungeon/StarredMobGlow.java (limited to 'src/main/java/de/hysky/skyblocker/skyblock') 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 0c774fac..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,5 +1,6 @@ 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; @@ -15,22 +16,34 @@ import java.util.Map; public class LividColor { private static final Map WOOL_TO_FORMATTING = Map.of( - Blocks.WHITE_WOOL, Formatting.WHITE, - Blocks.MAGENTA_WOOL, Formatting.LIGHT_PURPLE, Blocks.RED_WOOL, Formatting.RED, - Blocks.GRAY_WOOL, Formatting.GRAY, - Blocks.GREEN_WOOL, Formatting.DARK_GREEN, + 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.YELLOW_WOOL, Formatting.YELLOW + Blocks.GRAY_WOOL, Formatting.GRAY, + Blocks.WHITE_WOOL, Formatting.WHITE + ); + private static final Map 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; } }); @@ -39,7 +52,8 @@ 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) { onLividColorFound(Blocks.RED_WOOL); return; @@ -58,40 +72,19 @@ public class LividColor { private static void onLividColorFound(Block color) { LividColor.color = WOOL_TO_FORMATTING.get(color); - String colorString = Registries.BLOCK.getId(color).getPath(); - MessageScheduler.INSTANCE.sendMessageAfterCooldown(SkyblockerConfigManager.get().locations.dungeons.lividColor.lividColorText.replace("[color]", colorString.substring(0, colorString.length() - 5))); + 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 switch (name) { - case "Arcade Livid" -> color == Formatting.YELLOW; - case "Crossed Livid" -> color == Formatting.LIGHT_PURPLE; - case "Doctor Livid" -> color == Formatting.GRAY; - case "Frog Livid" -> color == Formatting.DARK_GREEN; - case "Hockey Livid" -> color == Formatting.RED; - case "Purple Livid" -> color == Formatting.DARK_PURPLE; - case "Scream Livid" -> color == Formatting.BLUE; - case "Smile Livid" -> color == Formatting.GREEN; - case "Vendetta Livid" -> color == Formatting.WHITE; - - default -> false; - }; + return SkyblockerConfigManager.get().locations.dungeons.lividColor.enableLividColorGlow && color == LIVID_TO_FORMATTING.get(name); } + @SuppressWarnings("DataFlowIssue") public static int getGlowColor(String name) { - return switch (name) { - case "Arcade Livid" -> Formatting.YELLOW.getColorValue(); - case "Crossed Livid" -> Formatting.LIGHT_PURPLE.getColorValue(); - case "Doctor Livid" -> Formatting.GRAY.getColorValue(); - case "Frog Livid" -> Formatting.DARK_GREEN.getColorValue(); - case "Hockey Livid" -> Formatting.RED.getColorValue(); - case "Purple Livid" -> Formatting.DARK_PURPLE.getColorValue(); - case "Scream Livid" -> Formatting.BLUE.getColorValue(); - case "Smile Livid" -> Formatting.GREEN.getColorValue(); - case "Vendetta Livid" -> Formatting.WHITE.getColorValue(); - - default -> Formatting.WHITE.getColorValue(); - }; + 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 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 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 4529797c..00000000 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/StarredMobGlow.java +++ /dev/null @@ -1,66 +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 net.minecraft.world.World; - -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)) { - String name = entity.getName().getString(); - - // Minibosses - if (entity instanceof PlayerEntity) { - switch (name) { - case "Lost Adventurer", "Shadow Assassin", "Diamond Guy": return true; - 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 armorStands = getArmorStands(entity.getWorld(), box); - - if (!armorStands.isEmpty() && armorStands.get(0).getName().getString().contains("✯")) return true; - } - - // Bats - return entity instanceof BatEntity; - } - - return false; - } - - private static List 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; - } -} -- cgit