From cb2d8b1a2ba0874e2da633e99f8db646e362ebad Mon Sep 17 00:00:00 2001 From: Roy Curtis Date: Tue, 25 Aug 2015 15:17:44 +0100 Subject: [PATCH] * licensed under 3-clause BSD (as agreed by KJ4IPS) * added KJ4IPS as author under mcmod.info * updated gradlefile, README and EnchantIcons to latest conventions * enforce siding; mod will now only work client side. fixes crash on server side * use correct logger --- LICENSE.md | 12 ++++ README.md | 12 ++++ Readme.markdown | 26 -------- build.gradle | 61 ++++++++++++------- src/main/java/roycurtis/EnchantIcons.java | 36 ++++++++--- .../roycurtis/EnchantIconsConfiguration.java | 1 - src/main/resources/mcmod.info | 6 +- 7 files changed, 94 insertions(+), 60 deletions(-) create mode 100644 LICENSE.md create mode 100644 README.md delete mode 100644 Readme.markdown diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..854782b --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,12 @@ +Copyright (c) 2015, Roy Adrian Curtis +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7746ed0 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +[![Build Status](http://ci.haun.guru/buildStatus/icon?job=EnchantIcons)](http://ci.haun.guru/job/EnchantIcons/) + +**EnchantIcons** is a client-only mod that makes enchanted books easier to find, based on their inner enchantment. It is available for 1.7.10 and 1.6.4. + +# Building + +## Requirements + +* [Gradle installation with gradle binary in PATH](http://www.gradle.org/installation). Unlike the source package provided by Forge, this repository does not include a gradle wrapper or distribution. + +## Usage +Simply execute `gradle setupCIWorkspace` in the root directory of this repository. Then execute `gradle build`. If subsequent builds cause problems, do `gradle clean`. \ No newline at end of file diff --git a/Readme.markdown b/Readme.markdown deleted file mode 100644 index d87459a..0000000 --- a/Readme.markdown +++ /dev/null @@ -1,26 +0,0 @@ -[![Build Status](http://ci.haun.guru/buildStatus/icon?job=EnchantIcons)](http://ci.haun.guru/job/EnchantIcons/) -## Requirements -* [Gradle installation with gradle binary in PATH](http://www.gradle.org/installation) - - Unlike the source package provided by Forge, this template does not include a gradle wrapper or distribution. - -* NetBeans, IntelliJ 13 or any other IDE which can use a gradle build as a project - - Unlike the source package provided by Forge, this template does not include any eclipse files or project skeleton. You may try to generate one via gradle, but YMMV. - -## Usage -Simply execute `gradle setupDevWorkspace` in the root directory of this repository. Then open it as a `Gradle project` or open build.gradle using your IDE of choice. - -An example mod is included in `.\src\main\java\com\example\examplemod`. To edit the metadata of your mod, edit `.\src\main\resources\mcmod.info`. - -### IDE notes -* **IntelliJ 13** - You will need to additionally run `gradle genIntellijRuns`. This will add the run configurations for Client and Server. -* **NetBeans** - You will need to use the provided `debugClient` task to debug Minecraft. - -## Warnings -Do not execute `gradle setupDecompWorkspace`. Personal experience has shown that this breaks gradle building/usage and takes too long anyway. This is not a nessecary task. - -## Updating -To update to a later version of forge, open `build.gradle` in a text editor and update the `version` line under `minecraft` to the latest Forge version string. Alternatively, pull in and merge any changes from this template repository. - -Finally, execute `gradle setupDevWorkspace --refresh-dependencies`. diff --git a/build.gradle b/build.gradle index f23d6da..24be030 100644 --- a/build.gradle +++ b/build.gradle @@ -1,39 +1,59 @@ -buildscript { - repositories { +buildscript +{ + // Repositories and plugins used by this buildscript. For internal Gradle use only. + repositories + { mavenCentral() - maven { + maven + { name = "forge" url = "http://files.minecraftforge.net/maven" } - maven { + maven + { name = "sonatype" url = "https://oss.sonatype.org/content/repositories/snapshots/" } } - dependencies { + dependencies + { classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' } } +// Applies the custom Gradle plugin Forge uses, for Forge-specific tasks apply plugin: 'forge' -modid = "enchanticons" -version = "0.1.0" -group = "roycurtis.EnchantIcons" - -archivesBaseName = modid +version = "0.1.1" +group = "roycurtis" minecraft { - version = "1.7.10-10.13.0.1180" - assetDir = "eclipse/assets" + version = "1.7.10-10.13.4.1448-1.7.10" + runDir = "debug" } jar { - // Sets the output directory of the mod's jar file. Can be an absolute path to your - // Minecraft mods folder for quicker testing + // Sets the output directory of the mod's jar file destinationDir = file 'output' + classifier "1.7.10" +} + +compileJava +{ + // Enforces use of Java 1.7 language level + sourceCompatibility = "1.7" + targetCompatibility = "1.7" +} + +idea +{ + module + { + // Fixes issues with debugging in IntelliJ + inheritOutputDirs = true + } } processResources @@ -41,20 +61,19 @@ processResources // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version - inputs.property "modid", project.modid // 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, 'modid':project.modid + expand 'version':project.version, 'mcversion':project.minecraft.version } - + // copy everything else, thats not the mcmod.info from(sourceSets.main.resources.srcDirs) - { + { exclude 'mcmod.info' } -} +} \ No newline at end of file diff --git a/src/main/java/roycurtis/EnchantIcons.java b/src/main/java/roycurtis/EnchantIcons.java index 7939494..99c9d17 100644 --- a/src/main/java/roycurtis/EnchantIcons.java +++ b/src/main/java/roycurtis/EnchantIcons.java @@ -4,32 +4,50 @@ import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.init.Items; import net.minecraftforge.client.MinecraftForgeClient; +import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -@Mod(modid = EnchantIcons.MODID, version = EnchantIcons.VERSION) +@Mod( + modid = EnchantIcons.MODID, + name = EnchantIcons.MODID, + version = EnchantIcons.VERSION, + + acceptableRemoteVersions = "*", + acceptableSaveVersions = "" +) public class EnchantIcons { - public static final String MODID = "enchanticons"; + /** Frozen at 0.0.1 to prevent misleading world save error */ public static final String VERSION = "0.0.1"; + public static final String MODID = "enchanticons"; - public static Logger Logger; + public static Logger LOG = LogManager.getFormatterLogger(EnchantIcons.MODID); public static EnchantIconsConfiguration config; @EventHandler - public void preInit(FMLPreInitializationEvent event) + @SideOnly(Side.SERVER) + public void serverPreInit(FMLPreInitializationEvent event) { - Logger = event.getModLog(); - config = new EnchantIconsConfiguration(event.getSuggestedConfigurationFile()); - + LOG.error("This mod is intended only for use on clients"); + LOG.error("Please consider removing this mod from your server installation"); + } + @EventHandler + @SideOnly(Side.CLIENT) + public void clientPreInit(FMLPreInitializationEvent event) + { + config = new EnchantIconsConfiguration(event.getSuggestedConfigurationFile()); } @EventHandler - public void init(FMLInitializationEvent event) + @SideOnly(Side.CLIENT) + public void clientInit(FMLInitializationEvent event) { MinecraftForgeClient.registerItemRenderer( Items.enchanted_book, new EnchantIconsRenderer() ); - Logger.info("Loaded version %s", VERSION); + LOG.info("Loaded version %s", VERSION); } } diff --git a/src/main/java/roycurtis/EnchantIconsConfiguration.java b/src/main/java/roycurtis/EnchantIconsConfiguration.java index 3488ebd..671aa5f 100644 --- a/src/main/java/roycurtis/EnchantIconsConfiguration.java +++ b/src/main/java/roycurtis/EnchantIconsConfiguration.java @@ -1,7 +1,6 @@ package roycurtis; import net.minecraftforge.common.config.Configuration; -import sun.misc.Regexp; import java.io.File; import java.util.HashMap; diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 9b05494..2f59f39 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,13 +1,13 @@ [ { - "modid": "${modid}", - "name": "Enchant Icons", + "modid": "enchanticons", + "name": "EnchantIcons", "description": "Custom renderer for enchanted book items.", "version": "${version}", "mcversion": "${mcversion}", "url": "", "updateUrl": "", - "authors": ["Roy Curtis"], + "authors": ["Roy Curtis", "KJ4IPS"], "credits": "The Forge and FML guys, for making this example", "logoFile": "", "screenshots": [],