-
Notifications
You must be signed in to change notification settings - Fork 8
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
0 parents
commit efffb5a
Showing
12 changed files
with
322 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,64 @@ | ||
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 = "1.7.10-1.0" | ||
group= "com.qkninja.clockhud" // http://maven.apache.org/guides/mini/guide-naming-conventions.html | ||
archivesBaseName = "ClockHUD" | ||
|
||
minecraft { | ||
version = "1.7.10-10.13.2.1230" | ||
} | ||
|
||
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' | ||
} | ||
} | ||
|
||
sourceSets { main { output.resourcesDir = output.classesDir } } |
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,28 @@ | ||
package com.qkninja.clockhud; | ||
|
||
import com.qkninja.clockhud.proxy.IProxy; | ||
import com.qkninja.clockhud.reference.Reference; | ||
import cpw.mods.fml.common.Mod; | ||
import cpw.mods.fml.common.SidedProxy; | ||
import cpw.mods.fml.common.event.FMLInitializationEvent; | ||
|
||
/** | ||
* Created by Sam on 2014-12-20. | ||
*/ | ||
@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION) | ||
public class ClockHUD | ||
{ | ||
|
||
@Mod.Instance(Reference.MOD_ID) | ||
public static ClockHUD instance; | ||
|
||
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) | ||
public static IProxy proxy; | ||
|
||
@Mod.EventHandler | ||
public void Init(FMLInitializationEvent event) | ||
{ | ||
proxy.registerRenderers(); | ||
} | ||
|
||
} |
97 changes: 97 additions & 0 deletions
97
src/main/java/com/qkninja/clockhud/client/gui/GuiClock.java
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,97 @@ | ||
package com.qkninja.clockhud.client.gui; | ||
|
||
import com.qkninja.clockhud.reference.Textures; | ||
import cpw.mods.fml.common.eventhandler.EventPriority; | ||
import cpw.mods.fml.common.eventhandler.SubscribeEvent; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.Gui; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.client.event.RenderGameOverlayEvent; | ||
import org.lwjgl.opengl.GL11; | ||
|
||
/** | ||
* Creates the Clock Gui. | ||
*/ | ||
public class GuiClock extends Gui | ||
{ | ||
private Minecraft mc; | ||
|
||
public GuiClock(Minecraft mc) | ||
{ | ||
super(); | ||
|
||
// Invokes the render engine, or something. | ||
this.mc = mc; | ||
} | ||
|
||
private static final int SUN_WIDTH = 24; // 48 | ||
private static final int MOON_WIDTH = 16; // 31 | ||
private static final int ICON_HEIGHT = 25; // 49 | ||
private static final int BAR_LENGTH = 200; // 400 | ||
private static final int BAR_HEIGHT = 5; // 10 | ||
private static final int DOT = 5; // 10 | ||
private static final float SCALE =.7F; | ||
|
||
private static final int DAY_TICKS = 24000; | ||
private static final int NIGHT_TICK = 13000; | ||
|
||
@SubscribeEvent(priority = EventPriority.NORMAL) | ||
public void onRenderExperienceBar(RenderGameOverlayEvent.Post event) | ||
{ | ||
|
||
if(event.isCancelable() || event.type != RenderGameOverlayEvent.ElementType.EXPERIENCE) | ||
{ | ||
return; | ||
} | ||
|
||
int xPos = 2; | ||
int yPos = 2; | ||
|
||
this.mc.getTextureManager().bindTexture(Textures.Gui.HUD); | ||
|
||
GL11.glEnable(GL11.GL_BLEND); | ||
GL11.glDisable(GL11.GL_DEPTH_TEST); | ||
GL11.glDepthMask(false); | ||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); | ||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); | ||
GL11.glDisable(GL11.GL_ALPHA_TEST); | ||
GL11.glScalef(SCALE, SCALE, SCALE); | ||
|
||
this.drawTexturedModalRect(xPos + SUN_WIDTH / 2 - (DOT / 2), yPos + ICON_HEIGHT / 2 - BAR_HEIGHT / 2, 0, 0, BAR_LENGTH, BAR_HEIGHT); | ||
if (isDay()) | ||
this.drawTexturedModalRect(xPos + getScaledTime(), yPos, 0, BAR_HEIGHT, SUN_WIDTH, ICON_HEIGHT); | ||
else | ||
this.drawTexturedModalRect(xPos + (SUN_WIDTH - MOON_WIDTH) / 2 + getScaledTime(), yPos, SUN_WIDTH, BAR_HEIGHT, MOON_WIDTH, ICON_HEIGHT); | ||
|
||
GL11.glScalef(1 / SCALE, 1 / SCALE, 1 / SCALE); | ||
GL11.glDisable(GL11.GL_BLEND); | ||
GL11.glEnable(GL11.GL_DEPTH_TEST); | ||
GL11.glDepthMask(true); | ||
|
||
} | ||
|
||
private int getScaledTime() | ||
{ | ||
World world = Minecraft.getMinecraft().theWorld; | ||
long time = world.getWorldInfo().getWorldTime(); | ||
int currentTime = (int) time % DAY_TICKS; | ||
|
||
if (currentTime >= 0 && currentTime <= NIGHT_TICK) | ||
{ | ||
return currentTime * (BAR_LENGTH - DOT) / NIGHT_TICK; | ||
} | ||
else | ||
{ | ||
return (currentTime - NIGHT_TICK) * (BAR_LENGTH - DOT) / (DAY_TICKS - NIGHT_TICK); | ||
} | ||
} | ||
|
||
private boolean isDay() | ||
{ | ||
World world = Minecraft.getMinecraft().theWorld; | ||
long time = world.getWorldInfo().getWorldTime(); | ||
int currentTime = (int) time % DAY_TICKS; | ||
|
||
return (currentTime >= 0 && currentTime <= NIGHT_TICK); | ||
} | ||
} |
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,20 @@ | ||
package com.qkninja.clockhud.proxy; | ||
|
||
import com.qkninja.clockhud.client.gui.GuiClock; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraftforge.common.MinecraftForge; | ||
|
||
/** | ||
* Created by Sam on 2014-12-20. | ||
*/ | ||
public class ClientProxy extends CommonProxy | ||
{ | ||
|
||
private Minecraft mc = Minecraft.getMinecraft(); | ||
|
||
@Override | ||
public void registerRenderers() | ||
{ | ||
MinecraftForge.EVENT_BUS.register(new GuiClock(mc)); | ||
} | ||
} |
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,9 @@ | ||
package com.qkninja.clockhud.proxy; | ||
|
||
/** | ||
* Created by Sam on 2014-12-20. | ||
*/ | ||
public abstract class CommonProxy implements IProxy | ||
{ | ||
|
||
} |
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,11 @@ | ||
package com.qkninja.clockhud.proxy; | ||
|
||
/** | ||
* Created by Sam on 2014-12-20. | ||
*/ | ||
public interface IProxy | ||
{ | ||
|
||
public void registerRenderers(); | ||
|
||
} |
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,9 @@ | ||
package com.qkninja.clockhud.proxy; | ||
|
||
/** | ||
* Created by Sam on 2014-12-20. | ||
*/ | ||
public class ServerProxy extends CommonProxy | ||
{ | ||
public void registerRenderers() {} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/qkninja/clockhud/reference/Reference.java
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,14 @@ | ||
package com.qkninja.clockhud.reference; | ||
|
||
/** | ||
* Created by Sam on 2014-12-20. | ||
*/ | ||
public class Reference | ||
{ | ||
public static final String MOD_ID = "ClockHUD"; | ||
public static final String MOD_NAME = "ClockHUD"; | ||
public static final String VERSION = "1.7.10-1.0"; | ||
public static final String SERVER_PROXY_CLASS = "com.qkninja.clockhud.proxy.ServerProxy"; | ||
public static final String CLIENT_PROXY_CLASS = "com.qkninja.clockhud.proxy.ClientProxy"; | ||
// public static final String GUI_FACTORY_CLASS = "com.qkninja.clockhud.client.gui.GuiFactory"; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/qkninja/clockhud/reference/Textures.java
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,18 @@ | ||
package com.qkninja.clockhud.reference; | ||
|
||
import com.qkninja.clockhud.utility.ResourceLocationHelper; | ||
import net.minecraft.util.ResourceLocation; | ||
|
||
/** | ||
* Created by Sam on 2014-12-20. | ||
*/ | ||
public class Textures | ||
{ | ||
public static final String RESOURCE_PREFIX = Reference.MOD_ID.toLowerCase() + ":"; | ||
|
||
public static final class Gui | ||
{ | ||
private static final String GUI_SHEET_LOCATION = "textures/gui/"; | ||
public static final ResourceLocation HUD = ResourceLocationHelper.getResourceLocation(GUI_SHEET_LOCATION + "gui_clock.png"); | ||
} | ||
} |
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,32 @@ | ||
package com.qkninja.clockhud.utility; | ||
|
||
import com.qkninja.clockhud.reference.Reference; | ||
import cpw.mods.fml.common.FMLLog; | ||
import org.apache.logging.log4j.Level; | ||
|
||
/** | ||
* Created by Sam on 2014-12-20. | ||
*/ | ||
public class LogHelper | ||
{ | ||
public static void log(Level logLevel, Object object) | ||
{ | ||
FMLLog.log(Reference.MOD_NAME, logLevel, String.valueOf(object)); | ||
} | ||
|
||
public static void all(Object object) { log(Level.ALL, object); } | ||
|
||
public static void debug(Object object) { log(Level.DEBUG, object); } | ||
|
||
public static void error(Object object) { log(Level.ERROR, object); } | ||
|
||
public static void fatal(Object object) { log(Level.FATAL, object); } | ||
|
||
public static void info(Object object) { log(Level.INFO, object); } | ||
|
||
public static void off(Object object) { log(Level.OFF, object); } | ||
|
||
public static void trace(Object object) { log(Level.TRACE, object); } | ||
|
||
public static void warn(Object object) { log(Level.WARN, object); } | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/qkninja/clockhud/utility/ResourceLocationHelper.java
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,20 @@ | ||
package com.qkninja.clockhud.utility; | ||
|
||
import com.qkninja.clockhud.reference.Reference; | ||
import net.minecraft.util.ResourceLocation; | ||
|
||
/** | ||
* Created by Sam on 2014-12-20. | ||
*/ | ||
public class ResourceLocationHelper | ||
{ | ||
public static ResourceLocation getResourceLocation(String modId, String path) | ||
{ | ||
return new ResourceLocation(modId, path); | ||
} | ||
|
||
public static ResourceLocation getResourceLocation(String path) | ||
{ | ||
return getResourceLocation(Reference.MOD_ID.toLowerCase(), path); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.