Skip to content

Commit

Permalink
Merge pull request #371 from AzureAaron/waypoint-rendering-customization
Browse files Browse the repository at this point in the history
Secret Waypoint Rendering Customization
  • Loading branch information
AzureAaron authored Oct 19, 2023
2 parents 38f3ec2 + 7773e42 commit 65731ff
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 14 deletions.
25 changes: 25 additions & 0 deletions src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,12 @@ public static class SecretWaypoints {

@SerialEntry
public boolean noInitSecretWaypoints = false;

@SerialEntry
public WaypointType waypointType = WaypointType.WAYPOINT;

@SerialEntry
public boolean showSecretText = true;

@SerialEntry
public boolean enableEntranceWaypoints = true;
Expand Down Expand Up @@ -603,6 +609,25 @@ public static class SecretWaypoints {
@SerialEntry
public boolean enableDefaultWaypoints = true;
}

public enum WaypointType {
WAYPOINT,
OUTLINED_WAYPOINT,
HIGHLIGHT,
OUTLINED_HIGHLIGHT,
OUTLINE;

@Override
public String toString() {
return switch (this) {
case WAYPOINT -> "Waypoint";
case OUTLINED_WAYPOINT -> "Outlined Waypoint";
case HIGHLIGHT -> "Highlight";
case OUTLINED_HIGHLIGHT -> "Outlined Highlight";
case OUTLINE -> "Outline";
};
}
}

public static class DungeonChestProfit {
@SerialEntry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.hysky.skyblocker.config.ConfigUtils;
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.SkyblockerConfig.WaypointType;
import dev.isxander.yacl3.api.ButtonOption;
import dev.isxander.yacl3.api.ConfigCategory;
import dev.isxander.yacl3.api.Option;
Expand Down Expand Up @@ -43,6 +44,21 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.controller(ConfigUtils::createBooleanController)
.flag(OptionFlag.GAME_RESTART)
.build())
.option(Option.<WaypointType>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.waypointType"))
.description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.waypointType.@Tooltip")))
.binding(defaults.locations.dungeons.secretWaypoints.waypointType,
() -> config.locations.dungeons.secretWaypoints.waypointType,
newValue -> config.locations.dungeons.secretWaypoints.waypointType = newValue)
.controller(ConfigUtils::createEnumCyclingListController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.showSecretText"))
.binding(defaults.locations.dungeons.secretWaypoints.showSecretText,
() -> config.locations.dungeons.secretWaypoints.showSecretText,
newValue -> config.locations.dungeons.secretWaypoints.showSecretText = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableEntranceWaypoints"))
.binding(defaults.locations.dungeons.secretWaypoints.enableEntranceWaypoints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ public void updateState(ClientWorld world) {
// render either in a color if not created or faintly green if created
public void render(WorldRenderContext wrc, float[] color) {
if (toDo) {
RenderHelper.renderOutline(wrc, outlineOne, color, 3);
RenderHelper.renderOutline(wrc, outlineTwo, color, 3);
RenderHelper.renderOutline(wrc, outlineOne, color, 3, false);
RenderHelper.renderOutline(wrc, outlineTwo, color, 3, false);
RenderHelper.renderLinesFromPoints(wrc, line, color, 1, 2);
} else {
RenderHelper.renderOutline(wrc, outlineOne, LIME_COLOR_COMPONENTS, 1);
RenderHelper.renderOutline(wrc, outlineTwo, LIME_COLOR_COMPONENTS, 1);
RenderHelper.renderOutline(wrc, outlineOne, LIME_COLOR_COMPONENTS, 1, false);
RenderHelper.renderOutline(wrc, outlineTwo, LIME_COLOR_COMPONENTS, 1, false);
RenderHelper.renderLinesFromPoints(wrc, line, LIME_COLOR_COMPONENTS, 0.75f, 1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ public static void blazeRenderer(WorldRenderContext wrc) {
*/
private static void renderBlazeOutline(ArmorStandEntity blaze, ArmorStandEntity nextBlaze, WorldRenderContext wrc) {
Box blazeBox = blaze.getBoundingBox().expand(0.3, 0.9, 0.3).offset(0, -1.1, 0);
RenderHelper.renderOutline(wrc, blazeBox, GREEN_COLOR_COMPONENTS, 5f);
RenderHelper.renderOutline(wrc, blazeBox, GREEN_COLOR_COMPONENTS, 5f, false);

if (nextBlaze != null && nextBlaze.isAlive() && nextBlaze != blaze) {
Box nextBlazeBox = nextBlaze.getBoundingBox().expand(0.3, 0.9, 0.3).offset(0, -1.1, 0);
RenderHelper.renderOutline(wrc, nextBlazeBox, WHITE_COLOR_COMPONENTS, 5f);
RenderHelper.renderOutline(wrc, nextBlazeBox, WHITE_COLOR_COMPONENTS, 5f, false);

Vec3d blazeCenter = blazeBox.getCenter();
Vec3d nextBlazeCenter = nextBlazeBox.getCenter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static void tick() {
private static void solutionRenderer(WorldRenderContext context) {
try {
if (SkyblockerConfigManager.get().locations.dungeons.solveTicTacToe && nextBestMoveToMake != null) {
RenderHelper.renderOutline(context, nextBestMoveToMake, RED_COLOR_COMPONENTS, 5);
RenderHelper.renderOutline(context, nextBestMoveToMake, RED_COLOR_COMPONENTS, 5, false);
}
} catch (Exception e) {
LOGGER.error("[Skyblocker Tic Tac Toe] Encountered an exception while rendering the tic tac toe solution!", e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.hysky.skyblocker.skyblock.dungeon.secrets;

import com.google.gson.JsonObject;

import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.render.RenderHelper;
Expand All @@ -11,13 +10,16 @@
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;

import java.util.List;
import java.util.function.Predicate;
import java.util.function.ToDoubleFunction;

public class SecretWaypoint {
private static final float HIGHLIGHT_ALPHA = 0.5f;
private static final float LINE_WIDTH = 5f;
static final List<String> SECRET_ITEMS = List.of("Decoy", "Defuse Kit", "Dungeon Chest Key", "Healing VIII", "Inflatable Jerry", "Spirit Leap", "Training Weights", "Trap", "Treasure Talisman");
final int secretIndex;
final Category category;
Expand Down Expand Up @@ -75,11 +77,29 @@ void setMissing() {
* Renders the secret waypoint, including a filled cube, a beacon beam, the name, and the distance from the player.
*/
void render(WorldRenderContext context) {
RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, pos, category.colorComponents, 0.5F);
Vec3d posUp = centerPos.add(0, 1, 0);
RenderHelper.renderText(context, name, posUp, true);
double distance = context.camera().getPos().distanceTo(centerPos);
RenderHelper.renderText(context, Text.literal(Math.round(distance) + "m").formatted(Formatting.YELLOW), posUp, 1, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true);
SkyblockerConfig.SecretWaypoints config = SkyblockerConfigManager.get().locations.dungeons.secretWaypoints;

switch (config.waypointType) {
case WAYPOINT -> RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, pos, category.colorComponents, HIGHLIGHT_ALPHA);
case OUTLINED_WAYPOINT -> {
RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, pos, category.colorComponents, HIGHLIGHT_ALPHA);
RenderHelper.renderOutline(context, new Box(pos), category.colorComponents, LINE_WIDTH, true);
}
case HIGHLIGHT -> RenderHelper.renderFilledThroughWalls(context, pos, category.colorComponents, HIGHLIGHT_ALPHA);
case OUTLINED_HIGHLIGHT -> {
RenderHelper.renderFilledThroughWalls(context, pos, category.colorComponents, HIGHLIGHT_ALPHA);
RenderHelper.renderOutline(context, new Box(pos), category.colorComponents, LINE_WIDTH, true);
}
//TODO In the future, shrink the box for wither essence and items so its more realistic
case OUTLINE -> RenderHelper.renderOutline(context, new Box(pos), category.colorComponents, LINE_WIDTH, true);
}

if (config.showSecretText) {
Vec3d posUp = centerPos.add(0, 1, 0);
RenderHelper.renderText(context, name, posUp, true);
double distance = context.camera().getPos().distanceTo(centerPos);
RenderHelper.renderText(context, Text.literal(Math.round(distance) + "m").formatted(Formatting.YELLOW), posUp, 1, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true);
}
}

enum Category {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static void renderBeaconBeam(WorldRenderContext context, BlockPos pos, f
* Renders the outline of a box with the specified color components and line width.
* This does not use renderer since renderer draws outline using debug lines with a fixed width.
*/
public static void renderOutline(WorldRenderContext context, Box box, float[] colorComponents, float lineWidth) {
public static void renderOutline(WorldRenderContext context, Box box, float[] colorComponents, float lineWidth, boolean throughWalls) {
if (FrustumUtils.isVisible(box)) {
MatrixStack matrices = context.matrixStack();
Vec3d camera = context.camera().getPos();
Expand All @@ -90,6 +90,7 @@ public static void renderOutline(WorldRenderContext context, Box box, float[] co
RenderSystem.lineWidth(lineWidth);
RenderSystem.disableCull();
RenderSystem.enableDepthTest();
RenderSystem.depthFunc(throughWalls ? GL11.GL_ALWAYS : GL11.GL_LEQUAL);

matrices.push();
matrices.translate(-camera.getX(), -camera.getY(), -camera.getZ());
Expand All @@ -102,6 +103,7 @@ public static void renderOutline(WorldRenderContext context, Box box, float[] co
RenderSystem.lineWidth(1f);
RenderSystem.enableCull();
RenderSystem.disableDepthTest();
RenderSystem.depthFunc(GL11.GL_LEQUAL);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@
"text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableSecretWaypoints": "Enable Dungeon Secret Waypoints",
"text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.noInitSecretWaypoints": "Do Not Initialize Secret Waypoints",
"text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.noInitSecretWaypoints.@Tooltip": "This option can save around 20 MB of ram if enabled, but Secret Waypoint will require a restart after turning off this option to work.",
"text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.waypointType": "Waypoint Type",
"text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.waypointType.@Tooltip": "Waypoint: Displays a highlight and beam.\n\nOutlined Waypoint: Displays both a waypoint and an outline.\n\nHighlight: Only displays a highlight.\n\nOutlined Highlight: Displays both a highlight and an outline.\n\nOutline: Outlines the secret in a box.",
"text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.showSecretText": "Show Secret Text",
"text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableEntranceWaypoints" : "Enable Entrance Waypoints",
"text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableSuperboomWaypoints" : "Enable Superboom Waypoints",
"text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.enableChestWaypoints" : "Enable Chest Waypoints",
Expand Down

0 comments on commit 65731ff

Please sign in to comment.