diff --git a/build.gradle b/build.gradle index a4a2b0c..859dcfe 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ compileJava { sourceCompatibility = '1.8' targetCompatibility = '1.8' } -version = "1.2.1" +version = "1.2.2" group= "io.github.symt" archivesBaseName = "ZealotCounter" diff --git a/src/main/java/io/github/symt/EventHandler.java b/src/main/java/io/github/symt/EventHandler.java index 98b894a..936f672 100644 --- a/src/main/java/io/github/symt/EventHandler.java +++ b/src/main/java/io/github/symt/EventHandler.java @@ -47,7 +47,8 @@ public void onMobDeath(LivingDeathEvent event) { if (((objectMouseOver != null && objectMouseOver.typeOfHit == MovingObjectType.ENTITY && objectMouseOver.entityHit.getEntityId() == event.entity.getEntityId()) || attackedEntity == event.entity.getEntityId()) - && ((event.entity.getName().length() > 2 && event.entity.getName().substring(2).equals("Enderman")) + && ((event.entity.getName().length() > 2 && event.entity.getName().substring(2) + .equals("Enderman")) || event.entity instanceof EntityEnderman) && prevEntity != event.entity.getEntityId() && ZealotCounter.dragonsNest) { @@ -63,7 +64,8 @@ public void onMobDeath(LivingDeathEvent event) { @SubscribeEvent(priority = EventPriority.HIGH) public void onAttack(AttackEntityEvent event) { if (event.entity.getEntityId() == Minecraft.getMinecraft().thePlayer.getEntityId() && - ((event.target.getName().length() > 2 && event.target.getName().substring(2).equals("Enderman")) + ((event.target.getName().length() > 2 && event.target.getName().substring(2) + .equals("Enderman")) || event.target instanceof EntityEnderman) && ZealotCounter.dragonsNest) { attackedEntity = event.target.getEntityId(); } @@ -83,7 +85,9 @@ public void onTick(TickEvent.ClientTickEvent e) { tick++; if (tick > 99 && Minecraft.getMinecraft() != null && Minecraft.getMinecraft().thePlayer != null) { - if (Minecraft.getMinecraft().theWorld.getScoreboard().getObjectiveInDisplaySlot(1) + if (Minecraft.getMinecraft().getCurrentServerData() != null + && Minecraft.getMinecraft().getCurrentServerData().serverIP != null + && Minecraft.getMinecraft().theWorld.getScoreboard().getObjectiveInDisplaySlot(1) != null) { ZealotCounter.isInSkyblock = (stripString(StringUtils.stripControlCodes( Minecraft.getMinecraft().theWorld.getScoreboard().getObjectiveInDisplaySlot(1) @@ -164,15 +168,20 @@ public void onPlayerJoinEvent(FMLNetworkEvent.ClientConnectedToServerEvent event .addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "You are currently on a pre-release build of ZealotCounter. Please report any bugs that you may come across")); } else if (latestTag[i].compareTo(currentTag[i]) >= 1) { - ChatComponentText updateLink = new ChatComponentText(EnumChatFormatting.DARK_GREEN + "" + EnumChatFormatting.BOLD + "[CLICK HERE]"); - updateLink.setChatStyle(updateLink.getChatStyle().setChatClickEvent(new ClickEvent( - Action.OPEN_URL, "https://github.com/symt/zealot-counter/releases/latest"))); + ChatComponentText updateLink = new ChatComponentText( + EnumChatFormatting.DARK_GREEN + "" + EnumChatFormatting.BOLD + + "[CLICK HERE]"); + updateLink + .setChatStyle(updateLink.getChatStyle().setChatClickEvent(new ClickEvent( + Action.OPEN_URL, + "https://github.com/symt/zealot-counter/releases/latest"))); Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( EnumChatFormatting.GREEN + "You are currently on version " + EnumChatFormatting.DARK_GREEN + current + EnumChatFormatting.GREEN + " and the latest version is " + EnumChatFormatting.DARK_GREEN + latest + EnumChatFormatting.GREEN - + ". Please update to the latest version of ZealotCounter. ").appendSibling(updateLink)); + + ". Please update to the latest version of ZealotCounter. ") + .appendSibling(updateLink)); } Minecraft.getMinecraft().thePlayer .addChatMessage(new ChatComponentTranslation("", new Object[0])); @@ -226,55 +235,57 @@ private boolean isUsingLabymod() { } private void renderStats() { - String zealotEye = - "Zealots/Eye: " + ((ZealotCounter.summoningEyes == 0) ? ZealotCounter.zealotCount - : new DecimalFormat("#.##") - .format(ZealotCounter.zealotCount / (ZealotCounter.summoningEyes * 1.0d))); - String zealot = "Zealots: " + ZealotCounter.zealotCount; - String eye = "Eyes: " + ZealotCounter.summoningEyes; - String lastEye = "Zealots since last eye: " + ZealotCounter.sinceLastEye; - String zealotsPerHour = "Zealots/Hour: " + Math.round(ZealotCounter.zealotSession / ( - ((perHourTimer.getTime() == 0) ? 1 : perHourTimer.getTime()) / 3600000d)); - String chanceOfEye = - "Current drop rate: " + (1 + Math.floor(ZealotCounter.zealotCount / 420d)) + "/420"; - String longest = - (lastEye.length() > zealot.length() && lastEye.length() > zealotEye.length()) ? lastEye - : (zealot.length() > zealotEye.length()) ? zealot : zealotEye; - if (ZealotCounter.align.equals("right")) { - renderer.drawString(eye, ZealotCounter.guiLocation[0] + - renderer.getStringWidth(longest) - - renderer.getStringWidth(eye), - ZealotCounter.guiLocation[1], ZealotCounter.color, true); - renderer.drawString(zealot, ZealotCounter.guiLocation[0] + - renderer.getStringWidth(longest) - - renderer.getStringWidth(zealot), - ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT, ZealotCounter.color, true); - renderer.drawString(zealotEye, ZealotCounter.guiLocation[0] + - renderer.getStringWidth(longest) - - renderer.getStringWidth(zealotEye), - ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT * 2, ZealotCounter.color, true); - renderer.drawString(lastEye, ZealotCounter.guiLocation[0] + - renderer.getStringWidth(longest) - - renderer.getStringWidth(lastEye), - ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT * 3, ZealotCounter.color, true); - if (ZealotCounter.zealotSession != 0 && perHourTimer.isStarted()) { - renderer.drawString(zealotsPerHour, ZealotCounter.guiLocation[0] + + if (ZealotCounter.toggled) { + String zealotEye = + "Zealots/Eye: " + ((ZealotCounter.summoningEyes == 0) ? ZealotCounter.zealotCount + : new DecimalFormat("#.##") + .format(ZealotCounter.zealotCount / (ZealotCounter.summoningEyes * 1.0d))); + String zealot = "Zealots: " + ZealotCounter.zealotCount; + String eye = "Eyes: " + ZealotCounter.summoningEyes; + String lastEye = "Zealots since last eye: " + ZealotCounter.sinceLastEye; + String zealotsPerHour = "Zealots/Hour: " + Math.round(ZealotCounter.zealotSession / ( + ((perHourTimer.getTime() == 0) ? 1 : perHourTimer.getTime()) / 3600000d)); + String chanceOfEye = + "Current drop rate: " + (1 + Math.floor(ZealotCounter.zealotCount / 420d)) + "/420"; + String longest = + (lastEye.length() > zealot.length() && lastEye.length() > zealotEye.length()) ? lastEye + : (zealot.length() > zealotEye.length()) ? zealot : zealotEye; + if (ZealotCounter.align.equals("right")) { + renderer.drawString(eye, ZealotCounter.guiLocation[0] + renderer.getStringWidth(longest) - - renderer.getStringWidth(zealotsPerHour), - ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT * 4, ZealotCounter.color, true); - } - } else { - renderer.drawString(eye, ZealotCounter.guiLocation[0], - ZealotCounter.guiLocation[1], ZealotCounter.color, true); - renderer.drawString(zealot, ZealotCounter.guiLocation[0], - ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT, ZealotCounter.color, true); - renderer.drawString(zealotEye, ZealotCounter.guiLocation[0], - ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT * 2, ZealotCounter.color, true); - renderer.drawString(lastEye, ZealotCounter.guiLocation[0], - ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT * 3, ZealotCounter.color, true); - if (ZealotCounter.zealotSession != 0 && perHourTimer.isStarted()) { - renderer.drawString(zealotsPerHour, ZealotCounter.guiLocation[0], - ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT * 4, ZealotCounter.color, true); + renderer.getStringWidth(eye), + ZealotCounter.guiLocation[1], ZealotCounter.color, true); + renderer.drawString(zealot, ZealotCounter.guiLocation[0] + + renderer.getStringWidth(longest) - + renderer.getStringWidth(zealot), + ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT, ZealotCounter.color, true); + renderer.drawString(zealotEye, ZealotCounter.guiLocation[0] + + renderer.getStringWidth(longest) - + renderer.getStringWidth(zealotEye), + ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT * 2, ZealotCounter.color, true); + renderer.drawString(lastEye, ZealotCounter.guiLocation[0] + + renderer.getStringWidth(longest) - + renderer.getStringWidth(lastEye), + ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT * 3, ZealotCounter.color, true); + if (ZealotCounter.zealotSession != 0 && perHourTimer.isStarted()) { + renderer.drawString(zealotsPerHour, ZealotCounter.guiLocation[0] + + renderer.getStringWidth(longest) - + renderer.getStringWidth(zealotsPerHour), + ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT * 4, ZealotCounter.color, true); + } + } else { + renderer.drawString(eye, ZealotCounter.guiLocation[0], + ZealotCounter.guiLocation[1], ZealotCounter.color, true); + renderer.drawString(zealot, ZealotCounter.guiLocation[0], + ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT, ZealotCounter.color, true); + renderer.drawString(zealotEye, ZealotCounter.guiLocation[0], + ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT * 2, ZealotCounter.color, true); + renderer.drawString(lastEye, ZealotCounter.guiLocation[0], + ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT * 3, ZealotCounter.color, true); + if (ZealotCounter.zealotSession != 0 && perHourTimer.isStarted()) { + renderer.drawString(zealotsPerHour, ZealotCounter.guiLocation[0], + ZealotCounter.guiLocation[1] + renderer.FONT_HEIGHT * 4, ZealotCounter.color, true); + } } } } diff --git a/src/main/java/io/github/symt/ZealotCounter.java b/src/main/java/io/github/symt/ZealotCounter.java index d74ba29..f751d0c 100644 --- a/src/main/java/io/github/symt/ZealotCounter.java +++ b/src/main/java/io/github/symt/ZealotCounter.java @@ -30,11 +30,12 @@ public class ZealotCounter { static final String MODID = "ZealotCounter"; - static final String VERSION = "1.2.1"; + static final String VERSION = "1.2.2"; private static final String ZEALOT_PATH = "zealotcounter.dat"; static boolean loggedIn = false; static boolean usingLabyMod = false; static boolean dragonsNest = false; + static boolean toggled = true; static int color = 0x55FFFF; static String align = "left"; static int zealotCount = 0; diff --git a/src/main/java/io/github/symt/ZealotCounterCommand.java b/src/main/java/io/github/symt/ZealotCounterCommand.java index fe9b1ce..30dd4a3 100644 --- a/src/main/java/io/github/symt/ZealotCounterCommand.java +++ b/src/main/java/io/github/symt/ZealotCounterCommand.java @@ -45,6 +45,10 @@ public void processCommand(ICommandSender ics, String[] args) { } else if (args.length == 2 && args[0].equalsIgnoreCase("color") && ZealotCounter .isInteger(args[1], 16) && args[1].length() == 6) { ZealotCounter.color = Integer.parseInt(args[1], 16); + } else if (args.length == 1 && args[0].equalsIgnoreCase("toggle")) { + ZealotCounter.toggled ^= true; + player.addChatMessage( + new ChatComponentText(EnumChatFormatting.GREEN + "ZealotCounter has been toggled " + EnumChatFormatting.DARK_GREEN + (ZealotCounter.toggled ? "on" : "off"))); } else if (args.length == 2 && args[0].equalsIgnoreCase("timer") && (Arrays .asList(new String[]{"start", "stop", "reset", "resume"}) .contains(args[1].toLowerCase()))) { @@ -140,6 +144,9 @@ public void processCommand(ICommandSender ics, String[] args) { player.addChatMessage(new ChatComponentText( EnumChatFormatting.DARK_PURPLE + "7. " + EnumChatFormatting.LIGHT_PURPLE + "timer (start|stop|resume|reset)")); + player.addChatMessage(new ChatComponentText( + EnumChatFormatting.DARK_PURPLE + "8. " + EnumChatFormatting.LIGHT_PURPLE + + "toggle")); player.addChatMessage( new ChatComponentText(EnumChatFormatting.DARK_GRAY + "---------------------------")); }