diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..a8e787c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,26 @@ +# default +* text eol=auto + +# git +.gitattributes text eol=lf +.gitignore text eol=lf + +# sources +*.java text eol=lf + +# resources +*.lang text eol=lf +*.cfg text eol=lf +*.info text eol=lf +*.mcmeta text eol=lf +*.md text eol=lf +*.xml text eol=lf + +# scripts +*.bat text eol=crlf +*.gradle text eol=lf +*.properties text eol=lf + +# binaries +*.png binary +*.jar binary diff --git a/.gitignore b/.gitignore index b9e8d82..418781a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,23 @@ -/.settings/ -/bin/ -/release/ -/build/ -/.gradle/ -/run/ -.project -.classpath -build.properties.old \ No newline at end of file +## gradle +/.gradle +/build + +## ForgeGradle +/run + +## eclipse +/.settings +/.metadata +/.classpath +/.project +/bin + +## intellij +/out +/.idea +/*.iml +/*.ipr +/*.iws + +## custom +/release diff --git a/build.gradle b/build.gradle index bee783c..b6b8158 100644 --- a/build.gradle +++ b/build.gradle @@ -1,44 +1,37 @@ buildscript { repositories { mavenCentral() + jcenter() maven { - name = "forge" - url = "http://files.minecraftforge.net/maven" + name = 'forge' + url = 'http://files.minecraftforge.net/maven' } maven { - name = "sonatype" - url = "https://oss.sonatype.org/content/repositories/snapshots/" + name = 'sonatype' + url = 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' + classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT' + classpath 'com.matthewprenger:CurseGradle:1.0-SNAPSHOT' } } -apply plugin: "forge" +apply plugin: 'net.minecraftforge.gradle.forge' +apply plugin: 'com.matthewprenger.cursegradle' compileJava.options.encoding = 'UTF-8' -// define the properties file -ext.configFile = file "build.properties" - -configFile.withReader { - // read config. it shall from now on be referenced as simply config or as project.config - def prop = new Properties() - prop.load(it) - project.ext.config = new ConfigSlurper().parse prop -} - -group = config.group_name -version = config.mod_version -archivesBaseName = "[${config.minecraft_version}]${config.mod_id}" +group = project.group_name +version = project.mod_version +archivesBaseName = "[${project.minecraft_version}]${project.mod_id}" minecraft { - version = config.minecraft_version + "-" + config.forge_version // grab latest forge - mappings = config.mappings_version - runDir = "run" - replace '@MOD_VERSION@', config.mod_version - replace '@MINECRAFT_VERSION@', config.minecraft_version + version = project.minecraft_version + '-' + project.forge_version // grab latest forge + mappings = project.mappings_version + runDir = 'run' + replace '@MOD_VERSION@', project.mod_version + replace '@MINECRAFT_VERSION@', project.minecraft_version } processResources { @@ -49,9 +42,9 @@ processResources { // replaces expand ([ - 'mod_version': config.mod_version, - 'forge_version': config.forge_version, - 'minecraft_version': config.minecraft_version, + 'mod_version': project.mod_version, + 'forge_version': project.forge_version, + 'minecraft_version': project.minecraft_version, ]) } @@ -64,22 +57,29 @@ processResources { // change the name of my obfuscated jar jar { - appendix = config.appendix + appendix = project.appendix } -// add a source jar -task sourceJar(type: Jar) { - from sourceSets.main.allSource +sourceJar { appendix = 'src' -} - -// because the normal output has been made to be obfuscated -task deobfJar(type: Jar) { - from sourceSets.main.output - appendix = 'deobf' + classifier = '' } artifacts { archives sourceJar - archives deobfJar -} \ No newline at end of file +} + +if (project.hasProperty('api_key_curse') && project.hasProperty('extra_curse_id')) { + tasks.curseforge.dependsOn signJars + curseforge { + apiKey = project.api_key_curse + + project { + id = project.extra_curse_id + changelog = '' + releaseType = project.hasProperty('extra_curse_releasetype') ? project.extra_curse_releasetype : 'release' + + addArtifact sourceJar + } + } +} diff --git a/build.properties b/build.properties deleted file mode 100644 index 5d78ac2..0000000 --- a/build.properties +++ /dev/null @@ -1,7 +0,0 @@ -minecraft_version=1.8 -forge_version=11.14.1.1334 -mappings_version=stable_16 -mod_version=7.01 -mod_id=bspkrsCore -group_name=bspkrscore -appendix=universal \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..3718fcf --- /dev/null +++ b/gradle.properties @@ -0,0 +1,10 @@ +minecraft_version=1.8.9 +forge_version=11.15.0.1719 +mappings_version=snapshot_20160125 +mod_version=1.8.9.1 +mod_id=bspkrsCore +group_name=bspkrscore +appendix=universal + +# extra_curse_id=-1 +# extra_curse_releasetype=release diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index b761216..9411448 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 678d9d8..baf5d7e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Jul 02 15:54:47 CDT 2014 +#Tue Feb 02 17:03:16 CET 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip diff --git a/gradlew b/gradlew index 91a7e26..9d82f78 100644 --- a/gradlew +++ b/gradlew @@ -42,11 +42,6 @@ case "`uname`" in ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" @@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do fi done SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- +cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" -cd "$SAVED" >&- +cd "$SAVED" >/dev/null CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -114,6 +109,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` diff --git a/src/main/java/bspkrs/bspkrscore/fml/BSCClientTicker.java b/src/main/java/bspkrs/bspkrscore/fml/BSCClientTicker.java deleted file mode 100644 index 3e7dc46..0000000 --- a/src/main/java/bspkrs/bspkrscore/fml/BSCClientTicker.java +++ /dev/null @@ -1,61 +0,0 @@ -package bspkrs.bspkrscore.fml; - -import net.minecraft.client.Minecraft; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.fml.client.FMLClientHandler; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class BSCClientTicker -{ - public static boolean allowUpdateCheck = bspkrsCoreMod.instance.allowUpdateCheck; - private Minecraft mcClient; - public static boolean isRegistered = false; - - public BSCClientTicker() - { - if (!isRegistered) - { - mcClient = FMLClientHandler.instance().getClient(); - FMLCommonHandler.instance().bus().register(this); - isRegistered = true; - } - } - - @SubscribeEvent - public void onTick(ClientTickEvent event) - { - if (!event.phase.equals(Phase.START)) - { - boolean keepTicking = !(mcClient != null && mcClient.thePlayer != null && mcClient.theWorld != null); - - if (!keepTicking && isRegistered) - { - if (bspkrsCoreMod.instance.allowUpdateCheck && bspkrsCoreMod.instance.versionChecker != null) - if (!bspkrsCoreMod.instance.versionChecker.isCurrentVersion()) - for (String msg : bspkrsCoreMod.instance.versionChecker.getInGameMessage()) - mcClient.thePlayer.addChatMessage(new ChatComponentText(msg)); - - allowUpdateCheck = false; - - if (bspkrsCoreMod.instance.allowDebugOutput && !keepTicking && mcClient.theWorld.isRemote) - { - //EntityPlayerHelper.addChatMessage(mcClient.thePlayer, new ChatComponentText("\2470\2470\2471\2472\2473\2474\2475\2476\2477\247e\247f")); - } - - FMLCommonHandler.instance().bus().unregister(this); - isRegistered = false; - } - } - } - - public static boolean isRegistered() - { - return isRegistered; - } -} diff --git a/src/main/java/bspkrs/bspkrscore/fml/ClientProxy.java b/src/main/java/bspkrs/bspkrscore/fml/ClientProxy.java index 498b65f..1c8f479 100644 --- a/src/main/java/bspkrs/bspkrscore/fml/ClientProxy.java +++ b/src/main/java/bspkrs/bspkrscore/fml/ClientProxy.java @@ -8,8 +8,5 @@ public class ClientProxy extends CommonProxy { @Override protected void registerGameTickHandler() - { - if (BSCClientTicker.allowUpdateCheck) - new BSCClientTicker(); - } + {} } diff --git a/src/main/java/bspkrs/bspkrscore/fml/CommandBS.java b/src/main/java/bspkrs/bspkrscore/fml/CommandBS.java deleted file mode 100644 index 0d31993..0000000 --- a/src/main/java/bspkrs/bspkrscore/fml/CommandBS.java +++ /dev/null @@ -1,81 +0,0 @@ -package bspkrs.bspkrscore.fml; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.command.WrongUsageException; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import bspkrs.util.ModVersionChecker; - -@SuppressWarnings("unchecked") -public class CommandBS extends CommandBase -{ - @SuppressWarnings("rawtypes") - private static List version = new ArrayList(); - - static - { - version.add("version"); - } - - @Override - public String getCommandName() - { - return "bs"; - } - - @Override - public String getCommandUsage(ICommandSender sender) - { - return "commands.bs.usage"; - } - - @Override - public boolean canCommandSenderUseCommand(ICommandSender par1ICommandSender) - { - return true; - } - - @Override - public int getRequiredPermissionLevel() - { - return 1; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws WrongUsageException - { - if (!bspkrsCoreMod.instance.allowUpdateCheck) - throw new WrongUsageException("commands.bs.disabled"); - - if (args.length != 2) - throw new WrongUsageException("commands.bs.usage"); - - if (!args[0].equalsIgnoreCase("version")) - throw new WrongUsageException("commands.bs.usage"); - - String[] message = ModVersionChecker.checkVersionForMod(args[1]); - - for (String s : message) - sender.addChatMessage(new ChatComponentText(s)); - } - - @SuppressWarnings("rawtypes") - @Override - public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) - { - return args.length == 2 ? getListOfStringsMatchingLastWord(args, ModVersionChecker.getVersionCheckerMap().keySet().toArray(new String[] {})) : args.length == 1 ? version : null; - } - - @Override - public int compareTo(Object object) - { - if (object instanceof CommandBase) - return this.getCommandName().compareTo(((CommandBase) object).getCommandName()); - - return 0; - } -} diff --git a/src/main/java/bspkrs/bspkrscore/fml/bspkrsCoreMod.java b/src/main/java/bspkrs/bspkrscore/fml/bspkrsCoreMod.java index cc19559..652b626 100644 --- a/src/main/java/bspkrs/bspkrscore/fml/bspkrsCoreMod.java +++ b/src/main/java/bspkrs/bspkrscore/fml/bspkrsCoreMod.java @@ -4,10 +4,9 @@ import java.util.ArrayList; import java.util.List; -import net.minecraftforge.client.ClientCommandHandler; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; -import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; @@ -19,14 +18,11 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import bspkrs.util.CommonUtils; import bspkrs.util.Const; -import bspkrs.util.ModVersionChecker; import bspkrs.util.UniqueNameListGenerator; -@Mod(modid = Reference.MODID, name = Reference.NAME, version = "@MOD_VERSION@", useMetadata = true, guiFactory = Reference.GUI_FACTORY) +@Mod(modid = Reference.MODID, name = Reference.NAME, version = "@MOD_VERSION@", useMetadata = true, guiFactory = Reference.GUI_FACTORY, updateJSON = Const.VERSION_URL_BASE + Reference.MODID + Const.VERSION_URL_EXT) public class bspkrsCoreMod { // config stuff @@ -48,19 +44,9 @@ public class bspkrsCoreMod @SidedProxy(clientSide = Reference.PROXY_CLIENT, serverSide = Reference.PROXY_COMMON) public static CommonProxy proxy; - protected ModVersionChecker versionChecker; - protected final String versionURL = Const.VERSION_URL + "/Minecraft/" + Const.MCVERSION + "/bspkrsCore.version"; - protected final String mcfTopic = "http://www.minecraftforum.net/topic/1114612-"; - - @SideOnly(Side.CLIENT) - protected BSCClientTicker ticker; - private boolean isCommandRegistered; - @EventHandler public void preInit(FMLPreInitializationEvent event) { - metadata = event.getModMetadata(); - File file = event.getSuggestedConfigurationFile(); if (!CommonUtils.isObfuscatedEnv()) @@ -108,27 +94,12 @@ public void syncConfig() @EventHandler public void init(FMLInitializationEvent event) { - if (allowUpdateCheck) - { - versionChecker = new ModVersionChecker(Reference.MODID, metadata.version, versionURL, mcfTopic); - versionChecker.checkVersionWithLogging(); - } - if (event.getSide().isClient()) { - FMLCommonHandler.instance().bus().register(new NetworkHandler()); - try - { - ClientCommandHandler.instance.registerCommand(new CommandBS()); - isCommandRegistered = true; - } - catch (Throwable e) - { - isCommandRegistered = false; - } + MinecraftForge.EVENT_BUS.register(new NetworkHandler()); } - FMLCommonHandler.instance().bus().register(instance); + MinecraftForge.EVENT_BUS.register(instance); } @EventHandler @@ -141,8 +112,6 @@ public void postInit(FMLPostInitializationEvent event) @EventHandler public void serverStarting(FMLServerStartingEvent event) { - if (!isCommandRegistered) - event.registerServerCommand(new CommandBS()); } @SubscribeEvent diff --git a/src/main/java/bspkrs/client/util/HUDUtils.java b/src/main/java/bspkrs/client/util/HUDUtils.java index a7cc89e..1ac32f4 100644 --- a/src/main/java/bspkrs/client/util/HUDUtils.java +++ b/src/main/java/bspkrs/client/util/HUDUtils.java @@ -6,6 +6,7 @@ import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -170,11 +171,11 @@ public static void drawTexturedModalRect(int x, int y, int u, int v, int width, float var8 = 0.00390625F; Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldRenderer = tessellator.getWorldRenderer(); - worldRenderer.startDrawingQuads(); - worldRenderer.addVertexWithUV((x + 0), (y + height), zLevel, ((u + 0) * var7), ((v + height) * var8)); - worldRenderer.addVertexWithUV((x + width), (y + height), zLevel, ((u + width) * var7), ((v + height) * var8)); - worldRenderer.addVertexWithUV((x + width), (y + 0), zLevel, ((u + width) * var7), ((v + 0) * var8)); - worldRenderer.addVertexWithUV((x + 0), (y + 0), zLevel, ((u + 0) * var7), ((v + 0) * var8)); + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + worldRenderer.pos((x + 0), (y + height), zLevel).tex(((u + 0) * var7), ((v + height) * var8)).endVertex(); + worldRenderer.pos((x + width), (y + height), zLevel).tex(((u + width) * var7), ((v + height) * var8)).endVertex(); + worldRenderer.pos((x + width), (y + 0), zLevel).tex(((u + width) * var7), ((v + 0) * var8)).endVertex(); + worldRenderer.pos((x + 0), (y + 0), zLevel).tex(((u + 0) * var7), ((v + 0) * var8)).endVertex(); tessellator.draw(); } @@ -245,12 +246,15 @@ else if (itemStack.getItem().equals(Items.bow)) public static void renderQuad(Tessellator tessellator, int x, int y, int width, int height, int color) { WorldRenderer worldRenderer = tessellator.getWorldRenderer(); - worldRenderer.startDrawingQuads(); - worldRenderer.setColorOpaque_I(color); - worldRenderer.addVertex((x + 0), (y + 0), 0.0D); - worldRenderer.addVertex((x + 0), (y + height), 0.0D); - worldRenderer.addVertex((x + width), (y + height), 0.0D); - worldRenderer.addVertex((x + width), (y + 0), 0.0D); + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); + int a = (color >> 24) & 0xFF; + int r = (color >> 16) & 0xFF; + int g = (color >> 8) & 0xFF; + int b = (color >> 0) & 0xFF; + worldRenderer.pos(x + 0, y + 0, 0.0D).color(r, g, b, a).endVertex(); + worldRenderer.pos(x + 0, y + height, 0.0D).color(r, g, b, a).endVertex(); + worldRenderer.pos(x + width, y + height, 0.0D).color(r, g, b, a).endVertex(); + worldRenderer.pos(x + width, y + 0, 0.0D).color(r, g, b, a).endVertex(); tessellator.draw(); } diff --git a/src/main/java/bspkrs/fml/util/DelayedGuiDisplayTicker.java b/src/main/java/bspkrs/fml/util/DelayedGuiDisplayTicker.java index b8e2e76..da8d7c5 100644 --- a/src/main/java/bspkrs/fml/util/DelayedGuiDisplayTicker.java +++ b/src/main/java/bspkrs/fml/util/DelayedGuiDisplayTicker.java @@ -2,6 +2,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -19,7 +20,7 @@ public DelayedGuiDisplayTicker(int delayTicks, GuiScreen screen) this.delayTicks = delayTicks; this.mcClient = FMLClientHandler.instance().getClient(); this.screen = screen; - FMLCommonHandler.instance().bus().register(this); + MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent @@ -31,7 +32,7 @@ public void onTick(ClientTickEvent event) if (--delayTicks <= 0) { mcClient.displayGuiScreen(screen); - FMLCommonHandler.instance().bus().unregister(this); + MinecraftForge.EVENT_BUS.unregister(this); } } } diff --git a/src/main/java/bspkrs/fml/util/InputEventListener.java b/src/main/java/bspkrs/fml/util/InputEventListener.java index 1545ff5..a714cdc 100644 --- a/src/main/java/bspkrs/fml/util/InputEventListener.java +++ b/src/main/java/bspkrs/fml/util/InputEventListener.java @@ -4,6 +4,7 @@ import net.minecraft.client.settings.KeyBinding; +import net.minecraftforge.common.MinecraftForge; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; @@ -79,7 +80,7 @@ public static void unRegister(KeyBinding kb) { if (isRegistered(kb)) { - FMLCommonHandler.instance().bus().unregister(instances.get(kb)); + MinecraftForge.EVENT_BUS.unregister(instances.get(kb)); instances.remove(kb); } } diff --git a/src/main/java/bspkrs/util/BSConfiguration.java b/src/main/java/bspkrs/util/BSConfiguration.java deleted file mode 100644 index 96a8ea8..0000000 --- a/src/main/java/bspkrs/util/BSConfiguration.java +++ /dev/null @@ -1,227 +0,0 @@ -package bspkrs.util; - -import java.io.File; - -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.common.config.Property; - -/** - * This class offers advanced configurations capabilities, allowing to provide various categories for configuration variables. - */ -@Deprecated -public class BSConfiguration extends Configuration -{ - private final File fileRef; - - public BSConfiguration(File file) - { - super(file); - fileRef = file; - } - - @Override - public File getConfigFile() - { - return fileRef; - } - - /** - * Renames a property in a given category. - * - * @param category the category in which the property resides - * @param oldPropName the existing property name - * @param newPropName the - * @return true if the category and property exist, false otherwise - */ - @Override - public boolean renameProperty(String category, String oldPropName, String newPropName) - { - if (hasCategory(category)) - { - if (getCategory(category).containsKey(oldPropName) && !oldPropName.equalsIgnoreCase(newPropName)) - { - get(category, newPropName, getCategory(category).get(oldPropName).getString()); - getCategory(category).remove(oldPropName); - return true; - } - } - return false; - } - - /** - * Moves a property from one category to another. - * - * @param oldCategory the category the property currently resides in - * @param propName the name of the property to move - * @param newCategory the category the property should be moved to - * @return true if the old category and property exist, false otherwise - */ - @Override - public boolean moveProperty(String oldCategory, String propName, String newCategory) - { - if (hasCategory(oldCategory)) - { - if (getCategory(oldCategory).containsKey(propName)) - { - getCategory(newCategory).put(propName, getCategory(oldCategory).get(propName)); - return true; - } - } - return false; - } - - // public static void renameCtgy(Configuration config, String oldCtgy, String newCtgy) - // { - // if (!oldCtgy.equalsIgnoreCase(newCtgy)) - // { - // for (String prop : config.getCategory(oldCtgy).keySet()) - // config.get(newCtgy, prop, config.getCategory(oldCtgy).get(prop).getString()); - // - // Map> toAdd = new HashMap>(); - // - // for (String key : config.getCategoryNames()) - // if (key.contains(oldCtgy + ".")) - // { - // HashMap props = new HashMap(); - // for (String prop : config.getCategory(key).keySet()) - // props.put(prop, config.getCategory(key).get(prop).getString()); - // - // toAdd.put(newCtgy + key.substring(key.indexOf(".")), props); - // } - // - // for (String newName : toAdd.keySet()) - // for (String newProp : toAdd.get(newName).keySet()) - // config.get(newName, newProp, toAdd.get(newName).get(newProp)); - // - // //config.categories.remove(oldCtgy); - // } - // } - - /** - * Creates a string property. - * - * @param name Name of the property. - * @param category Category of the property. - * @param defaultValue Default value of the property. - * @param comment A brief description what the property does. - * @return The value of the new string property. - */ - @Override - public String getString(String name, String category, String defaultValue, String comment) - { - return getString(name, category, defaultValue, comment, new String[0]); - } - - /** - * Creates a string property. - * - * @param name Name of the property. - * @param category Category of the property. - * @param defaultValue Default value of the property. - * @param comment A brief description what the property does. - * @param validValues A list of valid values that this property can be set to. - * @return The value of the new string property. - */ - @Override - public String getString(String name, String category, String defaultValue, String comment, String[] validValues) - { - Property prop = this.get(category, name, defaultValue); - prop.comment = comment + " [default: " + defaultValue + "]"; - return prop.getString(); - } - - /** - * Creates a string list property. - * - * @param name Name of the property. - * @param category Category of the property. - * @param defaultValue Default value of the property. - * @param comment A brief description what the property does. - * @return The value of the new string property. - */ - @Override - public String[] getStringList(String name, String category, String[] defaultValues, String comment) - { - return getStringList(name, category, defaultValues, comment, new String[0]); - } - - /** - * Creates a string list property. - * - * @param name Name of the property. - * @param category Category of the property. - * @param defaultValue Default value of the property. - * @param comment A brief description what the property does. - * @return The value of the new string property. - */ - @Override - public String[] getStringList(String name, String category, String[] defaultValue, String comment, String[] validValues) - { - Property prop = this.get(category, name, defaultValue); - prop.comment = comment + " [default: " + defaultValue + "]"; - return prop.getStringList(); - } - - /** - * Creates a boolean property. - * - * @param name Name of the property. - * @param category Category of the property. - * @param defaultValue Default value of the property. - * @param comment A brief description what the property does. - * @return The value of the new boolean property. - */ - @Override - public boolean getBoolean(String name, String category, boolean defaultValue, String comment) - { - Property prop = this.get(category, name, defaultValue); - prop.comment = comment + " [default: " + defaultValue + "]"; - return prop.getBoolean(defaultValue); - } - - /** - * Creates a integer property. - * - * @param name Name of the property. - * @param category Category of the property. - * @param defaultValue Default value of the property. - * @param minValue Minimum value of the property. - * @param maxValue Maximum value of the property. - * @param comment A brief description what the property does. - * @return The value of the new integer property. - */ - @Override - public int getInt(String name, String category, int defaultValue, int minValue, int maxValue, String comment) - { - Property prop = this.get(category, name, defaultValue); - prop.comment = comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + defaultValue + "]"; - return prop.getInt(defaultValue) < minValue ? minValue : (prop.getInt(defaultValue) > maxValue ? maxValue : prop.getInt(defaultValue)); - } - - /** - * Creates a float property. - * - * @param name Name of the property. - * @param category Category of the property. - * @param defaultValue Default value of the property. - * @param minValue Minimum value of the property. - * @param maxValue Maximum value of the property. - * @param comment A brief description what the property does. - * @return The value of the new float property. - */ - @Override - public float getFloat(String name, String category, float defaultValue, float minValue, float maxValue, String comment) - { - Property prop = this.get(category, name, Float.toString(defaultValue)); - prop.comment = comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + defaultValue + "]"; - try - { - return Float.parseFloat(prop.getString()) < minValue ? minValue : (Float.parseFloat(prop.getString()) > maxValue ? maxValue : Float.parseFloat(prop.getString())); - } - catch (Exception e) - { - e.printStackTrace(); - } - return defaultValue; - } -} diff --git a/src/main/java/bspkrs/util/BlockID.java b/src/main/java/bspkrs/util/BlockID.java index 2983a05..85ca316 100644 --- a/src/main/java/bspkrs/util/BlockID.java +++ b/src/main/java/bspkrs/util/BlockID.java @@ -1,148 +1,150 @@ -package bspkrs.util; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fml.common.registry.GameData; - -public class BlockID -{ - public final String id; - public final int metadata; - - public BlockID(String id, int metadata) - { - this.id = id; - this.metadata = metadata; - } - - public BlockID(String block) - { - this(block, -1); - } - - public BlockID(Block block, int metadata) - { - this(GameData.getBlockRegistry().getNameForObject(block).toString(), metadata); - } - - public BlockID(Block block) - { - this(GameData.getBlockRegistry().getNameForObject(block).toString(), -1); - } - - public BlockID(Block block, IBlockState state) - { - this(block, block.getMetaFromState(state)); - } - - public BlockID(IBlockState state) - { - this(state.getBlock(), state); - } - - public BlockID(World world, BlockPos pos) - { - this(world.getBlockState(pos)); - } - - public BlockID(World world, BlockPos pos, int metadata) - { - this(world.getBlockState(pos).getBlock(), metadata); - } - - public boolean isValid() - { - return getBlock() != null; - } - - public Block getBlock() - { - return GameData.getBlockRegistry().getObject(id); - } - - public static BlockID parse(String format) - { - String id; - int metadata; - int metadataModulus = 0; - format = format.trim(); - int comma = format.indexOf(","); - int tilde = format.indexOf("~"); - if (tilde == -1) - tilde = format.indexOf("%"); - - if ((comma == -1) && (tilde != -1)) - throw new RuntimeException(String.format("ModulusBlockID format error: a \"~\" or \"%1$s\" was found, but no \",\" in format \"%2$s\". " + - "Expected format is \", %1$s \". EG: \"minecraft:log, 0 %1$s 4\".", "%", format)); - - if ((tilde != -1) && (comma > tilde)) - throw new RuntimeException(String.format("ModulusBlockID format error: a \"~\" or \"%1$s\" was found before a \",\" in format \"%2$s\". " + - "Expected format is \", %1$s \". EG: \"minecraft:log, 0 %1$s 4\".", "%", format)); - - if (tilde == -1) - tilde = format.length(); - - if (comma != -1) - id = format.substring(0, comma).trim(); - else - id = format.trim(); - - metadata = CommonUtils.parseInt(format.substring(comma + 1, tilde).trim(), -1); - if (tilde != format.length()) - metadataModulus = CommonUtils.parseInt(format.substring(tilde + 1, format.length()).trim(), 0); - - if ((metadata != -1) && (metadataModulus > 0)) - return new ModulusBlockID(id, metadata, metadataModulus); - else - return new BlockID(id, metadata); - } - - @Override - public BlockID clone() - { - return new BlockID(id, metadata); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - - if (!(obj instanceof BlockID)) - return false; - - if ((((BlockID) obj).id != null) && !((BlockID) obj).id.equals(id)) - return false; - else if ((((BlockID) obj).id == null) && (id != null)) - return false; - - if (obj instanceof ModulusBlockID) - { - ModulusBlockID o = (ModulusBlockID) obj; - return (metadata % o.metadataModulus) == (o.metadata % o.metadataModulus); - } - else - { - BlockID o = (BlockID) obj; - if ((o.metadata == -1) || (metadata == -1)) - return true; - else - return metadata == o.metadata; - } - } - - @Override - public int hashCode() - { - return id.hashCode() * 37; - } - - @Override - public String toString() - { - return (metadata == -1 ? id : id + ", " + metadata); - } -} +package bspkrs.util; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.BlockPos; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.fml.common.registry.GameData; + +@Deprecated // TODO: replace with a IBlockState implementation +public class BlockID +{ + public final String id; + public final int metadata; + + public BlockID(String id, int metadata) + { + this.id = id; + this.metadata = metadata; + } + + public BlockID(String block) + { + this(block, -1); + } + + public BlockID(Block block, int metadata) + { + this(GameData.getBlockRegistry().getNameForObject(block).toString(), metadata); + } + + public BlockID(Block block) + { + this(GameData.getBlockRegistry().getNameForObject(block).toString(), -1); + } + + public BlockID(Block block, IBlockState state) + { + this(block, block.getMetaFromState(state)); + } + + public BlockID(IBlockState state) + { + this(state.getBlock(), state); + } + + public BlockID(World world, BlockPos pos) + { + this(world.getBlockState(pos)); + } + + public BlockID(World world, BlockPos pos, int metadata) + { + this(world.getBlockState(pos).getBlock(), metadata); + } + + public boolean isValid() + { + return getBlock() != null; + } + + public Block getBlock() + { + return GameData.getBlockRegistry().getObject(new ResourceLocation(id)); + } + + public static BlockID parse(String format) + { + String id; + int metadata; + int metadataModulus = 0; + format = format.trim(); + int comma = format.indexOf(","); + int tilde = format.indexOf("~"); + if (tilde == -1) + tilde = format.indexOf("%"); + + if ((comma == -1) && (tilde != -1)) + throw new RuntimeException(String.format("ModulusBlockID format error: a \"~\" or \"%1$s\" was found, but no \",\" in format \"%2$s\". " + + "Expected format is \", %1$s \". EG: \"minecraft:log, 0 %1$s 4\".", "%", format)); + + if ((tilde != -1) && (comma > tilde)) + throw new RuntimeException(String.format("ModulusBlockID format error: a \"~\" or \"%1$s\" was found before a \",\" in format \"%2$s\". " + + "Expected format is \", %1$s \". EG: \"minecraft:log, 0 %1$s 4\".", "%", format)); + + if (tilde == -1) + tilde = format.length(); + + if (comma != -1) + id = format.substring(0, comma).trim(); + else + id = format.trim(); + + metadata = CommonUtils.parseInt(format.substring(comma + 1, tilde).trim(), -1); + if (tilde != format.length()) + metadataModulus = CommonUtils.parseInt(format.substring(tilde + 1, format.length()).trim(), 0); + + if ((metadata != -1) && (metadataModulus > 0)) + return new ModulusBlockID(id, metadata, metadataModulus); + else + return new BlockID(id, metadata); + } + + @Override + public BlockID clone() + { + return new BlockID(id, metadata); + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + + if (!(obj instanceof BlockID)) + return false; + + if ((((BlockID) obj).id != null) && !((BlockID) obj).id.equals(id)) + return false; + else if ((((BlockID) obj).id == null) && (id != null)) + return false; + + if (obj instanceof ModulusBlockID) + { + ModulusBlockID o = (ModulusBlockID) obj; + return (metadata % o.metadataModulus) == (o.metadata % o.metadataModulus); + } + else + { + BlockID o = (BlockID) obj; + if ((o.metadata == -1) || (metadata == -1)) + return true; + else + return metadata == o.metadata; + } + } + + @Override + public int hashCode() + { + return id.hashCode() * 37; + } + + @Override + public String toString() + { + return (metadata == -1 ? id : id + ", " + metadata); + } +} diff --git a/src/main/java/bspkrs/util/Const.java b/src/main/java/bspkrs/util/Const.java index ec70f0a..010bdd5 100644 --- a/src/main/java/bspkrs/util/Const.java +++ b/src/main/java/bspkrs/util/Const.java @@ -2,6 +2,7 @@ public class Const { - public static String MCVERSION = "@MINECRAFT_VERSION@"; - public static String VERSION_URL = "http://bspk.rs"; + public static final String MCVERSION = "@MINECRAFT_VERSION@"; + public static final String VERSION_URL_BASE = "http://bspk.rs/Minecraft/"; + public static final String VERSION_URL_EXT = ".json"; } diff --git a/src/main/java/bspkrs/util/ModVersionChecker.java b/src/main/java/bspkrs/util/ModVersionChecker.java deleted file mode 100644 index a4b603c..0000000 --- a/src/main/java/bspkrs/util/ModVersionChecker.java +++ /dev/null @@ -1,232 +0,0 @@ -package bspkrs.util; - -import java.io.File; -import java.net.URL; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.prefs.Preferences; - -import net.minecraft.util.StatCollector; -import bspkrs.bspkrscore.fml.bspkrsCoreMod; - -import com.google.common.collect.Ordering; - -/** - * This class retrieves a version string from a text file at a given URL and compares it against the locally provided version string. It - * uses a natural order comparator to determine if the remote version is newer than our local version. - * - * @author bspkrs - */ - -public class ModVersionChecker -{ - private static final Map versionCheckerMap = new HashMap(); - private URL versionURL; - private final String modID; - private String newVersion; - private final String currentVersion; - private String updateURL; - private String[] loadMsg; - private String[] inGameMsg; - private File trackerFile; - private File trackerDir; - private static Preferences versionCheckTracker; - private String lastNewVersionFound; - private final String CHECK_ERROR = "check_error"; - private final boolean errorDetected; - private int runsSinceLastMessage; - - public ModVersionChecker(String modID, String curVer, String versionURL, String updateURL, String[] loadMsg, String[] inGameMsg) - { - this(modID, curVer, versionURL, updateURL, loadMsg, inGameMsg, bspkrsCoreMod.instance.updateTimeoutMilliseconds); - } - - public ModVersionChecker(String modID, String curVer, String versionURL, String updateURL, String[] loadMsg, String[] inGameMsg, int timeoutMS) - { - this.modID = modID; - this.currentVersion = curVer; - this.updateURL = updateURL; - this.loadMsg = loadMsg; - this.inGameMsg = inGameMsg; - - try - { - if (versionURL.startsWith("http://dl.dropboxusercontent.com")) - versionURL = versionURL.replaceFirst("http", "https"); - - this.versionURL = new URL(versionURL); - BSLog.info("Initializing ModVersionChecker for mod %s", modID); - } - catch (Throwable e) - { - BSLog.warning("Error initializing ModVersionChecker for mod %s: %s", modID, e.getMessage()); - } - - String[] versionLines = CommonUtils.loadTextFromURL(this.versionURL, BSLog.INSTANCE.getLogger(), new String[] { CHECK_ERROR }, timeoutMS); - - if (versionLines.length == 0 || versionLines[0].trim().equals("")) - newVersion = CHECK_ERROR; - else - newVersion = versionLines[0].trim(); - - errorDetected = newVersion.equals(CHECK_ERROR); - - // Keep track of the versions we've seen to keep from nagging players with new version notifications beyond the first one - if (trackerDir == null) - { - trackerDir = new File(CommonUtils.getConfigDir() + "/bspkrsCore/"); - if (trackerDir.exists()) - { - trackerFile = new File(trackerDir, "ModVersionCheckerTracking.txt"); - trackerFile.delete(); - trackerDir.delete(); - } - - trackerDir = new File(CommonUtils.getConfigDir()); - trackerFile = new File(trackerDir, "bspkrs_ModVersionCheckerTracking.txt"); - if ((trackerFile.exists())) - trackerFile.delete(); - } - - if (versionCheckTracker == null) - versionCheckTracker = Preferences.userNodeForPackage(this.getClass()).node("modversiontracker" + Const.MCVERSION); - - if (!(new StringBuilder("@").append("MOD_VERSION@")).toString().equals(currentVersion) && !"${mod_version}".equals(currentVersion)) - { - lastNewVersionFound = versionCheckTracker.get(modID, currentVersion); - - if (lastNewVersionFound.equals("")) - lastNewVersionFound = currentVersion; - - runsSinceLastMessage = versionCheckTracker.node("runs_since_last_message").getInt(modID, 0); - - if (errorDetected) - newVersion = lastNewVersionFound; - - if (!errorDetected && !isCurrentVersion(lastNewVersionFound, newVersion)) - { - runsSinceLastMessage = 0; - lastNewVersionFound = newVersion; - } - else - runsSinceLastMessage = runsSinceLastMessage % 10; - - versionCheckTracker.node("runs_since_last_message").putInt(modID, runsSinceLastMessage + 1); - versionCheckTracker.put(modID, lastNewVersionFound); - } - - // Override instantiated updateURL with second line of version file if it exists and is non-blank - if (versionLines.length > 1 && versionLines[1].trim().length() != 0) - this.updateURL = versionLines[1]; - - setLoadMessage(loadMsg); - setInGameMessage(inGameMsg); - - versionCheckerMap.put(modID.toLowerCase(Locale.US), this); - } - - public ModVersionChecker(String modName, String oldVer, String versionURL, String updateURL) - { - this(modName, oldVer, versionURL, updateURL, - new String[] { "{modID} {oldVer} is out of date! Visit {updateURL} to download the latest release ({newVer})." }, - new String[] { "\247c{modID} {newVer} \247ris out! Download the latest from \247a{updateURL}\247r" }); - } - - public void checkVersionWithLogging() - { - if (!isCurrentVersion(currentVersion, newVersion)) - for (String msg : loadMsg) - BSLog.info(msg); - } - - public void setLoadMessage(String[] loadMsg) - { - this.loadMsg = loadMsg; - - for (int i = 0; i < this.loadMsg.length; i++) - this.loadMsg[i] = replaceAllTags(this.loadMsg[i]); - } - - public void setInGameMessage(String[] inGameMsg) - { - this.inGameMsg = inGameMsg; - - for (int i = 0; i < this.inGameMsg.length; i++) - this.inGameMsg[i] = replaceAllTags(this.inGameMsg[i]); - - } - - public String[] getLoadMessage() - { - return loadMsg; - } - - public String[] getInGameMessage() - { - return inGameMsg; - } - - public URL getVersionURL() - { - return versionURL; - } - - public String getNewVersion() - { - return newVersion; - } - - public String getCurrentVersion() - { - return currentVersion; - } - - public String getUpdateURL() - { - return updateURL; - } - - public static Map getVersionCheckerMap() - { - return versionCheckerMap; - } - - public boolean isCurrentVersion() - { - return errorDetected || isCurrentVersion(runsSinceLastMessage == 0 ? currentVersion : lastNewVersionFound, newVersion); - } - - public static boolean isCurrentVersion(String oldVer, String newVer) - { - return Ordering.natural().compare(oldVer, newVer) >= 0; - } - - private String replaceAllTags(String s) - { - return s.replace("{oldVer}", currentVersion).replace("{newVer}", newVersion).replace("{modID}", modID).replace("{updateURL}", updateURL); - } - - public static String[] checkVersionForMod(String modID) - { - String[] r = { "" }; - - if (versionCheckerMap.containsKey(modID.toLowerCase(Locale.US))) - { - ModVersionChecker versionChecker = versionCheckerMap.get(modID.toLowerCase(Locale.US)); - if (!versionChecker.errorDetected) - { - if (!isCurrentVersion(versionChecker.currentVersion, versionChecker.newVersion)) - r = versionChecker.getInGameMessage(); - else - r = new String[] { StatCollector.translateToLocalFormatted("bspkrs.modversionchecker.uptodate", versionChecker.modID) }; - } - else - r = new String[] { StatCollector.translateToLocalFormatted("bspkrs.modversionchecker.error", versionChecker.modID) }; - } - else - r = new String[] { StatCollector.translateToLocal("bspkrs.modversionchecker.invalidmodid") }; - - return r; - } -} diff --git a/src/main/java/bspkrs/util/ModulusBlockID.java b/src/main/java/bspkrs/util/ModulusBlockID.java index 187d4b6..dd9e8d0 100644 --- a/src/main/java/bspkrs/util/ModulusBlockID.java +++ b/src/main/java/bspkrs/util/ModulusBlockID.java @@ -5,6 +5,7 @@ import net.minecraft.util.BlockPos; import net.minecraft.world.World; +@Deprecated // TODO: replace with a IBlockState implementation public class ModulusBlockID extends BlockID { public final int metadataModulus; diff --git a/src/main/java/bspkrs/util/UniqueNameListGenerator.java b/src/main/java/bspkrs/util/UniqueNameListGenerator.java index 3c43426..cd22fed 100644 --- a/src/main/java/bspkrs/util/UniqueNameListGenerator.java +++ b/src/main/java/bspkrs/util/UniqueNameListGenerator.java @@ -45,7 +45,7 @@ public void run() listFile.createNewFile(); - PrintWriter out = new PrintWriter(new FileWriter(listFile)); + PrintWriter out = new PrintWriter(listFile, "UTF-8"); out.println("# generated by bspkrsCore " + new SimpleDateFormat("yyyyMMdd HH:mm:ss").format(new Date())); out.println(); diff --git a/src/test/java/bspkrs/testmod/ClientProxy.java b/src/test/java/bspkrs/testmod/ClientProxy.java new file mode 100644 index 0000000..c42bdd1 --- /dev/null +++ b/src/test/java/bspkrs/testmod/ClientProxy.java @@ -0,0 +1,9 @@ +package bspkrs.testmod; + +public class ClientProxy extends CommonProxy +{ + @Override + protected void registerTickHandler() + { + } +} diff --git a/testmod/bspkrs/testmod/CommonProxy.java b/src/test/java/bspkrs/testmod/CommonProxy.java similarity index 100% rename from testmod/bspkrs/testmod/CommonProxy.java rename to src/test/java/bspkrs/testmod/CommonProxy.java diff --git a/testmod/bspkrs/testmod/GuiTestModConfig.java b/src/test/java/bspkrs/testmod/GuiTestModConfig.java similarity index 100% rename from testmod/bspkrs/testmod/GuiTestModConfig.java rename to src/test/java/bspkrs/testmod/GuiTestModConfig.java diff --git a/testmod/bspkrs/testmod/ModGuiFactoryHandler.java b/src/test/java/bspkrs/testmod/ModGuiFactoryHandler.java similarity index 100% rename from testmod/bspkrs/testmod/ModGuiFactoryHandler.java rename to src/test/java/bspkrs/testmod/ModGuiFactoryHandler.java diff --git a/testmod/bspkrs/testmod/TMTicker.java b/src/test/java/bspkrs/testmod/TMTicker.java similarity index 56% rename from testmod/bspkrs/testmod/TMTicker.java rename to src/test/java/bspkrs/testmod/TMTicker.java index 1f63a8f..1b11289 100644 --- a/testmod/bspkrs/testmod/TMTicker.java +++ b/src/test/java/bspkrs/testmod/TMTicker.java @@ -3,6 +3,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.util.ChatComponentText; import bspkrs.bspkrscore.fml.bspkrsCoreMod; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -16,34 +17,19 @@ public class TMTicker { private Minecraft mcClient; private static boolean isRegistered = false; - + public TMTicker() { mcClient = FMLClientHandler.instance().getClient(); isRegistered = true; } - + @SubscribeEvent public void onTick(ClientTickEvent event) { - boolean keepTicking = !(mcClient != null && mcClient.thePlayer != null && mcClient.theWorld != null); - - if (!event.phase.equals(Phase.START)) - { - if (bspkrsCoreMod.instance.allowUpdateCheck && !keepTicking) - if (TestMod.instance.versionChecker != null) - if (!TestMod.instance.versionChecker.isCurrentVersion()) - for (String msg : TestMod.instance.versionChecker.getInGameMessage()) - mcClient.thePlayer.addChatMessage(new ChatComponentText(msg)); - - if (!keepTicking) - { - FMLCommonHandler.instance().bus().unregister(this); - isRegistered = false; - } - } + } - + public static boolean isRegistered() { return isRegistered; diff --git a/testmod/bspkrs/testmod/TestMod.java b/src/test/java/bspkrs/testmod/TestMod.java similarity index 62% rename from testmod/bspkrs/testmod/TestMod.java rename to src/test/java/bspkrs/testmod/TestMod.java index ae28180..8debe1b 100644 --- a/testmod/bspkrs/testmod/TestMod.java +++ b/src/test/java/bspkrs/testmod/TestMod.java @@ -1,8 +1,6 @@ package bspkrs.testmod; -import bspkrs.bspkrscore.fml.bspkrsCoreMod; import bspkrs.util.Const; -import bspkrs.util.ModVersionChecker; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; @@ -13,39 +11,27 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @Mod(modid = "TestMod", name = "TestMod", version = "2.0", dependencies = "required-after:bspkrsCore", - guiFactory = "bspkrs.testmod.ModGuiFactoryHandler") + guiFactory = "bspkrs.testmod.ModGuiFactoryHandler", updateJSON = Const.VERSION_URL_BASE + "TestMod" + Const.VERSION_URL_EXT) public class TestMod { @Metadata(value = "TestMod") public static ModMetadata metadata; - + @Instance(value = "TestMod") public static TestMod instance; - + @SidedProxy(clientSide = "bspkrs.testmod.ClientProxy", serverSide = "bspkrs.testmod.CommonProxy") public static CommonProxy proxy; - - protected ModVersionChecker versionChecker; - private final String versionURL = Const.VERSION_URL + "/Minecraft/TestMod/testMod.version"; - private final String mcfTopic = "http://www.minecraftforum.net/topic/1114612-"; - + @EventHandler public void preInit(FMLPreInitializationEvent event) { - metadata = event.getModMetadata(); - TestModSimpleConfig.initConfig(event.getSuggestedConfigurationFile()); } - + @EventHandler public void init(FMLInitializationEvent event) { - if (bspkrsCoreMod.instance.allowUpdateCheck) - { - versionChecker = new ModVersionChecker(metadata.name, metadata.version, versionURL, mcfTopic); - versionChecker.checkVersionWithLogging(); - } - proxy.registerTickHandler(); } } diff --git a/testmod/bspkrs/testmod/TestModSimpleConfig.java b/src/test/java/bspkrs/testmod/TestModSimpleConfig.java similarity index 100% rename from testmod/bspkrs/testmod/TestModSimpleConfig.java rename to src/test/java/bspkrs/testmod/TestModSimpleConfig.java diff --git a/testmod/bspkrs/testmod/ClientProxy.java b/testmod/bspkrs/testmod/ClientProxy.java deleted file mode 100644 index 68ca03f..0000000 --- a/testmod/bspkrs/testmod/ClientProxy.java +++ /dev/null @@ -1,13 +0,0 @@ -package bspkrs.testmod; - -import net.minecraftforge.fml.common.FMLCommonHandler; - -public class ClientProxy extends CommonProxy -{ - @Override - protected void registerTickHandler() - { - if (!TMTicker.isRegistered()) - FMLCommonHandler.instance().bus().register(new TMTicker()); - } -}