init
7
.gitignore
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
.gradle/
|
||||
.settings/
|
||||
bin/
|
||||
build/
|
||||
run/
|
||||
.classpath
|
||||
.project
|
56
build.gradle
Normal file
|
@ -0,0 +1,56 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
maven {
|
||||
name = 'minecrell'
|
||||
url = "http://repo.minecrell.net/snapshots"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecrell:VanillaGradle:3.0-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
evaluationDependsOnChildren()
|
||||
apply plugin: 'net.minecrell.vanilla'
|
||||
|
||||
archivesBaseName = "mod_minelp"
|
||||
version = "1.8-UNOFFICIAL_mc1.8"
|
||||
|
||||
minecraft {
|
||||
version = "1.8"
|
||||
mappings = 'snapshot_20150606'
|
||||
clientTweaker = 'com.mumfrey.liteloader.launch.LiteLoaderTweaker'
|
||||
// fix reobf issues
|
||||
srgExtra "FD: com/voxelmodpack/common/properties/gui/GuiVoxelBoxSettingsPanel/zLevel bub/e"
|
||||
srgExtra "FD: com/voxelmodpack/common/gui/GuiControl/zLevel bub/e"
|
||||
srgExtra "FD: com/voxelmodpack/common/gui/GuiScreenEx/zLevel bub/e"
|
||||
}
|
||||
project(':voxellib').dependencies {
|
||||
compile fileTree("libs")
|
||||
}
|
||||
dependencies {
|
||||
compile project(':voxellib')
|
||||
}
|
||||
jar {
|
||||
extension 'litemod'
|
||||
}
|
||||
task standaloneJar(type:Jar, dependsOn: [reobf, project(':voxellib').reobf]) {
|
||||
extension "litemod"
|
||||
from zipTree(jar.archivePath)
|
||||
from project(':voxellib').jar.archivePath
|
||||
classifier 'standalone'
|
||||
}
|
||||
artifacts {
|
||||
archives standaloneJar
|
||||
}
|
||||
reobf {
|
||||
setSrgMcp()
|
||||
}
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
#Thu Jul 23 18:28:01 EDT 2015
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-bin.zip
|
164
gradlew
vendored
Normal file
|
@ -0,0 +1,164 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
90
gradlew.bat
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
BIN
libs/liteloader-1.8-SNAPSHOT-mcpnames.jar
Normal file
1
settings.gradle
Normal file
|
@ -0,0 +1 @@
|
|||
include ':voxellib'
|
|
@ -0,0 +1,20 @@
|
|||
package com.minelittlepony.minelp;
|
||||
|
||||
import com.voxelmodpack.common.VoxelCommonLiteMod;
|
||||
|
||||
public class LiteModMineLittlePony extends VoxelCommonLiteMod {
|
||||
|
||||
public LiteModMineLittlePony() {
|
||||
super("com.minelittlepony.minelp.MineLittlePony");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return MineLittlePony.MOD_VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MineLittlePony.MOD_NAME;
|
||||
}
|
||||
}
|
179
src/main/java/com/minelittlepony/minelp/MineLittlePony.java
Normal file
|
@ -0,0 +1,179 @@
|
|||
package com.minelittlepony.minelp;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.minelittlepony.minelp.gui.MineLittlePonyGUI;
|
||||
import com.minelittlepony.minelp.gui.MineLittlePonyGUIMob;
|
||||
import com.minelittlepony.minelp.hdskins.gui.EntityPonyModel;
|
||||
import com.minelittlepony.minelp.hdskins.gui.GuiSkinsMineLP;
|
||||
import com.minelittlepony.minelp.hdskins.gui.RenderPonyModel;
|
||||
import com.minelittlepony.minelp.renderer.RenderPonySkeleton;
|
||||
import com.minelittlepony.minelp.renderer.RenderPonyVillager;
|
||||
import com.minelittlepony.minelp.renderer.RenderPonyZombie;
|
||||
import com.minelittlepony.minelp.util.MineLPLogger;
|
||||
import com.mumfrey.liteloader.InitCompleteListener;
|
||||
import com.mumfrey.liteloader.core.LiteLoader;
|
||||
import com.mumfrey.liteloader.util.ModUtilities;
|
||||
import com.voxelmodpack.common.properties.ModConfig;
|
||||
import com.voxelmodpack.common.properties.gui.SettingsPanelManager;
|
||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.monster.EntityPigZombie;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
|
||||
public class MineLittlePony implements InitCompleteListener {
|
||||
public static final String MOD_VERSION = "1.8-UNOFFICIAL";
|
||||
public static final String MOD_NAME = "Mine Little Pony";
|
||||
public static final String SKIN_SERVER_URL = "minelpskins.voxelmodpack.com";
|
||||
public static final String GATEWAY_URL = "minelpskinmanager.voxelmodpack.com";
|
||||
public static final String UPLOAD_URL = "http://minelpskinmanager.voxelmodpack.com/";
|
||||
private static final KeyBinding guiKeybinding = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony");
|
||||
private static final KeyBinding skinKeybinding = new KeyBinding("Skin Manager", Keyboard.KEY_F1, "Mine Little Pony");
|
||||
private PonyConfig config;
|
||||
private PonyManager ponyManager;
|
||||
private String spUsername;
|
||||
private static MineLittlePony instance;
|
||||
|
||||
public MineLittlePony() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static MineLittlePony getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MOD_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return MOD_VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradeSettings(String version, File configPath, File oldConfigPath) {}
|
||||
|
||||
@Override
|
||||
public void init(File configPath) {
|
||||
LiteLoader.getInput().registerKeyBinding(guiKeybinding);
|
||||
LiteLoader.getInput().registerKeyBinding(skinKeybinding);
|
||||
SettingsPanelManager.addSettingsPanel("Pony", MineLittlePonyGUI.class);
|
||||
SettingsPanelManager.addSettingsPanel("Pony Mobs", MineLittlePonyGUIMob.class);
|
||||
this.ponyManager = PonyManager.getInstance();
|
||||
this.config = new PonyConfig();
|
||||
|
||||
int readInt = this.config.getIntPropertySafe("ponylevel", 0, 2);
|
||||
this.ponyManager.setPonyLevel(PonyLevel.parse(readInt));
|
||||
MineLPLogger.info("Pony level is set to %d.", Integer.valueOf(readInt));
|
||||
|
||||
readInt = this.config.getIntPropertySafe("sizes", 0, 1);
|
||||
this.ponyManager.setUseSizes(readInt);
|
||||
MineLPLogger.info("Different pony sizes are %s.", readInt == 0 ? "disabled" : "enabled");
|
||||
|
||||
readInt = this.config.getIntPropertySafe("ponyarmor", 0, 1);
|
||||
this.ponyManager.setPonyArmor(readInt);
|
||||
MineLPLogger.info("Pony armor is %s.", readInt == 0 ? "disabled" : "enabled");
|
||||
|
||||
readInt = this.config.getIntPropertySafe("snuzzles", 0, 1);
|
||||
this.ponyManager.setShowSnuzzles(readInt);
|
||||
MineLPLogger.info("Snuzzels are %s.", readInt == 0 ? "disabled (You are a bad pony)" : "enabled");
|
||||
|
||||
readInt = this.config.getIntPropertySafe("hd", 0, 1);
|
||||
this.ponyManager.setHD(readInt);
|
||||
MineLPLogger.info("MineLittlePony skin server is %s.", readInt == 0 ? "disabled" : "enabled");
|
||||
|
||||
readInt = this.config.getIntPropertySafe("showscale", 0, 1);
|
||||
this.ponyManager.setShowScale(readInt);
|
||||
MineLPLogger.info("Show-accurate scaling is %s.", readInt == 0 ? "disabled" : "enabled");
|
||||
|
||||
readInt = this.config.getIntPropertySafe("villagers", 0, 1);
|
||||
this.ponyManager.setPonyVillagers(readInt);
|
||||
MineLPLogger.info("Pony villagers are %s.", readInt == 0 ? "disabled" : "enabled");
|
||||
|
||||
readInt = this.config.getIntPropertySafe("zombies", 0, 1);
|
||||
this.ponyManager.setPonyZombies(readInt);
|
||||
MineLPLogger.info("Pony zombies are %s.", readInt == 0 ? "disabled" : "enabled");
|
||||
|
||||
readInt = this.config.getIntPropertySafe("pigzombies", 0, 1);
|
||||
this.ponyManager.setPonyPigzombies(readInt);
|
||||
MineLPLogger.info("Pony pigzombies are %s.", readInt == 0 ? "disabled" : "enabled");
|
||||
|
||||
readInt = this.config.getIntPropertySafe("skeletons", 0, 1);
|
||||
this.ponyManager.setPonySkeletons(readInt);
|
||||
MineLPLogger.info("Pony skeletons are %s.", readInt == 0 ? "disabled" : "enabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitCompleted(Minecraft minecraft, LiteLoader loader) {
|
||||
this.spUsername = minecraft.getSession().getUsername();
|
||||
if (this.ponyManager.getHD() == 1) {
|
||||
HDSkinManager.clearSkinCache();
|
||||
HDSkinManager.setSkinUrl(SKIN_SERVER_URL);
|
||||
HDSkinManager.setGatewayURL(GATEWAY_URL);
|
||||
MineLPLogger.info("Set MineLP skin server URL.");
|
||||
}
|
||||
RenderManager rm = minecraft.getRenderManager();
|
||||
ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm));
|
||||
if (this.ponyManager.getPonyVillagers() == 1) {
|
||||
ModUtilities.addRenderer(EntityVillager.class, new RenderPonyVillager(rm));
|
||||
MineLPLogger.info("Villagers are now ponies.");
|
||||
}
|
||||
|
||||
if (this.ponyManager.getPonyZombies() == 1) {
|
||||
ModUtilities.addRenderer(EntityZombie.class, new RenderPonyZombie(rm));
|
||||
MineLPLogger.info("Zombies are now ponies.");
|
||||
}
|
||||
|
||||
if (this.ponyManager.getPonyPigzombies() == 1) {
|
||||
ModUtilities.addRenderer(EntityPigZombie.class, new RenderPonyZombie(rm));
|
||||
MineLPLogger.info("Zombie pigmen are now ponies.");
|
||||
}
|
||||
|
||||
if (this.ponyManager.getPonySkeletons() == 1) {
|
||||
ModUtilities.addRenderer(EntitySkeleton.class, new RenderPonySkeleton(rm));
|
||||
MineLPLogger.info("Skeletons are now ponies.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) {
|
||||
this.ponyManager.setPonyLevel(PonyLevel.parse(this.config.getIntProperty("ponylevel")));
|
||||
this.ponyManager.setUseSizes(this.config.getIntProperty("sizes"));
|
||||
this.ponyManager.setPonyArmor(this.config.getIntProperty("ponyarmor"));
|
||||
this.ponyManager.setShowSnuzzles(this.config.getIntProperty("snuzzles"));
|
||||
this.ponyManager.setShowScale(this.config.getIntProperty("showscale"));
|
||||
if (inGame && minecraft.currentScreen == null && guiKeybinding.isPressed()) {
|
||||
minecraft.displayGuiScreen(new MineLittlePonyGUI());
|
||||
}
|
||||
// if (Keyboard.isKeyDown(Keyboard.KEY_O)) {
|
||||
// ponyManager.initmodels();
|
||||
// }
|
||||
|
||||
if (!inGame && minecraft.currentScreen != null
|
||||
&& (minecraft.currentScreen instanceof GuiMainMenu && Keyboard.isKeyDown(skinKeybinding.getKeyCode())
|
||||
|| minecraft.currentScreen instanceof GuiSkins)) {
|
||||
minecraft.displayGuiScreen(new GuiSkinsMineLP());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static ModConfig getConfig() {
|
||||
return getInstance().config;
|
||||
}
|
||||
|
||||
public static String getSPUsername() {
|
||||
return getInstance().spUsername;
|
||||
}
|
||||
}
|
447
src/main/java/com/minelittlepony/minelp/Pony.java
Normal file
|
@ -0,0 +1,447 @@
|
|||
package com.minelittlepony.minelp;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.minelittlepony.minelp.model.PMAPI;
|
||||
import com.minelittlepony.minelp.model.PlayerModel;
|
||||
import com.minelittlepony.minelp.util.MineLPLogger;
|
||||
import com.voxelmodpack.common.runtime.PrivateFields;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Pony {
|
||||
public static PonyManager ponyManager = PonyManager.getInstance();
|
||||
public Pony.PonyRace race;
|
||||
public boolean advancedTexturing;
|
||||
public ResourceLocation textureResourceLocation;
|
||||
public boolean isSpPlayer;
|
||||
public boolean isPony;
|
||||
public boolean isPonySkin;
|
||||
public boolean isPegasus;
|
||||
public boolean isUnicorn;
|
||||
public boolean isFlying;
|
||||
public boolean isGlow;
|
||||
public int glowColor;
|
||||
public boolean isMale;
|
||||
public int size;
|
||||
public int wantTail;
|
||||
public boolean isVillager;
|
||||
public int villagerProfession;
|
||||
public float defaultYOffset;
|
||||
boolean pegasusFlying;
|
||||
@SuppressWarnings("unused")
|
||||
private final int dangerzone;
|
||||
private float previousFallDistance;
|
||||
private static int ponyCount = 0;
|
||||
private final int ponyId;
|
||||
private int skinCheckCount;
|
||||
private boolean skinChecked;
|
||||
private boolean newSkinSize;
|
||||
|
||||
public Pony(AbstractClientPlayer player) {
|
||||
this.race = Pony.PonyRace.EARTH;
|
||||
this.isSpPlayer = false;
|
||||
this.isPony = false;
|
||||
this.isPonySkin = false;
|
||||
this.isPegasus = false;
|
||||
this.isUnicorn = false;
|
||||
this.isFlying = false;
|
||||
this.isGlow = false;
|
||||
this.glowColor = -12303190;
|
||||
this.isMale = false;
|
||||
this.size = 1;
|
||||
this.wantTail = 0;
|
||||
this.isVillager = false;
|
||||
this.villagerProfession = 1;
|
||||
this.defaultYOffset = 1.62F;
|
||||
this.pegasusFlying = false;
|
||||
this.dangerzone = 2;
|
||||
this.previousFallDistance = 0.0F;
|
||||
this.skinCheckCount = 0;
|
||||
this.skinChecked = false;
|
||||
this.ponyId = ++ponyCount;
|
||||
this.textureResourceLocation = player.getLocationSkin();
|
||||
MineLPLogger.debug("+ Initialising new pony #%d for player %s (%s) with resource location %s.", this.ponyId,
|
||||
player.getCommandSenderName(), player.getUniqueID(), this.textureResourceLocation);
|
||||
this.checkSkin(this.textureResourceLocation);
|
||||
}
|
||||
|
||||
public Pony(ResourceLocation aTextureResourceLocation) {
|
||||
this.race = Pony.PonyRace.EARTH;
|
||||
this.isSpPlayer = false;
|
||||
this.isPony = false;
|
||||
this.isPonySkin = false;
|
||||
this.isPegasus = false;
|
||||
this.isUnicorn = false;
|
||||
this.isFlying = false;
|
||||
this.isGlow = false;
|
||||
this.glowColor = -12303190;
|
||||
this.isMale = false;
|
||||
this.size = 1;
|
||||
this.wantTail = 0;
|
||||
this.isVillager = false;
|
||||
this.villagerProfession = 1;
|
||||
this.defaultYOffset = 1.62F;
|
||||
this.pegasusFlying = false;
|
||||
this.dangerzone = 2;
|
||||
this.previousFallDistance = 0.0F;
|
||||
this.skinCheckCount = 0;
|
||||
this.skinChecked = false;
|
||||
this.ponyId = ++ponyCount;
|
||||
this.textureResourceLocation = aTextureResourceLocation;
|
||||
|
||||
MineLPLogger.debug("+ Initialising new pony #%d with resource location %s.", this.ponyId,
|
||||
this.textureResourceLocation);
|
||||
this.checkSkin(this.textureResourceLocation);
|
||||
}
|
||||
|
||||
public void invalidateSkinCheck() {
|
||||
this.resetValues();
|
||||
this.skinChecked = false;
|
||||
}
|
||||
|
||||
public void checkSkin() {
|
||||
if (!this.skinChecked) {
|
||||
this.checkSkin(this.textureResourceLocation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void checkSkin(ResourceLocation textureResourceLocation) {
|
||||
BufferedImage skinImage = this.getBufferedImage(textureResourceLocation);
|
||||
if (skinImage != null) {
|
||||
this.checkSkin(skinImage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public BufferedImage getBufferedImage(ResourceLocation textureResourceLocation) {
|
||||
BufferedImage skinImage = null;
|
||||
|
||||
try {
|
||||
skinImage = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(textureResourceLocation)
|
||||
.getInputStream());
|
||||
MineLPLogger.debug("Obtained skin from resource location %s", textureResourceLocation);
|
||||
this.checkSkin(skinImage);
|
||||
} catch (Exception var6) {
|
||||
Exception e = var6;
|
||||
|
||||
try {
|
||||
ITextureObject e2 = Minecraft.getMinecraft().getTextureManager().getTexture(textureResourceLocation);
|
||||
if (e2 instanceof ThreadDownloadImageData) {
|
||||
skinImage = PrivateFields.downloadedImage.get((ThreadDownloadImageData) e2);
|
||||
if (skinImage != null) {
|
||||
MineLPLogger.debug(e, "Successfully reflected downloadedImage from texture object");
|
||||
this.checkSkin(skinImage);
|
||||
}
|
||||
}
|
||||
} catch (Exception var5) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
return skinImage;
|
||||
}
|
||||
|
||||
public void checkSkin(BufferedImage bufferedimage) {
|
||||
MineLPLogger.debug("\tStart skin check #%d for pony #%d with image %s.", ++this.skinCheckCount, this.ponyId);
|
||||
this.resetValues();
|
||||
Color flagPix = new Color(bufferedimage.getRGB(0, 0), true);
|
||||
Color applejack = new Color(249, 177, 49, 255);
|
||||
Color dashie = new Color(136, 202, 240, 255);
|
||||
Color twilight = new Color(209, 159, 228, 255);
|
||||
Color celestia = new Color(254, 249, 252, 255);
|
||||
Color zecora = new Color(208, 204, 207, 255);
|
||||
Color changeling = new Color(40, 43, 41, 255);
|
||||
if (flagPix.equals(applejack)) {
|
||||
this.isPony = true;
|
||||
this.isPonySkin = true;
|
||||
this.race = Pony.PonyRace.EARTH;
|
||||
}
|
||||
|
||||
if (flagPix.equals(zecora)) {
|
||||
this.isPony = true;
|
||||
this.isPonySkin = true;
|
||||
this.race = Pony.PonyRace.ZEBRA;
|
||||
}
|
||||
|
||||
if (flagPix.equals(dashie)) {
|
||||
this.isPony = true;
|
||||
this.isPonySkin = true;
|
||||
this.isPegasus = true;
|
||||
this.race = Pony.PonyRace.PEGASUS;
|
||||
}
|
||||
|
||||
if (flagPix.equals(twilight)) {
|
||||
this.isPony = true;
|
||||
this.isPonySkin = true;
|
||||
this.isUnicorn = true;
|
||||
this.race = Pony.PonyRace.UNICORN;
|
||||
}
|
||||
|
||||
if (flagPix.equals(celestia)) {
|
||||
this.isPony = true;
|
||||
this.isPonySkin = true;
|
||||
this.isPegasus = true;
|
||||
this.isUnicorn = true;
|
||||
this.race = Pony.PonyRace.ALICORN;
|
||||
}
|
||||
|
||||
if (flagPix.equals(changeling)) {
|
||||
this.isPony = true;
|
||||
this.isPonySkin = true;
|
||||
this.isPegasus = true;
|
||||
this.isUnicorn = true;
|
||||
this.race = Pony.PonyRace.CHANGELING;
|
||||
}
|
||||
|
||||
Color tailcolor = new Color(bufferedimage.getRGB(1, 0), true);
|
||||
Color tailcolor1 = new Color(66, 88, 68, 255);
|
||||
Color tailcolor2 = new Color(70, 142, 136, 255);
|
||||
Color tailcolor3 = new Color(83, 75, 118, 255);
|
||||
Color tailcolor4 = new Color(138, 107, 127, 255);
|
||||
if (tailcolor.equals(tailcolor1)) {
|
||||
this.wantTail = 4;
|
||||
} else if (tailcolor.equals(tailcolor2)) {
|
||||
this.wantTail = 3;
|
||||
} else if (tailcolor.equals(tailcolor3)) {
|
||||
this.wantTail = 2;
|
||||
} else if (tailcolor.equals(tailcolor4)) {
|
||||
this.wantTail = 1;
|
||||
} else {
|
||||
this.wantTail = 0;
|
||||
}
|
||||
|
||||
Color gendercolor = new Color(bufferedimage.getRGB(2, 0), true);
|
||||
Color gendercolor1 = new Color(255, 255, 255, 255);
|
||||
if (gendercolor.equals(gendercolor1)) {
|
||||
this.isMale = true;
|
||||
} else {
|
||||
this.isMale = false;
|
||||
}
|
||||
|
||||
Color sizecolor = new Color(bufferedimage.getRGB(3, 0), true);
|
||||
Color scootaloo = new Color(255, 190, 83);
|
||||
Color bigmac = new Color(206, 50, 84);
|
||||
Color luna = new Color(42, 60, 120);
|
||||
if (ponyManager.getUseSizes() == 1) {
|
||||
if (sizecolor.equals(scootaloo)) {
|
||||
this.size = 0;
|
||||
} else if (sizecolor.equals(bigmac)) {
|
||||
this.size = 2;
|
||||
} else if (sizecolor.equals(luna)) {
|
||||
this.size = 3;
|
||||
} else {
|
||||
this.size = 1;
|
||||
}
|
||||
}
|
||||
|
||||
Color black = new Color(0, 0, 0);
|
||||
int scaleFactor = bufferedimage.getHeight() / 32;
|
||||
int tileSize = 8 * scaleFactor;
|
||||
Color advcutiecolor = new Color(bufferedimage.getRGB(tileSize / 2, 0), true);
|
||||
if (advcutiecolor.getAlpha() == 0) {
|
||||
this.advancedTexturing = false;
|
||||
} else {
|
||||
this.advancedTexturing = false;
|
||||
|
||||
for (int tempGlowColor = tileSize / 2; tempGlowColor < tileSize; ++tempGlowColor) {
|
||||
for (int y = 0; y < tileSize; ++y) {
|
||||
Color aColor = new Color(bufferedimage.getRGB(tempGlowColor, y), true);
|
||||
if (!aColor.equals(black)) {
|
||||
this.advancedTexturing = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Color var27 = new Color(bufferedimage.getRGB(0, 1), true);
|
||||
if (!var27.equals(black) && var27.getAlpha() != 0) {
|
||||
this.glowColor = var27.getRGB();
|
||||
} else {
|
||||
this.glowColor = -12303190;
|
||||
}
|
||||
|
||||
this.newSkinSize = bufferedimage.getWidth() == bufferedimage.getHeight();
|
||||
this.skinChecked = true;
|
||||
MineLPLogger.debug(
|
||||
"\tSkin check #%d for pony #%d completed. {IsPony:%b, Race:%s, FlagPixel:%s, AdvancedTexturing:%b}",
|
||||
this.skinCheckCount, this.ponyId, this.isPony, this.race, flagPix, this.advancedTexturing);
|
||||
}
|
||||
|
||||
protected void resetValues() {
|
||||
this.isPony = false;
|
||||
this.isPonySkin = false;
|
||||
this.isPegasus = false;
|
||||
this.isUnicorn = false;
|
||||
this.isPonySkin = false;
|
||||
this.isMale = false;
|
||||
this.wantTail = 0;
|
||||
this.size = 1;
|
||||
}
|
||||
|
||||
public boolean isPony() {
|
||||
return this.isPony;
|
||||
}
|
||||
|
||||
public boolean isPonySkin() {
|
||||
return this.isPonySkin;
|
||||
}
|
||||
|
||||
public boolean isUnicorn() {
|
||||
return this.isUnicorn;
|
||||
}
|
||||
|
||||
public boolean isPegasus() {
|
||||
return this.isPegasus;
|
||||
}
|
||||
|
||||
public Pony.PonyRace getRace() {
|
||||
return this.race;
|
||||
}
|
||||
|
||||
public int wantTail() {
|
||||
return this.wantTail;
|
||||
}
|
||||
|
||||
public boolean isMale() {
|
||||
return this.isMale;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return ponyManager.getUseSizes() == 1 ? this.size : 1;
|
||||
}
|
||||
|
||||
public boolean advancedTexturing() {
|
||||
return this.advancedTexturing;
|
||||
}
|
||||
|
||||
public boolean isFlying() {
|
||||
return this.isFlying;
|
||||
}
|
||||
|
||||
public boolean isGlow() {
|
||||
return this.isGlow;
|
||||
}
|
||||
|
||||
public int glowColor() {
|
||||
return this.glowColor;
|
||||
}
|
||||
|
||||
public int villagerProfession() {
|
||||
return this.villagerProfession;
|
||||
}
|
||||
|
||||
public boolean isPegasusFlying(double posX, double posY, double posZ, float fallDistance, boolean isJumping,
|
||||
boolean onGround, World equestria) {
|
||||
if (!this.isPegasus) {
|
||||
return pegasusFlying = false;
|
||||
} else if (isJumping) {
|
||||
return true;
|
||||
} else {
|
||||
boolean falling = fallDistance > 0;
|
||||
boolean levitating = fallDistance == this.previousFallDistance;
|
||||
boolean standingOnAir;
|
||||
if (falling && !levitating) {
|
||||
standingOnAir = this.standingOnAir(posX, posY, posZ, 1.5F, equestria);
|
||||
} else {
|
||||
standingOnAir = this.standingOnAir(posX, posY, posZ, 1.0F, equestria);
|
||||
}
|
||||
|
||||
if (!standingOnAir) {
|
||||
return pegasusFlying = false;
|
||||
} else if (this.pegasusFlying) {
|
||||
return true;
|
||||
} else if (levitating) {
|
||||
return pegasusFlying = true;
|
||||
} else {
|
||||
this.previousFallDistance = fallDistance;
|
||||
if (fallDistance < 2.0F) {
|
||||
return false;
|
||||
} else {
|
||||
return pegasusFlying = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean standingOnAir(double posX, double posY, double posZ, float range, World equestria) {
|
||||
boolean foundSolidBlock = false;
|
||||
int y;
|
||||
if (this.isSpPlayer) {
|
||||
y = MathHelper.floor_double(posY - this.defaultYOffset - 0.009999999776482582D);
|
||||
} else {
|
||||
y = MathHelper.floor_double(posY - 0.009999999776482582D);
|
||||
}
|
||||
|
||||
for (float shiftX = 0.0F - range; shiftX < range * 2.0F; shiftX += range) {
|
||||
for (float shiftZ = 0.0F - range; shiftZ < range * 2.0F; shiftZ += range) {
|
||||
int x = MathHelper.floor_double(posX + shiftX);
|
||||
int z = MathHelper.floor_double(posZ + shiftZ);
|
||||
if (!equestria.isAirBlock(new BlockPos(x, y, z))) {
|
||||
foundSolidBlock = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !foundSolidBlock;
|
||||
}
|
||||
|
||||
public PlayerModel getModel() {
|
||||
return getModel(false);
|
||||
}
|
||||
|
||||
public PlayerModel getModel(boolean ignorePony) {
|
||||
boolean is_a_pony = false;
|
||||
switch (ignorePony ? PonyLevel.MIXED : ponyManager.getPonyLevel()) {
|
||||
case HUMANS:
|
||||
is_a_pony = false;
|
||||
break;
|
||||
case MIXED:
|
||||
is_a_pony = isPonySkin;
|
||||
break;
|
||||
case PONIES:
|
||||
is_a_pony = true;
|
||||
}
|
||||
|
||||
PlayerModel model;
|
||||
if (is_a_pony) {
|
||||
model = newSkinSize ? PMAPI.newPonyAdv_64 : PMAPI.newPonyAdv;
|
||||
} else {
|
||||
model = newSkinSize ? PMAPI.human_64 : PMAPI.human;
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public ResourceLocation getTextureResourceLocation() {
|
||||
return this.textureResourceLocation;
|
||||
}
|
||||
|
||||
public void setVillager(int profession) {
|
||||
this.isVillager = true;
|
||||
this.villagerProfession = profession;
|
||||
}
|
||||
|
||||
public void setIsPonySkin(boolean b) {
|
||||
this.isPonySkin = false;
|
||||
}
|
||||
|
||||
public static enum PonyRace {
|
||||
EARTH,
|
||||
PEGASUS,
|
||||
UNICORN,
|
||||
ALICORN,
|
||||
CHANGELING,
|
||||
ZEBRA;
|
||||
}
|
||||
}
|
73
src/main/java/com/minelittlepony/minelp/PonyConfig.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
package com.minelittlepony.minelp;
|
||||
|
||||
import com.minelittlepony.minelp.util.MineLPLogger;
|
||||
import com.voxelmodpack.common.properties.ModConfig;
|
||||
|
||||
public class PonyConfig extends ModConfig {
|
||||
@Override
|
||||
protected void setDefaults() {
|
||||
this.defaults.setProperty("ponylevel", "2");
|
||||
this.defaults.setProperty("sizes", "1");
|
||||
this.defaults.setProperty("ponyarmor", "1");
|
||||
this.defaults.setProperty("snuzzles", "1");
|
||||
this.defaults.setProperty("hd", "1");
|
||||
this.defaults.setProperty("showscale", "1");
|
||||
this.defaults.setProperty("eqg", "0");
|
||||
this.defaults.setProperty("villagers", "1");
|
||||
this.defaults.setProperty("zombies", "1");
|
||||
this.defaults.setProperty("pigzombies", "1");
|
||||
this.defaults.setProperty("skeletons", "1");
|
||||
this.defaults.setProperty("oldSkinUploaded", "0");
|
||||
}
|
||||
|
||||
public PonyConfig() {
|
||||
super("Mine Little Pony", "minelittlepony.properties");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOptionDisplayString(String binding) {
|
||||
return "";
|
||||
}
|
||||
|
||||
public int getIntPropertySafe(String key) {
|
||||
return this.getIntPropertySafe(key, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public int getIntPropertySafe(String key, int minValue, int maxValue) {
|
||||
int value;
|
||||
try {
|
||||
value = this.getIntProperty(key);
|
||||
} catch (Exception var9) {
|
||||
try {
|
||||
boolean e2 = this.getBoolProperty(key);
|
||||
if (e2) {
|
||||
value = 1;
|
||||
} else {
|
||||
value = 0;
|
||||
}
|
||||
} catch (Exception var8) {
|
||||
int defaultValue1 = this.getDefaultIntProperty(key);
|
||||
this.setProperty(key, defaultValue1);
|
||||
MineLPLogger.error("Invalid value for config key \"%s\", using default value %d",
|
||||
new Object[] { key, Integer.valueOf(defaultValue1) });
|
||||
return defaultValue1;
|
||||
}
|
||||
}
|
||||
|
||||
if (value >= minValue && value <= maxValue) {
|
||||
return value;
|
||||
} else {
|
||||
int defaultValue = value = this.getDefaultIntProperty(key);
|
||||
this.setProperty(key, defaultValue);
|
||||
MineLPLogger.error(
|
||||
"Invalid value for config key \"%s\", using default value %d. Found %d, expected value between %d and %d.",
|
||||
new Object[] { key, Integer.valueOf(defaultValue), Integer.valueOf(value),
|
||||
Integer.valueOf(minValue), Integer.valueOf(maxValue) });
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSet(String key) {
|
||||
return this.config.containsKey(key);
|
||||
}
|
||||
}
|
23
src/main/java/com/minelittlepony/minelp/PonyLevel.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package com.minelittlepony.minelp;
|
||||
|
||||
public enum PonyLevel {
|
||||
PONIES,
|
||||
HUMANS,
|
||||
MIXED;
|
||||
|
||||
private static final PonyLevel[] oldValues = { HUMANS, MIXED, PONIES };
|
||||
|
||||
public static PonyLevel parse(int intValue) {
|
||||
if (intValue < 0)
|
||||
intValue = 0;
|
||||
if (intValue > 2)
|
||||
intValue = 2;
|
||||
// it's an old value
|
||||
return oldValues[intValue];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toString();
|
||||
}
|
||||
}
|
262
src/main/java/com/minelittlepony/minelp/PonyManager.java
Normal file
|
@ -0,0 +1,262 @@
|
|||
package com.minelittlepony.minelp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.minelittlepony.minelp.model.PMAPI;
|
||||
import com.minelittlepony.minelp.util.MineLPLogger;
|
||||
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class PonyManager {
|
||||
public static final String RESOURCE_NAMESPACE = "minelittlepony";
|
||||
public static final ResourceLocation zombiePonyResource = new ResourceLocation("minelittlepony",
|
||||
"textures/entity/zombie/zombie_pony.png");
|
||||
public static final ResourceLocation zombieVillagerPonyResource = new ResourceLocation("minelittlepony",
|
||||
"textures/entity/zombie/zombie_villager_pony.png");
|
||||
public static final ResourceLocation zombiePigmanPonyResource = new ResourceLocation("minelittlepony",
|
||||
"textures/entity/zombie_pigman_pony.png");
|
||||
public static final ResourceLocation skeletonPonyResource = new ResourceLocation("minelittlepony",
|
||||
"textures/entity/skeleton/skeleton_pony.png");
|
||||
public static final ResourceLocation skeletonWitherPonyResource = new ResourceLocation("minelittlepony",
|
||||
"textures/entity/skeleton/skeleton_wither_pony.png");
|
||||
public static final ResourceLocation defaultPonyResourceLocation = new ResourceLocation("minelittlepony",
|
||||
"textures/entity/pony/charpony.png");
|
||||
public static List<ResourceLocation> backgroundPonyResourceLocations = new ArrayList<ResourceLocation>();
|
||||
public static List<ResourceLocation> villagerResourceLocations;
|
||||
private static final int MAX_BGPONY_COUNT = 141;
|
||||
private static int numberOfPonies;
|
||||
private Map<ResourceLocation, Pony> ponyResourceRegistry = new HashMap<ResourceLocation, Pony>();
|
||||
private Map<ResourceLocation, Pony> backgroudPonyResourceRegistry = new HashMap<ResourceLocation, Pony>();
|
||||
private PonyLevel ponyLevel = PonyLevel.PONIES;
|
||||
private int useSizes = 1;
|
||||
private int ponyArmor = 1;
|
||||
private int showSnuzzles = 1;
|
||||
private int showScale = 1;
|
||||
private int ponyVillagers = 1;
|
||||
private int ponyZombies = 1;
|
||||
private int ponyPigzombies = 1;
|
||||
private int ponySkeletons = 1;
|
||||
private int useHDSkinServer = 1;
|
||||
private static PonyManager instance;
|
||||
|
||||
private PonyManager() {
|
||||
initmodels();
|
||||
}
|
||||
|
||||
public void initmodels() {
|
||||
MineLPLogger.info("Initializing models...");
|
||||
PMAPI.init();
|
||||
MineLPLogger.info("Done initializing models.");
|
||||
}
|
||||
|
||||
public static PonyManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new PonyManager();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Pony getPonyFromResourceRegistry(ResourceLocation skinResourceLocation, AbstractClientPlayer player) {
|
||||
Pony myLittlePony;
|
||||
if (!this.ponyResourceRegistry.containsKey(skinResourceLocation)) {
|
||||
if (player != null) {
|
||||
myLittlePony = new Pony(player);
|
||||
} else {
|
||||
myLittlePony = new Pony(skinResourceLocation);
|
||||
}
|
||||
|
||||
this.ponyResourceRegistry.put(skinResourceLocation, myLittlePony);
|
||||
} else {
|
||||
myLittlePony = this.ponyResourceRegistry.get(skinResourceLocation);
|
||||
}
|
||||
|
||||
return myLittlePony;
|
||||
}
|
||||
|
||||
public Pony getPonyFromResourceRegistry(ResourceLocation skinResourceLocation) {
|
||||
return this.getPonyFromResourceRegistry(skinResourceLocation, (AbstractClientPlayer) null);
|
||||
}
|
||||
|
||||
public Pony getPonyFromResourceRegistry(AbstractClientPlayer player) {
|
||||
Pony myLittlePony = this.getPonyFromResourceRegistry(player.getLocationSkin(), player);
|
||||
if (this.ponyLevel == PonyLevel.PONIES && !myLittlePony.isPonySkin()) {
|
||||
myLittlePony = this.getPonyFromBackgroundResourceRegistry(player);
|
||||
}
|
||||
|
||||
if (player.getCommandSenderName().equals(MineLittlePony.getSPUsername())) {
|
||||
myLittlePony.isSpPlayer = true;
|
||||
}
|
||||
|
||||
return myLittlePony;
|
||||
}
|
||||
|
||||
public Pony getPonyFromResourceRegistry(EntityVillager entity) {
|
||||
int profession = entity.getProfession();
|
||||
|
||||
ResourceLocation villagerResourceLocation;
|
||||
try {
|
||||
villagerResourceLocation = villagerResourceLocations.get(profession);
|
||||
} catch (IndexOutOfBoundsException var5) {
|
||||
villagerResourceLocation = villagerResourceLocations.get(5);
|
||||
}
|
||||
|
||||
Pony myLittlePony = this.getPonyFromResourceRegistry(villagerResourceLocation);
|
||||
myLittlePony.setVillager(profession);
|
||||
return myLittlePony;
|
||||
}
|
||||
|
||||
private ResourceLocation getBackgroundPonyResource(String username) {
|
||||
if (numberOfPonies > 0) {
|
||||
int backgroundIndex = username.hashCode() % this.getNumberOfPonies();
|
||||
if (backgroundIndex < 0) {
|
||||
backgroundIndex += this.getNumberOfPonies();
|
||||
}
|
||||
|
||||
return backgroundPonyResourceLocations.get(backgroundIndex);
|
||||
} else {
|
||||
return defaultPonyResourceLocation;
|
||||
}
|
||||
}
|
||||
|
||||
public Pony getPonyFromBackgroundResourceRegistry(AbstractClientPlayer player) {
|
||||
ResourceLocation textureResourceLocation;
|
||||
if (player.getCommandSenderName() == MineLittlePony.getSPUsername()) {
|
||||
textureResourceLocation = defaultPonyResourceLocation;
|
||||
} else {
|
||||
textureResourceLocation = this.getBackgroundPonyResource(player.getCommandSenderName());
|
||||
}
|
||||
|
||||
Pony myLittlePony;
|
||||
if (!this.backgroudPonyResourceRegistry.containsKey(textureResourceLocation)) {
|
||||
myLittlePony = new Pony(textureResourceLocation);
|
||||
this.backgroudPonyResourceRegistry.put(textureResourceLocation, myLittlePony);
|
||||
} else {
|
||||
myLittlePony = this.backgroudPonyResourceRegistry.get(textureResourceLocation);
|
||||
}
|
||||
|
||||
return myLittlePony;
|
||||
}
|
||||
|
||||
public int getHD() {
|
||||
return this.useHDSkinServer;
|
||||
}
|
||||
|
||||
public int getNumberOfPonies() {
|
||||
return numberOfPonies;
|
||||
}
|
||||
|
||||
public int getPonyArmor() {
|
||||
return this.ponyArmor;
|
||||
}
|
||||
|
||||
public PonyLevel getPonyLevel() {
|
||||
return this.ponyLevel;
|
||||
}
|
||||
|
||||
public int getPonyPigzombies() {
|
||||
return this.ponyPigzombies;
|
||||
}
|
||||
|
||||
public int getPonySkeletons() {
|
||||
return this.ponySkeletons;
|
||||
}
|
||||
|
||||
public int getPonyVillagers() {
|
||||
return this.ponyVillagers;
|
||||
}
|
||||
|
||||
public int getPonyZombies() {
|
||||
return this.ponyZombies;
|
||||
}
|
||||
|
||||
public int getShowScale() {
|
||||
return this.showScale;
|
||||
}
|
||||
|
||||
public int getShowSnuzzles() {
|
||||
return this.showSnuzzles;
|
||||
}
|
||||
|
||||
public int getUseSizes() {
|
||||
return this.useSizes;
|
||||
}
|
||||
|
||||
public void setHD(int useHDSkinServer) {
|
||||
this.useHDSkinServer = useHDSkinServer;
|
||||
}
|
||||
|
||||
public void setPonyArmor(int ponyArmor) {
|
||||
this.ponyArmor = ponyArmor;
|
||||
}
|
||||
|
||||
public void setPonyLevel(PonyLevel ponyLevel) {
|
||||
this.ponyLevel = ponyLevel;
|
||||
}
|
||||
|
||||
public void setPonyPigzombies(int ponyPigzombies) {
|
||||
this.ponyPigzombies = ponyPigzombies;
|
||||
}
|
||||
|
||||
public void setPonySkeletons(int ponySkeletons) {
|
||||
this.ponySkeletons = ponySkeletons;
|
||||
}
|
||||
|
||||
public void setPonyVillagers(int ponyVillagers) {
|
||||
this.ponyVillagers = ponyVillagers;
|
||||
}
|
||||
|
||||
public void setPonyZombies(int ponyZombies) {
|
||||
this.ponyZombies = ponyZombies;
|
||||
}
|
||||
|
||||
public void setShowScale(int showScale) {
|
||||
this.showScale = showScale;
|
||||
}
|
||||
|
||||
public void setShowSnuzzles(int showSnuzzles) {
|
||||
this.showSnuzzles = showSnuzzles;
|
||||
}
|
||||
|
||||
public void setUseSizes(int useSizes) {
|
||||
this.useSizes = useSizes;
|
||||
}
|
||||
|
||||
static {
|
||||
for (int check = 0; check < MAX_BGPONY_COUNT; ++check) {
|
||||
backgroundPonyResourceLocations
|
||||
.add(new ResourceLocation("minelittlepony", "textures/entity/pony/bpony_" + check + ".png"));
|
||||
}
|
||||
|
||||
numberOfPonies = backgroundPonyResourceLocations.size();
|
||||
MineLPLogger.info("Detected %d of %d background ponies installed.",
|
||||
new Object[] { Integer.valueOf(numberOfPonies), Integer.valueOf(MAX_BGPONY_COUNT) });
|
||||
villagerResourceLocations = new ArrayList<ResourceLocation>();
|
||||
villagerResourceLocations
|
||||
.add(new ResourceLocation("minelittlepony", "textures/entity/villager/farmer_pony.png"));
|
||||
villagerResourceLocations
|
||||
.add(new ResourceLocation("minelittlepony", "textures/entity/villager/librarian_pony.png"));
|
||||
villagerResourceLocations
|
||||
.add(new ResourceLocation("minelittlepony", "textures/entity/villager/priest_pony.png"));
|
||||
villagerResourceLocations
|
||||
.add(new ResourceLocation("minelittlepony", "textures/entity/villager/smith_pony.png"));
|
||||
villagerResourceLocations
|
||||
.add(new ResourceLocation("minelittlepony", "textures/entity/villager/butcher_pony.png"));
|
||||
villagerResourceLocations
|
||||
.add(new ResourceLocation("minelittlepony", "textures/entity/villager/villager_pony.png"));
|
||||
}
|
||||
|
||||
public static enum PonyRace {
|
||||
EARTH,
|
||||
PEGASUS,
|
||||
UNICORN,
|
||||
ALICORN,
|
||||
CHANGELING,
|
||||
ZEBRA;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package com.minelittlepony.minelp.gui;
|
||||
|
||||
import com.voxelmodpack.common.LiteModVoxelCommon;
|
||||
import com.voxelmodpack.common.gui.interfaces.IExtendedGui;
|
||||
import com.voxelmodpack.common.properties.VoxelProperty;
|
||||
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProvider;
|
||||
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderInteger;
|
||||
|
||||
public class FakeVoxelPropertyCheckBox extends VoxelProperty<IVoxelPropertyProviderInteger> {
|
||||
private int width = 11;
|
||||
|
||||
public FakeVoxelPropertyCheckBox(IVoxelPropertyProvider propertyProvider, String binding, String text, int xPos,
|
||||
int yPos) {
|
||||
super(propertyProvider, binding, text, xPos, yPos);
|
||||
this.width = this.fontRenderer.getStringWidth(this.displayText) + 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(IExtendedGui host, int mouseX, int mouseY) {
|
||||
this.drawString(this.fontRenderer, this.displayText, this.xPosition + 20, this.yPosition + 2, 16777215);
|
||||
boolean overButton = this.mouseOver(mouseX, mouseY);
|
||||
boolean checked = true;
|
||||
|
||||
try {
|
||||
int e = this.propertyProvider.getIntProperty(this.propertyBinding);
|
||||
if (e < 2 && e > -1) {
|
||||
if (e == 0) {
|
||||
checked = false;
|
||||
} else {
|
||||
checked = true;
|
||||
}
|
||||
}
|
||||
} catch (Exception var7) {
|
||||
;
|
||||
}
|
||||
|
||||
host.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, this.xPosition, this.yPosition,
|
||||
this.xPosition + 11, this.yPosition + 11, 0, overButton ? 16 : 0, 16, overButton ? 32 : 16, 4);
|
||||
host.drawTexturedModalRect(LiteModVoxelCommon.GUIPARTS, this.xPosition, this.yPosition, this.xPosition + 10,
|
||||
this.yPosition + 10, checked ? 12 : 0, 52, checked ? 23 : 11, 63);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY) {
|
||||
if (this.mouseOver(mouseX, mouseY)) {
|
||||
boolean checked = true;
|
||||
|
||||
try {
|
||||
int e = this.propertyProvider.getIntProperty(this.propertyBinding);
|
||||
if (e < 2 && e > -1) {
|
||||
if (e == 0) {
|
||||
checked = false;
|
||||
} else {
|
||||
checked = true;
|
||||
}
|
||||
}
|
||||
} catch (Exception var5) {
|
||||
;
|
||||
}
|
||||
|
||||
if (checked) {
|
||||
this.propertyProvider.setProperty(this.propertyBinding, 0);
|
||||
} else {
|
||||
this.propertyProvider.setProperty(this.propertyBinding, 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean mouseOver(int mouseX, int mouseY) {
|
||||
return mouseX > this.xPosition && mouseX < this.xPosition + this.width && mouseY > this.yPosition
|
||||
&& mouseY < this.yPosition + 11;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char keyChar, int keyCode) {}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.minelittlepony.minelp.gui;
|
||||
|
||||
import com.minelittlepony.minelp.MineLittlePony;
|
||||
import com.voxelmodpack.common.properties.VoxelPropertyLabel;
|
||||
import com.voxelmodpack.common.properties.gui.GuiVoxelBoxSettingsPanel;
|
||||
|
||||
public class MineLittlePonyGUI extends GuiVoxelBoxSettingsPanel {
|
||||
public MineLittlePonyGUI() {
|
||||
// PonyManager ponyManager = PonyManager.getInstance();
|
||||
this.config = MineLittlePony.getConfig();
|
||||
byte col1 = 30;
|
||||
this.properties.add(new VoxelPropertyIntSlider(this.config, "ponylevel", "Pony Level", PANEL_LEFT, PANEL_TOP + 24));
|
||||
this.properties.add(new VoxelPropertyLabel("Pony Options", PANEL_LEFT + 15, PANEL_TOP + 58));
|
||||
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "hd", "Enable MineLP skin server (requires restart)", PANEL_LEFT + col1, PANEL_TOP + 72));
|
||||
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "sizes", "Allow all different sizes of pony", PANEL_LEFT + col1, PANEL_TOP + 90));
|
||||
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "ponyarmor", "Use Mine Little Pony compatible armor", PANEL_LEFT + col1, PANEL_TOP + 108));
|
||||
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "snuzzles", "Display snuzzles on ponies", PANEL_LEFT + col1, PANEL_TOP + 126));
|
||||
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "showscale", "Use show-accurate scaling", PANEL_LEFT + col1, PANEL_TOP + 144));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPanelTitle() {
|
||||
return "Mine Little Pony Settings";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.minelittlepony.minelp.gui;
|
||||
|
||||
import com.minelittlepony.minelp.MineLittlePony;
|
||||
import com.voxelmodpack.common.properties.VoxelPropertyLabel;
|
||||
import com.voxelmodpack.common.properties.gui.GuiVoxelBoxSettingsPanel;
|
||||
|
||||
public class MineLittlePonyGUIMob extends GuiVoxelBoxSettingsPanel {
|
||||
public MineLittlePonyGUIMob() {
|
||||
// PonyManager ponyManager = PonyManager.getInstance();
|
||||
this.config = MineLittlePony.getConfig();
|
||||
byte col1 = 30;
|
||||
this.properties.add(new VoxelPropertyLabel("If you make any changes here, you must restart", PANEL_LEFT + 15, PANEL_TOP + 11, 16737894));
|
||||
this.properties.add(new VoxelPropertyLabel("Minecraft before they will take effect!", PANEL_LEFT + 15, PANEL_TOP + 23, 16737894));
|
||||
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "villagers", "Ponify villagers", PANEL_LEFT + col1, PANEL_TOP + 42));
|
||||
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "zombies", "Ponify zombies", PANEL_LEFT + col1, PANEL_TOP + 60));
|
||||
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "pigzombies", "Ponify zombie pigmen", PANEL_LEFT + col1, PANEL_TOP + 78));
|
||||
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "skeletons", "Ponify skeletons", PANEL_LEFT + col1, PANEL_TOP + 96));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPanelTitle() {
|
||||
return "Mine Little Pony Mob Settings";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,175 @@
|
|||
package com.minelittlepony.minelp.gui;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import com.voxelmodpack.common.LiteModVoxelCommon;
|
||||
import com.voxelmodpack.common.gui.interfaces.IExtendedGui;
|
||||
import com.voxelmodpack.common.properties.VoxelProperty;
|
||||
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderInteger;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class VoxelPropertyIntSlider extends VoxelProperty<IVoxelPropertyProviderInteger> {
|
||||
int minValue;
|
||||
int maxValue;
|
||||
float value;
|
||||
boolean overReset;
|
||||
boolean overSlide;
|
||||
boolean overBar;
|
||||
boolean setBar;
|
||||
boolean dragging;
|
||||
int offset;
|
||||
String minText;
|
||||
String midText;
|
||||
String maxText;
|
||||
String labelText;
|
||||
|
||||
public VoxelPropertyIntSlider(IVoxelPropertyProviderInteger parent, String binding, String text, String minText,
|
||||
String maxText, int xPos, int yPos, int min, int max) {
|
||||
this(parent, binding, text, minText, maxText, xPos, yPos);
|
||||
this.minValue = min;
|
||||
this.maxValue = max;
|
||||
}
|
||||
|
||||
public VoxelPropertyIntSlider(IVoxelPropertyProviderInteger parent, String binding, String text, int xPos, int yPos,
|
||||
float min, float max) {
|
||||
this(parent, binding, text, xPos, yPos);
|
||||
}
|
||||
|
||||
public VoxelPropertyIntSlider(IVoxelPropertyProviderInteger parent, String binding, String text, String minText,
|
||||
String maxText, int xPos, int yPos) {
|
||||
this(parent, binding, text, xPos, yPos);
|
||||
this.minText = minText;
|
||||
this.maxText = maxText;
|
||||
}
|
||||
|
||||
public VoxelPropertyIntSlider(IVoxelPropertyProviderInteger parent, String binding, String text, int xPos,
|
||||
int yPos) {
|
||||
super(parent, binding, text, xPos, yPos);
|
||||
this.minValue = 0;
|
||||
this.maxValue = 2;
|
||||
this.value = 2.0F;
|
||||
this.overReset = false;
|
||||
this.overSlide = false;
|
||||
this.overBar = false;
|
||||
this.setBar = false;
|
||||
this.dragging = false;
|
||||
this.offset = 0;
|
||||
this.minText = "Humans";
|
||||
this.midText = "Mix";
|
||||
this.maxText = "Ponies";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(IExtendedGui gui, int mouseX, int mouseY) {
|
||||
this.overReset = this.mouseOverReset(mouseX, mouseY);
|
||||
int outset = this.overReset ? 1 : 0;
|
||||
int v = this.overReset ? 16 : 0;
|
||||
drawRect(this.xPosition + 160 - outset, this.yPosition + 11 - outset, this.xPosition + 212 + outset,
|
||||
this.yPosition + 26 + outset, -16777216);
|
||||
gui.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, this.xPosition + 159 - outset,
|
||||
this.yPosition + 10 - outset, this.xPosition + 213 + outset, this.yPosition + 27 + outset, 0, v, 16,
|
||||
16 + v, 4);
|
||||
this.drawString(this.mc.fontRendererObj, "Default", this.xPosition + 169, this.yPosition + 15,
|
||||
this.overReset ? 16777215 : 10066329);
|
||||
int sliderLeft = this.xPosition + 48;
|
||||
int sliderRight = this.xPosition + 124;
|
||||
int sliderXPos = sliderLeft + 32;
|
||||
int sliderXPos2 = sliderLeft + 45;
|
||||
int sliderYPos = this.yPosition + 12;
|
||||
int sliderYPos2 = this.yPosition + 25;
|
||||
int sliderMinX = sliderLeft - (sliderXPos + sliderXPos2) / 2 + 5;
|
||||
int sliderMaxX = sliderRight - (sliderXPos + sliderXPos2) / 2 - 5;
|
||||
this.drawHorizontalLine(sliderLeft, sliderRight, this.yPosition + 18, -6710887);
|
||||
this.drawVerticalLine(this.xPosition + 86, this.yPosition + 14, this.yPosition + 22, -6710887);
|
||||
this.drawVerticalLine(sliderLeft, this.yPosition + 14, this.yPosition + 22, -6710887);
|
||||
this.drawVerticalLine(sliderRight, this.yPosition + 14, this.yPosition + 22, -6710887);
|
||||
if (this.displayText != null) {
|
||||
this.drawString(this.mc.fontRendererObj, this.displayText, this.xPosition + 15, this.yPosition - 14, 10079487);
|
||||
}
|
||||
|
||||
this.drawString(this.mc.fontRendererObj, this.minText, this.xPosition + 35, this.yPosition, 16777215);
|
||||
if (this.midText != null) {
|
||||
this.drawString(this.mc.fontRendererObj, this.midText, this.xPosition + 80, this.yPosition, 16777215);
|
||||
}
|
||||
|
||||
if (this.maxText != null) {
|
||||
this.drawString(this.mc.fontRendererObj, this.maxText, this.xPosition + 110, this.yPosition, 16777215);
|
||||
} else {
|
||||
float scale = (this.value + 1.0F) / 2.0F;
|
||||
int displayValue = MathHelper.ceiling_float_int(
|
||||
(this.minValue + (this.maxValue - this.minValue) * scale) * 100.0F);
|
||||
this.drawString(this.mc.fontRendererObj, displayValue + "%", this.xPosition + 130, this.yPosition + 15,
|
||||
16777215);
|
||||
}
|
||||
|
||||
this.overSlide = this.mouseIn(mouseX, mouseY, sliderXPos, sliderYPos, sliderXPos2, sliderYPos2);
|
||||
this.overBar = this.mouseIn(mouseX, mouseY, sliderLeft, sliderYPos, sliderRight, sliderYPos2)
|
||||
&& !this.overSlide;
|
||||
if (this.dragging) {
|
||||
if (Mouse.isButtonDown(0)) {
|
||||
this.offset = Math.min(Math.max(mouseX - (sliderXPos + sliderXPos2) / 2, sliderMinX), sliderMaxX);
|
||||
this.value = (float) this.offset / (float) sliderMaxX;
|
||||
} else {
|
||||
this.value = (float) this.offset / (float) sliderMaxX;
|
||||
this.propertyProvider.setProperty(this.propertyBinding,
|
||||
Math.round(this.value) + 1);
|
||||
this.dragging = false;
|
||||
}
|
||||
} else {
|
||||
this.offset = (this.propertyProvider.getIntProperty(this.propertyBinding)
|
||||
- 1) * sliderMaxX;
|
||||
this.value = (float) this.offset / (float) sliderMaxX;
|
||||
}
|
||||
|
||||
if (this.setBar) {
|
||||
this.offset = mouseX - (sliderXPos + sliderXPos2) / 2;
|
||||
this.value = (float) this.offset / (float) sliderMaxX;
|
||||
this.propertyProvider.setProperty(this.propertyBinding,
|
||||
Math.round(this.value) + 1);
|
||||
this.setBar = false;
|
||||
this.dragging = true;
|
||||
}
|
||||
|
||||
if (this.offset > sliderMaxX) {
|
||||
this.offset = sliderMaxX;
|
||||
}
|
||||
|
||||
if (this.offset < sliderMinX) {
|
||||
this.offset = sliderMinX;
|
||||
}
|
||||
|
||||
drawRect(sliderXPos2 - 1 + this.offset, sliderYPos2 - 1, sliderXPos + 1 + this.offset, sliderYPos + 1,
|
||||
-16777216);
|
||||
gui.drawTessellatedModalBorderRect(LiteModVoxelCommon.GUIPARTS, 256, sliderXPos + this.offset, sliderYPos,
|
||||
sliderXPos2 + this.offset, sliderYPos2, 0, !this.overSlide && !this.dragging ? 0 : 16, 16,
|
||||
!this.overSlide && !this.dragging ? 16 : 32, 4);
|
||||
}
|
||||
|
||||
protected boolean mouseIn(int mouseX, int mouseY, int x1, int y1, int x2, int y2) {
|
||||
return mouseX > x1 + this.offset && mouseX < x2 + this.offset && mouseY > y1 && mouseY < y2;
|
||||
}
|
||||
|
||||
protected boolean mouseOverReset(int mouseX, int mouseY) {
|
||||
return mouseX > this.xPosition + 159 && mouseX < this.xPosition + 213 && mouseY > this.yPosition + 10
|
||||
&& mouseY < this.yPosition + 27;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY) {
|
||||
if (this.overSlide) {
|
||||
this.dragging = true;
|
||||
this.playClickSound(this.mc.getSoundHandler());
|
||||
} else if (this.overBar) {
|
||||
this.setBar = true;
|
||||
this.playClickSound(this.mc.getSoundHandler());
|
||||
} else if (this.overReset) {
|
||||
this.propertyProvider.setProperty(this.propertyBinding, 2);
|
||||
this.playClickSound(this.mc.getSoundHandler());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char keyChar, int keyCode) {}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.minelittlepony.minelp.hdskins.gui;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
|
||||
|
||||
public class EntityPonyModel extends EntityPlayerModel {
|
||||
public EntityPonyModel(GameProfile profile) {
|
||||
super(profile);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,684 @@
|
|||
package com.minelittlepony.minelp.hdskins.gui;
|
||||
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.DoubleBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
|
||||
import com.minelittlepony.minelp.PonyManager;
|
||||
import com.minelittlepony.minelp.util.MineLPLogger;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.exceptions.AuthenticationException;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
||||
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
|
||||
import com.voxelmodpack.common.net.upload.IUploadCompleteCallback;
|
||||
import com.voxelmodpack.common.net.upload.ThreadMultipartPostUpload;
|
||||
import com.voxelmodpack.common.net.upload.awt.IOpenFileCallback;
|
||||
import com.voxelmodpack.common.net.upload.awt.ThreadOpenFilePNG;
|
||||
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
|
||||
import com.voxelmodpack.hdskins.mod.HDSkinsModCore;
|
||||
import com.voxelmodpack.voxelmenu.IPanoramaRenderer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Session;
|
||||
|
||||
public class GuiSkinsMineLP extends GuiScreen implements IUploadCompleteCallback, IOpenFileCallback, IPanoramaRenderer {
|
||||
private static final ResourceLocation vignette = new ResourceLocation("textures/misc/vignette.png");
|
||||
private static final int MAX_SKIN_DIMENSION = 8192;
|
||||
private static final String skinServerId = "7853dfddc358333843ad55a2c7485c4aa0380a51";
|
||||
private int updateCounter = 0;
|
||||
private ResourceLocation viewportTexture;
|
||||
private IPanoramaRenderer panoramaRenderer;
|
||||
private static final ResourceLocation[] cubemapTextures = {
|
||||
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_0.png"),
|
||||
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_1.png"),
|
||||
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_2.png"),
|
||||
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_3.png"),
|
||||
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_4.png"),
|
||||
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_5.png") };
|
||||
private GuiButton btnBrowse;
|
||||
private GuiButton btnUpload;
|
||||
private GuiButton btnClear;
|
||||
private GuiButton btnBack;
|
||||
private EntityPonyModel localPlayer;
|
||||
private EntityPonyModel remotePlayer;
|
||||
protected DoubleBuffer doubleBuffer;
|
||||
private String screenTitle;
|
||||
private String uploadError;
|
||||
private volatile String skinMessage = "Choose a file";
|
||||
private String skinUploadMessage = "Uploading skin please wait...";
|
||||
private volatile boolean fetchingSkin;
|
||||
private volatile boolean uploadingSkin;
|
||||
private volatile boolean pendingRemoteSkinRefresh;
|
||||
private volatile boolean throttledByMojang;
|
||||
private int refreshCounter = -1;
|
||||
private ThreadOpenFilePNG openFileThread;
|
||||
private ThreadMultipartPostUpload threadSkinUpload;
|
||||
private Object skinLock = new Object();
|
||||
private File pendingSkinFile;
|
||||
private File selectedSkin;
|
||||
private BufferedImage pendingSkinImage;
|
||||
private float uploadOpacity = 0.0F;
|
||||
private float lastPartialTick;
|
||||
|
||||
public GuiSkinsMineLP() {
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
this.screenTitle = "Skin Manager";
|
||||
GameProfile profile = minecraft.getSession().getProfile();
|
||||
this.localPlayer = new EntityPonyModel(profile);
|
||||
this.remotePlayer = new EntityPonyModel(profile);
|
||||
RenderManager rm = Minecraft.getMinecraft().getRenderManager();
|
||||
rm.renderEngine = minecraft.getTextureManager();
|
||||
rm.options = minecraft.gameSettings;
|
||||
rm.livingPlayer = this.localPlayer;
|
||||
this.setRemoteSkin();
|
||||
this.fetchingSkin = true;
|
||||
this.panoramaRenderer = HDSkinsModCore.getPanoramaRenderer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
++this.updateCounter;
|
||||
this.panoramaRenderer.updatePanorama();
|
||||
this.localPlayer.updateModel();
|
||||
this.remotePlayer.updateModel();
|
||||
if (this.fetchingSkin && this.remotePlayer.isTextureSetupComplete()) {
|
||||
this.fetchingSkin = false;
|
||||
this.btnClear.enabled = true;
|
||||
}
|
||||
|
||||
synchronized (this.skinLock) {
|
||||
if (this.pendingSkinFile != null) {
|
||||
this.localPlayer.setLocalSkin(this.pendingSkinFile);
|
||||
this.selectedSkin = this.pendingSkinFile;
|
||||
this.pendingSkinFile = null;
|
||||
MineLPLogger.debug("Invalidating old local skin, checking updated local skin");
|
||||
PonyManager.getInstance().getPonyFromResourceRegistry(this.localPlayer.getSkinTexture())
|
||||
.checkSkin(this.pendingSkinImage);
|
||||
this.pendingSkinImage = null;
|
||||
this.btnUpload.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.pendingRemoteSkinRefresh) {
|
||||
this.pendingRemoteSkinRefresh = false;
|
||||
this.fetchingSkin = true;
|
||||
this.btnClear.enabled = false;
|
||||
this.setRemoteSkin();
|
||||
MineLPLogger.debug("Invalidating old remove skin, checking updated remote skin");
|
||||
PonyManager.getInstance().getPonyFromResourceRegistry(this.remotePlayer.getSkinTexture())
|
||||
.invalidateSkinCheck();
|
||||
}
|
||||
|
||||
if (this.throttledByMojang) {
|
||||
if (this.refreshCounter == -1) {
|
||||
this.refreshCounter = 200;
|
||||
} else if (this.refreshCounter > 0) {
|
||||
--this.refreshCounter;
|
||||
} else {
|
||||
this.refreshCounter = -1;
|
||||
this.throttledByMojang = false;
|
||||
this.setRemoteSkin();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setRemoteSkin() {
|
||||
try {
|
||||
this.remotePlayer.setRemoteSkin();
|
||||
} catch (Exception var2) {
|
||||
var2.printStackTrace();
|
||||
this.throttledByMojang = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePanorama() {}
|
||||
|
||||
@Override
|
||||
public int getUpdateCounter() {
|
||||
return this.updateCounter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorldAndResolution(Minecraft par1Minecraft, int par2, int par3) {
|
||||
super.setWorldAndResolution(par1Minecraft, par2, par3);
|
||||
this.panoramaRenderer.setPanoramaResolution(par1Minecraft, par2, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPanoramaResolution(Minecraft minecraft, int width, int height) {}
|
||||
|
||||
protected List<GuiButton> getControlList() {
|
||||
return this.buttonList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.panoramaRenderer.initPanoramaRenderer();
|
||||
this.getControlList().clear();
|
||||
this.getControlList().add(this.btnBrowse = new GuiButton(0, 30, this.height - 36, 60, 20, "Browse..."));
|
||||
this.getControlList()
|
||||
.add(this.btnUpload = new GuiButton(1, this.width / 2 - 24, this.height / 2 - 10, 48, 20, ">>"));
|
||||
this.getControlList().add(this.btnClear = new GuiButton(2, this.width - 90, this.height - 36, 60, 20, "Clear"));
|
||||
this.getControlList()
|
||||
.add(this.btnBack = new GuiButton(3, this.width / 2 - 50, this.height - 36, 100, 20, "Close"));
|
||||
this.btnUpload.enabled = false;
|
||||
this.btnBrowse.enabled = !this.mc.isFullScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initPanoramaRenderer() {
|
||||
this.viewportTexture = this.mc.getTextureManager().getDynamicTextureLocation("skinpanorama",
|
||||
new DynamicTexture(256, 256));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
this.localPlayer.releaseTextures();
|
||||
this.remotePlayer.releaseTextures();
|
||||
PonyManager.getInstance().getPonyFromResourceRegistry(this.localPlayer.getSkinTexture()).invalidateSkinCheck();
|
||||
PonyManager.getInstance().getPonyFromResourceRegistry(this.remotePlayer.getSkinTexture()).invalidateSkinCheck();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileOpenDialogClosed(JFileChooser fileDialog, int dialogResult) {
|
||||
this.openFileThread = null;
|
||||
if (dialogResult == 0) {
|
||||
this.loadLocalFile(fileDialog.getSelectedFile());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void loadLocalFile(File skinFile) {
|
||||
if (!skinFile.exists()) {
|
||||
this.skinMessage = "File not readable";
|
||||
} else {
|
||||
BufferedImage chosenImage;
|
||||
try {
|
||||
chosenImage = ImageIO.read(skinFile);
|
||||
} catch (IOException var6) {
|
||||
this.skinMessage = "Error opening skin file";
|
||||
var6.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
if (chosenImage == null) {
|
||||
this.skinMessage = "Error opening skin file";
|
||||
} else if (isPowerOfTwo(chosenImage.getWidth())
|
||||
&& (chosenImage.getWidth() == chosenImage.getHeight() * 2
|
||||
|| chosenImage.getWidth() == chosenImage.getHeight())
|
||||
&& chosenImage.getWidth() <= MAX_SKIN_DIMENSION
|
||||
&& chosenImage.getHeight() <= MAX_SKIN_DIMENSION) {
|
||||
synchronized (this.skinLock) {
|
||||
this.pendingSkinFile = skinFile;
|
||||
this.pendingSkinImage = chosenImage;
|
||||
}
|
||||
} else {
|
||||
this.skinMessage = "Not a valid skin file";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guiButton) {
|
||||
if (this.openFileThread == null && !this.uploadingSkin) {
|
||||
if (this.uploadError != null) {
|
||||
this.uploadError = null;
|
||||
} else {
|
||||
if (guiButton.id == this.btnBrowse.id) {
|
||||
this.selectedSkin = null;
|
||||
this.localPlayer.releaseTextures();
|
||||
this.openFileThread = new ThreadOpenFilePNG(this.mc, "Choose skin", this);
|
||||
this.openFileThread.start();
|
||||
}
|
||||
|
||||
if (guiButton.id == this.btnUpload.id) {
|
||||
if (this.selectedSkin != null) {
|
||||
this.uploadSkin(this.mc.getSession(), this.selectedSkin);
|
||||
this.btnUpload.enabled = false;
|
||||
} else {
|
||||
this.setUploadError("Please select a skin first");
|
||||
}
|
||||
}
|
||||
|
||||
if (guiButton.id == this.btnClear.id && this.remotePlayer.isTextureSetupComplete()) {
|
||||
this.clearUploadedSkin(this.mc.getSession());
|
||||
this.btnUpload.enabled = this.selectedSkin != null;
|
||||
}
|
||||
|
||||
if (guiButton.id == this.btnBack.id) {
|
||||
this.mc.displayGuiScreen(new GuiMainMenu());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException {
|
||||
if (this.uploadError != null) {
|
||||
this.uploadError = null;
|
||||
} else {
|
||||
super.mouseClicked(mouseX, mouseY, button);
|
||||
byte top = 30;
|
||||
int bottom = this.height - 40;
|
||||
int mid = this.width / 2;
|
||||
if ((mouseX > 30 && mouseX < mid - 30 || mouseX > mid + 30 && mouseX < this.width - 30) && mouseY > top
|
||||
&& mouseY < bottom) {
|
||||
this.localPlayer.swingArm();
|
||||
this.remotePlayer.swingArm();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char keyChar, int keyCode) throws IOException {
|
||||
if (this.openFileThread == null && !this.uploadingSkin) {
|
||||
super.keyTyped(keyChar, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
public void setupCubemapCamera() {
|
||||
matrixMode(5889);
|
||||
pushMatrix();
|
||||
loadIdentity();
|
||||
GLU.gluPerspective(150.0F, 1.0F, 0.05F, 10.0F);
|
||||
matrixMode(5888);
|
||||
pushMatrix();
|
||||
loadIdentity();
|
||||
}
|
||||
|
||||
public void revertPanoramaMatrix() {
|
||||
matrixMode(5889);
|
||||
popMatrix();
|
||||
matrixMode(5888);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
private void renderCubeMapTexture(int mouseX, int mouseY, float partialTick) {
|
||||
this.setupCubemapCamera();
|
||||
color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
rotate(180.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glDisable(3008);
|
||||
GL11.glDisable(2884);
|
||||
depthMask(false);
|
||||
blendFunc(770, 771);
|
||||
byte blendIterations = 8;
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer wr = tessellator.getWorldRenderer();
|
||||
|
||||
for (int blendPass = 0; blendPass < blendIterations * blendIterations; ++blendPass) {
|
||||
pushMatrix();
|
||||
float offsetX = ((float) (blendPass % blendIterations) / (float) blendIterations - 0.5F) / 64.0F;
|
||||
float offsetY = ((float) (blendPass / blendIterations) / (float) blendIterations - 0.5F) / 64.0F;
|
||||
float offsetZ = 0.0F;
|
||||
translate(offsetX, offsetY, offsetZ);
|
||||
rotate(MathHelper.sin((this.updateCounter + 200 + partialTick) / 400.0F) * 25.0F + 20.0F, 1.0F,
|
||||
0.0F, 0.0F);
|
||||
rotate(-(this.updateCounter + 200 + partialTick) * 0.1F, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
for (int cubeSide = 0; cubeSide < 6; ++cubeSide) {
|
||||
pushMatrix();
|
||||
if (cubeSide == 1) {
|
||||
rotate(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (cubeSide == 2) {
|
||||
rotate(180.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (cubeSide == 3) {
|
||||
rotate(-90.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (cubeSide == 4) {
|
||||
rotate(90.0F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (cubeSide == 5) {
|
||||
rotate(-90.0F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
this.mc.getTextureManager().bindTexture(cubemapTextures[cubeSide]);
|
||||
wr.startDrawingQuads();
|
||||
wr.setColorRGBA_I(16777215, 255 / (blendPass + 1));
|
||||
wr.addVertexWithUV(-1.0D, -1.0D, 1.0D, 0.0D, 0.0D);
|
||||
wr.addVertexWithUV(1.0D, -1.0D, 1.0D, 1.0D, 0.0D);
|
||||
wr.addVertexWithUV(1.0D, 1.0D, 1.0D, 1.0D, 1.0D);
|
||||
wr.addVertexWithUV(-1.0D, 1.0D, 1.0D, 0.0D, 1.0D);
|
||||
tessellator.draw();
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
popMatrix();
|
||||
colorMask(true, true, true, false);
|
||||
}
|
||||
|
||||
wr.setTranslation(0.0D, 0.0D, 0.0D);
|
||||
colorMask(true, true, true, true);
|
||||
depthMask(true);
|
||||
GL11.glEnable(2884);
|
||||
GL11.glEnable(3008);
|
||||
GL11.glEnable(2929);
|
||||
this.revertPanoramaMatrix();
|
||||
}
|
||||
|
||||
private void rotateAndBlurCubemap(float partialTick) {
|
||||
this.mc.getTextureManager().bindTexture(this.viewportTexture);
|
||||
GL11.glCopyTexSubImage2D(3553, 0, 0, 0, 0, 0, 256, 256);
|
||||
GL11.glEnable(3042);
|
||||
blendFunc(770, 771);
|
||||
colorMask(true, true, true, false);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer wr = tessellator.getWorldRenderer();
|
||||
wr.startDrawingQuads();
|
||||
byte blurPasses = 4;
|
||||
|
||||
for (int blurPass = 0; blurPass < blurPasses; ++blurPass) {
|
||||
wr.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F / (blurPass + 1));
|
||||
float var7 = (blurPass - blurPasses / 2) / 256.0F;
|
||||
wr.addVertexWithUV(this.width, this.height, this.zLevel, 0.0F + var7, 0.0D);
|
||||
wr.addVertexWithUV(this.width, 0.0D, this.zLevel, 1.0F + var7, 0.0D);
|
||||
wr.addVertexWithUV(0.0D, 0.0D, this.zLevel, 1.0F + var7, 1.0D);
|
||||
wr.addVertexWithUV(0.0D, this.height, this.zLevel, 0.0F + var7, 1.0D);
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
colorMask(true, true, true, true);
|
||||
GL11.glDisable(3042);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderPanorama(int mouseX, int mouseY, float partialTicks) {
|
||||
GL11.glViewport(0, 0, 256, 256);
|
||||
this.renderCubeMapTexture(mouseX, mouseY, partialTicks);
|
||||
GL11.glDisable(3553);
|
||||
GL11.glEnable(3553);
|
||||
|
||||
for (int tessellator = 0; tessellator < 8; ++tessellator) {
|
||||
this.rotateAndBlurCubemap(partialTicks);
|
||||
}
|
||||
|
||||
GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer wr = tessellator.getWorldRenderer();
|
||||
wr.startDrawingQuads();
|
||||
float aspect = this.width > this.height ? 120.0F / this.width : 120.0F / this.height;
|
||||
float uSample = this.height * aspect / 256.0F;
|
||||
float vSample = this.width * aspect / 256.0F;
|
||||
GL11.glTexParameteri(3553, 10241, 9729);
|
||||
GL11.glTexParameteri(3553, 10240, 9729);
|
||||
wr.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
wr.addVertexWithUV(0.0D, this.height, this.zLevel, 0.5F - uSample, 0.5F + vSample);
|
||||
wr.addVertexWithUV(this.width, this.height, this.zLevel, 0.5F - uSample, 0.5F - vSample);
|
||||
wr.addVertexWithUV(this.width, 0.0D, this.zLevel, 0.5F + uSample, 0.5F - vSample);
|
||||
wr.addVertexWithUV(0.0D, 0.0D, this.zLevel, 0.5F + uSample, 0.5F + vSample);
|
||||
tessellator.draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTick) {
|
||||
float deltaTime = this.updateCounter + partialTick - this.lastPartialTick;
|
||||
this.lastPartialTick = this.updateCounter + partialTick;
|
||||
GL11.glDisable(2912);
|
||||
this.mc.entityRenderer.disableLightmap();
|
||||
this.panoramaRenderer.renderPanorama(mouseX, mouseY, partialTick);
|
||||
byte top = 30;
|
||||
int bottom = this.height - 40;
|
||||
int mid = this.width / 2;
|
||||
int horizon = this.height / 2 + this.height / 5;
|
||||
GL11.glPushAttrib(1048575);
|
||||
Gui.drawRect(30, top, mid - 30, bottom, Integer.MIN_VALUE);
|
||||
Gui.drawRect(mid + 30, top, this.width - 30, bottom, Integer.MIN_VALUE);
|
||||
this.drawGradientRect(30, horizon, mid - 30, bottom, -2130706433, 16777215);
|
||||
this.drawGradientRect(mid + 30, horizon, this.width - 30, bottom, -2130706433, 16777215);
|
||||
super.drawScreen(mouseX, mouseY, partialTick);
|
||||
popAttrib();
|
||||
this.enableClipping(30, bottom);
|
||||
float yPos = this.height * 0.75F;
|
||||
float xPos1 = this.width * 0.25F;
|
||||
float xPos2 = this.width * 0.75F;
|
||||
float scale = this.height * 0.25F;
|
||||
this.renderPlayerModel(this.localPlayer, xPos1, yPos, scale, xPos1 - mouseX, yPos - scale * 1.8F - mouseY,
|
||||
partialTick);
|
||||
this.renderPlayerModel(this.remotePlayer, xPos2, yPos, scale, xPos2 - mouseX, yPos - scale * 1.8F - mouseY,
|
||||
partialTick);
|
||||
this.disableClipping();
|
||||
this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 10, 16777215);
|
||||
this.fontRendererObj.drawStringWithShadow("Local Skin", 34, 34, 16777215);
|
||||
this.fontRendererObj.drawStringWithShadow("Server Skin", this.width / 2 + 34, 34, 16777215);
|
||||
GL11.glDisable(2929);
|
||||
depthMask(false);
|
||||
this.drawGradientRect(30, this.height - 60, mid - 30, bottom, 0, -520093697);
|
||||
this.drawGradientRect(mid + 30, this.height - 60, this.width - 30, bottom, 0, -520093697);
|
||||
int labelwidth = (this.width / 2 - 80) / 2;
|
||||
int opacity;
|
||||
if (!this.localPlayer.isUsingLocalTexture()) {
|
||||
opacity = this.fontRendererObj.getStringWidth(this.skinMessage) / 2;
|
||||
Gui.drawRect(40, this.height / 2 - 12, this.width / 2 - 40, this.height / 2 + 12, -1342177280);
|
||||
this.fontRendererObj.drawStringWithShadow(this.skinMessage, (int) (xPos1 - opacity), this.height / 2 - 4,
|
||||
16777215);
|
||||
}
|
||||
|
||||
if (this.fetchingSkin) {
|
||||
String opacity1;
|
||||
if (this.throttledByMojang) {
|
||||
opacity1 = "\u00a7cMojang API Error!";
|
||||
String stringWidth = "Please wait 1 minute";
|
||||
int stringWidth1 = this.fontRendererObj.getStringWidth(opacity1) / 2;
|
||||
int stringWidth2 = this.fontRendererObj.getStringWidth(stringWidth) / 2;
|
||||
Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 16, this.width - 40, this.height / 2 + 16,
|
||||
-1342177280);
|
||||
this.fontRendererObj.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 10,
|
||||
16777215);
|
||||
this.fontRendererObj.drawStringWithShadow(stringWidth, (int) (xPos2 - stringWidth2),
|
||||
this.height / 2 + 2, 16777215);
|
||||
} else {
|
||||
opacity1 = "Fetching skin...";
|
||||
int stringWidth1 = this.fontRendererObj.getStringWidth(opacity1) / 2;
|
||||
Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 12, this.width - 40, this.height / 2 + 12,
|
||||
-1342177280);
|
||||
this.fontRendererObj.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 4,
|
||||
16777215);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.uploadingSkin || this.uploadOpacity > 0.0F) {
|
||||
if (!this.uploadingSkin) {
|
||||
this.uploadOpacity -= deltaTime * 0.05F;
|
||||
} else if (this.uploadOpacity < 1.0F) {
|
||||
this.uploadOpacity += deltaTime * 0.1F;
|
||||
}
|
||||
|
||||
if (this.uploadOpacity > 1.0F) {
|
||||
this.uploadOpacity = 1.0F;
|
||||
}
|
||||
|
||||
opacity = Math.min(180, (int) (this.uploadOpacity * 180.0F)) & 255;
|
||||
if (this.uploadOpacity > 0.0F) {
|
||||
Gui.drawRect(0, 0, this.width, this.height, opacity << 24 | 0);
|
||||
if (this.uploadingSkin) {
|
||||
this.drawCenteredString(this.fontRendererObj, this.skinUploadMessage, this.width / 2,
|
||||
this.height / 2, opacity << 24 | 16777215);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.uploadError != null) {
|
||||
Gui.drawRect(0, 0, this.width, this.height, -1342177280);
|
||||
this.drawCenteredString(this.fontRendererObj, "Uploading skin failed", this.width / 2, this.height / 2 - 10,
|
||||
-171);
|
||||
this.drawCenteredString(this.fontRendererObj, this.uploadError, this.width / 2, this.height / 2 + 2,
|
||||
-43691);
|
||||
}
|
||||
|
||||
depthMask(true);
|
||||
GL11.glEnable(2929);
|
||||
}
|
||||
|
||||
protected void renderVignette(int mouseX, int mouseY, float partialTick) {
|
||||
GL11.glDisable(2929);
|
||||
depthMask(false);
|
||||
blendFunc(1, 774);
|
||||
color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(vignette);
|
||||
GL11.glLogicOp(5386);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer wr = tessellator.getWorldRenderer();
|
||||
wr.startDrawingQuads();
|
||||
wr.addVertexWithUV(0.0D, this.height, -90.0D, 0.0D, 1.0D);
|
||||
wr.addVertexWithUV(this.width, this.height, -90.0D, 1.0D, 1.0D);
|
||||
wr.addVertexWithUV(this.width, 0.0D, -90.0D, 1.0D, 0.0D);
|
||||
wr.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
|
||||
tessellator.draw();
|
||||
depthMask(true);
|
||||
GL11.glDisable(3058);
|
||||
GL11.glEnable(2929);
|
||||
color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
blendFunc(770, 771);
|
||||
}
|
||||
|
||||
public void renderPlayerModel(EntityPlayerModel thePlayer, float xPosition, float yPosition, float scale,
|
||||
float mouseX, float mouseY, float partialTick) {
|
||||
GL11.glEnable(2903);
|
||||
pushMatrix();
|
||||
translate(xPosition, yPosition, 300.0F);
|
||||
scale(-scale, scale, scale);
|
||||
rotate(180.0F, 0.0F, 0.0F, 1.0F);
|
||||
rotate(135.0F, 0.0F, 1.0F, 0.0F);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
rotate(-135.0F, 0.0F, 1.0F, 0.0F);
|
||||
rotate(15.0F, 1.0F, 0.0F, 0.0F);
|
||||
rotate((this.updateCounter + partialTick) * 2.5F, 0.0F, 1.0F, 0.0F);
|
||||
thePlayer.rotationPitch = -((float) Math.atan(mouseY / 40.0F)) * 20.0F;
|
||||
translate(0.0D, thePlayer.getYOffset(), 0.0D);
|
||||
RenderManager rm = Minecraft.getMinecraft().getRenderManager();
|
||||
rm.playerViewY = 180.0F;
|
||||
rm.renderEntityWithPosYaw(thePlayer, 0.0D, 0.0D, 0.0D, 1.0F, 1.0F);
|
||||
popMatrix();
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable('\u803a');
|
||||
}
|
||||
|
||||
protected final void enableClipping(int yTop, int yBottom) {
|
||||
if (this.doubleBuffer == null) {
|
||||
this.doubleBuffer = BufferUtils.createByteBuffer(32).asDoubleBuffer();
|
||||
}
|
||||
|
||||
this.doubleBuffer.clear();
|
||||
this.doubleBuffer.put(0.0D).put(1.0D).put(0.0D).put((-yTop)).flip();
|
||||
GL11.glClipPlane(12288, this.doubleBuffer);
|
||||
this.doubleBuffer.clear();
|
||||
this.doubleBuffer.put(0.0D).put(-1.0D).put(0.0D).put(yBottom).flip();
|
||||
GL11.glClipPlane(12289, this.doubleBuffer);
|
||||
GL11.glEnable(12288);
|
||||
GL11.glEnable(12289);
|
||||
}
|
||||
|
||||
protected final void disableClipping() {
|
||||
GL11.glDisable(12289);
|
||||
GL11.glDisable(12288);
|
||||
}
|
||||
|
||||
public static boolean isPowerOfTwo(int number) {
|
||||
return number != 0 && (number & number - 1) == 0;
|
||||
}
|
||||
|
||||
private boolean clearUploadedSkin(Session session) {
|
||||
if (!this.registerServerConnection(session, skinServerId)) {
|
||||
return false;
|
||||
} else {
|
||||
HashMap<String, Object> sourceData = new HashMap<String, Object>();
|
||||
sourceData.put("user", session.getUsername());
|
||||
sourceData.put("uuid", session.getPlayerID());
|
||||
sourceData.put("clear", "1");
|
||||
this.uploadError = null;
|
||||
this.uploadingSkin = true;
|
||||
this.skinUploadMessage = "Sending request to server please wait...";
|
||||
this.threadSkinUpload = new ThreadMultipartPostUpload("http://minelpskinmanager.voxelmodpack.com/",
|
||||
sourceData, this);
|
||||
this.threadSkinUpload.start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean uploadSkin(Session session, File skinFile) {
|
||||
if (!this.registerServerConnection(session, skinServerId)) {
|
||||
return false;
|
||||
} else {
|
||||
HashMap<String, Object> sourceData = new HashMap<String, Object>();
|
||||
sourceData.put("user", session.getUsername());
|
||||
sourceData.put("uuid", session.getPlayerID());
|
||||
sourceData.put("skin", skinFile);
|
||||
this.uploadError = null;
|
||||
this.uploadingSkin = true;
|
||||
this.skinUploadMessage = "Uploading skin please wait...";
|
||||
this.threadSkinUpload = new ThreadMultipartPostUpload("http://minelpskinmanager.voxelmodpack.com/",
|
||||
sourceData, this);
|
||||
this.threadSkinUpload.start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void setUploadError(String error) {
|
||||
this.uploadError = error.startsWith("ERROR: ") ? error.substring(7) : error;
|
||||
this.btnUpload.enabled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadComplete(String response) {
|
||||
LiteLoaderLogger.info("Upload completed with: %s", new Object[] { response });
|
||||
this.uploadingSkin = false;
|
||||
this.threadSkinUpload = null;
|
||||
if (!response.equalsIgnoreCase("OK")) {
|
||||
this.setUploadError(response);
|
||||
} else {
|
||||
this.pendingRemoteSkinRefresh = true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean registerServerConnection(Session session, String serverId) {
|
||||
try {
|
||||
MinecraftSessionService e = (new YggdrasilAuthenticationService(this.mc.getProxy(),
|
||||
UUID.randomUUID().toString())).createMinecraftSessionService();
|
||||
e.joinServer(session.getProfile(), session.getToken(), serverId);
|
||||
return true;
|
||||
} catch (AuthenticationException var4) {
|
||||
this.setUploadError(var4.toString());
|
||||
var4.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.minelittlepony.minelp.hdskins.gui;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.minelittlepony.minelp.PonyManager;
|
||||
import com.minelittlepony.minelp.util.MineLPLogger;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
class dGuiSkinsMineLP extends GuiSkins {
|
||||
|
||||
public dGuiSkinsMineLP() {
|
||||
GameProfile profile = Minecraft.getMinecraft().getSession().getProfile();
|
||||
this.localPlayer = new EntityPonyModel(profile);
|
||||
this.remotePlayer = new EntityPonyModel(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setLocalSkin(File pendingSkin) {
|
||||
super.setLocalSkin(pendingSkin);
|
||||
MineLPLogger.debug("Invalidating old local skin, checking updated local skin");
|
||||
try {
|
||||
PonyManager.getInstance().getPonyFromResourceRegistry(this.localPlayer.getSkinTexture()).checkSkin(ImageIO.read(pendingSkin));
|
||||
} catch (IOException e) {
|
||||
MineLPLogger.error(e, "Unable to read file {}", pendingSkin.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRemoteSkin() {
|
||||
super.setRemoteSkin();
|
||||
PonyManager.getInstance().getPonyFromResourceRegistry(this.remotePlayer.getSkinTexture()).invalidateSkinCheck();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
PonyManager.getInstance().getPonyFromResourceRegistry(this.localPlayer.getSkinTexture()).invalidateSkinCheck();
|
||||
PonyManager.getInstance().getPonyFromResourceRegistry(this.remotePlayer.getSkinTexture()).invalidateSkinCheck();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.minelittlepony.minelp.hdskins.gui;
|
||||
|
||||
import com.minelittlepony.minelp.Pony;
|
||||
import com.minelittlepony.minelp.PonyManager;
|
||||
import com.minelittlepony.minelp.model.PlayerModel;
|
||||
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
|
||||
import com.voxelmodpack.hdskins.gui.RenderPlayerModel;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
public class RenderPonyModel extends RenderPlayerModel {
|
||||
|
||||
public RenderPonyModel(RenderManager renderer) {
|
||||
super(renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderModel(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4, float par5, float par6, float par7) {
|
||||
this.bindEntityTexture(par1EntityLivingBase);
|
||||
EntityPlayerModel playerModelEntity = (EntityPlayerModel) par1EntityLivingBase;
|
||||
Pony thePony = PonyManager.getInstance().getPonyFromResourceRegistry(this.getEntityTexture(playerModelEntity));
|
||||
thePony.checkSkin();
|
||||
PlayerModel pm = thePony.getModel(true);
|
||||
this.mainModel = pm.model;
|
||||
pm.model.isFlying = thePony.isFlying = false;
|
||||
pm.model.isPegasus = thePony.isPegasus();
|
||||
pm.model.isUnicorn = thePony.isUnicorn();
|
||||
pm.model.isMale = thePony.isMale();
|
||||
pm.model.size = thePony.size();
|
||||
pm.model.glowColor = thePony.glowColor();
|
||||
pm.model.wantTail = thePony.wantTail();
|
||||
pm.model.isVillager = false;
|
||||
this.mainModel.render(par1EntityLivingBase, par2, par3, par4, par5, par6, par7);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.minelittlepony.minelp.model;
|
||||
|
||||
public abstract class ModelArmor {
|
||||
public final String path;
|
||||
public ModelPony base;
|
||||
public ModelPony modelArmorChestplate;
|
||||
public ModelPony modelArmor;
|
||||
|
||||
public ModelArmor(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public float layer() {
|
||||
return 1;
|
||||
};
|
||||
|
||||
public int subimage(int slot) {
|
||||
return slot == 2 ? 2 : 1;
|
||||
}
|
||||
|
||||
}
|
106
src/main/java/com/minelittlepony/minelp/model/ModelHornGlow.java
Normal file
|
@ -0,0 +1,106 @@
|
|||
package com.minelittlepony.minelp.model;
|
||||
|
||||
import com.minelittlepony.minelp.renderer.HornGlowRenderer;
|
||||
import net.minecraft.client.model.PositionTextureVertex;
|
||||
import net.minecraft.client.model.TexturedQuad;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
public class ModelHornGlow {
|
||||
private PositionTextureVertex[] vertexPositions;
|
||||
private TexturedQuad[] quadList;
|
||||
public final float posX1;
|
||||
public final float posY1;
|
||||
public final float posZ1;
|
||||
public final float posX2;
|
||||
public final float posY2;
|
||||
public final float posZ2;
|
||||
public String field_78247_g;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public ModelHornGlow(HornGlowRenderer par1ModelRenderer, int par2, int par3, float par4, float par5, float par6,
|
||||
int par7, int par8, int par9, float par10) {
|
||||
this.posX1 = par4;
|
||||
this.posY1 = par5;
|
||||
this.posZ1 = par6;
|
||||
this.posX2 = par4 + par7;
|
||||
this.posY2 = par5 + par8;
|
||||
this.posZ2 = par6 + par9;
|
||||
this.vertexPositions = new PositionTextureVertex[8];
|
||||
this.quadList = new TexturedQuad[6];
|
||||
float var11 = par4 + par7;
|
||||
float var12 = par5 + par8;
|
||||
float var13 = par6 + par9;
|
||||
float halfpar4 = par4 + par7 * 0.05F;
|
||||
float halfpar6 = par6 + par9 * 0.05F;
|
||||
float halfvar11 = par4 + par7 * 0.95F;
|
||||
float halfvar13 = par6 + par9 * 0.95F;
|
||||
par4 -= par10;
|
||||
par5 -= par10;
|
||||
par6 -= par10;
|
||||
var11 += par10;
|
||||
var12 += par10;
|
||||
var13 += par10;
|
||||
float xcentre = (par4 + var11) / 2.0F;
|
||||
float zcentre = (par6 + var13) / 2.0F;
|
||||
if (par1ModelRenderer.mirror) {
|
||||
float var26 = var11;
|
||||
var11 = par4;
|
||||
par4 = var26;
|
||||
}
|
||||
|
||||
PositionTextureVertex var32 = new PositionTextureVertex(halfpar4, par5, halfpar6, 0.0F, 0.0F);
|
||||
PositionTextureVertex var15 = new PositionTextureVertex(halfvar11, par5, halfpar6, 0.0F, 8.0F);
|
||||
PositionTextureVertex var16 = new PositionTextureVertex(var11, var12, par6, 8.0F, 8.0F);
|
||||
PositionTextureVertex var17 = new PositionTextureVertex(par4, var12, par6, 8.0F, 0.0F);
|
||||
PositionTextureVertex var18 = new PositionTextureVertex(halfpar4, par5, halfvar13, 0.0F, 0.0F);
|
||||
PositionTextureVertex var19 = new PositionTextureVertex(halfvar11, par5, halfvar13, 0.0F, 8.0F);
|
||||
PositionTextureVertex var20 = new PositionTextureVertex(var11, var12, var13, 8.0F, 8.0F);
|
||||
PositionTextureVertex var21 = new PositionTextureVertex(par4, var12, var13, 8.0F, 0.0F);
|
||||
this.vertexPositions[0] = var32;
|
||||
this.vertexPositions[1] = var15;
|
||||
this.vertexPositions[2] = var16;
|
||||
this.vertexPositions[3] = var17;
|
||||
this.vertexPositions[4] = var18;
|
||||
this.vertexPositions[5] = var19;
|
||||
this.vertexPositions[6] = var20;
|
||||
this.vertexPositions[7] = var21;
|
||||
this.quadList[0] = new TexturedQuad(new PositionTextureVertex[] { var19, var15, var16, var20 },
|
||||
par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8,
|
||||
par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
|
||||
this.quadList[1] = new TexturedQuad(new PositionTextureVertex[] { var32, var18, var21, var17 }, par2,
|
||||
par3 + par9, par2 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth,
|
||||
par1ModelRenderer.textureHeight);
|
||||
this.quadList[2] = new TexturedQuad(new PositionTextureVertex[] { var19, var18, var32, var15 }, par2 + par9,
|
||||
par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
|
||||
this.quadList[3] = new TexturedQuad(new PositionTextureVertex[] { var16, var17, var21, var20 },
|
||||
par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par7, par3, par1ModelRenderer.textureWidth,
|
||||
par1ModelRenderer.textureHeight);
|
||||
this.quadList[4] = new TexturedQuad(new PositionTextureVertex[] { var15, var32, var17, var16 }, par2 + par9,
|
||||
par3 + par9, par2 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth,
|
||||
par1ModelRenderer.textureHeight);
|
||||
this.quadList[5] = new TexturedQuad(new PositionTextureVertex[] { var18, var19, var20, var21 },
|
||||
par2 + par9 + par7 + par9, par3 + par9, par2 + par9 + par7 + par9 + par7, par3 + par9 + par8,
|
||||
par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
|
||||
if (par1ModelRenderer.mirror) {
|
||||
TexturedQuad[] var22 = this.quadList;
|
||||
|
||||
for (TexturedQuad var25 : var22) {
|
||||
var25.flipFace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void render(Tessellator par1Tessellator, float par2) {
|
||||
TexturedQuad[] var3 = this.quadList;
|
||||
for (TexturedQuad var6 : var3) {
|
||||
var6.draw(par1Tessellator.getWorldRenderer(), par2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ModelHornGlow func_78244_a(String par1Str) {
|
||||
this.field_78247_g = par1Str;
|
||||
return this;
|
||||
}
|
||||
}
|
219
src/main/java/com/minelittlepony/minelp/model/ModelPony.java
Normal file
|
@ -0,0 +1,219 @@
|
|||
package com.minelittlepony.minelp.model;
|
||||
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
|
||||
import com.minelittlepony.minelp.PonyManager;
|
||||
import com.minelittlepony.minelp.renderer.AniParams;
|
||||
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.model.ModelPlayer;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class ModelPony extends ModelPlayer {
|
||||
public String texture;
|
||||
protected float strech = 0.0F;
|
||||
protected float scale = 0.0625F;
|
||||
public boolean issneak = false;
|
||||
public boolean isArmour = false;
|
||||
public int glowColor = -12303190;
|
||||
public final float pi = 3.141593F;
|
||||
public boolean isPegasus;
|
||||
public boolean isUnicorn;
|
||||
public boolean isMale;
|
||||
public int wantTail;
|
||||
public int size;
|
||||
public boolean isVillager;
|
||||
public int villagerProfession;
|
||||
public boolean isFlying;
|
||||
public boolean isGlow;
|
||||
public boolean isSleeping;
|
||||
public int heldItemLeft;
|
||||
public int heldItemRight;
|
||||
public boolean aimedBow;
|
||||
|
||||
public ModelPony(String texture) {
|
||||
super(0, false);
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
public void setStrech(float strech) {
|
||||
this.strech = strech;
|
||||
}
|
||||
|
||||
public final void init() {
|
||||
init(0);
|
||||
}
|
||||
|
||||
public final void init(float var1) {
|
||||
init(var1, 0);
|
||||
}
|
||||
|
||||
public abstract void init(float var1, float var2);
|
||||
|
||||
public void animate(AniParams var1) {};
|
||||
|
||||
public void render(AniParams var1) {};
|
||||
|
||||
@Override
|
||||
public void render(Entity player, float Move, float Moveswing, float Loop, float Right, float Down, float Scale) {
|
||||
PonyManager.getInstance();
|
||||
if (player instanceof AbstractClientPlayer) {
|
||||
setModelVisibilities((AbstractClientPlayer) player);
|
||||
}
|
||||
if (!doCancelRender()) {
|
||||
AniParams ani = new AniParams(Move, Moveswing, Loop, Right, Down);
|
||||
this.animate(ani);
|
||||
this.render(ani);
|
||||
} else {
|
||||
super.render(player, Move, Moveswing, Loop, Right, Down, Scale);
|
||||
}
|
||||
}
|
||||
|
||||
private void setModelVisibilities(AbstractClientPlayer clientPlayer) {
|
||||
ModelPlayer modelplayer = this;
|
||||
|
||||
if (clientPlayer.isSpectator()) {
|
||||
modelplayer.setInvisible(false);
|
||||
modelplayer.bipedHead.showModel = true;
|
||||
modelplayer.bipedHeadwear.showModel = true;
|
||||
} else {
|
||||
ItemStack itemstack = clientPlayer.inventory.getCurrentItem();
|
||||
modelplayer.setInvisible(true);
|
||||
modelplayer.bipedHeadwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.HAT);
|
||||
modelplayer.bipedBodyWear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.JACKET);
|
||||
modelplayer.bipedLeftLegwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.LEFT_PANTS_LEG);
|
||||
modelplayer.bipedRightLegwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.RIGHT_PANTS_LEG);
|
||||
modelplayer.bipedLeftArmwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.LEFT_SLEEVE);
|
||||
modelplayer.bipedRightArmwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.RIGHT_SLEEVE);
|
||||
modelplayer.heldItemLeft = 0;
|
||||
modelplayer.aimedBow = false;
|
||||
modelplayer.isSneak = clientPlayer.isSneaking();
|
||||
|
||||
if (itemstack == null) {
|
||||
modelplayer.heldItemRight = 0;
|
||||
} else {
|
||||
modelplayer.heldItemRight = 1;
|
||||
|
||||
if (clientPlayer.getItemInUseCount() > 0) {
|
||||
EnumAction enumaction = itemstack.getItemUseAction();
|
||||
|
||||
if (enumaction == EnumAction.BLOCK) {
|
||||
modelplayer.heldItemRight = 3;
|
||||
} else if (enumaction == EnumAction.BOW) {
|
||||
modelplayer.aimedBow = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void renderDrop(RenderManager rendermanager, ItemRenderer itemrenderer, EntityLivingBase entity) {}
|
||||
|
||||
protected void renderDrop(ItemRenderer itemrenderer, EntityLivingBase entity, ModelRenderer box,
|
||||
float scalefactor, float posx, float posy, float posz) {
|
||||
ItemStack drop = entity.getHeldItem();
|
||||
if (drop != null) {
|
||||
pushMatrix();
|
||||
if (box != null) {
|
||||
box.postRender(scalefactor * 0.0625F);
|
||||
}
|
||||
|
||||
translate(posx, posy, posz);
|
||||
EnumAction playerAction = null;
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer is3D = (EntityPlayer) entity;
|
||||
if (is3D.fishEntity != null) {
|
||||
drop = new ItemStack(Items.stick);
|
||||
}
|
||||
|
||||
if (is3D.getItemInUseCount() > 0) {
|
||||
playerAction = drop.getItemUseAction();
|
||||
}
|
||||
}
|
||||
|
||||
if (drop.getItem() == Items.bow) {
|
||||
rotate(-20.0F, 0.0F, 1.0F, 0.0F);
|
||||
rotate(45.0F, 0.0F, 1.0F, 0.0F);
|
||||
} else if (drop.getItem().isFull3D()) {
|
||||
if (drop.getItem().shouldRotateAroundWhenRendering()) {
|
||||
rotate(180.0F, 0.0F, 0.0F, 1.0F);
|
||||
translate(0.0F, -0.125F, 0.0F);
|
||||
}
|
||||
|
||||
if (playerAction == EnumAction.BLOCK && entity instanceof EntityPlayer
|
||||
&& ((EntityPlayer) entity).getItemInUseCount() > 0) {
|
||||
translate(0.05F, 0.0F, -0.1F);
|
||||
rotate(-50.0F, 0.0F, 1.0F, 0.0F);
|
||||
rotate(-10.0F, 1.0F, 0.0F, 0.0F);
|
||||
rotate(-60.0F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
float g;
|
||||
float b;
|
||||
int var20;
|
||||
|
||||
var20 = drop.getItem().getColorFromItemStack(drop, 0);
|
||||
float var19 = (var20 >> 16 & 255) / 255.0F;
|
||||
g = (var20 >> 8 & 255) / 255.0F;
|
||||
b = (var20 & 255) / 255.0F;
|
||||
color(var19, g, b, 1.0F);
|
||||
itemrenderer.renderItem(entity, drop, TransformType.THIRD_PERSON);
|
||||
|
||||
if (isUnicorn && glowColor != 0) {
|
||||
this.renderItemGlow(itemrenderer, entity, drop);
|
||||
}
|
||||
|
||||
popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
public void renderItemGlow(ItemRenderer itemRenderer, EntityLivingBase entity, ItemStack drop) {
|
||||
// FIXME doesn't blend
|
||||
pushMatrix();
|
||||
GL11.glPushAttrib(24577);
|
||||
GL11.glDisable(2896);
|
||||
float red = (glowColor >> 16 & 255) / 255.0F;
|
||||
float green = (glowColor >> 8 & 255) / 255.0F;
|
||||
float blue = (glowColor & 255) / 255.0F;
|
||||
float alpha = 0.2F;
|
||||
enableBlend();
|
||||
GL11.glEnable(3042);
|
||||
GL14.glBlendColor(red, green, blue, alpha);
|
||||
blendFunc('\u8001', 1);
|
||||
color(red, green, blue, alpha);
|
||||
// translate(1.1F, 1.1F, 1.1F);
|
||||
if (!(drop.getItem() instanceof ItemBlock) || !drop.getItem().isFull3D()) {
|
||||
translate(0.02F, -0.06F, -0.02F);
|
||||
}
|
||||
// itemRenderer.renderItem(entity, drop, TransformType.THIRD_PERSON);
|
||||
popAttrib();
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
public void renderEars(EntityLivingBase entity, float par2) {}
|
||||
|
||||
public void renderCloak(EntityPlayer player, float par2) {}
|
||||
|
||||
public void renderStaticCloak(EntityLiving player, float par2) {}
|
||||
|
||||
protected boolean doCancelRender() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
55
src/main/java/com/minelittlepony/minelp/model/PMAPI.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
package com.minelittlepony.minelp.model;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import com.minelittlepony.minelp.model.pony.pm_Human;
|
||||
import com.minelittlepony.minelp.model.pony.pm_newPonyAdv;
|
||||
import com.minelittlepony.minelp.model.pony.pm_skeletonPony;
|
||||
import com.minelittlepony.minelp.model.pony.pm_zombiePony;
|
||||
import com.minelittlepony.minelp.model.pony.armor.pma_Human;
|
||||
import com.minelittlepony.minelp.model.pony.armor.pma_newPony;
|
||||
import com.minelittlepony.minelp.model.pony.armor.pma_skeletonPony;
|
||||
import com.minelittlepony.minelp.model.pony.armor.pma_zombiePony;
|
||||
|
||||
public final class PMAPI {
|
||||
|
||||
public static PlayerModel newPonyAdv = new PlayerModel("newPonyAdv", new pm_newPonyAdv("/mob/char.png"), 0)
|
||||
.setTextureHeight(32)
|
||||
.setArmor(new pma_newPony("minelittlepony:textures/models/armor/"))
|
||||
.setURL("http://skins.minecraft.net/MinecraftSkins/%NAME%.png")
|
||||
.setScale(0.9375F);
|
||||
public static PlayerModel newPonyAdv_64 = new PlayerModel("newPonyAdv", new pm_newPonyAdv("/mob/char.png"), 0)
|
||||
.setArmor(new pma_newPony("minelittlepony:textures/models/armor/"))
|
||||
.setURL("http://skins.minecraft.net/MinecraftSkins/%NAME%.png")
|
||||
.setScale(0.9375F);
|
||||
public static PlayerModel zombiePony = new PlayerModel("zombiePony", new pm_zombiePony("/mob/char.png"), 0)
|
||||
.setTextureHeight(32)
|
||||
.setArmor(new pma_zombiePony("minelittlepony:textures/models/armor/"))
|
||||
.setURL("http://skins.minecraft.net/MinecraftSkins/%NAME%.png")
|
||||
.setScale(0.9375F);
|
||||
public static PlayerModel skeletonPony = new PlayerModel("skeletonPony", new pm_skeletonPony("/mob/char.png"), 0)
|
||||
.setTextureHeight(32)
|
||||
.setArmor(new pma_skeletonPony("minelittlepony:textures/models/armor/"))
|
||||
.setURL("http://skins.minecraft.net/MinecraftSkins/%NAME%.png")
|
||||
.setScale(0.9375F);
|
||||
public static PlayerModel human = new PlayerModel("Human", new pm_Human("/mob/char.png"), 1)
|
||||
.setTextureHeight(32)
|
||||
.setArmor(new pma_Human("minecraft:textures/models/armor/"))
|
||||
.setURL("http://skins.minecraft.net/MinecraftSkins/%NAME%.png")
|
||||
.setScale(0.9375F);
|
||||
public static PlayerModel human_64 = new PlayerModel("Human", new pm_Human("/mob/char.png"), 1)
|
||||
.setArmor(new pma_Human("minecraft:textures/models/armor/"))
|
||||
.setURL("http://skins.minecraft.net/MinecraftSkins/%NAME%.png")
|
||||
.setScale(0.9375F);
|
||||
|
||||
public static void init() {
|
||||
for (Field field : PMAPI.class.getFields()) {
|
||||
try {
|
||||
PlayerModel model = (PlayerModel) field.get(null);
|
||||
model.init();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.minelittlepony.minelp.model;
|
||||
|
||||
import com.minelittlepony.minelp.model.ModelArmor;
|
||||
import com.minelittlepony.minelp.model.ModelPony;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class PlayerModel {
|
||||
public final int id;
|
||||
public String name;
|
||||
public String url;
|
||||
public ModelPony model;
|
||||
public ModelArmor armor;
|
||||
public float width = 0.6F;
|
||||
public float height = 1.8F;
|
||||
public float shadowsize = 0.5F;
|
||||
public float thirdpersondistance = 4.0F;
|
||||
public float yoffset = 1.62F;
|
||||
public float globalscale = 1.0F;
|
||||
|
||||
public PlayerModel(String name, ModelPony model, int manual_id) {
|
||||
this.name = name;
|
||||
this.model = model;
|
||||
this.id = manual_id;
|
||||
}
|
||||
|
||||
public PlayerModel setTextureHeight(int height) {
|
||||
model.textureHeight = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlayerModel setArmor(ModelArmor armor) {
|
||||
this.armor = armor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlayerModel setURL(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlayerModel setShadow(float size) {
|
||||
this.shadowsize = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlayerModel setSize(float width, float height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlayerModel setOffset(float offset) {
|
||||
this.yoffset = offset;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlayerModel setDistance(float distance) {
|
||||
this.thirdpersondistance = distance;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlayerModel setScale(float scale) {
|
||||
this.globalscale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasArmor() {
|
||||
return this.armor != null && this.armor.base != null && this.armor.path != null;
|
||||
}
|
||||
|
||||
public String getSize(DecimalFormat df) {
|
||||
return df.format(this.width) + " * " + df.format(this.height) + " * " + df.format(this.width);
|
||||
}
|
||||
|
||||
public void init() {
|
||||
model.init();
|
||||
armor.modelArmorChestplate.init(0.0F, 1.0F);
|
||||
armor.modelArmor.init(0.0F, 0.5F);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package com.minelittlepony.minelp.model;
|
||||
|
||||
import com.minelittlepony.minelp.renderer.ScalableModelRenderer;
|
||||
import net.minecraft.client.model.PositionTextureVertex;
|
||||
import net.minecraft.client.model.TexturedQuad;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
public class ScalableModelBox {
|
||||
private PositionTextureVertex[] vertexPositions;
|
||||
private TexturedQuad[] quadList;
|
||||
public final float posX1;
|
||||
public final float posY1;
|
||||
public final float posZ1;
|
||||
public final float posX2;
|
||||
public final float posY2;
|
||||
public final float posZ2;
|
||||
public String field_78247_g;
|
||||
|
||||
public ScalableModelBox(ScalableModelRenderer par1ModelRenderer, int par2, int par3, float par4, float par5, float par6, int par7, int par8, int par9, float par10) {
|
||||
this.posX1 = par4;
|
||||
this.posY1 = par5;
|
||||
this.posZ1 = par6;
|
||||
this.posX2 = par4 + par7;
|
||||
this.posY2 = par5 + par8;
|
||||
this.posZ2 = par6 + par9;
|
||||
this.vertexPositions = new PositionTextureVertex[8];
|
||||
this.quadList = new TexturedQuad[6];
|
||||
float var11 = par4 + par7;
|
||||
float var12 = par5 + par8;
|
||||
float var13 = par6 + par9;
|
||||
par4 -= par10;
|
||||
par5 -= par10;
|
||||
par6 -= par10;
|
||||
var11 += par10;
|
||||
var12 += par10;
|
||||
var13 += par10;
|
||||
if(par1ModelRenderer.mirror) {
|
||||
float var23 = var11;
|
||||
var11 = par4;
|
||||
par4 = var23;
|
||||
}
|
||||
|
||||
PositionTextureVertex var231 = new PositionTextureVertex(par4, par5, par6, 0.0F, 0.0F);
|
||||
PositionTextureVertex var15 = new PositionTextureVertex(var11, par5, par6, 0.0F, 8.0F);
|
||||
PositionTextureVertex var16 = new PositionTextureVertex(var11, var12, par6, 8.0F, 8.0F);
|
||||
PositionTextureVertex var17 = new PositionTextureVertex(par4, var12, par6, 8.0F, 0.0F);
|
||||
PositionTextureVertex var18 = new PositionTextureVertex(par4, par5, var13, 0.0F, 0.0F);
|
||||
PositionTextureVertex var19 = new PositionTextureVertex(var11, par5, var13, 0.0F, 8.0F);
|
||||
PositionTextureVertex var20 = new PositionTextureVertex(var11, var12, var13, 8.0F, 8.0F);
|
||||
PositionTextureVertex var21 = new PositionTextureVertex(par4, var12, var13, 8.0F, 0.0F);
|
||||
this.vertexPositions[0] = var231;
|
||||
this.vertexPositions[1] = var15;
|
||||
this.vertexPositions[2] = var16;
|
||||
this.vertexPositions[3] = var17;
|
||||
this.vertexPositions[4] = var18;
|
||||
this.vertexPositions[5] = var19;
|
||||
this.vertexPositions[6] = var20;
|
||||
this.vertexPositions[7] = var21;
|
||||
this.quadList[0] = new TexturedQuad(new PositionTextureVertex[]{var19, var15, var16, var20}, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
|
||||
this.quadList[1] = new TexturedQuad(new PositionTextureVertex[]{var231, var18, var21, var17}, par2, par3 + par9, par2 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
|
||||
this.quadList[2] = new TexturedQuad(new PositionTextureVertex[]{var19, var18, var231, var15}, par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
|
||||
this.quadList[3] = new TexturedQuad(new PositionTextureVertex[]{var16, var17, var21, var20}, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par7, par3, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
|
||||
this.quadList[4] = new TexturedQuad(new PositionTextureVertex[]{var15, var231, var17, var16}, par2 + par9, par3 + par9, par2 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
|
||||
this.quadList[5] = new TexturedQuad(new PositionTextureVertex[]{var18, var19, var20, var21}, par2 + par9 + par7 + par9, par3 + par9, par2 + par9 + par7 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
|
||||
if(par1ModelRenderer.mirror) {
|
||||
for (TexturedQuad element : this.quadList) {
|
||||
element.flipFace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void render(Tessellator par1Tessellator, float par2) {
|
||||
for (TexturedQuad element : this.quadList) {
|
||||
element.draw(par1Tessellator.getWorldRenderer(), par2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ScalableModelBox func_78244_a(String par1Str) {
|
||||
this.field_78247_g = par1Str;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,311 @@
|
|||
package com.minelittlepony.minelp.model.pony.armor;
|
||||
|
||||
import com.minelittlepony.minelp.model.pony.pm_newPonyAdv;
|
||||
import com.minelittlepony.minelp.renderer.AniParams;
|
||||
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class pm_newPonyArmor extends pm_newPonyAdv {
|
||||
public ModelRenderer Bodypiece;
|
||||
public ModelRenderer extBody;
|
||||
public ModelRenderer[] extHead;
|
||||
public ModelRenderer[] extLegs;
|
||||
|
||||
public pm_newPonyArmor(String texture) {
|
||||
super(texture);
|
||||
this.isArmour = true;
|
||||
this.textureHeight = 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate(AniParams aniparams) {
|
||||
this.checkRainboom(aniparams.swing);
|
||||
this.rotateHead(aniparams.horz, aniparams.vert);
|
||||
float bodySwingRotation = 0.0F;
|
||||
if (this.swingProgress > -9990.0F && !this.isUnicorn) {
|
||||
bodySwingRotation = MathHelper.sin(MathHelper.sqrt_float(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F;
|
||||
}
|
||||
|
||||
this.bipedBody.rotateAngleY = bodySwingRotation * 0.2F;
|
||||
this.Bodypiece.rotateAngleY = bodySwingRotation * 0.2F;
|
||||
this.extBody.rotateAngleY = bodySwingRotation * 0.2F;
|
||||
this.setLegs(aniparams.move, aniparams.swing, aniparams.tick);
|
||||
this.holdItem();
|
||||
this.swingItem(this.swingProgress);
|
||||
if (this.issneak && !this.isFlying) {
|
||||
this.adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK);
|
||||
this.sneakLegs();
|
||||
this.setHead(0.0F, 6.0F, -2.0F);
|
||||
} else {
|
||||
this.adjustBody(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK,
|
||||
BODY_RP_Z_NOTSNEAK);
|
||||
this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
|
||||
this.bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
|
||||
this.extLegs[0].rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
|
||||
this.extLegs[1].rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
|
||||
this.swingArms(aniparams.tick);
|
||||
this.setHead(0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (this.isSleeping) {
|
||||
this.ponySleep();
|
||||
}
|
||||
|
||||
if (this.aimedBow) {
|
||||
this.aimBow(aniparams.tick);
|
||||
}
|
||||
|
||||
this.fixSpecialRotationPoints(aniparams.move);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setHead(float posX, float posY, float posZ) {
|
||||
this.setRotationPoint(this.bipedHead, posX, posY, posZ);
|
||||
this.setRotationPoint(this.bipedHeadwear, posX, posY, posZ);
|
||||
this.setRotationPoint(this.extHead[0], posX, posY, posZ);
|
||||
this.setRotationPoint(this.extHead[1], posX, posY, posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rotateHead(float horz, float vert) {
|
||||
float headRotateAngleY;
|
||||
float headRotateAngleX;
|
||||
if (this.isSleeping) {
|
||||
headRotateAngleY = 1.4F;
|
||||
headRotateAngleX = 0.1F;
|
||||
} else {
|
||||
headRotateAngleY = horz / 57.29578F;
|
||||
headRotateAngleX = vert / 57.29578F;
|
||||
}
|
||||
|
||||
if (headRotateAngleX > 0.5F) {
|
||||
headRotateAngleX = 0.5F;
|
||||
}
|
||||
|
||||
if (headRotateAngleX < -0.5F) {
|
||||
headRotateAngleX = -0.5F;
|
||||
}
|
||||
|
||||
this.bipedHead.rotateAngleY = headRotateAngleY;
|
||||
this.bipedHead.rotateAngleX = headRotateAngleX;
|
||||
this.extHead[0].rotateAngleY = headRotateAngleY;
|
||||
this.extHead[0].rotateAngleX = headRotateAngleX;
|
||||
this.extHead[1].rotateAngleY = headRotateAngleY;
|
||||
this.extHead[1].rotateAngleX = headRotateAngleX;
|
||||
this.bipedHeadwear.rotateAngleY = headRotateAngleY;
|
||||
this.bipedHeadwear.rotateAngleX = headRotateAngleX;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adjustBody(float rotateAngleX, float rotationPointY, float rotationPointZ) {
|
||||
this.bipedBody.rotateAngleX = rotateAngleX;
|
||||
this.bipedBody.rotationPointY = rotationPointY;
|
||||
this.bipedBody.rotationPointZ = rotationPointZ;
|
||||
this.Bodypiece.rotateAngleX = rotateAngleX;
|
||||
this.Bodypiece.rotationPointY = rotationPointY;
|
||||
this.Bodypiece.rotationPointZ = rotationPointZ;
|
||||
this.extBody.rotateAngleX = rotateAngleX;
|
||||
this.extBody.rotationPointY = rotationPointY;
|
||||
this.extBody.rotationPointZ = rotationPointZ;
|
||||
}
|
||||
|
||||
protected void ridingPony() {
|
||||
this.setHead(this.bipedHead.rotationPointX + 0.0F, this.bipedHead.rotationPointY + RIDING_SHIFT_Y,
|
||||
this.bipedHead.rotationPointZ + RIDING_SHIFT_Z);
|
||||
this.shiftRotationPoint(this.bipedBody, 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z);
|
||||
this.shiftRotationPoint(this.Bodypiece, 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z);
|
||||
this.shiftRotationPoint(this.extBody, 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z);
|
||||
this.shiftRotationPoint(this.bipedLeftArm, 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z);
|
||||
this.shiftRotationPoint(this.bipedRightArm, 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z);
|
||||
this.shiftRotationPoint(this.bipedLeftLeg, 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z);
|
||||
this.shiftRotationPoint(this.bipedRightLeg, 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z);
|
||||
this.shiftRotationPoint(this.extLegs[0], 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z);
|
||||
this.shiftRotationPoint(this.extLegs[1], 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderHead() {
|
||||
this.bipedHead.render(this.scale);
|
||||
this.extHead[0].render(this.scale);
|
||||
this.extHead[1].render(this.scale);
|
||||
this.bipedHeadwear.render(this.scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderNeck() {}
|
||||
|
||||
@Override
|
||||
protected void renderBody() {
|
||||
this.bipedBody.render(this.scale);
|
||||
this.Bodypiece.render(this.scale);
|
||||
this.extBody.render(this.scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderTail() {}
|
||||
|
||||
@Override
|
||||
protected void renderLegs() {
|
||||
this.bipedLeftArm.render(this.scale);
|
||||
this.bipedRightArm.render(this.scale);
|
||||
this.bipedLeftLeg.render(this.scale);
|
||||
this.bipedRightLeg.render(this.scale);
|
||||
this.extLegs[0].render(this.scale);
|
||||
this.extLegs[1].render(this.scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initTextures() {
|
||||
this.extHead = new ModelRenderer[2];
|
||||
this.extLegs = new ModelRenderer[2];
|
||||
this.initHeadTextures();
|
||||
this.initBodyTextures();
|
||||
this.initLegTextures();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initHeadTextures() {
|
||||
this.bipedHead = new ModelRenderer(this, 0, 0);
|
||||
this.bipedHeadwear = new ModelRenderer(this, 32, 0);
|
||||
this.extHead[0] = new ModelRenderer(this, 0, 0);
|
||||
this.extHead[1] = new ModelRenderer(this, 0, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initBodyTextures() {
|
||||
this.bipedBody = new ModelRenderer(this, 16, 16);
|
||||
this.Bodypiece = new ModelRenderer(this, 0, 0);
|
||||
this.extBody = new ModelRenderer(this, 16, 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initLegTextures() {
|
||||
this.bipedRightArm = new ModelRenderer(this, 0, 16);
|
||||
this.bipedLeftArm = new ModelRenderer(this, 0, 16);
|
||||
this.bipedLeftArm.mirror = true;
|
||||
this.bipedRightLeg = new ModelRenderer(this, 0, 16);
|
||||
this.bipedLeftLeg = new ModelRenderer(this, 0, 16);
|
||||
this.bipedLeftLeg.mirror = true;
|
||||
this.SteveArm = new ModelRenderer(this, 0, 16);
|
||||
this.unicornarm = new ModelRenderer(this, 0, 16);
|
||||
this.extLegs[0] = new ModelRenderer(this, 48, 8);
|
||||
this.extLegs[1] = new ModelRenderer(this, 48, 8);
|
||||
this.extLegs[1].mirror = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initPositions(float yOffset, float stretch) {
|
||||
this.initHeadPositions(yOffset, stretch);
|
||||
this.initBodyPositions(yOffset, stretch);
|
||||
this.initLegPositions(yOffset, stretch);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initHeadPositions(float yOffset, float stretch) {
|
||||
this.bipedHead.addBox(-4.0F + HEAD_CENTRE_X, -4.0F + HEAD_CENTRE_Y,
|
||||
-4.0F + HEAD_CENTRE_Z, 8, 8, 8,
|
||||
stretch * 1.1F);
|
||||
this.bipedHead.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
|
||||
this.extHead[0].addBox(-4.0F + HEAD_CENTRE_X, -6.0F + HEAD_CENTRE_Y,
|
||||
1.0F + HEAD_CENTRE_Z, 2, 2,
|
||||
2, stretch * 0.5F);
|
||||
this.extHead[0].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset,
|
||||
HEAD_RP_Z);
|
||||
this.extHead[1].addBox(2.0F + HEAD_CENTRE_X, -6.0F + HEAD_CENTRE_Y,
|
||||
1.0F + HEAD_CENTRE_Z, 2, 2,
|
||||
2, stretch * 0.5F);
|
||||
this.extHead[1].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset,
|
||||
HEAD_RP_Z);
|
||||
this.bipedHeadwear.addBox(-4.0F + HEAD_CENTRE_X, -4.0F + HEAD_CENTRE_Y,
|
||||
-4.0F + HEAD_CENTRE_Z, 8, 8, 8,
|
||||
stretch * 1.1F + 0.5F);
|
||||
this.bipedHeadwear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset,
|
||||
HEAD_RP_Z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initBodyPositions(float yOffset, float stretch) {
|
||||
this.bipedBody.addBox(-4.0F, 4.0F, -2.0F, 8, 8, 4, stretch);
|
||||
this.bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
|
||||
this.Bodypiece.addBox(-4.0F, 4.0F, 6.0F, 8, 8, 8, stretch);
|
||||
this.Bodypiece.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset,
|
||||
HEAD_RP_Z);
|
||||
this.extBody.addBox(-4.0F, 4.0F, -2.0F, 8, 8, 16, stretch);
|
||||
this.extBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset,
|
||||
HEAD_RP_Z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initLegPositions(float yOffset, float stretch) {
|
||||
super.initLegPositions(yOffset, stretch);
|
||||
this.extLegs[0].addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y,
|
||||
-2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch);
|
||||
this.extLegs[0].setRotationPoint(-3.0F, 0.0F + yOffset, 0.0F);
|
||||
this.extLegs[1].addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y,
|
||||
-2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch);
|
||||
this.extLegs[1].setRotationPoint(3.0F, 0.0F + yOffset, 0.0F);
|
||||
}
|
||||
|
||||
protected void syncLegs() {
|
||||
this.extLegs[0].rotateAngleX = this.bipedRightLeg.rotateAngleX;
|
||||
this.extLegs[0].rotateAngleY = this.bipedRightLeg.rotateAngleY;
|
||||
this.extLegs[0].rotateAngleZ = this.bipedRightLeg.rotateAngleZ;
|
||||
this.extLegs[0].rotationPointX = this.bipedRightLeg.rotationPointX;
|
||||
this.extLegs[0].rotationPointY = this.bipedRightLeg.rotationPointY;
|
||||
this.extLegs[0].rotationPointZ = this.bipedRightLeg.rotationPointZ;
|
||||
this.extLegs[1].rotateAngleX = this.bipedLeftLeg.rotateAngleX;
|
||||
this.extLegs[1].rotateAngleY = this.bipedLeftLeg.rotateAngleY;
|
||||
this.extLegs[1].rotateAngleZ = this.bipedLeftLeg.rotateAngleZ;
|
||||
this.extLegs[1].rotationPointX = this.bipedLeftLeg.rotationPointX;
|
||||
this.extLegs[1].rotationPointY = this.bipedLeftLeg.rotationPointY;
|
||||
this.extLegs[1].rotationPointZ = this.bipedLeftLeg.rotationPointZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rotateLegs(float move, float swing, float tick) {
|
||||
super.rotateLegs(move, swing, tick);
|
||||
this.syncLegs();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adjustLegs() {
|
||||
super.adjustLegs();
|
||||
this.syncLegs();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sneakLegs() {
|
||||
super.sneakLegs();
|
||||
this.syncLegs();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void ponySleep() {
|
||||
super.ponySleep();
|
||||
this.syncLegs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderDrop(RenderManager rendermanager, ItemRenderer itemrenderer, EntityLivingBase entity) {
|
||||
this.renderDrop(itemrenderer, entity, this.bipedRightArm, 1.0F, -0.0625F, 0.8375F, 0.0625F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInvisible(boolean invisible) {
|
||||
super.setInvisible(invisible);
|
||||
this.bipedLeftArm.showModel = invisible;
|
||||
this.bipedRightArm.showModel = invisible;
|
||||
this.Bodypiece.showModel = invisible;
|
||||
extBody.showModel = invisible;
|
||||
for (ModelRenderer m : extHead) {
|
||||
m.showModel = invisible;
|
||||
}
|
||||
for (ModelRenderer m : extLegs) {
|
||||
m.showModel = invisible;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package com.minelittlepony.minelp.model.pony.armor;
|
||||
|
||||
import com.minelittlepony.minelp.model.pony.armor.pm_newPonyArmor;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class pm_skeletonPonyArmor extends pm_newPonyArmor {
|
||||
public pm_skeletonPonyArmor(String texture) {
|
||||
super(texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rotateLegs(float move, float swing, float tick) {
|
||||
float rightArmRotateAngleX;
|
||||
float leftArmRotateAngleX;
|
||||
float rightLegRotateAngleX;
|
||||
float leftLegRotateAngleX;
|
||||
float var8;
|
||||
float var9;
|
||||
if (this.isFlying && this.isPegasus) {
|
||||
if (this.rainboom) {
|
||||
rightArmRotateAngleX = ROTATE_270;
|
||||
leftArmRotateAngleX = ROTATE_270;
|
||||
rightLegRotateAngleX = ROTATE_90;
|
||||
leftLegRotateAngleX = ROTATE_90;
|
||||
} else {
|
||||
rightArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F);
|
||||
leftArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F);
|
||||
rightLegRotateAngleX = MathHelper.sin(swing * 0.5F);
|
||||
leftLegRotateAngleX = MathHelper.sin(swing * 0.5F);
|
||||
}
|
||||
|
||||
this.bipedRightArm.rotateAngleY = 0.2F;
|
||||
this.SteveArm.rotateAngleY = 0.2F;
|
||||
this.bipedLeftArm.rotateAngleY = -0.2F;
|
||||
this.bipedRightLeg.rotateAngleY = -0.2F;
|
||||
this.bipedLeftLeg.rotateAngleY = 0.2F;
|
||||
} else {
|
||||
var8 = (float) Math.pow(swing, 16.0D);
|
||||
this.getClass();
|
||||
var9 = 3.1415927F * var8 * 0.5F;
|
||||
this.getClass();
|
||||
float laQuad = 3.1415927F * var8;
|
||||
this.getClass();
|
||||
float rlQuad = 3.1415927F * var8 * 0.2F;
|
||||
this.getClass();
|
||||
float llQuad = 3.1415927F * var8 * -0.4F;
|
||||
rightArmRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + var9) * 0.6F * swing;
|
||||
leftArmRotateAngleX = MathHelper.cos(move * 0.6662F + laQuad) * 0.6F * swing;
|
||||
rightLegRotateAngleX = MathHelper.cos(move * 0.6662F + rlQuad) * 0.6F * swing;
|
||||
leftLegRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + llQuad) * 0.6F * swing;
|
||||
this.bipedRightArm.rotateAngleY = 0.0F;
|
||||
this.SteveArm.rotateAngleY = 0.0F;
|
||||
this.unicornarm.rotateAngleY = 0.0F;
|
||||
this.bipedLeftArm.rotateAngleY = 0.0F;
|
||||
this.bipedRightLeg.rotateAngleY = 0.0F;
|
||||
this.bipedLeftLeg.rotateAngleY = 0.0F;
|
||||
}
|
||||
|
||||
this.bipedRightArm.rotateAngleX = rightArmRotateAngleX;
|
||||
this.SteveArm.rotateAngleX = rightArmRotateAngleX;
|
||||
this.unicornarm.rotateAngleX = 0.0F;
|
||||
this.bipedLeftArm.rotateAngleX = leftArmRotateAngleX;
|
||||
this.bipedRightLeg.rotateAngleX = rightLegRotateAngleX;
|
||||
this.bipedLeftLeg.rotateAngleX = leftLegRotateAngleX;
|
||||
this.bipedRightArm.rotateAngleZ = 0.0F;
|
||||
this.SteveArm.rotateAngleZ = 0.0F;
|
||||
this.unicornarm.rotateAngleZ = 0.0F;
|
||||
this.bipedLeftArm.rotateAngleZ = 0.0F;
|
||||
if (this.heldItemRight != 0) {
|
||||
var8 = MathHelper.sin(this.swingProgress * 3.1415927F);
|
||||
var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * 3.1415927F);
|
||||
if (this.glowColor == 0) {
|
||||
this.bipedRightArm.rotateAngleZ = 0.0F;
|
||||
this.bipedRightArm.rotateAngleY = 0.1F - var8 * 0.6F;
|
||||
this.bipedRightArm.rotateAngleX = -1.5707964F;
|
||||
this.bipedRightArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F;
|
||||
this.bipedRightArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
|
||||
this.bipedRightArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F;
|
||||
} else {
|
||||
this.unicornarm.rotateAngleZ = 0.0F;
|
||||
this.unicornarm.rotateAngleY = 0.1F - var8 * 0.6F;
|
||||
this.unicornarm.rotateAngleX = -1.5707964F;
|
||||
this.unicornarm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F;
|
||||
this.unicornarm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
|
||||
this.unicornarm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F;
|
||||
}
|
||||
}
|
||||
|
||||
this.syncLegs();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fixSpecialRotationPoints(float move) {
|
||||
if (this.heldItemRight != 0 && this.glowColor == 0) {
|
||||
this.setRotationPoint(this.bipedRightArm, -1.5F, 9.5F, 4.0F);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package com.minelittlepony.minelp.model.pony.armor;
|
||||
|
||||
import com.minelittlepony.minelp.model.pony.armor.pm_newPonyArmor;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class pm_zombiePonyArmor extends pm_newPonyArmor {
|
||||
public pm_zombiePonyArmor(String texture) {
|
||||
super(texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rotateLegs(float move, float swing, float tick) {
|
||||
float rightArmRotateAngleX;
|
||||
float leftArmRotateAngleX;
|
||||
float rightLegRotateAngleX;
|
||||
float leftLegRotateAngleX;
|
||||
float var8;
|
||||
float var9;
|
||||
if (this.isFlying && this.isPegasus) {
|
||||
if (this.rainboom) {
|
||||
rightArmRotateAngleX = ROTATE_270;
|
||||
leftArmRotateAngleX = ROTATE_270;
|
||||
rightLegRotateAngleX = ROTATE_90;
|
||||
leftLegRotateAngleX = ROTATE_90;
|
||||
} else {
|
||||
rightArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F);
|
||||
leftArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F);
|
||||
rightLegRotateAngleX = MathHelper.sin(swing * 0.5F);
|
||||
leftLegRotateAngleX = MathHelper.sin(swing * 0.5F);
|
||||
}
|
||||
|
||||
this.bipedRightArm.rotateAngleY = 0.2F;
|
||||
this.SteveArm.rotateAngleY = 0.2F;
|
||||
this.bipedLeftArm.rotateAngleY = -0.2F;
|
||||
this.bipedRightLeg.rotateAngleY = -0.2F;
|
||||
this.bipedLeftLeg.rotateAngleY = 0.2F;
|
||||
} else {
|
||||
var8 = (float) Math.pow(swing, 16.0D);
|
||||
this.getClass();
|
||||
var9 = 3.1415927F * var8 * 0.5F;
|
||||
this.getClass();
|
||||
float laQuad = 3.1415927F * var8;
|
||||
this.getClass();
|
||||
float rlQuad = 3.1415927F * var8 * 0.2F;
|
||||
this.getClass();
|
||||
float llQuad = 3.1415927F * var8 * -0.4F;
|
||||
rightArmRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + var9) * 0.45F * swing;
|
||||
leftArmRotateAngleX = MathHelper.cos(move * 0.6662F + laQuad) * 0.45F * swing;
|
||||
rightLegRotateAngleX = MathHelper.cos(move * 0.6662F + rlQuad) * 0.45F * swing;
|
||||
leftLegRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + llQuad) * 0.45F * swing;
|
||||
this.bipedRightArm.rotateAngleY = 0.0F;
|
||||
this.SteveArm.rotateAngleY = 0.0F;
|
||||
this.unicornarm.rotateAngleY = 0.0F;
|
||||
this.bipedLeftArm.rotateAngleY = 0.0F;
|
||||
this.bipedRightLeg.rotateAngleY = 0.0F;
|
||||
this.bipedLeftLeg.rotateAngleY = 0.0F;
|
||||
}
|
||||
|
||||
this.bipedRightArm.rotateAngleX = rightArmRotateAngleX;
|
||||
this.SteveArm.rotateAngleX = rightArmRotateAngleX;
|
||||
this.unicornarm.rotateAngleX = 0.0F;
|
||||
this.bipedLeftArm.rotateAngleX = leftArmRotateAngleX;
|
||||
this.bipedRightLeg.rotateAngleX = rightLegRotateAngleX;
|
||||
this.bipedLeftLeg.rotateAngleX = leftLegRotateAngleX;
|
||||
this.bipedRightArm.rotateAngleZ = 0.0F;
|
||||
this.SteveArm.rotateAngleZ = 0.0F;
|
||||
this.unicornarm.rotateAngleZ = 0.0F;
|
||||
this.bipedLeftArm.rotateAngleZ = 0.0F;
|
||||
if (this.heldItemRight == 0) {
|
||||
var8 = MathHelper.sin(this.swingProgress * 3.1415927F);
|
||||
var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * 3.1415927F);
|
||||
if (MathHelper.sin(move / 20.0F) < 0.0F) {
|
||||
this.bipedRightArm.rotateAngleZ = 0.0F;
|
||||
this.bipedRightArm.rotateAngleY = 0.1F - var8 * 0.6F;
|
||||
this.bipedRightArm.rotateAngleX = -1.5707964F;
|
||||
this.bipedRightArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F;
|
||||
this.bipedRightArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
|
||||
this.bipedRightArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F;
|
||||
} else {
|
||||
this.bipedLeftArm.rotateAngleZ = 0.0F;
|
||||
this.bipedLeftArm.rotateAngleY = -(0.1F - var8 * 0.6F);
|
||||
this.bipedLeftArm.rotateAngleX = -1.5707964F;
|
||||
this.bipedLeftArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F;
|
||||
this.bipedLeftArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
|
||||
this.bipedLeftArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F;
|
||||
}
|
||||
}
|
||||
|
||||
this.syncLegs();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fixSpecialRotationPoints(float move) {
|
||||
if (this.heldItemRight == 0) {
|
||||
if (MathHelper.sin(move / 20.0F) < 0.0F) {
|
||||
this.shiftRotationPoint(this.bipedRightArm, 0.5F, 1.5F, 3.0F);
|
||||
} else {
|
||||
this.shiftRotationPoint(this.bipedLeftArm, -0.5F, 1.5F, 3.0F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.minelittlepony.minelp.model.pony.armor;
|
||||
|
||||
import com.minelittlepony.minelp.model.ModelArmor;
|
||||
import com.minelittlepony.minelp.model.pony.pm_Human;
|
||||
|
||||
public class pma_Human extends ModelArmor {
|
||||
|
||||
public pma_Human(String path) {
|
||||
super(path);
|
||||
this.modelArmorChestplate = new pm_Human(path);
|
||||
this.modelArmor = new pm_Human(path);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.minelittlepony.minelp.model.pony.armor;
|
||||
|
||||
import com.minelittlepony.minelp.model.ModelArmor;
|
||||
|
||||
public class pma_newPony extends ModelArmor {
|
||||
public pma_newPony(String path) {
|
||||
super(path);
|
||||
this.modelArmorChestplate = new pm_newPonyArmor(path);
|
||||
this.modelArmor = new pm_newPonyArmor(path);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.minelittlepony.minelp.model.pony.armor;
|
||||
|
||||
import com.minelittlepony.minelp.model.ModelArmor;
|
||||
|
||||
public class pma_skeletonPony extends ModelArmor {
|
||||
|
||||
public pma_skeletonPony(String path) {
|
||||
super(path);
|
||||
this.modelArmorChestplate = new pm_skeletonPonyArmor(path);
|
||||
this.modelArmor = new pm_skeletonPonyArmor(path);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.minelittlepony.minelp.model.pony.armor;
|
||||
|
||||
import com.minelittlepony.minelp.model.ModelArmor;
|
||||
|
||||
public class pma_zombiePony extends ModelArmor {
|
||||
|
||||
public pma_zombiePony(String path) {
|
||||
super(path);
|
||||
this.modelArmorChestplate = new pm_zombiePonyArmor(path);
|
||||
this.modelArmor = new pm_zombiePonyArmor(path);
|
||||
}
|
||||
}
|
152
src/main/java/com/minelittlepony/minelp/model/pony/pm_Human.java
Normal file
|
@ -0,0 +1,152 @@
|
|||
package com.minelittlepony.minelp.model.pony;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.minelittlepony.minelp.model.ModelPony;
|
||||
import com.minelittlepony.minelp.renderer.AniParams;
|
||||
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class pm_Human extends ModelPony {
|
||||
|
||||
public ModelRenderer bipedEars;
|
||||
public ModelRenderer cloak;
|
||||
|
||||
public pm_Human(String texture) {
|
||||
super(texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(float yoffset, float stretch) {
|
||||
this.cloak = new ModelRenderer(this, 0, 0);
|
||||
this.cloak.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch);
|
||||
this.bipedEars = new ModelRenderer(this, 24, 0);
|
||||
this.bipedEars.addBox(-3.0F, -6.0F, -1.0F, 6, 6, 1, stretch);
|
||||
this.bipedHead = new ModelRenderer(this, 0, 0);
|
||||
this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, stretch);
|
||||
this.bipedHead.setRotationPoint(0.0F, 0.0F + yoffset, 0.0F);
|
||||
this.bipedHeadwear = new ModelRenderer(this, 32, 0);
|
||||
this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, stretch + 0.5F);
|
||||
this.bipedHeadwear.setRotationPoint(0.0F, 0.0F + yoffset, 0.0F);
|
||||
this.bipedBody = new ModelRenderer(this, 16, 16);
|
||||
this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, stretch);
|
||||
this.bipedBody.setRotationPoint(0.0F, 0.0F + yoffset, 0.0F);
|
||||
this.bipedRightArm = new ModelRenderer(this, 40, 16);
|
||||
this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, stretch);
|
||||
this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + yoffset, 0.0F);
|
||||
this.bipedLeftArm = new ModelRenderer(this, 40, 16);
|
||||
this.bipedLeftArm.mirror = true;
|
||||
this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, stretch);
|
||||
this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + yoffset, 0.0F);
|
||||
this.bipedRightLeg = new ModelRenderer(this, 0, 16);
|
||||
this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, stretch);
|
||||
this.bipedRightLeg.setRotationPoint(-2.0F, 12.0F + yoffset, 0.0F);
|
||||
this.bipedLeftLeg = new ModelRenderer(this, 0, 16);
|
||||
this.bipedLeftLeg.mirror = true;
|
||||
this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, stretch);
|
||||
this.bipedLeftLeg.setRotationPoint(2.0F, 12.0F + yoffset, 0.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate(AniParams ani) {}
|
||||
|
||||
@Override
|
||||
public void render(AniParams ani) {}
|
||||
|
||||
@Override
|
||||
protected boolean doCancelRender() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void renderDrop(RenderManager rendermanager, ItemRenderer itemrenderer, EntityLivingBase entity) {
|
||||
this.renderDrop(itemrenderer, entity, this.bipedRightArm, 1.0F, -0.0625F, 0.4375F, 0.0625F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderEars(EntityLivingBase entity, float par2) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
float f1 = entity.renderYawOffset + (entity.prevRenderYawOffset - entity.renderYawOffset) * par2
|
||||
- (entity.prevRenderYawOffset + (entity.renderYawOffset - entity.prevRenderYawOffset) * par2);
|
||||
float f2 = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * par2;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(f1, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(f2, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glTranslatef(0.375F * (i * 2 - 1), 0.0F, 0.0F);
|
||||
GL11.glTranslatef(0.0F, -0.375F, 0.0F);
|
||||
GL11.glRotatef(-f2, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(-f1, 0.0F, 1.0F, 0.0F);
|
||||
float f7 = 1.333333F;
|
||||
GL11.glScalef(f7, f7, f7);
|
||||
this.bipedEars.rotateAngleY = this.bipedHead.rotateAngleY;
|
||||
this.bipedEars.rotateAngleX = this.bipedHead.rotateAngleX;
|
||||
this.bipedEars.rotationPointX = 0.0F;
|
||||
this.bipedEars.rotationPointY = 0.0F;
|
||||
this.bipedEars.render(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderCloak(EntityPlayer player, float par2) {
|
||||
this.renderCape(par2);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0F, 0.0F, 0.125F);
|
||||
double d = player.prevChasingPosX + (player.chasingPosX - player.prevChasingPosX) * par2
|
||||
- (player.prevPosX + (player.posX - player.prevPosX) * par2);
|
||||
double d1 = player.prevChasingPosY + (player.chasingPosY - player.prevChasingPosY) * par2
|
||||
- (player.prevPosY + (player.posY - player.prevPosY) * par2);
|
||||
double d2 = player.prevChasingPosZ + (player.chasingPosZ - player.prevChasingPosZ) * par2
|
||||
- (player.prevPosZ + (player.posZ - player.prevPosZ) * par2);
|
||||
float f10 = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * par2;
|
||||
double d3 = MathHelper.sin(f10 * 3.1415927F / 180.0F);
|
||||
double d4 = (-MathHelper.cos(f10 * 3.1415927F / 180.0F));
|
||||
float f12 = (float) d1 * 10.0F;
|
||||
if (f12 < -6.0F) {
|
||||
f12 = -6.0F;
|
||||
}
|
||||
|
||||
if (f12 > 32.0F) {
|
||||
f12 = 32.0F;
|
||||
}
|
||||
|
||||
float f13 = (float) (d * d3 + d2 * d4) * 100.0F;
|
||||
float f14 = (float) (d * d4 - d2 * d3) * 100.0F;
|
||||
if (f13 < 0.0F) {
|
||||
f13 = 0.0F;
|
||||
}
|
||||
|
||||
float f15 = player.prevCameraYaw + (player.cameraYaw - player.prevCameraYaw) * par2;
|
||||
f12 += MathHelper.sin((player.prevDistanceWalkedModified
|
||||
+ (player.distanceWalkedModified - player.prevDistanceWalkedModified) * par2) * 6.0F) * 32.0F * f15;
|
||||
if (player.isSneaking()) {
|
||||
f12 += 25.0F;
|
||||
}
|
||||
|
||||
GL11.glRotatef(6.0F + f13 / 2.0F + f12, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(f14 / 2.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(-f14 / 2.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
|
||||
this.cloak.render(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStaticCloak(EntityLiving player, float par2) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0F, 0.0F, 0.125F);
|
||||
GL11.glRotatef(3.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(2.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
|
||||
this.cloak.render(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
package com.minelittlepony.minelp.model.pony;
|
||||
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class pm_skeletonPony extends pm_newPonyAdv {
|
||||
|
||||
public pm_skeletonPony(String texture) {
|
||||
super(texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rotateLegs(float move, float swing, float tick) {
|
||||
float rightArmRotateAngleX;
|
||||
float leftArmRotateAngleX;
|
||||
float rightLegRotateAngleX;
|
||||
float leftLegRotateAngleX;
|
||||
float var8;
|
||||
float var9;
|
||||
if (this.isFlying && this.isPegasus) {
|
||||
if (this.rainboom) {
|
||||
rightArmRotateAngleX = ROTATE_270;
|
||||
leftArmRotateAngleX = ROTATE_270;
|
||||
rightLegRotateAngleX = ROTATE_90;
|
||||
leftLegRotateAngleX = ROTATE_90;
|
||||
} else {
|
||||
rightArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F);
|
||||
leftArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F);
|
||||
rightLegRotateAngleX = MathHelper.sin(swing * 0.5F);
|
||||
leftLegRotateAngleX = MathHelper.sin(swing * 0.5F);
|
||||
}
|
||||
|
||||
this.bipedRightArm.rotateAngleY = 0.2F;
|
||||
this.SteveArm.rotateAngleY = 0.2F;
|
||||
this.bipedLeftArm.rotateAngleY = -0.2F;
|
||||
this.bipedRightLeg.rotateAngleY = -0.2F;
|
||||
this.bipedLeftLeg.rotateAngleY = 0.2F;
|
||||
} else {
|
||||
var8 = (float) Math.pow(swing, 16.0D);
|
||||
this.getClass();
|
||||
var9 = 3.1415927F * var8 * 0.5F;
|
||||
this.getClass();
|
||||
float laQuad = 3.1415927F * var8;
|
||||
this.getClass();
|
||||
float rlQuad = 3.1415927F * var8 * 0.2F;
|
||||
this.getClass();
|
||||
float llQuad = 3.1415927F * var8 * -0.4F;
|
||||
rightArmRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + var9) * 0.6F * swing;
|
||||
leftArmRotateAngleX = MathHelper.cos(move * 0.6662F + laQuad) * 0.6F * swing;
|
||||
rightLegRotateAngleX = MathHelper.cos(move * 0.6662F + rlQuad) * 0.6F * swing;
|
||||
leftLegRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + llQuad) * 0.6F * swing;
|
||||
this.bipedRightArm.rotateAngleY = 0.0F;
|
||||
this.SteveArm.rotateAngleY = 0.0F;
|
||||
this.unicornarm.rotateAngleY = 0.0F;
|
||||
this.bipedLeftArm.rotateAngleY = 0.0F;
|
||||
this.bipedRightLeg.rotateAngleY = 0.0F;
|
||||
this.bipedLeftLeg.rotateAngleY = 0.0F;
|
||||
}
|
||||
|
||||
this.bipedRightArm.rotateAngleX = rightArmRotateAngleX;
|
||||
this.SteveArm.rotateAngleX = rightArmRotateAngleX;
|
||||
this.unicornarm.rotateAngleX = rightArmRotateAngleX;
|
||||
this.bipedLeftArm.rotateAngleX = leftArmRotateAngleX;
|
||||
this.bipedRightLeg.rotateAngleX = rightLegRotateAngleX;
|
||||
this.bipedLeftLeg.rotateAngleX = leftLegRotateAngleX;
|
||||
this.bipedRightArm.rotateAngleZ = 0.0F;
|
||||
this.SteveArm.rotateAngleZ = 0.0F;
|
||||
this.unicornarm.rotateAngleZ = 0.0F;
|
||||
this.bipedLeftArm.rotateAngleZ = 0.0F;
|
||||
if (this.heldItemRight != 0) {
|
||||
var8 = MathHelper.sin(this.swingProgress * 3.1415927F);
|
||||
var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * 3.1415927F);
|
||||
if (this.glowColor == 0) {
|
||||
this.bipedRightArm.rotateAngleZ = 0.0F;
|
||||
this.bipedRightArm.rotateAngleY = 0.1F - var8 * 0.6F;
|
||||
this.bipedRightArm.rotateAngleX = -1.5707964F;
|
||||
this.bipedRightArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F;
|
||||
this.bipedRightArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
|
||||
this.bipedRightArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F;
|
||||
} else {
|
||||
this.unicornarm.rotationPointX = -7.0F;
|
||||
this.unicornarm.rotationPointY = 12.0F;
|
||||
this.unicornarm.rotationPointZ = -2.0F;
|
||||
this.unicornarm.rotateAngleZ = 0.0F;
|
||||
this.unicornarm.rotateAngleY = 0.1F - var8 * 0.6F;
|
||||
this.unicornarm.rotateAngleX = -1.5707964F;
|
||||
this.unicornarm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F;
|
||||
this.unicornarm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
|
||||
this.unicornarm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fixSpecialRotationPoints(float move) {
|
||||
if (this.heldItemRight != 0 && this.glowColor == 0) {
|
||||
this.setRotationPoint(this.bipedRightArm, -1.5F, 9.5F, 4.0F);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLegs() {
|
||||
pushMatrix();
|
||||
translate(0.05F, -0.21F, -0.0F);
|
||||
scale(0.5F, 1.15F, 0.5F);
|
||||
this.bipedLeftArm.render(this.scale);
|
||||
popMatrix();
|
||||
|
||||
pushMatrix();
|
||||
if (this.heldItemRight != 0 && this.glowColor == 0) {
|
||||
translate(-0.1F, 0.3F, 0.1F);
|
||||
scale(0.5F, 0.5F, 1.2F);
|
||||
} else {
|
||||
translate(-0.05F, -0.21F, -0.0F);
|
||||
scale(0.5F, 1.2F, 0.5F);
|
||||
}
|
||||
|
||||
this.bipedRightArm.render(this.scale);
|
||||
popMatrix();
|
||||
|
||||
pushMatrix();
|
||||
translate(0.05F, -0.21F, 0.35F);
|
||||
scale(0.5F, 1.2F, 0.5F);
|
||||
this.bipedLeftLeg.render(this.scale);
|
||||
popMatrix();
|
||||
|
||||
pushMatrix();
|
||||
translate(-0.05F, -0.21F, 0.35F);
|
||||
scale(0.5F, 1.15F, 0.5F);
|
||||
this.bipedRightLeg.render(this.scale);
|
||||
popMatrix();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package com.minelittlepony.minelp.model.pony;
|
||||
|
||||
import com.minelittlepony.minelp.model.pony.pm_newPonyAdv;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class pm_zombiePony extends pm_newPonyAdv {
|
||||
|
||||
public pm_zombiePony(String texture) {
|
||||
super(texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rotateLegs(float move, float swing, float tick) {
|
||||
float rightArmRotateAngleX;
|
||||
float leftArmRotateAngleX;
|
||||
float rightLegRotateAngleX;
|
||||
float leftLegRotateAngleX;
|
||||
float var8;
|
||||
float var9;
|
||||
if (this.isFlying && this.isPegasus) {
|
||||
if (this.rainboom) {
|
||||
rightArmRotateAngleX = ROTATE_270;
|
||||
leftArmRotateAngleX = ROTATE_270;
|
||||
rightLegRotateAngleX = ROTATE_90;
|
||||
leftLegRotateAngleX = ROTATE_90;
|
||||
} else {
|
||||
rightArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F);
|
||||
leftArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F);
|
||||
rightLegRotateAngleX = MathHelper.sin(swing * 0.5F);
|
||||
leftLegRotateAngleX = MathHelper.sin(swing * 0.5F);
|
||||
}
|
||||
|
||||
this.bipedRightArm.rotateAngleY = 0.2F;
|
||||
this.SteveArm.rotateAngleY = 0.2F;
|
||||
this.bipedLeftArm.rotateAngleY = -0.2F;
|
||||
this.bipedRightLeg.rotateAngleY = -0.2F;
|
||||
this.bipedLeftLeg.rotateAngleY = 0.2F;
|
||||
} else {
|
||||
var8 = (float) Math.pow(swing, 16.0D);
|
||||
this.getClass();
|
||||
var9 = 3.1415927F * var8 * 0.5F;
|
||||
this.getClass();
|
||||
float laQuad = 3.1415927F * var8;
|
||||
this.getClass();
|
||||
float rlQuad = 3.1415927F * var8 * 0.2F;
|
||||
this.getClass();
|
||||
float llQuad = 3.1415927F * var8 * -0.4F;
|
||||
rightArmRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + var9) * 0.45F * swing;
|
||||
leftArmRotateAngleX = MathHelper.cos(move * 0.6662F + laQuad) * 0.45F * swing;
|
||||
rightLegRotateAngleX = MathHelper.cos(move * 0.6662F + rlQuad) * 0.45F * swing;
|
||||
leftLegRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + llQuad) * 0.45F * swing;
|
||||
this.bipedRightArm.rotateAngleY = 0.0F;
|
||||
this.SteveArm.rotateAngleY = 0.0F;
|
||||
this.unicornarm.rotateAngleY = 0.0F;
|
||||
this.bipedLeftArm.rotateAngleY = 0.0F;
|
||||
this.bipedRightLeg.rotateAngleY = 0.0F;
|
||||
this.bipedLeftLeg.rotateAngleY = 0.0F;
|
||||
}
|
||||
|
||||
this.bipedRightArm.rotateAngleX = rightArmRotateAngleX;
|
||||
this.SteveArm.rotateAngleX = rightArmRotateAngleX;
|
||||
this.unicornarm.rotateAngleX = 0.0F;
|
||||
this.bipedLeftArm.rotateAngleX = leftArmRotateAngleX;
|
||||
this.bipedRightLeg.rotateAngleX = rightLegRotateAngleX;
|
||||
this.bipedLeftLeg.rotateAngleX = leftLegRotateAngleX;
|
||||
this.bipedRightArm.rotateAngleZ = 0.0F;
|
||||
this.SteveArm.rotateAngleZ = 0.0F;
|
||||
this.unicornarm.rotateAngleZ = 0.0F;
|
||||
this.bipedLeftArm.rotateAngleZ = 0.0F;
|
||||
if (this.heldItemRight == 0) {
|
||||
var8 = MathHelper.sin(this.swingProgress * (float) Math.PI);
|
||||
var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float) Math.PI);
|
||||
if (MathHelper.sin(move / 20.0F) < 0.0F) {
|
||||
this.bipedRightArm.rotateAngleZ = 0.0F;
|
||||
this.bipedRightArm.rotateAngleY = 0.1F - var8 * 0.6F;
|
||||
this.bipedRightArm.rotateAngleX = -1.5707964F;
|
||||
this.bipedRightArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F;
|
||||
this.bipedRightArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
|
||||
this.bipedRightArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F;
|
||||
} else {
|
||||
this.bipedLeftArm.rotateAngleZ = 0.0F;
|
||||
this.bipedLeftArm.rotateAngleY = -(0.1F - var8 * 0.6F);
|
||||
this.bipedLeftArm.rotateAngleX = -1.5707964F;
|
||||
this.bipedLeftArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F;
|
||||
this.bipedLeftArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
|
||||
this.bipedLeftArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fixSpecialRotationPoints(float move) {
|
||||
if (this.heldItemRight == 0) {
|
||||
if (MathHelper.sin(move / 20.0F) < 0.0F) {
|
||||
this.shiftRotationPoint(this.bipedRightArm, 0.5F, 1.5F, 3.0F);
|
||||
} else {
|
||||
this.shiftRotationPoint(this.bipedLeftArm, -0.5F, 1.5F, 3.0F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.minelittlepony.minelp.renderer;
|
||||
|
||||
public class AniParams {
|
||||
|
||||
public float move;
|
||||
public float swing;
|
||||
public float tick;
|
||||
public float horz;
|
||||
public float vert;
|
||||
|
||||
public AniParams(float move, float swing, float tick, float horz, float vert) {
|
||||
this.move = move;
|
||||
this.swing = swing;
|
||||
this.tick = tick;
|
||||
this.horz = horz;
|
||||
this.vert = vert;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package com.minelittlepony.minelp.renderer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Random;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
public class CompressiveRendering {
|
||||
private boolean isCompressed;
|
||||
private int chance = 1;
|
||||
private Collection<CompressiveRendering> me;
|
||||
private ArrayList<ModelRenderer> expanded;
|
||||
private ArrayList<ModelRenderer> compressed;
|
||||
private ModelBase model;
|
||||
|
||||
public CompressiveRendering(ModelBase model) {
|
||||
this.model = model;
|
||||
this.expanded = new ArrayList<ModelRenderer>(1);
|
||||
this.compressed = new ArrayList<ModelRenderer>(1);
|
||||
model.boxList.remove(this.compressed);
|
||||
}
|
||||
|
||||
public void addExpanded(ModelRenderer expanded) {
|
||||
this.model.boxList.remove(expanded);
|
||||
this.expanded.add(expanded);
|
||||
}
|
||||
|
||||
public void addExpanded(ModelRenderer expanded, int weighted) {
|
||||
this.model.boxList.remove(expanded);
|
||||
this.expanded.addAll(Collections.nCopies(weighted, expanded));
|
||||
}
|
||||
|
||||
public void addCompressed(ModelRenderer compressed) {
|
||||
this.model.boxList.remove(compressed);
|
||||
this.compressed.add(compressed);
|
||||
}
|
||||
|
||||
public void addCompressed(ModelRenderer compressed, int weighted) {
|
||||
this.model.boxList.remove(compressed);
|
||||
this.compressed.addAll(Collections.nCopies(weighted, compressed));
|
||||
}
|
||||
|
||||
public void setChance(int chance) {
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
public int getChance() {
|
||||
return this.chance;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
this.me = Collections.nCopies(this.chance, this);
|
||||
this.model.boxList.addAll(this.me);
|
||||
}
|
||||
|
||||
public void deInit() {
|
||||
this.model.boxList.removeAll(this.me);
|
||||
this.me = null;
|
||||
}
|
||||
|
||||
public void init_Safe() {
|
||||
if (this.me == null) {
|
||||
this.init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void deInit_Safe() {
|
||||
if (this.me != null) {
|
||||
this.deInit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setIsCompressed(boolean isCompressed) {
|
||||
this.isCompressed = isCompressed;
|
||||
}
|
||||
|
||||
public boolean getIsCompressed() {
|
||||
return this.isCompressed;
|
||||
}
|
||||
|
||||
public ModelRenderer getARenderer(Random rand) {
|
||||
return this.isCompressed ? (ModelRenderer) this.compressed.get(rand.nextInt(this.compressed.size()))
|
||||
: (ModelRenderer) this.expanded.get(rand.nextInt(this.expanded.size()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,235 @@
|
|||
package com.minelittlepony.minelp.renderer;
|
||||
|
||||
import com.minelittlepony.minelp.model.ModelHornGlow;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.TextureOffset;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class HornGlowRenderer {
|
||||
public float textureWidth;
|
||||
public float textureHeight;
|
||||
private int textureOffsetX;
|
||||
private int textureOffsetY;
|
||||
public float rotationPointX;
|
||||
public float rotationPointY;
|
||||
public float rotationPointZ;
|
||||
public float rotateAngleX;
|
||||
public float rotateAngleY;
|
||||
public float rotateAngleZ;
|
||||
private boolean compiled;
|
||||
private int displayList;
|
||||
public boolean mirror;
|
||||
public boolean showModel;
|
||||
public boolean isHidden;
|
||||
public List<ModelHornGlow> cubeList;
|
||||
public List<HornGlowRenderer> childModels;
|
||||
public final String boxName;
|
||||
private ModelBase baseModel;
|
||||
|
||||
public HornGlowRenderer(ModelBase par1ModelBase, String par2Str) {
|
||||
this.textureWidth = 64.0F;
|
||||
this.textureHeight = 32.0F;
|
||||
this.compiled = false;
|
||||
this.displayList = 0;
|
||||
this.mirror = false;
|
||||
this.showModel = true;
|
||||
this.isHidden = false;
|
||||
this.cubeList = new ArrayList<ModelHornGlow>();
|
||||
this.baseModel = par1ModelBase;
|
||||
this.boxName = par2Str;
|
||||
this.setTextureSize(par1ModelBase.textureWidth, par1ModelBase.textureHeight);
|
||||
}
|
||||
|
||||
public HornGlowRenderer(ModelBase par1ModelBase) {
|
||||
this(par1ModelBase, (String) null);
|
||||
}
|
||||
|
||||
public HornGlowRenderer(ModelBase par1ModelBase, int par2, int par3) {
|
||||
this(par1ModelBase);
|
||||
this.setTextureOffset(par2, par3);
|
||||
}
|
||||
|
||||
public void addChild(HornGlowRenderer par1ModelRenderer) {
|
||||
if (this.childModels == null) {
|
||||
this.childModels = new ArrayList<HornGlowRenderer>();
|
||||
}
|
||||
|
||||
this.childModels.add(par1ModelRenderer);
|
||||
}
|
||||
|
||||
public HornGlowRenderer setTextureOffset(int par1, int par2) {
|
||||
this.textureOffsetX = par1;
|
||||
this.textureOffsetY = par2;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HornGlowRenderer addBox(String par1Str, float par2, float par3, float par4, int par5, int par6, int par7) {
|
||||
par1Str = this.boxName + "." + par1Str;
|
||||
TextureOffset var8 = this.baseModel.getTextureOffset(par1Str);
|
||||
this.setTextureOffset(var8.textureOffsetX, var8.textureOffsetY);
|
||||
this.cubeList.add((new ModelHornGlow(this, this.textureOffsetX, this.textureOffsetY, par2, par3, par4, par5,
|
||||
par6, par7, 0.0F)).func_78244_a(par1Str));
|
||||
return this;
|
||||
}
|
||||
|
||||
public HornGlowRenderer addBox(float par1, float par2, float par3, int par4, int par5, int par6) {
|
||||
this.cubeList.add(new ModelHornGlow(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4,
|
||||
par5, par6, 0.0F));
|
||||
return this;
|
||||
}
|
||||
|
||||
public void addBox(float par1, float par2, float par3, int par4, int par5, int par6, float par7) {
|
||||
this.cubeList.add(new ModelHornGlow(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4,
|
||||
par5, par6, par7));
|
||||
}
|
||||
|
||||
public void setRotationPoint(float par1, float par2, float par3) {
|
||||
this.rotationPointX = par1;
|
||||
this.rotationPointY = par2;
|
||||
this.rotationPointZ = par3;
|
||||
}
|
||||
|
||||
public void render(float par1) {
|
||||
if (!this.isHidden && this.showModel) {
|
||||
if (!this.compiled) {
|
||||
this.compileDisplayList(par1);
|
||||
}
|
||||
|
||||
Iterator<HornGlowRenderer> var2;
|
||||
HornGlowRenderer var3;
|
||||
if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) {
|
||||
if (this.rotationPointX == 0.0F && this.rotationPointY == 0.0F && this.rotationPointZ == 0.0F) {
|
||||
GL11.glCallList(this.displayList);
|
||||
if (this.childModels != null) {
|
||||
var2 = this.childModels.iterator();
|
||||
|
||||
while (var2.hasNext()) {
|
||||
var3 = var2.next();
|
||||
var3.render(par1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1,
|
||||
this.rotationPointZ * par1);
|
||||
GL11.glCallList(this.displayList);
|
||||
if (this.childModels != null) {
|
||||
var2 = this.childModels.iterator();
|
||||
|
||||
while (var2.hasNext()) {
|
||||
var3 = var2.next();
|
||||
var3.render(par1);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glTranslatef(-this.rotationPointX * par1, -this.rotationPointY * par1,
|
||||
-this.rotationPointZ * par1);
|
||||
}
|
||||
} else {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1);
|
||||
if (this.rotateAngleZ != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleZ * 57.295776F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleY != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleY * 57.295776F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleX != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleX * 57.295776F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
GL11.glCallList(this.displayList);
|
||||
if (this.childModels != null) {
|
||||
var2 = this.childModels.iterator();
|
||||
|
||||
while (var2.hasNext()) {
|
||||
var3 = var2.next();
|
||||
var3.render(par1);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void renderWithRotation(float par1) {
|
||||
if (!this.isHidden && this.showModel) {
|
||||
if (!this.compiled) {
|
||||
this.compileDisplayList(par1);
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1);
|
||||
if (this.rotateAngleY != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleY * 57.295776F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleX != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleX * 57.295776F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleZ != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleZ * 57.295776F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
GL11.glCallList(this.displayList);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void postRender(float par1) {
|
||||
if (!this.isHidden && this.showModel) {
|
||||
if (!this.compiled) {
|
||||
this.compileDisplayList(par1);
|
||||
}
|
||||
|
||||
if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) {
|
||||
if (this.rotationPointX != 0.0F || this.rotationPointY != 0.0F || this.rotationPointZ != 0.0F) {
|
||||
GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1,
|
||||
this.rotationPointZ * par1);
|
||||
}
|
||||
} else {
|
||||
GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1);
|
||||
if (this.rotateAngleZ != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleZ * 57.295776F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleY != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleY * 57.295776F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleX != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleX * 57.295776F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void compileDisplayList(float par1) {
|
||||
this.displayList = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(this.displayList, 4864);
|
||||
Tessellator var2 = Tessellator.getInstance();
|
||||
for (ModelHornGlow var4 : cubeList) {
|
||||
var4.render(var2, par1);
|
||||
}
|
||||
|
||||
GL11.glEndList();
|
||||
this.compiled = true;
|
||||
}
|
||||
|
||||
public HornGlowRenderer setTextureSize(int par1, int par2) {
|
||||
this.textureWidth = par1;
|
||||
this.textureHeight = par2;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.minelittlepony.minelp.renderer;
|
||||
|
||||
import com.minelittlepony.minelp.model.PlayerModel;
|
||||
|
||||
public interface IRenderPony {
|
||||
|
||||
PlayerModel getPony();
|
||||
}
|
|
@ -0,0 +1,444 @@
|
|||
package com.minelittlepony.minelp.renderer;
|
||||
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.model.PositionTextureVertex;
|
||||
import net.minecraft.client.model.TexturedQuad;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
|
||||
public class PlaneRenderer {
|
||||
public float textureWidth;
|
||||
public float textureHeight;
|
||||
private PositionTextureVertex[] corners;
|
||||
private TexturedQuad[] faces;
|
||||
private int textureOffsetX;
|
||||
private int textureOffsetY;
|
||||
public float rotationPointX;
|
||||
public float rotationPointY;
|
||||
public float rotationPointZ;
|
||||
public float rotateAngleX;
|
||||
public float rotateAngleY;
|
||||
public float rotateAngleZ;
|
||||
public float field_35977_i;
|
||||
public float field_35975_j;
|
||||
public float field_35976_k;
|
||||
public float field_35973_l;
|
||||
public float field_35974_m;
|
||||
public float field_35972_n;
|
||||
private boolean compiled = false;
|
||||
private int displayList = 0;
|
||||
public boolean mirror = false;
|
||||
public boolean mirrory = false;
|
||||
public boolean mirrorxy = false;
|
||||
public boolean showModel = true;
|
||||
public boolean isHidden = false;
|
||||
|
||||
public PlaneRenderer(ModelBase modelbase, int i, int j) {
|
||||
this.textureOffsetX = i;
|
||||
this.textureOffsetY = j;
|
||||
this.textureWidth = modelbase.textureWidth;
|
||||
this.textureHeight = modelbase.textureHeight;
|
||||
}
|
||||
|
||||
public void addBackPlane(float f, float f1, float f2, int i, int j, int k) {
|
||||
this.addBackPlane(f, f1, f2, i, j, k, 0.0F);
|
||||
}
|
||||
|
||||
public void addSidePlane(float f, float f1, float f2, int i, int j, int k) {
|
||||
this.addSidePlane(f, f1, f2, i, j, k, 0.0F);
|
||||
}
|
||||
|
||||
public void addTopPlane(float f, float f1, float f2, int i, int j, int k) {
|
||||
this.addTopPlane(f, f1, f2, i, j, k, 0.0F);
|
||||
}
|
||||
|
||||
public void addBottomPlane(float f, float f1, float f2, int i, int j, int k) {
|
||||
this.addBottomPlane(f, f1, f2, i, j, k, 0.0F);
|
||||
}
|
||||
|
||||
public void addBackPlane(float f, float f1, float f2, int i, int j, int k, float f3) {
|
||||
this.field_35977_i = f;
|
||||
this.field_35975_j = f1;
|
||||
this.field_35976_k = f2;
|
||||
this.field_35973_l = f + i;
|
||||
this.field_35974_m = f1 + j;
|
||||
this.field_35972_n = f2 + k;
|
||||
this.corners = new PositionTextureVertex[8];
|
||||
this.faces = new TexturedQuad[1];
|
||||
float f4 = f + i;
|
||||
float f5 = f1 + j;
|
||||
float f6 = f2 + k;
|
||||
f -= f3;
|
||||
f1 -= f3;
|
||||
f2 -= f3;
|
||||
f4 += f3;
|
||||
f5 += f3;
|
||||
f6 += f3;
|
||||
if (this.mirror) {
|
||||
float positiontexturevertex = f4;
|
||||
f4 = f;
|
||||
f = positiontexturevertex;
|
||||
}
|
||||
|
||||
PositionTextureVertex positiontexturevertex = new PositionTextureVertex(f, f1, f2, 0.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex1 = new PositionTextureVertex(f4, f1, f2, 0.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex2 = new PositionTextureVertex(f4, f5, f2, 8.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex3 = new PositionTextureVertex(f, f5, f2, 8.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex4 = new PositionTextureVertex(f, f1, f6, 0.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex5 = new PositionTextureVertex(f4, f1, f6, 0.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex6 = new PositionTextureVertex(f4, f5, f6, 8.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex7 = new PositionTextureVertex(f, f5, f6, 8.0F, 0.0F);
|
||||
this.corners[0] = positiontexturevertex;
|
||||
this.corners[1] = positiontexturevertex1;
|
||||
this.corners[2] = positiontexturevertex2;
|
||||
this.corners[3] = positiontexturevertex3;
|
||||
this.corners[4] = positiontexturevertex4;
|
||||
this.corners[5] = positiontexturevertex5;
|
||||
this.corners[6] = positiontexturevertex6;
|
||||
this.corners[7] = positiontexturevertex7;
|
||||
this.faces[0] = new TexturedQuad(
|
||||
new PositionTextureVertex[] {
|
||||
positiontexturevertex1,
|
||||
positiontexturevertex,
|
||||
positiontexturevertex3,
|
||||
positiontexturevertex2 },
|
||||
this.textureOffsetX, this.textureOffsetY,
|
||||
this.textureOffsetX + i, this.textureOffsetY + j,
|
||||
this.textureWidth, this.textureHeight);
|
||||
if (this.mirror) {
|
||||
this.faces[0].flipFace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addSidePlane(float f, float f1, float f2, int i, int j, int k, float f3) {
|
||||
this.field_35977_i = f;
|
||||
this.field_35975_j = f1;
|
||||
this.field_35976_k = f2;
|
||||
this.field_35973_l = f + i;
|
||||
this.field_35974_m = f1 + j;
|
||||
this.field_35972_n = f2 + k;
|
||||
this.corners = new PositionTextureVertex[8];
|
||||
this.faces = new TexturedQuad[1];
|
||||
float f4 = f + i;
|
||||
float f5 = f1 + j;
|
||||
float f6 = f2 + k;
|
||||
f -= f3;
|
||||
f1 -= f3;
|
||||
f2 -= f3;
|
||||
f4 += f3;
|
||||
f5 += f3;
|
||||
f6 += f3;
|
||||
if (this.mirror) {
|
||||
float positiontexturevertex = f4;
|
||||
f4 = f;
|
||||
f = positiontexturevertex;
|
||||
}
|
||||
|
||||
PositionTextureVertex positiontexturevertex = new PositionTextureVertex(f, f1, f2, 0.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex1 = new PositionTextureVertex(f4, f1, f2, 0.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex2 = new PositionTextureVertex(f4, f5, f2, 8.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex3 = new PositionTextureVertex(f, f5, f2, 8.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex4 = new PositionTextureVertex(f, f1, f6, 0.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex5 = new PositionTextureVertex(f4, f1, f6, 0.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex6 = new PositionTextureVertex(f4, f5, f6, 8.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex7 = new PositionTextureVertex(f, f5, f6, 8.0F, 0.0F);
|
||||
this.corners[0] = positiontexturevertex;
|
||||
this.corners[1] = positiontexturevertex1;
|
||||
this.corners[2] = positiontexturevertex2;
|
||||
this.corners[3] = positiontexturevertex3;
|
||||
this.corners[4] = positiontexturevertex4;
|
||||
this.corners[5] = positiontexturevertex5;
|
||||
this.corners[6] = positiontexturevertex6;
|
||||
this.corners[7] = positiontexturevertex7;
|
||||
this.faces[0] = new TexturedQuad(
|
||||
new PositionTextureVertex[] {
|
||||
positiontexturevertex5,
|
||||
positiontexturevertex1,
|
||||
positiontexturevertex2,
|
||||
positiontexturevertex6 },
|
||||
this.textureOffsetX, this.textureOffsetY,
|
||||
this.textureOffsetX + k, this.textureOffsetY + j,
|
||||
this.textureWidth, this.textureHeight);
|
||||
if (this.mirror) {
|
||||
this.faces[0].flipFace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addTopPlane(float f, float f1, float f2, int i, int j, int k, float f3) {
|
||||
this.field_35977_i = f;
|
||||
this.field_35975_j = f1;
|
||||
this.field_35976_k = f2;
|
||||
this.field_35973_l = f + i;
|
||||
this.field_35974_m = f1 + j;
|
||||
this.field_35972_n = f2 + k;
|
||||
this.corners = new PositionTextureVertex[8];
|
||||
this.faces = new TexturedQuad[1];
|
||||
float f4 = f + i;
|
||||
float f5 = f1 + j;
|
||||
float f6 = f2 + k;
|
||||
f -= f3;
|
||||
f1 -= f3;
|
||||
f2 -= f3;
|
||||
f4 += f3;
|
||||
f5 += f3;
|
||||
f6 += f3;
|
||||
float vertex;
|
||||
if (this.mirror) {
|
||||
vertex = f4;
|
||||
f4 = f;
|
||||
f = vertex;
|
||||
}
|
||||
|
||||
if (this.mirrory) {
|
||||
vertex = f6;
|
||||
f6 = f2;
|
||||
f2 = vertex;
|
||||
}
|
||||
|
||||
if (this.mirrorxy) {
|
||||
vertex = f6;
|
||||
f6 = f2;
|
||||
f2 = vertex;
|
||||
vertex = f4;
|
||||
f4 = f;
|
||||
f = vertex;
|
||||
}
|
||||
|
||||
PositionTextureVertex positiontexturevertex = new PositionTextureVertex(f, f1, f2, 0.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex1 = new PositionTextureVertex(f4, f1, f2, 0.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex2 = new PositionTextureVertex(f4, f5, f2, 8.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex3 = new PositionTextureVertex(f, f5, f2, 8.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex4 = new PositionTextureVertex(f, f1, f6, 0.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex5 = new PositionTextureVertex(f4, f1, f6, 0.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex6 = new PositionTextureVertex(f4, f5, f6, 8.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex7 = new PositionTextureVertex(f, f5, f6, 8.0F, 0.0F);
|
||||
this.corners[0] = positiontexturevertex;
|
||||
this.corners[1] = positiontexturevertex1;
|
||||
this.corners[2] = positiontexturevertex2;
|
||||
this.corners[3] = positiontexturevertex3;
|
||||
this.corners[4] = positiontexturevertex4;
|
||||
this.corners[5] = positiontexturevertex5;
|
||||
this.corners[6] = positiontexturevertex6;
|
||||
this.corners[7] = positiontexturevertex7;
|
||||
this.faces[0] = new TexturedQuad(
|
||||
new PositionTextureVertex[] {
|
||||
positiontexturevertex5,
|
||||
positiontexturevertex4,
|
||||
positiontexturevertex,
|
||||
positiontexturevertex1 },
|
||||
this.textureOffsetX, this.textureOffsetY,
|
||||
this.textureOffsetX + i, this.textureOffsetY + k,
|
||||
this.textureWidth, this.textureHeight);
|
||||
if (this.mirror || this.mirrory) {
|
||||
this.faces[0].flipFace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addBottomPlane(float f, float f1, float f2, int i, int j, int k, float f3) {
|
||||
this.field_35977_i = f;
|
||||
this.field_35975_j = f1;
|
||||
this.field_35976_k = f2;
|
||||
this.field_35973_l = f + i;
|
||||
this.field_35974_m = f1 + j;
|
||||
this.field_35972_n = f2 + k;
|
||||
this.corners = new PositionTextureVertex[8];
|
||||
this.faces = new TexturedQuad[1];
|
||||
float f4 = f + i;
|
||||
float f5 = f1 + j;
|
||||
float f6 = f2 + k;
|
||||
f -= f3;
|
||||
f1 -= f3;
|
||||
f2 -= f3;
|
||||
f4 += f3;
|
||||
f5 += f3;
|
||||
f6 += f3;
|
||||
float vertex;
|
||||
if (this.mirror) {
|
||||
vertex = f4;
|
||||
f4 = f;
|
||||
f = vertex;
|
||||
}
|
||||
|
||||
if (this.mirrory) {
|
||||
vertex = f6;
|
||||
f6 = f2;
|
||||
f2 = vertex;
|
||||
}
|
||||
|
||||
if (this.mirrorxy) {
|
||||
vertex = f6;
|
||||
f6 = f2;
|
||||
f2 = vertex;
|
||||
vertex = f4;
|
||||
f4 = f;
|
||||
f = vertex;
|
||||
}
|
||||
|
||||
PositionTextureVertex positiontexturevertex = new PositionTextureVertex(f, f1, f2, 0.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex1 = new PositionTextureVertex(f4, f1, f2, 0.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex2 = new PositionTextureVertex(f4, f5, f2, 8.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex3 = new PositionTextureVertex(f, f5, f2, 8.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex4 = new PositionTextureVertex(f, f1, f6, 0.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex5 = new PositionTextureVertex(f4, f1, f6, 0.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex6 = new PositionTextureVertex(f4, f5, f6, 8.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex7 = new PositionTextureVertex(f, f5, f6, 8.0F, 0.0F);
|
||||
this.corners[0] = positiontexturevertex;
|
||||
this.corners[1] = positiontexturevertex1;
|
||||
this.corners[2] = positiontexturevertex2;
|
||||
this.corners[3] = positiontexturevertex3;
|
||||
this.corners[4] = positiontexturevertex4;
|
||||
this.corners[5] = positiontexturevertex5;
|
||||
this.corners[6] = positiontexturevertex6;
|
||||
this.corners[7] = positiontexturevertex7;
|
||||
this.faces[0] = new TexturedQuad(
|
||||
new PositionTextureVertex[] {
|
||||
positiontexturevertex2,
|
||||
positiontexturevertex3,
|
||||
positiontexturevertex7,
|
||||
positiontexturevertex6 },
|
||||
this.textureOffsetX, this.textureOffsetY,
|
||||
this.textureOffsetX + i, this.textureOffsetY + k,
|
||||
this.textureWidth, this.textureHeight);
|
||||
if (this.mirror || this.mirrory) {
|
||||
this.faces[0].flipFace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setRotationPoint(float f, float f1, float f2) {
|
||||
this.rotationPointX = f;
|
||||
this.rotationPointY = f1;
|
||||
this.rotationPointZ = f2;
|
||||
}
|
||||
|
||||
public void render(float f) {
|
||||
if (!this.isHidden) {
|
||||
if (this.showModel) {
|
||||
if (!this.compiled) {
|
||||
this.compileDisplayList(f);
|
||||
}
|
||||
|
||||
if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) {
|
||||
if (this.rotationPointX == 0.0F && this.rotationPointY == 0.0F && this.rotationPointZ == 0.0F) {
|
||||
callList(this.displayList);
|
||||
} else {
|
||||
translate(this.rotationPointX * f, this.rotationPointY * f, this.rotationPointZ * f);
|
||||
callList(this.displayList);
|
||||
translate(-this.rotationPointX * f, -this.rotationPointY * f, -this.rotationPointZ * f);
|
||||
}
|
||||
} else {
|
||||
pushMatrix();
|
||||
translate(this.rotationPointX * f, this.rotationPointY * f, this.rotationPointZ * f);
|
||||
if (this.rotateAngleZ != 0.0F) {
|
||||
rotate(this.rotateAngleZ * 57.29578F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleY != 0.0F) {
|
||||
rotate(this.rotateAngleY * 57.29578F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleX != 0.0F) {
|
||||
rotate(this.rotateAngleX * 57.29578F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
callList(this.displayList);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void renderWithRotation(float f) {
|
||||
if (!this.isHidden) {
|
||||
if (this.showModel) {
|
||||
if (!this.compiled) {
|
||||
this.compileDisplayList(f);
|
||||
}
|
||||
|
||||
pushMatrix();
|
||||
translate(this.rotationPointX * f, this.rotationPointY * f, this.rotationPointZ * f);
|
||||
if (this.rotateAngleY != 0.0F) {
|
||||
rotate(this.rotateAngleY * 57.29578F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleX != 0.0F) {
|
||||
rotate(this.rotateAngleX * 57.29578F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleZ != 0.0F) {
|
||||
rotate(this.rotateAngleZ * 57.29578F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
callList(this.displayList);
|
||||
popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void postRender(float f) {
|
||||
if (!this.isHidden) {
|
||||
if (this.showModel) {
|
||||
if (!this.compiled) {
|
||||
this.compileDisplayList(f);
|
||||
}
|
||||
|
||||
if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) {
|
||||
if (this.rotationPointX != 0.0F || this.rotationPointY != 0.0F || this.rotationPointZ != 0.0F) {
|
||||
translate(this.rotationPointX * f, this.rotationPointY * f, this.rotationPointZ * f);
|
||||
}
|
||||
} else {
|
||||
translate(this.rotationPointX * f, this.rotationPointY * f, this.rotationPointZ * f);
|
||||
if (this.rotateAngleZ != 0.0F) {
|
||||
rotate(this.rotateAngleZ * 57.29578F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleY != 0.0F) {
|
||||
rotate(this.rotateAngleY * 57.29578F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleX != 0.0F) {
|
||||
rotate(this.rotateAngleX * 57.29578F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void compileDisplayList(float f) {
|
||||
this.displayList = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(this.displayList, 4864);
|
||||
WorldRenderer wr = Tessellator.getInstance().getWorldRenderer();
|
||||
|
||||
for (TexturedQuad face : this.faces) {
|
||||
face.draw(wr, f);
|
||||
}
|
||||
|
||||
GL11.glEndList();
|
||||
this.compiled = true;
|
||||
}
|
||||
|
||||
public PlaneRenderer setTextureSize(int i, int j) {
|
||||
this.textureWidth = i;
|
||||
this.textureHeight = j;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setToModel(ModelRenderer modelrenderer) {
|
||||
this.rotationPointX = modelrenderer.rotationPointX;
|
||||
this.rotationPointY = modelrenderer.rotationPointY;
|
||||
this.rotationPointZ = modelrenderer.rotationPointZ;
|
||||
this.rotateAngleX = modelrenderer.rotateAngleX;
|
||||
this.rotateAngleY = modelrenderer.rotateAngleY;
|
||||
this.rotateAngleZ = modelrenderer.rotateAngleZ;
|
||||
}
|
||||
}
|
150
src/main/java/com/minelittlepony/minelp/renderer/RenderPony.java
Normal file
|
@ -0,0 +1,150 @@
|
|||
package com.minelittlepony.minelp.renderer;
|
||||
|
||||
import static net.minecraft.client.renderer.GlStateManager.scale;
|
||||
|
||||
import com.minelittlepony.minelp.Pony;
|
||||
import com.minelittlepony.minelp.PonyManager;
|
||||
import com.minelittlepony.minelp.model.PMAPI;
|
||||
import com.minelittlepony.minelp.model.PlayerModel;
|
||||
import com.minelittlepony.minelp.model.pony.pm_Human;
|
||||
import com.minelittlepony.minelp.model.pony.pm_newPonyAdv;
|
||||
import com.minelittlepony.minelp.renderer.layer.LayerHeldPonyItem;
|
||||
import com.minelittlepony.minelp.renderer.layer.LayerPonyArmor;
|
||||
import com.minelittlepony.minelp.renderer.layer.LayerPonySkull;
|
||||
import com.minelittlepony.minelp.util.MineLPPrivateFields;
|
||||
import com.mumfrey.liteloader.transformers.AppendInsns;
|
||||
import com.mumfrey.liteloader.transformers.Obfuscated;
|
||||
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerArrow;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public abstract class RenderPony extends RendererLivingEntity implements IRenderPony {
|
||||
@SuppressWarnings("unused")
|
||||
private static RenderPlayer __TARGET;
|
||||
private PlayerModel playerModel;
|
||||
|
||||
private RenderPony(RenderManager renderManager) {
|
||||
super(renderManager, null, 0.5F);
|
||||
throw new InstantiationError("Overlay classes must not be instantiated");
|
||||
}
|
||||
|
||||
@AppendInsns("<init>")
|
||||
private void init(RenderManager renderManager, boolean useSmallArms) {
|
||||
this.playerModel = PMAPI.newPonyAdv;
|
||||
this.mainModel = this.playerModel.model;
|
||||
this.shadowSize = this.playerModel.shadowsize;
|
||||
this.layerRenderers.clear();
|
||||
|
||||
this.addLayer(new LayerPonyArmor(this));
|
||||
this.addLayer(new LayerHeldPonyItem(this));
|
||||
this.addLayer(new LayerArrow(this));
|
||||
this.addLayer(new LayerPonySkull(this));
|
||||
}
|
||||
|
||||
@Obfuscated({ "a", "func_180596_a" })
|
||||
public void doRender(AbstractClientPlayer player, double x, double y, double z, float yaw, float partialTicks) {
|
||||
ItemStack currentItemStack = player.inventory.getCurrentItem();
|
||||
Pony thePony = PonyManager.getInstance().getPonyFromResourceRegistry(player);
|
||||
this.playerModel = this.getModel(player);
|
||||
this.mainModel = this.playerModel.model;
|
||||
this.playerModel.armor.modelArmorChestplate.heldItemRight = this.playerModel.armor.modelArmor.heldItemRight = this.playerModel.model.heldItemRight = currentItemStack == null
|
||||
? 0 : 1;
|
||||
if (currentItemStack != null && player.getItemInUseCount() > 0) {
|
||||
EnumAction yOrigin = currentItemStack.getItemUseAction();
|
||||
if (yOrigin == EnumAction.BLOCK) {
|
||||
this.playerModel.armor.modelArmorChestplate.heldItemRight = this.playerModel.armor.modelArmor.heldItemRight = this.playerModel.model.heldItemRight = 3;
|
||||
} else if (yOrigin == EnumAction.BOW) {
|
||||
this.playerModel.armor.modelArmorChestplate.aimedBow = this.playerModel.armor.modelArmor.aimedBow = this.playerModel.model.aimedBow = true;
|
||||
}
|
||||
}
|
||||
|
||||
this.playerModel.armor.modelArmorChestplate.issneak = this.playerModel.armor.modelArmor.issneak = this.playerModel.model.issneak = player.isSneaking();
|
||||
this.playerModel.armor.modelArmorChestplate.isFlying = this.playerModel.armor.modelArmor.isFlying = this.playerModel.model.isFlying = thePony.isFlying = player.capabilities.isFlying
|
||||
|| thePony.isPegasusFlying(player.posX, player.posY, player.posZ, player.fallDistance,
|
||||
MineLPPrivateFields.isJumping.get(player).booleanValue(), player.onGround, this.renderManager.worldObj);
|
||||
this.playerModel.armor.modelArmorChestplate.isPegasus = this.playerModel.armor.modelArmor.isPegasus = this.playerModel.model.isPegasus = thePony
|
||||
.isPegasus();
|
||||
if (this.playerModel.model instanceof pm_newPonyAdv) {
|
||||
((pm_newPonyAdv) this.playerModel.model).setHasWings_Compression(thePony.isPegasus());
|
||||
}
|
||||
|
||||
this.playerModel.armor.modelArmorChestplate.isUnicorn = this.playerModel.armor.modelArmor.isUnicorn = this.playerModel.model.isUnicorn = thePony.isUnicorn();
|
||||
this.playerModel.armor.modelArmorChestplate.isMale = this.playerModel.armor.modelArmor.isMale = this.playerModel.model.isMale = thePony.isMale();
|
||||
this.playerModel.armor.modelArmorChestplate.size = this.playerModel.armor.modelArmor.size = this.playerModel.model.size = thePony.size();
|
||||
if (PonyManager.getInstance().getShowScale() == 1) {
|
||||
if (this.playerModel != PMAPI.human) {
|
||||
if (thePony.size() == 0) {
|
||||
this.shadowSize = 0.25F;
|
||||
} else if (thePony.size() == 1) {
|
||||
this.shadowSize = 0.4F;
|
||||
} else if (thePony.size() == 2) {
|
||||
this.shadowSize = 0.45F;
|
||||
} else if (thePony.size() == 3) {
|
||||
this.shadowSize = 0.5F;
|
||||
} else {
|
||||
this.shadowSize = 0.5F;
|
||||
}
|
||||
} else {
|
||||
this.shadowSize = 0.5F;
|
||||
}
|
||||
} else {
|
||||
this.shadowSize = 0.5F;
|
||||
}
|
||||
|
||||
double yOrigin1 = y;
|
||||
if (player.isSneaking() && !(player instanceof EntityPlayerSP)) {
|
||||
yOrigin1 -= 0.125D;
|
||||
}
|
||||
|
||||
this.playerModel.model.glowColor = thePony.glowColor();
|
||||
this.playerModel.armor.modelArmorChestplate.isSleeping = this.playerModel.armor.modelArmor.isSleeping = this.playerModel.model.isSleeping = player.isPlayerSleeping();
|
||||
this.playerModel.armor.modelArmorChestplate.swingProgress = this.playerModel.armor.modelArmor.swingProgress = this.playerModel.model.swingProgress;
|
||||
this.playerModel.model.wantTail = thePony.wantTail();
|
||||
this.playerModel.armor.modelArmorChestplate.isVillager = this.playerModel.armor.modelArmor.isVillager = this.playerModel.model.isVillager = false;
|
||||
super.doRender(player, x, yOrigin1, z, yaw, partialTicks);
|
||||
this.playerModel.armor.modelArmorChestplate.aimedBow = this.playerModel.armor.modelArmor.aimedBow = this.playerModel.model.aimedBow = false;
|
||||
this.playerModel.armor.modelArmorChestplate.issneak = this.playerModel.armor.modelArmor.issneak = this.playerModel.model.issneak = false;
|
||||
this.playerModel.armor.modelArmorChestplate.heldItemRight = this.playerModel.armor.modelArmor.heldItemRight = this.playerModel.model.heldItemRight = 0;
|
||||
}
|
||||
|
||||
@AppendInsns("renderLivingAt")
|
||||
@Obfuscated({ "a", "func_77039_a" })
|
||||
public void setupPlayerScale(AbstractClientPlayer player, double xPosition, double yPosition, double zPosition) {
|
||||
|
||||
if (PonyManager.getInstance().getShowScale() == 1 && !(playerModel.model instanceof pm_Human)) {
|
||||
if (this.playerModel.model.size == 2) {
|
||||
scale(0.9F, 0.9F, 0.9F);
|
||||
} else if (this.playerModel.model.size == 1 || this.playerModel.model.size == 0) {
|
||||
scale(0.8F, 0.8F, 0.8F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceLocation getEntityTexture(AbstractClientPlayer player) {
|
||||
Pony thePony = PonyManager.getInstance().getPonyFromResourceRegistry(player);
|
||||
return thePony.getTextureResourceLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(Entity entity) {
|
||||
return this.getEntityTexture((AbstractClientPlayer) entity);
|
||||
}
|
||||
|
||||
protected PlayerModel getModel(AbstractClientPlayer player) {
|
||||
Pony thePony = PonyManager.getInstance().getPonyFromResourceRegistry(player);
|
||||
return thePony.getModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerModel getPony() {
|
||||
return this.playerModel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
package com.minelittlepony.minelp.renderer;
|
||||
|
||||
import com.minelittlepony.minelp.PonyManager;
|
||||
import com.minelittlepony.minelp.model.ModelPony;
|
||||
import com.minelittlepony.minelp.model.PlayerModel;
|
||||
import com.minelittlepony.minelp.model.pony.pm_newPonyAdv;
|
||||
import com.minelittlepony.minelp.renderer.layer.LayerHeldPonyItem;
|
||||
import com.minelittlepony.minelp.renderer.layer.LayerPonyArmor;
|
||||
import com.minelittlepony.minelp.renderer.layer.LayerPonySkull;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.monster.EntityPigZombie;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving implements IRenderPony {
|
||||
protected ModelPony mobModel;
|
||||
protected PlayerModel playerModel;
|
||||
|
||||
public RenderPonyMob(RenderManager renderManager, PlayerModel playerModel) {
|
||||
super(renderManager, playerModel.model, playerModel.shadowsize);
|
||||
this.mobModel = playerModel.model;
|
||||
this.playerModel = playerModel;
|
||||
|
||||
this.addLayer(new LayerPonyArmor(this));
|
||||
this.addLayer(new LayerHeldPonyItem(this));
|
||||
// this.addLayer(new LayerArrow(this));
|
||||
this.addLayer(new LayerPonySkull(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRender(EntityLiving entity, double xPosition, double yPosition, double zPosition, float yaw,
|
||||
float partialTicks) {
|
||||
ItemStack heldItem = entity.getHeldItem();
|
||||
this.playerModel.armor.modelArmorChestplate.heldItemRight = this.playerModel.armor.modelArmor.heldItemRight = this.playerModel.model.heldItemRight = heldItem == null
|
||||
? 0 : 1;
|
||||
if (entity.isChild()) {
|
||||
this.playerModel.armor.modelArmorChestplate.size = this.playerModel.armor.modelArmor.size = this.playerModel.model.size = 0;
|
||||
} else {
|
||||
this.playerModel.armor.modelArmorChestplate.size = this.playerModel.armor.modelArmor.size = this.playerModel.model.size = 1;
|
||||
}
|
||||
|
||||
this.playerModel.armor.modelArmorChestplate.issneak = this.playerModel.armor.modelArmor.issneak = this.playerModel.model.issneak = false;
|
||||
this.playerModel.armor.modelArmorChestplate.isFlying = this.playerModel.armor.modelArmor.isFlying = this.playerModel.model.isFlying = false;
|
||||
this.playerModel.armor.modelArmorChestplate.isPegasus = this.playerModel.armor.modelArmor.isPegasus = this.playerModel.model.isPegasus = false;
|
||||
if (this.playerModel.model instanceof pm_newPonyAdv) {
|
||||
((pm_newPonyAdv) this.playerModel.model).setHasWings_Compression(false);
|
||||
}
|
||||
|
||||
if (entity instanceof EntitySkeleton) {
|
||||
this.playerModel.armor.modelArmorChestplate.glowColor = this.playerModel.armor.modelArmor.glowColor = this.playerModel.model.glowColor = 0;
|
||||
switch (entity.getEntityId() % 3) {
|
||||
case 0:
|
||||
this.playerModel.armor.modelArmorChestplate.glowColor = this.playerModel.armor.modelArmor.glowColor = this.playerModel.model.glowColor = -10066211;
|
||||
case 1:
|
||||
this.playerModel.armor.modelArmorChestplate.isUnicorn = this.playerModel.armor.modelArmor.isUnicorn = this.playerModel.model.isUnicorn = true;
|
||||
break;
|
||||
case 2:
|
||||
this.playerModel.armor.modelArmorChestplate.isUnicorn = this.playerModel.armor.modelArmor.isUnicorn = this.playerModel.model.isUnicorn = false;
|
||||
}
|
||||
} else {
|
||||
this.playerModel.armor.modelArmorChestplate.isUnicorn = this.playerModel.armor.modelArmor.isUnicorn = this.playerModel.model.isUnicorn = false;
|
||||
}
|
||||
|
||||
if (entity instanceof EntityPigZombie) {
|
||||
this.playerModel.armor.modelArmorChestplate.isMale = this.playerModel.armor.modelArmor.isMale = this.playerModel.model.isMale = true;
|
||||
} else {
|
||||
this.playerModel.armor.modelArmorChestplate.isMale = this.playerModel.armor.modelArmor.isMale = this.playerModel.model.isMale = false;
|
||||
}
|
||||
|
||||
if (entity instanceof EntitySkeleton) {
|
||||
this.playerModel.model.wantTail = 4;
|
||||
} else {
|
||||
this.playerModel.model.wantTail = 0;
|
||||
}
|
||||
|
||||
this.playerModel.armor.modelArmorChestplate.isSleeping = this.playerModel.armor.modelArmor.isSleeping = this.playerModel.model.isSleeping = false;
|
||||
this.playerModel.model.isVillager = false;
|
||||
if (PonyManager.getInstance().getShowScale() == 1) {
|
||||
this.shadowSize = 0.4F;
|
||||
}
|
||||
|
||||
double yOrigin = yPosition;
|
||||
if (entity.isSneaking()) {
|
||||
yOrigin -= 0.125D;
|
||||
}
|
||||
|
||||
super.doRender(entity, xPosition, yOrigin, zPosition, yaw, partialTicks);
|
||||
this.playerModel.armor.modelArmorChestplate.aimedBow = this.playerModel.armor.modelArmor.aimedBow = this.playerModel.model.aimedBow = false;
|
||||
this.playerModel.armor.modelArmorChestplate.issneak = this.playerModel.armor.modelArmor.issneak = this.playerModel.model.issneak = false;
|
||||
this.playerModel.armor.modelArmorChestplate.heldItemRight = this.playerModel.armor.modelArmor.heldItemRight = this.playerModel.model.heldItemRight = 0;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void doRender(Entity entity, double xPosition, double yPosition, double zPosition, float yaw,
|
||||
float partialTicks) {
|
||||
this.doRender((T) entity, xPosition, yPosition, zPosition, yaw, partialTicks);
|
||||
}
|
||||
|
||||
protected abstract ResourceLocation getEntityTexture(T var1);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(Entity var1) {
|
||||
return this.getEntityTexture((T) var1);
|
||||
}
|
||||
|
||||
protected void preRenderCallback(T t, float partick) {}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void preRenderCallback(EntityLivingBase entitylivingbaseIn, float partialTickTime) {
|
||||
preRenderCallback((T) entitylivingbaseIn, partialTickTime);
|
||||
}
|
||||
|
||||
protected void rotateCorpse(T entity, float xPosition, float yPosition, float zPosition) {}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void rotateCorpse(EntityLivingBase entity, float xPosition, float yPosition, float zPosition) {
|
||||
this.rotateCorpse((T) entity, xPosition, yPosition, zPosition);
|
||||
super.rotateCorpse(entity, xPosition, yPosition, zPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerModel getPony() {
|
||||
return playerModel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.minelittlepony.minelp.renderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.minelittlepony.minelp.PonyManager;
|
||||
import com.minelittlepony.minelp.model.PMAPI;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerBipedArmor;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class RenderPonySkeleton extends RenderPonyMob<EntitySkeleton> {
|
||||
public RenderPonySkeleton(RenderManager rm) {
|
||||
super(rm, PMAPI.skeletonPony);
|
||||
addLayer(new LayerBipedArmor(this) {
|
||||
@Override
|
||||
protected void func_177177_a() {
|
||||
this.field_177189_c = PMAPI.skeletonPony.model;
|
||||
this.field_177186_d = PMAPI.skeletonPony.model;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preRenderCallback(EntitySkeleton skeleton, float partialTicks) {
|
||||
if (skeleton.getSkeletonType() == 1) {
|
||||
GL11.glScalef(1.2F, 1.2F, 1.2F);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void a(EntityLivingBase entity, float partialTicks) {
|
||||
this.preRenderCallback((EntitySkeleton) entity, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(EntitySkeleton skeleton) {
|
||||
return skeleton.getSkeletonType() == 1 ? PonyManager.skeletonWitherPonyResource
|
||||
: PonyManager.skeletonPonyResource;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.minelittlepony.minelp.renderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.minelittlepony.minelp.Pony;
|
||||
import com.minelittlepony.minelp.PonyManager;
|
||||
import com.minelittlepony.minelp.model.PMAPI;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class RenderPonyVillager extends RenderPonyMob<EntityVillager> {
|
||||
|
||||
public RenderPonyVillager(RenderManager rm) {
|
||||
super(rm, PMAPI.newPonyAdv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preRenderCallback(EntityVillager villager, float partialTicks) {
|
||||
if (villager.getGrowingAge() < 0) {
|
||||
this.mobModel.size = 0;
|
||||
this.shadowSize = 0.25F;
|
||||
} else {
|
||||
this.mobModel.size = 1;
|
||||
if (PonyManager.getInstance().getShowScale() == 1) {
|
||||
this.shadowSize = 0.4F;
|
||||
} else {
|
||||
this.shadowSize = 0.5F;
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glScalef(0.9375F, 0.9375F, 0.9375F);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(EntityVillager villager) {
|
||||
Pony aVillagerPony = PonyManager.getInstance().getPonyFromResourceRegistry(villager);
|
||||
return aVillagerPony.getTextureResourceLocation();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.minelittlepony.minelp.renderer;
|
||||
|
||||
import com.minelittlepony.minelp.PonyManager;
|
||||
import com.minelittlepony.minelp.model.PMAPI;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.monster.EntityPigZombie;
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class RenderPonyZombie extends RenderPonyMob<EntityZombie> {
|
||||
|
||||
public RenderPonyZombie(RenderManager rendermanager) {
|
||||
super(rendermanager, PMAPI.zombiePony);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rotateCorpse(EntityZombie zombie, float xPosition, float yPosition, float zPosition) {
|
||||
if (zombie.isConverting()) {
|
||||
yPosition += (float) (Math.cos(zombie.ticksExisted * 3.25D) * 3.141592653589793D * 0.25D);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(EntityZombie zombie) {
|
||||
return zombie instanceof EntityPigZombie ? PonyManager.zombiePigmanPonyResource
|
||||
: (zombie.isVillager() ? PonyManager.zombieVillagerPonyResource
|
||||
: PonyManager.zombiePonyResource);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,313 @@
|
|||
package com.minelittlepony.minelp.renderer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.minelittlepony.minelp.model.ScalableModelBox;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.model.TextureOffset;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
public class ScalableModelRenderer extends ModelRenderer {
|
||||
public float textureWidth;
|
||||
public float textureHeight;
|
||||
private int textureOffsetX;
|
||||
private int textureOffsetY;
|
||||
public float rotationPointX;
|
||||
public float rotationPointY;
|
||||
public float rotationPointZ;
|
||||
public float rotateAngleX;
|
||||
public float rotateAngleY;
|
||||
public float rotateAngleZ;
|
||||
private boolean compiled;
|
||||
private int displayList;
|
||||
public boolean mirror;
|
||||
public boolean showModel;
|
||||
public boolean isHidden;
|
||||
public List<ScalableModelBox> cubeList;
|
||||
public List<ScalableModelRenderer> childModels;
|
||||
public final String boxName;
|
||||
private ModelBase baseModel;
|
||||
public float offsetX;
|
||||
public float offsetY;
|
||||
public float offsetZ;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ScalableModelRenderer(ModelBase par1ModelBase, String par2Str) {
|
||||
super(par1ModelBase);
|
||||
this.textureWidth = 64.0F;
|
||||
this.textureHeight = 32.0F;
|
||||
this.showModel = true;
|
||||
this.cubeList = new ArrayList<ScalableModelBox>();
|
||||
this.baseModel = par1ModelBase;
|
||||
par1ModelBase.boxList.add(this);
|
||||
this.boxName = par2Str;
|
||||
this.setTextureSize(par1ModelBase.textureWidth, par1ModelBase.textureHeight);
|
||||
}
|
||||
|
||||
public ScalableModelRenderer(ModelBase par1ModelBase) {
|
||||
this(par1ModelBase, (String) null);
|
||||
}
|
||||
|
||||
public ScalableModelRenderer(ModelBase par1ModelBase, int par2, int par3) {
|
||||
this(par1ModelBase);
|
||||
this.setTextureOffset(par2, par3);
|
||||
}
|
||||
|
||||
public void addChild(ScalableModelRenderer par1ModelRenderer) {
|
||||
if (this.childModels == null) {
|
||||
this.childModels = new ArrayList<ScalableModelRenderer>();
|
||||
}
|
||||
|
||||
this.childModels.add(par1ModelRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScalableModelRenderer setTextureOffset(int par1, int par2) {
|
||||
this.textureOffsetX = par1;
|
||||
this.textureOffsetY = par2;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScalableModelRenderer addBox(String par1Str, float par2, float par3, float par4, int par5, int par6,
|
||||
int par7) {
|
||||
par1Str = this.boxName + "." + par1Str;
|
||||
TextureOffset var8 = this.baseModel.getTextureOffset(par1Str);
|
||||
this.setTextureOffset(var8.textureOffsetX, var8.textureOffsetY);
|
||||
this.cubeList.add((new ScalableModelBox(this, this.textureOffsetX, this.textureOffsetY, par2, par3, par4, par5,
|
||||
par6, par7, 0.0F)).func_78244_a(par1Str));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScalableModelRenderer addBox(float par1, float par2, float par3, int par4, int par5, int par6) {
|
||||
this.cubeList.add(new ScalableModelBox(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4,
|
||||
par5, par6, 0.0F));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBox(float par1, float par2, float par3, int par4, int par5, int par6, float par7) {
|
||||
this.cubeList.add(new ScalableModelBox(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4,
|
||||
par5, par6, par7));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotationPoint(float par1, float par2, float par3) {
|
||||
this.rotationPointX = par1;
|
||||
this.rotationPointY = par2;
|
||||
this.rotationPointZ = par3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(float par1) {
|
||||
if (!this.isHidden && this.showModel) {
|
||||
if (!this.compiled) {
|
||||
this.compileDisplayList(par1);
|
||||
}
|
||||
|
||||
GL11.glTranslatef(this.offsetX, this.offsetY, this.offsetZ);
|
||||
int var2;
|
||||
if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) {
|
||||
if (this.rotationPointX == 0.0F && this.rotationPointY == 0.0F && this.rotationPointZ == 0.0F) {
|
||||
GL11.glCallList(this.displayList);
|
||||
if (this.childModels != null) {
|
||||
for (var2 = 0; var2 < this.childModels.size(); ++var2) {
|
||||
this.childModels.get(var2).render(par1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1,
|
||||
this.rotationPointZ * par1);
|
||||
GL11.glCallList(this.displayList);
|
||||
if (this.childModels != null) {
|
||||
for (var2 = 0; var2 < this.childModels.size(); ++var2) {
|
||||
this.childModels.get(var2).render(par1);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glTranslatef(-this.rotationPointX * par1, -this.rotationPointY * par1,
|
||||
-this.rotationPointZ * par1);
|
||||
}
|
||||
} else {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1);
|
||||
if (this.rotateAngleZ != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleZ * 57.295776F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleY != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleY * 57.295776F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleX != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleX * 57.295776F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
GL11.glCallList(this.displayList);
|
||||
if (this.childModels != null) {
|
||||
for (var2 = 0; var2 < this.childModels.size(); ++var2) {
|
||||
this.childModels.get(var2).render(par1);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glTranslatef(-this.offsetX, -this.offsetY, -this.offsetZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void render(float par1, float scaleX, float scaleY, float scaleZ) {
|
||||
if (!this.isHidden && this.showModel) {
|
||||
if (!this.compiled) {
|
||||
this.compileDisplayList(par1);
|
||||
}
|
||||
|
||||
GL11.glTranslatef(this.offsetX, this.offsetY, this.offsetZ);
|
||||
int var2;
|
||||
if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) {
|
||||
if (this.rotationPointX == 0.0F && this.rotationPointY == 0.0F && this.rotationPointZ == 0.0F) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(scaleX, scaleY, scaleZ);
|
||||
GL11.glCallList(this.displayList);
|
||||
if (this.childModels != null) {
|
||||
for (var2 = 0; var2 < this.childModels.size(); ++var2) {
|
||||
this.childModels.get(var2).render(par1);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
} else {
|
||||
GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1,
|
||||
this.rotationPointZ * par1);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(scaleX, scaleY, scaleZ);
|
||||
GL11.glCallList(this.displayList);
|
||||
if (this.childModels != null) {
|
||||
for (var2 = 0; var2 < this.childModels.size(); ++var2) {
|
||||
this.childModels.get(var2).render(par1);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glTranslatef(-this.rotationPointX * par1, -this.rotationPointY * par1,
|
||||
-this.rotationPointZ * par1);
|
||||
}
|
||||
} else {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1);
|
||||
if (this.rotateAngleZ != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleZ * 57.295776F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleY != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleY * 57.295776F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleX != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleX * 57.295776F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(scaleX, scaleY, scaleZ);
|
||||
GL11.glCallList(this.displayList);
|
||||
if (this.childModels != null) {
|
||||
for (var2 = 0; var2 < this.childModels.size(); ++var2) {
|
||||
this.childModels.get(var2).render(par1);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glTranslatef(-this.offsetX, -this.offsetY, -this.offsetZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWithRotation(float par1) {
|
||||
if (!this.isHidden && this.showModel) {
|
||||
if (!this.compiled) {
|
||||
this.compileDisplayList(par1);
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1);
|
||||
if (this.rotateAngleY != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleY * 57.295776F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleX != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleX * 57.295776F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleZ != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleZ * 57.295776F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
GL11.glCallList(this.displayList);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRender(float par1) {
|
||||
if (!this.isHidden && this.showModel) {
|
||||
if (!this.compiled) {
|
||||
this.compileDisplayList(par1);
|
||||
}
|
||||
|
||||
if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) {
|
||||
if (this.rotationPointX != 0.0F || this.rotationPointY != 0.0F || this.rotationPointZ != 0.0F) {
|
||||
GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1,
|
||||
this.rotationPointZ * par1);
|
||||
}
|
||||
} else {
|
||||
GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1);
|
||||
if (this.rotateAngleZ != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleZ * 57.295776F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleY != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleY * 57.295776F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (this.rotateAngleX != 0.0F) {
|
||||
GL11.glRotatef(this.rotateAngleX * 57.295776F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void compileDisplayList(float par1) {
|
||||
this.displayList = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(this.displayList, 4864);
|
||||
Tessellator var2 = Tessellator.getInstance();
|
||||
|
||||
for (int var3 = 0; var3 < this.cubeList.size(); ++var3) {
|
||||
this.cubeList.get(var3).render(var2, par1);
|
||||
}
|
||||
|
||||
GL11.glEndList();
|
||||
this.compiled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScalableModelRenderer setTextureSize(int par1, int par2) {
|
||||
this.textureWidth = par1;
|
||||
this.textureHeight = par2;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.minelittlepony.minelp.renderer.layer;
|
||||
|
||||
import com.minelittlepony.minelp.model.ModelPony;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
public class LayerHeldPonyItem implements LayerRenderer {
|
||||
|
||||
private final RendererLivingEntity livingPonyEntity;
|
||||
|
||||
public LayerHeldPonyItem(RendererLivingEntity livingPony) {
|
||||
this.livingPonyEntity = livingPony;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_,
|
||||
float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) {
|
||||
ModelPony pony = (ModelPony) livingPonyEntity.getMainModel();
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
pony.renderDrop(mc.getRenderManager(), mc.getItemRenderer(), entitylivingbaseIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCombineTextures() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,295 @@
|
|||
package com.minelittlepony.minelp.renderer.layer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.minelittlepony.minelp.PonyManager;
|
||||
import com.minelittlepony.minelp.model.ModelPony;
|
||||
import com.minelittlepony.minelp.model.PlayerModel;
|
||||
import com.minelittlepony.minelp.model.pony.pm_Human;
|
||||
import com.minelittlepony.minelp.model.pony.pm_newPonyAdv;
|
||||
import com.minelittlepony.minelp.model.pony.armor.pm_newPonyArmor;
|
||||
import com.minelittlepony.minelp.renderer.IRenderPony;
|
||||
import com.minelittlepony.minelp.util.MineLPReflection;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerBipedArmor;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemArmor.ArmorMaterial;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class LayerPonyArmor implements LayerRenderer {
|
||||
|
||||
private static final ResourceLocation ENCHANTED_ITEM_GLINT_RES = new ResourceLocation(
|
||||
"textures/misc/enchanted_item_glint.png");
|
||||
|
||||
private static final Map<String, ResourceLocation> field_110859_k = Maps.newHashMap();
|
||||
private static final Map<String, ResourceLocation> ponyArmorMap = Maps.newHashMap();
|
||||
private static final Map<String, ResourceLocation> onlyPonyArmorMap = Maps.newHashMap();
|
||||
private static final String[] bipedArmorFilenamePrefix = { "leather", "chainmail", "iron", "gold", "diamond" };
|
||||
|
||||
private static HashSet<String> ponyArmors = new HashSet<String>();
|
||||
|
||||
private RendererLivingEntity renderer;
|
||||
private LayerBipedArmor humanArmor;
|
||||
private PlayerModel pony;
|
||||
|
||||
public LayerPonyArmor(RendererLivingEntity entity) {
|
||||
this.renderer = entity;
|
||||
this.humanArmor = new LayerBipedArmor(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_,
|
||||
float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) {
|
||||
pony = ((IRenderPony) renderer).getPony();
|
||||
if (pony.model instanceof pm_Human) {
|
||||
humanArmor.doRenderLayer(entitylivingbaseIn, p_177141_2_, p_177141_3_, partialTicks, p_177141_5_,
|
||||
p_177141_6_, p_177141_7_, scale);
|
||||
} else {
|
||||
renderArmor(entitylivingbaseIn, p_177141_2_, p_177141_3_, partialTicks, p_177141_5_, p_177141_6_,
|
||||
p_177141_7_, scale, 4);
|
||||
renderArmor(entitylivingbaseIn, p_177141_2_, p_177141_3_, partialTicks, p_177141_5_, p_177141_6_,
|
||||
p_177141_7_, scale, 3);
|
||||
renderArmor(entitylivingbaseIn, p_177141_2_, p_177141_3_, partialTicks, p_177141_5_, p_177141_6_,
|
||||
p_177141_7_, scale, 2);
|
||||
renderArmor(entitylivingbaseIn, p_177141_2_, p_177141_3_, partialTicks, p_177141_5_, p_177141_6_,
|
||||
p_177141_7_, scale, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderArmor(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_,
|
||||
float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale, int armorSlot) {
|
||||
ItemStack itemstack = entitylivingbaseIn.getCurrentArmor(armorSlot - 1);
|
||||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemArmor) {
|
||||
ItemArmor itemarmor = (ItemArmor) itemstack.getItem();
|
||||
|
||||
ModelPony modelbase = armorSlot > 2 ? pony.armor.modelArmorChestplate : pony.armor.modelArmor;
|
||||
modelbase.setModelAttributes(this.renderer.getMainModel());
|
||||
modelbase.setLivingAnimations(entitylivingbaseIn, p_177141_2_, p_177141_3_, partialTicks);
|
||||
prepareToRender((pm_newPonyArmor) modelbase, armorSlot);
|
||||
this.bindPonyArmorTexture(itemarmor, armorSlot, null);
|
||||
if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) {
|
||||
int j = itemarmor.getColor(itemstack);
|
||||
float f7 = (j >> 16 & 255) / 255.0F;
|
||||
float f8 = (j >> 8 & 255) / 255.0F;
|
||||
float f9 = (j & 255) / 255.0F;
|
||||
GlStateManager.color(f7, f8, f9, 1);
|
||||
modelbase.render(entitylivingbaseIn, p_177141_2_, p_177141_3_, p_177141_5_, p_177141_6_, p_177141_7_,
|
||||
scale);
|
||||
|
||||
bindPonyArmorTexture(itemarmor, armorSlot, "overlay");
|
||||
}
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
modelbase.render(entitylivingbaseIn, p_177141_2_, p_177141_3_, p_177141_5_, p_177141_6_, p_177141_7_,
|
||||
scale);
|
||||
|
||||
if (itemstack.isItemEnchanted()) {
|
||||
this.renderEnchantment(entitylivingbaseIn, modelbase, p_177141_2_, p_177141_3_, partialTicks,
|
||||
p_177141_5_, p_177141_6_, p_177141_7_, scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareToRender(pm_newPonyArmor model, int slot) {
|
||||
model.setInvisible(false);
|
||||
|
||||
switch (slot) {
|
||||
// feet
|
||||
case 1:
|
||||
model.bipedRightArm.showModel = true;
|
||||
model.bipedLeftArm.showModel = true;
|
||||
for (ModelRenderer m : model.extLegs) {
|
||||
m.showModel = true;
|
||||
}
|
||||
model.bipedRightLeg.showModel = true;
|
||||
model.bipedLeftLeg.showModel = true;
|
||||
break;
|
||||
// legs
|
||||
case 2:
|
||||
model.bipedRightLeg.showModel = true;
|
||||
model.bipedLeftLeg.showModel = true;
|
||||
model.bipedRightArm.showModel = true;
|
||||
model.bipedLeftArm.showModel = true;
|
||||
model.Bodypiece.showModel = true;
|
||||
model.extBody.showModel = true;
|
||||
model.bipedBody.showModel = true;
|
||||
break;
|
||||
// chest
|
||||
case 3:
|
||||
model.bipedRightLeg.showModel = true;
|
||||
model.bipedLeftLeg.showModel = true;
|
||||
model.bipedRightArm.showModel = true;
|
||||
model.bipedLeftArm.showModel = true;
|
||||
model.extBody.showModel = true;
|
||||
break;
|
||||
// head
|
||||
case 4:
|
||||
model.bipedHead.showModel = true;
|
||||
for (ModelRenderer m : model.extHead) {
|
||||
m.showModel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderEnchantment(EntityLivingBase entitylivingbaseIn, ModelBase modelbaseIn, float p_177183_3_,
|
||||
float p_177183_4_, float p_177183_5_, float p_177183_6_, float p_177183_7_, float p_177183_8_,
|
||||
float p_177183_9_) {
|
||||
float f7 = entitylivingbaseIn.ticksExisted + p_177183_5_;
|
||||
this.renderer.bindTexture(ENCHANTED_ITEM_GLINT_RES);
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.depthFunc(514);
|
||||
GlStateManager.depthMask(false);
|
||||
float f8 = 0.5F;
|
||||
GlStateManager.color(f8, f8, f8, 1.0F);
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.blendFunc(768, 1);
|
||||
float f9 = 0.76F;
|
||||
GlStateManager.color(0.5F * f9, 0.25F * f9, 0.8F * f9, 1.0F);
|
||||
GlStateManager.matrixMode(5890);
|
||||
GlStateManager.loadIdentity();
|
||||
float f10 = 0.33333334F;
|
||||
GlStateManager.scale(f10, f10, f10);
|
||||
GlStateManager.rotate(30.0F - i * 60.0F, 0.0F, 0.0F, 1.0F);
|
||||
GlStateManager.translate(0.0F, f7 * (0.001F + i * 0.003F) * 20.0F, 0.0F);
|
||||
GlStateManager.matrixMode(5888);
|
||||
modelbaseIn.render(entitylivingbaseIn, p_177183_3_, p_177183_4_, p_177183_6_, p_177183_7_, p_177183_8_,
|
||||
p_177183_9_);
|
||||
}
|
||||
|
||||
GlStateManager.matrixMode(5890);
|
||||
GlStateManager.loadIdentity();
|
||||
GlStateManager.matrixMode(5888);
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.depthFunc(515);
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCombineTextures() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean bindPonyArmorTexture(ItemArmor armorPiece, int slot, String overlay) {
|
||||
String overlayText = "";
|
||||
if (overlay != null) {
|
||||
overlayText = String.format("_%s", overlay);
|
||||
}
|
||||
|
||||
String path = this.pony.armor.path
|
||||
+ bipedArmorFilenamePrefix[armorPiece.getArmorMaterial().ordinal()]
|
||||
+ "_layer_" + this.pony.armor.subimage(slot) + overlayText + ".png";
|
||||
if (PonyManager.getInstance().getPonyArmor() == 1 && this.pony.model instanceof pm_newPonyAdv) {
|
||||
Object[] armorResourceAndState = this.getPonyResourceLocation(path);
|
||||
renderer.bindTexture((ResourceLocation) armorResourceAndState[0]);
|
||||
return ((Boolean) armorResourceAndState[1]).booleanValue();
|
||||
} else {
|
||||
// this.a(RenderBiped.func_110858_a(armorPiece., slot, overlay));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean bindForgeArmorTexture(Entity playerEntity, ItemStack armorStack, ItemArmor armorPiece, int slot,
|
||||
String overlay) {
|
||||
String path = "";
|
||||
|
||||
try {
|
||||
path = String.format("textures/models/armor/%s_layer_%d%s.png",
|
||||
bipedArmorFilenamePrefix[armorPiece.renderIndex],
|
||||
Integer.valueOf(slot == 2 ? 2 : 1),
|
||||
overlay == null ? "" : String.format("_%s", overlay));
|
||||
} catch (ArrayIndexOutOfBoundsException var10) {}
|
||||
|
||||
path = (String) MineLPReflection.forgeAPI.invokeMethod("ForgeHooksClient.getArmorTexture", (Object) null,
|
||||
playerEntity, armorStack, path, Integer.valueOf(slot), overlay);
|
||||
boolean ponyArmor;
|
||||
if (ponyArmors.contains(path)) {
|
||||
ponyArmor = this.bindPonyArmorTexture(armorPiece, slot, overlay);
|
||||
} else {
|
||||
ponyArmor = false;
|
||||
ResourceLocation forgeResourceLocation;
|
||||
if (PonyManager.getInstance().getPonyArmor() == 1 && this.pony.model instanceof pm_newPonyAdv) {
|
||||
Object[] armorResourceAndState = this.getPonyResourceLocation(path);
|
||||
forgeResourceLocation = (ResourceLocation) armorResourceAndState[0];
|
||||
ponyArmor = ((Boolean) armorResourceAndState[1]).booleanValue();
|
||||
} else {
|
||||
forgeResourceLocation = field_110859_k.get(path);
|
||||
if (forgeResourceLocation == null) {
|
||||
forgeResourceLocation = new ResourceLocation(path);
|
||||
field_110859_k.put(path, forgeResourceLocation);
|
||||
}
|
||||
|
||||
ponyArmor = false;
|
||||
}
|
||||
|
||||
renderer.bindTexture(forgeResourceLocation);
|
||||
}
|
||||
|
||||
return ponyArmor;
|
||||
}
|
||||
|
||||
protected Object[] getPonyResourceLocation(String path) {
|
||||
boolean ponyArmor = false;
|
||||
String ponyPath = path.replace(".png", "_pony.png");
|
||||
ResourceLocation ponyResourceLocation = ponyArmorMap.get(path);
|
||||
if (ponyResourceLocation == null) {
|
||||
ResourceLocation ponyArmorResource = new ResourceLocation(ponyPath);
|
||||
|
||||
try {
|
||||
TextureUtil.readImageData(Minecraft.getMinecraft().getResourceManager(), ponyArmorResource);
|
||||
if (ponyArmorResource != null) {
|
||||
ponyResourceLocation = ponyArmorResource;
|
||||
ponyArmorMap.put(path, ponyArmorResource);
|
||||
onlyPonyArmorMap.put(path, ponyArmorResource);
|
||||
ponyArmor = true;
|
||||
}
|
||||
} catch (IOException var7) {
|
||||
ponyResourceLocation = field_110859_k.get(path);
|
||||
if (ponyResourceLocation == null) {
|
||||
ponyResourceLocation = new ResourceLocation(path);
|
||||
field_110859_k.put(path, ponyResourceLocation);
|
||||
}
|
||||
|
||||
ponyArmorMap.put(path, ponyResourceLocation);
|
||||
ponyArmor = false;
|
||||
}
|
||||
} else {
|
||||
ponyArmor = true;
|
||||
ponyResourceLocation = onlyPonyArmorMap.get(path);
|
||||
if (ponyResourceLocation == null) {
|
||||
ponyResourceLocation = ponyArmorMap.get(path);
|
||||
ponyArmor = false;
|
||||
}
|
||||
}
|
||||
|
||||
return new Object[] { ponyResourceLocation, Boolean.valueOf(ponyArmor) };
|
||||
}
|
||||
|
||||
static {
|
||||
MineLPReflection.preCall();
|
||||
|
||||
for (int i = 1; i <= 2; ++i) {
|
||||
for (String prefix : bipedArmorFilenamePrefix) {
|
||||
ponyArmors.add("textures/models/armor/" + prefix + "_layer_" + i + ".png");
|
||||
}
|
||||
}
|
||||
|
||||
ponyArmors.add("textures/models/armor/leather_layer_1_overlay.png");
|
||||
ponyArmors.add("textures/models/armor/leather_layer_2_overlay.png");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.minelittlepony.minelp.renderer.layer;
|
||||
|
||||
import com.minelittlepony.minelp.model.ModelPony;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class LayerPonyCape implements LayerRenderer {
|
||||
|
||||
private RendererLivingEntity renderer;
|
||||
|
||||
public LayerPonyCape(RendererLivingEntity entity) {
|
||||
renderer = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_,
|
||||
float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) {
|
||||
((ModelPony) renderer.getMainModel()).renderCloak((EntityPlayer) entitylivingbaseIn, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCombineTextures() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package com.minelittlepony.minelp.renderer.layer;
|
||||
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
|
||||
import com.minelittlepony.minelp.model.ModelPony;
|
||||
import com.minelittlepony.minelp.model.PlayerModel;
|
||||
import com.minelittlepony.minelp.model.pony.pm_newPonyAdv;
|
||||
import com.minelittlepony.minelp.renderer.IRenderPony;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.tileentity.TileEntitySkull;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public class LayerPonySkull implements LayerRenderer {
|
||||
|
||||
private RendererLivingEntity renderer;
|
||||
|
||||
public LayerPonySkull(RendererLivingEntity renderPony) {
|
||||
this.renderer = renderPony;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRenderLayer(EntityLivingBase entity, float p_177141_2_, float p_177141_3_,
|
||||
float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) {
|
||||
ItemStack itemstack = entity.getCurrentArmor(3);
|
||||
if (itemstack != null && itemstack.getItem() != null) {
|
||||
ModelPony model = getModel().model;
|
||||
Item item = itemstack.getItem();
|
||||
|
||||
pushMatrix();
|
||||
boolean isVillager = entity instanceof EntityVillager
|
||||
|| entity instanceof EntityZombie && ((EntityZombie) entity).isVillager();
|
||||
if (!isVillager && entity.isChild()) {
|
||||
scale(0.7, 0.7, 0.7);
|
||||
}
|
||||
if (model instanceof pm_newPonyAdv) {
|
||||
if (model.size == 0) {
|
||||
translate(0.0F, 0.76F, 0.0F);
|
||||
scale(0.9, 0.9, 0.9);
|
||||
}
|
||||
}
|
||||
model.bipedHead.postRender(0.0625f);
|
||||
if (model instanceof pm_newPonyAdv) {
|
||||
translate(0, .2, 0);
|
||||
}
|
||||
color(1, 1, 1, 1);
|
||||
if (item instanceof ItemBlock) {
|
||||
renderBlock(entity, itemstack, isVillager);
|
||||
} else if (item == Items.skull) {
|
||||
if (model instanceof pm_newPonyAdv) {
|
||||
translate(0, 0, -.15);
|
||||
}
|
||||
renderSkull(itemstack, isVillager);
|
||||
}
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void renderBlock(EntityLivingBase entity, ItemStack itemstack, boolean isVillager) {
|
||||
// translate(0, -0.25, 0);
|
||||
rotate(180, 0, 1, 0);
|
||||
scale(0.625, -0.625, -0.625);
|
||||
translate(0, 0.4, -0.21);
|
||||
|
||||
Minecraft.getMinecraft().getItemRenderer().renderItem(entity, itemstack, TransformType.HEAD);
|
||||
}
|
||||
|
||||
private void renderSkull(ItemStack itemstack, boolean isVillager) {
|
||||
float f = 1.1875f;
|
||||
scale(f, -f, -f);
|
||||
if (isVillager) {
|
||||
translate(0, 0.0625, 0);
|
||||
}
|
||||
translate(0, 0, -.05f);
|
||||
GameProfile profile = null;
|
||||
|
||||
if (itemstack.hasTagCompound()) {
|
||||
NBTTagCompound nbt = itemstack.getTagCompound();
|
||||
|
||||
if (nbt.hasKey("SkullOwner", 10)) {
|
||||
profile = NBTUtil.readGameProfileFromNBT(nbt.getCompoundTag("SkullOwner"));
|
||||
} else if (nbt.hasKey("SkullOwner", 8)) {
|
||||
profile = TileEntitySkull.updateGameprofile(new GameProfile(null, nbt.getString("SkullOwner")));
|
||||
nbt.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), profile));
|
||||
}
|
||||
}
|
||||
|
||||
TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.45F, EnumFacing.UP, 180.0F,
|
||||
itemstack.getMetadata(), profile, -1);
|
||||
|
||||
}
|
||||
|
||||
private PlayerModel getModel() {
|
||||
return ((IRenderPony) renderer).getPony();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCombineTextures() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.minelittlepony.minelp.transformers;
|
||||
|
||||
import com.mumfrey.liteloader.transformers.ClassOverlayTransformer;
|
||||
|
||||
public class RenderPlayerTransformer extends ClassOverlayTransformer {
|
||||
|
||||
private static final String overlayClassName = "com.minelittlepony.minelp.renderer.RenderPony";
|
||||
|
||||
public RenderPlayerTransformer() {
|
||||
super(overlayClassName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.minelittlepony.minelp.util;
|
||||
|
||||
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class MineLPLogger {
|
||||
private static Logger logger = LogManager.getLogger("MineLittlePony");
|
||||
|
||||
public static Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
private static void log(Level level, String format, Object... data) {
|
||||
logger.log(level, "MineLittlePony> " + String.format(format, data));
|
||||
}
|
||||
|
||||
private static void log(Level level, Throwable t, String format, Object... data) {
|
||||
logger.log(level, "MineLittlePony> " + String.format(format, data), t);
|
||||
}
|
||||
|
||||
public static void info(String message) {
|
||||
log(Level.INFO, message, new Object[0]);
|
||||
}
|
||||
|
||||
public static void info(String message, Object... data) {
|
||||
log(Level.INFO, message, data);
|
||||
}
|
||||
|
||||
public static void debug(String message) {
|
||||
if(LiteLoaderLogger.DEBUG) {
|
||||
log(Level.INFO, message, new Object[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void debug(String message, Object... data) {
|
||||
if(LiteLoaderLogger.DEBUG) {
|
||||
log(Level.INFO, message, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void debug(Throwable t, String message, Object... data) {
|
||||
if(LiteLoaderLogger.DEBUG) {
|
||||
log(Level.INFO, message, new Object[]{data, t});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void warn(String message) {
|
||||
log(Level.WARN, message, new Object[0]);
|
||||
}
|
||||
|
||||
public static void warn(String message, Object... data) {
|
||||
log(Level.WARN, message, data);
|
||||
}
|
||||
|
||||
public static void warn(Throwable t, String message, Object... data) {
|
||||
log(Level.WARN, t, message, data);
|
||||
}
|
||||
|
||||
public static void error(String message) {
|
||||
log(Level.ERROR, message, new Object[0]);
|
||||
}
|
||||
|
||||
public static void error(String message, Object... data) {
|
||||
log(Level.ERROR, message, data);
|
||||
}
|
||||
|
||||
public static void error(Throwable t, String message, Object... data) {
|
||||
log(Level.ERROR, t, message, data);
|
||||
}
|
||||
}
|
17
src/main/java/com/minelittlepony/minelp/util/MineLPObf.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package com.minelittlepony.minelp.util;
|
||||
|
||||
import com.mumfrey.liteloader.core.runtime.Obf;
|
||||
|
||||
public class MineLPObf extends Obf {
|
||||
|
||||
public static final MineLPObf isJumping = new MineLPObf("field_70703_bu", "aW", "isJumping");
|
||||
public static final MineLPObf ARMOR_TEXTURE_RES_MAP = new MineLPObf("field_177191_j", "j", "ARMOR_TEXTURE_RES_MAP");
|
||||
|
||||
protected MineLPObf(String seargeName, String obfName, String mcpName) {
|
||||
super(seargeName, obfName, mcpName);
|
||||
}
|
||||
|
||||
protected MineLPObf(String seargeName, String obfName) {
|
||||
super(seargeName, obfName, seargeName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.minelittlepony.minelp.util;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.mumfrey.liteloader.core.runtime.Obf;
|
||||
import com.mumfrey.liteloader.util.PrivateFields;
|
||||
|
||||
import net.minecraft.client.renderer.entity.layers.LayerArmorBase;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class MineLPPrivateFields<P, T> extends PrivateFields<P, T> {
|
||||
public static final MineLPPrivateFields<EntityLivingBase, Boolean> isJumping = new MineLPPrivateFields<EntityLivingBase, Boolean>(
|
||||
EntityLivingBase.class, MineLPObf.isJumping);
|
||||
public static final MineLPPrivateFields<LayerArmorBase, Map<String, ResourceLocation>> ARMOR_TEXTURE_RES_MAP = new MineLPPrivateFields<LayerArmorBase, Map<String, ResourceLocation>>(
|
||||
LayerArmorBase.class, MineLPObf.ARMOR_TEXTURE_RES_MAP);
|
||||
|
||||
protected MineLPPrivateFields(Class<P> owner, Obf obf) {
|
||||
super(owner, obf);
|
||||
}
|
||||
|
||||
}
|
210
src/main/java/com/minelittlepony/minelp/util/MineLPRData.java
Normal file
|
@ -0,0 +1,210 @@
|
|||
package com.minelittlepony.minelp.util;
|
||||
|
||||
import com.minelittlepony.minelp.util.MineLPLogger;
|
||||
import com.minelittlepony.minelp.util.MineLPReflection;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class MineLPRData {
|
||||
public boolean installed = false;
|
||||
public boolean compatible = false;
|
||||
public HashMap<String, Class<?>> classes = new HashMap<String, Class<?>>();
|
||||
public HashMap<String, Constructor<?>> constructors = new HashMap<String, Constructor<?>>();
|
||||
public HashMap<String, Method> methods = new HashMap<String, Method>();
|
||||
public HashMap<String, Field> fields = new HashMap<String, Field>();
|
||||
public HashMap<String, Object> objects = new HashMap<String, Object>();
|
||||
|
||||
public Object getInstance(String constructorName, Object... params) {
|
||||
try {
|
||||
if (this.constructors.containsKey(constructorName)) {
|
||||
Constructor<?> e = this.constructors.get(constructorName);
|
||||
if (params != null && params.length != 0) {
|
||||
return e.newInstance(params);
|
||||
}
|
||||
|
||||
return e.newInstance(new Object[0]);
|
||||
}
|
||||
|
||||
MineLPLogger.error("Unknown requested constructor \"%s\"", new Object[] { constructorName });
|
||||
} catch (Exception var4) {
|
||||
var4.printStackTrace();
|
||||
MineLPLogger.error("Error when trying to get constructor \"%s\"", new Object[] { constructorName });
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isInstance(String className, Object object) {
|
||||
return this.getClass(className).isInstance(object);
|
||||
}
|
||||
|
||||
public Object getField(String fieldName, Object object) {
|
||||
try {
|
||||
if (this.fields.containsKey(fieldName)) {
|
||||
Field e = this.fields.get(fieldName);
|
||||
return e.get(object);
|
||||
}
|
||||
|
||||
MineLPLogger.error("Unknown requested field \"%s\"", new Object[] { fieldName });
|
||||
} catch (Exception var4) {
|
||||
var4.printStackTrace();
|
||||
MineLPLogger.error("Error when trying to get field \"%s\"", new Object[] { fieldName });
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean setField(String fieldName, Object object, Object value) {
|
||||
try {
|
||||
if (this.fields.containsKey(fieldName)) {
|
||||
Field e = this.fields.get(fieldName);
|
||||
e.set(object, value);
|
||||
return true;
|
||||
} else {
|
||||
MineLPLogger.error("Unknown requested field \"%s\"", new Object[] { fieldName });
|
||||
return false;
|
||||
}
|
||||
} catch (Exception var5) {
|
||||
var5.printStackTrace();
|
||||
MineLPLogger.error("Error when trying to set field \"%s\"", new Object[] { fieldName });
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Object invokeMethod(String methodName, Object object, Object... params) {
|
||||
try {
|
||||
if (this.methods.containsKey(methodName)) {
|
||||
Method e = this.methods.get(methodName);
|
||||
return params != null ? e.invoke(object, params) : e.invoke(object, new Object[0]);
|
||||
} else {
|
||||
MineLPLogger.error("Unknown requested method \"%s\"", new Object[] { methodName });
|
||||
return null;
|
||||
}
|
||||
} catch (Exception var5) {
|
||||
var5.printStackTrace();
|
||||
MineLPLogger.error("Method \"%s\" failed to be invoked", new Object[] { methodName });
|
||||
MineLPLogger.error(
|
||||
"Types: " + MineLPReflection.getStringFromTypes(MineLPReflection.getTypesFromObjects(params)));
|
||||
MineLPLogger.error("Values: " + params.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Class<?> getClass(String className) {
|
||||
return this.classes.containsKey(className) ? (Class<?>) this.classes.get(className) : null;
|
||||
}
|
||||
|
||||
public Constructor<?> getConstructor(String constructorName) {
|
||||
return this.constructors.containsKey(constructorName) ? (Constructor<?>) this.constructors.get(constructorName)
|
||||
: null;
|
||||
}
|
||||
|
||||
public Method getMethod(String methodName) {
|
||||
return this.methods.containsKey(methodName) ? (Method) this.methods.get(methodName) : null;
|
||||
}
|
||||
|
||||
public Field getField(String fieldName) {
|
||||
return this.fields.containsKey(fieldName) ? (Field) this.fields.get(fieldName) : null;
|
||||
}
|
||||
|
||||
public Object getObject(String objectName) {
|
||||
Object object = null;
|
||||
if (this.objects.containsKey(objectName)) {
|
||||
object = this.objects.get(objectName);
|
||||
}
|
||||
|
||||
if (object == null) {
|
||||
MineLPLogger.error("Object \"%s\" is NULL", new Object[] { objectName });
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
public void putClass(String className, Class<?> clazz) {
|
||||
this.classes.put(className, clazz);
|
||||
}
|
||||
|
||||
public void putConstructor(String constructorName, Constructor<?> constructor) {
|
||||
this.constructors.put(constructorName, constructor);
|
||||
}
|
||||
|
||||
public void putMethod(String methodName, Method method) {
|
||||
this.methods.put(methodName, method);
|
||||
}
|
||||
|
||||
public void putField(String fieldName, Field field) {
|
||||
this.fields.put(fieldName, field);
|
||||
}
|
||||
|
||||
public void putObject(String objectName, Object object) {
|
||||
this.objects.put(objectName, object);
|
||||
}
|
||||
|
||||
public void removeClass(String className) {
|
||||
this.classes.remove(className);
|
||||
}
|
||||
|
||||
public void removeConstructor(String constructorName) {
|
||||
this.constructors.remove(constructorName);
|
||||
}
|
||||
|
||||
public void removeMethod(String methodName) {
|
||||
this.methods.remove(methodName);
|
||||
}
|
||||
|
||||
public void removeField(String fieldName) {
|
||||
this.fields.remove(fieldName);
|
||||
}
|
||||
|
||||
public void removeObject(String objectName) {
|
||||
this.objects.remove(objectName);
|
||||
}
|
||||
|
||||
public boolean hasClass(String className) {
|
||||
return this.classes.containsKey(className);
|
||||
}
|
||||
|
||||
public boolean hasConstructor(String constructorName) {
|
||||
return this.constructors.containsKey(constructorName);
|
||||
}
|
||||
|
||||
public boolean hasMethod(String methodName) {
|
||||
return this.methods.containsKey(methodName);
|
||||
}
|
||||
|
||||
public boolean hasField(String fieldName) {
|
||||
return this.fields.containsKey(fieldName);
|
||||
}
|
||||
|
||||
public boolean hasObject(String objectName) {
|
||||
return this.objects.containsKey(objectName);
|
||||
}
|
||||
|
||||
public boolean removeNullData() {
|
||||
boolean nullDataPresent = false;
|
||||
nullDataPresent |= this.removeNullData(this.classes);
|
||||
nullDataPresent |= this.removeNullData(this.constructors);
|
||||
nullDataPresent |= this.removeNullData(this.methods);
|
||||
nullDataPresent |= this.removeNullData(this.fields);
|
||||
return nullDataPresent;
|
||||
}
|
||||
|
||||
private <K> boolean removeNullData(Map<K, ?> map) {
|
||||
// boolean nullDataPresent = false;
|
||||
Iterator<K> var3 = map.keySet().iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
Object key = var3.next();
|
||||
if (map.get(key) == null) {
|
||||
this.constructors.remove(key);
|
||||
// nullDataPresent = true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,508 @@
|
|||
package com.minelittlepony.minelp.util;
|
||||
|
||||
import com.minelittlepony.minelp.util.MineLPLogger;
|
||||
import com.minelittlepony.minelp.util.MineLPRData;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderBiped;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
|
||||
public class MineLPReflection {
|
||||
public static MineLPRData forgeAPI;
|
||||
|
||||
public static void preCall() {}
|
||||
|
||||
private static boolean reflectForgeAPI(MineLPRData data) {
|
||||
MineLPLogger.info("Checking ForgeAPI...");
|
||||
Class<?> forgeAPIIItemRendererItemRenderType;
|
||||
Class<?> forgeAPIIItemRendererItemRendererHelper;
|
||||
Class<?> forgeAPIIItemRenderer;
|
||||
Class<?> forgeAPIMinecraftForgeClient;
|
||||
Class<?> forgeAPIForgeHooksClient;
|
||||
Class<?>[] reflectedForgeAPIClasses = new Class[] {
|
||||
forgeAPIIItemRendererItemRenderType = getClass(
|
||||
"net.minecraftforge.client.IItemRenderer$ItemRenderType"),
|
||||
forgeAPIIItemRendererItemRendererHelper = getClass(
|
||||
"net.minecraftforge.client.IItemRenderer$ItemRendererHelper"),
|
||||
forgeAPIIItemRenderer = getClass("net.minecraftforge.client.IItemRenderer"),
|
||||
forgeAPIMinecraftForgeClient = getClass("net.minecraftforge.client.MinecraftForgeClient"),
|
||||
forgeAPIForgeHooksClient = getClass("net.minecraftforge.client.ForgeHooksClient"),
|
||||
getClass("net.minecraft.src.RenderBiped") };
|
||||
data.installed = false;
|
||||
int var9 = reflectedForgeAPIClasses.length;
|
||||
byte o = 0;
|
||||
if (o < var9) {
|
||||
Class<?> enumConstants = reflectedForgeAPIClasses[o];
|
||||
if (enumConstants == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data.installed = true;
|
||||
}
|
||||
|
||||
data.putClass("ForgeHooksClient", forgeAPIForgeHooksClient);
|
||||
data.putClass("IItemRenderer", forgeAPIIItemRenderer);
|
||||
data.putClass("MinecraftForgeClient", forgeAPIMinecraftForgeClient);
|
||||
data.putClass("IItemRenderer$ItemRenderType", forgeAPIIItemRendererItemRenderType);
|
||||
data.putClass("IItemRenderer$ItemRendererHelper", forgeAPIIItemRendererItemRendererHelper);
|
||||
Method m;
|
||||
data.putMethod("ForgeHooksClient.getArmorModel", m = getMethod(forgeAPIForgeHooksClient, "getArmorModel",
|
||||
new Class[] { EntityLivingBase.class, ItemStack.class, Integer.TYPE, ModelBiped.class }));
|
||||
if (m == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Method " + stringMethod(m));
|
||||
data.putMethod("ForgeHooksClient.getArmorTexture",
|
||||
m = getMethod(forgeAPIForgeHooksClient, "getArmorTexture",
|
||||
new Class[] { Entity.class, ItemStack.class, String.class, Integer.TYPE, String.class }));
|
||||
if (m == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Method " + stringMethod(m));
|
||||
data.putMethod("ForgeHooksClient.orientBedCamera", m = getMethod(forgeAPIForgeHooksClient,
|
||||
"orientBedCamera", new Class[] { Minecraft.class, EntityLivingBase.class }));
|
||||
if (m == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Method " + stringMethod(m));
|
||||
data.putMethod("ForgeHooksClient.setRenderPass",
|
||||
m = getMethod(forgeAPIForgeHooksClient, "setRenderPass", new Class[] { Integer.TYPE }));
|
||||
if (m == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Method " + stringMethod(m));
|
||||
data.putMethod("ForgeHooksClient.onDrawBlockHighlight",
|
||||
m = getMethod(forgeAPIForgeHooksClient, "onDrawBlockHighlight",
|
||||
new Class[] { RenderGlobal.class, EntityPlayer.class,
|
||||
MovingObjectPosition.class, Integer.TYPE, ItemStack.class,
|
||||
Float.TYPE }));
|
||||
if (m == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Method " + stringMethod(m));
|
||||
data.putMethod("ForgeHooksClient.dispatchRenderLast",
|
||||
m = getMethod(forgeAPIForgeHooksClient, "dispatchRenderLast",
|
||||
new Class[] { RenderGlobal.class, Float.TYPE }));
|
||||
if (m == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Method " + stringMethod(m));
|
||||
data.putMethod("MinecraftForgeClient.getItemRenderer",
|
||||
m = getMethod(forgeAPIMinecraftForgeClient, "getItemRenderer",
|
||||
new Class[] { ItemStack.class, forgeAPIIItemRendererItemRenderType }));
|
||||
if (m == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Method " + stringMethod(m));
|
||||
data.putMethod("IItemRenderer.shouldUseRenderHelper",
|
||||
m = getMethod(forgeAPIIItemRenderer, "shouldUseRenderHelper",
|
||||
new Class[] { forgeAPIIItemRendererItemRenderType, ItemStack.class,
|
||||
forgeAPIIItemRendererItemRendererHelper }));
|
||||
if (m == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Method " + stringMethod(m));
|
||||
data.putMethod("Item.getRenderPasses", m = getMethod(Item.class,
|
||||
"getRenderPasses", new Class[] { Integer.TYPE }));
|
||||
if (m == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Method " + stringMethod(m));
|
||||
data.putMethod("RenderBiped.getArmorResource",
|
||||
m = getMethod(RenderBiped.class, "getArmorResource",
|
||||
new Class[] { Entity.class, ItemStack.class, Integer.TYPE,
|
||||
String.class }));
|
||||
if (m == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Method " + stringMethod(m));
|
||||
data.putMethod("Entity.canRiderInteract",
|
||||
m = getMethod(Entity.class, "canRiderInteract", new Class[0]));
|
||||
if (m == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Method " + stringMethod(m));
|
||||
data.putMethod("RenderGlobal.drawBlockDamageTexture",
|
||||
m = getMethod(RenderGlobal.class, "drawBlockDamageTexture",
|
||||
new Class[] { Tessellator.class,
|
||||
EntityLivingBase.class, Float.TYPE }));
|
||||
if (m == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Method " + stringMethod(m));
|
||||
Object[] enumConstants1 = forgeAPIIItemRendererItemRenderType
|
||||
.getEnumConstants();
|
||||
Object o1;
|
||||
data.putObject("IItemRenderer$ItemRenderType.ENTITY",
|
||||
o1 = enumConstants1[0]);
|
||||
if (o1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Object " + o1.toString());
|
||||
data.putObject("IItemRenderer$ItemRenderType.EQUIPPED",
|
||||
o1 = enumConstants1[1]);
|
||||
if (o1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Object " + o1.toString());
|
||||
data.putObject(
|
||||
"IItemRenderer$ItemRenderType.EQUIPPED_FIRST_PERSON",
|
||||
o1 = enumConstants1[2]);
|
||||
if (o1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger
|
||||
.debug("ForgeAPI Object " + o1.toString());
|
||||
data.putObject(
|
||||
"IItemRenderer$ItemRenderType.INVENTORY",
|
||||
o1 = enumConstants1[3]);
|
||||
if (o1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug(
|
||||
"ForgeAPI Object " + o1.toString());
|
||||
data.putObject(
|
||||
"IItemRenderer$ItemRenderType.FIRST_PERSON_MAP",
|
||||
o1 = enumConstants1[4]);
|
||||
if (o1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug(
|
||||
"ForgeAPI Object " + o1.toString());
|
||||
enumConstants1 = forgeAPIIItemRendererItemRendererHelper
|
||||
.getEnumConstants();
|
||||
data.putObject(
|
||||
"IItemRenderer$ItemRendererHelper.ENTITY_ROTATION",
|
||||
o1 = enumConstants1[0]);
|
||||
if (o1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug("ForgeAPI Object "
|
||||
+ o1.toString());
|
||||
data.putObject(
|
||||
"IItemRenderer$ItemRendererHelper.ENTITY_BOBBING",
|
||||
o1 = enumConstants1[1]);
|
||||
if (o1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger
|
||||
.debug("ForgeAPI Object "
|
||||
+ o1.toString());
|
||||
data.putObject(
|
||||
"IItemRenderer$ItemRendererHelper.EQUIPPED_BLOCK",
|
||||
o1 = enumConstants1[2]);
|
||||
if (o1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger.debug(
|
||||
"ForgeAPI Object " + o1
|
||||
.toString());
|
||||
data.putObject(
|
||||
"IItemRenderer$ItemRendererHelper.BLOCK_3D",
|
||||
o1 = enumConstants1[3]);
|
||||
if (o1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger
|
||||
.debug("ForgeAPI Object "
|
||||
+ o1.toString());
|
||||
data.putObject(
|
||||
"IItemRenderer$ItemRendererHelper.INVENTORY_BLOCK",
|
||||
o1 = enumConstants1[4]);
|
||||
if (o1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
MineLPLogger
|
||||
.debug("ForgeAPI Object "
|
||||
+ o1.toString());
|
||||
if (forgeAPI
|
||||
.removeNullData()) {
|
||||
MineLPLogger.warn(
|
||||
"ForgeAPI reflection returned some nulls");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?> getClass(String className) {
|
||||
try {
|
||||
return Class.forName(className);
|
||||
} catch (Exception var2) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Constructor<?> getConstructor(Class<?> clazz, Class<?>... types) {
|
||||
try {
|
||||
Constructor<?> e = null;
|
||||
|
||||
try {
|
||||
if (types != null && types.length != 0) {
|
||||
e = clazz.getConstructor(types);
|
||||
} else {
|
||||
e = clazz.getConstructor(new Class[0]);
|
||||
}
|
||||
} catch (Exception var4) {
|
||||
;
|
||||
}
|
||||
|
||||
return e;
|
||||
} catch (Exception var5) {
|
||||
MineLPLogger.error("Failed to match Constructor for class \"%s\"", new Object[] { clazz.getName() });
|
||||
var5.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Field getField(Class<?> clazz, String fieldName) {
|
||||
Object ex = null;
|
||||
|
||||
try {
|
||||
Field e = null;
|
||||
|
||||
try {
|
||||
e = clazz.getField(fieldName);
|
||||
} catch (Exception var5) {
|
||||
e = null;
|
||||
}
|
||||
|
||||
if (e == null) {
|
||||
e = clazz.getDeclaredField(fieldName);
|
||||
}
|
||||
|
||||
e.setAccessible(true);
|
||||
return e;
|
||||
} catch (SecurityException var6) {
|
||||
ex = var6;
|
||||
} catch (NoSuchFieldException var7) {
|
||||
ex = var7;
|
||||
} catch (Exception var8) {
|
||||
ex = var8;
|
||||
}
|
||||
|
||||
if (ex != null) {
|
||||
MineLPLogger.error("Failed to match Field \"%s\" in %s", new Object[] { fieldName, clazz.getName() });
|
||||
((Exception) ex).printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Method getMethod(Class<?> clazz, String methodName, Class<?>... types) {
|
||||
try {
|
||||
Method e = null;
|
||||
|
||||
try {
|
||||
e = clazz.getMethod(methodName, types);
|
||||
} catch (Exception var5) {
|
||||
;
|
||||
}
|
||||
|
||||
if (e == null) {
|
||||
if (types != null && types.length != 0) {
|
||||
e = clazz.getDeclaredMethod(methodName, types);
|
||||
} else {
|
||||
e = clazz.getDeclaredMethod(methodName, new Class[0]);
|
||||
}
|
||||
}
|
||||
|
||||
e.setAccessible(true);
|
||||
return e;
|
||||
} catch (Exception var6) {
|
||||
MineLPLogger.error("Failed to match method \"%s\" in %s", new Object[] { methodName, clazz.getName() });
|
||||
MineLPLogger.error("Types: " + getStringFromTypes(types));
|
||||
var6.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getStringFromTypes(Class<?>... types) {
|
||||
String temp = "";
|
||||
temp = temp + "(";
|
||||
boolean first = true;
|
||||
Class<?>[] var3 = types;
|
||||
int var4 = types.length;
|
||||
|
||||
for (int var5 = 0; var5 < var4; ++var5) {
|
||||
Class<?> c = var3[var5];
|
||||
if (!first) {
|
||||
temp = temp + ",";
|
||||
} else {
|
||||
first = false;
|
||||
}
|
||||
|
||||
temp = temp + c.getName();
|
||||
}
|
||||
|
||||
temp = temp + ")";
|
||||
return temp;
|
||||
}
|
||||
|
||||
public static Class<?>[] getTypesFromObjects(Object... objects) {
|
||||
Class<?>[] types = new Class[objects.length];
|
||||
|
||||
for (int i = 0; i < objects.length; ++i) {
|
||||
types[i] = objects[i].getClass();
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
public static void printClass(Class<?> c) {
|
||||
printClass(c, true);
|
||||
}
|
||||
|
||||
public static void printClass(Class<?> c, boolean declared) {
|
||||
printClass(c, declared, 0);
|
||||
}
|
||||
|
||||
public static void printClass(Class<?> c, boolean declared, int indent) {
|
||||
String indentation = "";
|
||||
int i;
|
||||
if (indent > 0) {
|
||||
char[] lineFormat = new char[indent];
|
||||
|
||||
for (i = 0; i < indent; ++i) {
|
||||
lineFormat[i] = 32;
|
||||
}
|
||||
|
||||
indentation = String.valueOf(lineFormat);
|
||||
}
|
||||
|
||||
String var10 = indentation + "%03d";
|
||||
System.out.println(indentation + c.getName());
|
||||
System.out.println(indentation + "Nested Classes:");
|
||||
Class<?>[] var6 = c.getClasses();
|
||||
int var7 = var6.length;
|
||||
|
||||
int var8;
|
||||
for (var8 = 0; var8 < var7; ++var8) {
|
||||
Class<?> f = var6[var8];
|
||||
printClass(f, declared, indent + 1);
|
||||
}
|
||||
|
||||
System.out.println(indentation + "Constructors:");
|
||||
i = 0;
|
||||
Constructor<?>[] var11 = c.getConstructors();
|
||||
var7 = var11.length;
|
||||
|
||||
for (var8 = 0; var8 < var7; ++var8) {
|
||||
Constructor<?> var14 = var11[var8];
|
||||
System.out.println(
|
||||
String.format(var10, new Object[] { Integer.valueOf(i) }) + " " + stringConstructor(var14));
|
||||
++i;
|
||||
}
|
||||
|
||||
System.out.println(indentation + "Methods:");
|
||||
i = 0;
|
||||
Method[] var12 = c.getMethods();
|
||||
var7 = var12.length;
|
||||
|
||||
Method var15;
|
||||
for (var8 = 0; var8 < var7; ++var8) {
|
||||
var15 = var12[var8];
|
||||
System.out.println(String.format(var10, new Object[] { Integer.valueOf(i) }) + " " + stringMethod(var15));
|
||||
++i;
|
||||
}
|
||||
|
||||
System.out.println(indentation + "Fields:");
|
||||
i = 0;
|
||||
Field[] var13 = c.getFields();
|
||||
var7 = var13.length;
|
||||
|
||||
Field var16;
|
||||
for (var8 = 0; var8 < var7; ++var8) {
|
||||
var16 = var13[var8];
|
||||
System.out.println(String.format(var10, new Object[] { Integer.valueOf(i) }) + " " + stringField(var16));
|
||||
++i;
|
||||
}
|
||||
|
||||
if (declared) {
|
||||
System.out.println(indentation + "Declared Methods:");
|
||||
i = 0;
|
||||
var12 = c.getDeclaredMethods();
|
||||
var7 = var12.length;
|
||||
|
||||
for (var8 = 0; var8 < var7; ++var8) {
|
||||
var15 = var12[var8];
|
||||
System.out
|
||||
.println(String.format(var10, new Object[] { Integer.valueOf(i) }) + " " + stringMethod(var15));
|
||||
++i;
|
||||
}
|
||||
|
||||
System.out.println(indentation + "Declared Fields:");
|
||||
i = 0;
|
||||
var13 = c.getDeclaredFields();
|
||||
var7 = var13.length;
|
||||
|
||||
for (var8 = 0; var8 < var7; ++var8) {
|
||||
var16 = var13[var8];
|
||||
System.out
|
||||
.println(String.format(var10, new Object[] { Integer.valueOf(i) }) + " " + stringField(var16));
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String stringConstructor(Constructor<?> c) {
|
||||
return Modifier.toString(c.getModifiers()) + " " + c.getName() + getStringFromTypes(c.getParameterTypes())
|
||||
+ (c.getExceptionTypes().length > 0 ? " throws " + c.getExceptionTypes() : "");
|
||||
}
|
||||
|
||||
public static String stringMethod(Method m) {
|
||||
return Modifier.toString(m.getModifiers()) + " "
|
||||
+ (m.getReturnType() != null ? m.getReturnType().getName() : "void") + " " + m.getName()
|
||||
+ getStringFromTypes(m.getParameterTypes())
|
||||
+ (m.getExceptionTypes().length > 0 ? " throws " + getStringFromTypes(m.getExceptionTypes()) : "");
|
||||
}
|
||||
|
||||
public static String stringField(Field f) {
|
||||
return Modifier.toString(f.getModifiers()) + " " + f.getType().getName() + " " + f.getName();
|
||||
}
|
||||
|
||||
static {
|
||||
MineLPLogger.info("Checking compatibilities...");
|
||||
forgeAPI = new MineLPRData();
|
||||
forgeAPI.compatible = reflectForgeAPI(forgeAPI);
|
||||
MineLPLogger.info("Compatibility Check Done!");
|
||||
if (forgeAPI.installed) {
|
||||
MineLPLogger.info(
|
||||
"ForgeAPI " + (forgeAPI.compatible ? "Installed and Compatible" : "Installed but Incompatible"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.mumfrey.liteloader.core;
|
||||
|
||||
import com.mumfrey.liteloader.LiteMod;
|
||||
import com.mumfrey.liteloader.core.LiteLoader;
|
||||
import com.mumfrey.liteloader.core.api.LoadableModFileFriend;
|
||||
import java.io.File;
|
||||
|
||||
public abstract class LiteLoaderFriend {
|
||||
public static void loadMod(String identifier, Class<? extends LiteMod> mod, File jarFile) throws InstantiationException, IllegalAccessException {
|
||||
LiteLoader.getInstance().mods.loadMod(identifier, mod, LoadableModFileFriend.getLoadableModFile(jarFile));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.mumfrey.liteloader.core.api;
|
||||
|
||||
import com.mumfrey.liteloader.core.api.LoadableModFile;
|
||||
import com.mumfrey.liteloader.interfaces.LoadableMod;
|
||||
import java.io.File;
|
||||
|
||||
public class LoadableModFileFriend {
|
||||
public static LoadableMod<?> getLoadableModFile(File jarFile) {
|
||||
return new LoadableModFile(jarFile, (String)null);
|
||||
}
|
||||
}
|
133
src/main/java/com/voxelmodpack/common/VoxelCommonLiteMod.java
Normal file
|
@ -0,0 +1,133 @@
|
|||
package com.voxelmodpack.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import com.google.common.io.ByteSink;
|
||||
import com.google.common.io.Files;
|
||||
import com.mumfrey.liteloader.Configurable;
|
||||
import com.mumfrey.liteloader.LiteMod;
|
||||
import com.mumfrey.liteloader.core.LiteLoader;
|
||||
import com.mumfrey.liteloader.core.LiteLoaderFriend;
|
||||
import com.mumfrey.liteloader.launch.ClassPathUtilities;
|
||||
import com.mumfrey.liteloader.modconfig.ConfigManager;
|
||||
import com.mumfrey.liteloader.modconfig.ConfigPanel;
|
||||
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
|
||||
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
|
||||
public abstract class VoxelCommonLiteMod implements LiteMod, Configurable {
|
||||
private String bundledJarName = "voxelcommon-2.3.1.jar";
|
||||
private final String voxelCommonClassName = "com.voxelmodpack.common.LiteModVoxelCommon";
|
||||
private final String modClassName;
|
||||
private LiteMod mod;
|
||||
|
||||
public VoxelCommonLiteMod(String modClassName) {
|
||||
this.bundledJarName = LiteLoader.getInstance().getModMetaData(this, "voxelCommonJarName", this.bundledJarName);
|
||||
this.modClassName = modClassName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(File configPath) {
|
||||
try {
|
||||
this.getClass();
|
||||
Class.forName(voxelCommonClassName, false, Launch.class.getClassLoader());
|
||||
} catch (Throwable var4) {
|
||||
this.getClass();
|
||||
if (!this.extractAndInjectMod("VoxelLib", voxelCommonClassName, this.bundledJarName,
|
||||
Files.createTempDir())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Class<?> th = Class.forName(this.modClassName);
|
||||
this.mod = (LiteMod) th.newInstance();
|
||||
this.mod.init(configPath);
|
||||
if (this.mod instanceof Configurable && ((Configurable) this.mod).getConfigPanelClass() != null) {
|
||||
this.registerConfigurable();
|
||||
}
|
||||
|
||||
LiteLoader.getInterfaceManager().registerListener(this.mod);
|
||||
} catch (Throwable var3) {
|
||||
var3.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void registerConfigurable()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
Field configManagerField = LiteLoader.class.getDeclaredField("configManager");
|
||||
configManagerField.setAccessible(true);
|
||||
ConfigManager mgr = (ConfigManager) configManagerField.get(LiteLoader.getInstance());
|
||||
mgr.registerMod(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends ConfigPanel> getConfigPanelClass() {
|
||||
return this.mod != null && this.mod instanceof Configurable ? ((Configurable) this.mod).getConfigPanelClass()
|
||||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradeSettings(String version, File configPath, File oldConfigPath) {
|
||||
if (this.mod != null) {
|
||||
this.mod.upgradeSettings(version, configPath, oldConfigPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean extractAndInjectMod(String libraryName, String className, String resourceName, File libPath) {
|
||||
if ("true".equals(System.getProperty("VoxelCommon.Injected"))) {
|
||||
LiteLoaderLogger.warning("%s jar was already injected, skipping injection.", libraryName);
|
||||
return true;
|
||||
} else {
|
||||
File jarFile = new File(libPath, resourceName);
|
||||
if (!jarFile.exists()) {
|
||||
LiteLoaderLogger.info("%s jar does not exist, attempting to extract to %s",
|
||||
libraryName, libPath.getAbsolutePath());
|
||||
if (!extractFile("/" + resourceName, jarFile)) {
|
||||
LiteLoaderLogger.warning("%s jar could not be extracted, %s may not function correctly (or at all)",
|
||||
libraryName, this.getName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (jarFile.exists()) {
|
||||
LiteLoaderLogger.info("%s jar exists, attempting to inject into classpath", libraryName);
|
||||
|
||||
try {
|
||||
ClassPathUtilities.injectIntoClassPath(Launch.classLoader, jarFile.toURI().toURL());
|
||||
LiteLoaderFriend.loadMod(libraryName, (Class<? extends LiteMod>) Class.forName(className), jarFile);
|
||||
} catch (Exception var7) {
|
||||
var7.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
System.setProperty("VoxelCommon.Injected", "true");
|
||||
LiteLoaderLogger.info("%s jar was successfully extracted", libraryName);
|
||||
return true;
|
||||
} else {
|
||||
LiteLoaderLogger.warning("%s jar was not detected, %s may not function correctly (or at all)",
|
||||
libraryName, this.getName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean extractFile(String resourceName, File outputFile) {
|
||||
try {
|
||||
InputStream ex = VoxelCommonLiteMod.class.getResourceAsStream(resourceName);
|
||||
ByteSink sink = Files.asByteSink(outputFile);
|
||||
sink.writeFrom(ex);
|
||||
return true;
|
||||
} catch (NullPointerException var4) {
|
||||
return false;
|
||||
} catch (IOException var5) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
33
src/main/java/com/voxelmodpack/hdskins/HDPrivateFields.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package com.voxelmodpack.hdskins;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import com.mumfrey.liteloader.core.runtime.Obf;
|
||||
import com.mumfrey.liteloader.util.PrivateFields;
|
||||
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
|
||||
public class HDPrivateFields<P, T> extends PrivateFields<P, T> {
|
||||
|
||||
public static PrivateFields<SkinManager, Cache<GameProfile, Map<Type, MinecraftProfileTexture>>> skinCacheLoader = new HDPrivateFields<SkinManager, Cache<GameProfile, Map<Type, MinecraftProfileTexture>>>(
|
||||
SkinManager.class, HDObf.skinLoadingCache);
|
||||
|
||||
protected HDPrivateFields(Class<P> owner, Obf obf) {
|
||||
super(owner, obf);
|
||||
}
|
||||
|
||||
private static class HDObf extends Obf {
|
||||
private static Obf skinLoadingCache = new HDObf("field_152798_f", "e", "skinCacheLoader");
|
||||
|
||||
protected HDObf(String seargeName, String obfName, String mcpName) {
|
||||
super(seargeName, obfName, mcpName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
70
src/main/java/com/voxelmodpack/hdskins/HDSkinDownload.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.voxelmodpack.hdskins;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
|
||||
import com.voxelmodpack.common.runtime.PrivateFields;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
|
||||
class HDSkinDownload extends Thread {
|
||||
private final ThreadDownloadImageData image;
|
||||
private final IImageBuffer imageBuffer;
|
||||
private final String skinUrl;
|
||||
private final Thread originalThread;
|
||||
|
||||
HDSkinDownload(ThreadDownloadImageData image, IImageBuffer imageBuffer, String url) {
|
||||
this.image = image;
|
||||
this.imageBuffer = imageBuffer != null ? imageBuffer : (IImageBuffer) PrivateFields.imageBuffer.get(image);
|
||||
this.originalThread = PrivateFields.imageThread.get(image);
|
||||
this.skinUrl = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Proxy proxy = Minecraft.getMinecraft().getProxy();
|
||||
if (!this.tryDownload(proxy, this.skinUrl) && this.originalThread != null) {
|
||||
this.originalThread.run();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
boolean tryDownload(Proxy proxy, String strUrl) {
|
||||
HttpURLConnection httpConnection = null;
|
||||
|
||||
try {
|
||||
LiteLoaderLogger.debug("Downloading HD Skin from %s", strUrl);
|
||||
URL ex = new URL(strUrl);
|
||||
httpConnection = (HttpURLConnection) ex.openConnection(proxy);
|
||||
httpConnection.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
|
||||
httpConnection.setDoInput(true);
|
||||
httpConnection.setDoOutput(false);
|
||||
httpConnection.connect();
|
||||
if (httpConnection.getResponseCode() / 100 == 2) {
|
||||
BufferedImage image1 = ImageIO.read(httpConnection.getInputStream());
|
||||
if (this.imageBuffer != null) {
|
||||
image1 = this.imageBuffer.parseUserSkin(image1);
|
||||
}
|
||||
|
||||
this.image.setBufferedImage(image1);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception var10) {
|
||||
return false;
|
||||
} finally {
|
||||
if (httpConnection != null) {
|
||||
httpConnection.disconnect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
234
src/main/java/com/voxelmodpack/hdskins/HDSkinManager.java
Normal file
|
@ -0,0 +1,234 @@
|
|||
package com.voxelmodpack.hdskins;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.InsecureTextureException;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mumfrey.liteloader.core.LiteLoader;
|
||||
import com.mumfrey.liteloader.transformers.event.EventInfo;
|
||||
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
|
||||
import com.voxelmodpack.common.runtime.PrivateFields;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
public final class HDSkinManager {
|
||||
private static String gatewayUrl = "skinmanager.voxelmodpack.com";
|
||||
private static String skinUrl = "skins.voxelmodpack.com";
|
||||
private static Cache<GameProfile, Map<Type, MinecraftProfileTexture>> skinsCache;
|
||||
private static final BiMap<String, String> playerHashes = HashBiMap.create();
|
||||
private static final Map<String, Map<Type, MinecraftProfileTexture>> cachedTextures = new HashMap<String, Map<Type, MinecraftProfileTexture>>();
|
||||
|
||||
public static void onDownloadSkin(EventInfo<ThreadDownloadImageData> e) {
|
||||
ThreadDownloadImageData imageDownload = e.getSource();
|
||||
if (imageDownload != null) {
|
||||
String imageUrl = PrivateFields.imageUrl.get(imageDownload);
|
||||
if (imageUrl != null) {
|
||||
String hash = FilenameUtils.getBaseName(imageUrl);
|
||||
String uuid = resolvePlayerIdFromHash(hash);
|
||||
if (uuid == null) {
|
||||
if (!(imageDownload instanceof PreviewTexture)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uuid = Minecraft.getMinecraft().getSession().getPlayerID();
|
||||
}
|
||||
|
||||
Map<Type, MinecraftProfileTexture> textures = getCachedTexturesForId(uuid);
|
||||
MinecraftProfileTexture skinTexture = textures.get(Type.SKIN);
|
||||
if (skinTexture != null && skinTexture.getUrl().equals(imageUrl)) {
|
||||
Thread imageThread = PrivateFields.imageThread.get(imageDownload);
|
||||
if (imageThread != null) {
|
||||
HDSkinDownload hdThread = new HDSkinDownload(imageDownload, new ImageBufferDownloadHD(),
|
||||
getCustomSkinURLForId(uuid, imageDownload instanceof PreviewTexture));
|
||||
PrivateFields.imageThread.set(imageDownload, hdThread);
|
||||
hdThread.setDaemon(true);
|
||||
hdThread.start();
|
||||
e.cancel();
|
||||
}
|
||||
} else {
|
||||
LiteLoaderLogger.debug("Not a skin texture!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String resolvePlayerIdFromHash(String hash) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
Collection<NetworkPlayerInfo> playersInfo = mc.getNetHandler().func_175106_d();
|
||||
String uuid;
|
||||
// players
|
||||
for (NetworkPlayerInfo player : playersInfo) {
|
||||
GameProfile profile = player.getGameProfile();
|
||||
Map<Type, MinecraftProfileTexture> textures = getTexturesForProfile(mc, profile);
|
||||
storeTexturesForProfile(profile, textures);
|
||||
uuid = findUUID(profile, textures, hash);
|
||||
if (uuid != null)
|
||||
return uuid;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
List<EntityPlayer> players = mc.theWorld.playerEntities;
|
||||
for (EntityPlayer player : players) {
|
||||
GameProfile profile = player.getGameProfile();
|
||||
Map<Type, MinecraftProfileTexture> textures = getTexturesForProfile(mc, profile);
|
||||
storeTexturesForProfile(profile, textures);
|
||||
uuid = findUUID(profile, textures, hash);
|
||||
if (uuid != null)
|
||||
return uuid;
|
||||
}
|
||||
// skulls
|
||||
for (Entry<GameProfile, Map<Type, MinecraftProfileTexture>> e : getSkinsCache().asMap().entrySet()) {
|
||||
GameProfile profile = e.getKey();
|
||||
Map<Type, MinecraftProfileTexture> textures = e.getValue();
|
||||
storeTexturesForProfile(profile, textures);
|
||||
uuid = findUUID(profile, textures, hash);
|
||||
if (uuid != null)
|
||||
return uuid;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String findUUID(GameProfile profile, Map<?, MinecraftProfileTexture> textures, String hash) {
|
||||
for (MinecraftProfileTexture texture : textures.values()) {
|
||||
if (hash.equals(texture.getHash())) {
|
||||
String uuid = trimUUID(profile.getId());
|
||||
playerHashes.put(hash, uuid);
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void storeTexturesForProfile(GameProfile profile, Map<Type, MinecraftProfileTexture> textures) {
|
||||
Map<?, ?> cached = getCachedTexturesForId(trimUUID(profile.getId()));
|
||||
if (cached == null && textures != null && !textures.isEmpty()) {
|
||||
LiteLoaderLogger.debug("Store textures for " + profile.getId());
|
||||
cachedTextures.put(trimUUID(profile.getId()), textures);
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<Type, MinecraftProfileTexture> getTexturesForProfile(Minecraft minecraft, GameProfile profile) {
|
||||
LiteLoaderLogger.debug("Get textures for " + profile.getId(), new Object[0]);
|
||||
Map<Type, MinecraftProfileTexture> cached = getCachedTexturesForId(trimUUID(profile.getId()));
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
} else {
|
||||
MinecraftSessionService sessionService = minecraft.getSessionService();
|
||||
Map<Type, MinecraftProfileTexture> textures = null;
|
||||
|
||||
try {
|
||||
textures = sessionService.getTextures(profile, true);
|
||||
} catch (InsecureTextureException var6) {
|
||||
textures = sessionService.getTextures(profile, false);
|
||||
}
|
||||
|
||||
if ((textures == null || textures.isEmpty())
|
||||
&& profile.getId().equals(minecraft.getSession().getProfile().getId())) {
|
||||
textures = sessionService.getTextures(sessionService.fillProfileProperties(profile, false), false);
|
||||
}
|
||||
|
||||
storeTexturesForProfile(profile, textures);
|
||||
|
||||
return textures;
|
||||
}
|
||||
}
|
||||
|
||||
private static Cache<GameProfile, Map<Type, MinecraftProfileTexture>> getSkinsCache() {
|
||||
if (skinsCache == null) {
|
||||
// final field isn't going to change
|
||||
skinsCache = HDPrivateFields.skinCacheLoader.get(Minecraft.getMinecraft().getSkinManager());
|
||||
}
|
||||
return skinsCache;
|
||||
}
|
||||
|
||||
private static Map<Type, MinecraftProfileTexture> getCachedTexturesForId(String uuid) {
|
||||
return cachedTextures.get(uuid);
|
||||
}
|
||||
|
||||
private static String trimUUID(UUID uuid) {
|
||||
return uuid.toString().replace("-", "");
|
||||
}
|
||||
|
||||
public static void setSkinUrl(String skinUrl) {
|
||||
HDSkinManager.skinUrl = skinUrl;
|
||||
}
|
||||
|
||||
public static void setGatewayURL(String gatewayURL) {
|
||||
gatewayUrl = gatewayURL;
|
||||
}
|
||||
|
||||
public static String getSkinUrl() {
|
||||
return String.format("http://%s/", skinUrl);
|
||||
}
|
||||
|
||||
public static String getGatewayUrl() {
|
||||
return String.format("http://%s/", gatewayUrl);
|
||||
}
|
||||
|
||||
public static String getCustomSkinURLForId(String uuid, boolean gateway) {
|
||||
uuid = StringUtils.stripControlCodes(uuid);
|
||||
return String.format("http://%s/skins/%s.png", gateway ? gatewayUrl : skinUrl, uuid);
|
||||
}
|
||||
|
||||
public static String getCustomCloakURLForId(String uuid) {
|
||||
return String.format("http://%s/capes/%s.png", skinUrl, StringUtils.stripControlCodes(uuid));
|
||||
}
|
||||
|
||||
public static PreviewTexture getPreviewTexture(ResourceLocation skinResource, GameProfile profile) {
|
||||
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||
Object skinTexture = textureManager.getTexture(skinResource);
|
||||
if (skinTexture == null) {
|
||||
Map<Type, MinecraftProfileTexture> textures = getTexturesForProfile(Minecraft.getMinecraft(), profile);
|
||||
MinecraftProfileTexture skin = textures.get(Type.SKIN);
|
||||
if (skin == null) {
|
||||
throw new RuntimeException("Could not get player skin URL from profile");
|
||||
}
|
||||
|
||||
String url = skin.getUrl();
|
||||
skinTexture = new PreviewTexture(url, DefaultPlayerSkin.getDefaultSkin(profile.getId()),
|
||||
new ImageBufferDownloadHD());
|
||||
textureManager.loadTexture(skinResource, (ITextureObject) skinTexture);
|
||||
}
|
||||
|
||||
return (PreviewTexture) skinTexture;
|
||||
}
|
||||
|
||||
public static void clearSkinCache() {
|
||||
LiteLoaderLogger.info("Clearing local player skin cache", new Object[0]);
|
||||
|
||||
try {
|
||||
FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "skins"));
|
||||
} catch (IOException var1) {
|
||||
var1.printStackTrace();
|
||||
}
|
||||
// clear the maps, too
|
||||
getSkinsCache().invalidateAll();
|
||||
cachedTextures.clear();
|
||||
playerHashes.clear();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.voxelmodpack.hdskins;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
|
||||
public class ImageBufferDownloadHD implements IImageBuffer {
|
||||
|
||||
private int scale;
|
||||
private Graphics graphics;
|
||||
private BufferedImage image;
|
||||
|
||||
@Override
|
||||
public BufferedImage parseUserSkin(BufferedImage downloadedImage) {
|
||||
if (downloadedImage == null) {
|
||||
return null;
|
||||
} else {
|
||||
int imageWidth = downloadedImage.getWidth();
|
||||
int imageHeight = downloadedImage.getHeight();
|
||||
if (imageHeight == imageWidth) {
|
||||
return downloadedImage;
|
||||
} else {
|
||||
scale = imageWidth / 64;
|
||||
image = new BufferedImage(imageWidth, imageWidth, BufferedImage.TYPE_INT_ARGB);
|
||||
graphics = image.getGraphics();
|
||||
graphics.drawImage(downloadedImage, 0, 0, (ImageObserver) null);
|
||||
|
||||
// copy layers
|
||||
drawImage(24, 48, 20, 52, 4, 16, 8, 20);
|
||||
drawImage(28, 48, 24, 52, 8, 16, 12, 20);
|
||||
drawImage(20, 52, 16, 64, 8, 20, 12, 32);
|
||||
drawImage(24, 52, 20, 64, 4, 20, 8, 32);
|
||||
drawImage(28, 52, 24, 64, 0, 20, 4, 32);
|
||||
drawImage(32, 52, 28, 64, 12, 20, 16, 32);
|
||||
drawImage(40, 48, 36, 52, 44, 16, 48, 20);
|
||||
drawImage(44, 48, 40, 52, 48, 16, 52, 20);
|
||||
drawImage(36, 52, 32, 64, 48, 20, 52, 32);
|
||||
drawImage(40, 52, 36, 64, 44, 20, 48, 32);
|
||||
drawImage(44, 52, 40, 64, 40, 20, 44, 32);
|
||||
drawImage(48, 52, 44, 64, 52, 20, 56, 32);
|
||||
|
||||
graphics.dispose();
|
||||
return image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawImage(int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2) {
|
||||
graphics.drawImage(image,
|
||||
dx1 * scale, dy1 * scale, dx2 * scale, dy2 * scale,
|
||||
sx1 * scale, sy1 * scale, sx2 * scale, sy2 * scale,
|
||||
null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skinAvailable() {}
|
||||
}
|
19
src/main/java/com/voxelmodpack/hdskins/PreviewTexture.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package com.voxelmodpack.hdskins;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.voxelmodpack.common.runtime.PrivateFields;
|
||||
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class PreviewTexture extends ThreadDownloadImageData {
|
||||
public PreviewTexture(String url, ResourceLocation fallbackTexture, IImageBuffer imageBuffer) {
|
||||
super((File) null, url, fallbackTexture, imageBuffer);
|
||||
}
|
||||
|
||||
public boolean isTextureUploaded() {
|
||||
return PrivateFields.downloadedImage.get(this) != null && this.getGlTextureId() > -1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
package com.voxelmodpack.hdskins.gui;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.voxelmodpack.common.gl.TextureHelper;
|
||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||
import com.voxelmodpack.hdskins.PreviewTexture;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityPlayerModel extends EntityLiving {
|
||||
public static final ResourceLocation NOSKIN = new ResourceLocation("hdskins", "textures/mob/noskin.png");
|
||||
private PreviewTexture remoteSkinTexture;
|
||||
private ResourceLocation remoteSkinResource;
|
||||
private ResourceLocation localSkinResource;
|
||||
private DynamicTexture localSkinTexture;
|
||||
private TextureManager textureManager;
|
||||
public final GameProfile profile;
|
||||
public boolean isSwinging = false;
|
||||
protected boolean remoteSkin = false;
|
||||
protected boolean hasLocalTexture = false;
|
||||
|
||||
public EntityPlayerModel(GameProfile profile) {
|
||||
super((World) null);
|
||||
this.profile = profile;
|
||||
this.textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||
this.remoteSkinResource = new ResourceLocation("skins/preview_" + this.profile.getName() + ".png");
|
||||
this.localSkinResource = NOSKIN;
|
||||
TextureHelper.releaseTexture(this.remoteSkinResource);
|
||||
}
|
||||
|
||||
public void setRemoteSkin() {
|
||||
this.remoteSkin = true;
|
||||
if (this.remoteSkinTexture != null) {
|
||||
TextureHelper.releaseTexture(this.remoteSkinResource);
|
||||
}
|
||||
|
||||
this.remoteSkinTexture = HDSkinManager.getPreviewTexture(this.remoteSkinResource, this.profile);
|
||||
}
|
||||
|
||||
public void setLocalSkin(File skinTextureFile) {
|
||||
if (skinTextureFile.exists()) {
|
||||
this.remoteSkin = false;
|
||||
if (this.localSkinTexture != null) {
|
||||
TextureHelper.releaseTexture(this.localSkinResource);
|
||||
this.localSkinTexture = null;
|
||||
}
|
||||
|
||||
BufferedImage bufferedImage;
|
||||
try {
|
||||
bufferedImage = ImageIO.read(skinTextureFile);
|
||||
} catch (IOException var4) {
|
||||
this.localSkinResource = NOSKIN;
|
||||
var4.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
this.localSkinTexture = new DynamicTexture(bufferedImage);
|
||||
this.localSkinResource = this.textureManager.getDynamicTextureLocation("localSkinPreview",
|
||||
this.localSkinTexture);
|
||||
this.hasLocalTexture = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean usingRemoteSkin() {
|
||||
return this.remoteSkin;
|
||||
}
|
||||
|
||||
public boolean isUsingLocalTexture() {
|
||||
return !this.remoteSkin && this.hasLocalTexture;
|
||||
}
|
||||
|
||||
public float d(float par1) {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
public boolean isTextureSetupComplete() {
|
||||
return this.remoteSkin && this.remoteSkinTexture != null ? this.remoteSkinTexture.isTextureUploaded() : false;
|
||||
}
|
||||
|
||||
public void releaseTextures() {
|
||||
if (this.localSkinTexture != null) {
|
||||
TextureHelper.releaseTexture(this.localSkinResource);
|
||||
this.localSkinTexture = null;
|
||||
this.localSkinResource = NOSKIN;
|
||||
this.hasLocalTexture = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ResourceLocation getSkinTexture() {
|
||||
return this.remoteSkin ? (this.remoteSkinTexture != null ? this.remoteSkinResource
|
||||
: DefaultPlayerSkin.getDefaultSkin(entityUniqueID)) : this.localSkinResource;
|
||||
}
|
||||
|
||||
public boolean hasCloak() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void swingArm() {
|
||||
if (!this.isSwinging || this.swingProgressInt >= 4 || this.swingProgressInt < 0) {
|
||||
this.swingProgressInt = -1;
|
||||
this.isSwinging = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateModel() {
|
||||
this.prevSwingProgress = this.swingProgress;
|
||||
if (this.isSwinging) {
|
||||
++this.swingProgressInt;
|
||||
if (this.swingProgressInt >= 8) {
|
||||
this.swingProgressInt = 0;
|
||||
this.isSwinging = false;
|
||||
}
|
||||
} else {
|
||||
this.swingProgressInt = 0;
|
||||
}
|
||||
|
||||
this.swingProgress = this.swingProgressInt / 8.0F;
|
||||
}
|
||||
}
|
638
src/main/java/com/voxelmodpack/hdskins/gui/GuiSkins.java
Normal file
|
@ -0,0 +1,638 @@
|
|||
package com.voxelmodpack.hdskins.gui;
|
||||
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.DoubleBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.exceptions.AuthenticationException;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
||||
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
|
||||
import com.voxelmodpack.common.net.upload.IUploadCompleteCallback;
|
||||
import com.voxelmodpack.common.net.upload.ThreadMultipartPostUpload;
|
||||
import com.voxelmodpack.common.net.upload.awt.IOpenFileCallback;
|
||||
import com.voxelmodpack.common.net.upload.awt.ThreadOpenFilePNG;
|
||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||
import com.voxelmodpack.hdskins.mod.HDSkinsModCore;
|
||||
import com.voxelmodpack.voxelmenu.IPanoramaRenderer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Session;
|
||||
|
||||
public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpenFileCallback, IPanoramaRenderer {
|
||||
private static final ResourceLocation vignette = new ResourceLocation("textures/misc/vignette.png");
|
||||
private static final int MAX_SKIN_DIMENSION = 8192;
|
||||
private static final String skinServerId = "7853dfddc358333843ad55a2c7485c4aa0380a51";
|
||||
private int updateCounter = 0;
|
||||
private ResourceLocation viewportTexture;
|
||||
private IPanoramaRenderer panoramaRenderer;
|
||||
private static final ResourceLocation[] cubemapTextures = {
|
||||
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_0.png"),
|
||||
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_1.png"),
|
||||
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_2.png"),
|
||||
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_3.png"),
|
||||
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_4.png"),
|
||||
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_5.png") };
|
||||
private GuiButton btnBrowse;
|
||||
private GuiButton btnUpload;
|
||||
private GuiButton btnClear;
|
||||
private GuiButton btnBack;
|
||||
protected EntityPlayerModel localPlayer;
|
||||
protected EntityPlayerModel remotePlayer;
|
||||
protected DoubleBuffer doubleBuffer;
|
||||
private String screenTitle;
|
||||
private String uploadError;
|
||||
private volatile String skinMessage = "Choose a file";
|
||||
private String skinUploadMessage = "Uploading skin please wait...";
|
||||
private volatile boolean fetchingSkin;
|
||||
private volatile boolean uploadingSkin;
|
||||
private volatile boolean pendingRemoteSkinRefresh;
|
||||
private volatile boolean throttledByMojang;
|
||||
private ThreadOpenFilePNG openFileThread;
|
||||
private ThreadMultipartPostUpload threadSkinUpload;
|
||||
private Object skinLock = new Object();
|
||||
private File pendingSkin;
|
||||
private File selectedSkin;
|
||||
private float uploadOpacity = 0.0F;
|
||||
private float lastPartialTick;
|
||||
|
||||
public GuiSkins() {
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
this.screenTitle = "Skin Manager";
|
||||
GameProfile profile = minecraft.getSession().getProfile();
|
||||
this.localPlayer = new EntityPlayerModel(profile);
|
||||
this.remotePlayer = new EntityPlayerModel(profile);
|
||||
RenderManager rm = Minecraft.getMinecraft().getRenderManager();
|
||||
rm.renderEngine = minecraft.getTextureManager();
|
||||
rm.options = minecraft.gameSettings;
|
||||
rm.livingPlayer = this.localPlayer;
|
||||
|
||||
try {
|
||||
this.remotePlayer.setRemoteSkin();
|
||||
} catch (Exception var4) {
|
||||
var4.printStackTrace();
|
||||
this.throttledByMojang = true;
|
||||
}
|
||||
|
||||
this.fetchingSkin = true;
|
||||
this.panoramaRenderer = HDSkinsModCore.getPanoramaRenderer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
++this.updateCounter;
|
||||
this.panoramaRenderer.updatePanorama();
|
||||
this.localPlayer.updateModel();
|
||||
this.remotePlayer.updateModel();
|
||||
if (this.fetchingSkin && this.remotePlayer.isTextureSetupComplete()) {
|
||||
this.fetchingSkin = false;
|
||||
this.btnClear.enabled = true;
|
||||
}
|
||||
|
||||
synchronized (this.skinLock) {
|
||||
if (this.pendingSkin != null) {
|
||||
this.setLocalSkin(this.pendingSkin);
|
||||
this.selectedSkin = this.pendingSkin;
|
||||
this.pendingSkin = null;
|
||||
}
|
||||
}
|
||||
|
||||
this.btnUpload.enabled = this.selectedSkin != null;
|
||||
if (this.pendingRemoteSkinRefresh) {
|
||||
this.pendingRemoteSkinRefresh = false;
|
||||
this.fetchingSkin = true;
|
||||
this.btnClear.enabled = false;
|
||||
this.setRemoteSkin();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void setLocalSkin(File pendingSkin) {
|
||||
this.localPlayer.setLocalSkin(pendingSkin);
|
||||
}
|
||||
|
||||
protected void setRemoteSkin() {
|
||||
this.remotePlayer.setRemoteSkin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePanorama() {}
|
||||
|
||||
@Override
|
||||
public int getUpdateCounter() {
|
||||
return this.updateCounter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorldAndResolution(Minecraft par1Minecraft, int par2, int par3) {
|
||||
super.setWorldAndResolution(par1Minecraft, par2, par3);
|
||||
this.panoramaRenderer.setPanoramaResolution(par1Minecraft, par2, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPanoramaResolution(Minecraft minecraft, int width, int height) {}
|
||||
|
||||
protected List<GuiButton> getControlList() {
|
||||
return this.buttonList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.panoramaRenderer.initPanoramaRenderer();
|
||||
this.getControlList().clear();
|
||||
this.getControlList().add(this.btnBrowse = new GuiButton(0, 30, this.height - 36, 60, 20, "Browse..."));
|
||||
this.getControlList()
|
||||
.add(this.btnUpload = new GuiButton(1, this.width / 2 - 24, this.height / 2 - 10, 48, 20, ">>"));
|
||||
this.getControlList().add(this.btnClear = new GuiButton(2, this.width - 90, this.height - 36, 60, 20, "Clear"));
|
||||
this.getControlList()
|
||||
.add(this.btnBack = new GuiButton(3, this.width / 2 - 50, this.height - 36, 100, 20, "Close"));
|
||||
this.btnUpload.enabled = false;
|
||||
this.btnBrowse.enabled = !this.mc.isFullScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initPanoramaRenderer() {
|
||||
this.viewportTexture = this.mc.getTextureManager().getDynamicTextureLocation("skinpanorama",
|
||||
new DynamicTexture(256, 256));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
this.localPlayer.releaseTextures();
|
||||
this.remotePlayer.releaseTextures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileOpenDialogClosed(JFileChooser fileDialog, int dialogResult) {
|
||||
this.openFileThread = null;
|
||||
|
||||
try {
|
||||
if (dialogResult == 0) {
|
||||
File ex = fileDialog.getSelectedFile();
|
||||
if (!ex.exists()) {
|
||||
this.skinMessage = "File not readable";
|
||||
return;
|
||||
}
|
||||
|
||||
BufferedImage chosenImage = ImageIO.read(ex);
|
||||
if (!isPowerOfTwo(chosenImage.getWidth())
|
||||
|| (chosenImage.getWidth() != chosenImage.getHeight() * 2
|
||||
&& chosenImage.getWidth() != chosenImage.getHeight())
|
||||
|| chosenImage.getWidth() > MAX_SKIN_DIMENSION
|
||||
|| chosenImage.getHeight() > MAX_SKIN_DIMENSION) {
|
||||
this.skinMessage = "Not a valid skin file";
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (this.skinLock) {
|
||||
this.pendingSkin = ex;
|
||||
}
|
||||
}
|
||||
} catch (Exception var8) {
|
||||
this.skinMessage = "Error opening skin file";
|
||||
var8.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guiButton) {
|
||||
if (this.openFileThread == null && !this.uploadingSkin) {
|
||||
if (this.uploadError != null) {
|
||||
this.uploadError = null;
|
||||
} else {
|
||||
if (guiButton.id == this.btnBrowse.id) {
|
||||
this.selectedSkin = null;
|
||||
this.localPlayer.releaseTextures();
|
||||
this.openFileThread = new ThreadOpenFilePNG(this.mc, "Choose skin", this);
|
||||
this.openFileThread.start();
|
||||
}
|
||||
|
||||
if (guiButton.id == this.btnUpload.id && this.selectedSkin != null) {
|
||||
this.uploadSkin(this.mc.getSession(), this.selectedSkin);
|
||||
this.selectedSkin = null;
|
||||
}
|
||||
|
||||
if (guiButton.id == this.btnClear.id && this.remotePlayer.isTextureSetupComplete()) {
|
||||
this.clearUploadedSkin(this.mc.getSession());
|
||||
}
|
||||
|
||||
if (guiButton.id == this.btnBack.id) {
|
||||
this.mc.displayGuiScreen(new GuiMainMenu());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException {
|
||||
if (this.uploadError != null) {
|
||||
this.uploadError = null;
|
||||
} else {
|
||||
super.mouseClicked(mouseX, mouseY, button);
|
||||
byte top = 30;
|
||||
int bottom = this.height - 40;
|
||||
int mid = this.width / 2;
|
||||
if ((mouseX > 30 && mouseX < mid - 30 || mouseX > mid + 30 && mouseX < this.width - 30) && mouseY > top
|
||||
&& mouseY < bottom) {
|
||||
this.localPlayer.swingArm();
|
||||
} else if (mouseX > mid + 30 && mouseY > top && mouseX < this.width - 30 && mouseY < bottom) {
|
||||
this.remotePlayer.swingArm();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char keyChar, int keyCode) throws IOException {
|
||||
if (this.openFileThread == null && !this.uploadingSkin) {
|
||||
super.keyTyped(keyChar, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
public void setupCubemapCamera() {
|
||||
matrixMode(5889);
|
||||
pushMatrix();
|
||||
loadIdentity();
|
||||
GLU.gluPerspective(150.0F, 1.0F, 0.05F, 10.0F);
|
||||
matrixMode(5888);
|
||||
pushMatrix();
|
||||
loadIdentity();
|
||||
}
|
||||
|
||||
public void revertPanoramaMatrix() {
|
||||
matrixMode(5889);
|
||||
popMatrix();
|
||||
matrixMode(5888);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
private void renderCubeMapTexture(int mouseX, int mouseY, float partialTick) {
|
||||
this.setupCubemapCamera();
|
||||
color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
rotate(180.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glDisable(3008);
|
||||
GL11.glDisable(2884);
|
||||
depthMask(false);
|
||||
blendFunc(770, 771);
|
||||
byte blendIterations = 8;
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer wr = tessellator.getWorldRenderer();
|
||||
|
||||
for (int blendPass = 0; blendPass < blendIterations * blendIterations; ++blendPass) {
|
||||
pushMatrix();
|
||||
float offsetX = ((float) (blendPass % blendIterations) / (float) blendIterations - 0.5F) / 64.0F;
|
||||
float offsetY = ((float) (blendPass / blendIterations) / (float) blendIterations - 0.5F) / 64.0F;
|
||||
float offsetZ = 0.0F;
|
||||
translate(offsetX, offsetY, offsetZ);
|
||||
rotate(MathHelper.sin((this.updateCounter + 200 + partialTick) / 400.0F) * 25.0F + 20.0F, 1.0F,
|
||||
0.0F, 0.0F);
|
||||
rotate(-(this.updateCounter + 200 + partialTick) * 0.1F, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
for (int cubeSide = 0; cubeSide < 6; ++cubeSide) {
|
||||
pushMatrix();
|
||||
if (cubeSide == 1) {
|
||||
rotate(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (cubeSide == 2) {
|
||||
rotate(180.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (cubeSide == 3) {
|
||||
rotate(-90.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (cubeSide == 4) {
|
||||
rotate(90.0F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (cubeSide == 5) {
|
||||
rotate(-90.0F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
this.mc.getTextureManager().bindTexture(cubemapTextures[cubeSide]);
|
||||
wr.startDrawingQuads();
|
||||
wr.setColorRGBA_I(16777215, 255 / (blendPass + 1));
|
||||
wr.addVertexWithUV(-1.0D, -1.0D, 1.0D, 0.0D, 0.0D);
|
||||
wr.addVertexWithUV(1.0D, -1.0D, 1.0D, 1.0D, 0.0D);
|
||||
wr.addVertexWithUV(1.0D, 1.0D, 1.0D, 1.0D, 1.0D);
|
||||
wr.addVertexWithUV(-1.0D, 1.0D, 1.0D, 0.0D, 1.0D);
|
||||
tessellator.draw();
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
popMatrix();
|
||||
colorMask(true, true, true, false);
|
||||
}
|
||||
|
||||
wr.setTranslation(0.0D, 0.0D, 0.0D);
|
||||
colorMask(true, true, true, true);
|
||||
depthMask(true);
|
||||
GL11.glEnable(2884);
|
||||
GL11.glEnable(3008);
|
||||
GL11.glEnable(2929);
|
||||
this.revertPanoramaMatrix();
|
||||
}
|
||||
|
||||
private void rotateAndBlurCubemap(float partialTick) {
|
||||
this.mc.getTextureManager().bindTexture(this.viewportTexture);
|
||||
GL11.glCopyTexSubImage2D(3553, 0, 0, 0, 0, 0, 256, 256);
|
||||
GL11.glEnable(3042);
|
||||
blendFunc(770, 771);
|
||||
colorMask(true, true, true, false);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer wr = tessellator.getWorldRenderer();
|
||||
wr.startDrawingQuads();
|
||||
byte blurPasses = 4;
|
||||
|
||||
for (int blurPass = 0; blurPass < blurPasses; ++blurPass) {
|
||||
wr.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F / (blurPass + 1));
|
||||
float var7 = (blurPass - blurPasses / 2) / 256.0F;
|
||||
wr.addVertexWithUV(this.width, this.height, this.zLevel, 0.0F + var7, 0.0D);
|
||||
wr.addVertexWithUV(this.width, 0.0D, this.zLevel, 1.0F + var7, 0.0D);
|
||||
wr.addVertexWithUV(0.0D, 0.0D, this.zLevel, 1.0F + var7, 1.0D);
|
||||
wr.addVertexWithUV(0.0D, this.height, this.zLevel, 0.0F + var7, 1.0D);
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
colorMask(true, true, true, true);
|
||||
GL11.glDisable(3042);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderPanorama(int mouseX, int mouseY, float partialTicks) {
|
||||
viewport(0, 0, 256, 256);
|
||||
this.renderCubeMapTexture(mouseX, mouseY, partialTicks);
|
||||
GL11.glDisable(3553);
|
||||
GL11.glEnable(3553);
|
||||
|
||||
for (int tessellator = 0; tessellator < 8; ++tessellator) {
|
||||
this.rotateAndBlurCubemap(partialTicks);
|
||||
}
|
||||
|
||||
viewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer wr = tessellator.getWorldRenderer();
|
||||
wr.startDrawingQuads();
|
||||
float aspect = this.width > this.height ? 120.0F / this.width : 120.0F / this.height;
|
||||
float uSample = this.height * aspect / 256.0F;
|
||||
float vSample = this.width * aspect / 256.0F;
|
||||
GL11.glTexParameteri(3553, 10241, 9729);
|
||||
GL11.glTexParameteri(3553, 10240, 9729);
|
||||
wr.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
wr.addVertexWithUV(0.0D, this.height, this.zLevel, 0.5F - uSample, 0.5F + vSample);
|
||||
wr.addVertexWithUV(this.width, this.height, this.zLevel, 0.5F - uSample, 0.5F - vSample);
|
||||
wr.addVertexWithUV(this.width, 0.0D, this.zLevel, 0.5F + uSample, 0.5F - vSample);
|
||||
wr.addVertexWithUV(0.0D, 0.0D, this.zLevel, 0.5F + uSample, 0.5F + vSample);
|
||||
tessellator.draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTick) {
|
||||
float deltaTime = this.updateCounter + partialTick - this.lastPartialTick;
|
||||
this.lastPartialTick = this.updateCounter + partialTick;
|
||||
GL11.glDisable(2912);
|
||||
this.mc.entityRenderer.disableLightmap();
|
||||
this.panoramaRenderer.renderPanorama(mouseX, mouseY, partialTick);
|
||||
byte top = 30;
|
||||
int bottom = this.height - 40;
|
||||
int mid = this.width / 2;
|
||||
int horizon = this.height / 2 + this.height / 5;
|
||||
GL11.glPushAttrib(1048575);
|
||||
Gui.drawRect(30, top, mid - 30, bottom, Integer.MIN_VALUE);
|
||||
Gui.drawRect(mid + 30, top, this.width - 30, bottom, Integer.MIN_VALUE);
|
||||
this.drawGradientRect(30, horizon, mid - 30, bottom, -2130706433, 16777215);
|
||||
this.drawGradientRect(mid + 30, horizon, this.width - 30, bottom, -2130706433, 16777215);
|
||||
super.drawScreen(mouseX, mouseY, partialTick);
|
||||
popAttrib();
|
||||
this.enableClipping(30, bottom);
|
||||
float yPos = this.height * 0.75F;
|
||||
float xPos1 = this.width * 0.25F;
|
||||
float xPos2 = this.width * 0.75F;
|
||||
float scale = this.height * 0.25F;
|
||||
this.renderPlayerModel(this.localPlayer, xPos1, yPos, scale, xPos1 - mouseX, yPos - scale * 1.8F - mouseY,
|
||||
partialTick);
|
||||
this.renderPlayerModel(this.remotePlayer, xPos2, yPos, scale, xPos2 - mouseX, yPos - scale * 1.8F - mouseY,
|
||||
partialTick);
|
||||
this.disableClipping();
|
||||
this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 10, 16777215);
|
||||
this.fontRendererObj.drawStringWithShadow("Local Skin", 34, 34, 16777215);
|
||||
this.fontRendererObj.drawStringWithShadow("Server Skin", this.width / 2 + 34, 34, 16777215);
|
||||
GL11.glDisable(2929);
|
||||
depthMask(false);
|
||||
this.drawGradientRect(30, this.height - 60, mid - 30, bottom, 0, -520093697);
|
||||
this.drawGradientRect(mid + 30, this.height - 60, this.width - 30, bottom, 0, -520093697);
|
||||
int labelwidth = (this.width / 2 - 80) / 2;
|
||||
int opacity;
|
||||
if (!this.localPlayer.isUsingLocalTexture()) {
|
||||
opacity = this.fontRendererObj.getStringWidth(this.skinMessage) / 2;
|
||||
Gui.drawRect(40, this.height / 2 - 12, this.width / 2 - 40, this.height / 2 + 12, -1342177280);
|
||||
this.fontRendererObj.drawStringWithShadow(this.skinMessage, (int) (xPos1 - opacity), this.height / 2 - 4,
|
||||
16777215);
|
||||
}
|
||||
|
||||
if (this.fetchingSkin) {
|
||||
String opacity1 = this.throttledByMojang ? "\u00a7cMojang API Error!" : "Fetching skin...";
|
||||
int stringWidth = this.fontRendererObj.getStringWidth(opacity1) / 2;
|
||||
Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 12, this.width - 40, this.height / 2 + 12,
|
||||
-1342177280);
|
||||
this.fontRendererObj.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth), this.height / 2 - 4,
|
||||
16777215);
|
||||
}
|
||||
|
||||
if (this.uploadingSkin || this.uploadOpacity > 0.0F) {
|
||||
if (!this.uploadingSkin) {
|
||||
this.uploadOpacity -= deltaTime * 0.05F;
|
||||
} else if (this.uploadOpacity < 1.0F) {
|
||||
this.uploadOpacity += deltaTime * 0.1F;
|
||||
}
|
||||
|
||||
if (this.uploadOpacity > 1.0F) {
|
||||
this.uploadOpacity = 1.0F;
|
||||
}
|
||||
|
||||
opacity = Math.min(180, (int) (this.uploadOpacity * 180.0F)) & 255;
|
||||
if (this.uploadOpacity > 0.0F) {
|
||||
Gui.drawRect(0, 0, this.width, this.height, opacity << 24 | 0);
|
||||
if (this.uploadingSkin) {
|
||||
this.drawCenteredString(this.fontRendererObj, this.skinUploadMessage, this.width / 2,
|
||||
this.height / 2, opacity << 24 | 16777215);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.uploadError != null) {
|
||||
Gui.drawRect(0, 0, this.width, this.height, -1342177280);
|
||||
this.drawCenteredString(this.fontRendererObj, "Uploading skin failed", this.width / 2, this.height / 2 - 10,
|
||||
-171);
|
||||
this.drawCenteredString(this.fontRendererObj, this.uploadError, this.width / 2, this.height / 2 + 2,
|
||||
-43691);
|
||||
}
|
||||
|
||||
depthMask(true);
|
||||
GL11.glEnable(2929);
|
||||
}
|
||||
|
||||
protected void renderVignette(int mouseX, int mouseY, float partialTick) {
|
||||
GL11.glDisable(2929);
|
||||
depthMask(false);
|
||||
blendFunc(1, 774);
|
||||
color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(vignette);
|
||||
GL11.glLogicOp(5386);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer wr = tessellator.getWorldRenderer();
|
||||
wr.startDrawingQuads();
|
||||
wr.addVertexWithUV(0.0D, this.height, -90.0D, 0.0D, 1.0D);
|
||||
wr.addVertexWithUV(this.width, this.height, -90.0D, 1.0D, 1.0D);
|
||||
wr.addVertexWithUV(this.width, 0.0D, -90.0D, 1.0D, 0.0D);
|
||||
wr.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
|
||||
tessellator.draw();
|
||||
depthMask(true);
|
||||
GL11.glDisable(3058);
|
||||
GL11.glEnable(2929);
|
||||
color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
blendFunc(770, 771);
|
||||
}
|
||||
|
||||
public void renderPlayerModel(EntityPlayerModel thePlayer, float xPosition, float yPosition, float scale,
|
||||
float mouseX, float mouseY, float partialTick) {
|
||||
GL11.glEnable(2903);
|
||||
pushMatrix();
|
||||
translate(xPosition, yPosition, 300.0F);
|
||||
scale(-scale, scale, scale);
|
||||
rotate(180.0F, 0.0F, 0.0F, 1.0F);
|
||||
rotate(135.0F, 0.0F, 1.0F, 0.0F);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
rotate(-135.0F, 0.0F, 1.0F, 0.0F);
|
||||
rotate(15.0F, 1.0F, 0.0F, 0.0F);
|
||||
rotate((this.updateCounter + partialTick) * 2.5F, 0.0F, 1.0F, 0.0F);
|
||||
thePlayer.rotationPitch = -((float) Math.atan(mouseY / 40.0F)) * 20.0F;
|
||||
translate(0.0F, thePlayer.getYOffset(), 0.0F);
|
||||
RenderManager rm = Minecraft.getMinecraft().getRenderManager();
|
||||
rm.playerViewY = 180.0F;
|
||||
rm.renderEntityWithPosYaw(thePlayer, 0.0D, 0.0D, 0.0D, 1.0F, 1.0F);
|
||||
popMatrix();
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable('\u803a');
|
||||
}
|
||||
|
||||
protected final void enableClipping(int yTop, int yBottom) {
|
||||
if (this.doubleBuffer == null) {
|
||||
this.doubleBuffer = BufferUtils.createByteBuffer(32).asDoubleBuffer();
|
||||
}
|
||||
|
||||
this.doubleBuffer.clear();
|
||||
this.doubleBuffer.put(0.0D).put(1.0D).put(0.0D).put((-yTop)).flip();
|
||||
GL11.glClipPlane(12288, this.doubleBuffer);
|
||||
this.doubleBuffer.clear();
|
||||
this.doubleBuffer.put(0.0D).put(-1.0D).put(0.0D).put(yBottom).flip();
|
||||
GL11.glClipPlane(12289, this.doubleBuffer);
|
||||
GL11.glEnable(12288);
|
||||
GL11.glEnable(12289);
|
||||
}
|
||||
|
||||
protected final void disableClipping() {
|
||||
GL11.glDisable(12289);
|
||||
GL11.glDisable(12288);
|
||||
}
|
||||
|
||||
public static boolean isPowerOfTwo(int number) {
|
||||
return number != 0 && (number & number - 1) == 0;
|
||||
}
|
||||
|
||||
private boolean clearUploadedSkin(Session session) {
|
||||
if (!this.registerServerConnection(session, skinServerId)) {
|
||||
return false;
|
||||
} else {
|
||||
HashMap<String, Object> sourceData = new HashMap<String, Object>();
|
||||
sourceData.put("user", session.getUsername());
|
||||
sourceData.put("uuid", session.getPlayerID());
|
||||
sourceData.put("clear", "1");
|
||||
this.uploadError = null;
|
||||
this.uploadingSkin = true;
|
||||
this.skinUploadMessage = "Sending request to server please wait...";
|
||||
this.threadSkinUpload = new ThreadMultipartPostUpload(HDSkinManager.getGatewayUrl(), sourceData, this);
|
||||
this.threadSkinUpload.start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean uploadSkin(Session session, File skinFile) {
|
||||
if (!this.registerServerConnection(session, skinServerId)) {
|
||||
return false;
|
||||
} else {
|
||||
HashMap<String, Object> sourceData = new HashMap<String, Object>();
|
||||
sourceData.put("user", session.getUsername());
|
||||
sourceData.put("uuid", session.getPlayerID());
|
||||
sourceData.put("skin", skinFile);
|
||||
this.uploadError = null;
|
||||
this.uploadingSkin = true;
|
||||
this.skinUploadMessage = "Uploading skin please wait...";
|
||||
this.threadSkinUpload = new ThreadMultipartPostUpload(HDSkinManager.getGatewayUrl(), sourceData, this);
|
||||
this.threadSkinUpload.start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void setUploadError(String error) {
|
||||
this.uploadError = error.startsWith("ERROR: ") ? error.substring(7) : error;
|
||||
this.btnUpload.enabled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadComplete(String response) {
|
||||
LiteLoaderLogger.info("Upload completed with: %s", new Object[] { response });
|
||||
this.uploadingSkin = false;
|
||||
this.threadSkinUpload = null;
|
||||
if (!response.equalsIgnoreCase("OK")) {
|
||||
this.setUploadError(response);
|
||||
} else {
|
||||
this.pendingRemoteSkinRefresh = true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean registerServerConnection(Session session, String serverId) {
|
||||
try {
|
||||
MinecraftSessionService e = (new YggdrasilAuthenticationService(this.mc.getProxy(),
|
||||
UUID.randomUUID().toString())).createMinecraftSessionService();
|
||||
e.joinServer(session.getProfile(), session.getToken(), serverId);
|
||||
return true;
|
||||
} catch (AuthenticationException var4) {
|
||||
this.setUploadError(var4.toString());
|
||||
var4.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.voxelmodpack.hdskins.gui;
|
||||
|
||||
import com.voxelmodpack.common.properties.VoxelPropertyToggleButton;
|
||||
import com.voxelmodpack.common.properties.gui.GuiVoxelBoxSettingsPanel;
|
||||
import com.voxelmodpack.common.properties.interfaces.IVoxelPropertyProviderBoolean;
|
||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||
|
||||
public class HDSkinsConfigPanel extends GuiVoxelBoxSettingsPanel implements IVoxelPropertyProviderBoolean {
|
||||
|
||||
public HDSkinsConfigPanel() {
|
||||
this.properties.add(new VoxelPropertyToggleButton(this, "clear", "Clear local skin cache", 72, 8, 120, 70, 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPanelTitle() {
|
||||
return "HD Skins Settings";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStringProperty(String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOptionDisplayString(String propertyName) {
|
||||
return "Clear now";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleOption(String propertyName) {
|
||||
HDSkinManager.clearSkinCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultPropertyValue(String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(String propertyName, boolean value) {}
|
||||
|
||||
@Override
|
||||
public boolean getBoolProperty(String propertyName) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.voxelmodpack.hdskins.gui;
|
||||
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.ModelPlayer;
|
||||
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class RenderPlayerModel extends RenderLiving {
|
||||
|
||||
public RenderPlayerModel(RenderManager renderer) {
|
||||
super(renderer, new ModelPlayer(0, false), 0.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(Entity var1) {
|
||||
return ((EntityPlayerModel) var1).getSkinTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canRenderName(EntityLivingBase targetEntity) {
|
||||
if (Minecraft.getMinecraft().thePlayer != null) {
|
||||
return super.canRenderName(targetEntity);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setBrightness(EntityLivingBase entitylivingbaseIn, float partialTicks, boolean p_177092_3_) {
|
||||
if (Minecraft.getMinecraft().theWorld != null) {
|
||||
return super.setBrightness(entitylivingbaseIn, partialTicks, p_177092_3_);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
this.doRender((EntityLiving) par1Entity, par2, par4, par6, par8, par9);
|
||||
popAttrib();
|
||||
pushMatrix();
|
||||
scale(1.0F, -1.0F, 1.0F);
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
this.doRender((EntityLiving) par1Entity, par2, par4, par6, par8, par9);
|
||||
popAttrib();
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preRenderCallback(EntityLivingBase par1EntityLiving, float par2) {
|
||||
this.renderCloak((EntityPlayerModel) par1EntityLiving, par2);
|
||||
}
|
||||
|
||||
protected void renderCloak(EntityPlayerModel entity, float par2) {
|
||||
super.preRenderCallback(entity, par2);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.voxelmodpack.hdskins.mod;
|
||||
|
||||
import com.mumfrey.liteloader.Configurable;
|
||||
import com.mumfrey.liteloader.InitCompleteListener;
|
||||
|
||||
public interface HDSkinsMod extends InitCompleteListener, Configurable {
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.voxelmodpack.hdskins.mod;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import com.mumfrey.liteloader.core.LiteLoader;
|
||||
import com.mumfrey.liteloader.modconfig.ConfigPanel;
|
||||
import com.mumfrey.liteloader.util.ModUtilities;
|
||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
|
||||
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
||||
import com.voxelmodpack.hdskins.gui.HDSkinsConfigPanel;
|
||||
import com.voxelmodpack.hdskins.gui.RenderPlayerModel;
|
||||
import com.voxelmodpack.voxelmenu.IPanoramaRenderer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class HDSkinsModCore implements HDSkinsMod {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "HD Skins";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "4.0.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(File configPath) {
|
||||
try {
|
||||
Class<?> ex = Class.forName("com.thevoxelbox.voxelmenu.GuiMainMenuVoxelBox");
|
||||
Method mRegisterCustomScreen = ex.getDeclaredMethod("registerCustomScreen",
|
||||
new Class[] { Class.class, String.class });
|
||||
mRegisterCustomScreen.invoke(null, GuiSkins.class, "HD Skins Manager");
|
||||
} catch (ClassNotFoundException var4) {
|
||||
;
|
||||
} catch (Exception var5) {
|
||||
var5.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradeSettings(String version, File configPath, File oldConfigPath) {
|
||||
HDSkinManager.clearSkinCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends ConfigPanel> getConfigPanelClass() {
|
||||
return HDSkinsConfigPanel.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitCompleted(Minecraft minecraft, LiteLoader loader) {
|
||||
ModUtilities.addRenderer(EntityPlayerModel.class, new RenderPlayerModel(minecraft.getRenderManager()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) {}
|
||||
|
||||
public static IPanoramaRenderer getPanoramaRenderer(IPanoramaRenderer fallbackRenderer) {
|
||||
try {
|
||||
Class<?> ex = Class.forName("com.thevoxelbox.voxelmenu.VoxelMenuModCore");
|
||||
Method mGetPanoramaRenderer = ex.getDeclaredMethod("getPanoramaRenderer", new Class[0]);
|
||||
IPanoramaRenderer panoramaRenderer = (IPanoramaRenderer) mGetPanoramaRenderer.invoke((Object) null,
|
||||
new Object[0]);
|
||||
if (panoramaRenderer != null) {
|
||||
return panoramaRenderer;
|
||||
}
|
||||
} catch (ClassNotFoundException var4) {
|
||||
;
|
||||
} catch (Exception var5) {
|
||||
var5.printStackTrace();
|
||||
}
|
||||
|
||||
return fallbackRenderer;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.voxelmodpack.hdskins.mod;
|
||||
|
||||
import com.voxelmodpack.common.VoxelCommonLiteMod;
|
||||
|
||||
public class LiteModHDSkins extends VoxelCommonLiteMod {
|
||||
public LiteModHDSkins() {
|
||||
super("com.voxelmodpack.hdskins.mod.HDSkinsModCore");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "4.0.1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "HDSkins";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.voxelmodpack.voxelmenu;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public interface IPanoramaRenderer {
|
||||
void setPanoramaResolution(Minecraft var1, int var2, int var3);
|
||||
|
||||
void initPanoramaRenderer();
|
||||
|
||||
void updatePanorama();
|
||||
|
||||
boolean renderPanorama(int var1, int var2, float var3);
|
||||
|
||||
int getUpdateCounter();
|
||||
}
|
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 9.1 KiB |
BIN
src/main/resources/assets/hdskins/textures/mob/noskin.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
src/main/resources/assets/hdskins/textures/mob/tempskin.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1 KiB |
After Width: | Height: | Size: 941 B |
After Width: | Height: | Size: 859 B |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 4 KiB |
After Width: | Height: | Size: 859 B |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 670 B |
After Width: | Height: | Size: 1,019 B |
After Width: | Height: | Size: 986 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 1,019 B |
After Width: | Height: | Size: 1 KiB |