Skip to content

Commit

Permalink
Added more waypoint options
Browse files Browse the repository at this point in the history
Also added a test to ping when a player enters radar range. Not that MC
owes me 5 double chests of obsidian
  • Loading branch information
willowsokora committed May 22, 2015
1 parent 80ad99b commit 041bad2
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

apply plugin: 'forge'

version = "beta-1.2.0"
version = "beta-1.2.1"
group= "com.biggestnerd.civradar" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "[1.8]CivRadar"

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/biggestnerd/civradar/CivRadar.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class CivRadar {
public final static String MODID = "civradar";
public final static String MODNAME = "CivRadar";
public final static String VERSION = "beta-1.2.0";
public final static String VERSION = "beta-1.2.1";
private RenderHandler renderHandler;
private Config radarConfig;
private File configFile;
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/biggestnerd/civradar/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class Config {
private float radarScale = 1.0F;
public enum NameLocation {above,below};
private NameLocation nameLocation = NameLocation.below;
private float pingVolume = 0.0F;

public Config() {
mobs = new ArrayList<Entity>(Arrays.asList(new Entity[]{
Expand Down Expand Up @@ -156,6 +157,14 @@ public boolean isExtraPlayerInfo() {
return extraPlayerInfo;
}

public float getPingVolume() {
return pingVolume;
}

public void setPingVolume(float pingVolume) {
this.pingVolume = pingVolume;
}

public boolean isPlayerNames() {
return playerNames;
}
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/com/biggestnerd/civradar/RenderHandler.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.biggestnerd.civradar;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

import net.minecraft.client.Minecraft;
Expand All @@ -17,9 +18,12 @@
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
Expand All @@ -36,6 +40,11 @@ public class RenderHandler extends Gui {
private double pingDelay = 63.0D;
private List entityList;
private float radarScale;
ArrayList<String> inRangePlayers;

public RenderHandler() {
inRangePlayers = new ArrayList<String>();
}

@SubscribeEvent
public void renderRadar(RenderGameOverlayEvent event) {
Expand All @@ -54,6 +63,18 @@ public void onTick(ClientTickEvent event) {
}
pingDelay -= 1.0D;
entityList = mc.theWorld.loadedEntityList;
ArrayList<String> newInRangePlayers = new ArrayList();
for(Object o : entityList) {
if(o instanceof EntityOtherPlayerMP) {
newInRangePlayers.add(((EntityOtherPlayerMP)o).getName());
}
}
ArrayList<String> temp = (ArrayList)newInRangePlayers.clone();
newInRangePlayers.removeAll(inRangePlayers);
for(String name : newInRangePlayers) {
mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, "minecraft:note.pling", config.getPingVolume(), 1.0F, false);
}
inRangePlayers = temp;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class GuiPlayerOptions extends GuiScreen {
private GuiButton playerNamesButton;
private GuiButton playerInfoButton;
private GuiButton playerNamePosButton;
private GuiSlider pingVolumeSlider;

public GuiPlayerOptions(GuiScreen parent) {
this.parent = parent;
Expand All @@ -32,7 +33,8 @@ public void initGui() {
this.buttonList.add(playerNamesButton = new GuiButton(0, this.width / 2 - 100, this.height / 4 - 20, "Player Names: " + (config.isPlayerNames() ? "Enabled" : "Disabled")));
this.buttonList.add(playerInfoButton = new GuiButton(1, this.width / 2 - 100, this.height / 4 + 2, "Position Info: " + (config.isExtraPlayerInfo() ? "Enabled" : "Disabled")));
this.buttonList.add(playerNamePosButton = new GuiButton(3, this.width / 2 - 100, this.height / 4 + 24, "Player Name Location: " + config.getNameLocation().toString()));
this.buttonList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 46, "Done"));
this.buttonList.add(pingVolumeSlider = new GuiSlider(4, this.width / 2 - 100, this.height / 4 + 46, 1.0F, 0.0F, "Ping Volume", config.getPingVolume()));
this.buttonList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 68, "Done"));
}

public void actionPerformed(GuiButton button) {
Expand Down Expand Up @@ -61,6 +63,11 @@ public void updateScreen() {
playerNamesButton.displayString = "Player Names: " + (config.isPlayerNames() ? "Enabled" : "Disabled");
playerInfoButton.displayString = "Position Info: " + (config.isExtraPlayerInfo() ? "Enabled" : "Disabled");
playerNamePosButton.displayString = "Player Name Location: " + config.getNameLocation().toString();
if(pingVolumeSlider.getCurrentValue() == 0.0F) {
pingVolumeSlider.setDisplayString("off");
} else {
pingVolumeSlider.updateDisplayString();
}
}

public void drawScreen(int i, int j, float k) {
Expand Down
32 changes: 28 additions & 4 deletions src/main/java/com/biggestnerd/civradar/gui/GuiWaypointList.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ public GuiWaypointList(GuiScreen parent) {

public void initGui() {
this.buttonList.clear();
this.buttonList.add(enableButton = new GuiButton(0, this.width / 2 - 100, this.height - 44, 64, 20, "Enable"));
this.buttonList.add(disableButton = new GuiButton(1, this.width / 2 - 32, this.height - 44, 64, 20, "Disable"));
this.buttonList.add(editButton = new GuiButton(2, this.width / 2 + 36, this.height - 44, 64, 20, "Edit"));
this.buttonList.add(enableButton = new GuiButton(0, this.width / 2 - 100, this.height - 64, 64, 20, "Enable"));
this.buttonList.add(disableButton = new GuiButton(1, this.width / 2 - 32, this.height - 64, 64, 20, "Disable"));
this.buttonList.add(editButton = new GuiButton(2, this.width / 2 + 36, this.height - 64, 64, 20, "Edit"));
this.buttonList.add(new GuiButton(3, this.width / 2 - 100, this.height - 43, 99, 20, "Enable All"));
this.buttonList.add(new GuiButton(4, this.width / 2 + 1, this.height - 43, 99, 20, "Disable All"));
this.buttonList.add(new GuiButton(100, this.width / 2 - 100, this.height - 22, "Done"));
this.waypointListContainer = new WaypointList(this.mc);
this.waypointListContainer.registerScrollButtons(4, 5);
editButton.enabled = false;
}

public void handleMouseInput() throws IOException {
Expand All @@ -50,6 +53,14 @@ private void enableOrDisableSelectedWaypoint(boolean enabled) {
mc.displayGuiScreen(new GuiWaypointList(parent));
}

private void enableOrDisableAllWaypoints(boolean enabled) {
for(Waypoint point : waypointList) {
CivRadar.instance.getWaypointSave().setEnabled(point, enabled);
}
CivRadar.instance.saveWaypoints();
mc.displayGuiScreen(new GuiWaypointList(parent));
}

protected void actionPerformed(GuiButton button) throws IOException {
if(button.enabled) {
if(button.id == 0) {
Expand All @@ -61,6 +72,12 @@ protected void actionPerformed(GuiButton button) throws IOException {
if(button.id == 2) {
mc.displayGuiScreen(new GuiEditWaypoint(waypointList.get(selected)));
}
if(button.id == 3) {
enableOrDisableAllWaypoints(true);
}
if(button.id == 4) {
enableOrDisableAllWaypoints(false);
}
if(button.id == 100) {
mc.displayGuiScreen(parent);
}
Expand Down Expand Up @@ -107,7 +124,14 @@ protected void drawBackground() {
protected void drawSlot(int entryId, int par2, int par3, int par4, int par5, int par6) {
Waypoint point = GuiWaypointList.this.waypointList.get(entryId);
GuiWaypointList.this.drawString(mc.fontRendererObj, point.getName(), par2 + 1, par3 + 1, Color.WHITE.getRGB());
String coords = "(" + point.getX() + "," + point.getY() + "," + point.getZ() + ")";
String dimension = "";
switch(point.getDimension()) {
case 0: dimension = "overworld";
case -1: dimension = "nether";
case 1: dimension = "end";
default: dimension = "null";
}
String coords = "(" + (int)point.getX() + "," + (int)point.getY() + "," + (int)point.getZ() + ") Dimension: " + dimension;
GuiWaypointList.this.drawString(mc.fontRendererObj, coords, par2 + 1, par3 + 11, point.getColor().getRGB());
GuiWaypointList.this.drawString(mc.fontRendererObj, point.isEnabled() ? "Enabled" : "Disabled", par2 + 215 - mc.fontRendererObj.getStringWidth("Disabled"), par3 + 1, point.isEnabled() ? Color.GREEN.getRGB() : Color.RED.getRGB());
}
Expand Down

0 comments on commit 041bad2

Please sign in to comment.