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 3 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
60 changes: 54 additions & 6 deletions src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,33 @@
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.entity.Entity;
import net.minecraft.registry.Registries;
import net.minecraft.text.Text;
import net.minecraft.text.TextColor;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;

import java.util.List;
import java.util.Map;

public class LividColor {
private static final Map<Block, Formatting> WOOL_TO_FORMATTING = Map.of(
Blocks.WHITE_WOOL, Formatting.WHITE,
Blocks.MAGENTA_WOOL, Formatting.LIGHT_PURPLE,
Blocks.RED_WOOL, Formatting.RED,
Blocks.GRAY_WOOL, Formatting.GRAY,
Blocks.GREEN_WOOL, Formatting.DARK_GREEN,
Blocks.LIME_WOOL, Formatting.GREEN,
Blocks.BLUE_WOOL, Formatting.BLUE,
Blocks.PURPLE_WOOL, Formatting.DARK_PURPLE,
Blocks.YELLOW_WOOL, Formatting.YELLOW
);
private static int tenTicks = 0;
private static Formatting color;

public static void init() {
ClientReceiveMessageEvents.GAME.register((message, overlay) -> {
Expand All @@ -23,14 +45,12 @@ public static void update() {
if (tenTicks != 0) {
if (SkyblockerConfigManager.get().locations.dungeons.lividColor.enableLividColor && 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 +59,32 @@ public static void update() {
}
}
}

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

public static boolean shouldGlow(Entity armorStand) {
kevinthegreat1 marked this conversation as resolved.
Show resolved Hide resolved
List<Text> nameTexts = armorStand.getName().getSiblings();
return !nameTexts.isEmpty() && nameTexts.get(0).getStyle().getColor() == TextColor.fromFormatting(color);
}

public static int getGlowColor(String name) {
return switch (name) {
case "Arcade Livid" -> Formatting.YELLOW.getColorValue();
case "Crossed Livid" -> Formatting.LIGHT_PURPLE.getColorValue();
case "Doctor Livid" -> Formatting.GRAY.getColorValue();
case "Frog Livid" -> Formatting.DARK_GREEN.getColorValue();
case "Hockey Livid" -> Formatting.RED.getColorValue();
case "Purple Livid" -> Formatting.DARK_PURPLE.getColorValue();
case "Scream Livid" -> Formatting.BLUE.getColorValue();
case "Smile Livid" -> Formatting.GREEN.getColorValue();
case "Vendetta Livid" -> Formatting.WHITE.getColorValue();

default -> Formatting.WHITE.getColorValue();
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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;

Expand All @@ -23,13 +24,20 @@ public static boolean shouldMobGlow(Entity entity) {
case "Lost Adventurer", "Shadow Assassin", "Diamond Guy" -> {
return true;
}
case "Arcade Livid", "Crossed Livid", "Doctor Livid", "Frog Livid", "Hockey Livid",
"Purple Livid", "Scream Livid", "Smile Livid", "Vendetta Livid" -> {
List<ArmorStandEntity> armorStands = getArmorStands(entity.getWorld(), box);

if (!armorStands.isEmpty() && LividColor.shouldGlow(armorStands.get(0))) {
return true;
}
}
}
}

// Regular Mobs
if (!(entity instanceof ArmorStandEntity)) {
Box searchBox = box.expand(0, 2, 0);
List<ArmorStandEntity> armorStands = entity.getWorld().getEntitiesByClass(ArmorStandEntity.class, searchBox, EntityPredicates.NOT_MOUNTED);
List<ArmorStandEntity> armorStands = getArmorStands(entity.getWorld(), box);

if (!armorStands.isEmpty() && armorStands.get(0).getName().getString().contains("✯")) return true;
}
Expand All @@ -41,12 +49,20 @@ public static boolean shouldMobGlow(Entity entity) {
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 (entity.getName().getString()) {
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;
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
"text.autoconfig.skyblocker.option.locations.dungeons.mapScreen": "Dungeon Map Placement Config...",
"text.autoconfig.skyblocker.option.locations.dungeons.mapScaling": "Map Scaling",
"text.autoconfig.skyblocker.option.locations.dungeons.starredMobGlow": "Starred Mob Glow",
"text.autoconfig.skyblocker.option.locations.dungeons.starredMobGlow.@Tooltip": "Applies the glowing effect to starred mobs that are visible.",
"text.autoconfig.skyblocker.option.locations.dungeons.starredMobGlow.@Tooltip": "Applies the glowing effect to starred mobs that are visible. Also applies it to the correct Livid in F5/M5.",
kevinthegreat1 marked this conversation as resolved.
Show resolved Hide resolved
"text.autoconfig.skyblocker.option.locations.dungeons.solveThreeWeirdos": "Solve Three Weirdos Puzzle",
"text.autoconfig.skyblocker.option.locations.dungeons.blazeSolver": "Solve Blaze Puzzle",
"text.autoconfig.skyblocker.option.locations.dungeons.blazeSolver.@Tooltip": "Boxes the correct blaze in green, also draws a line to and boxes the next blaze to kill in white.",
Expand Down