Compare commits

..
13 Commits
73 changed files with 1887 additions and 1120 deletions

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
# Ignore spotlessApply reformat
955a875d42bd8f725d389ef8c4f571824f2ae0c8
+36 -27
View File
@@ -1,35 +1,44 @@
* text eol=lf * text eol=lf
*.jar binary *.[jJ][aA][rR] binary
*.png binary *.[pP][nN][gG] binary
*.jpg binary *.[jJ][pP][gG] binary
*.jpeg binary *.[jJ][pP][eE][gG] binary
*.gif binary *.[gG][iI][fF] binary
*.tif binary *.[tT][iI][fF] binary
*.tiff binary *.[tT][iI][fF][fF] binary
*.ico binary *.[iI][cC][oO] binary
*.svg text *.[sS][vV][gG] text
*.eps binary *.[eE][pP][sS] binary
*.[xX][cC][fF] binary
*.kar binary *.[kK][aA][rR] binary
*.m4a binary *.[mM]4[aA] binary
*.mid binary *.[mM][iI][dD] binary
*.midi binary *.[mM][iI][dD][iI] binary
*.mp3 binary *.[mM][pP]3 binary
*.ogg binary *.[oO][gG][gG] binary
*.ra binary *.[rR][aA] binary
*.7z binary *.7[zZ] binary
*.gz binary *.[gG][zZ] binary
*.tar binary *.[tT][aA][rR] binary
*.tgz binary *.[tT][gG][zZ] binary
*.zip binary *.[zZ][iI][pP] binary
*.patch -text *.[tT][cC][nN] binary
*.[sS][oO] binary
*.[dD][lL][lL] binary
*.[dD][yY][lL][iI][bB] binary
*.[pP][sS][dD] binary
*.[tT][tT][fF] binary
*.[oO][tT][fF] binary
*.bat text eol=crlf *.[pP][aA][tT][cC][hH] -text
*.cmd text eol=crlf
*.ps1 text eol=crlf
*autogenerated binary *.[bB][aA][tT] text eol=crlf
*.[cC][mM][dD] text eol=crlf
*.[pP][sS]1 text eol=crlf
*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary
+1
View File
@@ -26,3 +26,4 @@ whitelist.json
*.ipr *.ipr
*.iws *.iws
src/main/resources/mixins.*.json src/main/resources/mixins.*.json
*.bat
+3 -3
View File
@@ -1,8 +1,8 @@
minecraft { minecraft {
if (replaceGradleTokenInFile) { if (replaceGradleTokenInFile) {
replaceIn "CodeChickenCorePlugin.java" tagReplacementFiles.add "CodeChickenCorePlugin.java"
if(gradleTokenVersion) { if(gradleTokenVersion) {
replace gradleTokenVersion, versionDetails().lastTag injectedTags.put gradleTokenVersion, versionDetails().lastTag
} }
} }
} }
+968 -479
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -1,5 +1,5 @@
// Add your dependencies here // Add your dependencies here
dependencies { dependencies {
compile('com.github.GTNewHorizons:CodeChickenLib:1.1.5.6:dev') api('com.github.GTNewHorizons:CodeChickenLib:1.2.0:dev')
} }
+38 -6
View File
@@ -21,16 +21,19 @@ forgeVersion = 10.13.4.1614
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty # Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
developmentEnvironmentUserName = Developer developmentEnvironmentUserName = Developer
# Define a source file of your project with: # Generate a class with String fields for the mod id, name, version and group name named with the fields below
generateGradleTokenClass = codechicken.core.asm.Tags
gradleTokenModId = MODID
gradleTokenModName = MODNAME
gradleTokenVersion = VERSION
gradleTokenGroupName = GROUPNAME
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION"; # public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's # The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...]) # version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements # Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = CodeChickenCoreModContainer.java replaceGradleTokenInFile =
gradleTokenModId = GRADLETOKEN_MODID
gradleTokenModName = GRADLETOKEN_MODNAME
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenGroupName =
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can # 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. # leave this property empty.
@@ -58,3 +61,32 @@ containsMixinsAndOrCoreModOnly = true
# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your # 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. # responsibility check the licence and request permission for distribution, if required.
usesShadowedDependencies = false usesShadowedDependencies = false
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
# The project's numeric ID on CurseForge. You can find this in the About Project box.
# Leave this empty if you don't want to publish on CurseForge.
curseForgeProjectId = 746279
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
# and the name is the CurseForge project id of the other mod.
# curseForgeRelations =
# Publishing to modrinth requires you to set the MODRINTH_TOKEN environment variable to your current modrinth API token.
# The project's ID on Modrinth. Can be either the slug or the ID.
# Leave this empty if you don't want to publish on Modrinth.
modrinthProjectId = codechickencore-unofficial
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
# Syntax: scope1-type1:name1;scope2-type2:name2;...
# Where scope can be one of [required, optional, incompatible, embedded],
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# modrinthRelations =
Binary file not shown.
+3 -1
View File
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
Vendored
+178 -117
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env sh #!/bin/sh
# #
# Copyright 2015 the original author or authors. # Copyright © 2015-2021 the original authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@@ -17,78 +17,111 @@
# #
############################################################################## ##############################################################################
## #
## Gradle start up script for UN*X # Gradle start up script for POSIX generated by Gradle.
## #
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
############################################################################## ##############################################################################
# Attempt to set APP_HOME # Attempt to set APP_HOME
# Resolve links: $0 may be a link # Resolve links: $0 may be a link
PRG="$0" app_path=$0
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do # Need this for daisy-chained symlinks.
ls=`ls -ld "$PRG"` while
link=`expr "$ls" : '.*-> \(.*\)$'` APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
if expr "$link" : '/.*' > /dev/null; then [ -h "$app_path" ]
PRG="$link" do
else ls=$( ls -ld "$app_path" )
PRG=`dirname "$PRG"`"/$link" link=${ls#*' -> '}
fi case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle" # This is normally unused
APP_BASE_NAME=`basename "$0"` # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD=maximum
warn () { warn () {
echo "$*" echo "$*"
} } >&2
die () { die () {
echo echo
echo "$*" echo "$*"
echo echo
exit 1 exit 1
} } >&2
# OS specific support (must be 'true' or 'false'). # OS specific support (must be 'true' or 'false').
cygwin=false cygwin=false
msys=false msys=false
darwin=false darwin=false
nonstop=false nonstop=false
case "`uname`" in case "$( uname )" in #(
CYGWIN* ) CYGWIN* ) cygwin=true ;; #(
cygwin=true Darwin* ) darwin=true ;; #(
;; MSYS* | MINGW* ) msys=true ;; #(
Darwin* ) NONSTOP* ) nonstop=true ;;
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables # IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java" JAVACMD=$JAVA_HOME/jre/sh/java
else else
JAVACMD="$JAVA_HOME/bin/java" JAVACMD=$JAVA_HOME/bin/java
fi fi
if [ ! -x "$JAVACMD" ] ; then if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -97,92 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi fi
else else
JAVACMD="java" 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. if ! command -v java >/dev/null 2>&1
then
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 Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
MAX_FD_LIMIT=`ulimit -H -n` case $MAX_FD in #(
if [ $? -eq 0 ] ; then max*)
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
MAX_FD="$MAX_FD_LIMIT" # shellcheck disable=SC2039,SC3045
fi MAX_FD=$( ulimit -H -n ) ||
ulimit -n $MAX_FD warn "Could not query maximum file descriptor limit"
if [ $? -ne 0 ] ; then esac
warn "Could not set maximum file descriptor limit: $MAX_FD" case $MAX_FD in #(
fi '' | soft) :;; #(
else *)
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
fi # shellcheck disable=SC2039,SC3045
fi ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
# 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 esac
fi fi
# Escape application args # Collect all arguments for the java command, stacking in reverse order:
save () { # * args from the command line
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done # * the main class name
echo " " # * -classpath
} # * -D...appname settings
APP_ARGS=$(save "$@") # * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules # For Cygwin or MSYS, switch paths to Windows format before running java
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong JAVACMD=$( cygpath --unix "$JAVACMD" )
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")" # Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi fi
# 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"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@" exec "$JAVACMD" "$@"
Vendored
+15 -23
View File
@@ -14,7 +14,7 @@
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@@ -25,10 +25,14 @@
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @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" set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@@ -37,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if %ERRORLEVEL% equ 0 goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -51,7 +55,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -61,38 +65,26 @@ echo location of your Java installation.
goto fail 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 :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @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% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if %ERRORLEVEL% equ 0 goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 set EXIT_CODE=%ERRORLEVEL%
exit /b 1 if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal
-8
View File
@@ -1,12 +1,4 @@
// Add any additional repositiroes for your dependencies here // Add any additional repositiroes for your dependencies here
repositories { repositories {
maven {
name 'GTNH Maven'
url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public/'
allowInsecureProtocol
}
maven {
url 'https://jitpack.io'
}
} }
+21 -4
View File
@@ -1,10 +1,27 @@
plugins {
id 'com.diffplug.blowdryerSetup' version '1.6.0' pluginManagement {
repositories {
maven {
// RetroFuturaGradle
name "GTNH Maven"
url "https://nexus.gtnewhorizons.com/repository/public/"
mavenContent {
includeGroupByRegex("com\\.gtnewhorizons\\..+")
}
}
gradlePluginPortal()
mavenCentral()
mavenLocal()
}
} }
apply plugin: 'com.diffplug.blowdryerSetup' plugins {
id 'com.diffplug.blowdryerSetup' version '1.7.1'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' // Provides java toolchains
}
blowdryerSetup { blowdryerSetup {
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.1.5') repoSubfolder 'gtnhShared'
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0')
//devLocal '.' // Use this when testing config updates locally //devLocal '.' // Use this when testing config updates locally
} }
@@ -1,10 +1,5 @@
package codechicken.core; package codechicken.core;
import codechicken.core.launch.CodeChickenCorePlugin;
import com.google.common.base.Function;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.versioning.ComparableVersion;
import cpw.mods.fml.relauncher.FMLInjectionData;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@@ -14,14 +9,24 @@ import java.net.SocketTimeoutException;
import java.net.URL; import java.net.URL;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import com.google.common.base.Function;
import codechicken.core.launch.CodeChickenCorePlugin;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.versioning.ComparableVersion;
import cpw.mods.fml.relauncher.FMLInjectionData;
public class CCUpdateChecker { public class CCUpdateChecker {
private static final ArrayList<String> updates = new ArrayList<String>(); private static final ArrayList<String> updates = new ArrayList<String>();
private static class ThreadUpdateCheck extends Thread { private static class ThreadUpdateCheck extends Thread {
private final URL url; private final URL url;
private final Function<String, Void> handler; private final Function<String, Void> handler;
@@ -44,9 +49,7 @@ public class CCUpdateChecker {
read.close(); read.close();
if (ret == null) ret = ""; if (ret == null) ret = "";
handler.apply(ret); handler.apply(ret);
} catch (SocketTimeoutException ignored) { } catch (SocketTimeoutException ignored) {} catch (UnknownHostException ignored) {} catch (IOException iox) {
} catch (UnknownHostException ignored) {
} catch (IOException iox) {
iox.printStackTrace(); iox.printStackTrace();
} }
} }
@@ -75,20 +78,22 @@ public class CCUpdateChecker {
public static void updateCheck(final String mod, final String version) { public static void updateCheck(final String mod, final String version) {
updateCheck( updateCheck(
"http://www.chickenbones.net/Files/notification/version.php?" + "version=" "http://www.chickenbones.net/Files/notification/version.php?" + "version="
+ mcVersion() + "&" + "file=" + mcVersion()
+ "&"
+ "file="
+ mod, + mod,
new Function<String, Void>() { new Function<String, Void>() {
@Override @Override
public Void apply(String ret) { public Void apply(String ret) {
if (!ret.startsWith("Ret: ")) { if (!ret.startsWith("Ret: ")) {
CodeChickenCorePlugin.logger.error( CodeChickenCorePlugin.logger
"Failed to check update for " + mod + " returned: " + ret); .error("Failed to check update for " + mod + " returned: " + ret);
return null; return null;
} }
ComparableVersion newversion = new ComparableVersion(ret.substring(5)); ComparableVersion newversion = new ComparableVersion(ret.substring(5));
if (newversion.compareTo(new ComparableVersion(version)) > 0) if (newversion.compareTo(new ComparableVersion(version)) > 0) addUpdateMessage(
addUpdateMessage( StatCollector.translateToLocalFormatted("codechickencore.update", newversion, mod));
StatCollector.translateToLocalFormatted("codechickencore.update", newversion, mod));
return null; return null;
} }
}); });
@@ -1,12 +1,5 @@
package codechicken.core; package codechicken.core;
import codechicken.core.launch.CodeChickenCorePlugin;
import codechicken.lib.asm.ASMHelper;
import com.google.common.collect.ImmutableList;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModClassLoader;
import cpw.mods.fml.relauncher.CoreModManager;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
@@ -15,10 +8,22 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import net.minecraft.launchwrapper.Launch; import net.minecraft.launchwrapper.Launch;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import com.google.common.collect.ImmutableList;
import codechicken.core.launch.CodeChickenCorePlugin;
import codechicken.lib.asm.ASMHelper;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModClassLoader;
import cpw.mods.fml.relauncher.CoreModManager;
public class ClassDiscoverer { public class ClassDiscoverer {
public IStringMatcher matcher; public IStringMatcher matcher;
public String[] superclasses; public String[] superclasses;
public ArrayList<Class<?>> classes; public ArrayList<Class<?>> classes;
@@ -35,13 +40,12 @@ public class ClassDiscoverer {
} }
public ClassDiscoverer(Class<?>... superclasses) { public ClassDiscoverer(Class<?>... superclasses) {
this( this(new IStringMatcher() {
new IStringMatcher() {
public boolean matches(String test) { public boolean matches(String test) {
return true; return true;
} }
}, }, superclasses);
superclasses);
} }
public ArrayList<Class<?>> findClasses() { public ArrayList<Class<?>> findClasses() {
@@ -79,10 +83,8 @@ public class ClassDiscoverer {
} }
private void findClasspathMods() { private void findClasspathMods() {
List<String> knownLibraries = ImmutableList.<String>builder() List<String> knownLibraries = ImmutableList.<String>builder().addAll(modClassLoader.getDefaultLibraries())
.addAll(modClassLoader.getDefaultLibraries()) .addAll(CoreModManager.getLoadedCoremods()).build();
.addAll(CoreModManager.getLoadedCoremods())
.build();
File[] minecraftSources = modClassLoader.getParentSources(); File[] minecraftSources = modClassLoader.getParentSources();
HashSet<String> searchedSources = new HashSet<String>(); HashSet<String> searchedSources = new HashSet<String>();
for (File minecraftSource : minecraftSources) { for (File minecraftSource : minecraftSources) {
@@ -98,7 +100,8 @@ public class ClassDiscoverer {
readFromZipFile(minecraftSource); readFromZipFile(minecraftSource);
} catch (Exception e) { } catch (Exception e) {
CodeChickenCorePlugin.logger.error( CodeChickenCorePlugin.logger.error(
"Failed to scan " + minecraftSource.getAbsolutePath() + ", the zip file is invalid", e); "Failed to scan " + minecraftSource.getAbsolutePath() + ", the zip file is invalid",
e);
} }
} }
} else if (minecraftSource.isDirectory()) { } else if (minecraftSource.isDirectory()) {
@@ -1,10 +1,5 @@
package codechicken.core; package codechicken.core;
import codechicken.core.internal.CCCEventHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
@@ -12,7 +7,14 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World; import net.minecraft.world.World;
import codechicken.core.internal.CCCEventHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ClientUtils extends CommonUtils { public class ClientUtils extends CommonUtils {
private static Minecraft mc() { private static Minecraft mc() {
return Minecraft.getMinecraft(); return Minecraft.getMinecraft();
} }
@@ -22,7 +24,7 @@ public class ClientUtils extends CommonUtils {
} }
public static boolean inWorld() // TODO unused public static boolean inWorld() // TODO unused
{ {
return mc().getNetHandler() != null; return mc().getNetHandler() != null;
} }
@@ -59,8 +61,8 @@ public class ClientUtils extends CommonUtils {
public static void enhanceSupportersList(Object mod) { public static void enhanceSupportersList(Object mod) {
ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod); ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod);
mc.getMetadata().description = mc.getMetadata().description = mc.getMetadata().description
mc.getMetadata().description.replace("Supporters:", EnumChatFormatting.AQUA + "Supporters:"); .replace("Supporters:", EnumChatFormatting.AQUA + "Supporters:");
GuiModListScroll.register(mod); GuiModListScroll.register(mod);
} }
} }
@@ -1,14 +1,17 @@
package codechicken.core; package codechicken.core;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.FMLInjectionData;
import java.io.File; import java.io.File;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityList;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.FMLInjectionData;
public class CommonUtils { public class CommonUtils {
public static boolean isClient() { public static boolean isClient() {
return FMLCommonHandler.instance().getSide().isClient(); return FMLCommonHandler.instance().getSide().isClient();
} }
@@ -1,7 +1,39 @@
package codechicken.core; package codechicken.core;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.GL_ALWAYS;
import static org.lwjgl.opengl.GL11.GL_EQUAL;
import static org.lwjgl.opengl.GL11.GL_KEEP;
import static org.lwjgl.opengl.GL11.GL_PACK_ALIGNMENT;
import static org.lwjgl.opengl.GL11.GL_REPLACE;
import static org.lwjgl.opengl.GL11.GL_STENCIL_INDEX;
import static org.lwjgl.opengl.GL11.GL_STENCIL_TEST;
import static org.lwjgl.opengl.GL11.GL_UNPACK_ALIGNMENT;
import static org.lwjgl.opengl.GL11.GL_UNSIGNED_BYTE;
import static org.lwjgl.opengl.GL11.GL_ZERO;
import static org.lwjgl.opengl.GL11.glColorMask;
import static org.lwjgl.opengl.GL11.glDisable;
import static org.lwjgl.opengl.GL11.glEnable;
import static org.lwjgl.opengl.GL11.glPixelStorei;
import static org.lwjgl.opengl.GL11.glReadPixels; import static org.lwjgl.opengl.GL11.glReadPixels;
import static org.lwjgl.opengl.GL11.glStencilFunc;
import static org.lwjgl.opengl.GL11.glStencilOp;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.LinkedList;
import java.util.List;
import javax.imageio.ImageIO;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.MinecraftForgeClient;
import org.lwjgl.BufferUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import codechicken.core.launch.CodeChickenCorePlugin; import codechicken.core.launch.CodeChickenCorePlugin;
import codechicken.lib.gui.GuiDraw; import codechicken.lib.gui.GuiDraw;
@@ -10,21 +42,9 @@ import cpw.mods.fml.client.GuiModList;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.ModMetadata; import cpw.mods.fml.common.ModMetadata;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.LinkedList;
import java.util.List;
import javax.imageio.ImageIO;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.MinecraftForgeClient;
import org.lwjgl.BufferUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
public class GuiModListScroll { public class GuiModListScroll {
private static List<ModContainer> scrollMods = new LinkedList<ModContainer>(); private static List<ModContainer> scrollMods = new LinkedList<ModContainer>();
public static void register(Object mod) { public static void register(Object mod) {
@@ -45,9 +65,8 @@ public class GuiModListScroll {
glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glReadPixels(0, 0, d.width, d.height, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, buf); glReadPixels(0, 0, d.width, d.height, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, buf);
for (int i = 0; i < d.width; i++) for (int i = 0; i < d.width; i++) for (int j = 0; j < d.height; j++)
for (int j = 0; j < d.height; j++) img.setRGB(i, d.height - j - 1, buf.get(j * d.width + i) == 0 ? 0 : 0xFFFFFF);
img.setRGB(i, d.height - j - 1, buf.get(j * d.width + i) == 0 ? 0 : 0xFFFFFF);
try { try {
ImageIO.write(img, "png", new File("stencil" + x + ".png")); ImageIO.write(img, "png", new File("stencil" + x + ".png"));
} catch (IOException e) { } catch (IOException e) {
@@ -109,9 +128,7 @@ public class GuiModListScroll {
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
String description = selectedMod.getMetadata().description; String description = selectedMod.getMetadata().description;
int height = GuiDraw.fontRenderer int height = GuiDraw.fontRenderer.listFormattedStringToWidth(description, x2 - x1).size()
.listFormattedStringToWidth(description, x2 - x1)
.size()
* GuiDraw.fontRenderer.FONT_HEIGHT; * GuiDraw.fontRenderer.FONT_HEIGHT;
boolean needsScroll = height > y2 - y1draw; boolean needsScroll = height > y2 - y1draw;
@@ -142,8 +159,8 @@ public class GuiModListScroll {
} }
/** /**
* Does not add the last 10 px space before the description normally starts * Does not add the last 10 px space before the description normally starts Ignores empty child mods expecting a
* Ignores empty child mods expecting a background draw overwrite * background draw overwrite
*/ */
private static int calcDescY(GuiModList gui, ModContainer mod) { private static int calcDescY(GuiModList gui, ModContainer mod) {
ModMetadata meta = mod.getMetadata(); ModMetadata meta = mod.getMetadata();
@@ -3,5 +3,6 @@ package codechicken.core;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
public interface IGuiPacketSender { public interface IGuiPacketSender {
void sendPacket(EntityPlayerMP player, int windowId); void sendPacket(EntityPlayerMP player, int windowId);
} }
@@ -1,5 +1,6 @@
package codechicken.core; package codechicken.core;
public interface IStringMatcher { public interface IStringMatcher {
public boolean matches(String test); public boolean matches(String test);
} }
@@ -3,6 +3,7 @@ package codechicken.core;
import codechicken.core.launch.CodeChickenCorePlugin; import codechicken.core.launch.CodeChickenCorePlugin;
public class ProfileTimer { public class ProfileTimer {
public double decay; public double decay;
public long startTime; public long startTime;
public long nanoTime; public long nanoTime;
@@ -1,13 +1,15 @@
package codechicken.core; package codechicken.core;
import codechicken.lib.asm.ObfMapping;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.HashMap; import java.util.HashMap;
import codechicken.lib.asm.ObfMapping;
public class ReflectionManager { public class ReflectionManager {
public static HashMap<Class<?>, Class<?>> primitiveWrappers = new HashMap<Class<?>, Class<?>>(); public static HashMap<Class<?>, Class<?>> primitiveWrappers = new HashMap<Class<?>, Class<?>>();
static { static {
@@ -27,12 +29,12 @@ public class ReflectionManager {
if (primitive == Long.class && Long.class.isInstance(obj)) return true; if (primitive == Long.class && Long.class.isInstance(obj)) return true;
if ((primitive == Long.class || primitive == Integer.class) && Integer.class.isInstance(obj)) return true; if ((primitive == Long.class || primitive == Integer.class) && Integer.class.isInstance(obj)) return true;
if ((primitive == Long.class || primitive == Integer.class || primitive == Short.class) if ((primitive == Long.class || primitive == Integer.class || primitive == Short.class)
&& Short.class.isInstance(obj)) return true; && Short.class.isInstance(obj))
if ((primitive == Long.class return true;
|| primitive == Integer.class if ((primitive == Long.class || primitive == Integer.class
|| primitive == Short.class || primitive == Short.class
|| primitive == Byte.class) || primitive == Byte.class) && Integer.class.isInstance(obj))
&& Integer.class.isInstance(obj)) return true; return true;
if (primitive == Double.class && Double.class.isInstance(obj)) return true; if (primitive == Double.class && Double.class.isInstance(obj)) return true;
if ((primitive == Double.class || primitive == Float.class) && Float.class.isInstance(obj)) return true; if ((primitive == Double.class || primitive == Float.class) && Float.class.isInstance(obj)) return true;
@@ -64,7 +66,7 @@ public class ReflectionManager {
public static void setField(Class<?> class1, Object instance, String name, Object value) public static void setField(Class<?> class1, Object instance, String name, Object value)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
setField(class1, instance, new String[] {name}, value); setField(class1, instance, new String[] { name }, value);
} }
public static void setField(Class<?> class1, Object instance, String[] names, Object value) public static void setField(Class<?> class1, Object instance, String[] names, Object value)
@@ -95,19 +97,15 @@ public class ReflectionManager {
} }
/** /**
* Static function * Static function void return type single name
* void return type
* single name
*/ */
public static void callMethod(Class<?> class1, String name, Object... params) public static void callMethod(Class<?> class1, String name, Object... params)
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
callMethod(class1, null, new String[] {name}, params); callMethod(class1, null, new String[] { name }, params);
} }
/** /**
* Static function * Static function void return type single name
* void return type
* single name
*/ */
public static void callMethod(Class<?> class1, String[] names, Object... params) public static void callMethod(Class<?> class1, String[] names, Object... params)
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
@@ -115,12 +113,11 @@ public class ReflectionManager {
} }
/** /**
* void return type * void return type single name
* single name
*/ */
public static void callMethod(Class<?> class1, Object instance, String name, Object... params) public static void callMethod(Class<?> class1, Object instance, String name, Object... params)
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
callMethod(class1, null, instance, new String[] {name}, params); callMethod(class1, null, instance, new String[] { name }, params);
} }
/** /**
@@ -132,12 +129,11 @@ public class ReflectionManager {
} }
/** /**
* Static method * Static method single name
* single name
*/ */
public static <R> R callMethod(Class<?> class1, Class<R> returntype, String name, Object... params) public static <R> R callMethod(Class<?> class1, Class<R> returntype, String name, Object... params)
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
return callMethod(class1, returntype, null, new String[] {name}, params); return callMethod(class1, returntype, null, new String[] { name }, params);
} }
/** /**
@@ -153,14 +149,12 @@ public class ReflectionManager {
*/ */
public static <R> R callMethod(Class<?> class1, Class<R> returntype, Object instance, String name, Object... params) public static <R> R callMethod(Class<?> class1, Class<R> returntype, Object instance, String name, Object... params)
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
return callMethod(class1, returntype, instance, new String[] {name}, params); return callMethod(class1, returntype, instance, new String[] { name }, params);
} }
public static <R> R callMethod( public static <R> R callMethod(Class<?> class1, Class<R> returntype, Object instance, String[] names,
Class<?> class1, Class<R> returntype, Object instance, String[] names, Object... params) Object... params) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { nextMethod: for (Method method : class1.getDeclaredMethods()) {
nextMethod:
for (Method method : class1.getDeclaredMethods()) {
boolean match = false; boolean match = false;
for (String name : names) { for (String name : names) {
if (method.getName().equals(name)) { if (method.getName().equals(name)) {
@@ -204,8 +198,7 @@ public class ReflectionManager {
public static <T> T newInstance(Class<T> class1, Object... params) public static <T> T newInstance(Class<T> class1, Object... params)
throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
nextMethod: nextMethod: for (Constructor<?> constructor : class1.getDeclaredConstructors()) {
for (Constructor<?> constructor : class1.getDeclaredConstructors()) {
Class<?>[] paramtypes = constructor.getParameterTypes(); Class<?>[] paramtypes = constructor.getParameterTypes();
if (paramtypes.length != params.length) continue; if (paramtypes.length != params.length) continue;
+15 -10
View File
@@ -1,20 +1,24 @@
package codechicken.core; package codechicken.core;
import codechicken.lib.asm.ObfMapping;
import com.mojang.authlib.GameProfile;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.util.IChatComponent; import net.minecraft.util.IChatComponent;
import com.mojang.authlib.GameProfile;
import codechicken.lib.asm.ObfMapping;
public class ServerUtils extends CommonUtils { public class ServerUtils extends CommonUtils {
public static MinecraftServer mc() { public static MinecraftServer mc() {
return MinecraftServer.getServer(); return MinecraftServer.getServer();
} }
@@ -49,17 +53,18 @@ public class ServerUtils extends CommonUtils {
static { static {
try { try {
field_152661_c = ReflectionManager.getField(new ObfMapping( field_152661_c = ReflectionManager.getField(
"net/minecraft/server/management/PlayerProfileCache", "field_152661_c", "[Ljava/util/Map;")); new ObfMapping(
c_ProfileEntry = ServerUtils.class "net/minecraft/server/management/PlayerProfileCache",
.getClassLoader() "field_152661_c",
"[Ljava/util/Map;"));
c_ProfileEntry = ServerUtils.class.getClassLoader()
.loadClass("net.minecraft.server.management.PlayerProfileCache$ProfileEntry"); .loadClass("net.minecraft.server.management.PlayerProfileCache$ProfileEntry");
func_152668_a = c_ProfileEntry.getDeclaredMethod(new ObfMapping( func_152668_a = c_ProfileEntry.getDeclaredMethod(
new ObfMapping(
"net/minecraft/server/management/PlayerProfileCache$ProfileEntry", "net/minecraft/server/management/PlayerProfileCache$ProfileEntry",
"func_152668_a", "func_152668_a",
"()Lcom/mojang/authlib/GameProfile;") "()Lcom/mojang/authlib/GameProfile;").toRuntime().s_name);
.toRuntime()
.s_name);
func_152668_a.setAccessible(true); func_152668_a.setAccessible(true);
} catch (Exception e) { } catch (Exception e) {
@@ -6,7 +6,9 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
public class TaskProfiler { public class TaskProfiler {
public static class ProfilerResult { public static class ProfilerResult {
public final String name; public final String name;
public final long time; public final long time;
public final double fraction; public final double fraction;
@@ -1,13 +1,16 @@
package codechicken.core.asm; package codechicken.core.asm;
import codechicken.lib.asm.ObfMapping;
import com.google.common.collect.ImmutableBiMap;
import cpw.mods.fml.common.asm.transformers.AccessTransformer;
import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import com.google.common.collect.ImmutableBiMap;
import codechicken.lib.asm.ObfMapping;
import cpw.mods.fml.common.asm.transformers.AccessTransformer;
import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
public class CodeChickenAccessTransformer extends AccessTransformer { public class CodeChickenAccessTransformer extends AccessTransformer {
private static boolean makeAllPublic; private static boolean makeAllPublic;
private static Field f_classNameBiMap; private static Field f_classNameBiMap;
private static Object emptyMap = ImmutableBiMap.of(); private static Object emptyMap = ImmutableBiMap.of();
@@ -20,12 +23,10 @@ public class CodeChickenAccessTransformer extends AccessTransformer {
private void loadPublicConfig() { private void loadPublicConfig() {
if (ObfMapping.obfuscated) return; if (ObfMapping.obfuscated) return;
makeAllPublic = CodeChickenCoreModContainer.config makeAllPublic = CodeChickenCoreModContainer.config.getTag("dev.runtimePublic").setComment(
.getTag("dev.runtimePublic") "Enabling this setting will make all minecraft classes public at runtime in MCP just as they are in modloader."
.setComment( + "\nYou should ONLY use this when you are testing with a mod that relies on runtime publicity and doesn't include access transformers."
"Enabling this setting will make all minecraft classes public at runtime in MCP just as they are in modloader." + "\nSuch mods are doing the wrong thing and should be fixed.")
+ "\nYou should ONLY use this when you are testing with a mod that relies on runtime publicity and doesn't include access transformers."
+ "\nSuch mods are doing the wrong thing and should be fixed.")
.getBooleanValue(false); .getBooleanValue(false);
if (!makeAllPublic) return; if (!makeAllPublic) return;
@@ -1,25 +1,32 @@
package codechicken.core.asm; package codechicken.core.asm;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import net.minecraftforge.common.MinecraftForge;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import codechicken.core.CCUpdateChecker; import codechicken.core.CCUpdateChecker;
import codechicken.core.ClientUtils; import codechicken.core.ClientUtils;
import codechicken.core.featurehack.LiquidTextures; import codechicken.core.featurehack.LiquidTextures;
import codechicken.core.internal.CCCEventHandler; import codechicken.core.internal.CCCEventHandler;
import codechicken.core.launch.CodeChickenCorePlugin; import codechicken.core.launch.CodeChickenCorePlugin;
import codechicken.lib.config.ConfigFile; import codechicken.lib.config.ConfigFile;
import com.google.common.eventbus.EventBus; import cpw.mods.fml.common.DummyModContainer;
import com.google.common.eventbus.Subscribe; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.*; import cpw.mods.fml.common.LoadController;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.versioning.ArtifactVersion; import cpw.mods.fml.common.versioning.ArtifactVersion;
import cpw.mods.fml.common.versioning.VersionParser; import cpw.mods.fml.common.versioning.VersionParser;
import cpw.mods.fml.common.versioning.VersionRange; import cpw.mods.fml.common.versioning.VersionRange;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import net.minecraftforge.common.MinecraftForge;
public class CodeChickenCoreModContainer extends DummyModContainer { public class CodeChickenCoreModContainer extends DummyModContainer {
public static ConfigFile config; public static ConfigFile config;
public static void loadConfig() { public static void loadConfig() {
@@ -34,9 +41,9 @@ public class CodeChickenCoreModContainer extends DummyModContainer {
private static ModMetadata getModMetadata() { private static ModMetadata getModMetadata() {
final ModMetadata modMetadata = new ModMetadata(); final ModMetadata modMetadata = new ModMetadata();
modMetadata.name = "GRADLETOKEN_MODNAME"; modMetadata.name = "CodeChicken Core";
modMetadata.modId = "GRADLETOKEN_MODID"; modMetadata.modId = "CodeChickenCore";
modMetadata.version = "GRADLETOKEN_VERSION"; modMetadata.version = Tags.VERSION;
return modMetadata; return modMetadata;
} }
@@ -1,19 +1,23 @@
package codechicken.core.asm; package codechicken.core.asm;
import codechicken.lib.asm.ASMHelper;
import codechicken.lib.asm.ClassHeirachyManager;
import codechicken.lib.asm.ObfMapping;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.launchwrapper.IClassTransformer; import net.minecraft.launchwrapper.IClassTransformer;
import net.minecraft.launchwrapper.LaunchClassLoader; import net.minecraft.launchwrapper.LaunchClassLoader;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.MethodNode;
import codechicken.lib.asm.ASMHelper;
import codechicken.lib.asm.ClassHeirachyManager;
import codechicken.lib.asm.ObfMapping;
public class DefaultImplementationTransformer implements IClassTransformer { public class DefaultImplementationTransformer implements IClassTransformer {
private static LaunchClassLoader cl = (LaunchClassLoader) ClassHeirachyManager.class.getClassLoader(); private static LaunchClassLoader cl = (LaunchClassLoader) ClassHeirachyManager.class.getClassLoader();
private static ClassNode getClassNode(String name) { private static ClassNode getClassNode(String name) {
@@ -25,6 +29,7 @@ public class DefaultImplementationTransformer implements IClassTransformer {
} }
static class InterfaceImpl { static class InterfaceImpl {
public final String iname; public final String iname;
public ArrayList<MethodNode> impls = new ArrayList<MethodNode>(); public ArrayList<MethodNode> impls = new ArrayList<MethodNode>();
@@ -35,11 +40,10 @@ public class DefaultImplementationTransformer implements IClassTransformer {
for (MethodNode method : inode.methods) names.add(method.name + method.desc); for (MethodNode method : inode.methods) names.add(method.name + method.desc);
ClassNode cnode = getClassNode(cname); ClassNode cnode = getClassNode(cname);
for (MethodNode method : cnode.methods) for (MethodNode method : cnode.methods) if (names.contains(method.name + method.desc)) {
if (names.contains(method.name + method.desc)) { impls.add(method);
impls.add(method); method.desc = new ObfMapping(cnode.name, method.name, method.desc).toRuntime().s_desc;
method.desc = new ObfMapping(cnode.name, method.name, method.desc).toRuntime().s_desc; }
}
} }
public boolean patch(ClassNode cnode) { public boolean patch(ClassNode cnode) {
@@ -13,13 +13,16 @@ import java.util.Map;
import java.util.Stack; import java.util.Stack;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import net.minecraft.launchwrapper.IClassTransformer; import net.minecraft.launchwrapper.IClassTransformer;
import net.minecraft.launchwrapper.Launch; import net.minecraft.launchwrapper.Launch;
import net.minecraft.launchwrapper.LaunchClassLoader; import net.minecraft.launchwrapper.LaunchClassLoader;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
public class DelegatedTransformer implements IClassTransformer { public class DelegatedTransformer implements IClassTransformer {
private static ArrayList<IClassTransformer> delegatedTransformers; private static ArrayList<IClassTransformer> delegatedTransformers;
private static Method m_defineClass; private static Method m_defineClass;
private static Field f_cachedClasses; private static Field f_cachedClasses;
@@ -27,8 +30,8 @@ public class DelegatedTransformer implements IClassTransformer {
public DelegatedTransformer() { public DelegatedTransformer() {
delegatedTransformers = new ArrayList<IClassTransformer>(); delegatedTransformers = new ArrayList<IClassTransformer>();
try { try {
m_defineClass = ClassLoader.class.getDeclaredMethod( m_defineClass = ClassLoader.class
"defineClass", String.class, byte[].class, Integer.TYPE, Integer.TYPE); .getDeclaredMethod("defineClass", String.class, byte[].class, Integer.TYPE, Integer.TYPE);
m_defineClass.setAccessible(true); m_defineClass.setAccessible(true);
f_cachedClasses = LaunchClassLoader.class.getDeclaredField("cachedClasses"); f_cachedClasses = LaunchClassLoader.class.getDeclaredField("cachedClasses");
f_cachedClasses.setAccessible(true); f_cachedClasses.setAccessible(true);
@@ -53,9 +56,10 @@ public class DelegatedTransformer implements IClassTransformer {
if (bytes == null) { if (bytes == null) {
String resourceName = transformer.replace('.', '/') + ".class"; String resourceName = transformer.replace('.', '/') + ".class";
ZipEntry entry = jar.getEntry(resourceName); ZipEntry entry = jar.getEntry(resourceName);
if (entry == null) if (entry == null) throw new Exception(
throw new Exception("Failed to add transformer: " + transformer + ". Entry not found in jar file " "Failed to add transformer: " + transformer
+ jarFile.getName()); + ". Entry not found in jar file "
+ jarFile.getName());
bytes = readFully(jar.getInputStream(entry)); bytes = readFully(jar.getInputStream(entry));
} }
@@ -63,14 +67,12 @@ public class DelegatedTransformer implements IClassTransformer {
defineDependancies(bytes, jar, jarFile); defineDependancies(bytes, jar, jarFile);
Class<?> clazz = defineClass(transformer, bytes); Class<?> clazz = defineClass(transformer, bytes);
if (!IClassTransformer.class.isAssignableFrom(clazz)) if (!IClassTransformer.class.isAssignableFrom(clazz)) throw new Exception(
throw new Exception( "Failed to add transformer: " + transformer + " is not an instance of IClassTransformer");
"Failed to add transformer: " + transformer + " is not an instance of IClassTransformer");
IClassTransformer classTransformer; IClassTransformer classTransformer;
try { try {
classTransformer = (IClassTransformer) classTransformer = (IClassTransformer) clazz.getDeclaredConstructor(File.class).newInstance(jarFile);
clazz.getDeclaredConstructor(File.class).newInstance(jarFile);
} catch (NoSuchMethodException nsme) { } catch (NoSuchMethodException nsme) {
classTransformer = (IClassTransformer) clazz.newInstance(); classTransformer = (IClassTransformer) clazz.newInstance();
} }
@@ -5,6 +5,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Label; import org.objectweb.asm.Label;
@@ -12,9 +13,11 @@ import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
public class DependancyLister extends ClassVisitor { public class DependancyLister extends ClassVisitor {
private static Pattern classdesc = Pattern.compile("L(.+?);"); private static Pattern classdesc = Pattern.compile("L(.+?);");
private class DependancyMethodLister extends MethodVisitor { private class DependancyMethodLister extends MethodVisitor {
public DependancyMethodLister(int api) { public DependancyMethodLister(int api) {
super(api); super(api);
} }
@@ -6,5 +6,5 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE}) @Target({ ElementType.TYPE })
public @interface InterfaceDependancies {} public @interface InterfaceDependancies {}
@@ -1,5 +1,28 @@
package codechicken.core.asm; package codechicken.core.asm;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import net.minecraft.launchwrapper.IClassTransformer;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.launchwrapper.LaunchClassLoader;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import codechicken.lib.asm.ASMHelper; import codechicken.lib.asm.ASMHelper;
import codechicken.lib.asm.ASMInit; import codechicken.lib.asm.ASMInit;
import codechicken.lib.asm.CC_ClassWriter; import codechicken.lib.asm.CC_ClassWriter;
@@ -7,30 +30,17 @@ import codechicken.lib.asm.ObfMapping;
import codechicken.obfuscator.IHeirachyEvaluator; import codechicken.obfuscator.IHeirachyEvaluator;
import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry; import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry;
import codechicken.obfuscator.ObfuscationRun; import codechicken.obfuscator.ObfuscationRun;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import cpw.mods.fml.common.asm.transformers.AccessTransformer; import cpw.mods.fml.common.asm.transformers.AccessTransformer;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin; import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.*;
import java.util.Map.Entry;
import net.minecraft.launchwrapper.IClassTransformer;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.launchwrapper.LaunchClassLoader;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
public class MCPDeobfuscationTransformer implements IClassTransformer, Opcodes, IHeirachyEvaluator { public class MCPDeobfuscationTransformer implements IClassTransformer, Opcodes, IHeirachyEvaluator {
static { static {
ASMInit.init(); ASMInit.init();
} }
public static class LoadPlugin implements IFMLLoadingPlugin { public static class LoadPlugin implements IFMLLoadingPlugin {
@Override @Override
public String[] getASMTransformerClass() { public String[] getASMTransformerClass() {
return new String[0]; return new String[0];
@@ -72,8 +82,8 @@ public class MCPDeobfuscationTransformer implements IClassTransformer, Opcodes,
try { try {
f_transformers = LaunchClassLoader.class.getDeclaredField("transformers"); f_transformers = LaunchClassLoader.class.getDeclaredField("transformers");
f_modifiers = AccessTransformer.class.getDeclaredField("modifiers"); f_modifiers = AccessTransformer.class.getDeclaredField("modifiers");
Class<?> c_Modifier = Class<?> c_Modifier = Class
Class.forName(AccessTransformer.class.getName() + "$Modifier", false, Launch.classLoader); .forName(AccessTransformer.class.getName() + "$Modifier", false, Launch.classLoader);
f_Modifier_name = c_Modifier.getDeclaredField("name"); f_Modifier_name = c_Modifier.getDeclaredField("name");
f_Modifier_desc = c_Modifier.getDeclaredField("desc"); f_Modifier_desc = c_Modifier.getDeclaredField("desc");
@@ -110,8 +120,7 @@ public class MCPDeobfuscationTransformer implements IClassTransformer, Opcodes,
public static void load() { public static void load() {
CodeChickenCoreModContainer.loadConfig(); CodeChickenCoreModContainer.loadConfig();
if (CodeChickenCoreModContainer.config if (CodeChickenCoreModContainer.config.getTag("dev.deobfuscate")
.getTag("dev.deobfuscate")
.setComment("set to true to completely deobfuscate mcp names") .setComment("set to true to completely deobfuscate mcp names")
.getBooleanValue(!ObfMapping.obfuscated)) { .getBooleanValue(!ObfMapping.obfuscated)) {
run = new ObfuscationRun( run = new ObfuscationRun(
@@ -120,8 +129,7 @@ public class MCPDeobfuscationTransformer implements IClassTransformer, Opcodes,
ObfuscationRun.fillDefaults(new HashMap<String, String>())); ObfuscationRun.fillDefaults(new HashMap<String, String>()));
run.obf.setHeirachyEvaluator(instance); run.obf.setHeirachyEvaluator(instance);
run.setQuiet().parseMappings(); run.setQuiet().parseMappings();
Collections.addAll( Collections.addAll(excludedPackages, run.config.get("excludedPackages").split(";"));
excludedPackages, run.config.get("excludedPackages").split(";"));
if (ObfMapping.obfuscated) { if (ObfMapping.obfuscated) {
ObfMapping.loadMCPRemapper(); ObfMapping.loadMCPRemapper();
@@ -151,8 +159,12 @@ public class MCPDeobfuscationTransformer implements IClassTransformer, Opcodes,
private byte[] injectCallback(byte[] bytes) { private byte[] injectCallback(byte[] bytes) {
ClassNode cnode = ASMHelper.createClassNode(bytes); ClassNode cnode = ASMHelper.createClassNode(bytes);
MethodNode mnode = ASMHelper.findMethod(new ObfMapping(cnode.name, "<clinit>", "()V"), cnode); MethodNode mnode = ASMHelper.findMethod(new ObfMapping(cnode.name, "<clinit>", "()V"), cnode);
mnode.instructions.insert(new MethodInsnNode( mnode.instructions.insert(
INVOKESTATIC, "codechicken/core/asm/MCPDeobfuscationTransformer", "loadCallback", "()V")); new MethodInsnNode(
INVOKESTATIC,
"codechicken/core/asm/MCPDeobfuscationTransformer",
"loadCallback",
"()V"));
return ASMHelper.createBytes(cnode, 0); return ASMHelper.createBytes(cnode, 0);
} }
@@ -205,8 +217,7 @@ public class MCPDeobfuscationTransformer implements IClassTransformer, Opcodes,
try { try {
byte[] bytes = Launch.classLoader.getClassBytes(name); byte[] bytes = Launch.classLoader.getClassBytes(name);
if (bytes != null) return ObfuscationRun.getParents(ASMHelper.createClassNode(bytes)); if (bytes != null) return ObfuscationRun.getParents(ASMHelper.createClassNode(bytes));
} catch (IOException ignored) { } catch (IOException ignored) {}
}
// clear the miss cache because the library containing it might be loaded later // clear the miss cache because the library containing it might be loaded later
Launch.classLoader.clearNegativeEntries(Collections.singleton(name)); Launch.classLoader.clearNegativeEntries(Collections.singleton(name));
return null; return null;
@@ -1,18 +1,22 @@
package codechicken.core.asm; package codechicken.core.asm;
import static org.objectweb.asm.Opcodes.*; import static org.objectweb.asm.Opcodes.ASM4;
import codechicken.lib.asm.ObfMapping;
import java.io.File; import java.io.File;
import java.io.PrintWriter; import java.io.PrintWriter;
import net.minecraft.launchwrapper.Launch; import net.minecraft.launchwrapper.Launch;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.util.Printer; import org.objectweb.asm.util.Printer;
import org.objectweb.asm.util.TraceMethodVisitor; import org.objectweb.asm.util.TraceMethodVisitor;
import codechicken.lib.asm.ObfMapping;
public class MethodASMifier extends ClassVisitor { public class MethodASMifier extends ClassVisitor {
PrintWriter printWriter; PrintWriter printWriter;
ObfMapping method; ObfMapping method;
Printer asmifier; Printer asmifier;
@@ -1,20 +1,28 @@
package codechicken.core.asm; package codechicken.core.asm;
import static codechicken.lib.asm.InsnComparator.*; import static codechicken.lib.asm.InsnComparator.findOnce;
import codechicken.lib.asm.*;
import codechicken.lib.asm.ModularASMTransformer.MethodReplacer;
import codechicken.lib.asm.ModularASMTransformer.MethodTransformer;
import codechicken.lib.asm.ModularASMTransformer.MethodWriter;
import codechicken.lib.config.ConfigTag;
import java.util.Map; import java.util.Map;
import net.minecraft.launchwrapper.IClassTransformer; import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.JumpInsnNode; import org.objectweb.asm.tree.JumpInsnNode;
import org.objectweb.asm.tree.LabelNode; import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.MethodNode;
import codechicken.lib.asm.ASMBlock;
import codechicken.lib.asm.ASMInit;
import codechicken.lib.asm.ASMReader;
import codechicken.lib.asm.ModularASMTransformer;
import codechicken.lib.asm.ModularASMTransformer.MethodReplacer;
import codechicken.lib.asm.ModularASMTransformer.MethodTransformer;
import codechicken.lib.asm.ModularASMTransformer.MethodWriter;
import codechicken.lib.asm.ObfMapping;
import codechicken.lib.config.ConfigTag;
public class TweakTransformer implements IClassTransformer, Opcodes { public class TweakTransformer implements IClassTransformer, Opcodes {
static { static {
ASMInit.init(); ASMInit.init();
} }
@@ -25,43 +33,42 @@ public class TweakTransformer implements IClassTransformer, Opcodes {
public static void load() { public static void load() {
CodeChickenCoreModContainer.loadConfig(); CodeChickenCoreModContainer.loadConfig();
tweaks = CodeChickenCoreModContainer.config tweaks = CodeChickenCoreModContainer.config.getTag("tweaks")
.getTag("tweaks") .setComment("Various tweaks that can be applied to game mechanics.").useBraces();
.setComment("Various tweaks that can be applied to game mechanics.")
.useBraces();
tweaks.removeTag("persistantLava"); tweaks.removeTag("persistantLava");
if (tweaks.getTag("environmentallyFriendlyCreepers") if (tweaks.getTag("environmentallyFriendlyCreepers").setComment(
.setComment( "If set to true, creepers will not destroy landscape. (A version of mobGriefing setting just for creepers)")
"If set to true, creepers will not destroy landscape. (A version of mobGriefing setting just for creepers)")
.getBooleanValue(false)) { .getBooleanValue(false)) {
transformer.add(new MethodReplacer( transformer.add(
new ObfMapping("net/minecraft/entity/monster/EntityCreeper", "func_146077_cc", "()V"), new MethodReplacer(
blocks.get("d_environmentallyFriendlyCreepers"), new ObfMapping("net/minecraft/entity/monster/EntityCreeper", "func_146077_cc", "()V"),
blocks.get("environmentallyFriendlyCreepers"))); blocks.get("d_environmentallyFriendlyCreepers"),
blocks.get("environmentallyFriendlyCreepers")));
} }
if (!tweaks.getTag("softLeafReplace") if (!tweaks.getTag("softLeafReplace").setComment("If set to false, leaves will only replace air when growing")
.setComment("If set to false, leaves will only replace air when growing")
.getBooleanValue(false)) { .getBooleanValue(false)) {
transformer.add(new MethodWriter( transformer.add(
ACC_PUBLIC, new MethodWriter(
new ObfMapping( ACC_PUBLIC,
"net/minecraft/block/Block", new ObfMapping(
"canBeReplacedByLeaves", "net/minecraft/block/Block",
"(Lnet/minecraft/world/IBlockAccess;III)Z"), "canBeReplacedByLeaves",
blocks.get("softLeafReplace"))); "(Lnet/minecraft/world/IBlockAccess;III)Z"),
blocks.get("softLeafReplace")));
} }
if (tweaks.getTag("doFireTickOut") if (tweaks.getTag("doFireTickOut").setComment(
.setComment( "If set to true and doFireTick is disabled in the game rules, fire will still dissipate if it's not over a fire source")
"If set to true and doFireTick is disabled in the game rules, fire will still dissipate if it's not over a fire source")
.getBooleanValue(true)) { .getBooleanValue(true)) {
transformer.add( transformer.add(
new MethodTransformer(new ObfMapping( new MethodTransformer(
"net/minecraft/block/BlockFire", new ObfMapping(
"func_149674_a", "net/minecraft/block/BlockFire",
"(Lnet/minecraft/world/World;IIILjava/util/Random;)V")) { "func_149674_a",
"(Lnet/minecraft/world/World;IIILjava/util/Random;)V")) {
@Override @Override
public void transform(MethodNode mv) { public void transform(MethodNode mv) {
ASMBlock needle = blocks.get("n_doFireTick"); ASMBlock needle = blocks.get("n_doFireTick");
@@ -79,10 +86,12 @@ public class TweakTransformer implements IClassTransformer, Opcodes {
.setComment("If set to true two adjacent water source blocks will not generate a third.") .setComment("If set to true two adjacent water source blocks will not generate a third.")
.getBooleanValue(false)) { .getBooleanValue(false)) {
transformer.add( transformer.add(
new MethodTransformer(new ObfMapping( new MethodTransformer(
"net/minecraft/block/BlockDynamicLiquid", new ObfMapping(
"func_149674_a", "net/minecraft/block/BlockDynamicLiquid",
"(Lnet/minecraft/world/World;IIILjava/util/Random;)V")) { "func_149674_a",
"(Lnet/minecraft/world/World;IIILjava/util/Random;)V")) {
@Override @Override
public void transform(MethodNode mv) { public void transform(MethodNode mv) {
ASMBlock needle = blocks.get("finiteWater"); ASMBlock needle = blocks.get("finiteWater");
@@ -1,7 +1,7 @@
package codechicken.core.commands; package codechicken.core.commands;
import codechicken.core.ServerUtils;
import java.util.List; import java.util.List;
import net.minecraft.command.ICommand; import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender; import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -15,8 +15,12 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import codechicken.core.ServerUtils;
public abstract class CoreCommand implements ICommand { public abstract class CoreCommand implements ICommand {
public class WCommandSender implements ICommandSender { public class WCommandSender implements ICommandSender {
public ICommandSender wrapped; public ICommandSender wrapped;
public WCommandSender(ICommandSender sender) { public WCommandSender(ICommandSender sender) {
@@ -125,10 +129,8 @@ public abstract class CoreCommand implements ICommand {
@Override @Override
public boolean canCommandSenderUseCommand(ICommandSender var1) { public boolean canCommandSenderUseCommand(ICommandSender var1) {
if (OPOnly()) { if (OPOnly()) {
if (var1 instanceof EntityPlayer) if (var1 instanceof EntityPlayer) return MinecraftServer.getServer().getConfigurationManager()
return MinecraftServer.getServer() .func_152596_g(((EntityPlayer) var1).getGameProfile());
.getConfigurationManager()
.func_152596_g(((EntityPlayer) var1).getGameProfile());
else if (var1 instanceof MinecraftServer) return true; else if (var1 instanceof MinecraftServer) return true;
else return false; else return false;
} }
@@ -11,6 +11,7 @@ import net.minecraft.world.ChunkPosition;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
public abstract class PlayerCommand extends CoreCommand { public abstract class PlayerCommand extends CoreCommand {
@Override @Override
public boolean canCommandSenderUseCommand(ICommandSender var1) { public boolean canCommandSenderUseCommand(ICommandSender var1) {
if (!super.canCommandSenderUseCommand(var1)) return false; if (!super.canCommandSenderUseCommand(var1)) return false;
@@ -26,8 +27,8 @@ public abstract class PlayerCommand extends CoreCommand {
public abstract void handleCommand(WorldServer world, EntityPlayerMP player, String[] args); public abstract void handleCommand(WorldServer world, EntityPlayerMP player, String[] args);
public ChunkPosition getPlayerLookingAtBlock(EntityPlayerMP player, float reach) { public ChunkPosition getPlayerLookingAtBlock(EntityPlayerMP player, float reach) {
Vec3 vec3d = Vec3 vec3d = Vec3
Vec3.createVectorHelper(player.posX, (player.posY + 1.6200000000000001D) - player.yOffset, player.posZ); .createVectorHelper(player.posX, (player.posY + 1.6200000000000001D) - player.yOffset, player.posZ);
Vec3 vec3d1 = player.getLook(1.0F); Vec3 vec3d1 = player.getLook(1.0F);
Vec3 vec3d2 = vec3d.addVector(vec3d1.xCoord * reach, vec3d1.yCoord * reach, vec3d1.zCoord * reach); Vec3 vec3d2 = vec3d.addVector(vec3d1.xCoord * reach, vec3d1.yCoord * reach, vec3d1.zCoord * reach);
MovingObjectPosition hit = player.worldObj.rayTraceBlocks(vec3d, vec3d2); MovingObjectPosition hit = player.worldObj.rayTraceBlocks(vec3d, vec3d2);
@@ -39,8 +40,8 @@ public abstract class PlayerCommand extends CoreCommand {
} }
public Entity getPlayerLookingAtEntity(EntityPlayerMP player, float reach) { public Entity getPlayerLookingAtEntity(EntityPlayerMP player, float reach) {
Vec3 vec3d = Vec3 vec3d = Vec3
Vec3.createVectorHelper(player.posX, (player.posY + 1.6200000000000001D) - player.yOffset, player.posZ); .createVectorHelper(player.posX, (player.posY + 1.6200000000000001D) - player.yOffset, player.posZ);
Vec3 vec3d1 = player.getLook(1.0F); Vec3 vec3d1 = player.getLook(1.0F);
Vec3 vec3d2 = vec3d.addVector(vec3d1.xCoord * reach, vec3d1.yCoord * reach, vec3d1.zCoord * reach); Vec3 vec3d2 = vec3d.addVector(vec3d1.xCoord * reach, vec3d1.yCoord * reach, vec3d1.zCoord * reach);
MovingObjectPosition hit = player.worldObj.rayTraceBlocks(vec3d, vec3d2); MovingObjectPosition hit = player.worldObj.rayTraceBlocks(vec3d, vec3d2);
@@ -4,6 +4,7 @@ import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
public abstract class ServerCommand extends CoreCommand { public abstract class ServerCommand extends CoreCommand {
@Override @Override
public void processCommand(ICommandSender var1, String[] var2) { public void processCommand(ICommandSender var1, String[] var2) {
handleCommand(var2, (MinecraftServer) var1); handleCommand(var2, (MinecraftServer) var1);
@@ -5,7 +5,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
public class EntityRenderHook extends Entity { public class EntityRenderHook extends Entity {
public static interface IRenderCallback { public static interface IRenderCallback {
public void render(float frame, int pass); public void render(float frame, int pass);
public boolean shouldRenderInPass(int pass); public boolean shouldRenderInPass(int pass);
@@ -5,7 +5,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
public class EntityUpdateHook extends Entity { public class EntityUpdateHook extends Entity {
public static interface IUpdateCallback { public static interface IUpdateCallback {
public void onUpdate(); public void onUpdate();
public boolean isValid(); public boolean isValid();
@@ -6,6 +6,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class FeatureHack { public class FeatureHack {
private static boolean updateHookEnabled = false; private static boolean updateHookEnabled = false;
private static boolean renderHookEnabled = false; private static boolean renderHookEnabled = false;
@@ -1,14 +1,17 @@
package codechicken.core.featurehack; package codechicken.core.featurehack;
import codechicken.lib.asm.ObfMapping;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Map; import java.util.Map;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.ObjectIntIdentityMap; import net.minecraft.util.ObjectIntIdentityMap;
import net.minecraft.util.RegistryNamespaced; import net.minecraft.util.RegistryNamespaced;
import net.minecraft.util.RegistrySimple; import net.minecraft.util.RegistrySimple;
import codechicken.lib.asm.ObfMapping;
public class GameDataManipulator { public class GameDataManipulator {
public static Field f_registryObjects; public static Field f_registryObjects;
public static Field f_underlyingIntegerMap; public static Field f_underlyingIntegerMap;
@@ -16,15 +19,13 @@ public class GameDataManipulator {
try { try {
f_registryObjects = RegistrySimple.class.getDeclaredField( f_registryObjects = RegistrySimple.class.getDeclaredField(
new ObfMapping("net/minecraft/util/RegistrySimple", "field_82596_a", "Ljava/util/Map;") new ObfMapping("net/minecraft/util/RegistrySimple", "field_82596_a", "Ljava/util/Map;")
.toRuntime() .toRuntime().s_name);
.s_name);
f_registryObjects.setAccessible(true); f_registryObjects.setAccessible(true);
f_underlyingIntegerMap = RegistryNamespaced.class.getDeclaredField(new ObfMapping( f_underlyingIntegerMap = RegistryNamespaced.class.getDeclaredField(
new ObfMapping(
"net/minecraft/util/RegistryNamespaced", "net/minecraft/util/RegistryNamespaced",
"field_148759_a", "field_148759_a",
"Lnet/minecraft/util/ObjectIntIdentityMap;") "Lnet/minecraft/util/ObjectIntIdentityMap;").toRuntime().s_name);
.toRuntime()
.s_name);
f_underlyingIntegerMap.setAccessible(true); f_underlyingIntegerMap.setAccessible(true);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@@ -1,5 +1,12 @@
package codechicken.core.featurehack; package codechicken.core.featurehack;
import java.lang.reflect.Field;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import codechicken.core.ReflectionManager; import codechicken.core.ReflectionManager;
import codechicken.core.asm.TweakTransformer; import codechicken.core.asm.TweakTransformer;
import codechicken.core.featurehack.mc.TextureLavaFX; import codechicken.core.featurehack.mc.TextureLavaFX;
@@ -8,13 +15,9 @@ import codechicken.core.featurehack.mc.TextureWaterFX;
import codechicken.core.featurehack.mc.TextureWaterFlowFX; import codechicken.core.featurehack.mc.TextureWaterFlowFX;
import codechicken.lib.asm.ObfMapping; import codechicken.lib.asm.ObfMapping;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import java.lang.reflect.Field;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
public class LiquidTextures { public class LiquidTextures {
public static IIcon[] newTextures = new IIcon[4]; public static IIcon[] newTextures = new IIcon[4];
public static boolean replaceLava; public static boolean replaceLava;
@@ -23,14 +26,10 @@ public class LiquidTextures {
private static Field field_tex; private static Field field_tex;
public static void init() { public static void init() {
replaceWater = TweakTransformer.tweaks replaceWater = TweakTransformer.tweaks.getTag("replaceWaterFX")
.getTag("replaceWaterFX") .setComment("Set this to true to use the pre1.5 water textures").getBooleanValue(false);
.setComment("Set this to true to use the pre1.5 water textures") replaceLava = TweakTransformer.tweaks.getTag("replaceLavaFX")
.getBooleanValue(false); .setComment("Set this to true to use the pre1.5 lava textures").getBooleanValue(false);
replaceLava = TweakTransformer.tweaks
.getTag("replaceLavaFX")
.setComment("Set this to true to use the pre1.5 lava textures")
.getBooleanValue(false);
if (replaceWater) { if (replaceWater) {
newTextures[0] = new TextureWaterFX().texture; newTextures[0] = new TextureWaterFX().texture;
newTextures[1] = new TextureWaterFlowFX().texture; newTextures[1] = new TextureWaterFlowFX().texture;
@@ -4,9 +4,11 @@ import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.MinecraftForgeClient;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class RenderEntityRenderHook extends Render { public class RenderEntityRenderHook extends Render {
@Override @Override
public void doRender(Entity entity, double x, double y, double z, float f, float frame) { public void doRender(Entity entity, double x, double y, double z, float f, float frame) {
EntityRenderHook hook = (EntityRenderHook) entity; EntityRenderHook hook = (EntityRenderHook) entity;
@@ -5,6 +5,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
public class RenderNull extends Render { public class RenderNull extends Render {
@Override @Override
public void doRender(Entity var1, double var2, double var4, double var6, float var8, float var9) {} public void doRender(Entity var1, double var2, double var4, double var6, float var8, float var9) {}
@@ -3,23 +3,23 @@ package codechicken.core.featurehack;
import static net.minecraftforge.common.util.ForgeDirection.UP; import static net.minecraftforge.common.util.ForgeDirection.UP;
import java.util.Random; import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.world.World; import net.minecraft.world.World;
public class TweakTransformerHelper { public class TweakTransformerHelper {
public static void quenchFireTick(World world, int x, int y, int z, Random rand) { public static void quenchFireTick(World world, int x, int y, int z, Random rand) {
Block base = world.getBlock(x, y - 1, z); Block base = world.getBlock(x, y - 1, z);
boolean supported = (base != null && base.isFireSource(world, x, y - 1, z, UP)); boolean supported = (base != null && base.isFireSource(world, x, y - 1, z, UP));
if (!Blocks.fire.canPlaceBlockAt(world, x, y, z) if (!Blocks.fire.canPlaceBlockAt(world, x, y, z) || !supported && world.isRaining()
|| !supported && (world.canLightningStrikeAt(x, y, z) || world.canLightningStrikeAt(x - 1, y, z)
&& world.isRaining() || world.canLightningStrikeAt(x + 1, y, z)
&& (world.canLightningStrikeAt(x, y, z) || world.canLightningStrikeAt(x, y, z - 1)
|| world.canLightningStrikeAt(x - 1, y, z) || world.canLightningStrikeAt(x, y, z + 1)))
|| world.canLightningStrikeAt(x + 1, y, z) world.setBlockToAir(x, y, z);
|| world.canLightningStrikeAt(x, y, z - 1)
|| world.canLightningStrikeAt(x, y, z + 1))) world.setBlockToAir(x, y, z);
else { else {
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
if (meta < 15) world.setBlockMetadataWithNotify(x, y, z, meta + rand.nextInt(3) / 2, 0); if (meta < 15) world.setBlockMetadataWithNotify(x, y, z, meta + rand.nextInt(3) / 2, 0);
@@ -1,13 +1,15 @@
package codechicken.core.featurehack.mc; package codechicken.core.featurehack.mc;
import net.minecraft.util.MathHelper;
import codechicken.lib.colour.ColourRGBA; import codechicken.lib.colour.ColourRGBA;
import codechicken.lib.render.TextureFX; import codechicken.lib.render.TextureFX;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.MathHelper;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class TextureLavaFX extends TextureFX { public class TextureLavaFX extends TextureFX {
protected float[] field_76876_g = new float[256]; protected float[] field_76876_g = new float[256];
protected float[] field_76878_h = new float[256]; protected float[] field_76878_h = new float[256];
protected float[] field_76879_i = new float[256]; protected float[] field_76879_i = new float[256];
@@ -52,16 +54,16 @@ public class TextureLavaFX extends TextureFX {
this.field_76878_h[var1 + var2 * tileSizeBase] = var3 / 10.0F this.field_76878_h[var1 + var2 * tileSizeBase] = var3 / 10.0F
+ (this.field_76879_i[(var1 + 0 & tileSizeMask) + (var2 + 0 & tileSizeMask) * tileSizeBase] + (this.field_76879_i[(var1 + 0 & tileSizeMask) + (var2 + 0 & tileSizeMask) * tileSizeBase]
+ this.field_76879_i[ + this.field_76879_i[(var1 + 1 & tileSizeMask)
(var1 + 1 & tileSizeMask) + (var2 + 0 & tileSizeMask) * tileSizeBase] + (var2 + 0 & tileSizeMask) * tileSizeBase]
+ this.field_76879_i[ + this.field_76879_i[(var1 + 1 & tileSizeMask)
(var1 + 1 & tileSizeMask) + (var2 + 1 & tileSizeMask) * tileSizeBase] + (var2 + 1 & tileSizeMask) * tileSizeBase]
+ this.field_76879_i[ + this.field_76879_i[(var1 + 0 & tileSizeMask)
(var1 + 0 & tileSizeMask) + (var2 + 1 & tileSizeMask) * tileSizeBase]) + (var2 + 1 & tileSizeMask) * tileSizeBase])
/ 4.0F / 4.0F
* 0.8F; * 0.8F;
this.field_76879_i[var1 + var2 * tileSizeBase] += this.field_76879_i[var1 + var2 * tileSizeBase] += this.field_76877_j[var1 + var2 * tileSizeBase]
this.field_76877_j[var1 + var2 * tileSizeBase] * 0.01F; * 0.01F;
if (this.field_76879_i[var1 + var2 * tileSizeBase] < 0.0F) { if (this.field_76879_i[var1 + var2 * tileSizeBase] < 0.0F) {
this.field_76879_i[var1 + var2 * tileSizeBase] = 0.0F; this.field_76879_i[var1 + var2 * tileSizeBase] = 0.0F;
@@ -1,13 +1,15 @@
package codechicken.core.featurehack.mc; package codechicken.core.featurehack.mc;
import net.minecraft.util.MathHelper;
import codechicken.lib.colour.ColourRGBA; import codechicken.lib.colour.ColourRGBA;
import codechicken.lib.render.TextureFX; import codechicken.lib.render.TextureFX;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.MathHelper;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class TextureLavaFlowFX extends TextureFX { public class TextureLavaFlowFX extends TextureFX {
protected float[] field_76871_g = new float[256]; protected float[] field_76871_g = new float[256];
protected float[] field_76874_h = new float[256]; protected float[] field_76874_h = new float[256];
protected float[] field_76875_i = new float[256]; protected float[] field_76875_i = new float[256];
@@ -60,16 +62,16 @@ public class TextureLavaFlowFX extends TextureFX {
this.field_76874_h[var1 + var2 * tileSizeBase] = var3 / 10.0F this.field_76874_h[var1 + var2 * tileSizeBase] = var3 / 10.0F
+ (this.field_76875_i[(var1 + 0 & tileSizeMask) + (var2 + 0 & tileSizeMask) * tileSizeBase] + (this.field_76875_i[(var1 + 0 & tileSizeMask) + (var2 + 0 & tileSizeMask) * tileSizeBase]
+ this.field_76875_i[ + this.field_76875_i[(var1 + 1 & tileSizeMask)
(var1 + 1 & tileSizeMask) + (var2 + 0 & tileSizeMask) * tileSizeBase] + (var2 + 0 & tileSizeMask) * tileSizeBase]
+ this.field_76875_i[ + this.field_76875_i[(var1 + 1 & tileSizeMask)
(var1 + 1 & tileSizeMask) + (var2 + 1 & tileSizeMask) * tileSizeBase] + (var2 + 1 & tileSizeMask) * tileSizeBase]
+ this.field_76875_i[ + this.field_76875_i[(var1 + 0 & tileSizeMask)
(var1 + 0 & tileSizeMask) + (var2 + 1 & tileSizeMask) * tileSizeBase]) + (var2 + 1 & tileSizeMask) * tileSizeBase])
/ 4.0F / 4.0F
* 0.8F; * 0.8F;
this.field_76875_i[var1 + var2 * tileSizeBase] += this.field_76875_i[var1 + var2 * tileSizeBase] += this.field_76872_j[var1 + var2 * tileSizeBase]
this.field_76872_j[var1 + var2 * tileSizeBase] * 0.01F; * 0.01F;
if (this.field_76875_i[var1 + var2 * tileSizeBase] < 0.0F) { if (this.field_76875_i[var1 + var2 * tileSizeBase] < 0.0F) {
this.field_76875_i[var1 + var2 * tileSizeBase] = 0.0F; this.field_76875_i[var1 + var2 * tileSizeBase] = 0.0F;
@@ -7,6 +7,7 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class TextureWaterFX extends TextureFX { public class TextureWaterFX extends TextureFX {
/** red RGB value for water texture */ /** red RGB value for water texture */
protected float[] red = new float[256]; protected float[] red = new float[256];
@@ -7,6 +7,7 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class TextureWaterFlowFX extends TextureFX { public class TextureWaterFlowFX extends TextureFX {
protected float[] field_76880_g = new float[256]; protected float[] field_76880_g = new float[256];
protected float[] field_76883_h = new float[256]; protected float[] field_76883_h = new float[256];
protected float[] field_76884_i = new float[256]; protected float[] field_76884_i = new float[256];
@@ -51,15 +52,15 @@ public class TextureWaterFlowFX extends TextureFX {
var3 += this.field_76880_g[var5 + var6 * tileSizeBase]; var3 += this.field_76880_g[var5 + var6 * tileSizeBase];
} }
this.field_76883_h[var1 + var2 * tileSizeBase] = this.field_76883_h[var1 + var2 * tileSizeBase] = var3 / 3.2F
var3 / 3.2F + this.field_76884_i[var1 + var2 * tileSizeBase] * 0.8F; + this.field_76884_i[var1 + var2 * tileSizeBase] * 0.8F;
} }
} }
for (var1 = 0; var1 < tileSizeBase; ++var1) { for (var1 = 0; var1 < tileSizeBase; ++var1) {
for (var2 = 0; var2 < tileSizeBase; ++var2) { for (var2 = 0; var2 < tileSizeBase; ++var2) {
this.field_76884_i[var1 + var2 * tileSizeBase] += this.field_76884_i[var1 + var2 * tileSizeBase] += this.field_76881_j[var1 + var2 * tileSizeBase]
this.field_76881_j[var1 + var2 * tileSizeBase] * 0.05F; * 0.05F;
if (this.field_76884_i[var1 + var2 * tileSizeBase] < 0.0F) { if (this.field_76884_i[var1 + var2 * tileSizeBase] < 0.0F) {
this.field_76884_i[var1 + var2 * tileSizeBase] = 0.0F; this.field_76884_i[var1 + var2 * tileSizeBase] = 0.0F;
@@ -6,6 +6,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidTank; import net.minecraftforge.fluids.IFluidTank;
public class ExtendedFluidTank implements IFluidTank { public class ExtendedFluidTank implements IFluidTank {
private FluidStack fluid; private FluidStack fluid;
private boolean changeType; private boolean changeType;
private int capacity; private int capacity;
@@ -1,6 +1,5 @@
package codechicken.core.fluid; package codechicken.core.fluid;
import codechicken.lib.inventory.InventoryUtils;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@@ -11,7 +10,10 @@ import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import codechicken.lib.inventory.InventoryUtils;
public class FluidUtils { public class FluidUtils {
public static int B = FluidContainerRegistry.BUCKET_VOLUME; public static int B = FluidContainerRegistry.BUCKET_VOLUME;
public static FluidStack water = new FluidStack(FluidRegistry.WATER, 1000); public static FluidStack water = new FluidStack(FluidRegistry.WATER, 1000);
public static FluidStack lava = new FluidStack(FluidRegistry.LAVA, 1000); public static FluidStack lava = new FluidStack(FluidRegistry.LAVA, 1000);
@@ -68,8 +70,7 @@ public class FluidUtils {
} }
public static NBTTagCompound write(FluidStack fluid, NBTTagCompound tag) { public static NBTTagCompound write(FluidStack fluid, NBTTagCompound tag) {
return fluid == null || fluid.getFluid() == null return fluid == null || fluid.getFluid() == null ? new NBTTagCompound()
? new NBTTagCompound()
: fluid.writeToNBT(new NBTTagCompound()); : fluid.writeToNBT(new NBTTagCompound());
} }
@@ -5,6 +5,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
public class TankAccess { public class TankAccess {
public IFluidHandler tank; public IFluidHandler tank;
public ForgeDirection side; public ForgeDirection side;
@@ -1,11 +1,14 @@
package codechicken.core.gui; package codechicken.core.gui;
import com.google.common.base.Objects;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import com.google.common.base.Objects;
public class ClickCounter<T> { public class ClickCounter<T> {
public class ClickCount { public class ClickCount {
public T clicked; public T clicked;
public long time; public long time;
public int count; public int count;
@@ -3,9 +3,11 @@ package codechicken.core.gui;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class GuiCCButton extends GuiWidget { public class GuiCCButton extends GuiWidget {
public String text; public String text;
public String actionCommand; public String actionCommand;
private boolean isEnabled = true; private boolean isEnabled = true;
@@ -32,8 +34,7 @@ public class GuiCCButton extends GuiWidget {
public void mouseClicked(int x, int y, int button) { public void mouseClicked(int x, int y, int button) {
if (isEnabled && pointInside(x, y) && actionCommand != null) { if (isEnabled && pointInside(x, y) && actionCommand != null) {
sendAction(actionCommand, button); sendAction(actionCommand, button);
Minecraft.getMinecraft() Minecraft.getMinecraft().getSoundHandler()
.getSoundHandler()
.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); .playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
} }
} }
@@ -52,8 +53,8 @@ public class GuiCCButton extends GuiWidget {
int state = getButtonTex(mousex, mousey); int state = getButtonTex(mousex, mousey);
drawTexturedModalRect(x, y, 0, 46 + state * 20, width / 2, height / 2); // top left drawTexturedModalRect(x, y, 0, 46 + state * 20, width / 2, height / 2); // top left
drawTexturedModalRect(x + width / 2, y, 200 - width / 2, 46 + state * 20, width / 2, height / 2); // top right drawTexturedModalRect(x + width / 2, y, 200 - width / 2, 46 + state * 20, width / 2, height / 2); // top right
drawTexturedModalRect( drawTexturedModalRect(x, y + height / 2, 0, 46 + state * 20 + 20 - height / 2, width / 2, height / 2); // bottom
x, y + height / 2, 0, 46 + state * 20 + 20 - height / 2, width / 2, height / 2); // bottom left // left
drawTexturedModalRect( drawTexturedModalRect(
x + width / 2, x + width / 2,
y + height / 2, y + height / 2,
@@ -2,9 +2,11 @@ package codechicken.core.gui;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ChatAllowedCharacters; import net.minecraft.util.ChatAllowedCharacters;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
public class GuiCCTextField extends GuiWidget { public class GuiCCTextField extends GuiWidget {
private String text; private String text;
private boolean isFocused; private boolean isFocused;
private boolean isEnabled; private boolean isEnabled;
@@ -63,10 +65,9 @@ public class GuiCCTextField extends GuiWidget {
public void keyTyped(char c, int keycode) { public void keyTyped(char c, int keycode) {
if (!isEnabled || !isFocused) return; if (!isEnabled || !isFocused) return;
/*if(c == '\t')//tab /*
{ * if(c == '\t')//tab { parentGuiScreen.selectNextField(); }
parentGuiScreen.selectNextField(); */
}*/
if (c == '\026') // paste if (c == '\026') // paste
{ {
String s = GuiScreen.getClipboardString(); String s = GuiScreen.getClipboardString();
@@ -90,8 +91,7 @@ public class GuiCCTextField extends GuiWidget {
} }
public boolean canAddChar(char c) { public boolean canAddChar(char c) {
return allowedCharacters == null return allowedCharacters == null ? ChatAllowedCharacters.isAllowedCharacter(c)
? ChatAllowedCharacters.isAllowedCharacter(c)
: allowedCharacters.indexOf(c) >= 0; : allowedCharacters.indexOf(c) >= 0;
} }
@@ -1,14 +1,18 @@
package codechicken.core.gui; package codechicken.core.gui;
import codechicken.lib.gui.GuiDraw;
import java.awt.Point; import java.awt.Point;
import java.util.ArrayList; import java.util.ArrayList;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import codechicken.lib.gui.GuiDraw;
public class GuiScreenWidget extends GuiScreen implements IGuiActionListener { public class GuiScreenWidget extends GuiScreen implements IGuiActionListener {
public ArrayList<GuiWidget> widgets = new ArrayList<GuiWidget>(); public ArrayList<GuiWidget> widgets = new ArrayList<GuiWidget>();
public int xSize, ySize, guiTop, guiLeft; public int xSize, ySize, guiTop, guiLeft;
@@ -1,10 +1,13 @@
package codechicken.core.gui; package codechicken.core.gui;
import java.awt.Dimension;
import java.awt.Rectangle;
import codechicken.lib.math.MathHelper; import codechicken.lib.math.MathHelper;
import codechicken.lib.vec.Rectangle4i; import codechicken.lib.vec.Rectangle4i;
import java.awt.*;
public abstract class GuiScrollPane extends GuiWidget { public abstract class GuiScrollPane extends GuiWidget {
protected int scrollclicky = -1; protected int scrollclicky = -1;
protected float scrollpercent; protected float scrollpercent;
protected int scrollmousey; protected int scrollmousey;
@@ -28,7 +31,10 @@ public abstract class GuiScrollPane extends GuiWidget {
public Rectangle windowBounds() { public Rectangle windowBounds() {
return new Rectangle( return new Rectangle(
x + marginleft, y + margintop, width - marginleft - marginright, height - margintop - marginbottom); x + marginleft,
y + margintop,
width - marginleft - marginright,
height - margintop - marginbottom);
} }
public abstract int contentHeight(); public abstract int contentHeight();
@@ -103,13 +109,8 @@ public abstract class GuiScrollPane extends GuiWidget {
Rectangle w = windowBounds(); Rectangle w = windowBounds();
int barempty = height - sbar.height; int barempty = height - sbar.height;
if (button == 0 if (button == 0 && sbar.height < height && // the scroll bar can move (not full length)
&& sbar.height < height mx >= sbar.x && mx <= sbar.x + sbar.width && my >= y && my <= y + height) // in the scroll pane
&& // the scroll bar can move (not full length)
mx >= sbar.x
&& mx <= sbar.x + sbar.width
&& my >= y
&& my <= y + height) // in the scroll pane
{ {
if (my < sbar.y) { if (my < sbar.y) {
percentscrolled = (my - y) / (float) barempty; percentscrolled = (my - y) / (float) barempty;
@@ -126,14 +127,12 @@ public abstract class GuiScrollPane extends GuiWidget {
} }
/** /**
* Mouse down on slot area * Mouse down on slot area Coordinates relative to slot content area
* Coordinates relative to slot content area
*/ */
public void slotDown(int mx, int my, int button) {} public void slotDown(int mx, int my, int button) {}
/** /**
* Mouse up on slot area * Mouse up on slot area Coordinates relative to slot content area
* Coordinates relative to slot content area
*/ */
public void slotUp(int mx, int my, int button) {} public void slotUp(int mx, int my, int button) {}
@@ -141,7 +140,7 @@ public abstract class GuiScrollPane extends GuiWidget {
public void mouseMovedOrUp(int mx, int my, int button) { public void mouseMovedOrUp(int mx, int my, int button) {
Rectangle w = windowBounds(); Rectangle w = windowBounds();
if (isScrolling() && button == 0) // we were scrolling and we released mouse if (isScrolling() && button == 0) // we were scrolling and we released mouse
scrollclicky = -1; scrollclicky = -1;
else if (w.contains(mx, my)) slotUp(mx - w.x, my - w.y + scrolledPixels(), button); else if (w.contains(mx, my)) slotUp(mx - w.x, my - w.y + scrolledPixels(), button);
} }
@@ -1,9 +1,11 @@
package codechicken.core.gui; package codechicken.core.gui;
import java.awt.*; import java.awt.Rectangle;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
public abstract class GuiScrollSlot extends GuiScrollPane { public abstract class GuiScrollSlot extends GuiScrollPane {
protected String actionCommand; protected String actionCommand;
public boolean focused; public boolean focused;
protected ClickCounter<Integer> click = new ClickCounter<Integer>(); protected ClickCounter<Integer> click = new ClickCounter<Integer>();
@@ -8,6 +8,7 @@ import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
public class GuiWidget extends Gui { public class GuiWidget extends Gui {
protected static final ResourceLocation guiTex = new ResourceLocation("textures/gui/widgets.png"); protected static final ResourceLocation guiTex = new ResourceLocation("textures/gui/widgets.png");
public GuiScreen parentScreen; public GuiScreen parentScreen;
@@ -1,5 +1,6 @@
package codechicken.core.gui; package codechicken.core.gui;
public interface IGuiActionListener { public interface IGuiActionListener {
public void actionPerformed(String actionCommand, Object... params); public void actionPerformed(String actionCommand, Object... params);
} }
@@ -1,5 +1,7 @@
package codechicken.core.internal; package codechicken.core.internal;
import net.minecraftforge.client.event.GuiScreenEvent;
import codechicken.core.CCUpdateChecker; import codechicken.core.CCUpdateChecker;
import codechicken.core.GuiModListScroll; import codechicken.core.GuiModListScroll;
import cpw.mods.fml.client.GuiModList; import cpw.mods.fml.client.GuiModList;
@@ -8,9 +10,9 @@ import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.client.event.GuiScreenEvent;
public class CCCEventHandler { public class CCCEventHandler {
public static int renderTime; public static int renderTime;
public static float renderFrame; public static float renderFrame;
@@ -1,17 +1,21 @@
package codechicken.core.inventory; package codechicken.core.inventory;
import java.awt.Point;
import java.util.ArrayList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Container;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import codechicken.core.gui.GuiWidget; import codechicken.core.gui.GuiWidget;
import codechicken.core.gui.IGuiActionListener; import codechicken.core.gui.IGuiActionListener;
import codechicken.lib.gui.GuiDraw; import codechicken.lib.gui.GuiDraw;
import java.awt.Point;
import java.util.ArrayList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Container;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
public class GuiContainerWidget extends GuiContainer implements IGuiActionListener { public class GuiContainerWidget extends GuiContainer implements IGuiActionListener {
public ArrayList<GuiWidget> widgets = new ArrayList<GuiWidget>(); public ArrayList<GuiWidget> widgets = new ArrayList<GuiWidget>();
public GuiContainerWidget(Container inventorySlots) { public GuiContainerWidget(Container inventorySlots) {
@@ -1,17 +1,7 @@
package codechicken.core.launch; package codechicken.core.launch;
import codechicken.core.asm.*; import java.awt.Desktop;
import codechicken.lib.config.ConfigTag; import java.awt.GraphicsEnvironment;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
import cpw.mods.fml.common.versioning.VersionParser;
import cpw.mods.fml.relauncher.CoreModManager;
import cpw.mods.fml.relauncher.FMLInjectionData;
import cpw.mods.fml.relauncher.IFMLCallHook;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
import java.awt.*;
import java.io.File; import java.io.File;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@@ -22,20 +12,39 @@ import java.util.Map;
import java.util.jar.Attributes; import java.util.jar.Attributes;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.jar.Manifest; import java.util.jar.Manifest;
import javax.swing.JEditorPane; import javax.swing.JEditorPane;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener; import javax.swing.event.HyperlinkListener;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@TransformerExclusions(value = {"codechicken.core.asm", "codechicken.obfuscator"}) import codechicken.core.asm.CodeChickenCoreModContainer;
import codechicken.core.asm.DelegatedTransformer;
import codechicken.core.asm.MCPDeobfuscationTransformer;
import codechicken.core.asm.Tags;
import codechicken.core.asm.TweakTransformer;
import codechicken.lib.config.ConfigTag;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
import cpw.mods.fml.common.versioning.VersionParser;
import cpw.mods.fml.relauncher.CoreModManager;
import cpw.mods.fml.relauncher.FMLInjectionData;
import cpw.mods.fml.relauncher.IFMLCallHook;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
@TransformerExclusions(value = { "codechicken.core.asm", "codechicken.obfuscator" })
@MCVersion("1.7.10") @MCVersion("1.7.10")
public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook { public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
public static final String mcVersion = "[1.7.10]"; public static final String mcVersion = "[1.7.10]";
@Deprecated @Deprecated
public static final String version = "1.1.3-unused"; public static final String version = Tags.VERSION;
public static File minecraftDir; public static File minecraftDir;
public static String currentMcVersion; public static String currentMcVersion;
@@ -54,20 +63,19 @@ public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
private void injectDeobfPlugin() { private void injectDeobfPlugin() {
try { try {
Class<?> wrapperClass = Class.forName("cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper"); Class<?> wrapperClass = Class.forName("cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper");
Constructor wrapperConstructor = wrapperClass.getConstructor( Constructor wrapperConstructor = wrapperClass
String.class, IFMLLoadingPlugin.class, File.class, Integer.TYPE, String[].class); .getConstructor(String.class, IFMLLoadingPlugin.class, File.class, Integer.TYPE, String[].class);
Field f_loadPlugins = CoreModManager.class.getDeclaredField("loadPlugins"); Field f_loadPlugins = CoreModManager.class.getDeclaredField("loadPlugins");
wrapperConstructor.setAccessible(true); wrapperConstructor.setAccessible(true);
f_loadPlugins.setAccessible(true); f_loadPlugins.setAccessible(true);
((List) f_loadPlugins.get(null)) ((List) f_loadPlugins.get(null)).add(
.add( 2,
2, wrapperConstructor.newInstance(
wrapperConstructor.newInstance( "CCCDeobfPlugin",
"CCCDeobfPlugin", new MCPDeobfuscationTransformer.LoadPlugin(),
new MCPDeobfuscationTransformer.LoadPlugin(), null,
null, 0,
0, new String[0]));
new String[0]));
} catch (Exception e) { } catch (Exception e) {
logger.error("Failed to inject MCPDeobfuscation Transformer", e); logger.error("Failed to inject MCPDeobfuscation Transformer", e);
} }
@@ -88,13 +96,13 @@ public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
ep.setEditable(false); ep.setEditable(false);
ep.setOpaque(false); ep.setOpaque(false);
ep.addHyperlinkListener(new HyperlinkListener() { ep.addHyperlinkListener(new HyperlinkListener() {
@Override @Override
public void hyperlinkUpdate(HyperlinkEvent event) { public void hyperlinkUpdate(HyperlinkEvent event) {
try { try {
if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
Desktop.getDesktop().browse(event.getURL().toURI()); Desktop.getDesktop().browse(event.getURL().toURI());
} catch (Exception ignored) { } catch (Exception ignored) {}
}
} }
}); });
@@ -134,45 +142,43 @@ public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
} }
public static void systemCheck(ConfigTag checkRAM) { public static void systemCheck(ConfigTag checkRAM) {
long minBytes = parseSize(checkRAM.getTag("minRAM") long minBytes = parseSize(
.setComment("Amount of RAM minimum this modpack needs to load") checkRAM.getTag("minRAM").setComment("Amount of RAM minimum this modpack needs to load")
.getValue("3GB")); .getValue("3GB"));
if (Runtime.getRuntime().maxMemory() < minBytes) { if (Runtime.getRuntime().maxMemory() < minBytes) {
String err = "You should have at least " + humanReadableByteCountBin(minBytes) String err = "You should have at least " + humanReadableByteCountBin(minBytes)
+ " of RAM but you have only allocated " + " of RAM but you have only allocated "
+ humanReadableByteCountBin(Runtime.getRuntime().maxMemory()) + "."; + humanReadableByteCountBin(Runtime.getRuntime().maxMemory())
+ ".";
logger.error(err); logger.error(err);
JEditorPane ep = new JEditorPane( JEditorPane ep = new JEditorPane(
"text/html", "text/html",
"<html>" + err + "<br>" "<html>" + err
+ checkRAM.getTag("modPack") + "<br>"
.setComment("Name of the modpack") + checkRAM.getTag("modPack").setComment("Name of the modpack")
.getValue("Unidentified ModPack") .getValue("Unidentified ModPack")
+ " seriously won't run without enough RAM. " + " seriously won't run without enough RAM. "
+ checkRAM.getTag("wiki") + checkRAM.getTag("wiki").setComment("Webpage describing RAM settings").getValue(
.setComment("Webpage describing RAM settings") "See <a href=\"https://downloadmoreram.com\">DownloadMoreRam.com</a> for details.")
.getValue(
"See <a href=\"https://downloadmoreram.com\">DownloadMoreRam.com</a> for details.")
+ "<br>Recommended values are between " + "<br>Recommended values are between "
+ checkRAM.getTag("recRAM") + checkRAM.getTag("recRAM").setComment("Lower bound of recommended RAM").getValue("4GB")
.setComment("Lower bound of recommended RAM") + " and "
.getValue("4GB") + " and " + checkRAM.getTag("recRAMUpper").setComment("Upper bound of recommended RAM")
+ checkRAM.getTag("recRAMUpper")
.setComment("Upper bound of recommended RAM")
.getValue("6GB") .getValue("6GB")
+ ". Check your launcher's JVM arguments." + "</html>"); + ". Check your launcher's JVM arguments."
+ "</html>");
ep.setEditable(false); ep.setEditable(false);
ep.setOpaque(false); ep.setOpaque(false);
ep.addHyperlinkListener(new HyperlinkListener() { ep.addHyperlinkListener(new HyperlinkListener() {
@Override @Override
public void hyperlinkUpdate(HyperlinkEvent event) { public void hyperlinkUpdate(HyperlinkEvent event) {
try { try {
if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
Desktop.getDesktop().browse(event.getURL().toURI()); Desktop.getDesktop().browse(event.getURL().toURI());
} catch (Exception ignored) { } catch (Exception ignored) {}
}
} }
}); });
@@ -185,12 +191,9 @@ public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
@Override @Override
public String[] getASMTransformerClass() { public String[] getASMTransformerClass() {
versionCheck(mcVersion, "CodeChickenCore"); versionCheck(mcVersion, "CodeChickenCore");
return new String[] { return new String[] { "codechicken.lib.asm.ClassHeirachyManager", "codechicken.core.asm.TweakTransformer",
"codechicken.lib.asm.ClassHeirachyManager", "codechicken.core.asm.DelegatedTransformer", "codechicken.core.asm.DefaultImplementationTransformer",
"codechicken.core.asm.TweakTransformer", "codechicken.lib.asm.RedirectorTransformer" };
"codechicken.core.asm.DelegatedTransformer",
"codechicken.core.asm.DefaultImplementationTransformer"
};
} }
@Override @Override
@@ -215,13 +218,12 @@ public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
public Void call() { public Void call() {
CodeChickenCoreModContainer.loadConfig(); CodeChickenCoreModContainer.loadConfig();
ConfigTag checkRAM; ConfigTag checkRAM;
checkRAM = CodeChickenCoreModContainer.config checkRAM = CodeChickenCoreModContainer.config.getTag("checks")
.getTag("checks") .setComment("Configuration options for checking various requirements for a modpack.").useBraces();
.setComment("Configuration options for checking various requirements for a modpack.")
.useBraces();
if (checkRAM.getTag("checkRAM") if (checkRAM.getTag("checkRAM")
.setComment("If set to true, check RAM available for Minecraft before continuing to load") .setComment("If set to true, check RAM available for Minecraft before continuing to load")
.getBooleanValue(false)) systemCheck(checkRAM); .getBooleanValue(false))
systemCheck(checkRAM);
TweakTransformer.load(); TweakTransformer.load();
scanCodeChickenMods(); scanCodeChickenMods();
@@ -1,52 +1,76 @@
package codechicken.core.launch; package codechicken.core.launch;
import com.google.gson.JsonElement; import java.awt.Desktop;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import cpw.mods.fml.common.versioning.ComparableVersion;
import cpw.mods.fml.relauncher.FMLInjectionData;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
import cpw.mods.fml.relauncher.IFMLCallHook;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
import java.awt.*;
import java.awt.Dialog.ModalityType; import java.awt.Dialog.ModalityType;
import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.io.*; import java.io.Closeable;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.InterruptedIOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.*; import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException; import java.util.regex.PatternSyntaxException;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import javax.swing.*;
import javax.swing.Box;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JProgressBar;
import javax.swing.WindowConstants;
import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener; import javax.swing.event.HyperlinkListener;
import net.minecraft.launchwrapper.LaunchClassLoader; import net.minecraft.launchwrapper.LaunchClassLoader;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import cpw.mods.fml.common.versioning.ComparableVersion;
import cpw.mods.fml.relauncher.FMLInjectionData;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
import cpw.mods.fml.relauncher.IFMLCallHook;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
import sun.misc.URLClassPath; import sun.misc.URLClassPath;
import sun.net.util.URLUtil; import sun.net.util.URLUtil;
/** /**
* For autodownloading stuff. * For autodownloading stuff. This is really unoriginal, mostly ripped off FML, credits to cpw.
* This is really unoriginal, mostly ripped off FML, credits to cpw.
*/ */
@MCVersion("1.7.10") @MCVersion("1.7.10")
public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook { public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
private static ByteBuffer downloadBuffer = ByteBuffer.allocateDirect(1 << 23); private static ByteBuffer downloadBuffer = ByteBuffer.allocateDirect(1 << 23);
private static final String owner = "CB's DepLoader"; private static final String owner = "CB's DepLoader";
private static DepLoadInst inst; private static DepLoadInst inst;
public interface IDownloadDisplay { public interface IDownloadDisplay {
void resetProgress(int sizeGuess); void resetProgress(int sizeGuess);
void setPokeThread(Thread currentThread); void setPokeThread(Thread currentThread);
@@ -64,6 +88,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
@SuppressWarnings("serial") @SuppressWarnings("serial")
public static class Downloader extends JOptionPane implements IDownloadDisplay { public static class Downloader extends JOptionPane implements IDownloadDisplay {
private JDialog container; private JDialog container;
private JLabel currentActivity; private JLabel currentActivity;
private JProgressBar progress; private JProgressBar progress;
@@ -73,12 +98,13 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
private Box makeProgressPanel() { private Box makeProgressPanel() {
Box box = Box.createVerticalBox(); Box box = Box.createVerticalBox();
box.add(Box.createRigidArea(new Dimension(0, 10))); box.add(Box.createRigidArea(new Dimension(0, 10)));
JLabel welcomeLabel = new JLabel("<html><b><font size='+1'>" + owner JLabel welcomeLabel = new JLabel(
+ " is setting up your minecraft environment</font></b></html>"); "<html><b><font size='+1'>" + owner
+ " is setting up your minecraft environment</font></b></html>");
box.add(welcomeLabel); box.add(welcomeLabel);
welcomeLabel.setAlignmentY(LEFT_ALIGNMENT); welcomeLabel.setAlignmentY(LEFT_ALIGNMENT);
welcomeLabel = welcomeLabel = new JLabel(
new JLabel("<html>Please wait, " + owner + " has some tasks to do before you can play</html>"); "<html>Please wait, " + owner + " has some tasks to do before you can play</html>");
welcomeLabel.setAlignmentY(LEFT_ALIGNMENT); welcomeLabel.setAlignmentY(LEFT_ALIGNMENT);
box.add(welcomeLabel); box.add(welcomeLabel);
box.add(Box.createRigidArea(new Dimension(0, 10))); box.add(Box.createRigidArea(new Dimension(0, 10)));
@@ -98,8 +124,9 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
setMessageType(JOptionPane.INFORMATION_MESSAGE); setMessageType(JOptionPane.INFORMATION_MESSAGE);
setMessage(makeProgressPanel()); setMessage(makeProgressPanel());
setOptions(new Object[] {"Stop"}); setOptions(new Object[] { "Stop" });
addPropertyChangeListener(new PropertyChangeListener() { addPropertyChangeListener(new PropertyChangeListener() {
@Override @Override
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
if (evt.getSource() == Downloader.this && evt.getPropertyName() == VALUE_PROPERTY) { if (evt.getSource() == Downloader.this && evt.getPropertyName() == VALUE_PROPERTY) {
@@ -117,6 +144,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
container.setVisible(true); container.setVisible(true);
container.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); container.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
container.addWindowListener(new WindowAdapter() { container.addWindowListener(new WindowAdapter() {
@Override @Override
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
requestClose( requestClose(
@@ -170,21 +198,26 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
JEditorPane ep = new JEditorPane( JEditorPane ep = new JEditorPane(
"text/html", "text/html",
"<html>" + owner "<html>" + owner
+ " was unable to download required library " + name + " was unable to download required library "
+ name
+ "<br>Check your internet connection and try restarting or download it manually from" + "<br>Check your internet connection and try restarting or download it manually from"
+ "<br><a href=\"" + "<br><a href=\""
+ url + "\">" + url + "</a> and put it in your mods folder" + "</html>"); + url
+ "\">"
+ url
+ "</a> and put it in your mods folder"
+ "</html>");
ep.setEditable(false); ep.setEditable(false);
ep.setOpaque(false); ep.setOpaque(false);
ep.addHyperlinkListener(new HyperlinkListener() { ep.addHyperlinkListener(new HyperlinkListener() {
@Override @Override
public void hyperlinkUpdate(HyperlinkEvent event) { public void hyperlinkUpdate(HyperlinkEvent event) {
try { try {
if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
Desktop.getDesktop().browse(event.getURL().toURI()); Desktop.getDesktop().browse(event.getURL().toURI());
} catch (Exception e) { } catch (Exception e) {}
}
} }
}); });
@@ -193,6 +226,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
} }
public static class DummyDownloader implements IDownloadDisplay { public static class DummyDownloader implements IDownloadDisplay {
@Override @Override
public void resetProgress(int sizeGuess) {} public void resetProgress(int sizeGuess) {}
@@ -220,6 +254,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
} }
public static class VersionedFile { public static class VersionedFile {
public final Pattern pattern; public final Pattern pattern;
public final String filename; public final String filename;
public final ComparableVersion version; public final ComparableVersion version;
@@ -244,6 +279,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
} }
public static class Dependency { public static class Dependency {
public String url; public String url;
public VersionedFile file; public VersionedFile file;
@@ -261,6 +297,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
} }
public static class DepLoadInst { public static class DepLoadInst {
private File modsDir; private File modsDir;
private File v_modsDir; private File v_modsDir;
private IDownloadDisplay downloadMonitor; private IDownloadDisplay downloadMonitor;
@@ -312,7 +349,8 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
if (!mod.delete()) { if (!mod.delete()) {
mod.deleteOnExit(); mod.deleteOnExit();
String msg = owner + " was unable to delete file " + mod.getPath() String msg = owner + " was unable to delete file "
+ mod.getPath()
+ " the game will now try to delete it on exit. If this dialog appears again, delete it manually."; + " the game will now try to delete it on exit. If this dialog appears again, delete it manually.";
CodeChickenCorePlugin.logger.error(msg); CodeChickenCorePlugin.logger.error(msg);
if (!GraphicsEnvironment.isHeadless()) if (!GraphicsEnvironment.isHeadless())
@@ -342,8 +380,8 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
} catch (Exception e) { } catch (Exception e) {
libFile.delete(); libFile.delete();
if (downloadMonitor.shouldStopIt()) { if (downloadMonitor.shouldStopIt()) {
CodeChickenCorePlugin.logger.error( CodeChickenCorePlugin.logger
"You have stopped the downloading operation before it could complete"); .error("You have stopped the downloading operation before it could complete");
System.exit(1); System.exit(1);
return; return;
} }
@@ -353,10 +391,10 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
} }
private void download(InputStream is, int sizeGuess, File target) throws Exception { private void download(InputStream is, int sizeGuess, File target) throws Exception {
if (sizeGuess > downloadBuffer.capacity()) if (sizeGuess > downloadBuffer.capacity()) throw new Exception(
throw new Exception(String.format( String.format(
"The file %s is too large to be downloaded by " + owner + " - the download is invalid", "The file %s is too large to be downloaded by " + owner + " - the download is invalid",
target.getName())); target.getName()));
downloadBuffer.clear(); downloadBuffer.clear();
@@ -387,20 +425,20 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
} }
try { try {
/*String cksum = generateChecksum(downloadBuffer); /*
if (cksum.equals(validationHash)) * String cksum = generateChecksum(downloadBuffer); if (cksum.equals(validationHash)) {
{*/ */
if (!target.exists()) target.createNewFile(); if (!target.exists()) target.createNewFile();
downloadBuffer.position(0); downloadBuffer.position(0);
FileOutputStream fos = new FileOutputStream(target); FileOutputStream fos = new FileOutputStream(target);
fos.getChannel().write(downloadBuffer); fos.getChannel().write(downloadBuffer);
fos.close(); fos.close();
/*} /*
else * } else { throw new RuntimeException(String.
{ * format("The downloaded file %s has an invalid checksum %s (expecting %s). The download did not succeed correctly and the file has been deleted. Please try launching again."
throw new RuntimeException(String.format("The downloaded file %s has an invalid checksum %s (expecting %s). The download did not succeed correctly and the file has been deleted. Please try launching again.", target.getName(), cksum, validationHash)); * , target.getName(), cksum, validationHash)); }
}*/ */
} catch (Exception e) { } catch (Exception e) {
throw e; throw e;
} }
@@ -427,8 +465,12 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
return null; return null;
} }
if (cmp > 0) { if (cmp > 0) {
CodeChickenCorePlugin.logger.warn("Warning: version of " + dep.file.name + ", " + vfile.version CodeChickenCorePlugin.logger.warn(
+ " is newer than request " + dep.file.version); "Warning: version of " + dep.file.name
+ ", "
+ vfile.version
+ " is newer than request "
+ dep.file.version);
return f.getName(); return f.getName();
} }
return f.getName(); // found dependency return f.getName(); // found dependency
@@ -497,8 +539,8 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
if (e != null) loadJSon(zip.getInputStream(e)); if (e != null) loadJSon(zip.getInputStream(e));
zip.close(); zip.close();
} catch (Exception e) { } catch (Exception e) {
CodeChickenCorePlugin.logger.error( CodeChickenCorePlugin.logger
"Failed to load dependencies.info from " + file.getName() + " as JSON"); .error("Failed to load dependencies.info from " + file.getName() + " as JSON");
e.printStackTrace(); e.printStackTrace();
} }
} }
@@ -516,9 +558,8 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
} }
private void loadJson(JsonObject node) throws IOException { private void loadJson(JsonObject node) throws IOException {
boolean obfuscated = boolean obfuscated = ((LaunchClassLoader) DepLoader.class.getClassLoader())
((LaunchClassLoader) DepLoader.class.getClassLoader()).getClassBytes("net.minecraft.world.World") .getClassBytes("net.minecraft.world.World") == null;
== null;
String testClass = node.get("class").getAsString(); String testClass = node.get("class").getAsString();
if (DepLoader.class.getResource("/" + testClass.replace('.', '/') + ".class") != null) return; if (DepLoader.class.getResource("/" + testClass.replace('.', '/') + ".class") != null) return;
@@ -531,8 +572,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
Pattern pattern = null; Pattern pattern = null;
try { try {
if (node.has("pattern")) if (node.has("pattern")) pattern = Pattern.compile(node.get("pattern").getAsString());
pattern = Pattern.compile(node.get("pattern").getAsString());
} catch (PatternSyntaxException e) { } catch (PatternSyntaxException e) {
CodeChickenCorePlugin.logger.error("Invalid filename pattern: " + node.get("pattern")); CodeChickenCorePlugin.logger.error("Invalid filename pattern: " + node.get("pattern"));
e.printStackTrace(); e.printStackTrace();
@@ -1,10 +1,11 @@
package codechicken.obfuscator; package codechicken.obfuscator;
import static org.objectweb.asm.tree.AbstractInsnNode.*; import static org.objectweb.asm.tree.AbstractInsnNode.LDC_INSN;
import static org.objectweb.asm.tree.AbstractInsnNode.METHOD_INSN;
import codechicken.lib.asm.ObfMapping;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
@@ -12,7 +13,10 @@ import org.objectweb.asm.tree.LdcInsnNode;
import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.MethodNode;
import codechicken.lib.asm.ObfMapping;
public class ConstantObfuscator implements Opcodes { public class ConstantObfuscator implements Opcodes {
public ObfRemapper obf; public ObfRemapper obf;
public List<ObfMapping> descCalls = new LinkedList<ObfMapping>(); public List<ObfMapping> descCalls = new LinkedList<ObfMapping>();
public List<ObfMapping> classCalls = new LinkedList<ObfMapping>(); public List<ObfMapping> classCalls = new LinkedList<ObfMapping>();
@@ -3,6 +3,7 @@ package codechicken.obfuscator;
import java.io.OutputStream; import java.io.OutputStream;
public class DummyOutputStream extends OutputStream { public class DummyOutputStream extends OutputStream {
public static DummyOutputStream instance = new DummyOutputStream(); public static DummyOutputStream instance = new DummyOutputStream();
@Override @Override
@@ -1,9 +1,11 @@
package codechicken.obfuscator; package codechicken.obfuscator;
import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry;
import java.util.List; import java.util.List;
import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry;
public interface IHeirachyEvaluator { public interface IHeirachyEvaluator {
/** /**
* @param desc The mapping descriptor of the class to evaluate heirachy for * @param desc The mapping descriptor of the class to evaluate heirachy for
* @return A list of parents (srg or obf names) * @return A list of parents (srg or obf names)
@@ -3,6 +3,7 @@ package codechicken.obfuscator;
import java.io.PrintStream; import java.io.PrintStream;
public interface ILogStreams { public interface ILogStreams {
public PrintStream err(); public PrintStream err();
public PrintStream out(); public PrintStream out();
@@ -4,6 +4,7 @@ import codechicken.lib.asm.ObfMapping;
import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry; import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry;
public class ObfDirection { public class ObfDirection {
public boolean obfuscate; public boolean obfuscate;
public boolean srg; public boolean srg;
public boolean srg_cst; public boolean srg_cst;
@@ -1,9 +1,11 @@
package codechicken.obfuscator; package codechicken.obfuscator;
import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry;
import org.objectweb.asm.commons.Remapper; import org.objectweb.asm.commons.Remapper;
import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry;
public class ObfRemapper extends Remapper { public class ObfRemapper extends Remapper {
public final ObfuscationMap obf; public final ObfuscationMap obf;
public ObfDirection dir; public ObfDirection dir;
@@ -1,8 +1,5 @@
package codechicken.obfuscator; package codechicken.obfuscator;
import codechicken.lib.asm.ObfMapping;
import com.google.common.base.Function;
import com.google.common.collect.ArrayListMultimap;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@@ -10,8 +7,15 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.google.common.base.Function;
import com.google.common.collect.ArrayListMultimap;
import codechicken.lib.asm.ObfMapping;
public class ObfuscationMap { public class ObfuscationMap {
public class ObfuscationEntry { public class ObfuscationEntry {
public final ObfMapping obf; public final ObfMapping obf;
public final ObfMapping srg; public final ObfMapping srg;
public final ObfMapping mcp; public final ObfMapping mcp;
@@ -24,6 +28,7 @@ public class ObfuscationMap {
} }
private class ClassEntry extends ObfuscationEntry { private class ClassEntry extends ObfuscationEntry {
public Map<String, ObfuscationEntry> mcpMap = new HashMap<String, ObfuscationEntry>(); public Map<String, ObfuscationEntry> mcpMap = new HashMap<String, ObfuscationEntry>();
public Map<String, ObfuscationEntry> srgMap = new HashMap<String, ObfuscationEntry>(); public Map<String, ObfuscationEntry> srgMap = new HashMap<String, ObfuscationEntry>();
public Map<String, ObfuscationEntry> obfMap = new HashMap<String, ObfuscationEntry>(); public Map<String, ObfuscationEntry> obfMap = new HashMap<String, ObfuscationEntry>();
@@ -81,8 +86,8 @@ public class ObfuscationMap {
return addEntry(new ObfMapping(obf_owner, obf_name, ""), new ObfMapping(srg_owner, srg_name, "")); return addEntry(new ObfMapping(obf_owner, obf_name, ""), new ObfMapping(srg_owner, srg_name, ""));
} }
public ObfuscationEntry addMethod( public ObfuscationEntry addMethod(String obf_owner, String obf_name, String obf_desc, String srg_owner,
String obf_owner, String obf_name, String obf_desc, String srg_owner, String srg_name, String srg_desc) { String srg_name, String srg_desc) {
return addEntry(new ObfMapping(obf_owner, obf_name, obf_desc), new ObfMapping(srg_owner, srg_name, srg_desc)); return addEntry(new ObfMapping(obf_owner, obf_name, obf_desc), new ObfMapping(srg_owner, srg_name, srg_desc));
} }
@@ -161,10 +166,8 @@ public class ObfuscationMap {
private ObfuscationEntry getOrCreateClassEntry(String name) { private ObfuscationEntry getOrCreateClassEntry(String name) {
ObfuscationEntry e = lookupObfClass(name); ObfuscationEntry e = lookupObfClass(name);
if (e == null) e = lookupMcpClass(name); if (e == null) e = lookupMcpClass(name);
if (e == null) if (e == null) e = addClass(name, name); // if the class isn't in obf or srg maps, it must be a custom mod class
e = addClass( // with no name change.
name,
name); // if the class isn't in obf or srg maps, it must be a custom mod class with no name change.
return e; return e;
} }
@@ -207,7 +210,7 @@ public class ObfuscationMap {
public static String[] splitLast(String s, char c) { public static String[] splitLast(String s, char c) {
int i = s.lastIndexOf(c); int i = s.lastIndexOf(c);
return new String[] {s.substring(0, i), s.substring(i + 1)}; return new String[] { s.substring(0, i), s.substring(i + 1) };
} }
public static String[] split4(String s, char c) { public static String[] split4(String s, char c) {
@@ -230,6 +233,7 @@ public class ObfuscationMap {
log.out().println("Parsing " + srgs.getName()); log.out().println("Parsing " + srgs.getName());
Function<String, Void> function = new Function<String, Void>() { Function<String, Void> function = new Function<String, Void>() {
@Override @Override
public Void apply(String line) { public Void apply(String line) {
int hpos = line.indexOf('#'); int hpos = line.indexOf('#');
@@ -261,6 +265,7 @@ public class ObfuscationMap {
log.out().println("Parsing " + csv.getName()); log.out().println("Parsing " + csv.getName());
Function<String, Void> function = new Function<String, Void>() { Function<String, Void> function = new Function<String, Void>() {
@Override @Override
public Void apply(String line) { public Void apply(String line) {
if (line.startsWith("func_") || line.startsWith("field_")) { if (line.startsWith("func_") || line.startsWith("field_")) {
@@ -1,6 +1,5 @@
package codechicken.obfuscator; package codechicken.obfuscator;
import com.google.common.base.Function;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
@@ -9,11 +8,15 @@ import java.text.DecimalFormat;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.commons.RemappingClassAdapter; import org.objectweb.asm.commons.RemappingClassAdapter;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import com.google.common.base.Function;
public class ObfuscationRun implements ILogStreams { public class ObfuscationRun implements ILogStreams {
public final ObfDirection obfDir; public final ObfDirection obfDir;
public final ObfuscationMap obf; public final ObfuscationMap obf;
public final ObfRemapper obfMapper; public final ObfRemapper obfMapper;
@@ -98,27 +101,24 @@ public class ObfuscationRun implements ILogStreams {
} }
public static Map<String, String> fillDefaults(Map<String, String> config) { public static Map<String, String> fillDefaults(Map<String, String> config) {
if (!config.containsKey("excludedPackages")) if (!config.containsKey("excludedPackages")) config.put(
config.put( "excludedPackages",
"excludedPackages", "java/;sun/;javax/;scala/;" + "argo/;org/lwjgl/;org/objectweb/;org/bouncycastle/;com/google/");
"java/;sun/;javax/;scala/;" + "argo/;org/lwjgl/;org/objectweb/;org/bouncycastle/;com/google/");
if (!config.containsKey("ignore")) config.put("ignore", "."); if (!config.containsKey("ignore")) config.put("ignore", ".");
if (!config.containsKey("classConstantCalls")) if (!config.containsKey("classConstantCalls")) config.put(
config.put( "classConstantCalls",
"classConstantCalls", "codechicken/lib/asm/ObfMapping.<init>(Ljava/lang/String;)V,"
"codechicken/lib/asm/ObfMapping.<init>(Ljava/lang/String;)V," + "codechicken/lib/asm/ObfMapping.subclass(Ljava/lang/String;)Lcodechicken/lib/asm/ObfMapping;,"
+ "codechicken/lib/asm/ObfMapping.subclass(Ljava/lang/String;)Lcodechicken/lib/asm/ObfMapping;," + "codechicken/lib/asm/ObfMapping.<init>(Lcodechicken/lib/asm/ObfMapping;Ljava/lang/String;)V");
+ "codechicken/lib/asm/ObfMapping.<init>(Lcodechicken/lib/asm/ObfMapping;Ljava/lang/String;)V"); if (!config.containsKey("descConstantCalls")) config.put(
if (!config.containsKey("descConstantCalls")) "descConstantCalls",
config.put( "codechicken/lib/asm/ObfMapping.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
"descConstantCalls", + "org/objectweb/asm/MethodVisitor.visitFieldInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
"codechicken/lib/asm/ObfMapping.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V," + "org/objectweb/asm/tree/MethodNode.visitFieldInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
+ "org/objectweb/asm/MethodVisitor.visitFieldInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V," + "org/objectweb/asm/MethodVisitor.visitMethodInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
+ "org/objectweb/asm/tree/MethodNode.visitFieldInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V," + "org/objectweb/asm/tree/MethodNode.visitMethodInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
+ "org/objectweb/asm/MethodVisitor.visitMethodInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V," + "org/objectweb/asm/tree/MethodInsnNode.<init>(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
+ "org/objectweb/asm/tree/MethodNode.visitMethodInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V," + "org/objectweb/asm/tree/FieldInsnNode.<init>(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
+ "org/objectweb/asm/tree/MethodInsnNode.<init>(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
+ "org/objectweb/asm/tree/FieldInsnNode.<init>(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
return config; return config;
} }
@@ -135,9 +135,8 @@ public class ObfuscationRun implements ILogStreams {
} }
public static void processFiles(File dir, Function<File, Void> function, boolean recursive) { public static void processFiles(File dir, Function<File, Void> function, boolean recursive) {
for (File file : dir.listFiles()) for (File file : dir.listFiles()) if (file.isDirectory() && recursive) processFiles(file, function, recursive);
if (file.isDirectory() && recursive) processFiles(file, function, recursive); else function.apply(file);
else function.apply(file);
} }
public static void deleteDir(File directory, boolean remove) { public static void deleteDir(File directory, boolean remove) {
@@ -173,7 +172,7 @@ public class ObfuscationRun implements ILogStreams {
File fields = new File(mapDir, "fields.csv"); File fields = new File(mapDir, "fields.csv");
if (!fields.exists()) throw new RuntimeException("Could not find fields.csv"); if (!fields.exists()) throw new RuntimeException("Could not find fields.csv");
return new File[] {srgs, methods, fields}; return new File[] { srgs, methods, fields };
} }
public long startTime() { public long startTime() {
@@ -196,8 +195,8 @@ public class ObfuscationRun implements ILogStreams {
public void finish(boolean errored) { public void finish(boolean errored) {
long millis = System.currentTimeMillis() - startTime; long millis = System.currentTimeMillis() - startTime;
out().println((errored ? "Errored after" : "Done in ") + new DecimalFormat("0.00").format(millis / 1000D) out().println(
+ "s"); (errored ? "Errored after" : "Done in ") + new DecimalFormat("0.00").format(millis / 1000D) + "s");
finished = true; finished = true;
} }
@@ -3,6 +3,7 @@ package codechicken.obfuscator;
import java.io.PrintStream; import java.io.PrintStream;
public class SystemLogStreams implements ILogStreams { public class SystemLogStreams implements ILogStreams {
public static SystemLogStreams inst = new SystemLogStreams(); public static SystemLogStreams inst = new SystemLogStreams();
@Override @Override
+1 -1
View File
@@ -7,6 +7,6 @@
"version": "${modVersion}", "version": "${modVersion}",
"mcversion": "${minecraftVersion}", "mcversion": "${minecraftVersion}",
"url": "http://www.minecraftforum.net/topic/909223", "url": "http://www.minecraftforum.net/topic/909223",
"authorList": ["ChickenBones"] "authorList": ["ChickenBones", "GTNH Team"]
}] }]
} }