Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/main/java/de/hysky/skyblocker/SkyblockerScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.hysky.skyblocker.annotations.Init;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.Tips;
import de.hysky.skyblocker.utils.FunUtils;
import de.hysky.skyblocker.utils.scheduler.Scheduler;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
Expand All @@ -19,8 +20,6 @@
import net.minecraft.util.Identifier;
import net.minecraft.util.Language;

import java.time.LocalDate;

public class SkyblockerScreen extends Screen {
private static final int SPACING = 8;
private static final int BUTTON_WIDTH = 210;
Expand All @@ -38,9 +37,7 @@ public class SkyblockerScreen extends Screen {
private MultilineTextWidget tip;

static {
LocalDate date = LocalDate.now();

if (date.getMonthValue() == 4 && date.getDayOfMonth() == 1) {
if (FunUtils.shouldEnableFun()) {
TITLE = Text.literal("Skibidiblocker " + SkyblockerMod.VERSION);
ICON = SkyblockerMod.id("icons.png");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,63 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.build())
.build())

// F7/M7 Terminal Hud
.group(OptionGroup.createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.terminalHud"))
.collapsed(true)
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.terminalHud.enabled"))
.binding(defaults.dungeons.terminalHud.enableTerminalHud,
() -> config.dungeons.terminalHud.enableTerminalHud,
newValue -> config.dungeons.terminalHud.enableTerminalHud = newValue)
.controller(ConfigUtils.createBooleanController())
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.terminalHud.showTerminalStatus"))
.description(Text.translatable("skyblocker.config.dungeons.terminalHud.showTerminalStatus.@Tooltip"))
.binding(defaults.dungeons.terminalHud.showTerminalStatus,
() -> config.dungeons.terminalHud.showTerminalStatus,
newValue -> config.dungeons.terminalHud.showTerminalStatus = newValue)
.controller(ConfigUtils.createBooleanController())
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.terminalHud.determineInProgressStatus"))
.description(Text.translatable("skyblocker.config.dungeons.terminalHud.determineInProgressStatus.@Tooltip"))
.binding(defaults.dungeons.terminalHud.showPlayerAtTerminal,
() -> config.dungeons.terminalHud.showPlayerAtTerminal,
newValue -> config.dungeons.terminalHud.showPlayerAtTerminal = newValue)
.controller(ConfigUtils.createBooleanController())
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.terminalHud.showTerminals"))
.binding(defaults.dungeons.terminalHud.showTerminals,
() -> config.dungeons.terminalHud.showTerminals,
newValue -> config.dungeons.terminalHud.showTerminals = newValue)
.controller(ConfigUtils.createBooleanController())
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.terminalHud.showDevice"))
.binding(defaults.dungeons.terminalHud.showDevice,
() -> config.dungeons.terminalHud.showDevice,
newValue -> config.dungeons.terminalHud.showDevice = newValue)
.controller(ConfigUtils.createBooleanController())
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.terminalHud.showLevers"))
.binding(defaults.dungeons.terminalHud.showLevers,
() -> config.dungeons.terminalHud.showLevers,
newValue -> config.dungeons.terminalHud.showLevers = newValue)
.controller(ConfigUtils.createBooleanController())
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.terminalHud.showGate"))
.binding(defaults.dungeons.terminalHud.showGate,
() -> config.dungeons.terminalHud.showGate,
newValue -> config.dungeons.terminalHud.showGate = newValue)
.controller(ConfigUtils.createBooleanController())
.build())
.build())

// Dungeon Secret Waypoints
.group(OptionGroup.createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.secretWaypoints"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class DungeonsConfig {

public Goldor goldor = new Goldor();

public TerminalHud terminalHud = new TerminalHud();

public SecretWaypoints secretWaypoints = new SecretWaypoints();

public MimicMessage mimicMessage = new MimicMessage();
Expand Down Expand Up @@ -172,6 +174,23 @@ public static class Goldor {
public Waypoint.Type waypointType = Waypoint.Type.WAYPOINT;
}

public static class TerminalHud {
public boolean enableTerminalHud = false;

public boolean showTerminalStatus = true;

public boolean showPlayerAtTerminal = true;

public boolean showTerminals = true;

public boolean showDevice = true;

public boolean showLevers = true;

public boolean showGate = true;
}


public static class SecretWaypoints {
@Deprecated
public transient boolean enableRoomMatching = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,23 @@ public class GoldorWaypointsManager {
private static final ObjectArrayList<GoldorWaypoint> DEVICES = new ObjectArrayList<>();
private static final ObjectArrayList<GoldorWaypoint> LEVERS = new ObjectArrayList<>();

private static final ObjectArrayList<GoldorWaypoint> ACTIVE_PHASE_WAYPOINTS = new ObjectArrayList<>();

private static final String TERMINALS_START = "[BOSS] Storm: I should have known that I stood no chance.";
private static final Pattern TERMINAL_ACTIVATED = Pattern.compile("^(?<name>\\w+) activated a terminal! \\(\\d/\\d\\)$");
private static final Pattern DEVICE_ACTIVATED = Pattern.compile("^(?<name>\\w+) completed a device! \\(\\d/\\d\\)$");
private static final Pattern LEVER_ACTIVATED = Pattern.compile("^(?<name>\\w+) activated a lever! \\(\\d/\\d\\)$");
private static final Pattern PHASE_COMPLETE = Pattern.compile("^(?<name>\\w+) (?:activated a (?:terminal|lever)|completed a device)! (?:\\(7/7\\)|\\(8/8\\))$");
private static final String GATE_DESTROYED = "The gate has been destroyed!";
private static final String CORE_ENTRANCE = "The Core entrance is opening!";
private static final Codec<List<GoldorWaypoint>> CODEC = GoldorWaypoint.CODEC.listOf();

// If the waypoints are loaded
private static boolean loaded = false;
// If this should be processed
private static boolean active = false;
// If the current phase's gate is destroyed
private static boolean gateDestroyed = false;
// The current set of terminals, each phase is delimited by a gate
private static short currentPhase = 0;

Expand Down Expand Up @@ -101,8 +106,9 @@ private static CompletableFuture<Void> loadWaypoints(MinecraftClient client, Ide
*
* @return true if we should process messages
*/
private static boolean shouldProcessMsgs() {
return (loaded && SkyblockerConfigManager.get().dungeons.goldor.enableGoldorWaypoints && Utils.isInDungeons() && DungeonManager.isInBoss() && DungeonManager.getBoss().isFloor(7));
private static boolean shouldProcess() {
if (!loaded || !Utils.isInDungeons() || !DungeonManager.isInBoss() || !DungeonManager.getBoss().isFloor(7)) return false;
return SkyblockerConfigManager.get().dungeons.goldor.enableGoldorWaypoints || SkyblockerConfigManager.get().dungeons.terminalHud.enableTerminalHud;
}

/**
Expand All @@ -120,17 +126,20 @@ private static void removeNearestWaypoint(List<GoldorWaypoint> waypoints, String

// Find the nearest waypoint to the player and hide it
posOptional.flatMap(pos -> waypoints.stream().filter(GoldorWaypoint::shouldRender).min(Comparator.comparingDouble(waypoint -> waypoint.centerPos.squaredDistanceTo(pos)))).ifPresent(Waypoint::setFound);
TerminalHud.INSTANCE.update();
}

/**
* Resets state, disabling waypoint rendering (but setting all waypoints to be ready for the next run)
*/
private static void reset() {
active = false;
gateDestroyed = false;
currentPhase = 0;
enableAll(TERMINALS);
enableAll(DEVICES);
enableAll(LEVERS);
ACTIVE_PHASE_WAYPOINTS.clear();
}

/**
Expand All @@ -153,13 +162,17 @@ private static String getPlayerName(Matcher matcher) {
return matcher.matches() ? matcher.group("name") : null;
}

@SuppressWarnings("SameReturnValue")
private static boolean onChatMessage(Text text, boolean overlay) {
if (overlay || !shouldProcessMsgs()) return true;
if (overlay || !shouldProcess()) return true;
String message = text.getString();

if (active) {
if (PHASE_COMPLETE.matcher(message).matches()) {
currentPhase++;
gateDestroyed = false;
setPhaseWaypoints();
TerminalHud.INSTANCE.update();
} else {
String playerName;

Expand All @@ -171,37 +184,60 @@ private static boolean onChatMessage(Text text, boolean overlay) {
removeNearestWaypoint(LEVERS, playerName);
} else if (message.equals(CORE_ENTRANCE)) {
active = false;
ACTIVE_PHASE_WAYPOINTS.clear();
} else if (message.equals(GATE_DESTROYED)) {
gateDestroyed = true;
TerminalHud.INSTANCE.update();
}
}
} else {
if (message.equals(TERMINALS_START)) {
enableAll(TERMINALS);
enableAll(DEVICES);
enableAll(LEVERS);
active = true;
}
} else if (message.equals(TERMINALS_START)) {
reset();
setPhaseWaypoints();
active = true;
TerminalHud.INSTANCE.update();
}

return true;
}

private static void setPhaseWaypoints() {
ACTIVE_PHASE_WAYPOINTS.clear();
ACTIVE_PHASE_WAYPOINTS.addAll(TERMINALS.stream().filter(waypoint -> waypoint.phase == currentPhase).toList());
ACTIVE_PHASE_WAYPOINTS.addAll(DEVICES.stream().filter(waypoint -> waypoint.phase == currentPhase).toList());
ACTIVE_PHASE_WAYPOINTS.addAll(LEVERS.stream().filter(waypoint -> waypoint.phase == currentPhase).toList());
}

private static void extractRenderingForWaypoints(PrimitiveCollector collector, ObjectArrayList<GoldorWaypoint> waypoints) {
for (GoldorWaypoint waypoint : waypoints) {
if (waypoint.phase == currentPhase && waypoint.shouldRender()) {
if (waypoint.shouldRender()) {
waypoint.extractRendering(collector);
}
}
}

private static void extractRendering(PrimitiveCollector collector) {
if (active) {
extractRenderingForWaypoints(collector, TERMINALS);
extractRenderingForWaypoints(collector, DEVICES);
extractRenderingForWaypoints(collector, LEVERS);
if (active && SkyblockerConfigManager.get().dungeons.goldor.enableGoldorWaypoints) {
extractRenderingForWaypoints(collector, ACTIVE_PHASE_WAYPOINTS);
}
}

private static class GoldorWaypoint extends NamedWaypoint {
public static boolean isActive() {
return active;
}

public static boolean isGateDestroyed() {
return gateDestroyed;
}

public static short getCurrentPhase() {
return currentPhase;
}

public static List<GoldorWaypoint> getPhaseWaypoints() {
return ACTIVE_PHASE_WAYPOINTS;
}

public static class GoldorWaypoint extends NamedWaypoint {
public static final Codec<GoldorWaypoint> CODEC = RecordCodecBuilder.create(i -> i.group(
WaypointTargetKind.CODEC.fieldOf("kind").forGetter(w -> w.kind),
Codec.INT.fieldOf("phase").forGetter(customWaypoint -> customWaypoint.phase),
Expand Down
Loading