From 8ae13f1b79030dc6ad58f96d6f813fc9d1e924a9 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Sat, 20 Jul 2024 00:32:42 -0400 Subject: [PATCH 1/4] Kuudra Glow --- .../categories/CrimsonIsleCategory.java | 8 + .../config/configs/CrimsonIsleConfig.java | 3 + .../crimson/kuudra/ArrowPoisonWarning.java | 1 - .../skyblock/crimson/kuudra/Kuudra.java | 8 +- .../skyblock/crimson/kuudra/KuudraGlow.java | 12 + .../crimson/kuudra/KuudraWaypoints.java | 261 +++++++++--------- .../skyblocker/skyblock/entity/MobGlow.java | 6 + .../assets/skyblocker/lang/en_us.json | 2 + 8 files changed, 168 insertions(+), 133 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraGlow.java diff --git a/src/main/java/de/hysky/skyblocker/config/categories/CrimsonIsleCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/CrimsonIsleCategory.java index 1e35db1ef2..441d927b9c 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/CrimsonIsleCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/CrimsonIsleCategory.java @@ -80,6 +80,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.crimsonIsle.kuudra.arrowPoisonThreshold = newValue) .controller(IntegerFieldControllerBuilder::create) .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.crimsonIsle.kuudra.kuudraGlow")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.crimsonIsle.kuudra.kuudraGlow.@Tooltip"))) + .binding(defaults.crimsonIsle.kuudra.kuudraGlow, + () -> config.crimsonIsle.kuudra.kuudraGlow, + newValue -> config.crimsonIsle.kuudra.kuudraGlow = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) .build()) //dojo .group(OptionGroup.createBuilder() diff --git a/src/main/java/de/hysky/skyblocker/config/configs/CrimsonIsleConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/CrimsonIsleConfig.java index 6645b88d27..00e0f6547c 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/CrimsonIsleConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/CrimsonIsleConfig.java @@ -38,6 +38,9 @@ public static class Kuudra { @SerialEntry public int arrowPoisonThreshold = 32; + + @SerialEntry + public boolean kuudraGlow = true; } public static class Dojo { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/ArrowPoisonWarning.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/ArrowPoisonWarning.java index 7c3c634a0b..c0d371deb4 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/ArrowPoisonWarning.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/ArrowPoisonWarning.java @@ -2,7 +2,6 @@ import java.util.function.Supplier; -import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.config.configs.CrimsonIsleConfig; import de.hysky.skyblocker.skyblock.crimson.kuudra.Kuudra.KuudraPhase; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java index 5bc98894a7..133e18c75d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java @@ -1,11 +1,8 @@ package de.hysky.skyblocker.skyblock.crimson.kuudra; import de.hysky.skyblocker.utils.Utils; -import de.hysky.skyblocker.utils.scheduler.Scheduler; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; -import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -13,11 +10,10 @@ public class Kuudra { static KuudraPhase phase = KuudraPhase.OTHER; public static void init() { - WorldRenderEvents.AFTER_TRANSLUCENT.register(KuudraWaypoints::render); - ClientLifecycleEvents.CLIENT_STARTED.register(KuudraWaypoints::load); + KuudraWaypoints.init(); + ClientPlayConnectionEvents.JOIN.register((_handler, _sender, _client) -> reset()); ClientReceiveMessageEvents.GAME.register(Kuudra::onMessage); - Scheduler.INSTANCE.scheduleCyclic(KuudraWaypoints::tick, 20); } private static void onMessage(Text text, boolean overlay) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraGlow.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraGlow.java new file mode 100644 index 0000000000..0b9b88d800 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraGlow.java @@ -0,0 +1,12 @@ +package de.hysky.skyblocker.skyblock.crimson.kuudra; + +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import net.minecraft.entity.mob.MagmaCubeEntity; + +public class KuudraGlow { + private static final int KUUDRA_SIZE = 30; + + public static boolean shouldGlow(MagmaCubeEntity magmaCube, String name) { + return SkyblockerConfigManager.get().crimsonIsle.kuudra.kuudraGlow && magmaCube.getSize() == KUUDRA_SIZE && !name.equals("jeb_"); + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraWaypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraWaypoints.java index dbf7409a79..ba2e669526 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraWaypoints.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraWaypoints.java @@ -20,10 +20,13 @@ import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.PosUtils; import de.hysky.skyblocker.utils.Utils; +import de.hysky.skyblocker.utils.scheduler.Scheduler; import de.hysky.skyblocker.utils.waypoint.Waypoint; import de.hysky.skyblocker.utils.waypoint.Waypoint.Type; import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.entity.mob.GiantEntity; @@ -33,130 +36,136 @@ import net.minecraft.util.math.MathHelper; public class KuudraWaypoints { - private static final Logger LOGGER = LogUtils.getLogger(); - private static final float[] SUPPLIES_COLOR = {255f / 255f, 0f, 0f}; - private static final float[] PEARL_COLOR = {57f / 255f, 117f / 255f, 125f / 255f}; - private static final float[] SAFE_SPOT_COLOR = {255f / 255f, 85f / 255f, 255f / 255f}; - private static final Supplier SUPPLIES_AND_FUEL_TYPE = () -> SkyblockerConfigManager.get().crimsonIsle.kuudra.suppliesAndFuelWaypointType; - private static final ObjectArrayList SAFE_SPOT_WAYPOINTS = new ObjectArrayList<>(); - private static final ObjectArrayList PEARL_WAYPOINTS = new ObjectArrayList<>(); - private static final Function>> CODEC = cc -> PosUtils.ALT_BLOCK_POS_CODEC.xmap( - pos -> new Waypoint(pos, () -> Waypoint.Type.HIGHLIGHT, cc, false), - waypoint -> waypoint.pos) - .listOf(); - - //Use non final lists and swap them out to avoid ConcurrentModificationExceptions - private static ObjectArrayList supplyWaypoints = ObjectArrayList.of(); - private static ObjectArrayList ballistaBuildWaypoints = ObjectArrayList.of(); - private static ObjectArrayList fuelWaypoints = ObjectArrayList.of(); - private static boolean loaded; - - static void load(MinecraftClient client) { - CompletableFuture safeSpots = loadWaypoints(client, Identifier.of(SkyblockerMod.NAMESPACE, "crimson/kuudra/safe_spot_waypoints.json"), SAFE_SPOT_WAYPOINTS, SAFE_SPOT_COLOR); - CompletableFuture pearls = loadWaypoints(client, Identifier.of(SkyblockerMod.NAMESPACE, "crimson/kuudra/pearl_waypoints.json"), PEARL_WAYPOINTS, PEARL_COLOR); - - CompletableFuture.allOf(safeSpots, pearls).whenComplete((_result, _throwable) -> loaded = true); - } - - private static CompletableFuture loadWaypoints(MinecraftClient client, Identifier file, ObjectArrayList list, float[] colorComponents) { - return CompletableFuture.supplyAsync(() -> { - try (BufferedReader reader = client.getResourceManager().openAsReader(file)) { - return CODEC.apply(colorComponents).parse(JsonOps.INSTANCE, getWaypoints(reader)).getOrThrow(); - } catch (Exception e) { - LOGGER.error("[Skyblocker Kuudra Waypoints] Failed to load kuudra waypoints from: {}", file, e); - - return List.of(); - } - }).thenAccept(list::addAll); - } - - private static JsonElement getWaypoints(BufferedReader reader) { - return JsonParser.parseReader(reader).getAsJsonObject().getAsJsonArray("waypoints"); - } - - static void tick() { - MinecraftClient client = MinecraftClient.getInstance(); - CrimsonIsleConfig.Kuudra config = SkyblockerConfigManager.get().crimsonIsle.kuudra; - - if (Utils.isInKuudra() && (config.supplyWaypoints || config.fuelWaypoints || config.ballistaBuildWaypoints) && client.player != null) { - Box searchBox = client.player.getBoundingBox().expand(500d); - ObjectArrayList supplies = new ObjectArrayList<>(); - ObjectArrayList fuelCells = new ObjectArrayList<>(); - - if ((config.supplyWaypoints || config.fuelWaypoints) && client.world != null) { - List giants = client.world.getEntitiesByClass(GiantEntity.class, searchBox, giant -> giant.getY() < 67); - - for (GiantEntity giant : giants) { - double yawOffset = giant.getYaw() + 115; - - double x = giant.getX() + 4.5 * Math.cos((yawOffset) * MathHelper.RADIANS_PER_DEGREE); - double y = 75; - double z = giant.getZ() + 4.5 * Math.sin((yawOffset) * MathHelper.RADIANS_PER_DEGREE); - - Waypoint waypoint = new Waypoint(BlockPos.ofFloored(x, y, z), SUPPLIES_AND_FUEL_TYPE, SUPPLIES_COLOR, false); - - if (Objects.requireNonNull(Kuudra.phase) == Kuudra.KuudraPhase.DPS) { - fuelCells.add(waypoint); - } else { - supplies.add(waypoint); - } - } - } - - ObjectArrayList ballistaBuildSpots = new ObjectArrayList<>(); - - if (config.ballistaBuildWaypoints && client.world != null) { - List armorStands = client.world.getEntitiesByClass(ArmorStandEntity.class, searchBox, ArmorStandEntity::hasCustomName); - - for (ArmorStandEntity armorStand : armorStands) { - String name = armorStand.getName().getString(); - - if (config.ballistaBuildWaypoints && name.contains("SNEAK + PUNCH")) { - ballistaBuildSpots.add(new Waypoint(armorStand.getBlockPos(), () -> Waypoint.Type.WAYPOINT, SUPPLIES_COLOR, false)); - } - } - } - - supplyWaypoints = supplies; - ballistaBuildWaypoints = ballistaBuildSpots; - fuelWaypoints = fuelCells; - } - } - - static void render(WorldRenderContext context) { - CrimsonIsleConfig.Kuudra config = SkyblockerConfigManager.get().crimsonIsle.kuudra; - - if (Utils.isInKuudra() && loaded) { - if (config.supplyWaypoints) { - for (Waypoint waypoint : supplyWaypoints) { - waypoint.render(context); - } - } - - if (config.ballistaBuildWaypoints) { - for (Waypoint waypoint : ballistaBuildWaypoints) { - waypoint.render(context); - } - } - - if (config.fuelWaypoints) { - for (Waypoint waypoint : fuelWaypoints) { - waypoint.render(context); - } - } - - if (config.safeSpotWaypoints) { - for (Waypoint waypoint : SAFE_SPOT_WAYPOINTS) { - waypoint.render(context); - } - } - - //TODO maybe have "dynamic" waypoints that draw a line to the actual spot - if (config.pearlWaypoints) { - for (Waypoint waypoint : PEARL_WAYPOINTS) { - waypoint.render(context); - } - } - } - } + private static final Logger LOGGER = LogUtils.getLogger(); + private static final float[] SUPPLIES_COLOR = {255f / 255f, 0f, 0f}; + private static final float[] PEARL_COLOR = {57f / 255f, 117f / 255f, 125f / 255f}; + private static final float[] SAFE_SPOT_COLOR = {255f / 255f, 85f / 255f, 255f / 255f}; + private static final Supplier SUPPLIES_AND_FUEL_TYPE = () -> SkyblockerConfigManager.get().crimsonIsle.kuudra.suppliesAndFuelWaypointType; + private static final ObjectArrayList SAFE_SPOT_WAYPOINTS = new ObjectArrayList<>(); + private static final ObjectArrayList PEARL_WAYPOINTS = new ObjectArrayList<>(); + private static final Function>> CODEC = cc -> PosUtils.ALT_BLOCK_POS_CODEC.xmap( + pos -> new Waypoint(pos, () -> Waypoint.Type.HIGHLIGHT, cc, false), + waypoint -> waypoint.pos) + .listOf(); + + //Use non final lists and swap them out to avoid ConcurrentModificationExceptions + private static ObjectArrayList supplyWaypoints = ObjectArrayList.of(); + private static ObjectArrayList ballistaBuildWaypoints = ObjectArrayList.of(); + private static ObjectArrayList fuelWaypoints = ObjectArrayList.of(); + private static boolean loaded; + + static void init() { + WorldRenderEvents.AFTER_TRANSLUCENT.register(KuudraWaypoints::render); + ClientLifecycleEvents.CLIENT_STARTED.register(KuudraWaypoints::load); + Scheduler.INSTANCE.scheduleCyclic(KuudraWaypoints::tick, 20); + } + + private static void load(MinecraftClient client) { + CompletableFuture safeSpots = loadWaypoints(client, Identifier.of(SkyblockerMod.NAMESPACE, "crimson/kuudra/safe_spot_waypoints.json"), SAFE_SPOT_WAYPOINTS, SAFE_SPOT_COLOR); + CompletableFuture pearls = loadWaypoints(client, Identifier.of(SkyblockerMod.NAMESPACE, "crimson/kuudra/pearl_waypoints.json"), PEARL_WAYPOINTS, PEARL_COLOR); + + CompletableFuture.allOf(safeSpots, pearls).whenComplete((_result, _throwable) -> loaded = true); + } + + private static CompletableFuture loadWaypoints(MinecraftClient client, Identifier file, ObjectArrayList list, float[] colorComponents) { + return CompletableFuture.supplyAsync(() -> { + try (BufferedReader reader = client.getResourceManager().openAsReader(file)) { + return CODEC.apply(colorComponents).parse(JsonOps.INSTANCE, getWaypoints(reader)).getOrThrow(); + } catch (Exception e) { + LOGGER.error("[Skyblocker Kuudra Waypoints] Failed to load kuudra waypoints from: {}", file, e); + + return List.of(); + } + }).thenAccept(list::addAll); + } + + private static JsonElement getWaypoints(BufferedReader reader) { + return JsonParser.parseReader(reader).getAsJsonObject().getAsJsonArray("waypoints"); + } + + private static void tick() { + MinecraftClient client = MinecraftClient.getInstance(); + CrimsonIsleConfig.Kuudra config = SkyblockerConfigManager.get().crimsonIsle.kuudra; + + if (Utils.isInKuudra() && (config.supplyWaypoints || config.fuelWaypoints || config.ballistaBuildWaypoints) && client.player != null) { + Box searchBox = client.player.getBoundingBox().expand(500d); + ObjectArrayList supplies = new ObjectArrayList<>(); + ObjectArrayList fuelCells = new ObjectArrayList<>(); + + if ((config.supplyWaypoints || config.fuelWaypoints) && client.world != null) { + List giants = client.world.getEntitiesByClass(GiantEntity.class, searchBox, giant -> giant.getY() < 67); + + for (GiantEntity giant : giants) { + double yawOffset = giant.getYaw() + 115; + + double x = giant.getX() + 4.5 * Math.cos((yawOffset) * MathHelper.RADIANS_PER_DEGREE); + double y = 75; + double z = giant.getZ() + 4.5 * Math.sin((yawOffset) * MathHelper.RADIANS_PER_DEGREE); + + Waypoint waypoint = new Waypoint(BlockPos.ofFloored(x, y, z), SUPPLIES_AND_FUEL_TYPE, SUPPLIES_COLOR, false); + + if (Objects.requireNonNull(Kuudra.phase) == Kuudra.KuudraPhase.DPS) { + fuelCells.add(waypoint); + } else { + supplies.add(waypoint); + } + } + } + + ObjectArrayList ballistaBuildSpots = new ObjectArrayList<>(); + + if (config.ballistaBuildWaypoints && client.world != null) { + List armorStands = client.world.getEntitiesByClass(ArmorStandEntity.class, searchBox, ArmorStandEntity::hasCustomName); + + for (ArmorStandEntity armorStand : armorStands) { + String name = armorStand.getName().getString(); + + if (config.ballistaBuildWaypoints && name.contains("SNEAK + PUNCH")) { + ballistaBuildSpots.add(new Waypoint(armorStand.getBlockPos(), () -> Waypoint.Type.WAYPOINT, SUPPLIES_COLOR, false)); + } + } + } + + supplyWaypoints = supplies; + ballistaBuildWaypoints = ballistaBuildSpots; + fuelWaypoints = fuelCells; + } + } + + private static void render(WorldRenderContext context) { + CrimsonIsleConfig.Kuudra config = SkyblockerConfigManager.get().crimsonIsle.kuudra; + + if (Utils.isInKuudra() && loaded) { + if (config.supplyWaypoints) { + for (Waypoint waypoint : supplyWaypoints) { + waypoint.render(context); + } + } + + if (config.ballistaBuildWaypoints) { + for (Waypoint waypoint : ballistaBuildWaypoints) { + waypoint.render(context); + } + } + + if (config.fuelWaypoints) { + for (Waypoint waypoint : fuelWaypoints) { + waypoint.render(context); + } + } + + if (config.safeSpotWaypoints) { + for (Waypoint waypoint : SAFE_SPOT_WAYPOINTS) { + waypoint.render(context); + } + } + + //TODO maybe have "dynamic" waypoints that draw a line to the actual spot + if (config.pearlWaypoints) { + for (Waypoint waypoint : PEARL_WAYPOINTS) { + waypoint.render(context); + } + } + } + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java index 0438a8ce1e..3aa62a3bab 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java @@ -3,6 +3,7 @@ import com.google.common.collect.Streams; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.crimson.dojo.DojoManager; +import de.hysky.skyblocker.skyblock.crimson.kuudra.KuudraGlow; import de.hysky.skyblocker.skyblock.dungeon.LividColor; import de.hysky.skyblocker.skyblock.end.TheEnd; import de.hysky.skyblocker.utils.ItemUtils; @@ -12,6 +13,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.entity.mob.EndermanEntity; +import net.minecraft.entity.mob.MagmaCubeEntity; import net.minecraft.entity.mob.ZombieEntity; import net.minecraft.entity.passive.BatEntity; import net.minecraft.entity.player.PlayerEntity; @@ -67,6 +69,9 @@ public static boolean shouldMobGlow(Entity entity) { //dojo case ZombieEntity zombie when Utils.isInCrimson() && DojoManager.inArena -> DojoManager.shouldGlow(getArmorStandName(zombie)); + //Kuudra + case MagmaCubeEntity magmaCube when Utils.isInKuudra() -> KuudraGlow.shouldGlow(magmaCube, name); + default -> false; }; } @@ -120,6 +125,7 @@ public static int getGlowColor(Entity entity) { case EndermanEntity enderman when TheEnd.isSpecialZealot(enderman) -> Formatting.RED.getColorValue(); case ArmorStandEntity armorStand when isNukekubiHead(armorStand) -> Formatting.GREEN.getColorValue(); case ZombieEntity zombie when Utils.isInCrimson() && DojoManager.inArena -> DojoManager.getColor(); + case MagmaCubeEntity magmaCube when Utils.isInKuudra() -> 0xf7510f; default -> 0xf57738; }; diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 129381a27d..3bf50e0cef 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -45,6 +45,8 @@ "skyblocker.config.crimsonIsle.kuudra.arrowPoisonThreshold.@Tooltip": "If the amount of Toxic Arrow Poison you have in your inventory is below the set threshold, then you will receive a warning.\n\n16 is the absolute minimum.\nYou want 32 for smooth 'DPS' phase with prefire.", "skyblocker.config.crimsonIsle.kuudra.ballistaBuildWaypoints": "Ballista Build Spot Waypoints", "skyblocker.config.crimsonIsle.kuudra.fuelWaypoints": "Fuel Waypoints", + "skyblocker.config.crimsonIsle.kuudra.kuudraGlow": "Kuudra Glow", + "skyblocker.config.crimsonIsle.kuudra.kuudraGlow.@Tooltip": "Outlines Kuudra in a deep orange.", "skyblocker.config.crimsonIsle.kuudra.noArrowPoisonWarning": "No Arrow Poison Warning", "skyblocker.config.crimsonIsle.kuudra.noArrowPoisonWarning.@Tooltip": "Warns you when you pull out a bow and have no Toxic Arrow Poison in your inventory. Only works during the DPS phase.", "skyblocker.config.crimsonIsle.kuudra.pearlWaypoints": "Pearl Waypoints", From 7a9c7efa5705e81fecf81bdd8fa5247e9b7f43d8 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Sat, 20 Jul 2024 22:13:40 -0400 Subject: [PATCH 2/4] Danger Warning --- .../categories/CrimsonIsleCategory.java | 8 +++ .../config/configs/CrimsonIsleConfig.java | 3 + .../crimson/kuudra/DangerWarning.java | 72 +++++++++++++++++++ .../skyblock/crimson/kuudra/Kuudra.java | 1 + .../skyblocker/utils/render/title/Title.java | 4 +- .../assets/skyblocker/lang/en_us.json | 3 + 6 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/DangerWarning.java diff --git a/src/main/java/de/hysky/skyblocker/config/categories/CrimsonIsleCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/CrimsonIsleCategory.java index 441d927b9c..242bfd24d4 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/CrimsonIsleCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/CrimsonIsleCategory.java @@ -88,6 +88,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.crimsonIsle.kuudra.kuudraGlow = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.crimsonIsle.kuudra.dangerWarning")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.crimsonIsle.kuudra.dangerWarning.@Tooltip"))) + .binding(defaults.crimsonIsle.kuudra.dangerWarning, + () -> config.crimsonIsle.kuudra.dangerWarning, + newValue -> config.crimsonIsle.kuudra.dangerWarning = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) .build()) //dojo .group(OptionGroup.createBuilder() diff --git a/src/main/java/de/hysky/skyblocker/config/configs/CrimsonIsleConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/CrimsonIsleConfig.java index 00e0f6547c..9c087baf00 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/CrimsonIsleConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/CrimsonIsleConfig.java @@ -41,6 +41,9 @@ public static class Kuudra { @SerialEntry public boolean kuudraGlow = true; + + @SerialEntry + public boolean dangerWarning = true; } public static class Dojo { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/DangerWarning.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/DangerWarning.java new file mode 100644 index 0000000000..91ef557679 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/DangerWarning.java @@ -0,0 +1,72 @@ +package de.hysky.skyblocker.skyblock.crimson.kuudra; + +import java.util.function.Supplier; + +import org.apache.commons.lang3.ObjectUtils; + +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.Utils; +import de.hysky.skyblocker.utils.render.RenderHelper; +import de.hysky.skyblocker.utils.render.title.Title; +import de.hysky.skyblocker.utils.render.title.TitleContainer; +import de.hysky.skyblocker.utils.scheduler.Scheduler; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.client.MinecraftClient; +import net.minecraft.text.MutableText; +import net.minecraft.text.Text; +import net.minecraft.util.DyeColor; +import net.minecraft.util.math.BlockPos; + +public class DangerWarning { + private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); + private static final Supplier DANGER_TEXT = () -> Text.translatable("skyblocker.crimson.kuudra.danger"); + private static final Title TITLE = new Title(DANGER_TEXT.get()); + + static void init() { + Scheduler.INSTANCE.scheduleCyclic(DangerWarning::updateIndicator, 5); + ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> reset()); + } + + private static void updateIndicator() { + if (Utils.isInKuudra() && SkyblockerConfigManager.get().crimsonIsle.kuudra.dangerWarning && CLIENT.player != null && CLIENT.world != null) { + BlockPos under = CLIENT.player.getBlockPos().down(); + BlockPos under2 = CLIENT.player.getBlockPos().down(2); + BlockPos under3 = CLIENT.player.getBlockPos().down(3); + BlockPos under4 = CLIENT.player.getBlockPos().down(4); + BlockPos under5 = CLIENT.player.getBlockPos().down(5); + + Title title = ObjectUtils.firstNonNull(getDangerTitle(under), getDangerTitle(under2), getDangerTitle(under3), getDangerTitle(under4), getDangerTitle(under5)); + + if (title != null) { + RenderHelper.displayInTitleContainerAndPlaySound(title); + } else { + TitleContainer.removeTitle(TITLE); + } + } + } + + private static Title getDangerTitle(BlockPos pos) { + BlockState state = CLIENT.world.getBlockState(pos); + Block block = state.getBlock(); + + int argb = switch (block) { + case Block b when b == Blocks.GREEN_TERRACOTTA -> DyeColor.GREEN.getEntityColor(); + case Block b when b == Blocks.LIME_TERRACOTTA -> DyeColor.LIME.getEntityColor(); + case Block b when b == Blocks.YELLOW_TERRACOTTA -> DyeColor.YELLOW.getEntityColor(); + case Block b when b == Blocks.ORANGE_TERRACOTTA -> DyeColor.ORANGE.getEntityColor(); + case Block b when b == Blocks.PINK_TERRACOTTA -> DyeColor.PINK.getEntityColor(); + case Block b when b == Blocks.RED_TERRACOTTA -> DyeColor.RED.getEntityColor(); + + default -> 0; + }; + + return argb != 0 ? TITLE.setText(DANGER_TEXT.get().withColor(argb & 0x00FFFFFF)) : null; + } + + private static void reset() { + TitleContainer.removeTitle(TITLE); + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java index 133e18c75d..e2b3f25691 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java @@ -11,6 +11,7 @@ public class Kuudra { public static void init() { KuudraWaypoints.init(); + DangerWarning.init(); ClientPlayConnectionEvents.JOIN.register((_handler, _sender, _client) -> reset()); ClientReceiveMessageEvents.GAME.register(Kuudra::onMessage); diff --git a/src/main/java/de/hysky/skyblocker/utils/render/title/Title.java b/src/main/java/de/hysky/skyblocker/utils/render/title/Title.java index 1e167afa01..890976aea4 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/title/Title.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/title/Title.java @@ -38,8 +38,10 @@ public MutableText getText() { return text; } - public void setText(MutableText text) { + public Title setText(MutableText text) { this.text = text; + + return this; } protected boolean isDefaultPos() { diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 3bf50e0cef..faf3c7eec6 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -44,6 +44,8 @@ "skyblocker.config.crimsonIsle.kuudra.arrowPoisonThreshold": "Arrow Poison Warning Threshold", "skyblocker.config.crimsonIsle.kuudra.arrowPoisonThreshold.@Tooltip": "If the amount of Toxic Arrow Poison you have in your inventory is below the set threshold, then you will receive a warning.\n\n16 is the absolute minimum.\nYou want 32 for smooth 'DPS' phase with prefire.", "skyblocker.config.crimsonIsle.kuudra.ballistaBuildWaypoints": "Ballista Build Spot Waypoints", + "skyblocker.config.crimsonIsle.kuudra.dangerWarning": "Danger Warning", + "skyblocker.config.crimsonIsle.kuudra.dangerWarning.@Tooltip": "Displays a warning when you're in danger from a tentacle slam or from TNT. The color of the warning adapts to the danger level!", "skyblocker.config.crimsonIsle.kuudra.fuelWaypoints": "Fuel Waypoints", "skyblocker.config.crimsonIsle.kuudra.kuudraGlow": "Kuudra Glow", "skyblocker.config.crimsonIsle.kuudra.kuudraGlow.@Tooltip": "Outlines Kuudra in a deep orange.", @@ -995,6 +997,7 @@ "skyblocker.crimson.kuudra.noArrowPoison": "No Arrow Poison!", "skyblocker.crimson.kuudra.lowArrowPoison": "Low on Arrow Poison!", + "skyblocker.crimson.kuudra.danger": "DANGER!", "skyblocker.waypoints.ordered.groupNonExistent": "§cThe waypoint group %s doesn't exist.", "skyblocker.waypoints.ordered.add.invalidHexColor": "§cInvalid HEX color code!", From bdd5cb52b123015fc0c1c9e8d4ab46968a58fda6 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Sun, 21 Jul 2024 00:10:17 -0400 Subject: [PATCH 3/4] Kuudra's Lair detection --- .../hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java index e2b3f25691..f6a25b8432 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java @@ -32,6 +32,10 @@ private static void onMessage(Text text, boolean overlay) { if (message.equals("[NPC] Elle: POW! SURELY THAT'S IT! I don't think he has any more in him!")) { phase = KuudraPhase.OTHER; } + + if (message.equals("[NPC] Elle: What just happened!? Is this Kuudra's real lair?")) { + phase = KuudraPhase.KUUDRA_LAIR; + } } } @@ -42,6 +46,7 @@ private static void reset() { enum KuudraPhase { OTHER, RETRIEVE_SUPPLIES, - DPS; + DPS, + KUUDRA_LAIR; //Infernal Only } } From 87fcbf95725a8fec8028f8d2eca61030e156ff6f Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Wed, 31 Jul 2024 15:10:52 -0400 Subject: [PATCH 4/4] Implement Mr. Cat's suggestions --- .../crimson/kuudra/DangerWarning.java | 21 ++++++++----------- .../skyblock/crimson/kuudra/Kuudra.java | 4 +++- .../skyblock/crimson/kuudra/KuudraGlow.java | 12 ----------- .../skyblocker/skyblock/entity/MobGlow.java | 4 ++-- 4 files changed, 14 insertions(+), 27 deletions(-) delete mode 100644 src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraGlow.java diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/DangerWarning.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/DangerWarning.java index 91ef557679..feaa1a111f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/DangerWarning.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/DangerWarning.java @@ -2,8 +2,6 @@ import java.util.function.Supplier; -import org.apache.commons.lang3.ObjectUtils; - import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.render.RenderHelper; @@ -32,18 +30,17 @@ static void init() { private static void updateIndicator() { if (Utils.isInKuudra() && SkyblockerConfigManager.get().crimsonIsle.kuudra.dangerWarning && CLIENT.player != null && CLIENT.world != null) { - BlockPos under = CLIENT.player.getBlockPos().down(); - BlockPos under2 = CLIENT.player.getBlockPos().down(2); - BlockPos under3 = CLIENT.player.getBlockPos().down(3); - BlockPos under4 = CLIENT.player.getBlockPos().down(4); - BlockPos under5 = CLIENT.player.getBlockPos().down(5); + for (int i = 1; i <= 5; i++) { + BlockPos under = CLIENT.player.getBlockPos().down(i); + Title title = getDangerTitle(under); - Title title = ObjectUtils.firstNonNull(getDangerTitle(under), getDangerTitle(under2), getDangerTitle(under3), getDangerTitle(under4), getDangerTitle(under5)); + if (title != null) { + RenderHelper.displayInTitleContainerAndPlaySound(title); - if (title != null) { - RenderHelper.displayInTitleContainerAndPlaySound(title); - } else { - TitleContainer.removeTitle(TITLE); + return; + } else if (i == 5) { //Prevent removing the title prematurely + TitleContainer.removeTitle(TITLE); + } } } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java index f6a25b8432..626905a538 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/Kuudra.java @@ -6,7 +6,9 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; -public class Kuudra { +public class Kuudra { + public static final int KUUDRA_MAGMA_CUBE_SIZE = 30; + static KuudraPhase phase = KuudraPhase.OTHER; public static void init() { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraGlow.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraGlow.java deleted file mode 100644 index 0b9b88d800..0000000000 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraGlow.java +++ /dev/null @@ -1,12 +0,0 @@ -package de.hysky.skyblocker.skyblock.crimson.kuudra; - -import de.hysky.skyblocker.config.SkyblockerConfigManager; -import net.minecraft.entity.mob.MagmaCubeEntity; - -public class KuudraGlow { - private static final int KUUDRA_SIZE = 30; - - public static boolean shouldGlow(MagmaCubeEntity magmaCube, String name) { - return SkyblockerConfigManager.get().crimsonIsle.kuudra.kuudraGlow && magmaCube.getSize() == KUUDRA_SIZE && !name.equals("jeb_"); - } -} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java index 3aa62a3bab..22474cf8be 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java @@ -3,7 +3,7 @@ import com.google.common.collect.Streams; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.crimson.dojo.DojoManager; -import de.hysky.skyblocker.skyblock.crimson.kuudra.KuudraGlow; +import de.hysky.skyblocker.skyblock.crimson.kuudra.Kuudra; import de.hysky.skyblocker.skyblock.dungeon.LividColor; import de.hysky.skyblocker.skyblock.end.TheEnd; import de.hysky.skyblocker.utils.ItemUtils; @@ -70,7 +70,7 @@ public static boolean shouldMobGlow(Entity entity) { case ZombieEntity zombie when Utils.isInCrimson() && DojoManager.inArena -> DojoManager.shouldGlow(getArmorStandName(zombie)); //Kuudra - case MagmaCubeEntity magmaCube when Utils.isInKuudra() -> KuudraGlow.shouldGlow(magmaCube, name); + case MagmaCubeEntity magmaCube when Utils.isInKuudra() -> SkyblockerConfigManager.get().crimsonIsle.kuudra.kuudraGlow && magmaCube.getSize() == Kuudra.KUUDRA_MAGMA_CUBE_SIZE; default -> false; };