diff options
author | makamys <makamys@outlook.com> | 2020-03-10 22:54:52 +0100 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2021-05-06 13:54:48 +0200 |
commit | 02a6aa4a24662815664ad86cb81d2a3f167775d7 (patch) | |
tree | 795fab48832fce98ea12790536504f159fb89470 | |
download | Neodymium-02a6aa4a24662815664ad86cb81d2a3f167775d7.tar.gz Neodymium-02a6aa4a24662815664ad86cb81d2a3f167775d7.tar.bz2 Neodymium-02a6aa4a24662815664ad86cb81d2a3f167775d7.zip |
Initial commit (basic Mixin setup)
-rw-r--r-- | .gitignore | 16 | ||||
-rw-r--r-- | build.gradle | 113 | ||||
-rw-r--r-- | gradle/wrapper/gradle-wrapper.jar | bin | 0 -> 52271 bytes | |||
-rw-r--r-- | gradle/wrapper/gradle-wrapper.properties | 6 | ||||
-rw-r--r-- | gradlew | 164 | ||||
-rw-r--r-- | gradlew.bat | 90 | ||||
-rw-r--r-- | src/main/java/makamys/lodmod/LODMod.java | 45 | ||||
-rw-r--r-- | src/main/java/makamys/lodmod/mixin/IRenderGlobal.java | 26 | ||||
-rw-r--r-- | src/main/java/makamys/lodmod/mixin/MixinSoundManager.java | 22 | ||||
-rw-r--r-- | src/main/resources/lodmod.mixin.json | 11 | ||||
-rw-r--r-- | src/main/resources/mcmod.info | 15 |
11 files changed, 508 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7d8875c --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +.classpath +.metadata +.gradle +.project +.settings +bin/ +build/ +jars/ +run/ +*.iml +*.launch +/.nb-gradle/ + +/*Audio files*/ +*.ogg +*.WAV diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..1536e27 --- /dev/null +++ b/build.gradle @@ -0,0 +1,113 @@ +buildscript { + repositories { + mavenCentral() + jcenter() + maven { + name = "forge" + url = "https://repo.spongepowered.org/repository/forge-proxy/" + } + maven { + name = "sonatype" + url = "https://oss.sonatype.org/content/repositories/snapshots/" + } + } + dependencies { + classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' + // MixinGradle only works with ForgeGradle 2+, so we need to implement it ourselves. + // (Comments mark the lines where this is done.) + //classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT' + } +} + +repositories { + maven { // this has to be here and not in buildscript.repositories, otherwise Gradle won't find mixin <0.8 for some reason + name = 'sponge' + url = 'https://repo.spongepowered.org/maven/' + } +} + +configurations { + embed + compile.extendsFrom(embed) +} + +apply plugin: 'forge' + +version = "0.0" +group= "makamys.lodmod" // http://maven.apache.org/guides/mini/guide-naming-conventions.html +archivesBaseName = "lodmod" + +minecraft { + version = "1.7.10-10.13.4.1614-1.7.10" + runDir = "run" +} + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +dependencies { + embed 'org.spongepowered:mixin:0.7+' + + /* Mixin 0.8 breaks with 1.7.10, but can be made to work by embedding these. However, + doing so overrides the libraries provided by Forge, which will likely result in other mods breaking. */ + //embed 'org.ow2.asm:asm-all:5.2' + //embed 'com.google.guava:guava:21.0' +} + +def outRefMapFile = tasks.compileJava.temporaryDir.toString() + "/lodmod.mixin.refmap.json" // 1.7.10 mixin compatibility + +jar { + manifest { + attributes ( + 'MixinConfigs': 'lodmod.mixin.json', + 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker', + 'TweakOrder': 0, + + // If these two are not set, Forge will not detect the mod, it will only run the mixins + 'FMLCorePluginContainsFMLMod': 'true', + 'ForceLoadAsMod': 'true' + ) + } + + from(sourceSets.main.output); + + from outRefMapFile; // 1.7.10 mixin compatibility + + // embed libraries in jar + from configurations.embed.collect { + exclude '**/LICENSE.txt' + it.isDirectory() ? it : zipTree(it) + } +} + +// 1.7.10 mixin compatibility +def outSrgFile = tasks.compileJava.temporaryDir.toString() + "/outSrg.srg" + +afterEvaluate { + tasks.compileJava.options.compilerArgs += ["-AreobfSrgFile=${tasks.reobf.srg}", "-AoutSrgFile=${outSrgFile}", "-AoutRefMapFile=${outRefMapFile}"]; +} + +reobf { + addExtraSrgFile outSrgFile +} +// end of mixin stuff + +processResources +{ + // this will ensure that this task is redone when the versions change. + inputs.property "version", project.version + inputs.property "mcversion", project.minecraft.version + + // replace stuff in mcmod.info, nothing else + from(sourceSets.main.resources.srcDirs) { + include 'mcmod.info' + + // replace version and mcversion + expand 'version':project.version, 'mcversion':project.minecraft.version + } + + // copy everything else, thats not the mcmod.info + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar Binary files differnew file mode 100644 index 0000000..30d399d --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..0a3dbd5 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Sep 14 12:28:28 PDT 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip @@ -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/src/main/java/makamys/lodmod/LODMod.java b/src/main/java/makamys/lodmod/LODMod.java new file mode 100644 index 0000000..c31a5d7 --- /dev/null +++ b/src/main/java/makamys/lodmod/LODMod.java @@ -0,0 +1,45 @@ +package makamys.lodmod; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.launchwrapper.Launch; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.MinecraftForge; + +import java.nio.IntBuffer; + +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Mod; +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.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; +import makamys.lodmod.mixin.IRenderGlobal; + +@Mod(modid = LODMod.MODID, version = LODMod.VERSION) +public class LODMod +{ + public static final String MODID = "lodmod"; + public static final String VERSION = "0.0"; + + @EventHandler + public void init(FMLInitializationEvent event) + { + FMLCommonHandler.instance().bus().register(this); + } + + @SubscribeEvent + public void onClientTick(ClientTickEvent event) { + + } +} diff --git a/src/main/java/makamys/lodmod/mixin/IRenderGlobal.java b/src/main/java/makamys/lodmod/mixin/IRenderGlobal.java new file mode 100644 index 0000000..d5ac050 --- /dev/null +++ b/src/main/java/makamys/lodmod/mixin/IRenderGlobal.java @@ -0,0 +1,26 @@ +package makamys.lodmod.mixin; + +import java.nio.IntBuffer; +import java.util.ArrayList; +import java.util.List; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.IWorldAccess; + +@Mixin(RenderGlobal.class) +public interface IRenderGlobal { + @Accessor("cloudTickCounter") + int cloudTickCounter(); +}
\ No newline at end of file diff --git a/src/main/java/makamys/lodmod/mixin/MixinSoundManager.java b/src/main/java/makamys/lodmod/mixin/MixinSoundManager.java new file mode 100644 index 0000000..3cdb58b --- /dev/null +++ b/src/main/java/makamys/lodmod/mixin/MixinSoundManager.java @@ -0,0 +1,22 @@ +package makamys.lodmod.mixin; + +import java.util.List; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import net.minecraft.client.audio.SoundManager; + + +@Mixin(SoundManager.class) +abstract class MixinSoundManager { + + @Inject(method = "<init>*", at = @At("RETURN")) + private void onConstructed(CallbackInfo ci) { + System.out.println("(MIXIN EXAMPLE) Running injector mixin for SoundManager constructor!"); + } + + +} diff --git a/src/main/resources/lodmod.mixin.json b/src/main/resources/lodmod.mixin.json new file mode 100644 index 0000000..d8455bf --- /dev/null +++ b/src/main/resources/lodmod.mixin.json @@ -0,0 +1,11 @@ +{ + "required": true, + "minVersion": "0.6", + "package": "makamys.lodmod.mixin", + "refmap": "lodmod.mixin.refmap.json", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "MixinSoundManager", + "IRenderGlobal" + ] +} diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info new file mode 100644 index 0000000..7d06cb6 --- /dev/null +++ b/src/main/resources/mcmod.info @@ -0,0 +1,15 @@ +[ +{ + "modid": "lodmod", + "name": "LOD mod", + "description": "Increases render distance by rendering distant chunks with a low level of detail", + "version": "${version}", + "mcversion": "${mcversion}", + "url": "", + "updateUrl": "", + "authorList": ["makamys"], + "logoFile": "", + "screenshots": [], + "dependencies": [] +} +] |