Fixed LiteLoader compatibility, remade ForceModLoader into ForceForgeOnRenderTick, added some gradle stuff to the repo. 2.4.1

This commit is contained in:
Ivan Molodetskikh committed 2014-03-09 18:08:01 +04:00
1 parent 4a0fd23ba7
commit 2682b52f76
11 files changed
+453 -93

No files matched your search

+6 -1
View File
@@ -17,7 +17,7 @@ buildscript {
apply plugin: 'forge'
version = "2.4.0"
version = "2.4.1"
group= "yalter.mousetweaks" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "MouseTweaks"
@@ -30,6 +30,7 @@ processResources
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
include 'litemod.json'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
@@ -38,23 +39,27 @@ processResources
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
exclude 'litemod.json'
}
}
// Thanks to the IronChest repository for those.
jar {
exclude 'com/**'
version = "${project.minecraft.version}-${project.version}"
}
task sourceJar(type: Jar) {
from sourceSets.main.allSource
exclude 'com/**'
classifier = 'src'
version = "${project.minecraft.version}-${project.version}"
}
task deobfJar(type: Jar) {
from sourceSets.main.output
exclude 'com/**'
classifier = 'deobf'
version = "${project.minecraft.version}-${project.version}"
}
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
#Sat Mar 08 15:45:41 MSK 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip
Vendored
+164
View File
@@ -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 "$@"
Vendored
+90
View File
@@ -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
@@ -7,7 +7,7 @@ public class Constants
public static final String NAME = "Mouse Tweaks";
// Mod version
public static final String VERSION = "2.4.0";
public static final String VERSION = "2.4.1";
// Obfuscated names
public static final String ISMOUSEOVERSLOT_NAME = "a";
@@ -0,0 +1,70 @@
package yalter.mousetweaks;
import java.io.File;
import net.minecraft.client.gui.GuiScreen;
import com.mumfrey.liteloader.RenderListener;
public class LiteModMouseTweaks implements RenderListener
{
private static LiteModMouseTweaks instance;
public static LiteModMouseTweaks getInstance()
{
if ( instance == null )
{
instance = new LiteModMouseTweaks();
}
return instance;
}
public LiteModMouseTweaks()
{
}
@Override
public String getName()
{
return Constants.NAME;
}
@Override
public String getVersion()
{
return Constants.VERSION;
}
@Override
public void onRender()
{
Main.onUpdateInGame();
}
@Override
public void onRenderGui( GuiScreen currentScreen )
{
}
@Override
public void onRenderWorld()
{
}
@Override
public void onSetupCameraTransform()
{
}
@Override
public void init( File configPath )
{
Main.initialise();
}
@Override
public void upgradeSettings( String version, File configPath, File oldConfigPath )
{
}
}
+37 -46
View File
@@ -33,7 +33,7 @@ public class Main extends DeobfuscationLayer
public static boolean minecraftForge = false;
public static boolean optifine = false;
// public static boolean modLoader = false;
public static boolean useModLoader = false;
public static boolean useForge = false;
public static boolean DisableRMBTweak = false;
@@ -41,7 +41,7 @@ public class Main extends DeobfuscationLayer
public static int LMBTweakWithItem = 0;
public static int LMBTweakWithoutItem = 0;
public static int WheelTweak = 0;
public static int ForceModLoader = 0;
public static int ForceForgeOnRenderTick = 0;
public static int WheelSearchOrder = 1;
public static int Debug = 0;
@@ -67,32 +67,7 @@ public class Main extends DeobfuscationLayer
// modLoader = Reflection.doesClassExist( "net.minecraft.src.ModLoader" );
minecraftForge = Reflection
.doesClassExist( "net.minecraftforge.client.MinecraftForgeClient" );
if ( ForceModLoader == 1 )
{
// if ( modLoader )
// {
// useModLoader = true;
// Logger.Log( "ForceModLoader is set to 1, using ModLoader's onTick for mod operation..." );
// }
// else
// {
// Logger.Log( "ForceModLoader is set to 1, but ModLoader's main class is not present, quitting..." );
// disabled = true;
// return false;
// }
Logger.Log("ForceModLoader is not supported yet, quitting...");
disabled = true;
return false;
}
else
{
// liteLoader = Reflection.reflectLiteLoader();
liteLoader = false;
optifine = Reflection.reflectOptifine();
}
if ( minecraftForge )
{
Logger.Log( "Minecraft Forge is installed" );
@@ -101,35 +76,51 @@ public class Main extends DeobfuscationLayer
{
Logger.Log( "Minecraft Forge is not installed" );
}
if ( !liteLoader && ( ForceModLoader == 0 ) )
if ( ForceForgeOnRenderTick == 1 )
{
useModLoader = !Reflection.reflectMinecraft();
if ( !useModLoader )
if ( minecraftForge )
{
useForge = true;
Logger.Log( "ForceForgeOnRenderTick is set to 1, using Forge's RenderTickEvent for mod operation..." );
}
else
{
Logger.Log( "ForceForgeOnRenderTick is set to 1, but Forge's main class is not present, quitting..." );
disabled = true;
return false;
}
}
else
{
liteLoader = Reflection.reflectLiteLoader();
optifine = Reflection.reflectOptifine();
}
if ( !liteLoader && ( ForceForgeOnRenderTick == 0 ) )
{
useForge = !Reflection.reflectMinecraft();
if ( !useForge )
{
if ( !Reflection.replaceProfiler() )
{
// if ( modLoader )
// {
// useModLoader = true;
// Logger.Log( "Using ModLoader for mod operation" );
// }
// else
// {
if ( minecraftForge )
{
useForge = true;
Logger.Log( "Using Forge's RenderTickEvent for mod operation." );
}
else
{
Logger.Log( "Failed to replace the Minecraft profiler, quitting..." );
disabled = true;
return false;
// }
}
}
}
else
{
// Logger.Log( "Using ModLoader for mod operation" );
Logger.Log("Failed to reflect Minecraft, quitting...");
disabled = true;
return false;
Logger.Log( "Using Forge's RenderTickEvent for mod operation" );
}
}
@@ -158,7 +149,7 @@ public class Main extends DeobfuscationLayer
mainConfig.setPropertyValue( "LMBTweakWithoutItem", 1 );
mainConfig.setPropertyValue( "WheelTweak", 1 );
mainConfig.setPropertyValue( "WheelSearchOrder", 1 );
mainConfig.setPropertyValue( "ForceModLoader", 0 );
mainConfig.setPropertyValue( "ForceForgeOnRenderTick", 0 );
mainConfig.setPropertyValue( "Debug", 0 );
mainConfig.saveConfig();
@@ -171,7 +162,7 @@ public class Main extends DeobfuscationLayer
LMBTweakWithoutItem = mainConfig.getOrCreatePropertyValue( "LMBTweakWithoutItem", 1 );
WheelTweak = mainConfig.getOrCreatePropertyValue( "WheelTweak", 1 );
WheelSearchOrder = mainConfig.getOrCreatePropertyValue( "WheelSearchOrder", 1 );
ForceModLoader = mainConfig.getOrCreatePropertyValue( "ForceModLoader", 0 );
ForceForgeOnRenderTick = mainConfig.getOrCreatePropertyValue( "ForceForgeOnRenderTick", 0 );
Debug = mainConfig.getOrCreatePropertyValue( "Debug", 0 );
mainConfig.saveConfig();
@@ -1,8 +1,10 @@
package yalter.mousetweaks;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import net.minecraft.init.Blocks;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
@Mod(modid = MouseTweaksForge.MODID, version = MouseTweaksForge.VERSION, useMetadata = true)
public class MouseTweaksForge {
@@ -13,5 +15,19 @@ public class MouseTweaksForge {
public void init(FMLInitializationEvent event)
{
Main.initialise();
if (Main.useForge)
{
FMLCommonHandler.instance().bus().register(this);
}
}
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent event)
{
if (event.phase == TickEvent.Phase.START)
{
Main.onUpdateInGame();
}
}
}
@@ -82,62 +82,80 @@ public class Reflection
liteLoaderClass.storeClass( "LiteLoader", lL );
liteLoaderClass.available = true;
Class rL = getClass( "com.mumfrey.liteloader.RenderListener" );
if ( rL != null )
Class llEvents = getClass( "com.mumfrey.liteloader.core.Events" );
if ( llEvents != null )
{
Method addRenderListener = getMethod( lL, "addRenderListener", rL );
if ( addRenderListener != null )
liteLoaderClass.storeClass( "Events", llEvents );
Field llEventsField = getField( lL, "events" );
if ( llEventsField != null )
{
liteLoaderClass.storeMethod( "addRenderListener", addRenderListener );
Method getInstance = getMethod( lL, "getInstance" );
if ( getInstance != null )
liteLoaderClass.storeField( "events", llEventsField );
Class lM = getClass( "com.mumfrey.liteloader.LiteMod" );
if ( lM != null )
{
liteLoaderClass.storeMethod( "getInstance", getInstance );
Object liteLoaderInstance = liteLoaderClass.invokeStaticMethod( "LiteLoader", "getInstance" );
if ( liteLoaderInstance != null )
liteLoaderClass.storeClass( "LiteMod", lM );
Method addListener = getMethod( llEvents, "addListener", lM );
if ( addListener != null )
{
Class mouseTweaks = getClass( "yalter.mousetweaks.LiteModMouseTweaks" );
if ( mouseTweaks != null )
liteLoaderClass.storeMethod( "addListener", addListener );
Method getInstance = getMethod( lL, "getInstance" );
if ( getInstance != null )
{
liteModMouseTweaks = new ReflectionCache();
liteModMouseTweaks.storeClass( "LiteModMouseTweaks", mouseTweaks );
Method getLMMTInstance = getMethod( mouseTweaks, "getInstance" );
if ( getLMMTInstance != null )
liteLoaderClass.storeMethod( "getInstance", getInstance );
Object liteLoaderInstance = liteLoaderClass.invokeStaticMethod( "LiteLoader", "getInstance" );
if ( liteLoaderInstance != null )
{
liteModMouseTweaks.storeMethod( "getInstance", getLMMTInstance );
Object LMMTInstance = liteModMouseTweaks.invokeStaticMethod( "LiteModMouseTweaks", "getInstance" );
if ( LMMTInstance != null )
Object llEventsInstance = liteLoaderClass.getFieldValue( "events", liteLoaderInstance );
if ( llEventsInstance != null )
{
liteLoaderClass.invokeMethod( liteLoaderInstance, "addRenderListener", LMMTInstance );
liteLoaderClass.compatible = true;
Logger.Log( "LiteLoader is installed and compatible" );
return true;
}
else
{
Logger.Log( "Could not get instance from getInstance method of LiteModMouseTweaks class! Have you modified the class?" );
Class mouseTweaks = getClass( "yalter.mousetweaks.LiteModMouseTweaks" );
if ( mouseTweaks != null )
{
liteModMouseTweaks = new ReflectionCache();
liteModMouseTweaks.storeClass( "LiteModMouseTweaks", mouseTweaks );
Method getLMMTInstance = getMethod( mouseTweaks, "getInstance" );
if ( getLMMTInstance != null )
{
liteModMouseTweaks.storeMethod( "getInstance", getLMMTInstance );
Object LMMTInstance = liteModMouseTweaks.invokeStaticMethod( "LiteModMouseTweaks", "getInstance" );
if ( LMMTInstance != null )
{
liteLoaderClass.invokeMethod( llEventsInstance, "addListener", LMMTInstance );
liteLoaderClass.compatible = true;
Logger.Log( "LiteLoader is installed and compatible" );
return true;
}
else
{
Logger.Log( "Could not get instance from getInstance method of LiteModMouseTweaks class! Have you modified the class?" );
}
}
else
{
Logger.Log( "Could not get getInstance method from LiteModMouseTweaks class! Have you modified the class?" );
}
}
else
{
Logger.Log( "Could not get LiteModMouseTweaks class! Have you deleted it accidentally?" );
}
}
}
else
{
Logger.Log( "Could not get getInstance method from LiteModMouseTweaks class! Have you modified the class?" );
Logger.Log( "Failed to retrieve LiteLoader instance!" );
}
}
else
{
Logger.Log( "Could not get LiteModMouseTweaks class! Have you deleted it accidentally?" );
}
}
else
{
Logger.Log( "Failed to retrieve LiteLoader instance!" );
}
}
}
+1 -1
View File
@@ -7,7 +7,7 @@
"mcversion": "${mcversion}",
"url": "http://www.minecraftforum.net/topic/1518185-",
"updateUrl": "",
"authors": [ "YaLTeR" ],
"authorList": [ "YaLTeR" ],
"credits": "In the description.",
"logoFile": "/mousetweaks_logo.png",
"screenshots": [ ],