From 6eed0d48eeaa054392efe19dffaef691701c1356 Mon Sep 17 00:00:00 2001 From: bowser0000 Date: Sun, 11 Jul 2021 17:18:07 -0400 Subject: Add custom colours to nametags Also fix Spider's Den detection and fix copy paste error in /toggle --- .../java/me/Danker/commands/ToggleCommand.java | 2 +- src/main/java/me/Danker/features/ArachneESP.java | 2 +- .../java/me/Danker/features/ColouredNames.java | 27 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java index 3770d8f..95c4d98 100644 --- a/src/main/java/me/Danker/commands/ToggleCommand.java +++ b/src/main/java/me/Danker/commands/ToggleCommand.java @@ -293,7 +293,7 @@ public class ToggleCommand extends CommandBase implements ICommand { case "bonzotimer": bonzoTimerToggled = !bonzoTimerToggled; ConfigHandler.writeBooleanConfig("toggles", "BonzoTimer", bonzoTimerToggled); - player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Bonzo's Mask timer has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + necronNotificationsToggled + DankersSkyblockMod.MAIN_COLOUR + ".")); + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Bonzo's Mask timer has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + bonzoTimerToggled + DankersSkyblockMod.MAIN_COLOUR + ".")); break; case "autoskilltracker": autoSkillTrackerToggled = !autoSkillTrackerToggled; diff --git a/src/main/java/me/Danker/features/ArachneESP.java b/src/main/java/me/Danker/features/ArachneESP.java index c78c385..7e39a8f 100644 --- a/src/main/java/me/Danker/features/ArachneESP.java +++ b/src/main/java/me/Danker/features/ArachneESP.java @@ -32,7 +32,7 @@ public class ArachneESP { public boolean inSpidersDen(List scoreboard) { for (String s : scoreboard) { - if (ScoreboardHandler.cleanSB(s).contains("Spiders Den")) { + if (ScoreboardHandler.cleanSB(s).contains("Spider's Den")) { return true; } } diff --git a/src/main/java/me/Danker/features/ColouredNames.java b/src/main/java/me/Danker/features/ColouredNames.java index 478a47d..2156f3a 100644 --- a/src/main/java/me/Danker/features/ColouredNames.java +++ b/src/main/java/me/Danker/features/ColouredNames.java @@ -3,11 +3,15 @@ package me.Danker.features; import me.Danker.DankersSkyblockMod; import me.Danker.commands.ToggleCommand; import me.Danker.utils.Utils; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IChatComponent; import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.util.ArrayList; @@ -43,6 +47,29 @@ public class ColouredNames { } } + @SubscribeEvent + public void onRenderNametag(PlayerEvent.NameFormat event) { + if (!ToggleCommand.customColouredNames || !Utils.inSkyblock) return; + + if (users.contains(event.username)) { + event.displayname = replaceName(event.displayname, event.username, getColourFromName(event.username)); + } + } + + @SubscribeEvent + public void onRenderLiving(RenderLivingEvent.Specials.Pre event) { + if (!ToggleCommand.customColouredNames || !Utils.inSkyblock) return; + + Entity entity = event.entity; + if (entity.hasCustomName()) { + for (String user : users) { + if (entity.getCustomNameTag().contains(user)) { + entity.setCustomNameTag(replaceName(entity.getCustomNameTag(), user, getColourFromName(user))); + } + } + } + } + // https://github.com/SteveKunG/SkyBlockcatia/blob/1.8.9/src/main/java/com/stevekung/skyblockcatia/utils/SupporterUtils.java#L53 public static String replaceName(String text, String name, String colour) { String namePattern = "(?:(?:\\u00a7[0-9a-fbr])\\B(?:" + name + ")\\b)|(?:\\u00a7[rb]" + name + "\\u00a7r)|\\b" + name + "\\b"; -- cgit