aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcitrons <citrons@mondecitronne.com>2023-10-29 22:42:13 -0500
committercitrons <citrons@mondecitronne.com>2023-10-29 22:43:47 -0500
commit13c2fb7482d45a74ca460f6192a16dc8c956923f (patch)
tree552bbf97c5d28d8705dbcb1b7c3e8ccf4742d996
initial commit
-rw-r--r--.gitignore22
-rw-r--r--LICENSE21
-rw-r--r--README.md11
-rw-r--r--build.gradle207
-rw-r--r--gradle.properties22
-rw-r--r--gradle/wrapper/gradle-wrapper.jarbin0 -> 62076 bytes
-rw-r--r--gradle/wrapper/gradle-wrapper.properties6
-rwxr-xr-xgradlew245
-rw-r--r--gradlew.bat92
-rw-r--r--settings.gradle26
-rw-r--r--src/main/java/com/mondecitronne/homunculus/EntityHomunculus.java84
-rw-r--r--src/main/java/com/mondecitronne/homunculus/Homunculus.java40
-rw-r--r--src/main/java/com/mondecitronne/homunculus/PlayerSkin.java124
-rw-r--r--src/main/java/com/mondecitronne/homunculus/client/RenderHomunculus.java89
-rw-r--r--src/main/java/com/mondecitronne/homunculus/proxy/ClientProxy.java30
-rw-r--r--src/main/java/com/mondecitronne/homunculus/proxy/Proxy.java37
-rw-r--r--src/main/java/com/mondecitronne/homunculus/proxy/SkinHandlerClientProxy.java42
-rw-r--r--src/main/java/com/mondecitronne/homunculus/proxy/SkinHandlerProxy.java24
-rw-r--r--src/main/resources/assets/homunculus/lang/en_us.lang1
-rw-r--r--src/main/resources/mcmod.info16
-rw-r--r--src/main/resources/pack.mcmeta7
21 files changed, 1146 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2c770e0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,22 @@
+# eclipse
+bin
+*.launch
+.settings
+.metadata
+.classpath
+.project
+
+# idea
+out
+*.ipr
+*.iws
+*.iml
+.idea
+
+# gradle
+build
+.gradle
+
+# other
+eclipse
+run
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..06a9189
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2022-2023 CleanroomMC, citrons
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..faabaf3
--- /dev/null
+++ b/README.md
@@ -0,0 +1,11 @@
+# homunculus mod
+
+this mod adds mobs that look like players. they presently do nothing otherwise.
+
+a homunculus can be spawned like this:
+
+ /summon homunculus:homunculus
+
+a homunculus can be given a player skin like this:
+
+ /summon homunculus:homunculus ~ ~ ~ {SkinOwner:{Name:jeb_}}
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..9e82e74
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,207 @@
+import org.jetbrains.gradle.ext.Gradle
+
+plugins {
+ id 'java'
+ id 'java-library'
+ id 'maven-publish'
+ id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
+ id 'eclipse'
+ id 'com.gtnewhorizons.retrofuturagradle' version '1.3.16'
+ id 'com.matthewprenger.cursegradle' version '1.4.0'
+}
+
+version = project.mod_version
+group = project.maven_group
+archivesBaseName = project.archives_base_name
+
+// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
+java {
+ toolchain {
+ languageVersion.set(JavaLanguageVersion.of(8))
+ // Azul covers the most platforms for Java 8 toolchains, crucially including MacOS arm64
+ vendor.set(org.gradle.jvm.toolchain.JvmVendorSpec.AZUL)
+ }
+ // Generate sources and javadocs jars when building and publishing
+ withSourcesJar()
+ // withJavadocJar()
+}
+
+tasks.withType(JavaCompile).configureEach {
+ options.encoding = 'UTF-8'
+}
+
+configurations {
+ embed
+ implementation.extendsFrom(embed)
+}
+
+minecraft {
+ mcVersion = '1.12.2'
+
+ // MCP Mappings
+ mcpMappingChannel = 'stable'
+ mcpMappingVersion = '39'
+
+ // Set username here, the UUID will be looked up automatically
+ username = 'Developer'
+
+ // Add any additional tweaker classes here
+ // extraTweakClasses.add('org.spongepowered.asm.launch.MixinTweaker')
+
+ // Add various JVM arguments here for runtime
+ def args = ["-ea:${project.group}"]
+ if (project.use_coremod.toBoolean()) {
+ args << '-Dfml.coreMods.load=' + coremod_plugin_class_name
+ }
+ if (project.use_mixins.toBoolean()) {
+ args << '-Dmixin.hotSwap=true'
+ args << '-Dmixin.checks.interfaces=true'
+ args << '-Dmixin.debug.export=true'
+ }
+ extraRunJvmArguments.addAll(args)
+
+ // Include and use dependencies' Access Transformer files
+ useDependencyAccessTransformers = true
+
+ // Add any properties you want to swap out for a dynamic value at build time here
+ // Any properties here will be added to a class at build time, the name can be configured below
+ // Example:
+ // injectedTags.put('VERSION', project.version)
+ // injectedTags.put('MOD_ID', project.archives_base_name)
+}
+
+// Generate a group.archives_base_name.Tags class
+tasks.injectTags.configure {
+ // Change Tags class' name here:
+ outputClassName.set("${project.group}.${project.archives_base_name}.Tags")
+}
+
+repositories {
+ maven {
+ name 'CleanroomMC Maven'
+ url 'https://maven.cleanroommc.com'
+ }
+ maven {
+ name 'SpongePowered Maven'
+ url 'https://repo.spongepowered.org/maven'
+ }
+ maven {
+ name 'CurseMaven'
+ url 'https://cursemaven.com'
+ content {
+ includeGroup 'curse.maven'
+ }
+ }
+ mavenLocal() // Must be last for caching to work
+}
+
+dependencies {
+ if (project.use_assetmover.toBoolean()) {
+ implementation 'com.cleanroommc:assetmover:2.5'
+ }
+ if (project.use_mixins.toBoolean()) {
+ implementation 'zone.rong:mixinbooter:7.1'
+ }
+
+ // Example of deobfuscating a dependency
+ // implementation rfg.deobf('curse.maven:had-enough-items-557549:4543375')
+
+ if (project.use_mixins.toBoolean()) {
+ // Change your mixin refmap name here:
+ String mixin = modUtils.enableMixins('org.spongepowered:mixin:0.8.3', "mixins.${project.archives_base_name}.refmap.json")
+ api (mixin) {
+ transitive = false
+ }
+ annotationProcessor 'org.ow2.asm:asm-debug-all:5.2'
+ annotationProcessor 'com.google.guava:guava:24.1.1-jre'
+ annotationProcessor 'com.google.code.gson:gson:2.8.6'
+ annotationProcessor (mixin) {
+ transitive = false
+ }
+ }
+
+}
+
+// Adds Access Transformer files to tasks
+if (project.use_access_transformer.toBoolean()) {
+ for (File at : sourceSets.getByName("main").resources.files) {
+ if (at.name.toLowerCase().endsWith("_at.cfg")) {
+ tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(at)
+ tasks.srgifyBinpatchedJar.accessTransformerFiles.from(at)
+ }
+ }
+}
+
+processResources {
+ // This will ensure that this task is redone when the versions change
+ inputs.property 'version', project.version
+ inputs.property 'mcversion', project.minecraft.version
+
+ // Replace various properties in mcmod.info and pack.mcmeta if applicable
+ filesMatching(['mcmod.info', 'pack.mcmeta']) { fcd ->
+ // Replace version and mcversion
+ fcd.expand (
+ 'version': project.version,
+ 'mcversion': project.minecraft.version
+ )
+ }
+
+ if (project.use_access_transformer.toBoolean()) {
+ rename '(.+_at.cfg)', 'META-INF/$1' // Make sure Access Transformer files are in META-INF folder
+ }
+}
+
+jar {
+ manifest {
+ def attribute_map = [:]
+ if (project.use_coremod.toBoolean()) {
+ attribute_map['FMLCorePlugin'] = project.coremod_plugin_class_name
+ if (project.include_mod.toBoolean()) {
+ attribute_map['FMLCorePluginContainsFMLMod'] = true
+ attribute_map['ForceLoadAsMod'] = project.gradle.startParameter.taskNames[0] == "build"
+ }
+ }
+ if (project.use_access_transformer.toBoolean()) {
+ attribute_map['FMLAT'] = project.archives_base_name + '_at.cfg'
+ }
+ attributes(attribute_map)
+ }
+ // Add all embedded dependencies into the jar
+ from(provider{ configurations.embed.collect {it.isDirectory() ? it : zipTree(it)} })
+}
+
+idea {
+ module {
+ inheritOutputDirs = true
+ }
+ project {
+ settings {
+ runConfigurations {
+ "1. Run Client"(Gradle) {
+ taskNames = ["runClient"]
+ }
+ "2. Run Server"(Gradle) {
+ taskNames = ["runServer"]
+ }
+ "3. Run Obfuscated Client"(Gradle) {
+ taskNames = ["runObfClient"]
+ }
+ "4. Run Obfuscated Server"(Gradle) {
+ taskNames = ["runObfServer"]
+ }
+ }
+ compiler.javac {
+ afterEvaluate {
+ javacAdditionalOptions = "-encoding utf8"
+ moduleJavacAdditionalOptions = [
+ (project.name + ".main"): tasks.compileJava.options.compilerArgs.collect { '"' + it + '"' }.join(' ')
+ ]
+ }
+ }
+ }
+ }
+}
+
+tasks.named("processIdeaSettings").configure {
+ dependsOn("injectTags")
+}
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..76aa16a
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,22 @@
+# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
+# This is required to provide enough memory for the Minecraft decompilation process.
+org.gradle.jvmargs = -Xmx3G
+
+# Mod Information
+mod_version = 1.0
+maven_group = com.mondecitronne.homunculus
+archives_base_name = homunculus
+
+# If any properties changes below this line, run `gradlew setupDecompWorkspace` and refresh gradle again to ensure everything is working correctly.
+
+# Boilerplate Options
+use_mixins = false
+use_coremod = false
+use_assetmover = false
+
+# Access Transformer files should be in the root of `resources` folder and with the filename formatted as: `{archives_base_name}_at.cfg`
+use_access_transformer = false
+
+# Coremod Arguments
+include_mod = true
+coremod_plugin_class_name =
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..c1962a7
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..37aef8d
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
+networkTimeout=10000
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..aeb74cb
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,245 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+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" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..6689b85
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,92 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@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
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+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 execute
+
+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
+
+: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 %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 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!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..4d208c5
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,26 @@
+pluginManagement {
+ repositories {
+ maven {
+ // RetroFuturaGradle
+ name 'GTNH Maven'
+ url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public/'
+ allowInsecureProtocol = true
+ mavenContent {
+ includeGroup 'com.gtnewhorizons'
+ includeGroup 'com.gtnewhorizons.retrofuturagradle'
+ }
+ }
+ gradlePluginPortal()
+ mavenCentral()
+ mavenLocal()
+ }
+}
+
+plugins {
+ // Automatic toolchain provisioning
+ id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0'
+}
+
+// Due to an IntelliJ bug, this has to be done
+// rootProject.name = archives_base_name
+rootProject.name = rootProject.projectDir.getName()
diff --git a/src/main/java/com/mondecitronne/homunculus/EntityHomunculus.java b/src/main/java/com/mondecitronne/homunculus/EntityHomunculus.java
new file mode 100644
index 0000000..1193014
--- /dev/null
+++ b/src/main/java/com/mondecitronne/homunculus/EntityHomunculus.java
@@ -0,0 +1,84 @@
+package com.mondecitronne.homunculus;
+
+import javax.annotation.Nullable;
+
+import com.mojang.authlib.GameProfile;
+import com.mondecitronne.homunculus.proxy.SkinHandlerProxy;
+
+import io.netty.util.internal.StringUtil;
+import net.minecraft.entity.EntityLiving;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTUtil;
+import net.minecraft.network.datasync.DataParameter;
+import net.minecraft.network.datasync.DataSerializers;
+import net.minecraft.network.datasync.EntityDataManager;
+import net.minecraft.world.World;
+import net.minecraftforge.fml.common.SidedProxy;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
+
+public class EntityHomunculus extends EntityLiving {
+ @SidedProxy(clientSide = "com.mondecitronne.homunculus.proxy.SkinHandlerClientProxy", serverSide = "com.mondecitronne.homunculus.proxy.SkinHandlerProxy", modId = "homunculus")
+ private static SkinHandlerProxy skinProxy;
+
+ private SkinHandlerProxy.SkinOwner skinOwner;
+ private static final DataParameter<NBTTagCompound> SKIN_OWNER = EntityDataManager.createKey(EntityHomunculus.class, DataSerializers.COMPOUND_TAG);
+
+ public EntityHomunculus(World world) {
+ super(world);
+ }
+
+ @Override
+ protected void entityInit() {
+ super.entityInit();
+ this.getDataManager().register(SKIN_OWNER, new NBTTagCompound());
+ }
+
+ private boolean isPlayerProfileUpdated(GameProfile input) {
+ if (skinOwner == null) {
+ return input != null;
+ } else {
+ GameProfile skinOwnerProfile = skinOwner.getPlayerProfile();
+ return !skinOwnerProfile.getName().toLowerCase().equals(input.getName().toLowerCase()) || (input.getId() != null && !input.getId().equals(skinOwnerProfile.getId()));
+ }
+ }
+
+ @Nullable
+ public SkinHandlerProxy.SkinOwner getSkinOwner() {
+ GameProfile ownerProfile = NBTUtil.readGameProfileFromNBT(this.getDataManager().get(SKIN_OWNER));
+ if (isPlayerProfileUpdated(ownerProfile) && !StringUtil.isNullOrEmpty(ownerProfile.getName())) {
+ skinOwner = skinProxy.createSkinOwner(ownerProfile);
+ } else if (ownerProfile == null) {
+ skinOwner = null;
+ }
+ return skinOwner;
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound compound) {
+ super.readFromNBT(compound);
+ if (compound.hasKey("SkinOwner")) {
+ NBTTagCompound ownerCompound = compound.getCompoundTag("SkinOwner");
+ if (ownerCompound.hasKey("Name")) {
+ this.getDataManager().set(SKIN_OWNER, ownerCompound);
+ }
+ }
+ }
+
+ @Override
+ public NBTTagCompound writeToNBT(NBTTagCompound compound) {
+ super.writeToNBT(compound);
+ SkinHandlerProxy.SkinOwner owner = getSkinOwner();
+ if (owner != null) {
+ NBTTagCompound profileCompound = new NBTTagCompound();
+ NBTUtil.writeGameProfile(profileCompound, owner.getPlayerProfile());
+ NBTTagCompound ownerCompound = new NBTTagCompound();
+ ownerCompound.setTag("Name", profileCompound.getTag("Name"));
+ if (profileCompound.hasKey("Id")) {
+ ownerCompound.setTag("Id", profileCompound.getTag("Id"));
+ }
+ compound.setTag("SkinOwner", ownerCompound);
+ }
+ return compound;
+ }
+}
diff --git a/src/main/java/com/mondecitronne/homunculus/Homunculus.java b/src/main/java/com/mondecitronne/homunculus/Homunculus.java
new file mode 100644
index 0000000..deb97b4
--- /dev/null
+++ b/src/main/java/com/mondecitronne/homunculus/Homunculus.java
@@ -0,0 +1,40 @@
+package com.mondecitronne.homunculus;
+
+import com.mondecitronne.homunculus.proxy.Proxy;
+import net.minecraftforge.fml.common.event.FMLInitializationEvent;
+import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
+import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
+import net.minecraftforge.fml.common.Mod;
+import org.apache.logging.log4j.Logger;
+import net.minecraftforge.fml.common.SidedProxy;
+
+@Mod(modid = Homunculus.MODID, name = Homunculus.NAME, version = Homunculus.VERSION)
+public class Homunculus {
+ public static final String MODID = "homunculus";
+ public static final String NAME = "Homunculus";
+ public static final String VERSION = "1.0";
+
+ @SidedProxy(clientSide = "com.mondecitronne.homunculus.proxy.ClientProxy", serverSide = "com.mondecitronne.homunculus.proxy.Proxy")
+ public static Proxy proxy;
+
+ @Mod.Instance
+ public static Homunculus instance;
+
+ static Logger logger;
+
+ @Mod.EventHandler
+ public void preInit(FMLPreInitializationEvent event) {
+ logger = event.getModLog();
+ proxy.preInit(event);
+ }
+
+ @Mod.EventHandler
+ public void init(FMLInitializationEvent event) {
+ proxy.init(event);
+ }
+
+ @Mod.EventHandler
+ public void postInit(FMLPostInitializationEvent event) {
+ proxy.postInit(event);
+ }
+}
diff --git a/src/main/java/com/mondecitronne/homunculus/PlayerSkin.java b/src/main/java/com/mondecitronne/homunculus/PlayerSkin.java
new file mode 100644
index 0000000..9649790
--- /dev/null
+++ b/src/main/java/com/mondecitronne/homunculus/PlayerSkin.java
@@ -0,0 +1,124 @@
+package com.mondecitronne.homunculus;
+
+import java.io.File;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.annotation.Nullable;
+
+import com.google.common.collect.Iterables;
+import com.mojang.authlib.AuthenticationService;
+import com.mojang.authlib.GameProfile;
+import com.mojang.authlib.GameProfileRepository;
+import com.mojang.authlib.minecraft.MinecraftProfileTexture;
+import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
+import com.mojang.authlib.minecraft.MinecraftSessionService;
+import com.mojang.authlib.properties.Property;
+import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.management.PlayerProfileCache;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StringUtils;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
+
+@SideOnly(Side.CLIENT)
+public class PlayerSkin {
+ private GameProfile playerProfile;
+ private boolean skinLoaded;
+ private static PlayerProfileCache profileCache;
+ private static MinecraftSessionService sessionService;
+
+ public static void initProfileCache() {
+ AuthenticationService authenticationService = new YggdrasilAuthenticationService(Minecraft.getMinecraft().getProxy(), UUID.randomUUID().toString());
+ sessionService = authenticationService.createMinecraftSessionService();
+ GameProfileRepository profileRepository = authenticationService.createProfileRepository();
+ profileCache = new PlayerProfileCache(profileRepository, new File(Minecraft.getMinecraft().gameDir, MinecraftServer.USER_CACHE_FILE.getName()));
+ }
+
+ public PlayerSkin(GameProfile profile) {
+ playerProfile = profile;
+ }
+
+ public void loadSkin() {
+ if (!skinLoaded) {
+ playerProfile = populateGameProfile(playerProfile);
+ skinLoaded = true;
+ }
+ }
+
+ public GameProfile getPlayerProfile() {
+ assert(playerProfile != null);
+ return playerProfile;
+ }
+
+ protected MinecraftProfileTexture getProfileTexture() {
+ Minecraft minecraft = Minecraft.getMinecraft();
+ Map<Type, MinecraftProfileTexture> map = minecraft.getSkinManager().loadSkinFromCache(playerProfile);
+ if (map != null) {
+ return map.get(Type.SKIN);
+ } else {
+ return null;
+ }
+ }
+
+ @Nullable
+ public String getModelType() {
+ if (getTexture() != null) {
+ MinecraftProfileTexture tex = getProfileTexture();
+ if (tex != null && tex.getMetadata("model") != null) {
+ return tex.getMetadata("model");
+ }
+ }
+ return null;
+ }
+
+ @Nullable
+ public ResourceLocation getTexture() {
+ MinecraftProfileTexture tex = getProfileTexture();
+ if (tex != null) {
+ ResourceLocation location = Minecraft.getMinecraft().getSkinManager().loadSkin(tex, Type.SKIN);
+ if (location != null) {
+ return location;
+ }
+ }
+ return null;
+ }
+
+ private static GameProfile populateGameProfile(GameProfile input) {
+ if (input != null) {
+ if (input.isComplete() && input.getProperties().containsKey("textures")) {
+ return input;
+ } else if (profileCache != null && sessionService != null) {
+ GameProfile gameProfile = null;
+ if (!StringUtils.isNullOrEmpty(input.getName())) {
+ gameProfile = profileCache.getGameProfileForUsername(input.getName());
+ if (input.getId() != null && !input.getId().equals(gameProfile.getId())) {
+ return input;
+ }
+ }
+
+ if (gameProfile == null) {
+ return input;
+ } else {
+ Property property = (Property)Iterables.getFirst(gameProfile.getProperties().get("textures"), (Object)null);
+
+ if (property == null) {
+ gameProfile = sessionService.fillProfileProperties(gameProfile, true);
+ if (gameProfile == null) {
+ return input;
+ }
+ }
+
+ return gameProfile;
+ }
+ } else {
+ return input;
+ }
+ } else {
+ return input;
+ }
+ }
+}
diff --git a/src/main/java/com/mondecitronne/homunculus/client/RenderHomunculus.java b/src/main/java/com/mondecitronne/homunculus/client/RenderHomunculus.java
new file mode 100644
index 0000000..16ade41
--- /dev/null
+++ b/src/main/java/com/mondecitronne/homunculus/client/RenderHomunculus.java
@@ -0,0 +1,89 @@
+package com.mondecitronne.homunculus.client;
+
+import java.util.Map;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import com.google.common.collect.Maps;
+import com.mondecitronne.homunculus.EntityHomunculus;
+import com.mondecitronne.homunculus.PlayerSkin;
+import com.mondecitronne.homunculus.proxy.SkinHandlerClientProxy;
+import com.mondecitronne.homunculus.proxy.SkinHandlerProxy;
+
+import net.minecraft.client.renderer.entity.Render;
+import net.minecraft.client.renderer.entity.RenderLivingBase;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.client.resources.DefaultPlayerSkin;
+import net.minecraftforge.fml.client.registry.IRenderFactory;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraft.client.model.ModelPlayer;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class RenderHomunculus extends RenderLivingBase<EntityHomunculus> {
+ public static final Factory FACTORY = new Factory();
+ private final Map<String, ModelPlayer> modelTypes = Maps.<String, ModelPlayer>newHashMap();
+
+ public RenderHomunculus(RenderManager rendermanagerIn) {
+ super(rendermanagerIn, new ModelPlayer(0.0F, false), 0.5F);
+ modelTypes.put("default", new ModelPlayer(0.0F, false));
+ modelTypes.put("slim", new ModelPlayer(0.0F, true));
+ }
+
+ @Nullable
+ protected static PlayerSkin getSkin(EntityHomunculus entity) {
+ SkinHandlerProxy.SkinOwner owner = entity.getSkinOwner();
+ if (owner != null) {
+ PlayerSkin skin = ((SkinHandlerClientProxy.SkinOwner) entity.getSkinOwner()).getPlayerSkin();
+ skin.loadSkin();
+ return skin;
+ } else {
+ return null;
+ }
+ }
+
+ @Nonnull
+ public String getModelType(EntityHomunculus entity) {
+ String modelType = DefaultPlayerSkin.getSkinType(entity.getUniqueID());
+ PlayerSkin skin = getSkin(entity);
+ if (skin != null) {
+ String type = skin.getModelType();
+ if (type != null) {
+ modelType = type;
+ }
+ }
+ return modelType;
+ }
+
+ @Override
+ protected ResourceLocation getEntityTexture(@Nonnull EntityHomunculus entity) {
+ ResourceLocation texture = DefaultPlayerSkin.getDefaultSkin(entity.getUniqueID());
+ PlayerSkin skin = getSkin(entity);
+ if (skin != null) {
+ ResourceLocation tex = skin.getTexture();
+ if (tex != null) {
+ texture = tex;
+ }
+ }
+ return texture;
+ }
+
+ @Override
+ public void doRender(EntityHomunculus entity, double x, double y, double z, float entityYaw, float partialTicks) {
+ mainModel = modelTypes.get(getModelType(entity));
+ super.doRender(entity, x, y, z, entityYaw, partialTicks);
+ }
+
+ @Override
+ protected boolean canRenderName(EntityHomunculus entity) {
+ return super.canRenderName(entity) && entity.hasCustomName();
+ }
+
+ public static class Factory implements IRenderFactory<EntityHomunculus> {
+ @Override
+ public Render<? super EntityHomunculus> createRenderFor(RenderManager manager) {
+ return new RenderHomunculus(manager);
+ }
+ }
+}
diff --git a/src/main/java/com/mondecitronne/homunculus/proxy/ClientProxy.java b/src/main/java/com/mondecitronne/homunculus/proxy/ClientProxy.java
new file mode 100644
index 0000000..58d86ae
--- /dev/null
+++ b/src/main/java/com/mondecitronne/homunculus/proxy/ClientProxy.java
@@ -0,0 +1,30 @@
+package com.mondecitronne.homunculus.proxy;
+
+import com.mondecitronne.homunculus.EntityHomunculus;
+import com.mondecitronne.homunculus.PlayerSkin;
+import com.mondecitronne.homunculus.client.RenderHomunculus;
+
+import net.minecraftforge.client.event.ModelRegistryEvent;
+import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.client.registry.RenderingRegistry;
+import net.minecraftforge.fml.common.Mod;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
+
+@Mod.EventBusSubscriber(Side.CLIENT)
+@SideOnly(Side.CLIENT)
+public class ClientProxy extends Proxy {
+ @Override
+ public void preInit(FMLPreInitializationEvent e) {
+ super.preInit(e);
+ PlayerSkin.initProfileCache();
+
+ RenderingRegistry.registerEntityRenderingHandler(EntityHomunculus.class, RenderHomunculus.FACTORY);
+ }
+
+ @SubscribeEvent
+ public static void registerModels(ModelRegistryEvent event) {
+ }
+}
+
diff --git a/src/main/java/com/mondecitronne/homunculus/proxy/Proxy.java b/src/main/java/com/mondecitronne/homunculus/proxy/Proxy.java
new file mode 100644
index 0000000..d32f489
--- /dev/null
+++ b/src/main/java/com/mondecitronne/homunculus/proxy/Proxy.java
@@ -0,0 +1,37 @@
+package com.mondecitronne.homunculus.proxy;
+
+import net.minecraft.block.Block;
+import net.minecraftforge.event.RegistryEvent;
+import net.minecraftforge.fml.common.event.FMLInitializationEvent;
+import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
+import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.Mod;
+import net.minecraftforge.fml.common.registry.EntityRegistry;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraft.item.Item;
+import net.minecraft.util.ResourceLocation;
+
+import com.mondecitronne.homunculus.EntityHomunculus;
+import com.mondecitronne.homunculus.Homunculus;
+
+@Mod.EventBusSubscriber
+public class Proxy {
+ public void preInit(FMLPreInitializationEvent e) {
+ EntityRegistry.registerModEntity(new ResourceLocation(Homunculus.MODID, "homunculus"), EntityHomunculus.class, "homunculus", 0, Homunculus.instance, 64, 3, true);
+ }
+
+ public void init(FMLInitializationEvent e) {
+ }
+
+ public void postInit(FMLPostInitializationEvent e) {
+ }
+
+ @SubscribeEvent
+ public static void registerBlocks(RegistryEvent.Register<Block> event) {
+ }
+
+ @SubscribeEvent
+ public static void registerItems(RegistryEvent.Register<Item> event) {
+ }
+} \ No newline at end of file
diff --git a/src/main/java/com/mondecitronne/homunculus/proxy/SkinHandlerClientProxy.java b/src/main/java/com/mondecitronne/homunculus/proxy/SkinHandlerClientProxy.java
new file mode 100644
index 0000000..8c7a122
--- /dev/null
+++ b/src/main/java/com/mondecitronne/homunculus/proxy/SkinHandlerClientProxy.java
@@ -0,0 +1,42 @@
+package com.mondecitronne.homunculus.proxy;
+
+import com.mojang.authlib.GameProfile;
+import com.mondecitronne.homunculus.PlayerSkin;
+
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
+
+@SideOnly(Side.CLIENT)
+public class SkinHandlerClientProxy extends SkinHandlerProxy {
+ public class SkinOwner extends SkinHandlerProxy.SkinOwner {
+ private PlayerSkin skin;
+
+ SkinOwner(GameProfile playerProfileIn) {
+ super(playerProfileIn);
+ skin = new PlayerSkin(playerProfileIn);
+ }
+
+ @Override
+ public GameProfile getPlayerProfile() {
+ if (skin != null) {
+ return skin.getPlayerProfile();
+ } else {
+ return super.getPlayerProfile();
+ }
+ }
+
+ public PlayerSkin getPlayerSkin() {
+ return skin;
+ }
+
+ @Override
+ public void loadSkin() {
+ skin.loadSkin();
+ }
+ }
+
+ @Override
+ public SkinOwner createSkinOwner(GameProfile playerProfile) {
+ return new SkinOwner(playerProfile);
+ }
+}
diff --git a/src/main/java/com/mondecitronne/homunculus/proxy/SkinHandlerProxy.java b/src/main/java/com/mondecitronne/homunculus/proxy/SkinHandlerProxy.java
new file mode 100644
index 0000000..b56ba53
--- /dev/null
+++ b/src/main/java/com/mondecitronne/homunculus/proxy/SkinHandlerProxy.java
@@ -0,0 +1,24 @@
+package com.mondecitronne.homunculus.proxy;
+
+import com.mojang.authlib.GameProfile;
+
+public class SkinHandlerProxy {
+ public class SkinOwner {
+ private GameProfile playerProfile;
+
+ SkinOwner(GameProfile playerProfileIn) {
+ playerProfile = playerProfileIn;
+ }
+
+ public GameProfile getPlayerProfile() {
+ return playerProfile;
+ }
+
+ public void loadSkin() {
+ }
+ }
+
+ public SkinOwner createSkinOwner(GameProfile playerProfile) {
+ return new SkinOwner(playerProfile);
+ }
+} \ No newline at end of file
diff --git a/src/main/resources/assets/homunculus/lang/en_us.lang b/src/main/resources/assets/homunculus/lang/en_us.lang
new file mode 100644
index 0000000..de96bd6
--- /dev/null
+++ b/src/main/resources/assets/homunculus/lang/en_us.lang
@@ -0,0 +1 @@
+entity.homunculus.name=Homunculus
diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info
new file mode 100644
index 0000000..57009a4
--- /dev/null
+++ b/src/main/resources/mcmod.info
@@ -0,0 +1,16 @@
+[
+{
+ "modid": "homunculus",
+ "name": "Homunculus",
+ "description": "They're almost alive, but they have no soul.",
+ "version": "${version}",
+ "mcversion": "1.12.2",
+ "url": "",
+ "updateUrl": "",
+ "authorList": ["citrons"],
+ "credits": "",
+ "logoFile": "",
+ "screenshots": [],
+ "dependencies": []
+}
+]
diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta
new file mode 100644
index 0000000..9bef406
--- /dev/null
+++ b/src/main/resources/pack.mcmeta
@@ -0,0 +1,7 @@
+{
+ "pack": {
+ "description": "homunculus resources",
+ "pack_format": 3,
+ "_comment": "A pack_format of 3 should be used starting with Minecraft 1.11. All resources, including language files, should be lowercase (eg: en_us.lang). A pack_format of 2 will load your mod resources with LegacyV2Adapter, which requires language files to have uppercase letters (eg: en_US.lang)."
+ }
+}