Skip to content

Fancy Dungeon Map #1239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions src/main/java/de/hysky/skyblocker/config/HudConfigScreen.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.hysky.skyblocker.config;

import de.hysky.skyblocker.utils.render.RenderHelper;
import de.hysky.skyblocker.utils.render.HudHelper;
import de.hysky.skyblocker.utils.render.gui.AbstractWidget;
import it.unimi.dsi.fastutil.ints.IntIntMutablePair;
import net.minecraft.client.gui.DrawContext;
Expand Down Expand Up @@ -84,7 +84,7 @@ public final boolean mouseDragged(double mouseX, double mouseY, int button, doub
public final boolean mouseClicked(double mouseX, double mouseY, int button) {
if (button == 0) {
for (AbstractWidget widget : widgets) {
if (RenderHelper.pointIsInArea(mouseX, mouseY, widget.getX() + getWidgetXOffset(widget), widget.getY(), widget.getX() + getWidgetXOffset(widget) + widget.getWidth(), widget.getY() + widget.getHeight())) {
if (HudHelper.pointIsInArea(mouseX, mouseY, widget.getX() + getWidgetXOffset(widget), widget.getY(), widget.getX() + getWidgetXOffset(widget) + widget.getWidth(), widget.getY() + widget.getHeight())) {
draggingWidget = widget;
mouseClickRelativeX = mouseX - widget.getX() - getWidgetXOffset(widget);
mouseClickRelativeY = mouseY - widget.getY();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import de.hysky.skyblocker.utils.waypoint.Waypoint.Type;
import dev.isxander.yacl3.api.*;
import dev.isxander.yacl3.api.controller.FloatFieldControllerBuilder;
import dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder;
import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder;
import dev.isxander.yacl3.api.controller.StringControllerBuilder;
import net.minecraft.client.MinecraftClient;
Expand Down Expand Up @@ -59,14 +60,6 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.dungeons.classBasedPlayerGlow = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.spiritLeapOverlay"))
.description(OptionDescription.of(Text.translatable("skyblocker.config.dungeons.spiritLeapOverlay.@Tooltip")))
.binding(defaults.dungeons.spiritLeapOverlay,
() -> config.dungeons.spiritLeapOverlay,
newValue -> config.dungeons.spiritLeapOverlay = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.starredMobGlow"))
.description(OptionDescription.of(Text.translatable("skyblocker.config.dungeons.starredMobGlow.@Tooltip")))
Expand Down Expand Up @@ -111,6 +104,20 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.dungeons.dungeonMap.enableMap = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.map.fancyMap"))
.binding(defaults.dungeons.dungeonMap.fancyMap,
() -> config.dungeons.dungeonMap.fancyMap,
newValue -> config.dungeons.dungeonMap.fancyMap = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.map.showSelfHead"))
.binding(defaults.dungeons.dungeonMap.showSelfHead,
() -> config.dungeons.dungeonMap.showSelfHead,
newValue -> config.dungeons.dungeonMap.showSelfHead = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Float>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.map.mapScaling"))
.binding(defaults.dungeons.dungeonMap.mapScaling,
Expand All @@ -125,6 +132,34 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.build())
.build())

// Spirit Leap Overlay
.group(OptionGroup.createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.spiritLeapOverlay"))
.collapsed(true)
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.spiritLeapOverlay.enableLeapOverlay"))
.description(OptionDescription.of(Text.translatable("skyblocker.config.dungeons.spiritLeapOverlay.enableLeapOverlay.@Tooltip")))
.binding(defaults.dungeons.spiritLeapOverlay.enableLeapOverlay,
() -> config.dungeons.spiritLeapOverlay.enableLeapOverlay,
newValue -> config.dungeons.spiritLeapOverlay.enableLeapOverlay = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.spiritLeapOverlay.showMap"))
.binding(defaults.dungeons.spiritLeapOverlay.showMap,
() -> config.dungeons.spiritLeapOverlay.showMap,
newValue -> config.dungeons.spiritLeapOverlay.showMap = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Float>createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.spiritLeapOverlay.scale"))
.binding(defaults.dungeons.spiritLeapOverlay.scale,
() -> config.dungeons.spiritLeapOverlay.scale,
newValue -> config.dungeons.spiritLeapOverlay.scale = newValue)
.controller(opt -> FloatSliderControllerBuilder.create(opt).range(1f, 2f).step(0.05f).formatValue(ConfigUtils.FLOAT_TWO_FORMATTER))
.build())
.build())

// Puzzle Solver
.group(OptionGroup.createBuilder()
.name(Text.translatable("skyblocker.config.dungeons.puzzle"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public class DungeonsConfig {
@SerialEntry
public boolean classBasedPlayerGlow = true;

@SerialEntry
public boolean spiritLeapOverlay = true;

@SerialEntry
public boolean starredMobGlow = false;

Expand All @@ -39,6 +36,9 @@ public class DungeonsConfig {
@SerialEntry
public DungeonMap dungeonMap = new DungeonMap();

@SerialEntry
public SpiritLeapOverlay spiritLeapOverlay = new SpiritLeapOverlay();

@SerialEntry
public PuzzleSolvers puzzleSolvers = new PuzzleSolvers();

Expand Down Expand Up @@ -76,6 +76,12 @@ public static class DungeonMap {
@SerialEntry
public boolean enableMap = true;

@SerialEntry
public boolean fancyMap = true;

@SerialEntry
public boolean showSelfHead = true;

@SerialEntry
public float mapScaling = 1f;

Expand All @@ -86,6 +92,17 @@ public static class DungeonMap {
public int mapY = 2;
}

public static class SpiritLeapOverlay {
@SerialEntry
public boolean enableLeapOverlay = true;

@SerialEntry
public boolean showMap = true;

@SerialEntry
public float scale = 1.2f;
}

public static class PuzzleSolvers {
@SerialEntry
public boolean solveTicTacToe = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public static class ItemInfoDisplay {
public RarityBackgroundStyle itemRarityBackgroundStyle = RarityBackgroundStyle.SQUARE;

@SerialEntry
public float itemRarityBackgroundsOpacity = 1f;
public float itemRarityBackgroundsOpacity = 0.5f;
}

public enum RarityBackgroundStyle {
Expand Down
37 changes: 26 additions & 11 deletions src/main/java/de/hysky/skyblocker/events/DungeonEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@
import net.fabricmc.fabric.api.event.EventFactory;

public class DungeonEvents {
/**
* Called when the player loads into a dungeon after the location is sent to the scoreboard.
*/
public static final Event<DungeonLoaded> DUNGEON_LOADED = EventFactory.createArrayBacked(DungeonLoaded.class, callbacks -> () -> {
for (DungeonLoaded callback : callbacks) {
callback.onDungeonLoaded();
}
});

/**
* Called after the dungeons starts and after the tab has changed to include additional information about the run such as each player's class.
*/
public static final Event<DungeonStarted> DUNGEON_STARTED = EventFactory.createArrayBacked(DungeonStarted.class, callbacks -> () -> {
for (DungeonStarted callback : callbacks) {
callback.onDungeonStarted();
}
});

public static final Event<RoomMatched> PUZZLE_MATCHED = EventFactory.createArrayBacked(RoomMatched.class, callbacks -> room -> {
for (RoomMatched callback : callbacks) {
callback.onRoomMatched(room);
Expand All @@ -22,24 +40,21 @@ public class DungeonEvents {
}
});

/**
* Note: This event fires after the tab has changed to include additional information about the run such as each player's class.
*/
public static final Event<DungeonStarted> DUNGEON_STARTED = EventFactory.createArrayBacked(DungeonStarted.class, callbacks -> () -> {
for (DungeonStarted callback : callbacks) {
callback.onDungeonStarted();
}
});

@Environment(EnvType.CLIENT)
@FunctionalInterface
public interface RoomMatched {
void onRoomMatched(Room room);
public interface DungeonLoaded {
void onDungeonLoaded();
}

@Environment(EnvType.CLIENT)
@FunctionalInterface
public interface DungeonStarted {
void onDungeonStarted();
}

@Environment(EnvType.CLIENT)
@FunctionalInterface
public interface RoomMatched {
void onRoomMatched(Room room);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public interface HandledScreenProviderMixin<T extends ScreenHandler> {
}

// Leap Overlay
case GenericContainerScreenHandler containerScreenHandler when Utils.isInDungeons() && SkyblockerConfigManager.get().dungeons.spiritLeapOverlay && nameLowercase.contains(LeapOverlay.TITLE.toLowerCase()) -> {
case GenericContainerScreenHandler containerScreenHandler when Utils.isInDungeons() && SkyblockerConfigManager.get().dungeons.spiritLeapOverlay.enableLeapOverlay && nameLowercase.contains(LeapOverlay.TITLE.toLowerCase()) -> {
client.player.currentScreenHandler = containerScreenHandler;
client.setScreen(new LeapOverlay(containerScreenHandler));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package de.hysky.skyblocker.mixins.accessors;

import net.minecraft.item.map.MapDecoration;
import net.minecraft.item.map.MapState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import java.util.Map;

@Mixin(MapState.class)
public interface MapStateAccessor {
@Accessor
Map<String, MapDecoration> getDecorations();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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 net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
Expand Down Expand Up @@ -70,7 +71,7 @@ public static void onSound(PlaySoundS2CPacket packet) {
if (player != null && player.fishHook != null) {
Vec3d soundToFishHook = player.fishHook.getPos().subtract(packet.getX(), 0, packet.getZ());
if (Math.abs(normalYawVector.x * soundToFishHook.z - normalYawVector.z * soundToFishHook.x) < 0.2D && Math.abs(normalYawVector.dotProduct(soundToFishHook)) < 4D && player.squaredDistanceTo(packet.getX(), packet.getY(), packet.getZ()) > 1D) {
RenderHelper.displayInTitleContainerAndPlaySound(title, 10);
TitleContainer.addTitleAndPlaySound(title, 10);
resetFish();
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import de.hysky.skyblocker.skyblock.crimson.kuudra.Kuudra.KuudraPhase;
import de.hysky.skyblocker.utils.ItemUtils;
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 net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.BowItem;
Expand Down Expand Up @@ -44,9 +44,9 @@ public static void tryWarn(int newSlot) {
}

if (!hasToxicArrowPoison) {
RenderHelper.displayInTitleContainerAndPlaySound(NONE_TITLE, THREE_SECONDS);
TitleContainer.addTitleAndPlaySound(NONE_TITLE, THREE_SECONDS);
} else if (arrowPoisonAmount < CONFIG.get().arrowPoisonThreshold) {
RenderHelper.displayInTitleContainerAndPlaySound(LOW_TITLE, THREE_SECONDS);
TitleContainer.addTitleAndPlaySound(LOW_TITLE, THREE_SECONDS);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import de.hysky.skyblocker.annotations.Init;
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;
Expand Down Expand Up @@ -37,7 +36,7 @@ private static void updateIndicator() {
Title title = getDangerTitle(under);

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

return;
} else if (i == 5) { //Prevent removing the title prematurely
Expand Down
Loading
Loading