diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dbef3e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +/bin +/out +/build +/run +/deps/run +/.idea +/eclipse +/.gradle +/*.iml +/*.ipr \ No newline at end of file diff --git a/MMPL-1.0.txt b/MMPL-1.0.txt new file mode 100644 index 0000000..a445a6f --- /dev/null +++ b/MMPL-1.0.txt @@ -0,0 +1,87 @@ +Minecraft Mod Public License +============================ + +Version 1.0.1 + +0. Definitions +-------------- + +Minecraft: Denotes a copy of the Minecraft game licensed by Mojang AB + +User: Anybody that interacts with the software in one of the following ways: + - play + - decompile + - recompile or compile + - modify + - distribute + +Mod: The mod code designated by the present license, in source form, binary +form, as obtained standalone, as part of a wider distribution or resulting from +the compilation of the original or modified sources. + +Dependency: Code required for the mod to work properly. This includes +dependencies required to compile the code as well as any file or modification +that is explicitely or implicitely required for the mod to be working. + +1. Scope +-------- + +The present license is granted to any user of the mod. As a prerequisite, +a user must own a legally acquired copy of Minecraft + +2. Liability +------------ + +This mod is provided 'as is' with no warranties, implied or otherwise. The owner +of this mod takes no responsibility for any damages incurred from the use of +this mod. This mod alters fundamental parts of the Minecraft game, parts of +Minecraft may not work with this mod installed. All damages caused from the use +or misuse of this mad fall on the user. + +3. Play rights +-------------- + +The user is allowed to install this mod on a client or a server and to play +without restriction. + +4. Modification rights +---------------------- + +The user has the right to decompile the source code, look at either the +decompiled version or the original source code, and to modify it. + +5. Derivation rights +-------------------- + +The user has the rights to derive code from this mod, that is to say to +write code that extends or instanciate the mod classes or interfaces, refer to +its objects, or calls its functions. This code is known as "derived" code, and +can be licensed under a license different from this mod. + +6. Distribution of original or modified copy rights +--------------------------------------------------- + +Is subject to distribution rights this entire mod in its various forms. This +include: + - original binary or source forms of this mod files + - modified versions of these binaries or source files, as well as binaries + resulting from source modifications + - patch to its source or binary files + - any copy of a portion of its binary source files + +The user is allowed to redistribute this mod partially, in totality, or +included in a distribution. + +When distributing binary files, the user must provide means to obtain its +entire set of sources or modified sources at no costs. + +All distributions of this mod must remain licensed under the MMPL. + +All dependencies that this mod have on other mods or classes must be licensed +under conditions comparable to this version of MMPL, with the exception of the +Minecraft code and the mod loading framework (e.g. ModLoader, ModLoaderMP or +Bukkit). + +Modified version of binaries and sources, as well as files containing sections +copied from this mod, should be distributed under the terms of the present +license. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4e541b7 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +Mining Ray +========== + +This mod is in pre-alpha state. There are no official builds for now. \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..6dd167c --- /dev/null +++ b/build.gradle @@ -0,0 +1,137 @@ +buildscript { + configurations.all { + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } + repositories { + mavenCentral() + mavenLocal() + maven { + name = "forge" + url = "http://files.minecraftforge.net/maven" + } + maven { + name = "sonatype" + url = "https://oss.sonatype.org/content/repositories/snapshots/" + } + } + dependencies { + classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' + } +} + +apply plugin: 'scala' +apply plugin: 'forge' + +version = "0.0.1" +ext.bdlibver = "1.6.2.41" +ext.versuffix = "mc1710" +ext.apiVer = version + +if (project.hasProperty('buildnum')) { + project.version = project.version + '.' + project.buildnum +} else { + project.version = project.version + '-DEV' +} + +group = "net.bdew" +archivesBaseName = "miner_ray" + +minecraft { + version = "1.7.10-10.13.2.1231" + replace("BDLIB_VER", project.bdlibver) + replace("MINER_RAY_VER", project.version) +} + +repositories { + mavenCentral() + maven { + name = "bdew" + url = "http://jenkins.bdew.net/maven" + } + maven { + name = "chickenbones" + url = "http://chickenbones.net/maven" + } + maven { + name = "ic2" + url = "http://maven.ic2.player.to/" + } + maven { + name "waila" + url "http://mobiusstrip.eu/maven" + } +} + +dependencies { + compile "net.bdew:bdlib:" + bdlibver + compile "net.bdew.thirdparty:CoFHLib:1.7.10R3.0.0.8:api" +} + +import org.apache.tools.ant.filters.ReplaceTokens + +sourceSets { + main { + scala { + srcDir 'src' + } + resources { + srcDir 'resources' + } + output.resourcesDir = output.classesDir // Hack for IDEA + } +} + +processResources { + inputs.property "tokens", minecraft.replacements + from(sourceSets.main.resources.srcDirs) { + include 'mcmod.info' + filter(ReplaceTokens, tokens: minecraft.replacements) + } + + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } +} + +task sourceJar(type: Jar) { +} + +task deobfJar(type: Jar) { + from sourceSets.main.output + exclude "**/*.psd" +} + + +jar { + exclude "**/*.psd" + appendix = project.versuffix +} + +afterEvaluate { project -> + // Fudge the inputs of api/source jars so we get the version after replacements + tasks.getByPath(":sourceJar").from(tasks.getByPath(":sourceMainScala").outputs.files) +} + +artifacts { + archives sourceJar + archives deobfJar +} + +apply plugin: 'maven-publish' + +publishing { + publications { + maven(MavenPublication) { + artifact deobfJar + + artifact sourceJar { + classifier "sources" + } + } + } + repositories { + maven { + url "file://var/www/maven" + } + } +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..b761216 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..678d9d8 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Jul 02 15:54:47 CDT 2014 +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 diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..91a7e26 --- /dev/null +++ b/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# 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 +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +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" +# 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\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +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" ] ; 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, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # 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 + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@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 + +@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= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@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 Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_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=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +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/resources/assets/miner_ray/textures/items/miner.png b/resources/assets/miner_ray/textures/items/miner.png new file mode 100644 index 0000000..64181c6 Binary files /dev/null and b/resources/assets/miner_ray/textures/items/miner.png differ diff --git a/resources/assets/miner_ray/textures/items/miner.psd b/resources/assets/miner_ray/textures/items/miner.psd new file mode 100644 index 0000000..2affb05 Binary files /dev/null and b/resources/assets/miner_ray/textures/items/miner.psd differ diff --git a/resources/mcmod.info b/resources/mcmod.info new file mode 100644 index 0000000..29190fb --- /dev/null +++ b/resources/mcmod.info @@ -0,0 +1,20 @@ +[ +{ + "modid": "miner_ray", + "name": "Miner Ray", + "description": "", + "version": "@MINER_RAY_VER@", + "url": "http://bdew.net/", + "updateUrl": "", + "authorList": [ + "bdew" + ], + "credits": "", + "logoFile": "", + "screenshots": [ + ], + "parent":"", + "dependencies": [ + ] +} +] diff --git a/src/net/bdew/miner/CreativeTabsMiner.scala b/src/net/bdew/miner/CreativeTabsMiner.scala new file mode 100644 index 0000000..cc374b4 --- /dev/null +++ b/src/net/bdew/miner/CreativeTabsMiner.scala @@ -0,0 +1,17 @@ +/* + * Copyright (c) bdew, 2015 + * https://github.com/bdew/miner + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://bdew.net/minecraft-mod-public-license/ + */ + +package net.bdew.miner + +import net.bdew.lib.CreativeTabContainer +import net.bdew.miner.miner.ItemMiner + +object CreativeTabsMiner extends CreativeTabContainer { + val main = new Tab("bdew.miner", ItemMiner) +} diff --git a/src/net/bdew/miner/MinerRay.scala b/src/net/bdew/miner/MinerRay.scala new file mode 100644 index 0000000..4f69b9e --- /dev/null +++ b/src/net/bdew/miner/MinerRay.scala @@ -0,0 +1,54 @@ +/* + * Copyright (c) bdew, 2015 + * https://github.com/bdew/miner + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://bdew.net/minecraft-mod-public-license/ + */ + +package net.bdew.miner + +import java.io.File + +import cpw.mods.fml.client.registry.RenderingRegistry +import cpw.mods.fml.common.Mod +import cpw.mods.fml.common.Mod.EventHandler +import cpw.mods.fml.common.event.{FMLInitializationEvent, FMLPostInitializationEvent, FMLPreInitializationEvent} +import cpw.mods.fml.common.registry.EntityRegistry +import net.bdew.miner.config.Config +import net.bdew.miner.config.loader.TuningLoader +import net.bdew.miner.miner.{EntityMinerRay, RenderMinerRay} +import org.apache.logging.log4j.Logger + +@Mod(modid = MinerRay.modId, version = "MINER_RAY_VER", name = "Miner Ray", dependencies = "required-after:bdlib", modLanguage = "scala") +object MinerRay { + var log: Logger = null + var instance = this + + final val modId = "miner_ray" + + var configDir: File = null + + def logInfo(msg: String, args: Any*) = log.info(msg.format(args: _*)) + def logWarn(msg: String, args: Any*) = log.warn(msg.format(args: _*)) + + @EventHandler + def preInit(event: FMLPreInitializationEvent) { + log = event.getModLog + configDir = new File(event.getModConfigurationDirectory, "MinerRay") + TuningLoader.loadConfigFiles() + Config.load() + } + + @EventHandler + def init(event: FMLInitializationEvent): Unit = { + EntityRegistry.registerModEntity(classOf[EntityMinerRay], "bdewMinerRay", 1, this, 64, 1, true) + RenderingRegistry.registerEntityRenderingHandler(classOf[EntityMinerRay], new RenderMinerRay) + } + + @EventHandler + def postInit(event: FMLPostInitializationEvent): Unit = { + TuningLoader.loadDelayed() + } +} \ No newline at end of file diff --git a/src/net/bdew/miner/config/Config.scala b/src/net/bdew/miner/config/Config.scala new file mode 100644 index 0000000..ec716cd --- /dev/null +++ b/src/net/bdew/miner/config/Config.scala @@ -0,0 +1,20 @@ +/* + * Copyright (c) bdew, 2015 + * https://github.com/bdew/miner + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://bdew.net/minecraft-mod-public-license/ + */ + +package net.bdew.miner.config + +import net.bdew.lib.gui.GuiHandler + +object Config { + val guiHandler = new GuiHandler + + def load() { + Items.load() + } +} \ No newline at end of file diff --git a/src/net/bdew/miner/config/Items.scala b/src/net/bdew/miner/config/Items.scala new file mode 100644 index 0000000..b2799a7 --- /dev/null +++ b/src/net/bdew/miner/config/Items.scala @@ -0,0 +1,18 @@ +/* + * Copyright (c) bdew, 2015 + * https://github.com/bdew/miner + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://bdew.net/minecraft-mod-public-license/ + */ + +package net.bdew.miner.config + +import net.bdew.lib.config.ItemManager +import net.bdew.miner.CreativeTabsMiner +import net.bdew.miner.miner.ItemMiner + +object Items extends ItemManager(CreativeTabsMiner.main) { + regItem(ItemMiner) +} \ No newline at end of file diff --git a/src/net/bdew/miner/config/Tuning.scala b/src/net/bdew/miner/config/Tuning.scala new file mode 100644 index 0000000..233f255 --- /dev/null +++ b/src/net/bdew/miner/config/Tuning.scala @@ -0,0 +1,25 @@ +/* + * Copyright (c) bdew, 2015 + * https://github.com/bdew/miner + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://bdew.net/minecraft-mod-public-license/ + */ + +package net.bdew.miner.config + +import net.bdew.lib.recipes.gencfg.ConfigSection + +object Tuning extends ConfigSection + + + + + + + + + + + diff --git a/src/net/bdew/miner/config/loader/Loader.scala b/src/net/bdew/miner/config/loader/Loader.scala new file mode 100644 index 0000000..36f3485 --- /dev/null +++ b/src/net/bdew/miner/config/loader/Loader.scala @@ -0,0 +1,18 @@ +/* + * Copyright (c) bdew, 2015 + * https://github.com/bdew/miner + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://bdew.net/minecraft-mod-public-license/ + */ + +package net.bdew.miner.config.loader + +import net.bdew.lib.recipes.RecipeLoader +import net.bdew.lib.recipes.gencfg.GenericConfigLoader +import net.bdew.miner.config.Tuning + +class Loader extends RecipeLoader with GenericConfigLoader { + val cfgStore = Tuning +} diff --git a/src/net/bdew/miner/config/loader/Parser.scala b/src/net/bdew/miner/config/loader/Parser.scala new file mode 100644 index 0000000..21f7ef2 --- /dev/null +++ b/src/net/bdew/miner/config/loader/Parser.scala @@ -0,0 +1,15 @@ +/* + * Copyright (c) bdew, 2015 + * https://github.com/bdew/miner + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://bdew.net/minecraft-mod-public-license/ + */ + +package net.bdew.miner.config.loader + +import net.bdew.lib.recipes.RecipeParser +import net.bdew.lib.recipes.gencfg.GenericConfigParser + +class Parser extends RecipeParser with GenericConfigParser diff --git a/src/net/bdew/miner/config/loader/TuningLoader.scala b/src/net/bdew/miner/config/loader/TuningLoader.scala new file mode 100644 index 0000000..fb5b2fb --- /dev/null +++ b/src/net/bdew/miner/config/loader/TuningLoader.scala @@ -0,0 +1,39 @@ +/* + * Copyright (c) bdew, 2015 + * https://github.com/bdew/miner + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://bdew.net/minecraft-mod-public-license/ + */ + +package net.bdew.miner.config.loader + +import java.io.{File, FileWriter} + +import net.bdew.lib.recipes.RecipesHelper +import net.bdew.miner.MinerRay + +object TuningLoader { + val loader = new Loader + + def loadDelayed() = loader.processRecipeStatements() + + def loadConfigFiles() { + if (!MinerRay.configDir.exists()) { + MinerRay.configDir.mkdir() + val nl = System.getProperty("line.separator") + val f = new FileWriter(new File(MinerRay.configDir, "readme.txt")) + f.write("Any .cfg files in this directory will be loaded after the internal configuration, in alphabetic order" + nl) + f.write("Files in 'overrides' directory with matching names cab be used to override internal configuration" + nl) + f.close() + } + + RecipesHelper.loadConfigs( + modName = "Miner Ray", + listResource = "/assets/miner_ray/config/files.lst", + configDir = MinerRay.configDir, + resBaseName = "/assets/miner_ray/config/", + loader = loader) + } +} diff --git a/src/net/bdew/miner/miner/EntityMinerRay.scala b/src/net/bdew/miner/miner/EntityMinerRay.scala new file mode 100644 index 0000000..3e66e68 --- /dev/null +++ b/src/net/bdew/miner/miner/EntityMinerRay.scala @@ -0,0 +1,92 @@ +/* + * Copyright (c) bdew, 2015 + * https://github.com/bdew/miner + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://bdew.net/minecraft-mod-public-license/ + */ + +package net.bdew.miner.miner + +import net.bdew.lib.items.ItemUtils +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.entity.projectile.EntityThrowable +import net.minecraft.nbt.NBTTagCompound +import net.minecraft.util.{MathHelper, MovingObjectPosition} +import net.minecraft.world.World + +class EntityMinerRay(w: World) extends EntityThrowable(w) { + var ttl = 10 + var aoe = 1 + var owner: EntityPlayer = null + + def this(p: EntityPlayer) = { + this(p.worldObj) + + owner = p + + // code stolen from EntityThrowable ctor because we can't call it from scala... + this.setSize(0.25F, 0.25F) + this.setLocationAndAngles(p.posX, p.posY + p.getEyeHeight.toDouble, p.posZ, p.rotationYaw, p.rotationPitch) + this.posX -= (MathHelper.cos(this.rotationYaw / 180.0F * Math.PI.toFloat) * 0.16F).toDouble + this.posY -= 0.10000000149011612D + this.posZ -= (MathHelper.sin(this.rotationYaw / 180.0F * Math.PI.toFloat) * 0.16F).toDouble + this.setPosition(this.posX, this.posY, this.posZ) + this.yOffset = 0.0F + val f = 0.4F + this.motionX = (-MathHelper.sin(this.rotationYaw / 180.0F * Math.PI.toFloat) * MathHelper.cos(this.rotationPitch / 180.0F * Math.PI.toFloat) * f).toDouble + this.motionZ = (MathHelper.cos(this.rotationYaw / 180.0F * Math.PI.toFloat) * MathHelper.cos(this.rotationPitch / 180.0F * Math.PI.toFloat) * f).toDouble + this.motionY = (-MathHelper.sin((this.rotationPitch + this.func_70183_g) / 180.0F * Math.PI.toFloat) * f).toDouble + this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, this.func_70182_d, 1.0F) + } + + override def getGravityVelocity = 0 + protected override def func_70182_d = 1.5F + protected override def func_70183_g = 0F + + override def onUpdate() = { + super.onUpdate() + ttl -= 1 + if (ttl <= 0) { + setDead() + } + } + + override def onImpact(pos: MovingObjectPosition) = { + import scala.collection.JavaConversions._ + if (pos.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + if (!worldObj.isRemote && owner != null) { + val dropsList = for { + x <- (pos.blockX - aoe) to (pos.blockX + aoe) + y <- (pos.blockY - aoe) to (pos.blockY + aoe) + z <- (pos.blockZ - aoe) to (pos.blockZ + aoe) + } yield { + val bl = worldObj.getBlock(x, y, z) + if (bl == null || bl.getBlockHardness(worldObj, x, y, z) < 0 || bl.hasTileEntity(worldObj.getBlockMetadata(x, y, z))) { + List.empty + } else { + val drops = bl.getDrops(worldObj, x, y, z, worldObj.getBlockMetadata(x, y, z), 0) + worldObj.setBlockToAir(x, y, z) + drops.toList + } + } + for (item <- dropsList.flatten) + ItemUtils.dropItemToPlayer(worldObj, owner, item) + worldObj.createExplosion(null, posX, posY, posZ, 0, true) + } + setDead() + } + } + override def writeEntityToNBT(tag: NBTTagCompound): Unit = { + super.writeEntityToNBT(tag) + tag.setInteger("aoe", aoe) + tag.setInteger("ttl", ttl) + } + + override def readEntityFromNBT(tag: NBTTagCompound): Unit = { + super.readEntityFromNBT(tag) + aoe = tag.getInteger("aoe") + ttl = tag.getInteger("ttl") + } +} diff --git a/src/net/bdew/miner/miner/ItemMiner.scala b/src/net/bdew/miner/miner/ItemMiner.scala new file mode 100644 index 0000000..d57494e --- /dev/null +++ b/src/net/bdew/miner/miner/ItemMiner.scala @@ -0,0 +1,27 @@ +/* + * Copyright (c) bdew, 2015 + * https://github.com/bdew/miner + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://bdew.net/minecraft-mod-public-license/ + */ + +package net.bdew.miner.miner + +import net.bdew.lib.items.SimpleItem +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.item.ItemStack +import net.minecraft.world.World + +object ItemMiner extends SimpleItem("Miner") { + override def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer) = { + if (!world.isRemote) + world.spawnEntityInWorld(new EntityMinerRay(player)) + stack + } + + override def onItemUse(stack: ItemStack, player: EntityPlayer, world: World, x: Int, y: Int, z: Int, side: Int, xOff: Float, yOff: Float, zOff: Float): Boolean = { + false + } +} diff --git a/src/net/bdew/miner/miner/RenderMinerRay.scala b/src/net/bdew/miner/miner/RenderMinerRay.scala new file mode 100644 index 0000000..6e5b162 --- /dev/null +++ b/src/net/bdew/miner/miner/RenderMinerRay.scala @@ -0,0 +1,89 @@ +/* + * Copyright (c) bdew, 2015 + * https://github.com/bdew/miner + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://bdew.net/minecraft-mod-public-license/ + */ + +package net.bdew.miner.miner + +import net.minecraft.client.renderer.entity.Render +import net.minecraft.client.renderer.texture.TextureMap +import net.minecraft.client.renderer.{OpenGlHelper, Tessellator} +import net.minecraft.entity.Entity +import org.lwjgl.opengl.GL11 + +class RenderMinerRay extends Render { + def doRender(entity: Entity, x: Double, y: Double, z: Double, p1: Float, subFrame: Float) { + this.bindEntityTexture(entity) + GL11.glPushMatrix() + GL11.glTranslatef(x.toFloat, y.toFloat, z.toFloat) + GL11.glRotatef(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * subFrame - 90.0F, 0.0F, 1.0F, 0.0F) + GL11.glRotatef(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * subFrame, 0.0F, 0.0F, 1.0F) + + val T = Tessellator.instance + val scale = 9 / 160F + val L = 8D + val W = 0.5D + + GL11.glScalef(scale, scale, scale) + GL11.glTranslatef(-4.0F, 0.0F, 0.0F) + GL11.glColor3f(1F, 0F, 0F) + + GL11.glDisable(GL11.GL_LIGHTING) + GL11.glDisable(GL11.GL_TEXTURE_2D) + + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 61680, 0) + + T.startDrawingQuads() + T.addVertex(-L, -W, W) + T.addVertex(L, -W, W) + T.addVertex(L, W, W) + T.addVertex(-L, W, W) + T.draw() + + T.startDrawingQuads() + T.addVertex(L, W, -W) + T.addVertex(L, -W, -W) + T.addVertex(-L, -W, -W) + T.addVertex(-L, W, -W) + T.draw() + + T.startDrawingQuads() + T.addVertex(-L, -W, -W) + T.addVertex(L, -W, -W) + T.addVertex(L, -W, W) + T.addVertex(-L, -W, W) + T.draw() + + T.startDrawingQuads() + T.addVertex(L, W, W) + T.addVertex(L, W, -W) + T.addVertex(-L, W, -W) + T.addVertex(-L, W, W) + T.draw() + + T.startDrawingQuads() + T.addVertex(-L, W, W) + T.addVertex(-L, W, -W) + T.addVertex(-L, -W, -W) + T.addVertex(-L, -W, W) + T.draw() + + T.startDrawingQuads() + T.addVertex(L, -W, -W) + T.addVertex(L, W, -W) + T.addVertex(L, W, W) + T.addVertex(L, -W, W) + T.draw() + + GL11.glColor3f(1F, 1F, 1F) + GL11.glEnable(GL11.GL_TEXTURE_2D) + GL11.glEnable(GL11.GL_LIGHTING) + GL11.glPopMatrix() + } + + override def getEntityTexture(e: Entity) = TextureMap.locationItemsTexture +}