diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ccfb361 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +.gradle +.settings +/.idea/ +/run/ +/build/ +/eclipse/ +.classpath +.project +/bin/ +/config/ +/crash-reports/ +/logs/ +options.txt +/saves/ +usernamecache.json +banned-ips.json +banned-players.json +eula.txt +ops.json +server.properties +servers.dat +usercache.json +whitelist.json +world/ +/out/ +*.iml +*.ipr +*.iws diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..7debf44 --- /dev/null +++ b/build.gradle @@ -0,0 +1,256 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation +import java.util.concurrent.TimeUnit + +buildscript { + repositories { + maven { + name = "jitpack" + url = "https://jitpack.io" + } + maven { + name = "forge" + url = "https://maven.minecraftforge.net" + } + maven { + name = "sonatype" + url = "https://oss.sonatype.org/content/repositories/snapshots/" + } + } + dependencies { + classpath 'com.github.SinTh0r4s:ForgeGradle:FG_1.2-SNAPSHOT' + } +} + +plugins { + id("org.ajoberstar.grgit") version("3.1.1") + id("com.github.johnrengelman.shadow") version("4.0.4") + id("com.palantir.git-version") version("0.12.3") +} + +apply plugin: 'forge' +apply plugin: 'idea' + +idea { + module { + inheritOutputDirs = true + downloadJavadoc = true + downloadSources = true + } +} + +configurations.all { + resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS) +} + +// Pulls version from git tag +version = minecraftVersion + "-" + gitVersion() +group = modGroup +archivesBaseName = modId + +minecraft { + if(JavaVersion.current() != JavaVersion.VERSION_1_8) { + throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current()) + } + + version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion + runDir = "run" + + if (replaceGradleTokenInFile) { + replaceIn replaceGradleTokenInFile + if(gradleTokenModId) { + replace gradleTokenModId, modId + } + if(gradleTokenModName) { + replace gradleTokenModName, modName + } + if(gradleTokenModName) { + replace gradleTokenVersion, versionDetails().lastTag + } + if(gradleTokenGroupName) { + replace gradleTokenGroupName, modGroup + } + } +} + +apply from: 'repositories.gradle' + +configurations { + implementation.extendsFrom(shadowImplementation) +} + +repositories { + if(usesMixins.toBoolean()) { + maven { + name = "sponge" + url = "https://repo.spongepowered.org/repository/maven-public" + } + maven { + url = "https://jitpack.io" + } + } +} + +dependencies { + if(usesMixins.toBoolean()) { + annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3") + annotationProcessor("com.google.guava:guava:24.1.1-jre") + annotationProcessor("com.google.code.gson:gson:2.8.6") + annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT") + // using 0.8 to workaround a issue in 0.7 which fails mixin application + compile("org.spongepowered:mixin:0.7.11-SNAPSHOT") { + // Mixin includes a lot of dependencies that are too up-to-date + exclude module: "launchwrapper" + exclude module: "guava" + exclude module: "gson" + exclude module: "commons-io" + exclude module: "log4j-core" + } + compile("com.github.GTNewHorizons:SpongeMixins:1.3.3:dev") + } +} + +apply from: 'dependencies.gradle' + +task relocateShadowJar(type: ConfigureShadowRelocation) { + target = tasks.shadowJar + prefix = modGroup + ".shadow" +} + +def mixinConfigJson = "mixins." + modId + ".json" +def mixingConfigRefMap = "mixins." + modId + ".refmap.json" +def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap +def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg" + +shadowJar { + if(usesMixins.toBoolean()) { + from refMap + manifest { + attributes([ + "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", + "MixinConfigs" : mixinConfigJson, + "FMLCorePluginContainsFMLMod": true, + "ForceLoadAsMod" : loadNormalModAfterApplingMixins.toBoolean() + ]) + } + } + + minimize() + configurations = [project.configurations.shadowImplementation] + dependsOn(relocateShadowJar) +} + +jar { + if(usesMixins.toBoolean()) { + from refMap + manifest { + attributes([ + "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", + "MixinConfigs" : mixinConfigJson, + "FMLCorePluginContainsFMLMod": true, + "ForceLoadAsMod" : loadNormalModAfterApplingMixins.toBoolean() + ]) + } + } + + if(usesShadowedDependencies.toBoolean()) { + dependsOn(shadowJar) + enabled = false + } +} + +reobf { + if(usesMixins.toBoolean()) { + addExtraSrgFile mixinSrg + } +} + +afterEvaluate { + if(usesMixins.toBoolean()) { + tasks.compileJava { + options.compilerArgs += [ + "-AreobfSrgFile=${tasks.reobf.srg}", + "-AoutSrgFile=${mixinSrg}", + "-AoutRefMapFile=${refMap}", + // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code + "-XDenableSunApiLintControl", + "-XDignore.symbol.file" + ] + } + } +} + +runClient { + args "--mods=../build/libs/$modId-${version}.jar", + usesMixins.toBoolean() ? "--tweakClass org.spongepowered.asm.launch.MixinTweaker" : "", + developmentEnvironmentUserName.isEmpty() == false ? "--username": "", + developmentEnvironmentUserName.isEmpty() == false ? developmentEnvironmentUserName : "" +} + +runServer { + args "",//"--mods=../build/libs/$modId-${version}.jar", + usesMixins.toBoolean() ? "--tweakClass org.spongepowered.asm.launch.MixinTweaker" : "" + +} + +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 "minecraftVersion": project.minecraft.version, + "modVersion": versionDetails().lastTag, + "modId": modId, + "modName": modName, + "modDescription": modDescription, + "modUrl": modUrl, + "modCredits": modCredits + } + + // copy everything else, thats not the mcmod.info + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } +} + +task sourcesJar(type: Jar) { + from (sourceSets.main.allJava) + from (file("$projectDir/LICENSE")) + + getArchiveClassifier().set('sources') +} + +task devJar(type: Jar) { + from sourceSets.main.output + archiveClassifier.set("dev") +} + +task apiJar(type: Jar) { + from (sourceSets.main.allJava) { + include apiPackage + '/**' + } + + from (sourceSets.main.output) { + include apiPackage + '/**' + } + + from (sourceSets.main.resources.srcDirs) { + include("LICENSE") + } + + getArchiveClassifier().set('api') +} + + +artifacts { + archives sourcesJar + archives devJar + if(apiPackage.isEmpty() == false) { + archives apiJar + } +} diff --git a/dependencies.gradle b/dependencies.gradle new file mode 100644 index 0000000..c136bbe --- /dev/null +++ b/dependencies.gradle @@ -0,0 +1,3 @@ +dependencies { + +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..9278f88 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,50 @@ +# This is a case-sensitive string to identify your mod. Convention is to use lower case. +modId = mymod + +# The Information about your mod +modName = MyMod +modDescription = An example mod for Minecraft 1.7.10 with Forge focussed on a stable setup. +modUrl = https://github.com/SinTh0r4s/MyMod +modCredits = + +# Is it used somewhere else but shadow packet name generation? +modGroup = com.myname.mymodid + +minecraftVersion = 1.7.10 +forgeVersion = 10.13.4.1614 + +# Define a source file of your project with: +# public static final String VERSION = "GRADLETOKEN_VERSION"; +# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's +# version in @Mod([...], version = VERSION, [...]) +# Leave these properties empty to skip individual token replacements +replaceGradleTokenInFile = Tags.java +gradleTokenModId = GRADLETOKEN_MODID +gradleTokenModName = GRADLETOKEN_MODNAME +gradleTokenVersion = GRADLETOKEN_VERSION +gradleTokenGroupName = GRADLETOKEN_GROUPNAME + +# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can +# leave this property empty. Please use file notations! +# Example value: com/myname/mymod/api +apiPackage = + +# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled! +usesMixins = true +# If your project contains a mod next to a mixin you want this to be true. Only if you provide a lone collections +# of mixins you set this parameter to false. Is ignored when usesMixins = false. +loadNormalModAfterApplingMixins = true + +# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your +# responsibility check the licence and request permission for distribution, if required. +usesShadowedDependencies = false + +# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you +# restart Minecraft in development. Choose this dependent on your mod: +# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name +# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty +developmentEnvironmentUserName = "Developer" + +# Make sure GregTech build won't time out +systemProp.org.gradle.internal.http.connectionTimeout = 120000 +systemProp.org.gradle.internal.http.socketTimeout = 120000 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..5c2d1cf Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..5028f28 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..83f2acf --- /dev/null +++ b/gradlew @@ -0,0 +1,188 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..9618d8d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,100 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..09bbb51 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,2 @@ +before_install: + - ./gradlew setupCIWorkspace \ No newline at end of file diff --git a/repositories.gradle b/repositories.gradle new file mode 100644 index 0000000..826a17f --- /dev/null +++ b/repositories.gradle @@ -0,0 +1,3 @@ +repositories { + +} diff --git a/src/main/java/com/myname/mymodid/ClientProxy.java b/src/main/java/com/myname/mymodid/ClientProxy.java new file mode 100644 index 0000000..5c5252b --- /dev/null +++ b/src/main/java/com/myname/mymodid/ClientProxy.java @@ -0,0 +1,43 @@ +package com.myname.mymodid; + +import cpw.mods.fml.common.event.*; + +public class ClientProxy extends CommonProxy { + + // preInit "Run before anything else. Read your config, create blocks, items, + // etc, and register them with the GameRegistry." + public void preInit(FMLPreInitializationEvent event) { + super.preInit(event); + } + + // load "Do your mod setup. Build whatever data structures you care about. Register recipes." + public void init(FMLInitializationEvent event) { + super.init(event); + } + + // postInit "Handle interaction with other mods, complete your setup based on this." + public void postInit(FMLPostInitializationEvent event) { + super.postInit(event); + } + + public void serverAboutToStart(FMLServerAboutToStartEvent event) { + super.serverAboutToStart(event); + } + + // register server commands in this event handler + public void serverStarting(FMLServerStartingEvent event) { + super.serverStarting(event); + } + + public void serverStarted(FMLServerStartedEvent event) { + super.serverStarted(event); + } + + public void serverStopping(FMLServerStoppingEvent event) { + super.serverStopping(event); + } + + public void serverStopped(FMLServerStoppedEvent event) { + super.serverStopped(event); + } +} \ No newline at end of file diff --git a/src/main/java/com/myname/mymodid/CommonProxy.java b/src/main/java/com/myname/mymodid/CommonProxy.java new file mode 100644 index 0000000..5c5ef7d --- /dev/null +++ b/src/main/java/com/myname/mymodid/CommonProxy.java @@ -0,0 +1,46 @@ +package com.myname.mymodid; + +import cpw.mods.fml.common.event.*; + +public class CommonProxy { + + // preInit "Run before anything else. Read your config, create blocks, items, + // etc, and register them with the GameRegistry." + public void preInit(FMLPreInitializationEvent event) { + Config.syncronizeConfiguration(event.getSuggestedConfigurationFile()); + + MyMod.info(Config.greeting); + MyMod.info("I am " + Tags.MODNAME + " at version " + Tags.VERSION + " and group name " + Tags.GROUPNAME); + } + + // load "Do your mod setup. Build whatever data structures you care about. Register recipes." + public void init(FMLInitializationEvent event) { + + } + + // postInit "Handle interaction with other mods, complete your setup based on this." + public void postInit(FMLPostInitializationEvent event) { + + } + + public void serverAboutToStart(FMLServerAboutToStartEvent event) { + + } + + // register server commands in this event handler + public void serverStarting(FMLServerStartingEvent event) { + + } + + public void serverStarted(FMLServerStartedEvent event) { + + } + + public void serverStopping(FMLServerStoppingEvent event) { + + } + + public void serverStopped(FMLServerStoppedEvent event) { + + } +} \ No newline at end of file diff --git a/src/main/java/com/myname/mymodid/Config.java b/src/main/java/com/myname/mymodid/Config.java new file mode 100644 index 0000000..09a54f3 --- /dev/null +++ b/src/main/java/com/myname/mymodid/Config.java @@ -0,0 +1,31 @@ +package com.myname.mymodid; + +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; + +import java.io.File; + +public class Config { + + private static class Defaults { + public static final String greeting = "Hello World"; + } + + private static class Categories { + public static final String general = "general"; + } + + public static String greeting = Defaults.greeting; + + public static void syncronizeConfiguration(File configFile) { + Configuration configuration = new Configuration(configFile); + configuration.load(); + + Property greetingProperty = configuration.get(Categories.general, "greeting", Defaults.greeting, "How shall I greet?"); + greeting = greetingProperty.getString(); + + if(configuration.hasChanged()) { + configuration.save(); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/myname/mymodid/MyMod.java b/src/main/java/com/myname/mymodid/MyMod.java new file mode 100644 index 0000000..9f9618c --- /dev/null +++ b/src/main/java/com/myname/mymodid/MyMod.java @@ -0,0 +1,77 @@ +package com.myname.mymodid; + +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.*; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@Mod(modid = Tags.MODID, version = Tags.VERSION, name = Tags.MODNAME, acceptedMinecraftVersions = "[1.7.10]") +public class MyMod { + + private static Logger LOG = LogManager.getLogger(Tags.MODID); + + @SidedProxy(clientSide= Tags.GROUPNAME + ".ClientProxy", serverSide=Tags.GROUPNAME + ".CommonProxy") + public static CommonProxy proxy; + + @Mod.EventHandler + // preInit "Run before anything else. Read your config, create blocks, items, + // etc, and register them with the GameRegistry." + public void preInit(FMLPreInitializationEvent event) { + proxy.preInit(event); + } + + @Mod.EventHandler + // load "Do your mod setup. Build whatever data structures you care about. Register recipes." + public void init(FMLInitializationEvent event) { + proxy.init(event); + } + + @Mod.EventHandler + // postInit "Handle interaction with other mods, complete your setup based on this." + public void postInit(FMLPostInitializationEvent event) { + proxy.postInit(event); + } + + @Mod.EventHandler + public void serverAboutToStart(FMLServerAboutToStartEvent event) { + proxy.serverAboutToStart(event); + } + + @Mod.EventHandler + // register server commands in this event handler + public void serverStarting(FMLServerStartingEvent event) { + proxy.serverStarting(event); + } + + @Mod.EventHandler + public void serverStarted(FMLServerStartedEvent event) { + proxy.serverStarted(event); + } + + @Mod.EventHandler + public void serverStopping(FMLServerStoppingEvent event) { + proxy.serverStopping(event); + } + + @Mod.EventHandler + public void serverStopped(FMLServerStoppedEvent event) { + proxy.serverStopped(event); + } + + public static void debug(String message) { + LOG.debug(message); + } + + public static void info(String message) { + LOG.info(message); + } + + public static void warn(String message) { + LOG.warn(message); + } + + public static void error(String message) { + LOG.error(message); + } +} \ No newline at end of file diff --git a/src/main/java/com/myname/mymodid/Tags.java b/src/main/java/com/myname/mymodid/Tags.java new file mode 100644 index 0000000..35e4910 --- /dev/null +++ b/src/main/java/com/myname/mymodid/Tags.java @@ -0,0 +1,9 @@ +package com.myname.mymodid; + +public class Tags { + + public static final String MODID = "GRADLETOKEN_MODID"; + public static final String MODNAME = "GRADLETOKEN_MODNAME"; + public static final String VERSION = "GRADLETOKEN_VERSION"; + public static final String GROUPNAME = "GRADLETOKEN_GROUPNAME"; +} \ No newline at end of file diff --git a/src/main/java/com/myname/mymodid/mixinplugin/MixinPlugin.java b/src/main/java/com/myname/mymodid/mixinplugin/MixinPlugin.java new file mode 100644 index 0000000..379b0b1 --- /dev/null +++ b/src/main/java/com/myname/mymodid/mixinplugin/MixinPlugin.java @@ -0,0 +1,92 @@ +package com.myname.mymodid.mixinplugin; + +import com.myname.mymodid.Tags; +import cpw.mods.fml.relauncher.FMLLaunchHandler; +import net.minecraft.launchwrapper.Launch; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.spongepowered.asm.lib.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; +import ru.timeconqueror.spongemixins.MinecraftURLClassPath; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +public class MixinPlugin implements IMixinConfigPlugin { + + private static Logger LOG = LogManager.getLogger(Tags.MODID); + + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + return true; + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + final boolean loadClientSideOnlyClasses = FMLLaunchHandler.side().isClient(); + final boolean isDevelopmentEnvironment = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); + + List mixins = new ArrayList<>(); + mixins.add("minecraft.ItemEditableBookMixin"); + + if(isDevelopmentEnvironment || loadJar("gregtech")) { + LOG.info("Found GregTech! Integrating now..."); + //mixins.add("gregtech.SOMEGTMIXINEXAMPLE"); + } + else { + LOG.info("Could not find GregTech! Skipping integration...."); + } + + return mixins; + } + + private boolean loadJar(final String jarNameBeginsWith) { + try { + File jar = MinecraftURLClassPath.getJarInModPath(jarNameBeginsWith); + if(jar == null) { + LOG.info("Jar not found: " + jarNameBeginsWith); + return false; + } + + LOG.info("Attempting to add " + jar.toString() + " to the URL Class Path"); + if(!jar.exists()) { + throw new FileNotFoundException(jar.toString()); + } + MinecraftURLClassPath.addJar(jar); + return true; + } + catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} \ No newline at end of file diff --git a/src/main/java/com/myname/mymodid/mixins/minecraft/ItemEditableBookMixin.java b/src/main/java/com/myname/mymodid/mixins/minecraft/ItemEditableBookMixin.java new file mode 100644 index 0000000..268227a --- /dev/null +++ b/src/main/java/com/myname/mymodid/mixins/minecraft/ItemEditableBookMixin.java @@ -0,0 +1,24 @@ +package com.myname.mymodid.mixins.minecraft; + +import com.myname.mymodid.MyMod; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemEditableBook; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +@Mixin(value = ItemEditableBook.class) +public class ItemEditableBookMixin { + + @Inject(method = "onItemRightClick", + at = @At("HEAD"), + require = 1, + locals = LocalCapture.CAPTURE_FAILEXCEPTION) + private void onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer, CallbackInfoReturnable callbackInfoReturnable) { + MyMod.info("You are reading a book"); + } +} \ No newline at end of file diff --git a/src/main/resources/LICENSE b/src/main/resources/LICENSE new file mode 100644 index 0000000..63b4b68 --- /dev/null +++ b/src/main/resources/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) [year] [fullname] + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info new file mode 100644 index 0000000..8ceacb7 --- /dev/null +++ b/src/main/resources/mcmod.info @@ -0,0 +1,16 @@ +[ + { + "modid": "${modId}", + "name": "${modName}", + "description": "${modDescription}", + "version": "${modVersion}", + "mcversion": "${minecraftVersion}", + "url": "${modUrl}", + "updateUrl": "", + "authorList": ["MyName"], + "credits": "${modCredits}", + "logoFile": "", + "screenshots": [], + "dependencies": [] + } +] diff --git a/src/main/resources/mixins.mymod.json b/src/main/resources/mixins.mymod.json new file mode 100644 index 0000000..100545f --- /dev/null +++ b/src/main/resources/mixins.mymod.json @@ -0,0 +1,9 @@ +{ + "required": true, + "minVersion": "0.7.11", + "package": "com.myname.mymodid.mixins", + "plugin": "com.myname.mymodid.mixinplugin.MixinPlugin", + "refmap": "mixins.mymodid.refmap.json", + "target": "@env(DEFAULT)", + "compatibilityLevel": "JAVA_8" +}