Skip to content

Commit

Permalink
Added fac notifications, special AABB for XP5
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyzderp committed Mar 25, 2015
1 parent 1624e4e commit 5bd2387
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 58 deletions.
2 changes: 1 addition & 1 deletion ant/build_examplemod.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<!-- The version of your mod, can be any string as long as it's valid as part of a file name -->
<!-- and should match the version string returned by your mod. -->
<property name="version" value="1.0.3" />
<property name="version" value="1.1.0" />

<!-- The Minecraft version the mod is for, appended to the output file name for reference -->
<property name="mcversion" value="1.7.2" />
Expand Down
4 changes: 2 additions & 2 deletions ant/buildnumber.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Thu Feb 19 22:46:55 PST 2015
build.number=33
#Wed Mar 25 02:56:48 PDT 2015
build.number=38
Binary file modified bin/com/kyzeragon/mobcountmod/LiteModMobCounter.class
Binary file not shown.
Binary file modified bin/com/kyzeragon/mobcountmod/MobCounter.class
Binary file not shown.
Binary file modified bin/com/kyzeragon/mobcountmod/MobCounterConfigScreen.class
Binary file not shown.
152 changes: 105 additions & 47 deletions java/com/kyzeragon/mobcountmod/LiteModMobCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ public class LiteModMobCounter implements Tickable, ChatFilter, OutboundChatList
private MobCounterConfigScreen configScreen = new MobCounterConfigScreen();
private MobCounter counter = new MobCounter(staff);
private String[] toMessage;
private boolean notifyFac;
private String sound;

private int counterVisible = 0; // 0 - not visible, 1 - compact, 2 - expanded
private int hostileVisible = 1;
private int hostileVisible = 0;
private int playSoundCount = 0; // counts up so sound plays once per sec
private int sendMsgCount = 0; // counts up so message sends every 5 minutes

Expand All @@ -69,13 +70,14 @@ else if (this.staff)
}

@Override
public String getVersion() { return "1.0.3"; }
public String getVersion() { return "1.1.0"; }

@Override
public void init(File configPath)
{
this.sentCmd = false;
this.showChildCounts = false;
this.notifyFac = false;
this.sound = "note.bass";

counterKeyBinding = new KeyBinding("key.counter.toggle", Keyboard.KEY_P, "key.categories.litemods");
Expand All @@ -89,7 +91,9 @@ public void init(File configPath)
LiteLoader.getInput().registerKeyBinding(optionsKeyBinding);

if (this.rebel) { // EEEEEEEEEEEEEEEbel
// this.hostileVisible = 1;
this.notifyFac = true;
this.hostileVisible = 1;
this.counter.setXP5(true);
}
}

Expand Down Expand Up @@ -147,52 +151,96 @@ public void onSendChatMessage(C01PacketChatMessage packet, String message)
if (tokens[0].equalsIgnoreCase("/counter") || tokens[0].equalsIgnoreCase("/count"))
{
this.sentCmd = true;
if (tokens.length > 1)
if (tokens.length < 2)
{
if (tokens[1].equalsIgnoreCase("message") || tokens[1].equalsIgnoreCase("m")
|| tokens[1].equalsIgnoreCase("msg"))
this.logMessage(this.getName() + " [v" + this.getVersion() + "] by Kyzeragon");
this.logMessage("Type /counter help for commands.");
return;
}
if (tokens[1].equalsIgnoreCase("message") || tokens[1].equalsIgnoreCase("m")
|| tokens[1].equalsIgnoreCase("msg"))
{
if (tokens.length < 3)
{
String toSend = "Currently notifying: ";
for (String name : this.toMessage)
toSend += name + " ";
this.logMessage(toSend);
}
else if (tokens.length > 3)
this.logError("Too many args! Usage: /counter msg clear OR /counter msg [player1[,player2]]]");
else if (tokens[2].equalsIgnoreCase("clear"))
{
if (tokens.length < 3)
this.toMessage = null;
this.logMessage("Not currently notifying any players.");
}
else
{
this.toMessage = tokens[2].split(",");
String toSend = tokens[2].replaceAll(",", " ");
this.logMessage("Now notifying: " + toSend);
this.logError("Usage: /counter msg clear OR /counter msg <player[,player2]>");
}
}
else if (tokens[1].equalsIgnoreCase("sound"))
{
if (tokens.length < 3)
this.logMessage("Current hostile sound: " + this.sound);
else if (tokens.length > 3)
this.logError("Too many args! Usage: /counter sound <sound file>");
else
{
this.sound = tokens[2];
this.logMessage("Now using " + this.sound + " as notification sound.");
}
}
else if (tokens[1].matches("fac|faction"))
{
if (tokens.length > 2)
{
if (tokens[2].equalsIgnoreCase("on"))
{
String toSend = "Currently notifying: ";
for (String name : this.toMessage)
toSend += name + " ";
this.logMessage(toSend);
this.notifyFac = true;
this.logMessage("Now notifying in faction chat when over 150 mobs.");
}
else if (tokens.length > 3)
this.logError("Too many args! Usage: /counter msg [player1[,player2]]]");
else
else if (tokens[2].equalsIgnoreCase("off"))
{
this.toMessage = tokens[2].split(",");
String toSend = tokens[2].replaceAll(",", " ");
this.logMessage("Now notifying: " + toSend);
this.notifyFac = false;
this.logMessage("Not notifying in faction chat.");
}
else
this.logError("Usage: /counter fac <on|off>");
}
else if (tokens[1].equalsIgnoreCase("sound"))
}
else if (tokens[1].equalsIgnoreCase("xp5") && this.staff)
{
if (tokens.length > 2)
{
if (tokens.length < 3)
this.logMessage("Current hostile sound: " + this.sound);
else if (tokens.length > 3)
this.logError("Too many args! Usage: /counter sound <sound file>");
else
if (tokens[2].equalsIgnoreCase("on"))
{
this.sound = tokens[2];
this.logMessage("Now using " + this.sound + " as notification sound.");
this.counter.setXP5(true);
this.logMessage("Now counting only mobs at ShockerzXP5 kill points... mostly.");
return;
}
else if (tokens[2].equalsIgnoreCase("off"))
{
this.counter.setXP5(false);
this.logMessage("Using normal mob counter radius.");
return;
}
}
else if (tokens[1].equalsIgnoreCase("help"))
{
String[] commands = {"msg [player1[,player2]] - Set notified players",
"sound [sound file] - Set the notification sound.",
"help - This help message. Hurrdurr."};
this.logMessage(this.getName() + " [v" + this.getVersion() + "] commands");
for (String command : commands)
this.logMessage("/counter " + command);
}
else {
this.logMessage(this.getName() + " [v" + this.getVersion() + "]");
this.logMessage("Type /counter help for commands.");
}
this.logError("Usage: /sd xp5 <on|off>");
}
else if (tokens[1].equalsIgnoreCase("help"))
{
String[] commands = {"msg [player1[,player2]] - Set notified players",
"msg clear - Clear the list of notfied players",
"fac|faction <on|off> - Toggle notification in faction chat.",
"sound [sound file] - Set the notification sound.",
"help - This help message. Hurrdurr."};
this.logMessage(this.getName() + " [v" + this.getVersion() + "] commands");
for (String command : commands)
this.logMessage("/counter " + command);
}
else {
this.logMessage(this.getName() + " [v" + this.getVersion() + "]");
Expand Down Expand Up @@ -221,7 +269,7 @@ public boolean onChat(S02PacketChat chatPacket, IChatComponent chat,
*/
private void hostileLimit()
{
// System.out.println("playSoundCount: " + this.playSoundCount + " sendMsgCount: " + this.sendMsgCount);
// System.out.println("playSoundCount: " + this.playSoundCount + " sendMsgCount: " + this.sendMsgCount);
int totalCount = 0;
for (int i = 0; i < 8; i++)
totalCount += this.counter.countEntity(i + 8, true);
Expand All @@ -242,14 +290,14 @@ private void hostileLimit()

if (this.sendMsgCount == 0)
{
if (this.rebel)
if (this.notifyFac)
Minecraft.getMinecraft().thePlayer.sendChatMessage("/ch qm f Automated Message: "
+ totalCount + " mobz. Kill pl0x.");
if (this.toMessage != null && this.toMessage.length > 0)
{
for (String player : this.toMessage)
Minecraft.getMinecraft().thePlayer.sendChatMessage("/m " + player
+ " Automated Message: Kill mobz pl0x.");
+ " Automated Message: " + totalCount + " mobz. Kill pl0x.");
}
this.sendMsgCount++;
}
Expand Down Expand Up @@ -356,8 +404,15 @@ private void displayHostile()
if (this.counterVisible > 0)
offset = 50;

this.counter.updateHostileBB();
fontRender.drawStringWithShadow("Radius: " + this.counter.getHRadius(), 0, offset, 0xFFAA00);
if (this.counter.getXP5())
{
fontRender.drawStringWithShadow("ShockerzXP5", 0, offset, 0xFFAA00);
}
else
{
this.counter.updateHostileBB();
fontRender.drawStringWithShadow("Radius: " + this.counter.getHRadius(), 0, offset, 0xFFAA00);
}

int totalCount = 0;
for (int i = 0; i < 4; i++)
Expand All @@ -380,14 +435,17 @@ private void displayHostile()
}
else
this.playSoundCount = 100;
fontRender.drawStringWithShadow("Total: " + totalCount, 60, offset, color);
if (this.counter.getXP5())
fontRender.drawStringWithShadow("Total: " + totalCount, 70, offset, color);
else
fontRender.drawStringWithShadow("Total: " + totalCount, 60, offset, color);
}

/**
* Logs the message to the user
* @param message The message to log
*/
private void logMessage(String message)
public static void logMessage(String message)
{
ChatComponentText displayMessage = new ChatComponentText(message);
displayMessage.setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.AQUA));
Expand All @@ -398,9 +456,9 @@ private void logMessage(String message)
* Logs the error message to the user
* @param message The error message to log
*/
private void logError(String message)
public static void logError(String message)
{
ChatComponentText displayMessage = new ChatComponentText(message);
ChatComponentText displayMessage = new ChatComponentText("§8[§4!§8] §c" + message + " §8[§4!§8]");
displayMessage.setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.RED));
Minecraft.getMinecraft().thePlayer.addChatComponentMessage(displayMessage);
}
Expand Down
31 changes: 23 additions & 8 deletions java/com/kyzeragon/mobcountmod/MobCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@
public class MobCounter {

private int radius;
private boolean xp5;
private AxisAlignedBB boundingBox;
private int hRadius; //radius for hostiles
private AxisAlignedBB hostileBB;

public MobCounter(boolean isStaff)
{
this.xp5 = false;
this.radius = 16;
if (isStaff)
this.hRadius = 25;
else
this.hRadius = 16;

this.boundingBox = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0);
this.hostileBB = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0);
}
Expand Down Expand Up @@ -55,7 +57,7 @@ public int countEntity(int num, boolean adult)
case 13: return minecraft.theWorld.getEntitiesWithinAABB(EntityWitch.class, hostileBB).size();
case 14: return minecraft.theWorld.getEntitiesWithinAABB(EntityPigZombie.class, hostileBB).size();
case 15: return minecraft.theWorld.getEntitiesWithinAABB(EntitySlime.class, hostileBB).size();

case 16: return minecraft.theWorld.getEntitiesWithinAABB(EntityPlayer.class, boundingBox).size() - 1;
}
if (adult)
Expand All @@ -71,21 +73,21 @@ public int countEntity(int num, boolean adult)
return count;
}
}

public void updateBB()
{
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
this.boundingBox.setBounds(player.posX - this.radius, player.posY - this.radius, player.posZ - this.radius,
player.posX + this.radius, player.posY + this.radius, player.posZ + this.radius);
}

public void updateHostileBB()
{
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
this.hostileBB.setBounds(player.posX - this.hRadius, player.posY - this.hRadius, player.posZ - this.hRadius,
player.posX + this.hRadius, player.posY + this.hRadius, player.posZ + this.hRadius);
}

public int getRadius()
{
return this.radius;
Expand All @@ -108,12 +110,12 @@ public void decreaseRadius()
if (this.radius > 0)
this.radius--;
}

public int getHRadius()
{
return this.hRadius;
}

public void increaseHRadius(boolean staff)
{
if (staff)
Expand All @@ -125,11 +127,24 @@ public void increaseHRadius(boolean staff)
this.hRadius++;
}
}

public void decreaseHRadius()
{
if (this.hRadius > 0)
this.hRadius--;
}

public boolean getXP5() { return this.xp5; }

public void setXP5(boolean on)
{
this.xp5 = on;
if (on)
this.setXP5bounding();
}

private void setXP5bounding()
{
this.hostileBB.setBounds(-2290, 5, -4363, -2270, 34, -4357);
}
}

0 comments on commit 5bd2387

Please sign in to comment.