diff options
author | bowser0000 <bowser0000@gmail.com> | 2021-04-29 01:06:57 -0400 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2021-04-29 01:06:57 -0400 |
commit | 01822bff56d23b98885227943bd1e042e4f9e946 (patch) | |
tree | 5931c2b8a3df8ca25a5747fdc273a06c6102fa48 /src/main/java/me/Danker/features | |
parent | b48dabaf8ab58773eb51a1c2077b880ee1f28675 (diff) | |
download | SkyblockMod-01822bff56d23b98885227943bd1e042e4f9e946.tar.gz SkyblockMod-01822bff56d23b98885227943bd1e042e4f9e946.tar.bz2 SkyblockMod-01822bff56d23b98885227943bd1e042e4f9e946.zip |
Add giant hp display
Also make LocationButton easy to add
Diffstat (limited to 'src/main/java/me/Danker/features')
-rw-r--r-- | src/main/java/me/Danker/features/GiantHPDisplay.java | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/features/GiantHPDisplay.java b/src/main/java/me/Danker/features/GiantHPDisplay.java new file mode 100644 index 0000000..07378dd --- /dev/null +++ b/src/main/java/me/Danker/features/GiantHPDisplay.java @@ -0,0 +1,71 @@ +package me.Danker.features; + +import me.Danker.DankersSkyblockMod; +import me.Danker.commands.ToggleCommand; +import me.Danker.events.RenderOverlay; +import me.Danker.handlers.ScoreboardHandler; +import me.Danker.handlers.TextRenderer; +import me.Danker.utils.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.util.StringUtils; +import net.minecraft.world.World; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; + +public class GiantHPDisplay { + + static Pattern f6GiantPattern = Pattern.compile("(Jolly Pink Giant|L\\.A\\.S\\.R\\.|The Diamond Giant|Bigfoot).*"); + static List<Entity> giants = new ArrayList<>(); + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent event) { + if (event.phase != TickEvent.Phase.START) return; + + World world = Minecraft.getMinecraft().theWorld; + if (DankersSkyblockMod.tickAmount % 20 == 0) { + if (ToggleCommand.giantHP && Utils.inDungeons && world != null) { + giants.clear(); + List<String> scoreboard = ScoreboardHandler.getSidebarLines(); + String firstLine = ScoreboardHandler.cleanSB(scoreboard.get(scoreboard.size() - 1)); + + if (firstLine.contains("sadan")) { + List<Entity> entities = world.getLoadedEntityList(); + + for (Entity entity : entities) { + String name = StringUtils.stripControlCodes(entity.getName()); + if (f6GiantPattern.matcher(name).find()) { + giants.add(entity); + } + } + } else if (firstLine.contains("138,30") || firstLine.contains("354,66") || firstLine.contains("138,66")) { + List<Entity> entities = world.getLoadedEntityList(); + + for (Entity entity : entities) { + if (entity.getName().contains("Giant ")) { + giants.add(entity); + } + } + } + } + } + } + + @SubscribeEvent + public void renderPlayerInfo(RenderOverlay event) { + if (ToggleCommand.giantHP && Utils.inDungeons && giants.size() > 0) { + StringBuilder sb = new StringBuilder(); + + for (Entity giant : giants) { + if (!giant.isDead) sb.append(Utils.removeBold(giant.getDisplayName().getFormattedText())).append("\n"); + } + + new TextRenderer(Minecraft.getMinecraft(), sb.toString(), 100, 100, 1); + } + } + +} |