Skip to content

Commit

Permalink
Merge pull request #873 from AzureAaron/kuudra-part-2
Browse files Browse the repository at this point in the history
Kuudra Part 2
  • Loading branch information
AzureAaron authored Aug 3, 2024
2 parents aa72b77 + 87fcbf9 commit c160dac
Show file tree
Hide file tree
Showing 9 changed files with 252 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.crimsonIsle.kuudra.arrowPoisonThreshold = newValue)
.controller(IntegerFieldControllerBuilder::create)
.build())
.option(Option.<Boolean>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())
.option(Option.<Boolean>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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public static class Kuudra {

@SerialEntry
public int arrowPoisonThreshold = 32;

@SerialEntry
public boolean kuudraGlow = true;

@SerialEntry
public boolean dangerWarning = true;
}

public static class Dojo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package de.hysky.skyblocker.skyblock.crimson.kuudra;

import java.util.function.Supplier;

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<MutableText> 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) {
for (int i = 1; i <= 5; i++) {
BlockPos under = CLIENT.player.getBlockPos().down(i);
Title title = getDangerTitle(under);

if (title != null) {
RenderHelper.displayInTitleContainerAndPlaySound(title);

return;
} else if (i == 5) { //Prevent removing the title prematurely
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);
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
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;

public class Kuudra {
public class Kuudra {
public static final int KUUDRA_MAGMA_CUBE_SIZE = 30;

static KuudraPhase phase = KuudraPhase.OTHER;

public static void init() {
WorldRenderEvents.AFTER_TRANSLUCENT.register(KuudraWaypoints::render);
ClientLifecycleEvents.CLIENT_STARTED.register(KuudraWaypoints::load);
KuudraWaypoints.init();
DangerWarning.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) {
Expand All @@ -35,6 +34,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;
}
}
}

Expand All @@ -45,6 +48,7 @@ private static void reset() {
enum KuudraPhase {
OTHER,
RETRIEVE_SUPPLIES,
DPS;
DPS,
KUUDRA_LAIR; //Infernal Only
}
}
Loading

0 comments on commit c160dac

Please sign in to comment.