Skip to content
This repository has been archived by the owner on Dec 9, 2020. It is now read-only.

Commit

Permalink
1.2.2: Fixes & /zc toggle (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
symt authored Dec 24, 2019
1 parent e3d90f5 commit c362fc2
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 57 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
121 changes: 66 additions & 55 deletions src/main/java/io/github/symt/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
}
Expand All @@ -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)
Expand Down Expand Up @@ -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]));
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/github/symt/ZealotCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/io/github/symt/ZealotCounterCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()))) {
Expand Down Expand Up @@ -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 + "---------------------------"));
}
Expand Down

0 comments on commit c362fc2

Please sign in to comment.