-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6076c70
commit 34803dd
Showing
52 changed files
with
1,510 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
maven { | ||
name = "forge" | ||
url = "http://files.minecraftforge.net/maven" | ||
} | ||
maven { | ||
name = "sonatype" | ||
url = "https://oss.sonatype.org/content/repositories/snapshots/" | ||
} | ||
} | ||
dependencies { | ||
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' | ||
} | ||
} | ||
|
||
apply plugin: 'forge' | ||
|
||
version = "beta-1.0.0" | ||
group= "com.biggestnerd.civradar" // http://maven.apache.org/guides/mini/guide-naming-conventions.html | ||
archivesBaseName = "[1.8]CivRadar" | ||
|
||
minecraft { | ||
version = "1.8-11.14.1.1325" | ||
runDir = "eclipse" | ||
|
||
// the mappings can be changed at any time, and must be in the following format. | ||
// snapshot_YYYYMMDD snapshot are built nightly. | ||
// stable_# stables are built at the discretion of the MCP team. | ||
// Use non-default mappings at your own risk. they may not allways work. | ||
// simply re-run your setup task after changing the mappings to update your workspace. | ||
mappings = "snapshot_20141130" | ||
} | ||
|
||
dependencies { | ||
// you may put jars on which you depend on in ./libs | ||
// or you may define them like so.. | ||
//compile "some.group:artifact:version:classifier" | ||
//compile "some.group:artifact:version" | ||
|
||
// real examples | ||
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env | ||
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env | ||
|
||
// for more info... | ||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html | ||
// http://www.gradle.org/docs/current/userguide/dependency_management.html | ||
|
||
} | ||
|
||
processResources | ||
{ | ||
// this will ensure that this task is redone when the versions change. | ||
inputs.property "version", project.version | ||
inputs.property "mcversion", project.minecraft.version | ||
|
||
// replace stuff in mcmod.info, nothing else | ||
from(sourceSets.main.resources.srcDirs) { | ||
include 'mcmod.info' | ||
|
||
// replace version and mcversion | ||
expand 'version':project.version, 'mcversion':project.minecraft.version | ||
} | ||
|
||
// copy everything else, thats not the mcmod.info | ||
from(sourceSets.main.resources.srcDirs) { | ||
exclude 'mcmod.info' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package com.biggestnerd.civradar; | ||
|
||
import java.io.File; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.settings.KeyBinding; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.fml.client.registry.ClientRegistry; | ||
import net.minecraftforge.fml.common.FMLCommonHandler; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.common.Mod.EventHandler; | ||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; | ||
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent; | ||
|
||
import org.lwjgl.input.Keyboard; | ||
|
||
import com.biggestnerd.civradar.gui.GuiAddWaypoint; | ||
import com.biggestnerd.civradar.gui.GuiRadarOptions; | ||
import com.biggestnerd.civradar.gui.GuiRepositionRadar; | ||
|
||
@Mod(modid=CivRadar.MODID, name=CivRadar.MODNAME, version=CivRadar.VERSION) | ||
public class CivRadar { | ||
public final static String MODID = "civradar"; | ||
public final static String MODNAME = "CivRadar"; | ||
public final static String VERSION = "beta-1.0.0"; | ||
private RenderHandler renderHandler; | ||
private Config radarConfig; | ||
private File configFile; | ||
private KeyBinding radarOptions = new KeyBinding("CivRadar Settings", Keyboard.KEY_R, "CivRadar"); | ||
private KeyBinding addWaypoint = new KeyBinding("Add Waypoint", Keyboard.KEY_P, "CivRadar"); | ||
Minecraft mc; | ||
public static CivRadar instance; | ||
private WaypointSave currentWaypoints; | ||
private File saveFile; | ||
|
||
@EventHandler | ||
public void preInit(FMLPreInitializationEvent event) { | ||
mc = Minecraft.getMinecraft(); | ||
instance = this; | ||
File configDir = event.getModConfigurationDirectory(); | ||
if(!configDir.isDirectory()) { | ||
configDir.mkdir(); | ||
} | ||
configFile = new File(configDir, "civRadar.json"); | ||
if(!configFile.isFile()) { | ||
try { | ||
configFile.createNewFile(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
radarConfig = new Config(); | ||
radarConfig.save(configFile); | ||
} else { | ||
radarConfig = Config.load(configFile); | ||
if(radarConfig == null) { | ||
radarConfig = new Config(); | ||
} | ||
radarConfig.save(configFile); | ||
} | ||
renderHandler = new RenderHandler(); | ||
FMLCommonHandler.instance().bus().register(renderHandler); | ||
MinecraftForge.EVENT_BUS.register(renderHandler); | ||
FMLCommonHandler.instance().bus().register(this); | ||
ClientRegistry.registerKeyBinding(radarOptions); | ||
ClientRegistry.registerKeyBinding(addWaypoint); | ||
} | ||
|
||
@SubscribeEvent | ||
public void keyPress(KeyInputEvent event) { | ||
if(radarOptions.isKeyDown()) { | ||
mc.displayGuiScreen(new GuiRadarOptions(mc.currentScreen)); | ||
} | ||
if(addWaypoint.isKeyDown()) { | ||
mc.displayGuiScreen(new GuiAddWaypoint(mc.currentScreen)); | ||
} | ||
} | ||
|
||
//@SubscribeEvent | ||
public void connectToServer(ClientConnectedToServerEvent event) { | ||
File waypointsFile = new File(mc.mcDataDir, "/waypoints/"); | ||
if(!waypointsFile.isDirectory()) { | ||
waypointsFile.mkdir(); | ||
} | ||
if(mc.getCurrentServerData() == null) { | ||
return; | ||
} | ||
String ip = mc.getCurrentServerData().serverIP; | ||
saveFile = new File(waypointsFile, ip + ".json"); | ||
if(!saveFile.isFile()) { | ||
try { | ||
saveFile.createNewFile(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
currentWaypoints = new WaypointSave(); | ||
currentWaypoints.save(saveFile); | ||
} else { | ||
try { | ||
currentWaypoints.load(saveFile); | ||
} catch (Exception e) { | ||
currentWaypoints = new WaypointSave(); | ||
} | ||
currentWaypoints.save(saveFile); | ||
} | ||
} | ||
|
||
public Config getConfig() { | ||
return radarConfig; | ||
} | ||
|
||
public void saveConfig() { | ||
radarConfig.save(configFile); | ||
} | ||
|
||
public WaypointSave getWaypointSave() { | ||
return currentWaypoints; | ||
} | ||
|
||
public void saveWaypoints() { | ||
currentWaypoints.save(saveFile); | ||
} | ||
} |
Oops, something went wrong.