Skip to content
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

Livid Color Highlight #406

Merged
merged 6 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,10 @@ public static class DungeonChestProfit {

public static class LividColor {
@SerialEntry
public boolean enableLividColor = true;
public boolean enableLividColorGlow = true;

@SerialEntry
public boolean enableLividColorText = true;

@SerialEntry
public String lividColorText = "The livid color is [color]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,19 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.lividColor"))
.collapsed(true)
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColor"))
.description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColor.@Tooltip")))
.binding(defaults.locations.dungeons.lividColor.enableLividColor,
() -> config.locations.dungeons.lividColor.enableLividColor,
newValue -> config.locations.dungeons.lividColor.enableLividColor = newValue)
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorGlow"))
.description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorGlow.@Tooltip")))
.binding(defaults.locations.dungeons.lividColor.enableLividColorGlow,
() -> config.locations.dungeons.lividColor.enableLividColorGlow,
newValue -> config.locations.dungeons.lividColor.enableLividColorGlow = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorText"))
.description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorText.@Tooltip")))
.binding(defaults.locations.dungeons.lividColor.enableLividColorText,
() -> config.locations.dungeons.lividColor.enableLividColorText,
newValue -> config.locations.dungeons.lividColor.enableLividColorText = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<String>createBuilder()
Expand Down
18 changes: 7 additions & 11 deletions src/main/java/de/hysky/skyblocker/mixin/WorldRendererMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,21 @@
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef;

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.dungeon.StarredMobGlow;
import de.hysky.skyblocker.skyblock.dungeon.MobGlow;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.entity.Entity;

@Mixin(WorldRenderer.class)
public class WorldRendererMixin {

@ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;hasOutline(Lnet/minecraft/entity/Entity;)Z"))
private boolean skyblocker$shouldStarredMobGlow(boolean original, @Local Entity entity, @Share("isGlowingStarredMob") LocalBooleanRef isGlowingStarredMob) {
boolean isAStarredMobThatShouldGlow = SkyblockerConfigManager.get().locations.dungeons.starredMobGlow && StarredMobGlow.shouldMobGlow(entity);

isGlowingStarredMob.set(isAStarredMobThatShouldGlow);

return original || isAStarredMobThatShouldGlow;
private boolean skyblocker$shouldMobGlow(boolean original, @Local Entity entity, @Share("hasCustomGlow") LocalBooleanRef hasCustomGlow) {
boolean shouldGlow = MobGlow.shouldMobGlow(entity);
hasCustomGlow.set(shouldGlow);
return original || shouldGlow;
}

@ModifyVariable(method = "render", at = @At("STORE"), ordinal = 0)
private int skyblocker$modifyGlowColor(int color, @Local Entity entity, @Share("isGlowingStarredMob") LocalBooleanRef isGlowingStarredMob) {
return isGlowingStarredMob.get() ? StarredMobGlow.getGlowColor(entity) : color;
private int skyblocker$modifyGlowColor(int color, @Local Entity entity, @Share("hasCustomGlow") LocalBooleanRef hasCustomGlow) {
return hasCustomGlow.get() ? MobGlow.getGlowColor(entity) : color;
}
}
64 changes: 56 additions & 8 deletions src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,49 @@
package de.hysky.skyblocker.skyblock.dungeon;

import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.scheduler.MessageScheduler;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.registry.Registries;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;

import java.util.Map;

public class LividColor {
private static final Map<Block, Formatting> WOOL_TO_FORMATTING = Map.of(
Blocks.RED_WOOL, Formatting.RED,
Blocks.YELLOW_WOOL, Formatting.YELLOW,
Blocks.LIME_WOOL, Formatting.GREEN,
Blocks.GREEN_WOOL, Formatting.DARK_GREEN,
Blocks.BLUE_WOOL, Formatting.BLUE,
Blocks.MAGENTA_WOOL, Formatting.LIGHT_PURPLE,
Blocks.PURPLE_WOOL, Formatting.DARK_PURPLE,
Blocks.GRAY_WOOL, Formatting.GRAY,
Blocks.WHITE_WOOL, Formatting.WHITE
);
private static final Map<String, Formatting> LIVID_TO_FORMATTING = Map.of(
"Hockey Livid", Formatting.RED,
"Arcade Livid", Formatting.YELLOW,
"Smile Livid", Formatting.GREEN,
"Frog Livid", Formatting.DARK_GREEN,
"Scream Livid", Formatting.BLUE,
"Crossed Livid", Formatting.LIGHT_PURPLE,
"Purple Livid", Formatting.DARK_PURPLE,
"Doctor Livid", Formatting.GRAY,
"Vendetta Livid", Formatting.WHITE
);
private static int tenTicks = 0;
private static Formatting color;

public static void init() {
ClientReceiveMessageEvents.GAME.register((message, overlay) -> {
if (SkyblockerConfigManager.get().locations.dungeons.lividColor.enableLividColor && message.getString().equals("[BOSS] Livid: I respect you for making it to here, but I'll be your undoing.")) {
SkyblockerConfig.LividColor config = SkyblockerConfigManager.get().locations.dungeons.lividColor;
if ((config.enableLividColorText || config.enableLividColorGlow) && message.getString().equals("[BOSS] Livid: I respect you for making it to here, but I'll be your undoing.")) {
tenTicks = 8;
}
});
Expand All @@ -21,16 +52,15 @@ public static void init() {
public static void update() {
MinecraftClient client = MinecraftClient.getInstance();
if (tenTicks != 0) {
if (SkyblockerConfigManager.get().locations.dungeons.lividColor.enableLividColor && Utils.isInDungeons() && client.world != null) {
SkyblockerConfig.LividColor config = SkyblockerConfigManager.get().locations.dungeons.lividColor;
if ((config.enableLividColorText || config.enableLividColorGlow) && Utils.isInDungeons() && client.world != null) {
if (tenTicks == 1) {
MessageScheduler.INSTANCE.sendMessageAfterCooldown(SkyblockerConfigManager.get().locations.dungeons.lividColor.lividColorText.replace("[color]", "red"));
tenTicks = 0;
onLividColorFound(Blocks.RED_WOOL);
return;
}
String key = client.world.getBlockState(new BlockPos(5, 110, 42)).getBlock().getTranslationKey();
if (key.startsWith("block.minecraft.") && key.endsWith("wool") && !key.endsWith("red_wool")) {
MessageScheduler.INSTANCE.sendMessageAfterCooldown(SkyblockerConfigManager.get().locations.dungeons.lividColor.lividColorText.replace("[color]", key.substring(16, key.length() - 5)));
tenTicks = 0;
Block color = client.world.getBlockState(new BlockPos(5, 110, 42)).getBlock();
if (WOOL_TO_FORMATTING.containsKey(color) && !color.equals(Blocks.RED_WOOL)) {
onLividColorFound(color);
return;
}
tenTicks--;
Expand All @@ -39,4 +69,22 @@ public static void update() {
}
}
}

private static void onLividColorFound(Block color) {
LividColor.color = WOOL_TO_FORMATTING.get(color);
if (SkyblockerConfigManager.get().locations.dungeons.lividColor.enableLividColorText) {
String colorString = Registries.BLOCK.getId(color).getPath();
MessageScheduler.INSTANCE.sendMessageAfterCooldown(SkyblockerConfigManager.get().locations.dungeons.lividColor.lividColorText.replaceAll("\\[color]", colorString.substring(0, colorString.length() - 5)));
}
tenTicks = 0;
}

public static boolean shouldGlow(String name) {
return SkyblockerConfigManager.get().locations.dungeons.lividColor.enableLividColorGlow && color == LIVID_TO_FORMATTING.get(name);
}

@SuppressWarnings("DataFlowIssue")
public static int getGlowColor(String name) {
return LIVID_TO_FORMATTING.containsKey(name) ? LIVID_TO_FORMATTING.get(name).getColorValue() : Formatting.WHITE.getColorValue();
}
}
66 changes: 66 additions & 0 deletions src/main/java/de/hysky/skyblocker/skyblock/dungeon/MobGlow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package de.hysky.skyblocker.skyblock.dungeon;

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.render.culling.OcclusionCulling;
import net.minecraft.entity.Entity;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.entity.passive.BatEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.util.math.Box;
import net.minecraft.world.World;

import java.util.List;

public class MobGlow {
public static boolean shouldMobGlow(Entity entity) {
Box box = entity.getBoundingBox();

if (Utils.isInDungeons() && !entity.isInvisible() && OcclusionCulling.isVisible(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ)) {
String name = entity.getName().getString();

// Minibosses
if (entity instanceof PlayerEntity) {
switch (name) {
case "Lost Adventurer", "Shadow Assassin", "Diamond Guy": return SkyblockerConfigManager.get().locations.dungeons.starredMobGlow;
case "Arcade Livid", "Crossed Livid", "Doctor Livid", "Frog Livid", "Hockey Livid",
"Purple Livid", "Scream Livid", "Smile Livid", "Vendetta Livid": return LividColor.shouldGlow(name);
}
}

// Regular Mobs
if (!(entity instanceof ArmorStandEntity)) {
List<ArmorStandEntity> armorStands = getArmorStands(entity.getWorld(), box);

if (!armorStands.isEmpty() && armorStands.get(0).getName().getString().contains("✯")) return SkyblockerConfigManager.get().locations.dungeons.starredMobGlow;
}

// Bats
return SkyblockerConfigManager.get().locations.dungeons.starredMobGlow && entity instanceof BatEntity;
}

return false;
}

private static List<ArmorStandEntity> getArmorStands(World world, Box box) {
return world.getEntitiesByClass(ArmorStandEntity.class, box.expand(0, 2, 0), EntityPredicates.NOT_MOUNTED);
}

public static int getGlowColor(Entity entity) {
String name = entity.getName().getString();

if (entity instanceof PlayerEntity) {
return switch (name) {
case "Lost Adventurer" -> 0xfee15c;
case "Shadow Assassin" -> 0x5b2cb2;
case "Diamond Guy" -> 0x57c2f7;
case "Arcade Livid", "Crossed Livid", "Doctor Livid", "Frog Livid", "Hockey Livid",
"Purple Livid", "Scream Livid", "Smile Livid", "Vendetta Livid" -> LividColor.getGlowColor(name);
default -> 0xf57738;
};
}

return 0xf57738;
}
}

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/resources/assets/skyblocker/lang/en_ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"text.autoconfig.skyblocker.option.general.bars": "Health, Mana, Defence & XP Bars",
"text.autoconfig.skyblocker.option.locations.dungeons.croesusHelper.@Tooltip": "Grey out chests that have already been opened.",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor": "Livid Colour",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColor": "Enable Livid Colour",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColor.@Tooltip": "Send the livid colour in the chat during the Livid boss fight.",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorText": "Enable Livid Colour",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorText.@Tooltip": "Send the livid colour in the chat during the Livid boss fight.",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.lividColorText": "Livid Colour Text",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.lividColorText.@Tooltip": "Text which will be sent in the chat during the Livid boss fight. The string \"[color]\" will be replaced with the livid colour.",
"text.autoconfig.skyblocker.option.locations.dungeons.terminals.solveColor": "Solve Select Coloured",
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,10 @@
"text.autoconfig.skyblocker.option.locations.dungeons.solveTicTacToe": "Solve Tic Tac Toe Puzzle",
"text.autoconfig.skyblocker.option.locations.dungeons.solveTicTacToe.@Tooltip": "Puts a red box around the next best move for you to make!",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor": "Livid Color",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColor": "Enable Livid Color",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColor.@Tooltip": "Send the livid color in the chat during the Livid boss fight.",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorGlow": "Enable Livid Color Glow",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorGlow.@Tooltip": "Applies the glowing effect to the correct Livid in F5/M5.",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorText": "Enable Livid Color Text",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorText.@Tooltip": "Send the livid color in the chat during the Livid boss fight.",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.lividColorText": "Livid Color Text",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.lividColorText.@Tooltip": "Text which will be sent in the chat during the Livid boss fight. The string \"[color]\" will be replaced with the livid color.",
"text.autoconfig.skyblocker.option.locations.dungeons.terminals": "Terminal Solvers",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/skyblocker/lang/fr_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"text.autoconfig.skyblocker.option.locations.dungeons.mapScaling": "Taille de la Carte",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.lividColorText.@Tooltip": "Texte qui sera envoyé dans le chat lors du boss Livid. Le string \"[color]\" sera remplacé par la couleur Livid.",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor": "Couleur Livid",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColor": "Activer la Couleur Livid",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColor.@Tooltip": "Envoyer la Couler Livid dans le chat durant le boss Livid.",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorText": "Activer la Couleur Livid",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorText.@Tooltip": "Envoyer la Couler Livid dans le chat durant le boss Livid.",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.lividColorText": "Texte de la Couleur Livid",
"text.autoconfig.skyblocker.option.general.bars.barpositions.LAYER1": "Couche 1",
"text.autoconfig.skyblocker.option.general.bars.barpositions.NONE": "Désactivé",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/skyblocker/lang/pt_br.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"text.autoconfig.skyblocker.option.locations.dungeons.enableMap": "Ativar mapa",
"text.autoconfig.skyblocker.option.locations.dungeons.mapScaling": "Tamanho do mapa",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor": "Cor do Livid",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColor": "Ativar cor para Livid",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorText": "Ativar cor para Livid",
"text.autoconfig.skyblocker.option.locations.dungeons.terminals": "Guia dos terminais",
"text.autoconfig.skyblocker.option.locations.dungeons.terminals.solveColor": "Guia de seleção colorido",
"text.autoconfig.skyblocker.option.locations.dungeons.terminals.solveOrder": "Guia de clique em ordem",
Expand Down Expand Up @@ -238,5 +238,5 @@
"text.autoconfig.skyblocker.option.locations.dungeons.starredMobGlow": "Brilho em Mobs com estrela",
"text.autoconfig.skyblocker.option.locations.dungeons.starredMobGlow.@Tooltip": "Aplicar o efeito de brilho para Mobs estrelados que estão visíveis.",
"text.autoconfig.skyblocker.option.locations.dungeons.solveTicTacToe": "Guia para o Puzzle do jogo da velha",
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColor.@Tooltip": "Mandar a cor do Livid no chat durante a luta contra Livid."
"text.autoconfig.skyblocker.option.locations.dungeons.lividColor.enableLividColorText.@Tooltip": "Mandar a cor do Livid no chat durante a luta contra Livid."
}