package kr.syeyoung.dungeonsguide.features.impl; import kr.syeyoung.dungeonsguide.SkyblockStatus; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.features.GuiFeature; import kr.syeyoung.dungeonsguide.features.listener.ChatListener; import kr.syeyoung.dungeonsguide.features.listener.TickListener; import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.util.ChatComponentText; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.lwjgl.opengl.GL11; import java.awt.*; import java.util.regex.Pattern; public class FeatureDungeonSecrets extends GuiFeature { public FeatureDungeonSecrets() { super("Dungeon", "Display #Secrets", "Display how much total secrets have been found in a dungeon run.\n+ sign means DG does not know the correct number, but it's somewhere above that number.", "dungeon.stats.secrets", true, getFontRenderer().getStringWidth("Secrets: 999/999+"), getFontRenderer().FONT_HEIGHT); this.setEnabled(false); parameters.put("color", new FeatureParameter("color", "Color", "Color of text", Color.orange, "color")); } SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); @Override public void drawHUD(float partialTicks) { if (!skyblockStatus.isOnDungeon()) return; FontRenderer fr = getFontRenderer(); double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; GlStateManager.scale(scale, scale, 0); fr.drawString("Secrets: "+getSecretsFound() +"/"+getTotalSecrets(), 0,0, this.getParameter("color").getValue().getRGB()); } @Override public void drawDemo(float partialTicks) { FontRenderer fr = getFontRenderer(); double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; GlStateManager.scale(scale, scale, 0); fr.drawString("Secrets: 999/2+", 0,0, this.getParameter("color").getValue().getRGB()); } public int getSecretsFound() { for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); if (name.startsWith("§r Secrets Found: §r§b")) { String noColor = TextUtils.stripColor(name); return Integer.parseInt(noColor.substring(16)); } } return 0; } public String getTotalSecrets() { DungeonContext context = skyblockStatus.getContext(); int totalSecrets = 0; boolean allknown = true; for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { if (dungeonRoom.getTotalSecrets() != -1) totalSecrets += dungeonRoom.getTotalSecrets(); else allknown = false; } return totalSecrets + (allknown ? "":"+"); } }