diff options
author | bowser0000 <bowser0000@gmail.com> | 2021-07-11 17:18:07 -0400 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2021-07-11 17:18:07 -0400 |
commit | 6eed0d48eeaa054392efe19dffaef691701c1356 (patch) | |
tree | 8af7714bff21f8f58b14a9c385f2188e393f7eb0 | |
parent | 4e70985c1b6cd71505ab6dc96c8abcd1600948df (diff) | |
download | SkyblockMod-6eed0d48eeaa054392efe19dffaef691701c1356.tar.gz SkyblockMod-6eed0d48eeaa054392efe19dffaef691701c1356.tar.bz2 SkyblockMod-6eed0d48eeaa054392efe19dffaef691701c1356.zip |
Add custom colours to nametags
Also fix Spider's Den detection and fix copy paste error in /toggle
-rw-r--r-- | src/main/java/me/Danker/commands/ToggleCommand.java | 2 | ||||
-rw-r--r-- | src/main/java/me/Danker/features/ArachneESP.java | 2 | ||||
-rw-r--r-- | src/main/java/me/Danker/features/ColouredNames.java | 27 |
3 files changed, 29 insertions, 2 deletions
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<String> 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<EntityLivingBase> 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"; |