diff --git a/build.gradle b/build.gradle index 6e07a2b..1c7d0bc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,66 +1,21 @@ buildscript { repositories { - maven { - url 'https://repo.leviathan-studio.com/libs-release/' - credentials { - username = "${artifactory_user}" - password = "${artifactory_password}" - } - } + maven { url = 'https://repo.leviathan-studio.com/libs-release' } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' - classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.0.0" + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true } } -// plugins -apply plugin: 'net.minecraftforge.gradle.forge' +apply plugin: 'net.minecraftforge.gradle' +apply plugin: 'eclipse' apply plugin: 'maven-publish' -apply plugin: 'com.jfrog.artifactory' - -// Maven -version = "1.0.1" -group= "com.leviathanstudio" -archivesBaseName = "CraftStudioAPI" -ext.suffix="alpha" - -// Jenkins build -ext.buildnumber = 0 -if (System.getenv().TRAVIS_BUILD_NUMBER) { - project.buildnumber = System.getenv().TRAVIS_BUILD_NUMBER -} else { - logger.lifecycle "SETTING BUILDNUMBER TO 0" -} - -// Java -compileJava.options.encoding = 'UTF-8' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -minecraft { - version = "1.12-14.21.1.2387" - runDir = "run" - mappings = "snapshot_20170624" - replace "@VERSION@", project.version -} -//Full version -ext.fullVersion="${project.version}.${project.buildnumber}-mc${project.minecraft.version}" +version = '1.0.2' +group = 'com.leviathanstudio' // http://maven.apache.org/guides/mini/guide-naming-conventions.html +archivesBaseName = 'CraftStudioAPI' -if(ext.suffix != "") { - ext.fullVersion += "-${project.ext.suffix}" -} - -repositories { - maven { - url 'https://repo.leviathan-studio.com/libs-release/' - credentials { - username = "${artifactory_user}" - password = "${artifactory_password}" - } - } -} +sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. sourceSets { main { @@ -89,75 +44,110 @@ sourceSets { } } -dependencies { -} +minecraft { -processResources { - inputs.property "version", project.version - inputs.property "mcversion", project.minecraft.version - // resources - from(sourceSets.main.resources.srcDirs) { - include 'com/**/**' - include 'mcmod.info' - expand 'version':project.version, 'mcversion':project.minecraft.version - } - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' + mappings channel: 'snapshot', version: '20190719-1.14.3' + // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. + // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + + runs { + client { + workingDirectory project.file('run') + + property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + + property 'forge.logging.console.level', 'info' + + mods { + craftstudioapi { + ideaModule "${rootProject.name}.main" + source sourceSets.main + } + testmod { + ideaModule "${rootProject.name}.mod" + source sourceSets.mod + } + } + } + + server { + workingDirectory project.file('run') + + property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + + property 'forge.logging.console.level', 'info' + + mods { + craftstudioapi { + ideaModule "${rootProject.name}.main" + source sourceSets.main + } + testmod { + ideaModule "${rootProject.name}.mod" + source sourceSets.mod + } + } + } + + data { + workingDirectory project.file('run') + + property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + + property 'forge.logging.console.level', 'info' + + args '--mod', 'craftstudioapi', '--mod', 'testmod', '--all', '--output', file('src/generated/resources/') + + mods { + craftstudioapi { + source sourceSets.main + } + } + } } } -jar { - manifest { - attributes 'group':project.group - } - appendix = 'universal' - version = "${project.ext.fullVersion}" +dependencies { + minecraft 'net.minecraftforge:forge:1.14.4-28.0.51' } -task devJar(type: Jar) { - from(sourceSets.main.allSource) { - include 'com/**/**' - } - from(sourceSets.dev.allSource) { - include 'com/**/**' - } - from(sourceSets.main.output) { - include '**' - } - manifest { - attributes 'group':project.group - } - classifier = 'dev' - version = "${project.ext.fullVersion}" +repositories { + maven { url = 'https://repo.leviathan-studio.com/libs-release' } } -// Publish the library -artifactory { - contextUrl = "${artifactory_contextUrl}" - publish { - version = "${project.ext.fullVersion}" - repository { - repoKey = 'leviathan' - username = "${artifactory_user}" - password = "${artifactory_password}" - maven = true - } - defaults { - publications ('mavenJava') - } +// Example for how to get properties into the manifest for reading by the runtime.. +jar { + manifest { + attributes([ + "Specification-Title": "crafstudio_api", + "Specification-Vendor": "LeviathanStudio", + "Specification-Version": "1", // We are version 1 of ourselves + "Implementation-Title": project.name, + "Implementation-Version": "${version}", + "Implementation-Vendor" :"LeviathanStudio", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + ]) } } +// Example configuration to allow publishing using the maven-publish task +// we define a custom artifact that is sourced from the reobfJar output task +// and then declare that to be published +// Note you'll need to add a repository here +def reobfFile = file("$buildDir/reobfJar/output.jar") +def reobfArtifact = artifacts.add('default', reobfFile) { + type 'jar' + builtBy 'reobfJar' +} publishing { publications { mavenJava(MavenPublication) { - from components.java - artifact (devJar) { - classifier = 'dev' - } + artifact reobfArtifact } } -} - -build.dependsOn devJar -artifactoryPublish.dependsOn build + repositories { + maven { + url "file:///${project.projectDir}/mcmodsrepo" + } + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index f6768b0..878bf1f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -artifactory_user=leviathan -artifactory_password=APdsAiLd1UksNkxj2yRsKVqdMicTXhqHA2AjZ -artifactory_contextUrl=https://repo.leviathan-studio.com -org.gradle.daemon=true \ No newline at end of file +# 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 +org.gradle.daemon=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 30d399d..7a3265e 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6917d27..949819d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Mon Sep 14 12:28:28 PDT 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip diff --git a/gradlew b/gradlew index 91a7e26..cccdd3d 100644 --- a/gradlew +++ b/gradlew @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ############################################################################## ## @@ -6,20 +6,38 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# 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\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,31 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=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. @@ -90,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -114,6 +113,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` @@ -154,11 +154,19 @@ if $cygwin ; then 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=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" diff --git a/src/dev/java/com/leviathanstudio/craftstudio/dev/CraftStudioApiDev.java b/src/dev/java/com/leviathanstudio/craftstudio/dev/CraftStudioApiDev.java index 93da371..cff6d24 100644 --- a/src/dev/java/com/leviathanstudio/craftstudio/dev/CraftStudioApiDev.java +++ b/src/dev/java/com/leviathanstudio/craftstudio/dev/CraftStudioApiDev.java @@ -1,15 +1,14 @@ package com.leviathanstudio.craftstudio.dev; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - import com.leviathanstudio.craftstudio.dev.command.CommandCSList; import com.leviathanstudio.craftstudio.dev.command.CommandCSUVMap; -import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.event.server.FMLServerStartingEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Main class of the dev mod of the CraftStudioAPI @@ -18,9 +17,7 @@ * * @author Timmypote */ -@Mod(modid = CraftStudioApiDev.API_ID, name = CraftStudioApiDev.NAME, clientSideOnly = true, - version = "1.0.0", - acceptedMinecraftVersions = "1.12") +@Mod(CraftStudioApiDev.API_ID) public class CraftStudioApiDev { @@ -28,10 +25,13 @@ public class CraftStudioApiDev public static final String API_ID = "craftstudioapidev"; public static final String NAME = "CraftStudio API Dev"; - @EventHandler - public void init(FMLInitializationEvent event) { - ClientCommandHandler.instance.registerCommand(new CommandCSUVMap()); - ClientCommandHandler.instance.registerCommand(new CommandCSList()); + public CraftStudioApiDev() { + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::serverStartingEvent); + } + + private void serverStartingEvent(FMLServerStartingEvent event) { + CommandCSUVMap.register(event.getCommandDispatcher()); + CommandCSList.register(event.getCommandDispatcher()); } public static Logger getLogger() { diff --git a/src/dev/java/com/leviathanstudio/craftstudio/dev/command/CommandCSList.java b/src/dev/java/com/leviathanstudio/craftstudio/dev/command/CommandCSList.java index e4f175c..0008a16 100644 --- a/src/dev/java/com/leviathanstudio/craftstudio/dev/command/CommandCSList.java +++ b/src/dev/java/com/leviathanstudio/craftstudio/dev/command/CommandCSList.java @@ -1,26 +1,14 @@ package com.leviathanstudio.craftstudio.dev.command; import java.util.Arrays; -import java.util.Collections; import java.util.List; -import java.util.Set; -import javax.annotation.Nullable; +import com.mojang.brigadier.CommandDispatcher; -import com.leviathanstudio.craftstudio.client.registry.RegistryHandler; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.command.SyntaxErrorException; -import net.minecraft.command.WrongUsageException; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextComponentString; -import net.minecraftforge.client.IClientCommand; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.command.CommandSource; +import net.minecraft.command.Commands; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; /** * Command to list all the models or animations. @@ -29,8 +17,8 @@ * * @author Timmypote */ -@SideOnly(Side.CLIENT) -public class CommandCSList extends CommandBase implements IClientCommand +@OnlyIn(Dist.CLIENT) +public class CommandCSList { private static String name = "cslist"; @@ -38,12 +26,14 @@ public class CommandCSList extends CommandBase implements IClientCommand private static int permLevel = 0; private static List autoC = Arrays. asList(new String[] { "models", "animations" }); - @Override - public String getName() { - return CommandCSList.name; + public static void register(CommandDispatcher dispatcher) { + dispatcher.register(Commands.literal(name) + .requires(src -> src.hasPermissionLevel(permLevel))); + } - @Override + + /*@Override public String getUsage(ICommandSender sender) { return CommandCSList.usage; } @@ -70,18 +60,8 @@ else if (args[0].equals("animations")) throw new WrongUsageException(CommandCSList.usage); } - @Override - public int getRequiredPermissionLevel() { - return CommandCSList.permLevel; - } - @Override public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos) { return args.length == 1 ? getListOfStringsMatchingLastWord(args, CommandCSList.autoC) : Collections. emptyList(); - } - - @Override - public boolean allowUsageWithoutPrefix(ICommandSender sender, String message) { - return false; - } + }*/ } diff --git a/src/dev/java/com/leviathanstudio/craftstudio/dev/command/CommandCSUVMap.java b/src/dev/java/com/leviathanstudio/craftstudio/dev/command/CommandCSUVMap.java index c9e2856..bde00a9 100644 --- a/src/dev/java/com/leviathanstudio/craftstudio/dev/command/CommandCSUVMap.java +++ b/src/dev/java/com/leviathanstudio/craftstudio/dev/command/CommandCSUVMap.java @@ -1,26 +1,11 @@ package com.leviathanstudio.craftstudio.dev.command; -import java.util.Collections; -import java.util.List; - -import javax.annotation.Nullable; - -import com.leviathanstudio.craftstudio.client.exception.CSResourceNotRegisteredException; -import com.leviathanstudio.craftstudio.client.registry.RegistryHandler; -import com.leviathanstudio.craftstudio.dev.util.UVMapCreator; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.command.WrongUsageException; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextComponentString; -import net.minecraftforge.client.IClientCommand; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import com.mojang.brigadier.CommandDispatcher; +import net.minecraft.command.CommandSource; +import net.minecraft.command.Commands; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; /** * Command to generate a UV map for a specified model. * @@ -28,26 +13,23 @@ * * @author Timmypote */ -@SideOnly(Side.CLIENT) -public class CommandCSUVMap extends CommandBase implements IClientCommand -{ +@OnlyIn(Dist.CLIENT) +public class CommandCSUVMap { private static String name = "csuvmap"; private static String usage = "/csuvmap model"; private static int permLevel = 0; - @Override - public String getName() { - return CommandCSUVMap.name; - } - - @Override - public String getUsage(ICommandSender sender) { - return CommandCSUVMap.usage; + public static void register(CommandDispatcher dispatcher) { + //getListOfStringsMatchingLastWord(RegistryHandler.modelRegistry.keySet()); + //EntityArgument.entities() + dispatcher.register(Commands.literal(name) + .requires(src -> src.hasPermissionLevel(permLevel)) + ); + } - @Override - public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + /* public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length >= 1) { boolean succes = false; try { @@ -66,20 +48,7 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args } else throw new WrongUsageException(CommandCSUVMap.usage); - } + }*/ - @Override - public int getRequiredPermissionLevel() { - return CommandCSUVMap.permLevel; - } - @Override - public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos) { - return args.length == 1 ? getListOfStringsMatchingLastWord(args, RegistryHandler.modelRegistry.getKeys()) : Collections. emptyList(); - } - - @Override - public boolean allowUsageWithoutPrefix(ICommandSender sender, String message) { - return false; - } } diff --git a/src/dev/java/com/leviathanstudio/craftstudio/dev/util/UVMapCreator.java b/src/dev/java/com/leviathanstudio/craftstudio/dev/util/UVMapCreator.java index ea97b26..8ad6b23 100644 --- a/src/dev/java/com/leviathanstudio/craftstudio/dev/util/UVMapCreator.java +++ b/src/dev/java/com/leviathanstudio/craftstudio/dev/util/UVMapCreator.java @@ -16,8 +16,8 @@ import com.leviathanstudio.craftstudio.dev.CraftStudioApiDev; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; /** * Object to help generate a UV Map for a model. @@ -26,7 +26,8 @@ * * @author Timmypote */ -@SideOnly(Side.CLIENT) + +@OnlyIn(Dist.CLIENT) public class UVMapCreator { @@ -35,9 +36,8 @@ public class UVMapCreator private int maxu = 0, maxv = 0; public UVMapCreator(ResourceLocation modelIn) { - this.rModel = RegistryHandler.modelRegistry.getObject(modelIn); - if (this.rModel == null) - throw new CSResourceNotRegisteredException(modelIn.toString()); + this.rModel = RegistryHandler.modelRegistry.getValue(modelIn) + .orElseThrow(() -> new CSResourceNotRegisteredException(modelIn.toString())); } public boolean createUVMap() { diff --git a/src/main/java/com/leviathanstudio/craftstudio/CraftStudioApi.java b/src/main/java/com/leviathanstudio/craftstudio/CraftStudioApi.java index 528418d..6b9a367 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/CraftStudioApi.java +++ b/src/main/java/com/leviathanstudio/craftstudio/CraftStudioApi.java @@ -1,44 +1,48 @@ package com.leviathanstudio.craftstudio; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - +import com.leviathanstudio.craftstudio.client.registry.AssetAnimation; +import com.leviathanstudio.craftstudio.client.registry.AssetModel; +import com.leviathanstudio.craftstudio.client.registry.CSRegistryHelper; +import com.leviathanstudio.craftstudio.client.registry.RegistryHandler; import com.leviathanstudio.craftstudio.common.animation.AnimationHandler; import com.leviathanstudio.craftstudio.common.animation.IAnimated; +import com.leviathanstudio.craftstudio.proxy.CSClientProxy; import com.leviathanstudio.craftstudio.proxy.CSCommonProxy; +import com.leviathanstudio.craftstudio.proxy.CSServerProxy; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.network.NetworkRegistry; -import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.registries.IForgeRegistry; +import net.minecraftforge.registries.RegistryBuilder; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Main class of the CraftStudioApi - * - * @since 0.3.0 * * @author ZeAmateis * @author Timmypote + * @since 0.3.0 */ -@Mod(modid = CraftStudioApi.API_ID, name = CraftStudioApi.NAME, updateJSON = "https://leviathan-studio.com/craftstudioapi/update.json", - version = "1.0.0", - acceptedMinecraftVersions = "1.12") -public class CraftStudioApi -{ - private static final Logger LOGGER = LogManager.getLogger("CraftStudio"); - public static final String API_ID = "craftstudioapi"; - static final String NAME = "CraftStudio API"; - - public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(CraftStudioApi.API_ID); - - @SidedProxy(clientSide = "com.leviathanstudio.craftstudio.proxy.CSClientProxy", serverSide = "com.leviathanstudio.craftstudio.proxy.CSServerProxy") - private static CSCommonProxy proxy; - - @EventHandler - public void preInit(FMLPreInitializationEvent event) { - CraftStudioApi.proxy.preInit(event); +@Mod(CraftStudioApi.API_ID) +public class CraftStudioApi { + public static final String API_ID = "craftstudioapi"; + + private static final Logger LOGGER = LogManager.getLogger("CraftStudio"); + private static CSCommonProxy proxy = DistExecutor.runForDist(() -> CSClientProxy::new, () -> CSServerProxy::new); + + public CraftStudioApi() { + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonSetup); + MinecraftForge.EVENT_BUS.register(this); } public static Logger getLogger() { @@ -50,12 +54,20 @@ public static Logger getLogger() { * entity/block * * @param - * - * @param animated - * Class which implements IAnimated (Entity or TileEntity) + * @param animatedClass which implements IAnimated (Entity or TileEntity) */ public static AnimationHandler getNewAnimationHandler(Class animatedClass) { return CraftStudioApi.proxy.getNewAnimationHandler(animatedClass); } + + public void clientSetup(FMLClientSetupEvent event) { + CraftStudioApi.proxy.clientSetup(event); + } + + public void commonSetup(FMLCommonSetupEvent event) { + CraftStudioApi.proxy.commonSetup(event); + } + + } \ No newline at end of file diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/animation/CSAnimChannel.java b/src/main/java/com/leviathanstudio/craftstudio/client/animation/CSAnimChannel.java index 38ebeea..c0a4371 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/animation/CSAnimChannel.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/animation/CSAnimChannel.java @@ -1,50 +1,46 @@ package com.leviathanstudio.craftstudio.client.animation; -import java.util.Map.Entry; - -import javax.vecmath.Vector3f; - import com.leviathanstudio.craftstudio.CraftStudioApi; import com.leviathanstudio.craftstudio.client.exception.CSResourceNotRegisteredException; import com.leviathanstudio.craftstudio.client.json.CSReadedAnim; import com.leviathanstudio.craftstudio.client.json.CSReadedAnimBlock; import com.leviathanstudio.craftstudio.client.json.CSReadedAnimBlock.ReadedKeyFrame; -import com.leviathanstudio.craftstudio.client.registry.RegistryHandler; import com.leviathanstudio.craftstudio.client.json.CSReadedModel; import com.leviathanstudio.craftstudio.client.json.CSReadedModelBlock; +import com.leviathanstudio.craftstudio.client.registry.RegistryHandler; import com.leviathanstudio.craftstudio.client.util.MathHelper; - import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import javax.vecmath.Vector3f; +import java.util.Map.Entry; /** * Animation Channel for CraftStudio imported animation. * - * @since 0.3.0 - * * @author Timmypote + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class CSAnimChannel extends ClientChannel -{ - /** The registered animation it represent */ - private CSReadedAnim rAnim; - /** The registered model it animate */ +@OnlyIn(Dist.CLIENT) +public class CSAnimChannel extends ClientChannel { + /** + * The registered animation it represent + */ + private CSReadedAnim rAnim; + /** + * The registered model it animate + */ private CSReadedModel rModel; /** * Create a channel with the same name as the animation. Use the 60 fps by * default. * - * @param animNameIn - * The name of the animation in the registry. - * @param modelNameIn - * The name of the model bind to this animation in the registry. - * @param looped - * If the animation is looped or not. - * @throws CSResourceNotRegisteredException - * If the animation or model if not registered + * @param animIn The name of the animation in the registry. + * @param modelIn The name of the model bind to this animation in the registry. + * @param looped If the animation is looped or not. + * @throws CSResourceNotRegisteredException If the animation or model if not registered */ public CSAnimChannel(ResourceLocation animIn, ResourceLocation modelIn, boolean looped) throws CSResourceNotRegisteredException { this(animIn, modelIn, 60.0F, looped); @@ -53,25 +49,20 @@ public CSAnimChannel(ResourceLocation animIn, ResourceLocation modelIn, boolean /** * Create a channel. * - * @param animNameIn - * The name of the animation in the registry. - * @param name - * The name of the channel - * @param modelNameIn - * The name of the model bind to this animation in the registry. - * @param fps - * Keyframes per second of the animation. - * @param looped - * If the animation is looped or not. - * @throws CSResourceNotRegisteredException - * If the animation or model if not registered + * @param animIn The name of the animation in the registry. + * @param modelIn The name of the model bind to this animation in the registry. + * @param fps Keyframes per second of the animation. + * @param looped If the animation is looped or not. + * @throws CSResourceNotRegisteredException If the animation or model if not registered */ public CSAnimChannel(ResourceLocation animIn, ResourceLocation modelIn, float fps, boolean looped) throws CSResourceNotRegisteredException { super(animIn.toString(), false); - this.rAnim = RegistryHandler.animationRegistry.getObject(animIn); + //TODO Check ifPresent() + this.rAnim = RegistryHandler.animationRegistry.getValue(animIn).get(); if (this.rAnim == null) throw new CSResourceNotRegisteredException(animIn.toString()); - this.rModel = RegistryHandler.modelRegistry.getObject(modelIn); + //TODO Check ifPresent() + this.rModel = RegistryHandler.modelRegistry.getValue(modelIn).get(); if (this.rModel == null) throw new CSResourceNotRegisteredException(modelIn.toString()); if (!this.rModel.isAnimable()) { diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/animation/ClientAnimationHandler.java b/src/main/java/com/leviathanstudio/craftstudio/client/animation/ClientAnimationHandler.java index d055e09..5e2008e 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/animation/ClientAnimationHandler.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/animation/ClientAnimationHandler.java @@ -1,52 +1,212 @@ package com.leviathanstudio.craftstudio.client.animation; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.WeakHashMap; - -import javax.vecmath.Matrix4f; -import javax.vecmath.Quat4f; -import javax.vecmath.Vector3f; - import com.leviathanstudio.craftstudio.CraftStudioApi; import com.leviathanstudio.craftstudio.client.model.CSModelRenderer; -import com.leviathanstudio.craftstudio.common.animation.AnimationHandler; -import com.leviathanstudio.craftstudio.common.animation.Channel; -import com.leviathanstudio.craftstudio.common.animation.CustomChannel; -import com.leviathanstudio.craftstudio.common.animation.IAnimated; -import com.leviathanstudio.craftstudio.common.animation.InfoChannel; - +import com.leviathanstudio.craftstudio.common.animation.*; import net.minecraft.client.Minecraft; -import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.entity.model.RendererModel; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import javax.vecmath.Matrix4f; +import javax.vecmath.Quat4f; +import javax.vecmath.Vector3f; +import java.util.*; +import java.util.Map.Entry; /** * An object that hold the informations about its animated objects and all their * animations. It also start/stop/update the animations and render the models. * This is the client side AnimationHandler. * - * @since 0.3.0 - * + * @param The class of the animated object. * @author Timmypote * @author ZeAmateis - * - * @param - * The class of the animated object. + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class ClientAnimationHandler extends AnimationHandler -{ - /** Map with all the animations. */ - private Map animChannels = new HashMap<>(); +@OnlyIn(Dist.CLIENT) +public class ClientAnimationHandler extends AnimationHandler { + /** + * Map with all the animations. + */ + private Map animChannels = new HashMap<>(); - /** Map with the info about the animations. **/ + /** + * Map with the info about the animations. + **/ private Map> currentAnimInfo = new WeakHashMap<>(); + /** + * Check if game is paused, on the exit screen. + * + * @return true, if the game is paused. + */ + public static boolean isGamePaused() { + Minecraft MC = Minecraft.getInstance(); + return MC.isSingleplayer() && MC.currentScreen != null && MC.currentScreen.isPauseScreen() && !MC.getIntegratedServer().getPublic(); + } + + /** + * Apply animations if running or apply initial values. Should be only + * called by the model class. + * + * @param parts The list of block to update. + * @param animated The object that is animated. + */ + public static void performAnimationInModel(List parts, IAnimated animated) { + for (CSModelRenderer entry : parts) + performAnimationForBlock(entry, animated); + } + + /** + * Apply animations for model block. + * + * @param block The block to update. + * @param animated The object that is animated. + */ + public static void performAnimationForBlock(CSModelRenderer block, IAnimated animated) { + String boxName = block.boxName; + RendererModel child; + + if (animated.getAnimationHandler() instanceof ClientAnimationHandler) { + ClientAnimationHandler animHandler = (ClientAnimationHandler) animated.getAnimationHandler(); + + if (block.childModels != null) + for (int i = 0; i < block.childModels.size(); i++) { + child = block.childModels.get(i); + if (child instanceof CSModelRenderer) { + CSModelRenderer childModel = (CSModelRenderer) child; + performAnimationForBlock(childModel, animated); + } + } + + block.resetRotationPoint(); + block.resetRotationMatrix(); + block.resetOffset(); + block.resetStretch(); + + Map animInfoMap = (Map) animHandler.currentAnimInfo.get(animated); + if (animInfoMap == null) + return; + + for (Entry animInfo : animInfoMap.entrySet()) + if (animInfo.getKey() instanceof ClientChannel) { + ClientChannel clientChannel = (ClientChannel) animInfo.getKey(); + float currentFrame = animInfo.getValue().currentFrame; + + // Rotations + KeyFrame prevRotationKeyFrame = clientChannel.getPreviousRotationKeyFrameForBox(boxName, currentFrame); + int prevRotationKeyFramePosition = prevRotationKeyFrame != null ? clientChannel.getKeyFramePosition(prevRotationKeyFrame) : 0; + + KeyFrame nextRotationKeyFrame = clientChannel.getNextRotationKeyFrameForBox(boxName, currentFrame); + int nextRotationKeyFramePosition = nextRotationKeyFrame != null ? clientChannel.getKeyFramePosition(nextRotationKeyFrame) : 0; + + float SLERPProgress = (currentFrame - prevRotationKeyFramePosition) + / (nextRotationKeyFramePosition - prevRotationKeyFramePosition); + if (SLERPProgress > 1F || SLERPProgress < 0F) + SLERPProgress = 1F; + + if (prevRotationKeyFramePosition == 0 && prevRotationKeyFrame == null && !(nextRotationKeyFramePosition == 0)) { + Quat4f currentQuat = new Quat4f(); + currentQuat.interpolate(block.getDefaultRotationAsQuaternion(), nextRotationKeyFrame.modelRenderersRotations.get(boxName), + SLERPProgress); + Matrix4f mat = block.getRotationMatrix(); + mat.set(currentQuat); + mat.transpose(); + } else if (nextRotationKeyFramePosition != 0) { + Quat4f currentQuat = new Quat4f(); + currentQuat.interpolate(prevRotationKeyFrame.modelRenderersRotations.get(boxName), + nextRotationKeyFrame.modelRenderersRotations.get(boxName), SLERPProgress); + Matrix4f mat = block.getRotationMatrix(); + mat.set(currentQuat); + mat.transpose(); + } + + // Translations + KeyFrame prevTranslationKeyFrame = clientChannel.getPreviousTranslationKeyFrameForBox(boxName, currentFrame); + int prevTranslationsKeyFramePosition = prevTranslationKeyFrame != null + ? clientChannel.getKeyFramePosition(prevTranslationKeyFrame) : 0; + + KeyFrame nextTranslationKeyFrame = clientChannel.getNextTranslationKeyFrameForBox(boxName, currentFrame); + int nextTranslationsKeyFramePosition = nextTranslationKeyFrame != null + ? clientChannel.getKeyFramePosition(nextTranslationKeyFrame) : 0; + + float LERPProgress = (currentFrame - prevTranslationsKeyFramePosition) + / (nextTranslationsKeyFramePosition - prevTranslationsKeyFramePosition); + if (LERPProgress > 1F || LERPProgress < 0F) + LERPProgress = 1F; + + if (prevTranslationsKeyFramePosition == 0 && prevTranslationKeyFrame == null && !(nextTranslationsKeyFramePosition == 0)) { + Vector3f startPosition = block.getPositionAsVector(); + Vector3f endPosition = nextTranslationKeyFrame.modelRenderersTranslations.get(boxName); + Vector3f currentPosition = new Vector3f(startPosition); + currentPosition.interpolate(endPosition, LERPProgress); + block.setRotationPoint(currentPosition.x, currentPosition.y, currentPosition.z); + } else if (nextTranslationsKeyFramePosition != 0) { + Vector3f startPosition = prevTranslationKeyFrame.modelRenderersTranslations.get(boxName); + Vector3f endPosition = nextTranslationKeyFrame.modelRenderersTranslations.get(boxName); + Vector3f currentPosition = new Vector3f(startPosition); + currentPosition.interpolate(endPosition, LERPProgress); + block.setRotationPoint(currentPosition.x, currentPosition.y, currentPosition.z); + } + + // Offsets + KeyFrame prevOffsetKeyFrame = clientChannel.getPreviousOffsetKeyFrameForBox(boxName, currentFrame); + int prevOffsetKeyFramePosition = prevOffsetKeyFrame != null ? clientChannel.getKeyFramePosition(prevOffsetKeyFrame) : 0; + + KeyFrame nextOffsetKeyFrame = clientChannel.getNextOffsetKeyFrameForBox(boxName, currentFrame); + int nextOffsetKeyFramePosition = nextOffsetKeyFrame != null ? clientChannel.getKeyFramePosition(nextOffsetKeyFrame) : 0; + + float OffProgress = (currentFrame - prevOffsetKeyFramePosition) / (nextOffsetKeyFramePosition - prevOffsetKeyFramePosition); + if (OffProgress > 1F || OffProgress < 0F) + OffProgress = 1F; + + if (prevOffsetKeyFramePosition == 0 && prevOffsetKeyFrame == null && !(nextOffsetKeyFramePosition == 0)) { + Vector3f startPosition = block.getOffsetAsVector(); + Vector3f endPosition = nextOffsetKeyFrame.modelRenderersOffsets.get(boxName); + Vector3f currentPosition = new Vector3f(startPosition); + currentPosition.interpolate(endPosition, OffProgress); + block.setOffset(currentPosition.x, currentPosition.y, currentPosition.z); + } else if (nextOffsetKeyFramePosition != 0) { + Vector3f startPosition = prevOffsetKeyFrame.modelRenderersOffsets.get(boxName); + Vector3f endPosition = nextOffsetKeyFrame.modelRenderersOffsets.get(boxName); + Vector3f currentPosition = new Vector3f(startPosition); + currentPosition.interpolate(endPosition, OffProgress); + block.setOffset(currentPosition.x, currentPosition.y, currentPosition.z); + } + + // Stretch + KeyFrame prevStretchKeyFrame = clientChannel.getPreviousStretchKeyFrameForBox(boxName, currentFrame); + int prevStretchKeyFramePosition = prevStretchKeyFrame != null ? clientChannel.getKeyFramePosition(prevStretchKeyFrame) : 0; + + KeyFrame nextStretchKeyFrame = clientChannel.getNextStretchKeyFrameForBox(boxName, currentFrame); + int nextStretchKeyFramePosition = nextStretchKeyFrame != null ? clientChannel.getKeyFramePosition(nextStretchKeyFrame) : 0; + + float strProgress = (currentFrame - prevStretchKeyFramePosition) / (nextStretchKeyFramePosition - prevStretchKeyFramePosition); + if (strProgress > 1F || strProgress < 0F) + strProgress = 1F; + + if (prevStretchKeyFramePosition == 0 && prevStretchKeyFrame == null && !(nextStretchKeyFramePosition == 0)) { + Vector3f startPosition = block.getStretchAsVector(); + Vector3f endPosition = nextStretchKeyFrame.modelRenderersStretchs.get(boxName); + Vector3f currentPosition = new Vector3f(startPosition); + currentPosition.interpolate(endPosition, strProgress); + block.setStretch(currentPosition.x, currentPosition.y, currentPosition.z); + } else if (nextStretchKeyFramePosition != 0) { + Vector3f startPosition = prevStretchKeyFrame.modelRenderersStretchs.get(boxName); + Vector3f endPosition = nextStretchKeyFrame.modelRenderersStretchs.get(boxName); + Vector3f currentPosition = new Vector3f(startPosition); + currentPosition.interpolate(endPosition, strProgress); + block.setStretch(currentPosition.x, currentPosition.y, currentPosition.z); + } + + } else if (animInfo.getKey() instanceof CustomChannel) + ((CustomChannel) animInfo.getKey()).update(block, animated); + } + + } + @Override public void addAnim(String modid, String animNameIn, String modelNameIn, boolean looped) { super.addAnim(modid, animNameIn, modelNameIn, looped); @@ -133,7 +293,7 @@ public void animationsUpdate(T animatedElement) { if (animInfoMap == null) return; - for (Iterator> it = animInfoMap.entrySet().iterator(); it.hasNext();) { + for (Iterator> it = animInfoMap.entrySet().iterator(); it.hasNext(); ) { Entry animInfo = it.next(); animInfo.getValue(); boolean canUpdate = this.canUpdateAnimation(animInfo.getKey(), animatedElement); @@ -207,196 +367,15 @@ public boolean canUpdateAnimation(Channel channel, T animatedElement) { return true; } return false; - } - else + } else return true; - } - else { + } else { animInfo.prevTime = currentTime; return true; } } - /** - * Check if game is paused, on the exit screen. - * - * @return true, if the game is paused. - */ - public static boolean isGamePaused() { - Minecraft MC = Minecraft.getMinecraft(); - return MC.isSingleplayer() && MC.currentScreen != null && MC.currentScreen.doesGuiPauseGame() && !MC.getIntegratedServer().getPublic(); - } - - /** - * Apply animations if running or apply initial values. Should be only - * called by the model class. - * - * @param parts - * The list of block to update. - * @param animated - * The object that is animated. - */ - public static void performAnimationInModel(List parts, IAnimated animated) { - for (CSModelRenderer entry : parts) - performAnimationForBlock(entry, animated); - } - - /** - * Apply animations for model block. - * - * @param block - * The block to update. - * @param animated - * The object that is animated. - */ - public static void performAnimationForBlock(CSModelRenderer block, IAnimated animated) { - String boxName = block.boxName; - ModelRenderer child; - - if (animated.getAnimationHandler() instanceof ClientAnimationHandler) { - ClientAnimationHandler animHandler = (ClientAnimationHandler) animated.getAnimationHandler(); - - if (block.childModels != null) - for (int i = 0; i < block.childModels.size(); i++) { - child = block.childModels.get(i); - if (child instanceof CSModelRenderer) { - CSModelRenderer childModel = (CSModelRenderer) child; - performAnimationForBlock(childModel, animated); - } - } - - block.resetRotationPoint(); - block.resetRotationMatrix(); - block.resetOffset(); - block.resetStretch(); - - Map animInfoMap = (Map) animHandler.currentAnimInfo.get(animated); - if (animInfoMap == null) - return; - - for (Entry animInfo : animInfoMap.entrySet()) - if (animInfo.getKey() instanceof ClientChannel) { - ClientChannel clientChannel = (ClientChannel) animInfo.getKey(); - float currentFrame = animInfo.getValue().currentFrame; - - // Rotations - KeyFrame prevRotationKeyFrame = clientChannel.getPreviousRotationKeyFrameForBox(boxName, currentFrame); - int prevRotationKeyFramePosition = prevRotationKeyFrame != null ? clientChannel.getKeyFramePosition(prevRotationKeyFrame) : 0; - - KeyFrame nextRotationKeyFrame = clientChannel.getNextRotationKeyFrameForBox(boxName, currentFrame); - int nextRotationKeyFramePosition = nextRotationKeyFrame != null ? clientChannel.getKeyFramePosition(nextRotationKeyFrame) : 0; - - float SLERPProgress = (currentFrame - prevRotationKeyFramePosition) - / (nextRotationKeyFramePosition - prevRotationKeyFramePosition); - if (SLERPProgress > 1F || SLERPProgress < 0F) - SLERPProgress = 1F; - - if (prevRotationKeyFramePosition == 0 && prevRotationKeyFrame == null && !(nextRotationKeyFramePosition == 0)) { - Quat4f currentQuat = new Quat4f(); - currentQuat.interpolate(block.getDefaultRotationAsQuaternion(), nextRotationKeyFrame.modelRenderersRotations.get(boxName), - SLERPProgress); - Matrix4f mat = block.getRotationMatrix(); - mat.set(currentQuat); - mat.transpose(); - } - else if (nextRotationKeyFramePosition != 0) { - Quat4f currentQuat = new Quat4f(); - currentQuat.interpolate(prevRotationKeyFrame.modelRenderersRotations.get(boxName), - nextRotationKeyFrame.modelRenderersRotations.get(boxName), SLERPProgress); - Matrix4f mat = block.getRotationMatrix(); - mat.set(currentQuat); - mat.transpose(); - } - - // Translations - KeyFrame prevTranslationKeyFrame = clientChannel.getPreviousTranslationKeyFrameForBox(boxName, currentFrame); - int prevTranslationsKeyFramePosition = prevTranslationKeyFrame != null - ? clientChannel.getKeyFramePosition(prevTranslationKeyFrame) : 0; - - KeyFrame nextTranslationKeyFrame = clientChannel.getNextTranslationKeyFrameForBox(boxName, currentFrame); - int nextTranslationsKeyFramePosition = nextTranslationKeyFrame != null - ? clientChannel.getKeyFramePosition(nextTranslationKeyFrame) : 0; - - float LERPProgress = (currentFrame - prevTranslationsKeyFramePosition) - / (nextTranslationsKeyFramePosition - prevTranslationsKeyFramePosition); - if (LERPProgress > 1F || LERPProgress < 0F) - LERPProgress = 1F; - - if (prevTranslationsKeyFramePosition == 0 && prevTranslationKeyFrame == null && !(nextTranslationsKeyFramePosition == 0)) { - Vector3f startPosition = block.getPositionAsVector(); - Vector3f endPosition = nextTranslationKeyFrame.modelRenderersTranslations.get(boxName); - Vector3f currentPosition = new Vector3f(startPosition); - currentPosition.interpolate(endPosition, LERPProgress); - block.setRotationPoint(currentPosition.x, currentPosition.y, currentPosition.z); - } - else if (nextTranslationsKeyFramePosition != 0) { - Vector3f startPosition = prevTranslationKeyFrame.modelRenderersTranslations.get(boxName); - Vector3f endPosition = nextTranslationKeyFrame.modelRenderersTranslations.get(boxName); - Vector3f currentPosition = new Vector3f(startPosition); - currentPosition.interpolate(endPosition, LERPProgress); - block.setRotationPoint(currentPosition.x, currentPosition.y, currentPosition.z); - } - - // Offsets - KeyFrame prevOffsetKeyFrame = clientChannel.getPreviousOffsetKeyFrameForBox(boxName, currentFrame); - int prevOffsetKeyFramePosition = prevOffsetKeyFrame != null ? clientChannel.getKeyFramePosition(prevOffsetKeyFrame) : 0; - - KeyFrame nextOffsetKeyFrame = clientChannel.getNextOffsetKeyFrameForBox(boxName, currentFrame); - int nextOffsetKeyFramePosition = nextOffsetKeyFrame != null ? clientChannel.getKeyFramePosition(nextOffsetKeyFrame) : 0; - - float OffProgress = (currentFrame - prevOffsetKeyFramePosition) / (nextOffsetKeyFramePosition - prevOffsetKeyFramePosition); - if (OffProgress > 1F || OffProgress < 0F) - OffProgress = 1F; - - if (prevOffsetKeyFramePosition == 0 && prevOffsetKeyFrame == null && !(nextOffsetKeyFramePosition == 0)) { - Vector3f startPosition = block.getOffsetAsVector(); - Vector3f endPosition = nextOffsetKeyFrame.modelRenderersOffsets.get(boxName); - Vector3f currentPosition = new Vector3f(startPosition); - currentPosition.interpolate(endPosition, OffProgress); - block.setOffset(currentPosition.x, currentPosition.y, currentPosition.z); - } - else if (nextOffsetKeyFramePosition != 0) { - Vector3f startPosition = prevOffsetKeyFrame.modelRenderersOffsets.get(boxName); - Vector3f endPosition = nextOffsetKeyFrame.modelRenderersOffsets.get(boxName); - Vector3f currentPosition = new Vector3f(startPosition); - currentPosition.interpolate(endPosition, OffProgress); - block.setOffset(currentPosition.x, currentPosition.y, currentPosition.z); - } - - // Stretch - KeyFrame prevStretchKeyFrame = clientChannel.getPreviousStretchKeyFrameForBox(boxName, currentFrame); - int prevStretchKeyFramePosition = prevStretchKeyFrame != null ? clientChannel.getKeyFramePosition(prevStretchKeyFrame) : 0; - - KeyFrame nextStretchKeyFrame = clientChannel.getNextStretchKeyFrameForBox(boxName, currentFrame); - int nextStretchKeyFramePosition = nextStretchKeyFrame != null ? clientChannel.getKeyFramePosition(nextStretchKeyFrame) : 0; - - float strProgress = (currentFrame - prevStretchKeyFramePosition) / (nextStretchKeyFramePosition - prevStretchKeyFramePosition); - if (strProgress > 1F || strProgress < 0F) - strProgress = 1F; - - if (prevStretchKeyFramePosition == 0 && prevStretchKeyFrame == null && !(nextStretchKeyFramePosition == 0)) { - Vector3f startPosition = block.getStretchAsVector(); - Vector3f endPosition = nextStretchKeyFrame.modelRenderersStretchs.get(boxName); - Vector3f currentPosition = new Vector3f(startPosition); - currentPosition.interpolate(endPosition, strProgress); - block.setStretch(currentPosition.x, currentPosition.y, currentPosition.z); - } - else if (nextStretchKeyFramePosition != 0) { - Vector3f startPosition = prevStretchKeyFrame.modelRenderersStretchs.get(boxName); - Vector3f endPosition = nextStretchKeyFrame.modelRenderersStretchs.get(boxName); - Vector3f currentPosition = new Vector3f(startPosition); - currentPosition.interpolate(endPosition, strProgress); - block.setStretch(currentPosition.x, currentPosition.y, currentPosition.z); - } - - } - else if (animInfo.getKey() instanceof CustomChannel) - ((CustomChannel) animInfo.getKey()).update(block, animated); - } - - } - /** * Getter of currentAnimInfo. * @@ -409,8 +388,7 @@ public Map> getCurrentAnimInfo() { /** * Setter of currentAnimInfo. * - * @param currentAnimInfo - * the currentAnimInfo to set. + * @param currentAnimInfo the currentAnimInfo to set. */ public void setCurrentAnimInfo(Map> currentAnimInfo) { this.currentAnimInfo = currentAnimInfo; @@ -428,8 +406,7 @@ public Map getAnimChannels() { /** * Setter of animChannels. * - * @param animChannels - * the animChannels to set. + * @param animChannels the animChannels to set. */ public void setAnimChannels(Map animChannels) { this.animChannels = animChannels; diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/animation/ClientChannel.java b/src/main/java/com/leviathanstudio/craftstudio/client/animation/ClientChannel.java index 1b4d3d0..86fa4ab 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/animation/ClientChannel.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/animation/ClientChannel.java @@ -1,37 +1,36 @@ package com.leviathanstudio.craftstudio.client.animation; +import com.leviathanstudio.craftstudio.common.animation.InfoChannel; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import com.leviathanstudio.craftstudio.common.animation.InfoChannel; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - /** * A InfoChannel that hold keyframes to animate a model. * - * @since 0.3.0 - * * @author Timmypote + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class ClientChannel extends InfoChannel -{ - /** KeyFrames. Key is the position of that keyFrame in the frames list. */ - private Map keyFrames = new HashMap<>(); +@OnlyIn(Dist.CLIENT) +public class ClientChannel extends InfoChannel { + /** + * KeyFrames. Key is the position of that keyFrame in the frames list. + */ + private Map keyFrames = new HashMap<>(); - /** How this animation should behave. */ - private EnumAnimationMode animationMode = EnumAnimationMode.LINEAR; + /** + * How this animation should behave. + */ + private EnumAnimationMode animationMode = EnumAnimationMode.LINEAR; /** * Create an empty ClientChannel, with {@code totalFrames} = 0. * - * @param channelName - * The name of the animation channel. - * @param initialize - * If the keyFrames should be initialized in the constructor. + * @param channelName The name of the animation channel. + * @param initialize If the keyFrames should be initialized in the constructor. */ public ClientChannel(String channelName, boolean initialize) { super(channelName); @@ -42,16 +41,11 @@ public ClientChannel(String channelName, boolean initialize) { /** * Create a ClientChannel. * - * @param animationName - * The name of the animation channel. - * @param fps - * The number of frame per seconds. - * @param totalFrames - * The total number of frames. - * @param animationMode - * The animation mode. - * @param initialize - * If the keyFrames should be initialized in the constructor. + * @param animationName The name of the animation channel. + * @param fps The number of frame per seconds. + * @param totalFrames The total number of frames. + * @param animationMode The animation mode. + * @param initialize If the keyFrames should be initialized in the constructor. */ public ClientChannel(String animationName, float fps, int totalFrames, EnumAnimationMode animationMode, boolean initialize) { this(animationName, initialize); @@ -62,18 +56,19 @@ public ClientChannel(String animationName, float fps, int totalFrames, EnumAnima this.looped = true; } - /** Create all the frames and add them in the list in the correct order. */ - protected void initializeAllFrames() {} + /** + * Create all the frames and add them in the list in the correct order. + */ + protected void initializeAllFrames() { + } /** * Return the previous rotation KeyFrame before this frame that uses this * box, if it exists. If currentFrame is a keyFrame that uses this box, it * is returned. * - * @param boxName - * The name of the box. - * @param currentFrame - * The current frame. + * @param boxName The name of the box. + * @param currentFrame The current frame. * @return The previous key frames. */ public KeyFrame getPreviousRotationKeyFrameForBox(String boxName, float currentFrame) { @@ -105,10 +100,8 @@ public KeyFrame getPreviousRotationKeyFrameForBox(String boxName, float currentF * if it exists. If currentFrame is a keyFrame that uses this box, it is NOT * considered. * - * @param boxName - * The name of the box. - * @param currentFrame - * The current frame. + * @param boxName The name of the box. + * @param currentFrame The current frame. * @return The next key frames. */ public KeyFrame getNextRotationKeyFrameForBox(String boxName, float currentFrame) { @@ -141,10 +134,8 @@ public KeyFrame getNextRotationKeyFrameForBox(String boxName, float currentFrame * box, if it exists. If currentFrame is a keyFrame that uses this box, it * is returned. * - * @param boxName - * The name of the box. - * @param currentFrame - * The current frame. + * @param boxName The name of the box. + * @param currentFrame The current frame. * @return The previous key frames. */ public KeyFrame getPreviousTranslationKeyFrameForBox(String boxName, float currentFrame) { @@ -176,10 +167,8 @@ public KeyFrame getPreviousTranslationKeyFrameForBox(String boxName, float curre * box, if it exists. If currentFrame is a keyFrame that uses this box, it * is NOT considered. * - * @param boxName - * The name of the box. - * @param currentFrame - * The current frame. + * @param boxName The name of the box. + * @param currentFrame The current frame. * @return The next key frames. */ public KeyFrame getNextTranslationKeyFrameForBox(String boxName, float currentFrame) { @@ -213,10 +202,8 @@ public KeyFrame getNextTranslationKeyFrameForBox(String boxName, float currentFr * if it exists. If currentFrame is a keyFrame that uses this box, it is * returned. * - * @param boxName - * The name of the box. - * @param currentFrame - * The current frame. + * @param boxName The name of the box. + * @param currentFrame The current frame. * @return The previous key frames. */ public KeyFrame getPreviousOffsetKeyFrameForBox(String boxName, float currentFrame) { @@ -248,10 +235,8 @@ public KeyFrame getPreviousOffsetKeyFrameForBox(String boxName, float currentFra * it exists. If currentFrame is a keyFrame that uses this box, it is NOT * considered. * - * @param boxName - * The name of the box. - * @param currentFrame - * The current frame. + * @param boxName The name of the box. + * @param currentFrame The current frame. * @return The next key frames. */ public KeyFrame getNextOffsetKeyFrameForBox(String boxName, float currentFrame) { @@ -285,10 +270,8 @@ public KeyFrame getNextOffsetKeyFrameForBox(String boxName, float currentFrame) * box, if it exists. If curretFrame is a keyFrame that uses this box, it is * returned. * - * @param boxName - * The name of the box. - * @param currentFrame - * The current frame. + * @param boxName The name of the box. + * @param currentFrame The current frame. * @return The previous key frames. */ public KeyFrame getPreviousStretchKeyFrameForBox(String boxName, float currentFrame) { @@ -320,10 +303,8 @@ public KeyFrame getPreviousStretchKeyFrameForBox(String boxName, float currentFr * if it exists. If currentFrame is a keyFrame that uses this box, it is NOT * considered. * - * @param boxName - * The name of the box. - * @param currentFrame - * The current frame. + * @param boxName The name of the box. + * @param currentFrame The current frame. * @return The next key frames. */ public KeyFrame getNextStretchKeyFrameForBox(String boxName, float currentFrame) { @@ -356,8 +337,7 @@ public KeyFrame getNextStretchKeyFrameForBox(String boxName, float currentFrame) * Get the position of the keyframe in this animation, if the keyframe * exists. * - * @param keyFrame - * The keyframe. + * @param keyFrame The keyframe. * @return The position of the keyframe, -1 if it doesn't exist. */ public int getKeyFramePosition(KeyFrame keyFrame) { @@ -375,8 +355,7 @@ public int getKeyFramePosition(KeyFrame keyFrame) { /** * Get inverted channel, for inverted animation. * - * @param name - * The name of the new Channel. + * @param name The name of the new Channel. * @return The new Channel. */ public ClientChannel getInvertedChannel(String name) { @@ -398,8 +377,7 @@ public Map getKeyFrames() { /** * Setter of keyFrames. * - * @param keyFrames - * the keyFrames to set. + * @param keyFrames the keyFrames to set. */ public void setKeyFrames(Map keyFrames) { this.keyFrames = keyFrames; @@ -417,8 +395,7 @@ public EnumAnimationMode getAnimationMode() { /** * Setter of animationMode. * - * @param animationMode - * the animationMode to set. + * @param animationMode the animationMode to set. */ public void setAnimationMode(EnumAnimationMode animationMode) { this.animationMode = animationMode; diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/animation/EnumAnimationMode.java b/src/main/java/com/leviathanstudio/craftstudio/client/animation/EnumAnimationMode.java index 907629d..3539877 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/animation/EnumAnimationMode.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/animation/EnumAnimationMode.java @@ -1,22 +1,27 @@ package com.leviathanstudio.craftstudio.client.animation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; /** * Enumeration of the possible animation mode. * - * @since 0.3.0 - * * @author Timmypote * @author Phenix246 + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) +@OnlyIn(Dist.CLIENT) public enum EnumAnimationMode { - /** An animation that play just once */ + /** + * An animation that play just once + */ LINEAR, - /** An animation that play once and hold the last keyframe */ + /** + * An animation that play once and hold the last keyframe + */ HOLD, - /** An animation that restart everytime it end */ + /** + * An animation that restart everytime it end + */ LOOP; } diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/animation/KeyFrame.java b/src/main/java/com/leviathanstudio/craftstudio/client/animation/KeyFrame.java index 469bb88..e3de372 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/animation/KeyFrame.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/animation/KeyFrame.java @@ -1,39 +1,43 @@ package com.leviathanstudio.craftstudio.client.animation; -import java.util.HashMap; -import java.util.Map; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import javax.vecmath.Quat4f; import javax.vecmath.Vector3f; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import java.util.HashMap; +import java.util.Map; /** * Class that store informations about a model at a specific time of an * animation. - * - * @since 0.3.0 - * + * * @author Timmypote + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class KeyFrame implements Cloneable -{ - /** Map of quaternions for block rotation */ - protected Map modelRenderersRotations = new HashMap<>(); - /** Map of vector for block translation */ +@OnlyIn(Dist.CLIENT) +public class KeyFrame implements Cloneable { + /** + * Map of quaternions for block rotation + */ + protected Map modelRenderersRotations = new HashMap<>(); + /** + * Map of vector for block translation + */ protected Map modelRenderersTranslations = new HashMap<>(); - /** Map of vector for block offset */ - protected Map modelRenderersOffsets = new HashMap<>(); - /** Map of vector for block stretch */ - protected Map modelRenderersStretchs = new HashMap<>(); + /** + * Map of vector for block offset + */ + protected Map modelRenderersOffsets = new HashMap<>(); + /** + * Map of vector for block stretch + */ + protected Map modelRenderersStretchs = new HashMap<>(); /** * Check if box is in rotation. * - * @param boxName - * The name of the box. + * @param boxName The name of the box. * @return True if is in rotation, false if not. */ public boolean useBoxInRotations(String boxName) { @@ -43,8 +47,7 @@ public boolean useBoxInRotations(String boxName) { /** * Check if box is in translation. * - * @param boxName - * The name of the box. + * @param boxName The name of the box. * @return True if is in translation, false if not. */ public boolean useBoxInTranslations(String boxName) { @@ -54,8 +57,7 @@ public boolean useBoxInTranslations(String boxName) { /** * Check if box has offset modification. * - * @param boxName - * The name of the box. + * @param boxName The name of the box. * @return True if has offset modification, false if not. */ public boolean useBoxInOffsets(String boxName) { @@ -65,8 +67,7 @@ public boolean useBoxInOffsets(String boxName) { /** * Check if box has stretch modification. * - * @param boxName - * The name of the box. + * @param boxName The name of the box. * @return True if has stretch modification, false if not. */ public boolean useBoxInStretchs(String boxName) { diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/exception/CSMalformedJsonException.java b/src/main/java/com/leviathanstudio/craftstudio/client/exception/CSMalformedJsonException.java index a2bd547..32ebd3d 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/exception/CSMalformedJsonException.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/exception/CSMalformedJsonException.java @@ -1,30 +1,25 @@ package com.leviathanstudio.craftstudio.client.exception; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; /** * Exception raised when there is an error during json reading caused by a * malformed json. - * - * @since 0.3.0 * * @author Timmypote + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class CSMalformedJsonException extends Exception -{ +@OnlyIn(Dist.CLIENT) +public class CSMalformedJsonException extends Exception { private static final long serialVersionUID = -3495512445212088386L; /** * Create a exception for a missing field. * - * @param field - * The name of the field. - * @param type - * The type of the field. - * @param ress - * The resource that is malformed. + * @param field The name of the field. + * @param type The type of the field. + * @param ress The resource that is malformed. */ public CSMalformedJsonException(String field, String type, String ress) { super("Missing field " + field + " of type " + type + " in " + ress); @@ -33,10 +28,8 @@ public CSMalformedJsonException(String field, String type, String ress) { /** * Create a exception for a malformed field. * - * @param element - * Element that is malformed. - * @param ress - * The resource that is malformed. + * @param element Element that is malformed. + * @param ress The resource that is malformed. */ public CSMalformedJsonException(String element, String ress) { super("Malformation of " + element + " in " + ress); diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/exception/CSResourceNotFoundException.java b/src/main/java/com/leviathanstudio/craftstudio/client/exception/CSResourceNotFoundException.java index ae471bd..0620dbb 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/exception/CSResourceNotFoundException.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/exception/CSResourceNotFoundException.java @@ -1,27 +1,24 @@ package com.leviathanstudio.craftstudio.client.exception; -import java.io.FileNotFoundException; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import java.io.FileNotFoundException; /** * Exception raised when opening a .csjsmodel or .csjsmodelanim file has failed. - * - * @since 0.3.0 * * @author Phenix246 + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class CSResourceNotFoundException extends FileNotFoundException -{ +@OnlyIn(Dist.CLIENT) +public class CSResourceNotFoundException extends FileNotFoundException { private static final long serialVersionUID = -3495512420502088386L; /** * Create an exception for a resource not found. * - * @param resourceIn - * The resource that wasn't found. + * @param resourceIn The resource that wasn't found. */ public CSResourceNotFoundException(String resourceIn) { super("Resource not found: " + resourceIn); diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/exception/CSResourceNotRegisteredException.java b/src/main/java/com/leviathanstudio/craftstudio/client/exception/CSResourceNotRegisteredException.java index b634185..bef2330 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/exception/CSResourceNotRegisteredException.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/exception/CSResourceNotRegisteredException.java @@ -1,26 +1,23 @@ package com.leviathanstudio.craftstudio.client.exception; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; /** * Exception raised when the program try to call a resource that isn't * registered. - * - * @since 0.3.0 * * @author Timmypote + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class CSResourceNotRegisteredException extends RuntimeException -{ +@OnlyIn(Dist.CLIENT) +public class CSResourceNotRegisteredException extends RuntimeException { private static final long serialVersionUID = -3495512420502365486L; /** * Create an exception for a resource not registered. * - * @param resourceNameIn - * The resource that isn't registered. + * @param resourceNameIn The resource that isn't registered. */ public CSResourceNotRegisteredException(String resourceNameIn) { super("You are trying to acces \"" + resourceNameIn + "\", but it's not registered"); diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/json/CSJsonReader.java b/src/main/java/com/leviathanstudio/craftstudio/client/json/CSJsonReader.java index 5c6c2e4..75c2439 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/json/CSJsonReader.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/json/CSJsonReader.java @@ -1,14 +1,5 @@ package com.leviathanstudio.craftstudio.client.json; -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.InputStreamReader; -import java.util.Map.Entry; - -import javax.vecmath.Vector3f; - -import org.apache.commons.io.Charsets; - import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -17,40 +8,46 @@ import com.leviathanstudio.craftstudio.client.exception.CSMalformedJsonException; import com.leviathanstudio.craftstudio.client.exception.CSResourceNotFoundException; import com.leviathanstudio.craftstudio.client.util.EnumFrameType; - import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.IResource; +import net.minecraft.resources.IResource; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import org.apache.commons.io.Charsets; + +import javax.vecmath.Vector3f; +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Map.Entry; /** * Class used to read json and extract a {@link CSReadedModel} or a * {@link CSReadedAnim}. - * - * @since 0.3.0 * * @author Timmypote * @author ZeAmateis * @author Phenix246 + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class CSJsonReader -{ - /** The JsonObject that is the root of the file */ +@OnlyIn(Dist.CLIENT) +public class CSJsonReader { + /** + * The JsonObject that is the root of the file + */ private JsonObject root; - /** The resource location */ - private String ress; + /** + * The resource location + */ + private String ress; /** * Create a {@link CSJsonReader} link to the resource. * - * @param resourceIn - * Location of the model.csjsmodel or the - * anim.csjsmodelanim. - * @throws CraftStudioModelNotFound - * If the files doesn't exist. - * + * @param resourceIn Location of the model.csjsmodel or the + * anim.csjsmodelanim. + * @throws CSResourceNotFoundException If the files doesn't exist. * @see #readModel() * @see #readAnim() */ @@ -62,7 +59,13 @@ public CSJsonReader(ResourceLocation resourceIn) throws CSResourceNotFoundExcept this.ress = resourceIn.toString(); try { - iResource = Minecraft.getMinecraft().getResourceManager().getResource(resourceIn); + System.out.println(Minecraft.getInstance().getResourceManager().getResource(resourceIn).getLocation()); + } catch (IOException ex) { + ex.printStackTrace(); + } + + try { + iResource = Minecraft.getInstance().getResourceManager().getResource(resourceIn); reader = new BufferedReader(new InputStreamReader(iResource.getInputStream(), Charsets.UTF_8)); String s; while ((s = reader.readLine()) != null) @@ -85,54 +88,12 @@ public CSJsonReader(ResourceLocation resourceIn) throws CSResourceNotFoundExcept } } - /** - * Extract a {@link CSReadedModel} from a .csjsmodel file. - * - * @return A new {@link CSReadedModel} containing the informations of the - * file. - * @throws CSMalformedJsonException - * If the json does match the model structure - */ - public CSReadedModel readModel() throws CSMalformedJsonException { - - CSReadedModel model = new CSReadedModel(); - CSReadedModelBlock parent; - JsonObject jsonBlock; - JsonElement jsEl; - - jsEl = this.root.get("title"); - if (jsEl == null) - throw new CSMalformedJsonException("title", "String", this.ress); - model.setName(strNormalize(jsEl.getAsString())); - - JsonArray tree = this.root.getAsJsonArray("tree"); - if (tree == null) - throw new CSMalformedJsonException("tree", "Array", this.ress); - for (JsonElement element : tree) - if (element.isJsonObject()) { - jsonBlock = element.getAsJsonObject(); - - parent = new CSReadedModelBlock(); - model.getParents().add(parent); - - try { - readModelBlock(jsonBlock, parent); - } catch (NullPointerException | ClassCastException | IllegalStateException e) { - // e.printStackTrace(); - throw new CSMalformedJsonException(parent.getName() != null ? parent.getName() : "a parent block without name", this.ress); - } - } - return model; - } - /** * Extract a block (and all its children) from a {@link JsonObject} and * place it in the {@link CSReadedModelBlock}. * - * @param jsonBlock - * The object to read the information. - * @param block - * The block to place the information. + * @param jsonBlock The object to read the information. + * @param block The block to place the information. */ private static void readModelBlock(JsonObject jsonBlock, CSReadedModelBlock block) { readModelBlock(jsonBlock, block, null); @@ -142,15 +103,12 @@ private static void readModelBlock(JsonObject jsonBlock, CSReadedModelBlock bloc * Extract a child block from a {@link JsonObject} and place it in the * {@link CSReadedModelBlock}. * - * @param jsonBlock - * The object to read the information. - * @param block - * The block to place the information. - * @param parentOffset - * The offset from pivot of the parent block. + * @param jsonBlock The object to read the information. + * @param block The block to place the information. + * @param parentOffset The offset from pivot of the parent block. */ private static void readModelBlock(JsonObject jsonBlock, CSReadedModelBlock block, Vector3f parentOffset) { - final int[] vertexOrderConvert = new int[] { 3, 2, 1, 0, 6, 7, 4, 5 }; + final int[] vertexOrderConvert = new int[]{3, 2, 1, 0, 6, 7, 4, 5}; JsonObject jsonChild; CSReadedModelBlock child; @@ -199,8 +157,7 @@ private static void readModelBlock(JsonObject jsonBlock, CSReadedModelBlock bloc } block.setStretch(new Vector3f(stretchx, stretchy, stretchz)); - } - else + } else block.setStretch(new Vector3f(1, 1, 1)); if (parentOffset == null) @@ -225,58 +182,12 @@ private static void readModelBlock(JsonObject jsonBlock, CSReadedModelBlock bloc } - /** - * Extract a {@link CSReadedAnim} from a .csjsmodelanim file. - * - * @return A new {@link CSReadedAnim} containing the informations of the - * file. - * @throws CSMalformedJsonException - * If the json does match the animation structure - */ - public CSReadedAnim readAnim() throws CSMalformedJsonException { - - CSReadedAnim anim = new CSReadedAnim(); - CSReadedAnimBlock block; - JsonElement jsEl; - - jsEl = this.root.get("title"); - if (jsEl == null) - throw new CSMalformedJsonException("title", "String", this.ress); - anim.setName(strNormalize(jsEl.getAsString())); - jsEl = this.root.get("duration"); - if (jsEl == null) - throw new CSMalformedJsonException("duration", "Integer", this.ress); - anim.setDuration(jsEl.getAsInt()); - jsEl = this.root.get("holdLastKeyframe"); - if (jsEl == null) - throw new CSMalformedJsonException("holdLastKeyframe", "Boolean", this.ress); - anim.setHoldLastK(jsEl.getAsBoolean()); - - jsEl = this.root.get("nodeAnimations"); - if (jsEl == null) - throw new CSMalformedJsonException("nodeAnimations", "Object", this.ress); - JsonObject nodeAnims = jsEl.getAsJsonObject(); - for (Entry entry : nodeAnims.entrySet()) { - block = new CSReadedAnimBlock(); - anim.getBlocks().add(block); - try { - readAnimBlock(entry, block); - } catch (Exception e) { - CraftStudioApi.getLogger().error(e.getMessage()); - throw new CSMalformedJsonException(block.getName() != null ? block.getName() : "a block without name", this.ress); - } - } - return anim; - } - /** * Extract a block's informations and place them in a * {@link CSReadedAnimBlock}. * - * @param entry - * The entry containing the informations. - * @param block - * The block to store the informations. + * @param entry The entry containing the informations. + * @param block The block to store the informations. */ private static void readAnimBlock(Entry entry, CSReadedAnimBlock block) { block.setName(strNormalize(entry.getKey())); @@ -297,12 +208,9 @@ private static void readAnimBlock(Entry entry, CSReadedAnim /** * Extract the element asked of all the keyframes. * - * @param obj - * The object with the keyframes. - * @param block - * The block to store the keyframes. - * @param type - * type of element to add. See {@link CSReadedAnimBlock}. + * @param obj The object with the keyframes. + * @param block The block to store the keyframes. + * @param type type of element to add. See {@link CSReadedAnimBlock}. */ private static void addKFElement(JsonObject obj, CSReadedAnimBlock block, EnumFrameType type) { int keyFrame; @@ -327,12 +235,93 @@ private static void addKFElement(JsonObject obj, CSReadedAnimBlock block, EnumFr /** * Normalize a String. * - * @param str - * The String to normalize. + * @param str The String to normalize. * @return The normalized String. */ private static String strNormalize(String str) { return str.replaceAll("[^\\dA-Za-z ]", "_").replaceAll("\\s+", "_").replaceAll("[^\\p{ASCII}]", "_"); } + /** + * Extract a {@link CSReadedModel} from a .csjsmodel file. + * + * @return A new {@link CSReadedModel} containing the informations of the + * file. + * @throws CSMalformedJsonException If the json does match the model structure + */ + public CSReadedModel readModel() throws CSMalformedJsonException { + + CSReadedModel model = new CSReadedModel(); + CSReadedModelBlock parent; + JsonObject jsonBlock; + JsonElement jsEl; + + jsEl = this.root.get("title"); + if (jsEl == null) + throw new CSMalformedJsonException("title", "String", this.ress); + model.setName(strNormalize(jsEl.getAsString())); + + JsonArray tree = this.root.getAsJsonArray("tree"); + if (tree == null) + throw new CSMalformedJsonException("tree", "Array", this.ress); + for (JsonElement element : tree) + if (element.isJsonObject()) { + jsonBlock = element.getAsJsonObject(); + + parent = new CSReadedModelBlock(); + model.getParents().add(parent); + + try { + readModelBlock(jsonBlock, parent); + } catch (NullPointerException | ClassCastException | IllegalStateException e) { + // e.printStackTrace(); + throw new CSMalformedJsonException(parent.getName() != null ? parent.getName() : "a parent block without name", this.ress); + } + } + return model; + } + + /** + * Extract a {@link CSReadedAnim} from a .csjsmodelanim file. + * + * @return A new {@link CSReadedAnim} containing the informations of the + * file. + * @throws CSMalformedJsonException If the json does match the animation structure + */ + public CSReadedAnim readAnim() throws CSMalformedJsonException { + + CSReadedAnim anim = new CSReadedAnim(); + CSReadedAnimBlock block; + JsonElement jsEl; + + jsEl = this.root.get("title"); + if (jsEl == null) + throw new CSMalformedJsonException("title", "String", this.ress); + anim.setName(strNormalize(jsEl.getAsString())); + jsEl = this.root.get("duration"); + if (jsEl == null) + throw new CSMalformedJsonException("duration", "Integer", this.ress); + anim.setDuration(jsEl.getAsInt()); + jsEl = this.root.get("holdLastKeyframe"); + if (jsEl == null) + throw new CSMalformedJsonException("holdLastKeyframe", "Boolean", this.ress); + anim.setHoldLastK(jsEl.getAsBoolean()); + + jsEl = this.root.get("nodeAnimations"); + if (jsEl == null) + throw new CSMalformedJsonException("nodeAnimations", "Object", this.ress); + JsonObject nodeAnims = jsEl.getAsJsonObject(); + for (Entry entry : nodeAnims.entrySet()) { + block = new CSReadedAnimBlock(); + anim.getBlocks().add(block); + try { + readAnimBlock(entry, block); + } catch (Exception e) { + CraftStudioApi.getLogger().error(e.getMessage()); + throw new CSMalformedJsonException(block.getName() != null ? block.getName() : "a block without name", this.ress); + } + } + return anim; + } + } diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedAnim.java b/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedAnim.java index a3760f7..3ee243c 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedAnim.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedAnim.java @@ -1,31 +1,28 @@ package com.leviathanstudio.craftstudio.client.json; +import com.leviathanstudio.craftstudio.client.json.CSReadedAnimBlock.ReadedKeyFrame; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map.Entry; import java.util.Set; -import com.leviathanstudio.craftstudio.client.json.CSReadedAnimBlock.ReadedKeyFrame; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - /** * Class that store the informations relative to an animation. - * - * @since 0.3.0 * * @author Timmypote + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class CSReadedAnim -{ - private String name; - private int duration; - private boolean holdLastK; +@OnlyIn(Dist.CLIENT) +public class CSReadedAnim { + private String name; + private int duration; + private boolean holdLastK; private List blocks = new ArrayList<>(); - private Integer[] keyFrames; + private Integer[] keyFrames; /** * Get the keys of keyframes used in the animation. @@ -78,4 +75,5 @@ public void setBlocks(List blocks) { this.blocks = blocks; } + } diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedAnimBlock.java b/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedAnimBlock.java index adb9aca..13cfad7 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedAnimBlock.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedAnimBlock.java @@ -1,37 +1,30 @@ package com.leviathanstudio.craftstudio.client.json; -import java.util.HashMap; -import java.util.Map; - -import javax.vecmath.Vector3f; - import com.leviathanstudio.craftstudio.client.util.EnumFrameType; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import javax.vecmath.Vector3f; +import java.util.HashMap; +import java.util.Map; /** * Class that store information relative to an animated block.
- * - * @since 0.3.0 * * @author Timmypote + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class CSReadedAnimBlock -{ - private String name; +@OnlyIn(Dist.CLIENT) +public class CSReadedAnimBlock { + private String name; private Map keyFrames = new HashMap<>(); /** * Add an element to a keyframe. If the keyframe does exist it's created. * - * @param keyFrame - * Key of the keyframe. - * @param type - * Type of the element. See {@link CSReadedAnimBlock}. - * @param value - * Value of the element. + * @param keyFrame Key of the keyframe. + * @param type Type of the element. See {@link CSReadedAnimBlock}. + * @param value Value of the element. */ public void addKFElement(int keyFrame, EnumFrameType type, Vector3f value) { if (!this.keyFrames.containsKey(keyFrame)) @@ -55,18 +48,6 @@ public void addKFElement(int keyFrame, EnumFrameType type, Vector3f value) { } } - /** - * Class used to store informations relative to keyframes. - * - * @since 0.3.0 - * - * @author Timmypote - */ - public class ReadedKeyFrame - { - public Vector3f position, rotation, offset, size, stretching; - } - public String getName() { return this.name; } @@ -82,4 +63,14 @@ public Map getKeyFrames() { public void setKeyFrames(Map keyFrames) { this.keyFrames = keyFrames; } + + /** + * Class used to store informations relative to keyframes. + * + * @author Timmypote + * @since 0.3.0 + */ + public class ReadedKeyFrame { + public Vector3f position, rotation, offset, size, stretching; + } } diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedModel.java b/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedModel.java index e9c07a6..810ec3d 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedModel.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedModel.java @@ -1,33 +1,31 @@ package com.leviathanstudio.craftstudio.client.json; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + import java.util.ArrayList; import java.util.List; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - /** * Class that store information relative to a model. * - * @since 0.3.0 - * * @author Timmypote + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class CSReadedModel -{ - private String name; - private int textureWidth, textureHeight; +@OnlyIn(Dist.CLIENT) +public class CSReadedModel { + + private String name; + private int textureWidth, textureHeight; private List parents = new ArrayList<>(); /** * Get a block from the model with this name. * - * @param name - * The name of the block. + * @param name The name of the block. * @return A block with this name. null, if no block with this - * name.
- * If multiple block with the same name, return one of them. + * name.
+ * If multiple block with the same name, return one of them. */ public CSReadedModelBlock getBlockFromName(String name) { CSReadedModelBlock b; @@ -98,4 +96,5 @@ public List getParents() { public void setParents(List parents) { this.parents = parents; } + } diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedModelBlock.java b/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedModelBlock.java index 1351404..da61448 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedModelBlock.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/json/CSReadedModelBlock.java @@ -1,34 +1,30 @@ package com.leviathanstudio.craftstudio.client.json; -import java.util.ArrayList; -import java.util.List; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import javax.vecmath.Vector3f; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.List; /** * Class that store information relative to a block in a model. - * - * @since 0.3.0 * * @author Timmypote + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class CSReadedModelBlock -{ - private String name; - private Vector3f rotationPoint, rotation, size, stretch, offset; - private float vertex[][]; - private int[] texOffset = new int[2]; - private List childs = new ArrayList<>(); +@OnlyIn(Dist.CLIENT) +public class CSReadedModelBlock { + private String name; + private Vector3f rotationPoint, rotation, size, stretch, offset; + private float vertex[][]; + private int[] texOffset = new int[2]; + private List childs = new ArrayList<>(); /** * Create a new block with the specified name. * - * @param name - * The name of the block. + * @param name The name of the block. * @return The new block. */ CSReadedModelBlock getBlockFromName(String name) { @@ -47,10 +43,9 @@ CSReadedModelBlock getBlockFromName(String name) { * Check if the block or one of it's child as a name already in the list or * not and complete the list. * - * @param names - * A list of name. + * @param names A list of name. * @return null, if no block has duplicate name. One name that is - * duplicated, otherwise. + * duplicated, otherwise. */ String whyUnAnimable(List names) { String str; diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/model/CSModelBox.java b/src/main/java/com/leviathanstudio/craftstudio/client/model/CSModelBox.java index 60c965f..c4f8ce5 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/model/CSModelBox.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/model/CSModelBox.java @@ -1,84 +1,65 @@ package com.leviathanstudio.craftstudio.client.model; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.model.PositionTextureVertex; -import net.minecraft.client.model.TexturedQuad; import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.entity.model.RendererModel; +import net.minecraft.client.renderer.model.PositionTextureVertex; +import net.minecraft.client.renderer.model.TexturedQuad; import net.minecraft.util.math.Vec3d; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; /** - * Class used to render a box in a {@link CSModelRenderer} or a - * {@link ModelRenderer}.
- * Partially based on {@link net.minecraft.client.model.ModelBox ModelBox}. - * - * @since 0.3.0 + * Class used to render a box in a {@link RendererModel} or a + * {@link RendererModel}.
+ * Partially based on {@link net.minecraft.client.renderer.model.ModelBox ModelBox}. * * @author Timmypote + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class CSModelBox -{ - /** An array of 6 TexturedQuads, one for each face of a cube. */ +@OnlyIn(Dist.CLIENT) +public class CSModelBox { + private final static double NORM_PREC = 0.0001; + /** + * An array of 6 TexturedQuads, one for each face of a cube. + */ private final TexturedQuad[] quadList; - - /** The box name. **/ - public String boxName; - - private final static double NORM_PREC = 0.0001; + /** + * The box name. + **/ + public String boxName; /** * Create a textured rectangular box without textures mirror precision. * - * @param renderer - * The (CS)ModelRenderer to which the box will be add. - * @param texU - * The X coordinate of the texture. - * @param texV - * The Y coordinate of the texture. - * @param x - * The X coordinate of the starting point of the box. - * @param y - * The Y coordinate of the starting point of the box. - * @param z - * The Z coordinate of the starting point of the box. - * @param dx - * The length of the box on the X axis. - * @param dy - * The length of the box on the Y axis. - * @param dz - * The length of the box on the Z axis. + * @param renderer The (CS)RendererModel to which the box will be add. + * @param texU The X coordinate of the texture. + * @param texV The Y coordinate of the texture. + * @param x The X coordinate of the starting point of the box. + * @param y The Y coordinate of the starting point of the box. + * @param z The Z coordinate of the starting point of the box. + * @param dx The length of the box on the X axis. + * @param dy The length of the box on the Y axis. + * @param dz The length of the box on the Z axis. */ - public CSModelBox(ModelRenderer renderer, int texU, int texV, float x, float y, float z, float dx, float dy, float dz) { + public CSModelBox(RendererModel renderer, int texU, int texV, float x, float y, float z, float dx, float dy, float dz) { this(renderer, texU, texV, x, y, z, dx, dy, dz, renderer.mirror); } /** * Create a textured rectangular box. * - * @param renderer - * The (CS)ModelRenderer to which the box will be add. - * @param texU - * The X coordinate of the texture. - * @param texV - * The Y coordinate of the texture. - * @param x - * The X coordinate of the starting point of the box. - * @param y - * The Y coordinate of the starting point of the box. - * @param z - * The Z coordinate of the starting point of the box. - * @param dx - * The length of the box on the X axis. - * @param dy - * The length of the box on the Y axis. - * @param dz - * The length of the box on the Z axis. - * @param mirror - * True if the texture should be mirrored, False if it shouldn't. + * @param renderer The (CS)RendererModel to which the box will be add. + * @param texU The X coordinate of the texture. + * @param texV The Y coordinate of the texture. + * @param x The X coordinate of the starting point of the box. + * @param y The Y coordinate of the starting point of the box. + * @param z The Z coordinate of the starting point of the box. + * @param dx The length of the box on the X axis. + * @param dy The length of the box on the Y axis. + * @param dz The length of the box on the Z axis. + * @param mirror True if the texture should be mirrored, False if it shouldn't. */ - public CSModelBox(ModelRenderer renderer, int texU, int texV, float x, float y, float z, float dx, float dy, float dz, boolean mirror) { + public CSModelBox(RendererModel renderer, int texU, int texV, float x, float y, float z, float dx, float dy, float dz, boolean mirror) { this(renderer, getVerticesForRect(x, y, z, dx, dy, dz, mirror), getTextureUVsForRect(texU, texV, dx, dy, dz), mirror); } @@ -86,36 +67,29 @@ public CSModelBox(ModelRenderer renderer, int texU, int texV, float x, float y, * Create a box from PositionTextureVertex and texture it with textUVs * without textures mirror precision.
* See {@link #setVertex(PositionTextureVertex[]) setVertex()} and - * {@link #setTexture(ModelRenderer, int[][]) setTexture()} for orders. + * {@link #setTexture(RendererModel, int[][]) setTexture()} for orders. * - * @param renderer - * The (CS)ModelRenderer to which the box will be add. - * @param positionTextureVertex - * The 8 vertices used to create the box. - * @param textUVs - * The 6 pairs of points used to set the textures' UVs for each - * faces. + * @param renderer The (CS)RendererModel to which the box will be add. + * @param positionTextureVertex The 8 vertices used to create the box. + * @param textUVs The 6 pairs of points used to set the textures' UVs for each + * faces. */ - public CSModelBox(ModelRenderer renderer, PositionTextureVertex positionTextureVertex[], int[][] textUVs) { + public CSModelBox(RendererModel renderer, PositionTextureVertex positionTextureVertex[], int[][] textUVs) { this(renderer, positionTextureVertex, textUVs, renderer.mirror); } /** * Create a box from PositionTextureVertex and texture it with textUVs.
* See {@link #setVertex(PositionTextureVertex[]) setVertex()} and - * {@link #setTexture(ModelRenderer, int[][]) setTexture()} for orders. + * {@link #setTexture(RendererModel, int[][]) setTexture()} for orders. * - * @param renderer - * The (CS)ModelRenderer to which the box will be add. - * @param positionTextureVertex - * The 8 vertices used to create the box. - * @param textUVs - * The 6 pairs of points used to set the textures' UVs for each - * faces. - * @param mirror - * True if the texture should be mirrored, False if it shouldn't. + * @param renderer The (CS)RendererModel to which the box will be add. + * @param positionTextureVertex The 8 vertices used to create the box. + * @param textUVs The 6 pairs of points used to set the textures' UVs for each + * faces. + * @param mirror True if the texture should be mirrored, False if it shouldn't. */ - public CSModelBox(ModelRenderer renderer, PositionTextureVertex positionTextureVertex[], int[][] textUVs, boolean mirror) { + public CSModelBox(RendererModel renderer, PositionTextureVertex positionTextureVertex[], int[][] textUVs, boolean mirror) { this(positionTextureVertex); this.setTexture(renderer, textUVs); this.checkBlockForShadow(); @@ -128,8 +102,7 @@ public CSModelBox(ModelRenderer renderer, PositionTextureVertex positionTextureV * Create a box from PositionTextureVertex.
* See {@link #setVertex(PositionTextureVertex[]) setVertex()} for order. * - * @param positionTextureVertex - * The 8 vertices used to create the box. + * @param positionTextureVertex The 8 vertices used to create the box. */ public CSModelBox(PositionTextureVertex positionTextureVertex[]) { this(6); @@ -139,18 +112,77 @@ public CSModelBox(PositionTextureVertex positionTextureVertex[]) { /** * Just create a box with a list of {@link facesNumber} unset TexturedQuad. * - * @param facesNumber - * The number of faces the box will have. + * @param facesNumber The number of faces the box will have. */ public CSModelBox(int facesNumber) { this.quadList = new TexturedQuad[facesNumber]; } + /** + * Calculate the PositionTextureVertex from a rectangular box. + * + * @param x The X coordinate of the starting point of the box. + * @param y The Y coordinate of the starting point of the box. + * @param z The Z coordinate of the starting point of the box. + * @param dx The length of the box on the X axis. + * @param dy The length of the box on the Y axis. + * @param dz The length of the box on the Z axis. + * @param mirror True if the texture should be mirrored, False if it shouldn't. + * @return A 8 long array of PositionTextureVertex that can be used to + * create a rectangular box. + */ + public static PositionTextureVertex[] getVerticesForRect(float x, float y, float z, float dx, float dy, float dz, boolean mirror) { + PositionTextureVertex[] positionTextureVertex = new PositionTextureVertex[8]; + float endX = x + dx; + float endY = y + dy; + float endZ = z + dz; + + if (mirror) { + float buffer = endX; + endX = x; + x = buffer; + } + + positionTextureVertex[0] = new PositionTextureVertex(x, y, z, 0.0F, 0.0F); + positionTextureVertex[1] = new PositionTextureVertex(endX, y, z, 0.0F, 0.0F); + positionTextureVertex[2] = new PositionTextureVertex(endX, endY, z, 0.0F, 0.0F); + positionTextureVertex[3] = new PositionTextureVertex(x, endY, z, 0.0F, 0.0F); + positionTextureVertex[4] = new PositionTextureVertex(x, y, endZ, 0.0F, 0.0F); + positionTextureVertex[5] = new PositionTextureVertex(endX, y, endZ, 0.0F, 0.0F); + positionTextureVertex[6] = new PositionTextureVertex(endX, endY, endZ, 0.0F, 0.0F); + positionTextureVertex[7] = new PositionTextureVertex(x, endY, endZ, 0.0F, 0.0F); + + return positionTextureVertex; + } + + /** + * Calculate the textures' UVs for a rectangular box. + * + * @param texU The X coordinate of the texture. + * @param texV The Y coordinate of the texture. + * @param dx The length of the box on the X axis. + * @param dy The length of the box on the Y axis. + * @param dz The length of the box on the Z axis. + * @return A 6 long array of pairs of UV that can be used to texture a + * rectangular box. + */ + public static int[][] getTextureUVsForRect(int texU, int texV, float dx, float dy, float dz) { + dy = -dy; + dz = -dz; + int[][] tab = new int[][]{{(int) (texU + dz + dx + dz), (int) (texV + dz + dy), (int) (texU + dz + dx), (int) (texV + dz)}, + {(int) (texU + dz), (int) (texV + dz + dy), texU, (int) (texV + dz)}, + {(int) (texU + dz + dx), texV, (int) (texU + dz + dx + dx), (int) (texV + dz)}, + {(int) (texU + dz), texV, (int) (texU + dz + dx), (int) (texV + dz)}, + {(int) (texU + dz + dx + dz + dx), (int) (texV + dz + dy), (int) (texU + dz + dx + dz), (int) (texV + dz)}, + {(int) (texU + dz + dx), (int) (texV + dz + dy), (int) (texU + dz), (int) (texV + dz)}}; + return tab; + } + /** * Set the vertices of the box ! A - * {@link #setTexture(ModelRenderer, int[][]) setTexture()} is necessary + * {@link #setTexture(RendererModel, int[][]) setTexture()} is necessary * after that.
- * + *

* Order of the vertices:
* vertices[0] = (0, 0, 0) (bloc's origin)
* vertices[1] = (x, 0, 0)
@@ -161,23 +193,22 @@ public CSModelBox(int facesNumber) { * vertices[6] = (x, y, z) (bloc's end)
* vertices[7] = (0, y, z)
* - * @param positionTextureVertex - * The 8 vertices that will replace the old ones. + * @param positionTextureVertex The 8 vertices that will replace the old ones. */ public void setVertex(PositionTextureVertex positionTextureVertex[]) { if (positionTextureVertex.length == 8) { - this.quadList[0] = new TexturedQuad(new PositionTextureVertex[] { positionTextureVertex[5], positionTextureVertex[1], - positionTextureVertex[2], positionTextureVertex[6] }); - this.quadList[1] = new TexturedQuad(new PositionTextureVertex[] { positionTextureVertex[0], positionTextureVertex[4], - positionTextureVertex[7], positionTextureVertex[3] }); - this.quadList[2] = new TexturedQuad(new PositionTextureVertex[] { positionTextureVertex[5], positionTextureVertex[4], - positionTextureVertex[0], positionTextureVertex[1] }); - this.quadList[3] = new TexturedQuad(new PositionTextureVertex[] { positionTextureVertex[2], positionTextureVertex[3], - positionTextureVertex[7], positionTextureVertex[6] }); - this.quadList[4] = new TexturedQuad(new PositionTextureVertex[] { positionTextureVertex[1], positionTextureVertex[0], - positionTextureVertex[3], positionTextureVertex[2] }); - this.quadList[5] = new TexturedQuad(new PositionTextureVertex[] { positionTextureVertex[4], positionTextureVertex[5], - positionTextureVertex[6], positionTextureVertex[7] }); + this.quadList[0] = new TexturedQuad(new PositionTextureVertex[]{positionTextureVertex[5], positionTextureVertex[1], + positionTextureVertex[2], positionTextureVertex[6]}); + this.quadList[1] = new TexturedQuad(new PositionTextureVertex[]{positionTextureVertex[0], positionTextureVertex[4], + positionTextureVertex[7], positionTextureVertex[3]}); + this.quadList[2] = new TexturedQuad(new PositionTextureVertex[]{positionTextureVertex[5], positionTextureVertex[4], + positionTextureVertex[0], positionTextureVertex[1]}); + this.quadList[3] = new TexturedQuad(new PositionTextureVertex[]{positionTextureVertex[2], positionTextureVertex[3], + positionTextureVertex[7], positionTextureVertex[6]}); + this.quadList[4] = new TexturedQuad(new PositionTextureVertex[]{positionTextureVertex[1], positionTextureVertex[0], + positionTextureVertex[3], positionTextureVertex[2]}); + this.quadList[5] = new TexturedQuad(new PositionTextureVertex[]{positionTextureVertex[4], positionTextureVertex[5], + positionTextureVertex[6], positionTextureVertex[7]}); } } @@ -185,9 +216,9 @@ public void setVertex(PositionTextureVertex positionTextureVertex[]) { * Check and correct the problem of dark texture. */ private void checkBlockForShadow() { - Vec3d or = this.quadList[1].vertexPositions[0].vector3D; - double x = this.quadList[0].vertexPositions[1].vector3D.x, y = this.quadList[1].vertexPositions[3].vector3D.y, - z = this.quadList[1].vertexPositions[1].vector3D.z; + Vec3d or = this.quadList[1].field_78239_a[0].vector3D; + double x = this.quadList[0].field_78239_a[1].vector3D.x, y = this.quadList[1].field_78239_a[3].vector3D.y, + z = this.quadList[1].field_78239_a[1].vector3D.z; if (x - or.x < 0) this.flipFaces(); if (y - or.y > 0) @@ -206,7 +237,7 @@ private void flipFaces() { /** * Set the textures' UVs for each faces.
- * + *

* Faces order:
* faces[0] = X1
* faces[1] = X0
@@ -220,102 +251,26 @@ private void flipFaces() { * coord[2] = U1 (x1)
* coord[3] = V1 (y1) (Bottom/Right)
* - * @param renderer - * The (CS)ModelRenderer to which the box will be add. - * @param textUVs - * The 6 pairs of points used to set the textures' UVs for each - * faces. + * @param renderer The (CS)RendererModel to which the box will be add. + * @param textUVs The 6 pairs of points used to set the textures' UVs for each + * faces. */ - public void setTexture(ModelRenderer renderer, int[][] textUVs) { + public void setTexture(RendererModel renderer, int[][] textUVs) { int[] textUV; if (textUVs.length == 6) for (int i = 0; i < 6; i++) { textUV = textUVs[i]; if (textUV.length == 4) - this.quadList[i] = new TexturedQuad(this.quadList[i].vertexPositions, textUV[0], textUV[1], textUV[2], textUV[3], + this.quadList[i] = new TexturedQuad(this.quadList[i].field_78239_a, textUV[0], textUV[1], textUV[2], textUV[3], renderer.textureWidth, renderer.textureHeight); } } - /** - * Calculate the PositionTextureVertex from a rectangular box. - * - * @param x - * The X coordinate of the starting point of the box. - * @param y - * The Y coordinate of the starting point of the box. - * @param z - * The Z coordinate of the starting point of the box. - * @param dx - * The length of the box on the X axis. - * @param dy - * The length of the box on the Y axis. - * @param dz - * The length of the box on the Z axis. - * @param mirror - * True if the texture should be mirrored, False if it shouldn't. - * @return A 8 long array of PositionTextureVertex that can be used to - * create a rectangular box. - */ - public static PositionTextureVertex[] getVerticesForRect(float x, float y, float z, float dx, float dy, float dz, boolean mirror) { - PositionTextureVertex[] positionTextureVertex = new PositionTextureVertex[8]; - float endX = x + dx; - float endY = y + dy; - float endZ = z + dz; - - if (mirror) { - float buffer = endX; - endX = x; - x = buffer; - } - - positionTextureVertex[0] = new PositionTextureVertex(x, y, z, 0.0F, 0.0F); - positionTextureVertex[1] = new PositionTextureVertex(endX, y, z, 0.0F, 0.0F); - positionTextureVertex[2] = new PositionTextureVertex(endX, endY, z, 0.0F, 0.0F); - positionTextureVertex[3] = new PositionTextureVertex(x, endY, z, 0.0F, 0.0F); - positionTextureVertex[4] = new PositionTextureVertex(x, y, endZ, 0.0F, 0.0F); - positionTextureVertex[5] = new PositionTextureVertex(endX, y, endZ, 0.0F, 0.0F); - positionTextureVertex[6] = new PositionTextureVertex(endX, endY, endZ, 0.0F, 0.0F); - positionTextureVertex[7] = new PositionTextureVertex(x, endY, endZ, 0.0F, 0.0F); - - return positionTextureVertex; - } - - /** - * Calculate the textures' UVs for a rectangular box. - * - * @param texU - * The X coordinate of the texture. - * @param texV - * The Y coordinate of the texture. - * @param dx - * The length of the box on the X axis. - * @param dy - * The length of the box on the Y axis. - * @param dz - * The length of the box on the Z axis. - * @return A 6 long array of pairs of UV that can be used to texture a - * rectangular box. - */ - public static int[][] getTextureUVsForRect(int texU, int texV, float dx, float dy, float dz) { - dy = -dy; - dz = -dz; - int[][] tab = new int[][] { { (int) (texU + dz + dx + dz), (int) (texV + dz + dy), (int) (texU + dz + dx), (int) (texV + dz) }, - { (int) (texU + dz), (int) (texV + dz + dy), texU, (int) (texV + dz) }, - { (int) (texU + dz + dx), texV, (int) (texU + dz + dx + dx), (int) (texV + dz) }, - { (int) (texU + dz), texV, (int) (texU + dz + dx), (int) (texV + dz) }, - { (int) (texU + dz + dx + dz + dx), (int) (texV + dz + dy), (int) (texU + dz + dx + dz), (int) (texV + dz) }, - { (int) (texU + dz + dx), (int) (texV + dz + dy), (int) (texU + dz), (int) (texV + dz) } }; - return tab; - } - /** * Function used to prepare the rendering of the bloc. * - * @param renderer - * VertexBuffer from the Tesselator. - * @param scale - * Scale factor. + * @param renderer VertexBuffer from the Tesselator. + * @param scale Scale factor. */ public void render(BufferBuilder renderer, float scale) { for (TexturedQuad texturedquad : this.quadList) @@ -325,8 +280,7 @@ public void render(BufferBuilder renderer, float scale) { /** * Set the box name. * - * @param name - * The name given to the box. + * @param name The name given to the box. * @return The CSModelBox. */ public CSModelBox setBoxName(String name) { diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/model/CSModelRenderer.java b/src/main/java/com/leviathanstudio/craftstudio/client/model/CSModelRenderer.java index 17546a0..3071489 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/model/CSModelRenderer.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/model/CSModelRenderer.java @@ -1,136 +1,138 @@ package com.leviathanstudio.craftstudio.client.model; -import java.nio.FloatBuffer; -import java.util.ArrayList; -import java.util.List; - -import javax.vecmath.Matrix4f; -import javax.vecmath.Quat4f; -import javax.vecmath.Vector3f; - -import org.lwjgl.opengl.GL11; - import com.leviathanstudio.craftstudio.client.util.MathHelper; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.model.PositionTextureVertex; +import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GLAllocation; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.entity.model.RendererModel; +import net.minecraft.client.renderer.model.Model; +import net.minecraft.client.renderer.model.PositionTextureVertex; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import org.lwjgl.opengl.GL11; + +import javax.vecmath.Matrix4f; +import javax.vecmath.Quat4f; +import javax.vecmath.Vector3f; +import java.nio.FloatBuffer; +import java.util.ArrayList; +import java.util.List; /** * Class used to render CSModelBoxs. - * - * @since 0.3.0 - * + * * @author Timmypote + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class CSModelRenderer extends ModelRenderer -{ - /** Custom version, as parent variable is PRIVATE */ - private int textureOffsetX; - - /** Custom version, as parent variable is PRIVATE */ - private int textureOffsetY; - - /** Custom version, as parent variable is PRIVATE */ - private boolean compiled; +@OnlyIn(Dist.CLIENT) +public class CSModelRenderer extends RendererModel { + private final Matrix4f rotationMatrix = new Matrix4f(); + public List cubeCSList = new ArrayList<>(); + /** + * Custom version, as parent variable is PRIVATE + */ + private int textureOffsetX; + /** + * Custom version, as parent variable is PRIVATE + */ + private int textureOffsetY; + /** + * Custom version, as parent variable is PRIVATE + */ + private boolean compiled; + /** + * Custom version, as parent variable is PRIVATE + */ + private int displayList; + /** + * Previous value of the matrix + */ + private Matrix4f prevRotationMatrix = new Matrix4f(); - /** Custom version, as parent variable is PRIVATE */ - private int displayList; + private Vector3f stretch = new Vector3f(1, 1, 1); - public List cubeCSList = new ArrayList<>(); + /** + * Default informations for un-animated models + */ + private float defaultRotationPointX; + private float defaultRotationPointY; + private float defaultRotationPointZ; + private Matrix4f defaultRotationMatrix = new Matrix4f(); + private Quat4f defaultRotationAsQuaternion; + private float defaultOffsetX = 0; + private float defaultOffsetY = 0; + private float defaultOffsetZ = 0; + private Vector3f defaultStretch = new Vector3f(1, 1, 1); + + public CSModelRenderer(Model modelbase, String partName, int xTextureOffset, int yTextureOffset) { + super(modelbase, partName); + this.setTextureSize(modelbase.textureWidth, modelbase.textureHeight); + this.setTextureOffset(xTextureOffset, yTextureOffset); + } - private final Matrix4f rotationMatrix = new Matrix4f(); - /** Previous value of the matrix */ - private Matrix4f prevRotationMatrix = new Matrix4f(); + private static CSModelRenderer getRendererModelFromNameAndBlock(String name, CSModelRenderer block) { + CSModelRenderer childModel, result; - private Vector3f stretch = new Vector3f(1, 1, 1); + if (block.boxName.equals(name)) + return block; - /** Default informations for un-animated models */ - private float defaultRotationPointX; - private float defaultRotationPointY; - private float defaultRotationPointZ; - private Matrix4f defaultRotationMatrix = new Matrix4f(); - private Quat4f defaultRotationAsQuaternion; - private float defaultOffsetX = 0; - private float defaultOffsetY = 0; - private float defaultOffsetZ = 0; - private Vector3f defaultStretch = new Vector3f(1, 1, 1); + for (RendererModel child : block.childModels) + if (child instanceof CSModelRenderer) { + childModel = (CSModelRenderer) child; + result = getRendererModelFromNameAndBlock(name, childModel); + if (result != null) + return result; + } - public CSModelRenderer(ModelBase modelbase, String partName, int xTextureOffset, int yTextureOffset) { - super(modelbase, partName); - this.setTextureSize(modelbase.textureWidth, modelbase.textureHeight); - this.setTextureOffset(xTextureOffset, yTextureOffset); + return null; } @Override - public ModelRenderer setTextureOffset(int x, int y) { + public RendererModel setTextureOffset(int x, int y) { this.textureOffsetX = x; this.textureOffsetY = y; this.cubeList.size(); return this; } - public ModelRenderer addBox(String name, CSModelBox modelBox) { + public RendererModel addBox(String name, CSModelBox modelBox) { name = this.boxName + "." + name; this.cubeCSList.add(modelBox.setBoxName(name)); return this; } - public ModelRenderer addBox(String name, float par2, float par3, float par4, float par5, float par6, float par7) { + public RendererModel addBox(String name, float par2, float par3, float par4, float par5, float par6, float par7) { name = this.boxName + "." + name; this.cubeCSList.add(new CSModelBox(this, this.textureOffsetX, this.textureOffsetY, par2, par3, par4, par5, par6, par7).setBoxName(name)); return this; } - public ModelRenderer addBox(float posX, float posY, float posZ, float sizeX, float sizeY, float sizeZ) { + public RendererModel addBox(float posX, float posY, float posZ, float sizeX, float sizeY, float sizeZ) { this.cubeCSList.add(new CSModelBox(this, this.textureOffsetX, this.textureOffsetY, posX, posY, posZ, sizeX, sizeY, sizeZ)); return this; } - public ModelRenderer addBox(float posX, float posY, float posZ, float sizeX, float sizeY, float sizeZ, boolean mirror) { + public RendererModel addBox(float posX, float posY, float posZ, float sizeX, float sizeY, float sizeZ, boolean mirror) { this.cubeCSList.add(new CSModelBox(this, this.textureOffsetX, this.textureOffsetY, posX, posY, posZ, sizeX, sizeY, sizeZ, mirror)); return this; } - public ModelRenderer addBox(PositionTextureVertex positionTextureVertex[], int[][] textUVs) { + public RendererModel addBox(PositionTextureVertex positionTextureVertex[], int[][] textUVs) { this.cubeCSList.add(new CSModelBox(this, positionTextureVertex, textUVs)); return this; } - public ModelRenderer addBox(PositionTextureVertex positionTextureVertex[], int[][] textUVs, boolean mirror) { + public RendererModel addBox(PositionTextureVertex positionTextureVertex[], int[][] textUVs, boolean mirror) { this.cubeCSList.add(new CSModelBox(this, positionTextureVertex, textUVs, mirror)); return this; } - public ModelRenderer addBox(CSModelBox model) { + public RendererModel addBox(CSModelBox model) { this.cubeCSList.add(model); return this; } - private static CSModelRenderer getModelRendererFromNameAndBlock(String name, CSModelRenderer block) { - CSModelRenderer childModel, result; - - if (block.boxName.equals(name)) - return block; - - for (ModelRenderer child : block.childModels) - if (child instanceof CSModelRenderer) { - childModel = (CSModelRenderer) child; - result = getModelRendererFromNameAndBlock(name, childModel); - if (result != null) - return result; - } - - return null; - } - /** * Render model parts */ @@ -143,13 +145,13 @@ public void render(float scale) { GlStateManager.pushMatrix(); - GlStateManager.translate(this.rotationPointX * scale, this.rotationPointY * scale, this.rotationPointZ * scale); + GlStateManager.translated(this.rotationPointX * scale, this.rotationPointY * scale, this.rotationPointZ * scale); FloatBuffer buf = MathHelper.makeFloatBuffer(this.rotationMatrix); GlStateManager.multMatrix(buf); - GlStateManager.translate(this.offsetX * scale, this.offsetY * scale, this.offsetZ * scale); + GlStateManager.translated(this.offsetX * scale, this.offsetY * scale, this.offsetZ * scale); GlStateManager.pushMatrix(); - GlStateManager.scale(this.stretch.x, this.stretch.y, this.stretch.z); + GlStateManager.scaled(this.stretch.x, this.stretch.y, this.stretch.z); GlStateManager.callList(this.displayList); GlStateManager.popMatrix(); @@ -167,10 +169,12 @@ public void render(float scale) { * Allows the changing of Angles after a box has been rendered */ @Override - public void postRender(float scale) {} + public void postRender(float scale) { + } @Override - public void renderWithRotation(float scale) {} + public void renderWithRotation(float scale) { + } /** * Set default rotation point (model with no animations) and set the current @@ -195,7 +199,9 @@ public float getDefaultRotationPointZ() { return this.defaultRotationPointZ; } - /** Set the rotation point */ + /** + * Set the rotation point + */ @Override public void setRotationPoint(float x, float y, float z) { this.rotationPointX = x; @@ -203,7 +209,9 @@ public void setRotationPoint(float x, float y, float z) { this.rotationPointZ = z; } - /** Reset the rotation point to the default values. */ + /** + * Reset the rotation point to the default values. + */ public void resetRotationPoint() { this.rotationPointX = this.defaultRotationPointX; this.rotationPointY = this.defaultRotationPointY; @@ -279,7 +287,20 @@ public void setInitialRotationMatrix(float x, float y, float z) { this.setInitialRotationMatrix(mat); } - /** Set the rotation matrix values based on the given matrix. */ + /** + * Reset the rotation matrix to the default one. + */ + public void resetRotationMatrix() { + this.setRotationMatrix(this.defaultRotationMatrix); + } + + public Matrix4f getRotationMatrix() { + return this.rotationMatrix; + } + + /** + * Set the rotation matrix values based on the given matrix. + */ public void setRotationMatrix(Matrix4f matrix) { this.rotationMatrix.m00 = matrix.m00; this.rotationMatrix.m01 = matrix.m01; @@ -299,15 +320,6 @@ public void setRotationMatrix(Matrix4f matrix) { this.rotationMatrix.m33 = matrix.m33; } - /** Reset the rotation matrix to the default one. */ - public void resetRotationMatrix() { - this.setRotationMatrix(this.defaultRotationMatrix); - } - - public Matrix4f getRotationMatrix() { - return this.rotationMatrix; - } - public Quat4f getDefaultRotationAsQuaternion() { return new Quat4f(this.defaultRotationAsQuaternion); } @@ -317,17 +329,19 @@ public Quat4f getDefaultRotationAsQuaternion() { */ public void compileDisplayList(float scale) { this.displayList = GLAllocation.generateDisplayLists(1); - GlStateManager.glNewList(this.displayList, GL11.GL_COMPILE); + GlStateManager.newList(this.displayList, GL11.GL_COMPILE); BufferBuilder vertexbuffer = Tessellator.getInstance().getBuffer(); for (int i = 0; i < this.cubeCSList.size(); ++i) this.cubeCSList.get(i).render(vertexbuffer, scale); - GlStateManager.glEndList(); + GlStateManager.endList(); this.compiled = true; } - /** Getter */ + /** + * Getter + */ public List getCubeCSList() { return this.cubeCSList; } diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/model/ModelCraftStudio.java b/src/main/java/com/leviathanstudio/craftstudio/client/model/ModelCraftStudio.java index 2f47995..9298112 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/model/ModelCraftStudio.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/model/ModelCraftStudio.java @@ -1,62 +1,54 @@ package com.leviathanstudio.craftstudio.client.model; -import java.util.ArrayList; -import java.util.List; - import com.leviathanstudio.craftstudio.client.animation.ClientAnimationHandler; import com.leviathanstudio.craftstudio.client.exception.CSResourceNotRegisteredException; import com.leviathanstudio.craftstudio.client.json.CSReadedModel; import com.leviathanstudio.craftstudio.client.json.CSReadedModelBlock; import com.leviathanstudio.craftstudio.client.registry.RegistryHandler; import com.leviathanstudio.craftstudio.common.animation.IAnimated; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.model.PositionTextureVertex; +import net.minecraft.client.renderer.entity.model.EntityModel; +import net.minecraft.client.renderer.entity.model.RendererModel; +import net.minecraft.client.renderer.model.PositionTextureVertex; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.util.registry.SimpleRegistry; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import java.util.ArrayList; +import java.util.List; /** * Model to represent a CraftStudio model in Minecraft. - * - * @since 0.3.0 - * + * * @author Timmypote * @author ZeAmateis + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class ModelCraftStudio extends ModelBase -{ +@OnlyIn(Dist.CLIENT) +public class ModelCraftStudio extends EntityModel { + private List parentBlocks = new ArrayList<>(); /** - * @param modid - * The ID of your mod - * @param modelNameIn - * The name of your craftstudio model your have registered with - * {@link com.leviathanstudio.craftstudio.client.registry.CSRegistryHelper#register - * CraftStudioRegistry#register} - * @param textureSize - * The size of your texture if it's the same width/height + * @param modid The ID of your mod + * @param modelNameIn The name of your craftstudio model your have registered with + * {@link com.leviathanstudio.craftstudio.client.registry.CSRegistryHelper#register + * CraftStudioRegistry#register} + * @param textureSize The size of your texture if it's the same width/height */ public ModelCraftStudio(String modid, String modelNameIn, int textureSize) { this(modid, modelNameIn, textureSize, textureSize); } /** - * @param modid - * The ID of your mod - * @param modelNameIn - * The name of your craftstudio model your have registered with - * {@link com.leviathanstudio.craftstudio.client.registry.CSRegistryHelper#register - * CraftStudioRegistry#register} - * @param textureWidth - * The width texture of your model - * @param textureHeight - * The height texture of your model + * @param modid The ID of your mod + * @param modelNameIn The name of your craftstudio model your have registered with + * {@link com.leviathanstudio.craftstudio.client.registry.CSRegistryHelper#register + * CraftStudioRegistry#register} + * @param textureWidth The width texture of your model + * @param textureHeight The height texture of your model */ public ModelCraftStudio(String modid, String modelNameIn, int textureWidth, int textureHeight) { this(new ResourceLocation(modid, modelNameIn), textureWidth, textureHeight); @@ -67,9 +59,9 @@ private ModelCraftStudio(ResourceLocation modelIn, int textureWidth, int texture this.textureWidth = textureWidth; this.textureHeight = textureHeight; - CSReadedModel rModel = RegistryHandler.modelRegistry.getObject(modelIn); - if (rModel == null) - throw new CSResourceNotRegisteredException(modelIn.toString()); + CSReadedModel rModel = RegistryHandler.modelRegistry + .getValue(modelIn) + .orElseThrow(() -> new CSResourceNotRegisteredException(modelIn.toString())); CSModelRenderer modelRend; for (CSReadedModelBlock rBlock : rModel.getParents()) { @@ -79,7 +71,29 @@ private ModelCraftStudio(ResourceLocation modelIn, int textureWidth, int texture } } - /** Generate childs part of a model */ + /** + * Return CSModelRenderer by his name and parts + */ + public static CSModelRenderer getModelRendererFromNameAndBlock(String name, CSModelRenderer block) { + CSModelRenderer childModel, result; + + if (block.boxName.equals(name)) + return block; + + for (RendererModel child : block.childModels) + if (child instanceof CSModelRenderer) { + childModel = (CSModelRenderer) child; + result = getModelRendererFromNameAndBlock(name, childModel); + if (result != null) + return result; + } + + return null; + } + + /** + * Generate childs part of a model + */ private void generateChild(CSReadedModelBlock rParent, CSModelRenderer parent) { CSModelRenderer modelRend; for (CSReadedModelBlock rBlock : rParent.getChilds()) { @@ -89,7 +103,9 @@ private void generateChild(CSReadedModelBlock rParent, CSModelRenderer parent) { } } - /** Generate CSModelRenderer from readed model block */ + /** + * Generate CSModelRenderer from readed model block + */ private CSModelRenderer generateCSModelRend(CSReadedModelBlock rBlock) { CSModelRenderer modelRend = new CSModelRenderer(this, rBlock.getName(), rBlock.getTexOffset()[0], rBlock.getTexOffset()[1]); if (rBlock.getVertex() != null) { @@ -98,8 +114,7 @@ private CSModelRenderer generateCSModelRend(CSReadedModelBlock rBlock) { vertices[i] = new PositionTextureVertex(rBlock.getVertex()[i][0], rBlock.getVertex()[i][1], rBlock.getVertex()[i][2], 0.0F, 0.0F); modelRend.addBox(vertices, CSModelBox.getTextureUVsForRect(rBlock.getTexOffset()[0], rBlock.getTexOffset()[1], rBlock.getSize().x, rBlock.getSize().y, rBlock.getSize().z)); - } - else + } else modelRend.addBox(-rBlock.getSize().x / 2, -rBlock.getSize().y / 2, -rBlock.getSize().z / 2, rBlock.getSize().x, rBlock.getSize().y, rBlock.getSize().z); modelRend.setDefaultRotationPoint(rBlock.getRotationPoint().x, rBlock.getRotationPoint().y, rBlock.getRotationPoint().z); @@ -113,11 +128,10 @@ private CSModelRenderer generateCSModelRend(CSReadedModelBlock rBlock) { /** * Render function for an animated block
* Must be called in a - * {@link net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer#renderTileEntityAt + * {@link net.minecraft.client.renderer.tileentity.TileEntityRenderer#render * renderTileEntityAt} method * - * @param tileEntityIn - * The TileEntity who implements {@link IAnimated} + * @param tileEntityIn The TileEntity who implements {@link IAnimated} */ public void render(TileEntity tileEntityIn) { float modelScale = 0.0625F; @@ -129,7 +143,7 @@ public void render(TileEntity tileEntityIn) { /** * Render function for a non-animated block
* Must be called in a - * {@link net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer#renderTileEntityAt + * {@link net.minecraft.client.renderer.tileentity.TileEntityRenderer#render * renderTileEntityAt} method */ public void render() { @@ -138,34 +152,21 @@ public void render() { this.parentBlocks.get(i).render(modelScale); } - /** Render methods for an Entity */ + + /** + * Render methods for an Entity + */ @Override - public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + public void render(T entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); ClientAnimationHandler.performAnimationInModel(this.parentBlocks, (IAnimated) entityIn); for (int i = 0; i < this.parentBlocks.size(); i++) this.parentBlocks.get(i).render(scale); } - /** Return CSModelRenderer by his name and parts */ - public static CSModelRenderer getModelRendererFromNameAndBlock(String name, CSModelRenderer block) { - CSModelRenderer childModel, result; - - if (block.boxName.equals(name)) - return block; - - for (ModelRenderer child : block.childModels) - if (child instanceof CSModelRenderer) { - childModel = (CSModelRenderer) child; - result = getModelRendererFromNameAndBlock(name, childModel); - if (result != null) - return result; - } - - return null; - } - - /** Return CSModelRenderer by his name */ + /** + * Return CSModelRenderer by his name + */ public CSModelRenderer getModelRendererFromName(String name) { CSModelRenderer result; for (CSModelRenderer parent : this.parentBlocks) { @@ -176,7 +177,9 @@ public CSModelRenderer getModelRendererFromName(String name) { return null; } - /** Getter */ + /** + * Getter + */ public List getParentBlocks() { return this.parentBlocks; } diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/registry/AssetAnimation.java b/src/main/java/com/leviathanstudio/craftstudio/client/registry/AssetAnimation.java new file mode 100644 index 0000000..4d3697b --- /dev/null +++ b/src/main/java/com/leviathanstudio/craftstudio/client/registry/AssetAnimation.java @@ -0,0 +1,93 @@ +package com.leviathanstudio.craftstudio.client.registry; + +import com.google.common.reflect.TypeToken; +import com.leviathanstudio.craftstudio.CraftStudioApi; +import com.leviathanstudio.craftstudio.client.exception.CSMalformedJsonException; +import com.leviathanstudio.craftstudio.client.exception.CSResourceNotFoundException; +import com.leviathanstudio.craftstudio.client.json.CSJsonReader; +import com.leviathanstudio.craftstudio.client.json.CSReadedAnim; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.registries.GameData; +import net.minecraftforge.registries.IForgeRegistryEntry; + +import javax.annotation.Nullable; + +public class AssetAnimation extends CSReadedAnim implements IForgeRegistryEntry { + private final TypeToken token = new TypeToken(getClass()) { + }; + private ResourceLocation registryName = null; + + + public AssetAnimation(ResourceLocation assetIn) { + CSJsonReader jsonReader; + try { + jsonReader = new CSJsonReader(assetIn); + if (assetIn.getNamespace() != CraftStudioApi.API_ID) { + RegistryHandler.register(assetIn, jsonReader.readAnim()); + } else + CraftStudioApi.getLogger().fatal("You're not allowed to use the \"craftstudioapi\" to register CraftStudio resources."); + } catch (CSResourceNotFoundException | CSMalformedJsonException e) { + e.printStackTrace(); + } + } + + + /** + * A unique identifier for this entry, if this entry is registered already it will return it's official registry name. + * Otherwise it will return the name set in setRegistryName(). + * If neither are valid null is returned. + * + * @return Unique identifier or null. + */ + @Nullable + @Override + public ResourceLocation getRegistryName() { + return registryName != null ? registryName : null; + } + + /** + * Sets a unique name for this Item. This should be used for uniquely identify the instance of the Item. + * This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does. + * Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items. + *

+ * The supplied name will be prefixed with the currently active mod's modId. + * If the supplied name already has a prefix that is different, it will be used and a warning will be logged. + *

+ * If a name already exists, or this Item is already registered in a registry, then an IllegalStateException is thrown. + *

+ * Returns 'this' to allow for chaining. + * + * @param name Unique registry name + * @return This instance + */ + @Override + public final AssetAnimation setRegistryName(ResourceLocation name) { + return setRegistryName(name.toString()); + } + + + public final AssetAnimation setRegistryName(String name) { + if (getRegistryName() != null) + throw new IllegalStateException("Attempted to set registry name with existing registry name! New: " + name + " Old: " + getRegistryName()); + + this.registryName = GameData.checkPrefix(name, true); + return (AssetAnimation) this; + } + + + public final AssetAnimation setRegistryName(String modID, String name) { + return setRegistryName(modID + ":" + name); + } + + + /** + * Determines the type for this entry, used to look up the correct registry in the global registries list as there can only be one + * registry per concrete class. + * + * @return Root registry type. + */ + @Override + public Class getRegistryType() { + return (Class) token.getRawType(); + } +} diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/registry/AssetModel.java b/src/main/java/com/leviathanstudio/craftstudio/client/registry/AssetModel.java new file mode 100644 index 0000000..0467777 --- /dev/null +++ b/src/main/java/com/leviathanstudio/craftstudio/client/registry/AssetModel.java @@ -0,0 +1,93 @@ +package com.leviathanstudio.craftstudio.client.registry; + +import com.google.common.reflect.TypeToken; +import com.leviathanstudio.craftstudio.CraftStudioApi; +import com.leviathanstudio.craftstudio.client.exception.CSMalformedJsonException; +import com.leviathanstudio.craftstudio.client.exception.CSResourceNotFoundException; +import com.leviathanstudio.craftstudio.client.json.CSJsonReader; +import com.leviathanstudio.craftstudio.client.json.CSReadedModel; +import com.leviathanstudio.craftstudio.client.util.EnumRenderType; +import com.leviathanstudio.craftstudio.client.util.EnumResourceType; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.registries.GameData; +import net.minecraftforge.registries.IForgeRegistryEntry; + +import javax.annotation.Nullable; + +public class AssetModel extends CSReadedModel implements IForgeRegistryEntry { + private final TypeToken token = new TypeToken(getClass()) { + }; + private ResourceLocation registryName = null; + + + public AssetModel(EnumResourceType resourceType, EnumRenderType renderType, ResourceLocation assetIn) { + CSJsonReader jsonReader; + try { + ResourceLocation parsedPath = new ResourceLocation(assetIn.getNamespace(), resourceType.getPath() + renderType.getFolderName() + assetIn.getPath() + resourceType.getExtension()); + jsonReader = new CSJsonReader(parsedPath); + if (assetIn.getNamespace() != CraftStudioApi.API_ID) { + jsonReader.readModel(); + } else + CraftStudioApi.getLogger().fatal("You're not allowed to use the \"craftstudioapi\" to register CraftStudio resources."); + } catch (CSResourceNotFoundException | CSMalformedJsonException e) { + e.printStackTrace(); + } + } + + + /** + * A unique identifier for this entry, if this entry is registered already it will return it's official registry name. + * Otherwise it will return the name set in setRegistryName(). + * If neither are valid null is returned. + * + * @return Unique identifier or null. + */ + @Nullable + @Override + public ResourceLocation getRegistryName() { + return registryName != null ? registryName : null; + } + + /** + * Sets a unique name for this Item. This should be used for uniquely identify the instance of the Item. + * This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does. + * Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items. + *

+ * The supplied name will be prefixed with the currently active mod's modId. + * If the supplied name already has a prefix that is different, it will be used and a warning will be logged. + *

+ * If a name already exists, or this Item is already registered in a registry, then an IllegalStateException is thrown. + *

+ * Returns 'this' to allow for chaining. + * + * @param name Unique registry name + * @return This instance + */ + public final AssetModel setRegistryName(String name) { + if (getRegistryName() != null) + throw new IllegalStateException("Attempted to set registry name with existing registry name! New: " + name + " Old: " + getRegistryName()); + + this.registryName = GameData.checkPrefix(name, true); + return (AssetModel) this; + } + + @Override + public final AssetModel setRegistryName(ResourceLocation name) { + return setRegistryName(name.toString()); + } + + public final AssetModel setRegistryName(String modID, String name) { + return setRegistryName(modID + ":" + name); + } + + /** + * Determines the type for this entry, used to look up the correct registry in the global registries list as there can only be one + * registry per concrete class. + * + * @return Root registry type. + */ + @Override + public Class getRegistryType() { + return (Class) token.getRawType(); + } +} diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/registry/CSRegistryHelper.java b/src/main/java/com/leviathanstudio/craftstudio/client/registry/CSRegistryHelper.java index 9377eec..136ae14 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/registry/CSRegistryHelper.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/registry/CSRegistryHelper.java @@ -1,162 +1,76 @@ package com.leviathanstudio.craftstudio.client.registry; -import java.util.ArrayList; -import java.util.List; - import com.leviathanstudio.craftstudio.CraftStudioApi; import com.leviathanstudio.craftstudio.client.exception.CSMalformedJsonException; import com.leviathanstudio.craftstudio.client.exception.CSResourceNotFoundException; import com.leviathanstudio.craftstudio.client.json.CSJsonReader; import com.leviathanstudio.craftstudio.client.util.EnumRenderType; import com.leviathanstudio.craftstudio.client.util.EnumResourceType; - import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.ProgressManager; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import java.util.ArrayList; +import java.util.List; /** * Class containing useful methods to register models and animations. - * - * @since 0.3.0 - * + * * @author Timmypote * @author ZeAmateis + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class CSRegistryHelper -{ - private String modid; +@OnlyIn(Dist.CLIENT) +public class CSRegistryHelper { + private String modid; - private static List loadModelList = new ArrayList(); - private static List loadAnimList = new ArrayList(); - /** - * Constructor for the registry - * - * @param modid - * Define the ID of your mod - */ public CSRegistryHelper(String modid) { - this.modid = modid; + this.modid = modid; } /** * Pre-register your resource. * - * @param resourceTypeIn - * Set your resource type,
- * {@link EnumResourceType#ANIM} for animation,
- * {@link EnumResourceType#MODELS} for models
- *
- * @param renderTypeIn - * Set your render type,
- * {@link EnumRenderType#BLOCK} for a block
- * {@link EnumRenderType#ENTITY} for an entity
- *
- * - * @param resourceNameIn - * The name of your resource in assets without extension - */ - public void register(EnumResourceType resourceTypeIn, EnumRenderType renderTypeIn, String resourceNameIn) { - capitalCheck(resourceNameIn); - CSRegistryHelper.register(resourceTypeIn, - new ResourceLocation(modid, resourceTypeIn.getPath() + renderTypeIn.getFolderName() + resourceNameIn + resourceTypeIn.getExtension()), - resourceNameIn); - } - - /** - * Pre-register your resource. - * - * @param resourceTypeIn - * Set your resource type,
- * {@link EnumResourceType#ANIM} for animation,
- * {@link EnumResourceType#MODELS} for models
- *
- * @param resourceLocationIn - * Custom location of your resource - * - * @param resourceNameIn - * The name of your resource in assets without extension + * @param resourceTypeIn Set your resource type,
+ * {@link EnumResourceType#ANIM} for animation,
+ * {@link EnumResourceType#MODEL} for models
+ *
+ * @param resourceLocationIn Custom location of your resource + * @param resourceNameIn The name of your resource in assets without extension */ public static void register(EnumResourceType resourceTypeIn, ResourceLocation resourceLocationIn, String resourceNameIn) { switch (resourceTypeIn) { case MODEL: - if (CSRegistryHelper.loadModelList != null) - CSRegistryHelper.loadModelList.add(new LoadElement(resourceLocationIn, resourceNameIn)); - else - CraftStudioApi.getLogger() - .error("Unable to load model outside of the RegistryEvent.Register event, use forceRegister instead"); + registry(EnumResourceType.MODEL, resourceLocationIn, resourceNameIn); break; case ANIM: - if (CSRegistryHelper.loadAnimList != null) - CSRegistryHelper.loadAnimList.add(new LoadElement(resourceLocationIn, resourceNameIn)); - else - CraftStudioApi.getLogger() - .error("Unable to load animations outside of the RegistryEvent.Register event, use forceRegister instead"); + registry(EnumResourceType.ANIM, resourceLocationIn, resourceNameIn); break; } } - /** - * Load all the pre-registered models. Used internally. - */ - public static void loadModels() { - if (loadModelList == null) - return; - ProgressManager.ProgressBar progressBarModels; - progressBarModels = ProgressManager.push("Registry Models", CSRegistryHelper.loadModelList.size()); - - for (LoadElement el : CSRegistryHelper.loadModelList) { - progressBarModels.step("[" + el.resourceLoc.getResourceDomain() + ":" + el.ressourceName + "]"); - registry(EnumResourceType.MODEL, el.resourceLoc, el.ressourceName); - } - ProgressManager.pop(progressBarModels); - - CraftStudioApi.getLogger().info(String.format("CraftStudioAPI loaded %s models", CSRegistryHelper.loadModelList.size())); - CSRegistryHelper.loadModelList = null; - } - /** - * Load all the pre-registered animations. Used internally. - */ - public static void loadAnims() { - if (loadAnimList == null) - return; - ProgressManager.ProgressBar progressBarAnim; - progressBarAnim = ProgressManager.push("Registry Animations", CSRegistryHelper.loadAnimList.size()); - for (LoadElement el : CSRegistryHelper.loadAnimList) { - progressBarAnim.step("[" + el.resourceLoc.getResourceDomain() + ":" + el.ressourceName + "]"); - registry(EnumResourceType.ANIM, el.resourceLoc, el.ressourceName); - } - ProgressManager.pop(progressBarAnim); - - CraftStudioApi.getLogger().info(String.format("CraftStudioAPI loaded %s animations", CSRegistryHelper.loadAnimList.size())); - CSRegistryHelper.loadAnimList = null; - } /** * Register an assets. - * - * @param resourceTypeIn - * The resource type. - * @param resourceLocationIn - * Location of the resource. - * @param resourceNameIn - * The name of your resource. + * + * @param resourceTypeIn The resource type. + * @param resourceLocationIn Location of the resource. + * @param resourceNameIn The name of your resource. */ private static void registry(EnumResourceType resourceTypeIn, ResourceLocation resourceLocationIn, String resourceNameIn) { CSJsonReader jsonReader; try { jsonReader = new CSJsonReader(resourceLocationIn); - if (resourceLocationIn.getResourceDomain() != CraftStudioApi.API_ID) + if (resourceLocationIn.getNamespace() != CraftStudioApi.API_ID) switch (resourceTypeIn) { case MODEL: - RegistryHandler.register(new ResourceLocation(resourceLocationIn.getResourceDomain(), resourceNameIn), + RegistryHandler.register(new ResourceLocation(resourceLocationIn.getNamespace(), resourceNameIn), jsonReader.readModel()); break; case ANIM: - RegistryHandler.register(new ResourceLocation(resourceLocationIn.getResourceDomain(), resourceNameIn), jsonReader.readAnim()); + RegistryHandler.register(new ResourceLocation(resourceLocationIn.getNamespace(), resourceNameIn), jsonReader.readAnim()); break; } else @@ -168,9 +82,8 @@ private static void registry(EnumResourceType resourceTypeIn, ResourceLocation r /** * Check if there is capital letter in a String, and send a warning message. - * - * @param str - * The String to test. + * + * @param str The String to test. */ private static void capitalCheck(String str) { if (!str.toLowerCase().equals(str)) { @@ -179,20 +92,25 @@ private static void capitalCheck(String str) { } } + /** - * An object containing informations about a pre-registered object to load - * later. - * - * @author Timmypote + * Pre-register your resource. + * + * @param resourceTypeIn Set your resource type,
+ * {@link EnumResourceType#ANIM} for animation,
+ * {@link EnumResourceType#MODEL} for models
+ *
+ * @param renderTypeIn Set your render type,
+ * {@link EnumRenderType#BLOCK} for a block
+ * {@link EnumRenderType#ENTITY} for an entity
+ *
+ * @param resourceNameIn The name of your resource in assets without extension */ - private static class LoadElement - { - ResourceLocation resourceLoc; - String ressourceName; - - LoadElement(ResourceLocation resourceLoc, String ressourceName) { - this.resourceLoc = resourceLoc; - this.ressourceName = ressourceName; - } + public void register(EnumResourceType resourceTypeIn, EnumRenderType renderTypeIn, String resourceNameIn) { + capitalCheck(resourceNameIn); + CSRegistryHelper.register(resourceTypeIn, + new ResourceLocation(modid, resourceTypeIn.getPath() + renderTypeIn.getFolderName() + resourceNameIn + resourceTypeIn.getExtension()), + resourceNameIn); } + } \ No newline at end of file diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/registry/CraftStudioAssetsEvent.java b/src/main/java/com/leviathanstudio/craftstudio/client/registry/CraftStudioAssetsEvent.java new file mode 100644 index 0000000..6a95439 --- /dev/null +++ b/src/main/java/com/leviathanstudio/craftstudio/client/registry/CraftStudioAssetsEvent.java @@ -0,0 +1,20 @@ +package com.leviathanstudio.craftstudio.client.registry; + +import net.minecraftforge.eventbus.api.Event; + +public class CraftStudioAssetsEvent extends Event { + + + /** + * Determine if this function is cancelable at all. + * + * @return If access to setCanceled should be allowed + *

+ * Note: + * Events with the Cancelable annotation will have this method automatically added to return true. + */ + @Override + public boolean isCancelable() { + return false; + } +} diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/registry/CraftStudioLoader.java b/src/main/java/com/leviathanstudio/craftstudio/client/registry/CraftStudioLoader.java deleted file mode 100644 index 2dafd88..0000000 --- a/src/main/java/com/leviathanstudio/craftstudio/client/registry/CraftStudioLoader.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.leviathanstudio.craftstudio.client.registry; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -/** - * Annotation to indicate that the method it is applied on should be called - * during the loading of CraftStudio assets. Must be applied on a 'static' - * method with no arguments. - * - * @since 1.0.0 - * - * @author Timmypote - */ -@SideOnly(Side.CLIENT) -@Retention(RUNTIME) -@Target(METHOD) -public @interface CraftStudioLoader {} diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/registry/RegistryHandler.java b/src/main/java/com/leviathanstudio/craftstudio/client/registry/RegistryHandler.java index ea4cc44..7efbbf9 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/registry/RegistryHandler.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/registry/RegistryHandler.java @@ -2,54 +2,44 @@ import com.leviathanstudio.craftstudio.client.json.CSReadedAnim; import com.leviathanstudio.craftstudio.client.json.CSReadedModel; - import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.RegistrySimple; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.util.registry.SimpleRegistry; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; /** * Class that handle registry for the CraftStudioApi. - * - * @since 1.0.0 - * + * * @author Timmypote + * @since 1.0.0 */ -@SideOnly(Side.CLIENT) -public class RegistryHandler -{ - public static RegistrySimple modelRegistry; - public static RegistrySimple animationRegistry; +@OnlyIn(Dist.CLIENT) +public class RegistryHandler { + public static SimpleRegistry modelRegistry; + public static SimpleRegistry animationRegistry; - /** - * Initialize the registries. - */ - public static void init() { - modelRegistry = new RegistrySimple<>(); - animationRegistry = new RegistrySimple<>(); + static { + modelRegistry = new SimpleRegistry<>(); + animationRegistry = new SimpleRegistry<>(); } /** * Register a CSReadedModel. - * - * @param res - * The name of the model. - * @param model - * The model. + * + * @param res The name of the model. + * @param model The model. */ public static void register(ResourceLocation res, CSReadedModel model) { - modelRegistry.putObject(res, model); + modelRegistry.register(res, model); } /** * Register a CSReadedAnim. - * - * @param res - * The name of the animation. - * @param anim - * The animation. + * + * @param res The name of the animation. + * @param anim The animation. */ public static void register(ResourceLocation res, CSReadedAnim anim) { - animationRegistry.putObject(res, anim); + animationRegistry.register(res, anim); } } diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/util/EnumFrameType.java b/src/main/java/com/leviathanstudio/craftstudio/client/util/EnumFrameType.java index 1344579..27dd960 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/util/EnumFrameType.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/util/EnumFrameType.java @@ -1,17 +1,16 @@ package com.leviathanstudio.craftstudio.client.util; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; /** * Enumeration of the different type of keyframe field type. - * - * @since 0.3.0 * * @author ZeAmateis * @author Phenix246 + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) +@OnlyIn(Dist.CLIENT) public enum EnumFrameType { POSITION, ROTATION, OFFSET, SIZE, STRETCH; } diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/util/EnumRenderType.java b/src/main/java/com/leviathanstudio/craftstudio/client/util/EnumRenderType.java index 17eb2aa..9822a61 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/util/EnumRenderType.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/util/EnumRenderType.java @@ -1,17 +1,16 @@ package com.leviathanstudio.craftstudio.client.util; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; /** * Enumeration of the different render type. - * - * @since 0.3.0 * * @author ZeAmateis * @author Phenix246 + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) +@OnlyIn(Dist.CLIENT) public enum EnumRenderType { BLOCK("blocks/"), ENTITY("entity/"); diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/util/EnumResourceType.java b/src/main/java/com/leviathanstudio/craftstudio/client/util/EnumResourceType.java index fb5db87..646fc62 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/util/EnumResourceType.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/util/EnumResourceType.java @@ -1,17 +1,16 @@ package com.leviathanstudio.craftstudio.client.util; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; /** * Enumeration of the different resource type. - * - * @since 0.3.0 * * @author ZeAmateis * @author Phenix246 + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) +@OnlyIn(Dist.CLIENT) public enum EnumResourceType { MODEL("craftstudio/models/", ".csjsmodel"), ANIM("craftstudio/animations/", ".csjsmodelanim"); diff --git a/src/main/java/com/leviathanstudio/craftstudio/client/util/MathHelper.java b/src/main/java/com/leviathanstudio/craftstudio/client/util/MathHelper.java index c231e61..244fed1 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/client/util/MathHelper.java +++ b/src/main/java/com/leviathanstudio/craftstudio/client/util/MathHelper.java @@ -1,31 +1,27 @@ package com.leviathanstudio.craftstudio.client.util; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.FloatBuffer; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import javax.vecmath.Matrix4f; import javax.vecmath.Quat4f; import javax.vecmath.Vector3f; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; /** * Class containing useful math methods for the api. - * - * @since 0.3.0 * * @author Timmypote + * @since 0.3.0 */ -@SideOnly(Side.CLIENT) -public class MathHelper -{ +@OnlyIn(Dist.CLIENT) +public class MathHelper { /** * Create a direct FloatBuffer from a Matrix4f. * - * @param mat - * The Matrix4f. + * @param mat The Matrix4f. * @return The FloatBuffer. */ public static FloatBuffer makeFloatBuffer(Matrix4f mat) { @@ -56,8 +52,7 @@ public static FloatBuffer makeFloatBuffer(Matrix4f mat) { * Create a new Quat4f representing the yaw, pitch and roll given(applied in * that order). * - * @param rot - * The pitch, yaw and roll as a Vector3f(x=pitch, y=yaw, z=roll). + * @param rot The pitch, yaw and roll as a Vector3f(x=pitch, y=yaw, z=roll). * @return The new Quat4f. */ public static Quat4f quatFromEuler(Vector3f rot) { @@ -68,12 +63,9 @@ public static Quat4f quatFromEuler(Vector3f rot) { * Create a new Quat4f representing the yaw, pitch and roll given(applied in * that order). * - * @param pitch - * The pitch. - * @param yaw - * The yaw. - * @param roll - * The roll. + * @param pitch The pitch. + * @param yaw The yaw. + * @param roll The roll. * @return The new Quat4f. */ public static Quat4f quatFromEuler(float pitch, float yaw, float roll) { diff --git a/src/main/java/com/leviathanstudio/craftstudio/common/animation/AnimationHandler.java b/src/main/java/com/leviathanstudio/craftstudio/common/animation/AnimationHandler.java index fe75736..5206dce 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/common/animation/AnimationHandler.java +++ b/src/main/java/com/leviathanstudio/craftstudio/common/animation/AnimationHandler.java @@ -5,7 +5,7 @@ import com.leviathanstudio.craftstudio.common.network.CSNetworkHelper; import com.leviathanstudio.craftstudio.common.network.EnumIAnimatedEvent; -import com.leviathanstudio.craftstudio.common.network.IAnimatedEventMessage; +import com.leviathanstudio.craftstudio.common.network.AnimatedEventMessage; import net.minecraft.util.ResourceLocation; @@ -110,7 +110,7 @@ public void networkStartAnimation(String res, float startingFrame, T animatedEle if (animatedElement.isWorldRemote() == clientSend) { this.serverInitAnimation(res, startingFrame, animatedElement); CSNetworkHelper.sendIAnimatedEvent( - new IAnimatedEventMessage(EnumIAnimatedEvent.START_ANIM, animatedElement, this.getAnimIdFromName(res), startingFrame)); + new AnimatedEventMessage(EnumIAnimatedEvent.START_ANIM, animatedElement, this.getAnimIdFromName(res), startingFrame)); } } @@ -173,7 +173,7 @@ public void stopAnimation(String res, T animatedElement) { public void networkStopAnimation(String res, T animatedElement, boolean clientSend) { if (animatedElement.isWorldRemote() == clientSend) { this.serverStopAnimation(res, animatedElement); - CSNetworkHelper.sendIAnimatedEvent(new IAnimatedEventMessage(EnumIAnimatedEvent.STOP_ANIM, animatedElement, this.getAnimIdFromName(res))); + CSNetworkHelper.sendIAnimatedEvent(new AnimatedEventMessage(EnumIAnimatedEvent.STOP_ANIM, animatedElement, this.getAnimIdFromName(res))); } } @@ -222,7 +222,7 @@ public void stopStartAnimation(String animToStop, String animToStart, float star public void networkStopStartAnimation(String animToStop, String animToStart, float startingFrame, T animatedElement, boolean clientSend) { if (animatedElement.isWorldRemote() == clientSend) { this.serverStopStartAnimation(animToStop, animToStart, startingFrame, animatedElement); - CSNetworkHelper.sendIAnimatedEvent(new IAnimatedEventMessage(EnumIAnimatedEvent.STOP_START_ANIM, animatedElement, + CSNetworkHelper.sendIAnimatedEvent(new AnimatedEventMessage(EnumIAnimatedEvent.STOP_START_ANIM, animatedElement, this.getAnimIdFromName(animToStart), startingFrame, this.getAnimIdFromName(animToStop))); } } @@ -339,7 +339,7 @@ public short getAnimIdFromName(String name) { * @return True, if the message was correctly processed and a response * should be send if it's needed. */ - public boolean onClientIAnimatedEvent(IAnimatedEventMessage message) { + public boolean onClientIAnimatedEvent(AnimatedEventMessage message) { AnimationHandler hand = message.animated.getAnimationHandler(); switch (EnumIAnimatedEvent.getEvent(message.event)) { case START_ANIM: @@ -362,7 +362,7 @@ public boolean onClientIAnimatedEvent(IAnimatedEventMessage message) { * @return True, if the message was correctly processed and should be send * to all the clients in range. */ - public static boolean onServerIAnimatedEvent(IAnimatedEventMessage message) { + public static boolean onServerIAnimatedEvent(AnimatedEventMessage message) { AnimationHandler hand = message.animated.getAnimationHandler(); switch (EnumIAnimatedEvent.getEvent(message.event)) { case START_ANIM: diff --git a/src/main/java/com/leviathanstudio/craftstudio/common/animation/CustomChannel.java b/src/main/java/com/leviathanstudio/craftstudio/common/animation/CustomChannel.java index 54af4ef..e350722 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/common/animation/CustomChannel.java +++ b/src/main/java/com/leviathanstudio/craftstudio/common/animation/CustomChannel.java @@ -1,9 +1,8 @@ package com.leviathanstudio.craftstudio.common.animation; import com.leviathanstudio.craftstudio.client.model.CSModelRenderer; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; /** * Class used to perform custom animations. For example, using in game data. @@ -29,6 +28,6 @@ public CustomChannel(String channelName) { * @param animated * The animated object. */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public abstract void update(CSModelRenderer part, IAnimated animated); } diff --git a/src/main/java/com/leviathanstudio/craftstudio/common/animation/IAnimated.java b/src/main/java/com/leviathanstudio/craftstudio/common/animation/IAnimated.java index f3d5e88..19bc88e 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/common/animation/IAnimated.java +++ b/src/main/java/com/leviathanstudio/craftstudio/common/animation/IAnimated.java @@ -1,60 +1,58 @@ package com.leviathanstudio.craftstudio.common.animation; +import net.minecraft.world.dimension.DimensionType; + /** * Implement object that must be animated with the api. * - * @since 0.3.0 - * * @author Timmypote * @author ZeAmateis + * @since 0.3.0 */ -public interface IAnimated -{ +public interface IAnimated { /** * Getter to call custom {@link AnimationHandler} class to call useful * methods. * + * @param The animated object class'. * @see AnimationHandler#addAnim addAnim() * @see AnimationHandler#startAnimation startAnimation() * @see AnimationHandler#stopAnimation stopAnimation() * @see AnimationHandler#isAnimationActive isAnimationActive() - * - * @param - * The animated object class'. */ public AnimationHandler getAnimationHandler(); /** * Getter for the dimension. - * + * * @return The dimension of the object as a int. */ - public int getDimension(); + public DimensionType getDimension(); /** * Getter for the x coordinate. - * + * * @return The position on the x axis of the object. */ public double getX(); /** * Getter for the y coordinate. - * + * * @return The position on the y axis of the object. */ public double getY(); /** * Getter for the z coordinate. - * + * * @return The position on the z axis of the object. */ public double getZ(); /** * Check if the world of this object is remote or not. - * + * * @return True, if the world is remote. False, otherwise. */ public boolean isWorldRemote(); diff --git a/src/main/java/com/leviathanstudio/craftstudio/common/animation/simpleImpl/AnimatedEntity.java b/src/main/java/com/leviathanstudio/craftstudio/common/animation/simpleImpl/AnimatedEntity.java index 76daa3d..e7a9510 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/common/animation/simpleImpl/AnimatedEntity.java +++ b/src/main/java/com/leviathanstudio/craftstudio/common/animation/simpleImpl/AnimatedEntity.java @@ -3,21 +3,22 @@ import com.leviathanstudio.craftstudio.CraftStudioApi; import com.leviathanstudio.craftstudio.common.animation.AnimationHandler; import com.leviathanstudio.craftstudio.common.animation.IAnimated; - -import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.CreatureEntity; +import net.minecraft.entity.EntityType; import net.minecraft.world.World; +import net.minecraft.world.dimension.DimensionType; /** * An abstract class that represent an animated entity. You can extends it or * use it as a model to create your own animated entity. - * - * @since 0.3.0 - * + * * @author Timmypote + * @since 0.3.0 */ -public abstract class AnimatedEntity extends EntityCreature implements IAnimated -{ - /** The animation handler of this type of entity. */ +public abstract class AnimatedEntity extends CreatureEntity implements IAnimated { + /** + * The animation handler of this type of entity. + */ // It should be different for every entity class, unless child classes have // the same models. // You should declare a new one in your extended classes. @@ -28,16 +29,23 @@ public abstract class AnimatedEntity extends EntityCreature implements IAnimated //AnimatedEntity.animHandler.addAnim("yourModId", "yourAnimation", "yourModel", false); } - /** The constructor of the entity. */ - public AnimatedEntity(World worldIn) { - super(worldIn); + /** + * The constructor of the entity. + */ + public AnimatedEntity(EntityType entityTypeIn, World worldIn) { + super(entityTypeIn, worldIn); } // You must call super.onLivingUpdate(), in your entity, or call the // animationsUpdate() method like here. + + /** + * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons + * use this to react to sunlight and start to burn. + */ @Override - public void onLivingUpdate() { - super.onLivingUpdate(); + public void livingTick() { + super.livingTick(); this.getAnimationHandler().animationsUpdate(this); } @@ -48,7 +56,7 @@ public AnimationHandler getAnimationHandler() { } @Override - public int getDimension() { + public DimensionType getDimension() { return this.dimension; } diff --git a/src/main/java/com/leviathanstudio/craftstudio/common/animation/simpleImpl/AnimatedTileEntity.java b/src/main/java/com/leviathanstudio/craftstudio/common/animation/simpleImpl/AnimatedTileEntity.java index 46b13a5..63e762f 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/common/animation/simpleImpl/AnimatedTileEntity.java +++ b/src/main/java/com/leviathanstudio/craftstudio/common/animation/simpleImpl/AnimatedTileEntity.java @@ -3,22 +3,23 @@ import com.leviathanstudio.craftstudio.CraftStudioApi; import com.leviathanstudio.craftstudio.common.animation.AnimationHandler; import com.leviathanstudio.craftstudio.common.animation.IAnimated; - +import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ITickable; +import net.minecraft.tileentity.TileEntityType; +import net.minecraft.world.dimension.DimensionType; /** * An abstract class that represent a animated TileEntity. You should extends it * and not create your own, or be careful to implement all the methods of this * class. - * - * @since 0.3.0 - * + * * @author Timmypote + * @since 0.3.0 */ -public abstract class AnimatedTileEntity extends TileEntity implements IAnimated, ITickable -{ - /** The animation handler of this type of tile entity. */ +public abstract class AnimatedTileEntity extends TileEntity implements IAnimated, ITickableTileEntity { + /** + * The animation handler of this type of tile entity. + */ // It should be different for every entity class, unless child classes have // the same models. // You should declare a new one in your extended classes. @@ -29,15 +30,19 @@ public abstract class AnimatedTileEntity extends TileEntity implements IAnimated //AnimatedTileEntity.animHandler.addAnim("yourModId", "yourAnimation", "yourModel", false); } - /** The constructor of the tile entity. */ - public AnimatedTileEntity() { - super(); + public AnimatedTileEntity(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); } + /** + * The constructor of the tile entity. + */ + + // You must call super.update() at the beginning of your update() method, // or call the animationsUpdate() method like here. @Override - public void update() { + public void tick() { this.getAnimationHandler().animationsUpdate(this); } @@ -48,8 +53,8 @@ public AnimationHandler getAnimationHandler() { } @Override - public int getDimension() { - return this.world.provider.getDimension(); + public DimensionType getDimension() { + return this.world.getDimension().getType(); } @Override diff --git a/src/main/java/com/leviathanstudio/craftstudio/common/animation/simpleImpl/CSTileEntitySpecialRenderer.java b/src/main/java/com/leviathanstudio/craftstudio/common/animation/simpleImpl/CSTileEntitySpecialRenderer.java index 1a69ab9..383bd4b 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/common/animation/simpleImpl/CSTileEntitySpecialRenderer.java +++ b/src/main/java/com/leviathanstudio/craftstudio/common/animation/simpleImpl/CSTileEntitySpecialRenderer.java @@ -1,54 +1,62 @@ package com.leviathanstudio.craftstudio.common.animation.simpleImpl; -import java.nio.FloatBuffer; - -import javax.vecmath.Matrix4f; - import com.leviathanstudio.craftstudio.client.model.ModelCraftStudio; import com.leviathanstudio.craftstudio.client.util.MathHelper; - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import com.mojang.blaze3d.platform.GlStateManager; +import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; +import javax.vecmath.Matrix4f; +import java.nio.FloatBuffer; + /** * Renderer of animated TileEntity. If you only need one model to be render you * can directly use this class. Otherwise, or if you prefer, you can use this * class as a model to create your renderer. - * - * @since 0.3.0 - * - * @author Timmypote * * @param + * @author Timmypote + * @since 0.3.0 */ -public class CSTileEntitySpecialRenderer extends TileEntitySpecialRenderer -{ - /** Efficient rotation corrector, you can use it in your renderer. */ +public class CSTileEntitySpecialRenderer extends TileEntityRenderer { + /** + * Efficient rotation corrector, you can use it in your renderer. + */ public static final FloatBuffer ROTATION_CORRECTOR; + static { Matrix4f mat = new Matrix4f(); mat.set(MathHelper.quatFromEuler(180, 0, 0)); ROTATION_CORRECTOR = MathHelper.makeFloatBuffer(mat); } - /** The model of the block. */ + /** + * The model of the block. + */ protected ModelCraftStudio model; - /** The texture of the block */ + /** + * The texture of the block + */ protected ResourceLocation texture; - /** The constructor that initialize the model and save texture. */ + /** + * The constructor that initialize the model and save texture. + */ public CSTileEntitySpecialRenderer(String modid, String modelNameIn, int textureWidth, int textureHeigth, ResourceLocation texture) { this.model = new ModelCraftStudio(modid, modelNameIn, textureWidth, textureHeigth); this.texture = texture; } + + @Override - public void render(T te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { + public void render(T te, double x, double y, double z, float partialTicks, int destroyStage) { + super.render(te, x, y, z, partialTicks, destroyStage); + GlStateManager.pushMatrix(); // Correction of the position. - GlStateManager.translate(x + 0.5D, y + 1.5D, z + 0.5D); + GlStateManager.translated(x + 0.5D, y + 1.5D, z + 0.5D); // Correction of the rotation. GlStateManager.multMatrix(CSTileEntitySpecialRenderer.ROTATION_CORRECTOR); this.bindTexture(this.texture); // Binding the texture. diff --git a/src/main/java/com/leviathanstudio/craftstudio/common/network/AnimatedEventMessage.java b/src/main/java/com/leviathanstudio/craftstudio/common/network/AnimatedEventMessage.java new file mode 100644 index 0000000..761faf7 --- /dev/null +++ b/src/main/java/com/leviathanstudio/craftstudio/common/network/AnimatedEventMessage.java @@ -0,0 +1,86 @@ +package com.leviathanstudio.craftstudio.common.network; + +import com.leviathanstudio.craftstudio.common.animation.IAnimated; + +/** + * Base class for + * {@link com.leviathanstudio.craftstudio.common.animation.IAnimated IAnimated} + * event messages. + * + * @author Timmypote + * @since 0.3.0 + */ +public class AnimatedEventMessage { + /** + * The id of the event. See for more info {@link EnumIAnimatedEvent}. + */ + public short event; + /** + * The id of the primary animation. + */ + public short animId; + /** + * The id of the secondary animation, used for stopStart message. + */ + public short optAnimId = -1; + /** + * A float used to transmit keyframe related informations. + */ + public float keyframeInfo = -1; + /** + * The object that is animated + */ + public IAnimated animated; + /** + * Variable that transmit part of the UUID of an Entity. + */ + public long most, least; + /** + * Variable that transmit the position of a TileEntity. + */ + public int x, y, z; + /** + * True, if on message receiving the animated object is an entity. + */ + public boolean hasEntity; + + /** + * Simple empty constructor for packets system. + */ + public AnimatedEventMessage() { + } + + /** + * Constructor + */ + public AnimatedEventMessage(EnumIAnimatedEvent event, IAnimated animated, short animId) { + if (event != null) + this.event = event.getId(); + this.animated = animated; + this.animId = animId; + } + + /** + * Constructor + */ + public AnimatedEventMessage(EnumIAnimatedEvent event, IAnimated animated, short animId, float keyframeInfo) { + this(event, animated, animId); + this.keyframeInfo = keyframeInfo; + } + + /** + * Constructor + */ + public AnimatedEventMessage(EnumIAnimatedEvent event, IAnimated animated, short animId, float keyframeInfo, short optAnimId) { + this(event, animated, animId, keyframeInfo); + this.optAnimId = optAnimId; + } + + /** + * Constructor + */ + public AnimatedEventMessage(AnimatedEventMessage eventObj) { + this(null, eventObj.animated, eventObj.animId, eventObj.keyframeInfo, eventObj.optAnimId); + this.event = eventObj.event; + } +} diff --git a/src/main/java/com/leviathanstudio/craftstudio/common/network/AnimatedEventMessageUtil.java b/src/main/java/com/leviathanstudio/craftstudio/common/network/AnimatedEventMessageUtil.java new file mode 100644 index 0000000..208fe29 --- /dev/null +++ b/src/main/java/com/leviathanstudio/craftstudio/common/network/AnimatedEventMessageUtil.java @@ -0,0 +1,223 @@ +package com.leviathanstudio.craftstudio.common.network; + +import java.util.UUID; +import java.util.function.BiConsumer; +import java.util.function.Function; +import java.util.function.Supplier; + +import com.google.common.base.Predicates; +import com.leviathanstudio.craftstudio.CraftStudioApi; +import com.leviathanstudio.craftstudio.client.animation.ClientAnimationHandler; +import com.leviathanstudio.craftstudio.common.animation.AnimationHandler; +import com.leviathanstudio.craftstudio.common.animation.IAnimated; +import com.leviathanstudio.craftstudio.common.animation.InfoChannel; + +import net.minecraft.client.world.ClientWorld; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.network.PacketBuffer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.server.ServerWorld; +import net.minecraftforge.fml.network.NetworkEvent.Context; + +public class AnimatedEventMessageUtil { + + private static final CommonHandler SERVER = new ServerHandler(); + private static final CommonHandler CLIENT = new ClientHandler(); + + public static final BiConsumer ENCODER = (msg, buffer) -> { + if (msg.event < 0 || msg.event >= EnumIAnimatedEvent.ID_COUNT) { + buffer.writeShort(-1); + CraftStudioApi.getLogger().error("Unsuported event id " + msg.event + " for network message."); + return; + } + if (msg.animated instanceof Entity) { + Entity e = (Entity) msg.animated; + buffer.writeShort(msg.event); + UUID uuid = e.getUniqueID(); + buffer.writeLong(uuid.getMostSignificantBits()); + buffer.writeLong(uuid.getLeastSignificantBits()); + } else if (msg.animated instanceof TileEntity) { + TileEntity te = (TileEntity) msg.animated; + buffer.writeShort(msg.event + EnumIAnimatedEvent.ID_COUNT); + BlockPos pos = te.getPos(); + buffer.writeInt(pos.getX()); + buffer.writeInt(pos.getY()); + buffer.writeInt(pos.getZ()); + } else { + buffer.writeShort(-1); + CraftStudioApi.getLogger().error("Unsuported class " + msg.animated.getClass().getSimpleName() + " for network message."); + CraftStudioApi.getLogger().error("You are trying to animate an other class than Entity or TileEntity."); + return; + } + buffer.writeShort(msg.animId); + if (msg.event != EnumIAnimatedEvent.STOP_ANIM.getId()) + buffer.writeFloat(msg.keyframeInfo); + if (msg.event == EnumIAnimatedEvent.STOP_START_ANIM.getId()) + buffer.writeShort(msg.optAnimId); + }; + + public static final Function DECODER = (buffer) -> { + AnimatedEventMessage msg = new AnimatedEventMessage(); + + short actualEvent = buffer.readShort(); + if (actualEvent < 0 || actualEvent >= 2 * EnumIAnimatedEvent.ID_COUNT) { + msg.event = -1; + CraftStudioApi.getLogger().error("Networking error : invalid packet."); + return null; + } else if (actualEvent < EnumIAnimatedEvent.ID_COUNT) { + msg.most = buffer.readLong(); + msg.least = buffer.readLong(); + msg.event = actualEvent; + msg.hasEntity = true; + } else { + msg.x = buffer.readInt(); + msg.y = buffer.readInt(); + msg.z = buffer.readInt(); + msg.event = (short) (actualEvent - EnumIAnimatedEvent.ID_COUNT); + msg.hasEntity = false; + } + msg.animId = buffer.readShort(); + if (msg.event != 2) + msg.keyframeInfo = buffer.readFloat(); + if (msg.event > 2) + msg.optAnimId = buffer.readShort(); + return msg; + }; + + + public static BiConsumer> HANDLER = (msg, ctx) -> { + switch(ctx.get().getDirection()) { + case PLAY_TO_SERVER: + SERVER.handle(msg, ctx.get()); + break; + case PLAY_TO_CLIENT: + CLIENT.handle(msg, ctx.get()); + break; + default: + // Do nothing + break; + } + ctx.get().setPacketHandled(true); + }; + + + + private static class ServerHandler extends CommonHandler { + + @Override + public Entity getEntityByUUID(Context ctx, long most, long least) { + ServerPlayerEntity sender = ctx.getSender(); // the client that sent this packet + ServerWorld world = (ServerWorld)sender.getEntityWorld(); + UUID uuid = new UUID(most, least); + for (Entity e : world.getEntities(null, Predicates.alwaysTrue())) + if (e.getUniqueID().equals(uuid)) + return e; + + return null; + } + + @Override + public TileEntity getTileEntityByPos(Context ctx, int x, int y, int z) { + return ctx.getSender().world.getTileEntity(new BlockPos(x, y, z)); + } + + @Override + public void handle(AnimatedEventMessage message, Context ctx) { + ctx.enqueueWork(() -> { + if (handleCommonSide(message, ctx)) { + message.animated.getAnimationHandler(); + boolean succes = AnimationHandler.onServerIAnimatedEvent(message); + if (succes && message.event != EnumIAnimatedEvent.ANSWER_START_ANIM.getId()) + CSNetworkHelper.sendPacketTo(new AnimatedEventMessage(message), ctx.getSender()); + } + }); + } + + } + + private static class ClientHandler extends CommonHandler { + + @Override + public Entity getEntityByUUID(Context ctx, long most, long least) { + ServerPlayerEntity sender = ctx.getSender(); // the client that sent this packet + ClientWorld world = (ClientWorld)sender.getEntityWorld(); + UUID uuid = new UUID(most, least); + + for (Entity e : world.getAllEntities()) + if (e.getUniqueID().equals(uuid)) + return e; + + return null; + } + + @Override + public TileEntity getTileEntityByPos(Context ctx, int x, int y, int z) { + return ctx.getSender().world.getTileEntity(new BlockPos(x, y, z)); + } + + @Override + public void handle(AnimatedEventMessage message, Context ctx) { + ctx.enqueueWork(() -> { + if (handleCommonSide(message, ctx)) { + boolean succes = message.animated.getAnimationHandler().onClientIAnimatedEvent(message); + if (succes && message.animated.getAnimationHandler() instanceof ClientAnimationHandler + && (message.event == EnumIAnimatedEvent.START_ANIM.getId() || message.event == EnumIAnimatedEvent.STOP_START_ANIM.getId())) { + @SuppressWarnings("rawtypes") + ClientAnimationHandler hand = (ClientAnimationHandler) message.animated.getAnimationHandler(); + String animName = hand.getAnimNameFromId(message.animId); + InfoChannel infoC = (InfoChannel) hand.getAnimChannels().get(animName); + CSNetworkHelper.sendPacketToServer(new AnimatedEventMessage(EnumIAnimatedEvent.ANSWER_START_ANIM, message.animated, message.animId, infoC.totalFrames)); + } + } + }); + } + + } + + private static abstract class CommonHandler { + + protected boolean handleCommonSide(AnimatedEventMessage message, Context ctx) { + if (message.hasEntity) { + Entity e = this.getEntityByUUID(ctx, message.most, message.least); + if (!(e instanceof IAnimated)) { + CraftStudioApi.getLogger().debug("Networking error : invalid entity."); + return false; + } + message.animated = (IAnimated) e; + } else { + TileEntity te = this.getTileEntityByPos(ctx, message.x, message.y, message.z); + if (!(te instanceof IAnimated)) { + CraftStudioApi.getLogger().debug("Networking error : invalid tile entity."); + return false; + } + message.animated = (IAnimated) te; + } + return true; + } + + /** + * Get an entity by its UUID. + * + * @param ctx The context of the message received. + * @param most The most significants bits of the UUID. + * @param least The least significants bits of the UUID. + * @return The Entity, null if it couldn't be found. + */ + public abstract Entity getEntityByUUID(Context ctx, long most, long least); + + /** + * Get a TileEntity by its position. + * + * @param ctx The context of the message received. + * @param x The position on the x axis. + * @param y The position on the y axis. + * @param z The position on the z axis. + * @return The TileEntity, null if it couldn't be found. + */ + public abstract TileEntity getTileEntityByPos(Context ctx, int x, int y, int z); + + public abstract void handle(AnimatedEventMessage message, Context ctx); + } +} diff --git a/src/main/java/com/leviathanstudio/craftstudio/common/network/CSNetworkHelper.java b/src/main/java/com/leviathanstudio/craftstudio/common/network/CSNetworkHelper.java index d71a1f1..da05e84 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/common/network/CSNetworkHelper.java +++ b/src/main/java/com/leviathanstudio/craftstudio/common/network/CSNetworkHelper.java @@ -2,19 +2,22 @@ import com.leviathanstudio.craftstudio.CraftStudioApi; -import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.dimension.DimensionType; +import net.minecraftforge.fml.network.NetworkRegistry; +import net.minecraftforge.fml.network.PacketDistributor; +import net.minecraftforge.fml.network.simple.SimpleChannel; /** * A helper class to easily send * {@link com.leviathanstudio.craftstudio.common.animation.IAnimated IAnimated} * event on client and server. - * - * @since 0.3.0 - * + * * @author Timmypote + * @since 0.3.0 */ -public class CSNetworkHelper -{ +public class CSNetworkHelper { /** * The range around the * {@link com.leviathanstudio.craftstudio.common.animation.IAnimated @@ -22,20 +25,56 @@ public class CSNetworkHelper */ public static final double EVENT_RANGE = 128; + public static final String PROTOCOL_VERSION = String.valueOf(1); + + public static final SimpleChannel CHANNEL = NetworkRegistry.ChannelBuilder + .named(new ResourceLocation(CraftStudioApi.API_ID, "channel")) + .networkProtocolVersion(() -> PROTOCOL_VERSION) + .clientAcceptedVersions(PROTOCOL_VERSION::equals) + .serverAcceptedVersions(PROTOCOL_VERSION::equals) + .simpleChannel(); + + private static int id = 0; + /** * Send the given message through the network. - * - * @param message - * The message to send. + * + * @param message The message to send. */ - public static void sendIAnimatedEvent(IAnimatedEventMessage message) { + public static void sendIAnimatedEvent(AnimatedEventMessage message) { if (message.animated.isWorldRemote()) // If we are on client, we send a server message to the server. - CraftStudioApi.NETWORK.sendToServer(new ServerIAnimatedEventMessage(message)); + sendPacketToServer(new AnimatedEventMessage(message)); else // If we are on server, we send a client message to the clients in // range. - CraftStudioApi.NETWORK.sendToAllAround(new ClientIAnimatedEventMessage(message), new TargetPoint(message.animated.getDimension(), - message.animated.getX(), message.animated.getY(), message.animated.getZ(), CSNetworkHelper.EVENT_RANGE)); + sendToAllAround(new AnimatedEventMessage(message), new PacketDistributor.TargetPoint( + message.animated.getX(), message.animated.getY(), message.animated.getZ(), CSNetworkHelper.EVENT_RANGE, message.animated.getDimension())); + } + + + public static SimpleChannel.MessageBuilder messageBuilder(Class packetIn) { + return CHANNEL.messageBuilder(packetIn, id++); + } + + public static void sendPacketToServer(AnimatedEventMessage packetIn) { + CHANNEL.sendToServer(packetIn); + } + + public static void sendPacketTo(AnimatedEventMessage packetIn, ServerPlayerEntity player) { + CHANNEL.send(PacketDistributor.PLAYER.with(() -> player), packetIn); + } + + public static void sendPacketToEveryone(AnimatedEventMessage packetIn) { + CHANNEL.send(PacketDistributor.ALL.noArg(), packetIn); + } + + public static void sendPacketToDimension(AnimatedEventMessage packetIn, DimensionType dimension) { + CHANNEL.send(PacketDistributor.DIMENSION.with(() -> dimension), packetIn); + } + + public static void sendToAllAround(AnimatedEventMessage packetIn, PacketDistributor.TargetPoint targetPoint) { + CHANNEL.send(PacketDistributor.NEAR.with(() -> targetPoint), packetIn); + } } diff --git a/src/main/java/com/leviathanstudio/craftstudio/common/network/ClientIAnimatedEventMessage.java b/src/main/java/com/leviathanstudio/craftstudio/common/network/ClientIAnimatedEventMessage.java deleted file mode 100644 index 7400014..0000000 --- a/src/main/java/com/leviathanstudio/craftstudio/common/network/ClientIAnimatedEventMessage.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.leviathanstudio.craftstudio.common.network; - -import java.util.UUID; - -import com.leviathanstudio.craftstudio.CraftStudioApi; -import com.leviathanstudio.craftstudio.client.animation.ClientAnimationHandler; -import com.leviathanstudio.craftstudio.common.animation.IAnimated; -import com.leviathanstudio.craftstudio.common.animation.InfoChannel; - -import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; - -/** - * Message to send an IAnimated event to the client. - * - * @since 0.3.0 - * - * @author Timmypote - */ -public class ClientIAnimatedEventMessage extends IAnimatedEventMessage -{ - /** Constructor */ - public ClientIAnimatedEventMessage() {} - - /** Constructor */ - public ClientIAnimatedEventMessage(EnumIAnimatedEvent event, IAnimated animated, short animId) { - super(event, animated, animId); - } - - /** Constructor */ - public ClientIAnimatedEventMessage(EnumIAnimatedEvent event, IAnimated animated, short animId, float keyframeInfo) { - super(event, animated, animId, keyframeInfo); - } - - /** Constructor */ - public ClientIAnimatedEventMessage(EnumIAnimatedEvent event, IAnimated animated, short animId, float keyframeInfo, short optAnimId) { - super(event, animated, animId, keyframeInfo, optAnimId); - } - - /** Constructor */ - public ClientIAnimatedEventMessage(IAnimatedEventMessage eventObj) { - super(eventObj); - } - - /** - * Handler for IAnimated event messages send to the client. - * - * @since 0.3.0 - * - * @author Timmypote - */ - public static class ClientIAnimatedEventHandler extends IAnimatedEventHandler - implements IMessageHandler - { - @Override - public ServerIAnimatedEventMessage onMessage(ClientIAnimatedEventMessage message, MessageContext ctx) { - Minecraft.getMinecraft().addScheduledTask(() -> { - if (super.onMessage(message, ctx)) { - boolean succes = message.animated.getAnimationHandler().onClientIAnimatedEvent(message); - if (succes && message.animated.getAnimationHandler() instanceof ClientAnimationHandler - && (message.event == EnumIAnimatedEvent.START_ANIM.getId() || message.event == EnumIAnimatedEvent.STOP_START_ANIM.getId())) { - ClientAnimationHandler hand = (ClientAnimationHandler) message.animated.getAnimationHandler(); - String animName = hand.getAnimNameFromId(message.animId); - InfoChannel infoC = (InfoChannel) hand.getAnimChannels().get(animName); - CraftStudioApi.NETWORK.sendToServer(new ServerIAnimatedEventMessage(EnumIAnimatedEvent.ANSWER_START_ANIM, message.animated, message.animId, infoC.totalFrames)); - } - } - }); - - return null; - } - - @Override - public Entity getEntityByUUID(MessageContext ctx, long most, long least) { - UUID uuid = new UUID(most, least); - for (Entity e : Minecraft.getMinecraft().world.loadedEntityList) - if (e.getPersistentID().equals(uuid)) - return e; - return null; - } - - @Override - public TileEntity getTileEntityByPos(MessageContext ctx, int x, int y, int z) { - BlockPos pos = new BlockPos(x, y, z); - return Minecraft.getMinecraft().world.getTileEntity(pos); - } - } -} diff --git a/src/main/java/com/leviathanstudio/craftstudio/common/network/IAnimatedEventMessage.java b/src/main/java/com/leviathanstudio/craftstudio/common/network/IAnimatedEventMessage.java deleted file mode 100644 index d2cf245..0000000 --- a/src/main/java/com/leviathanstudio/craftstudio/common/network/IAnimatedEventMessage.java +++ /dev/null @@ -1,203 +0,0 @@ -package com.leviathanstudio.craftstudio.common.network; - -import java.util.UUID; - -import com.leviathanstudio.craftstudio.CraftStudioApi; -import com.leviathanstudio.craftstudio.common.animation.IAnimated; - -import io.netty.buffer.ByteBuf; -import net.minecraft.entity.Entity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fml.common.network.simpleimpl.IMessage; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; - -/** - * Base class for - * {@link com.leviathanstudio.craftstudio.common.animation.IAnimated IAnimated} - * event messages. - * - * @since 0.3.0 - * - * @author Timmypote - */ -public class IAnimatedEventMessage implements IMessage -{ - /** The id of the event. See for more info {@link EnumIAnimatedEvent}. */ - public short event; - /** The id of the primary animation. */ - public short animId; - /** The id of the secondary animation, used for stopStart message. */ - public short optAnimId = -1; - /** A float used to transmit keyframe related informations. */ - public float keyframeInfo = -1; - /** The object that is animated */ - public IAnimated animated; - /** Variable that transmit part of the UUID of an Entity. */ - public long most, least; - /** Variable that transmit the position of a TileEntity. */ - public int x, y, z; - /** True, if on message receiving the animated object is an entity. */ - public boolean hasEntity; - - /** Simple empty constructor for packets system. */ - public IAnimatedEventMessage() {} - - /** Constructor */ - public IAnimatedEventMessage(EnumIAnimatedEvent event, IAnimated animated, short animId) { - if (event != null) - this.event = event.getId(); - this.animated = animated; - this.animId = animId; - } - - /** Constructor */ - public IAnimatedEventMessage(EnumIAnimatedEvent event, IAnimated animated, short animId, float keyframeInfo) { - this(event, animated, animId); - this.keyframeInfo = keyframeInfo; - } - - /** Constructor */ - public IAnimatedEventMessage(EnumIAnimatedEvent event, IAnimated animated, short animId, float keyframeInfo, short optAnimId) { - this(event, animated, animId, keyframeInfo); - this.optAnimId = optAnimId; - } - - /** Constructor */ - public IAnimatedEventMessage(IAnimatedEventMessage eventObj) { - this(null, eventObj.animated, eventObj.animId, eventObj.keyframeInfo, eventObj.optAnimId); - this.event = eventObj.event; - } - - @Override - public void fromBytes(ByteBuf buf) { - short actualEvent = buf.readShort(); - if (actualEvent < 0 || actualEvent >= 2 * EnumIAnimatedEvent.ID_COUNT) { - this.event = -1; - CraftStudioApi.getLogger().error("Networking error : invalid packet."); - return; - } - else if (actualEvent < EnumIAnimatedEvent.ID_COUNT) { - this.most = buf.readLong(); - this.least = buf.readLong(); - this.event = actualEvent; - this.hasEntity = true; - } - else { - this.x = buf.readInt(); - this.y = buf.readInt(); - this.z = buf.readInt(); - this.event = (short) (actualEvent - EnumIAnimatedEvent.ID_COUNT); - this.hasEntity = false; - } - this.animId = buf.readShort(); - if (this.event != 2) - this.keyframeInfo = buf.readFloat(); - if (this.event > 2) - this.optAnimId = buf.readShort(); - } - - @Override - public void toBytes(ByteBuf buf) { - if (this.event < 0 || this.event >= EnumIAnimatedEvent.ID_COUNT) { - buf.writeShort(-1); - CraftStudioApi.getLogger().error("Unsuported event id " + this.event + " for network message."); - return; - } - if (this.animated instanceof Entity) { - Entity e = (Entity) this.animated; - buf.writeShort(this.event); - UUID uuid = e.getUniqueID(); - buf.writeLong(uuid.getMostSignificantBits()); - buf.writeLong(uuid.getLeastSignificantBits()); - } - else if (this.animated instanceof TileEntity) { - TileEntity te = (TileEntity) this.animated; - buf.writeShort(this.event + EnumIAnimatedEvent.ID_COUNT); - BlockPos pos = te.getPos(); - buf.writeInt(pos.getX()); - buf.writeInt(pos.getY()); - buf.writeInt(pos.getZ()); - } - else { - buf.writeShort(-1); - CraftStudioApi.getLogger().error("Unsuported class " + this.animated.getClass().getSimpleName() + " for network message."); - CraftStudioApi.getLogger().error("You are trying to animate an other class than Entity or TileEntity."); - return; - } - buf.writeShort(this.animId); - if (this.event != EnumIAnimatedEvent.STOP_ANIM.getId()) - buf.writeFloat(this.keyframeInfo); - if (this.event == EnumIAnimatedEvent.STOP_START_ANIM.getId()) - buf.writeShort(this.optAnimId); - } - - /** - * Base class for the messages handler. - * - * @since 0.3.0 - * - * @author Timmypote - */ - public static abstract class IAnimatedEventHandler - { - - /** - * Extract the Entity or TileEntity when a message is received. - * - * @param message - * The message received. - * @param ctx - * The context of the message. - * @return True, if the Entity/TileEntity was successfully extracted. - * False, otherwise. - */ - public boolean onMessage(IAnimatedEventMessage message, MessageContext ctx) { - if (message.hasEntity) { - Entity e = this.getEntityByUUID(ctx, message.most, message.least); - if (!(e instanceof IAnimated)) { - CraftStudioApi.getLogger().debug("Networking error : invalid entity."); - return false; - } - message.animated = (IAnimated) e; - } - else { - TileEntity te = this.getTileEntityByPos(ctx, message.x, message.y, message.z); - if (!(te instanceof IAnimated)) { - CraftStudioApi.getLogger().debug("Networking error : invalid tile entity."); - return false; - } - message.animated = (IAnimated) te; - } - return true; - } - - /** - * Get an entity by its UUID. - * - * @param ctx - * The context of the message received. - * @param most - * The most significants bits of the UUID. - * @param least - * The least significants bits of the UUID. - * @return The Entity, null if it couldn't be found. - */ - public abstract Entity getEntityByUUID(MessageContext ctx, long most, long least); - - /** - * Get a TileEntity by its position. - * - * @param ctx - * The context of the message received. - * @param x - * The position on the x axis. - * @param y - * The position on the y axis. - * @param z - * The position on the z axis. - * @return The TileEntity, null if it couldn't be found. - */ - public abstract TileEntity getTileEntityByPos(MessageContext ctx, int x, int y, int z); - } -} diff --git a/src/main/java/com/leviathanstudio/craftstudio/common/network/ServerIAnimatedEventMessage.java b/src/main/java/com/leviathanstudio/craftstudio/common/network/ServerIAnimatedEventMessage.java deleted file mode 100644 index aae825c..0000000 --- a/src/main/java/com/leviathanstudio/craftstudio/common/network/ServerIAnimatedEventMessage.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.leviathanstudio.craftstudio.common.network; - -import java.util.UUID; - -import com.leviathanstudio.craftstudio.CraftStudioApi; -import com.leviathanstudio.craftstudio.common.animation.AnimationHandler; -import com.leviathanstudio.craftstudio.common.animation.IAnimated; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; - -/** - * Message to send an IAnimated event to the server. - * - * @since 0.3.0 - * - * @author Timmypote - */ -public class ServerIAnimatedEventMessage extends IAnimatedEventMessage -{ - /** Constructor */ - public ServerIAnimatedEventMessage() {} - - /** Constructor */ - public ServerIAnimatedEventMessage(EnumIAnimatedEvent event, IAnimated animated, short animId) { - super(event, animated, animId); - } - - /** Constructor */ - public ServerIAnimatedEventMessage(EnumIAnimatedEvent event, IAnimated animated, short animId, float keyframeInfo) { - super(event, animated, animId, keyframeInfo); - } - - /** Constructor */ - public ServerIAnimatedEventMessage(EnumIAnimatedEvent event, IAnimated animated, short animId, float keyframeInfo, short optAnimId) { - super(event, animated, animId, keyframeInfo, optAnimId); - } - - /** Constructor */ - public ServerIAnimatedEventMessage(IAnimatedEventMessage eventObj) { - super(eventObj); - } - - /** - * Handler for IAnimated event messages send to the server. - * - * @since 0.3.0 - * - * @author Timmypote - */ - public static class ServerIAnimatedEventHandler extends IAnimatedEventHandler - implements IMessageHandler - { - @Override - public ClientIAnimatedEventMessage onMessage(ServerIAnimatedEventMessage message, MessageContext ctx) { - FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(() -> { - if (super.onMessage(message, ctx)) { - EntityPlayerMP player = ctx.getServerHandler().player; - message.animated.getAnimationHandler(); - boolean succes = AnimationHandler.onServerIAnimatedEvent(message); - if (succes && message.event != EnumIAnimatedEvent.ANSWER_START_ANIM.getId()) - CraftStudioApi.NETWORK.sendTo(new ClientIAnimatedEventMessage(message), player); - } - }); - - return null; - } - - @Override - public Entity getEntityByUUID(MessageContext ctx, long most, long least) { - UUID uuid = new UUID(most, least); - for (Entity e : ctx.getServerHandler().player.world.loadedEntityList) - if (e.getPersistentID().equals(uuid)) - return e; - return null; - } - - @Override - public TileEntity getTileEntityByPos(MessageContext ctx, int x, int y, int z) { - BlockPos pos = new BlockPos(x, y, z); - return ctx.getServerHandler().player.world.getTileEntity(pos); - } - } -} diff --git a/src/main/java/com/leviathanstudio/craftstudio/proxy/CSClientProxy.java b/src/main/java/com/leviathanstudio/craftstudio/proxy/CSClientProxy.java index 4666050..bfeb168 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/proxy/CSClientProxy.java +++ b/src/main/java/com/leviathanstudio/craftstudio/proxy/CSClientProxy.java @@ -1,34 +1,23 @@ package com.leviathanstudio.craftstudio.proxy; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Set; - -import com.leviathanstudio.craftstudio.CraftStudioApi; import com.leviathanstudio.craftstudio.client.animation.ClientAnimationHandler; -import com.leviathanstudio.craftstudio.client.registry.CSRegistryHelper; -import com.leviathanstudio.craftstudio.client.registry.RegistryHandler; import com.leviathanstudio.craftstudio.common.animation.AnimationHandler; import com.leviathanstudio.craftstudio.common.animation.IAnimated; - -import net.minecraftforge.fml.common.discovery.ASMDataTable; -import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; /** * Client proxy of the CraftStudioApi - * - * @since 0.3.0 - * + * * @author Timmypote * @author ZeAmateis + * @since 0.3.0 */ -public class CSClientProxy extends CSCommonProxy -{ +public class CSClientProxy extends CSCommonProxy { + + @Override - public void preInit(FMLPreInitializationEvent e) { - super.preInit(e); - this.loadCraftStudioLoaders(e); + public void clientSetup(FMLClientSetupEvent e) { + super.clientSetup(e); } @Override @@ -36,33 +25,4 @@ public AnimationHandler getNewAnimationHandler(Class return new ClientAnimationHandler<>(); } - private void loadCraftStudioLoaders(FMLPreInitializationEvent e) { - String methodName, className; - Method method; - - RegistryHandler.init(); - - ASMDataTable dataTable = e.getAsmData(); - Set datas = dataTable.getAll("com.leviathanstudio.craftstudio.client.registry.CraftStudioLoader"); - for (ASMData data : datas) { - className = data.getClassName(); - methodName = data.getObjectName().substring(0, data.getObjectName().indexOf("(")); - try { - method = Class.forName(className).getMethod(methodName); - method.invoke(null); - } catch (NoSuchMethodException | SecurityException | ClassNotFoundException e1) { - e1.printStackTrace(); - CraftStudioApi.getLogger().error("Error loading @CraftStudioLoader in class " + className + " for method " + methodName + "()."); - CraftStudioApi.getLogger().error("Does that method has arguments ? Because it should have none."); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NullPointerException e1) { - e1.printStackTrace(); - CraftStudioApi.getLogger().error("Error loading craftstudio assets in class " + className + " for method " + methodName + "()."); - CraftStudioApi.getLogger().error("Is that method 'static' ? Because it should."); - } - } - - CSRegistryHelper.loadModels(); - CSRegistryHelper.loadAnims(); - } - } diff --git a/src/main/java/com/leviathanstudio/craftstudio/proxy/CSCommonProxy.java b/src/main/java/com/leviathanstudio/craftstudio/proxy/CSCommonProxy.java index e66b6b8..da1175a 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/proxy/CSCommonProxy.java +++ b/src/main/java/com/leviathanstudio/craftstudio/proxy/CSCommonProxy.java @@ -1,29 +1,31 @@ package com.leviathanstudio.craftstudio.proxy; -import com.leviathanstudio.craftstudio.CraftStudioApi; import com.leviathanstudio.craftstudio.common.animation.AnimationHandler; import com.leviathanstudio.craftstudio.common.animation.IAnimated; -import com.leviathanstudio.craftstudio.common.network.ClientIAnimatedEventMessage; -import com.leviathanstudio.craftstudio.common.network.ClientIAnimatedEventMessage.ClientIAnimatedEventHandler; -import com.leviathanstudio.craftstudio.common.network.ServerIAnimatedEventMessage; -import com.leviathanstudio.craftstudio.common.network.ServerIAnimatedEventMessage.ServerIAnimatedEventHandler; +import com.leviathanstudio.craftstudio.common.network.AnimatedEventMessage; +import com.leviathanstudio.craftstudio.common.network.AnimatedEventMessageUtil; +import com.leviathanstudio.craftstudio.common.network.CSNetworkHelper; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; /** * Common base for the proxies of the CraftStudioApi - * - * @since 0.3.0 - * + * * @author Timmypote * @author ZeAmateis + * @since 0.3.0 */ -public abstract class CSCommonProxy -{ - public void preInit(FMLPreInitializationEvent e) { - CraftStudioApi.NETWORK.registerMessage(ClientIAnimatedEventHandler.class, ClientIAnimatedEventMessage.class, 0, Side.CLIENT); - CraftStudioApi.NETWORK.registerMessage(ServerIAnimatedEventHandler.class, ServerIAnimatedEventMessage.class, 1, Side.SERVER); +public abstract class CSCommonProxy { + + public void clientSetup(FMLClientSetupEvent event) { + } + + //TODO Register packets + public void commonSetup(FMLCommonSetupEvent event) { + CSNetworkHelper.CHANNEL.registerMessage(1, AnimatedEventMessage.class, AnimatedEventMessageUtil.ENCODER, AnimatedEventMessageUtil.DECODER, AnimatedEventMessageUtil.HANDLER); + //CSNetworkHelper.CHANNEL.registerMessage(ClientIAnimatedEventHandler.class, ClientIAnimatedEventMessage.class, 0, Side.CLIENT); + //CraftStudioApi.NETWORK.registerMessage(ServerIAnimatedEventHandler.class, ServerIAnimatedEventMessage.class, 1, Side.SERVER); } public abstract AnimationHandler getNewAnimationHandler(Class animatedClass); diff --git a/src/main/java/com/leviathanstudio/craftstudio/proxy/CSServerProxy.java b/src/main/java/com/leviathanstudio/craftstudio/proxy/CSServerProxy.java index e8a1e4b..707cfb4 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/proxy/CSServerProxy.java +++ b/src/main/java/com/leviathanstudio/craftstudio/proxy/CSServerProxy.java @@ -4,22 +4,14 @@ import com.leviathanstudio.craftstudio.common.animation.IAnimated; import com.leviathanstudio.craftstudio.server.animation.ServerAnimationHandler; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - /** * Server proxy of the CraftStudioApi - * - * @since 0.3.0 - * + * * @author Timmypote * @author ZeAmateis + * @since 0.3.0 */ -public class CSServerProxy extends CSCommonProxy -{ - @Override - public void preInit(FMLPreInitializationEvent e) { - super.preInit(e); - } +public class CSServerProxy extends CSCommonProxy { @Override public AnimationHandler getNewAnimationHandler(Class animatedClass) { diff --git a/src/main/java/com/leviathanstudio/craftstudio/server/animation/ServerAnimationHandler.java b/src/main/java/com/leviathanstudio/craftstudio/server/animation/ServerAnimationHandler.java index 3eb31b1..45a812a 100644 --- a/src/main/java/com/leviathanstudio/craftstudio/server/animation/ServerAnimationHandler.java +++ b/src/main/java/com/leviathanstudio/craftstudio/server/animation/ServerAnimationHandler.java @@ -1,43 +1,44 @@ package com.leviathanstudio.craftstudio.server.animation; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.WeakHashMap; - import com.leviathanstudio.craftstudio.common.animation.AnimationHandler; import com.leviathanstudio.craftstudio.common.animation.Channel; import com.leviathanstudio.craftstudio.common.animation.CustomChannel; import com.leviathanstudio.craftstudio.common.animation.IAnimated; - import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.WeakHashMap; /** * An object that hold the informations about its animated objects and all their * animations. It also start/stop/update the animations. This is the server side * AnimationHandler. - * - * @since 0.3.0 - * - * @author Timmypote * - * @param - * The class of the animated object. + * @param The class of the animated object. + * @author Timmypote + * @since 0.3.0 */ -@SideOnly(Side.SERVER) -public class ServerAnimationHandler extends AnimationHandler -{ - /** Map with all the animations. */ - private Map animChannels = new HashMap<>(); - - /** Map with the informations about animations. */ - private Map> currentAnimInfo = new WeakHashMap<>(); - - /** Map with the initialized animations and their starting frames. */ - private Map> startingAnimations = new WeakHashMap<>(); +@OnlyIn(Dist.DEDICATED_SERVER) +public class ServerAnimationHandler extends AnimationHandler { + /** + * Map with all the animations. + */ + private Map animChannels = new HashMap<>(); + + /** + * Map with the informations about animations. + */ + private Map> currentAnimInfo = new WeakHashMap<>(); + + /** + * Map with the initialized animations and their starting frames. + */ + private Map> startingAnimations = new WeakHashMap<>(); @Override public void addAnim(String modid, String animNameIn, String modelNameIn, boolean looped) { @@ -121,7 +122,7 @@ public void animationsUpdate(T animatedElement) { if (animInfoMap == null) return; - for (Iterator> it = animInfoMap.entrySet().iterator(); it.hasNext();) { + for (Iterator> it = animInfoMap.entrySet().iterator(); it.hasNext(); ) { Entry animInfo = it.next(); boolean animStatus = this.canUpdateAnimation(this.animChannels.get(animInfo.getKey()), animatedElement); if (!animStatus) diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..0896a68 --- /dev/null +++ b/src/main/resources/META-INF/mods.toml @@ -0,0 +1,27 @@ + +modLoader="javafml" #mandatory +loaderVersion="[28,)" #mandatory (26 is current forge version) +issueTrackerURL="https://github.com/Leviathan-Studio/CraftStudioAPI" #optional +[[mods]] #mandatory +modId="craftstudioapi" #mandatory +version="${file.jarVersion}" #mandatory +displayName="CraftStudio API" #mandatory +updateJSONURL="https://leviathan-studio.com/craftstudioapi/update.json" #optional +#displayURL="http://example.com/" #optional +#logoFile="examplemod.png" #optional +credits="See https://github.com/Leviathan-Studio/CraftStudioAPI/blob/master/CREDITS.md" #optional +authors="ZeAmateis, Timmypote, Elisee, IncubeSupreme, Phenix246" #optional +description='''A CraftStudio API for models/animations support in Minecraft''' + +[[dependencies.craftstudioapi]] #optional + modId="forge" #mandatory + mandatory=true #mandatory + versionRange="[28,)" #mandatory + ordering="NONE" + side="BOTH" +[[dependencies.craftstudioapi]] + modId="minecraft" + mandatory=true + versionRange="[1.14.4]" + ordering="NONE" + side="BOTH" diff --git a/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/offset.csjsmodelanim b/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/offset.csjsmodelanim new file mode 100644 index 0000000..315fac1 --- /dev/null +++ b/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/offset.csjsmodelanim @@ -0,0 +1,28 @@ +{ + "title": "Offset", + "duration": 60, + "holdLastKeyframe": false, + "nodeAnimations": { + "Block": { + "position": { + }, + "offsetFromPivot": { + "0": [ 0, 0, 0 ], + "4": [ -15, 0, 0 ], + "16": [ -30, 0, 0 ], + "30": [ -50, 0, 0 ], + "44": [ -30, 0, 0 ], + "56": [ -15, 0, 0 ] + }, + "size": { + }, + "rotation": { + "0": [ 0, 0, 0 ], + "20": [ 0, 120, 0 ], + "40": [ -360, -120, 0 ] + }, + "stretch": { + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/position.csjsmodelanim b/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/position.csjsmodelanim new file mode 100644 index 0000000..1585c6e --- /dev/null +++ b/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/position.csjsmodelanim @@ -0,0 +1,24 @@ +{ + "title": "Position", + "duration": 60, + "holdLastKeyframe": false, + "nodeAnimations": { + "Block": { + "position": { + "0": [ 0, 0, 0 ], + "10": [ 0, 15, 0 ], + "30": [ 0, 15, 15 ], + "50": [ 0, 0, 15 ], + "60": [ 0, 0, 0 ] + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + }, + "stretch": { + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/rotation.csjsmodelanim b/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/rotation.csjsmodelanim new file mode 100644 index 0000000..617f512 --- /dev/null +++ b/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/rotation.csjsmodelanim @@ -0,0 +1,26 @@ +{ + "title": "Rotation", + "duration": 60, + "holdLastKeyframe": false, + "nodeAnimations": { + "Block": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 0, 0, 0 ], + "10": [ 90, 0, 0 ], + "20": [ 90, 90, 0 ], + "30": [ 45, 89.99999, 0 ], + "40": [ 45, 45, 6.74449E-07 ], + "50": [ 0, 45, 0 ], + "60": [ 0, 0, 0 ] + }, + "stretch": { + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/size.csjsmodelanim b/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/size.csjsmodelanim new file mode 100644 index 0000000..308846f --- /dev/null +++ b/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/size.csjsmodelanim @@ -0,0 +1,21 @@ +{ + "title": "Size", + "duration": 60, + "holdLastKeyframe": false, + "nodeAnimations": { + "Block": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + "0": [ 0, 0, 0 ], + "30": [ 512, 512, 512 ] + }, + "rotation": { + }, + "stretch": { + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/streching.csjsmodelanim b/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/streching.csjsmodelanim new file mode 100644 index 0000000..74c717c --- /dev/null +++ b/src/main/resources/assets/craftstudioapi/craftstudio/animations/blocks/streching.csjsmodelanim @@ -0,0 +1,22 @@ +{ + "title": "Streching", + "duration": 60, + "holdLastKeyframe": false, + "nodeAnimations": { + "Block": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + }, + "stretch": { + "0": [ 0, 1, -0.5 ], + "20": [ 1, -0.5, 0 ], + "40": [ -0.5, 0, 1 ] + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/craftstudioapi/craftstudio/animations/entity/fly.csjsmodelanim b/src/main/resources/assets/craftstudioapi/craftstudio/animations/entity/fly.csjsmodelanim new file mode 100644 index 0000000..1b782b3 --- /dev/null +++ b/src/main/resources/assets/craftstudioapi/craftstudio/animations/entity/fly.csjsmodelanim @@ -0,0 +1,250 @@ +{ + "title": "Fly", + "duration": 120, + "holdLastKeyframe": false, + "nodeAnimations": { + "Aile13": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 3.291526E-07, -3.761236E-07, 30 ], + "60": [ -4.808296E-07, -1.222556E-06, -30 ] + }, + "stretch": { + } + }, + "Aile2": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 7.642279E-07, 7.395585E-07, -30 ], + "60": [ -5.275069E-08, 1.601725E-06, 30 ] + }, + "stretch": { + } + }, + "Aile 1_23": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -40.33549, 13.12927, -39.47359 ], + "30": [ -0.003967197, -0.0002578979, -0.001361898 ], + "60": [ 19.73745, 3.63261, 10.48193 ], + "90": [ -25.29968, 8.267124, -19.52541 ] + }, + "stretch": { + } + }, + "Aile 2.2": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -40.33549, -13.12927, 39.47359 ], + "30": [ -0.003967197, 0.0002578979, 0.001361898 ], + "60": [ 19.73745, -3.63261, -10.48193 ], + "90": [ -25.29968, -8.267124, 19.52541 ] + }, + "stretch": { + } + }, + "AileBranche116": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 45.00003, -13.72258, -30.00002 ], + "30": [ 1.716233E-05, -0.002573994, 2.260436E-07 ], + "60": [ 7.00002, -0.7225692, -3.000001 ] + }, + "stretch": { + } + }, + "AileBranche1.25616": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 45.00003, 13.72258, 30.00002 ], + "30": [ 1.716233E-05, 0.002573994, -2.260436E-07 ], + "60": [ 7.00002, 0.7225692, 3.000001 ] + }, + "stretch": { + } + }, + "Queue2": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -2.910305, 13.26382, 0.5369502 ], + "60": [ -2.905939, -13.26874, -0.0001595522 ] + }, + "stretch": { + } + }, + "Queue3": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -3.848111, 3.938147, 0.4985428 ], + "60": [ -3.848873, -3.091373, 0.0005935003 ] + }, + "stretch": { + } + }, + "Queue4": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 2.624762, 4.204419, 0.1928858 ], + "60": [ 0.001829665, -4.184887, -0.0001338744 ] + }, + "stretch": { + } + }, + "Queue5": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 0.0004375024, -5.629999, -0.003000514 ], + "60": [ 0.0005822151, 5.632043, 5.741543E-05 ] + }, + "stretch": { + } + }, + "Queue6": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -0.002708734, 8.376065, 0.5173528 ], + "60": [ -0.003822795, -8.37129, 0.0005625481 ] + }, + "stretch": { + } + }, + "Queue7": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 0.002702838, 10.52605, 1.435099 ], + "60": [ -0.001400483, -10.52523, 0.0002601927 ] + }, + "stretch": { + } + }, + "Coup128": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -5.565439, 0, 0 ], + "60": [ 0.003037606, 0, 0 ] + }, + "stretch": { + } + }, + "Coup229": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -6.341984, 0, 0 ], + "60": [ 0.002954404, 0, 0 ] + }, + "stretch": { + } + }, + "Coup330": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 3.725061, 0, 0 ], + "60": [ 0.003234291, 0, 0 ] + }, + "stretch": { + } + }, + "Tete31": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 4.102807, 0, 0 ], + "60": [ -6.402161E-07, 0, 0 ] + }, + "stretch": { + } + }, + "Corp1": { + "position": { + "2": [ 0, 13, 0 ] + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + }, + "stretch": { + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/craftstudioapi/craftstudio/animations/entity/idle.csjsmodelanim b/src/main/resources/assets/craftstudioapi/craftstudio/animations/entity/idle.csjsmodelanim new file mode 100644 index 0000000..4de653c --- /dev/null +++ b/src/main/resources/assets/craftstudioapi/craftstudio/animations/entity/idle.csjsmodelanim @@ -0,0 +1,542 @@ +{ + "title": "Idle", + "duration": 60, + "holdLastKeyframe": false, + "nodeAnimations": { + "Corp": { + "position": { + "0": [ 0, -7, 0 ] + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -6.95448, 0, 0 ] + }, + "stretch": { + } + }, + "Jambe G 2": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 88.4198, 0, 0 ] + }, + "stretch": { + } + }, + "Patte G": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -31.88758, 0, 0 ] + }, + "stretch": { + } + }, + "Doigt 31": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -62.55437, 0, 0 ] + }, + "stretch": { + } + }, + "Doigt 11": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -62.5258, 0, 0 ] + }, + "stretch": { + } + }, + "Patte GDansTonCulMonGars": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -76.10495, 0, 0 ] + }, + "stretch": { + } + }, + "Doigt 21": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -62.56549, 0, 0 ] + }, + "stretch": { + } + }, + "Jambe G 24": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 86.37075, 0, 0 ] + }, + "stretch": { + } + }, + "Patte GToiAussiEncule": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -75.88501, 0, 0 ] + }, + "stretch": { + } + }, + "Doigt 115": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -62.39467, 0, 0 ] + }, + "stretch": { + } + }, + "Doigt 218": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -62.56549, 0, 0 ] + }, + "stretch": { + } + }, + "Doigt 315": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 297.4959, 0, 0 ] + }, + "stretch": { + } + }, + "Corp1": { + "position": { + "0": [ 0, -2, 0 ] + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + }, + "stretch": { + } + }, + "Doigt 124": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -13.69234, -0.00093032, 0.0009806722 ] + }, + "stretch": { + } + }, + "Doigt 229": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -13.8, 3.426467E-08, -2.645391E-08 ] + }, + "stretch": { + } + }, + "Doigt 326": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -13.85166, -9.335115E-08, 1.032376E-06 ] + }, + "stretch": { + } + }, + "Doigt 325624": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -13.85166, 9.335115E-08, -1.032376E-06 ] + }, + "stretch": { + } + }, + "Doigt 22": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -13.8, -3.426467E-08, 2.645391E-08 ] + }, + "stretch": { + } + }, + "Doigt 12": { + "position": { + "0": [ 0, -0.0008046627, 1.587085E-06 ] + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -13.68662, -0.2860991, 0.03135122 ] + }, + "stretch": { + } + }, + "Queue1": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -7.605498, 0, 0 ] + }, + "stretch": { + } + }, + "Queue2": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -9.66692, 0, 0 ] + }, + "stretch": { + } + }, + "Queue3": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -3.591036, 0.004510937, 0.0005610722 ], + "30": [ -3.561704, 7.298983, -0.4549873 ] + }, + "stretch": { + } + }, + "Queue4": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -8.872405, -11.33216, 1.7704 ], + "30": [ 8.492069, 9.083971, -1.488779 ] + }, + "stretch": { + } + }, + "Queue5": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -11.06903, -14.00055, 2.740704 ], + "30": [ -11.15722, 12.02902, -2.35928 ] + }, + "stretch": { + } + }, + "Queue6": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 11.04499, -23.07582, -4.666147 ], + "30": [ 11.46751, 16.99657, 3.481989 ] + }, + "stretch": { + } + }, + "Queue7": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -7.741637, -23.45368, 3.344707 ], + "30": [ -7.882482, 20.82449, -2.985341 ] + }, + "stretch": { + } + }, + "Aile2": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 29.65776, -15.23403, 14.90397 ], + "30": [ 36.75339, -11.90225, 8.362887 ] + }, + "stretch": { + } + }, + "Aile13": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 29.67346, 14.85071, -14.08584 ], + "4": [ 30.83915, 14.32192, -13.13631 ], + "30": [ 36.75338, 11.90225, -8.362885 ] + }, + "stretch": { + } + }, + "Aile 2.2": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -0.004115467, 30.0765, -0.0008094828 ] + }, + "stretch": { + } + }, + "AileBranche2.2": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 7.013703E-06, -36.69177, -1.641257E-05 ] + }, + "stretch": { + } + }, + "AileBranche1.25616": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 1.413958E-05, -33.77565, -9.729792E-06 ] + }, + "stretch": { + } + }, + "AileBranche24": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 1.042858E-05, 24.07793, 1.448479E-05 ] + }, + "stretch": { + } + }, + "AileBranche116": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 1.562372E-05, 23.70007, 7.106058E-06 ] + }, + "stretch": { + } + }, + "Coup128": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 14.78527, 0, 0 ], + "30": [ 22.67531, 0, 0 ] + }, + "stretch": { + } + }, + "Coup229": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -2.317662, 0, 0 ], + "30": [ -8.312517, 0, 0 ] + }, + "stretch": { + } + }, + "Coup330": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -19.79341, 0, 0 ], + "30": [ -25.85116, 0, 0 ] + }, + "stretch": { + } + }, + "Tete31": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 15.24, 0, 0 ], + "30": [ 15.24027, 0, 0 ] + }, + "stretch": { + } + }, + "Bouche": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ -0.5519297, 0, 0 ], + "30": [ -6.551931, 0, 0 ] + }, + "stretch": { + } + }, + "Jambe G 1": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 0.00483182, 0.000353878, -0.002519864 ] + }, + "stretch": { + } + }, + "Jambe D 1": { + "position": { + }, + "offsetFromPivot": { + }, + "size": { + }, + "rotation": { + "0": [ 0.00483182, -0.000353878, 0.002519864 ] + }, + "stretch": { + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/craftstudioapi/craftstudio/models/blocks/craftstudio_api_test.csjsmodel b/src/main/resources/assets/craftstudioapi/craftstudio/models/blocks/craftstudio_api_test.csjsmodel new file mode 100644 index 0000000..956351e --- /dev/null +++ b/src/main/resources/assets/craftstudioapi/craftstudio/models/blocks/craftstudio_api_test.csjsmodel @@ -0,0 +1,14 @@ +{ + "title": "CraftStudioAPITest", + "tree": [ + { + "name": "Block", + "position": [ 0, 8, 0 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 16, 16, 16 ], + "rotation": [ 0, 0, 0 ], + "texOffset": [ 0, 0 ], + "children": [] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/craftstudioapi/craftstudio/models/blocks/craftstudio_api_test2.csjsmodel b/src/main/resources/assets/craftstudioapi/craftstudio/models/blocks/craftstudio_api_test2.csjsmodel new file mode 100644 index 0000000..dbb1b8a --- /dev/null +++ b/src/main/resources/assets/craftstudioapi/craftstudio/models/blocks/craftstudio_api_test2.csjsmodel @@ -0,0 +1,24 @@ +{ + "title": "CraftStudioAPITest", + "tree": [ + { + "name": "Block", + "position": [ 0, 8, 0 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 16, 16, 16 ], + "rotation": [ 0, 0, 0 ], + "vertexCoords": [ + [ -8, 16, -8 ], + [ 8, 16, -8 ], + [ 8, -16, -8 ], + [ -8, -16, -8 ], + [ 8, 16, 8 ], + [ -8, 16, 8 ], + [ -8, -16, 8 ], + [ 8, -16, 8 ] + ], + "texOffset": [ 0, 0 ], + "children": [] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/craftstudioapi/craftstudio/models/entity/dragon_brun.csjsmodel b/src/main/resources/assets/craftstudioapi/craftstudio/models/entity/dragon_brun.csjsmodel new file mode 100644 index 0000000..ab9b564 --- /dev/null +++ b/src/main/resources/assets/craftstudioapi/craftstudio/models/entity/dragon_brun.csjsmodel @@ -0,0 +1,1933 @@ +{ + "title": "Dragon Brun", + "tree": [ + { + "name": "Corp1", + "position": [ 0, 37, 30 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 21, 16, 16 ], + "rotation": [ 1.954482, 0, 0 ], + "texOffset": [ 0, 0 ], + "children": [ + { + "name": "Epaules2", + "position": [ 0, -5.960464E-07, -7.152557E-07 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 35, 12, 12 ], + "rotation": [ -1.82036E-07, 0, 0 ], + "texOffset": [ 0, 74 ], + "children": [] + }, + { + "name": "Aile13", + "position": [ 15, 8.469357E-08, -1.488686E-06 ], + "offsetFromPivot": [ 24, 0, 0 ], + "size": [ 50, 5, 8 ], + "rotation": [ -6.89, 22, -2.168892E-09 ], + "texOffset": [ 58, 0 ], + "children": [ + { + "name": "Aile 1_23", + "position": [ 21.31004, 0.0002365663, -0.0255119 ], + "offsetFromPivot": [ 24, 0, 0 ], + "size": [ 50, 5, 7 ], + "rotation": [ 0.2339692, -63.46978, -0.4686372 ], + "texOffset": [ 74, 13 ], + "children": [ + { + "name": "AileBranche24", + "position": [ 23.84916, 0.09999574, 2.215488 ], + "offsetFromPivot": [ 44, 0, 0 ], + "size": [ 86, 5, 3 ], + "rotation": [ -1.543068E-05, 110.841, -8.969847E-06 ], + "texOffset": [ 74, 25 ], + "children": [ + { + "name": "AileToile25", + "position": [ -34.94409, -0.1125191, -8.335443 ], + "offsetFromPivot": [ 38, 0, -16 ], + "size": [ 86, 0, 46 ], + "rotation": [ -1.080418E-05, 1.636025E-05, -9.369185E-06 ], + "texOffset": [ -46, 140 ], + "children": [] + }, + { + "name": "griffes bout ailes26", + "position": [ 39.18649, 0.2161948, -0.09094638 ], + "offsetFromPivot": [ 0, 0, 5 ], + "size": [ 3, 3, 9 ], + "rotation": [ 0.5044933, 99.31251, 91.96687 ], + "texOffset": [ 174, 0 ], + "children": [ + { + "name": "griffes bout7", + "position": [ 0.3783033, 0.1637897, 3 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 17.07758, 1.555225E-05, 9.53466E-06 ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou28", + "position": [ 0.02169422, 0.2021261, 0.5993456 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 9.424067, 5.280378E-06, -5.510787E-06 ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou39", + "position": [ 0, 0.2, 0.5 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 1, 2, 4 ], + "rotation": [ 8.012905, -5.684132E-06, 6.632725E-07 ], + "texOffset": [ 189, 0 ], + "children": [] + } + ] + } + ] + } + ] + } + ] + }, + { + "name": "AileBranche310", + "position": [ 23.84916, 0.0999957, 2.215488 ], + "offsetFromPivot": [ 44, 0, 0 ], + "size": [ 86, 5, 3 ], + "rotation": [ -5.683263E-06, 141.5232, -2.130234E-05 ], + "texOffset": [ 74, 25 ], + "children": [ + { + "name": "griffes bout ailes211", + "position": [ 39.18649, 0.2161948, -0.09094638 ], + "offsetFromPivot": [ 0, 0, 5 ], + "size": [ 3, 3, 9 ], + "rotation": [ 0.5044933, 99.31251, 91.96687 ], + "texOffset": [ 174, 0 ], + "children": [ + { + "name": "griffes bout12", + "position": [ 0.4, 0, 3 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 2.648026, 1.073253, -0.0176872 ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou213", + "position": [ 0.02169422, 0.2021261, 0.5993456 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 9.424067, 5.280378E-06, -5.510787E-06 ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou314", + "position": [ 0, 0.2, 0.5 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 1, 2, 4 ], + "rotation": [ 8.012905, -5.684132E-06, 6.632725E-07 ], + "texOffset": [ 189, 0 ], + "children": [] + } + ] + } + ] + } + ] + }, + { + "name": "AileToile 1.315", + "position": [ -46.37394, 1.574688E-06, -11.22091 ], + "offsetFromPivot": [ 55, 0, -5 ], + "size": [ 82, 0, 30 ], + "rotation": [ -5.072849E-06, 3.746575E-07, -1.22216E-05 ], + "texOffset": [ -30, 186 ], + "children": [] + } + ] + }, + { + "name": "AileBranche116", + "position": [ 23.84916, 0.1499978, 2.215489 ], + "offsetFromPivot": [ 29, 0, 0 ], + "size": [ 57, 5, 3 ], + "rotation": [ -1.716231E-05, 83.72255, -2.268148E-07 ], + "texOffset": [ 86, 25 ], + "children": [ + { + "name": "AileToilebranche 117", + "position": [ -26.12369, -0.07595771, -7.794971 ], + "offsetFromPivot": [ 36, 0, -13 ], + "size": [ 84, 0, 42 ], + "rotation": [ -1.325583E-05, 1.158159E-05, -2.358795E-06 ], + "texOffset": [ -42, 98 ], + "children": [] + }, + { + "name": "griffes bout ailes18", + "position": [ 26.23009, 0.166191, -0.02326208 ], + "offsetFromPivot": [ 0, 0, 5 ], + "size": [ 3, 3, 9 ], + "rotation": [ 1.228018, 103.6092, 91.61719 ], + "texOffset": [ 174, 0 ], + "children": [ + { + "name": "griffes bout19", + "position": [ 0.3783033, 0.1637897, 3 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 17.07758, 1.555225E-05, 9.53466E-06 ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou220", + "position": [ 0, 0.3, 0 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 12.42268, -6.004402E-06, -4.675526E-08 ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou321", + "position": [ -4.170682E-06, -1.131516E-06, 1 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 1, 2, 4 ], + "rotation": [ 8.012905, -5.684132E-06, 6.632725E-07 ], + "texOffset": [ 189, 0 ], + "children": [] + } + ] + } + ] + } + ] + } + ] + }, + { + "name": "griffes bout ailes_centre22", + "position": [ 18.87914, 0.3161923, 1.668774 ], + "offsetFromPivot": [ 0, 0, 5 ], + "size": [ 3, 3, 9 ], + "rotation": [ 1.389455, 87.70204, 88.51917 ], + "texOffset": [ 174, 0 ], + "children": [ + { + "name": "griffes bout23", + "position": [ 0.3783033, 0.1637897, 3 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 17.07758, 1.555225E-05, 9.53466E-06 ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou224", + "position": [ 0, 0.3, 0 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 12.42268, -6.004402E-06, -4.675526E-08 ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou326", + "position": [ -4.170682E-06, -1.131516E-06, 1 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 1, 2, 4 ], + "rotation": [ 8.012905, -5.684132E-06, 6.632725E-07 ], + "texOffset": [ 189, 0 ], + "children": [] + } + ] + } + ] + } + ] + } + ] + }, + { + "name": "AileToile1.127", + "position": [ -24, -3.476012E-06, 1.473967E-06 ], + "offsetFromPivot": [ 23, 0, -23 ], + "size": [ 53, 0, 42 ], + "rotation": [ -1.219527E-05, 1.112748E-05, 3.504153E-06 ], + "texOffset": [ 52, 56 ], + "children": [] + } + ] + }, + { + "name": "Coup128", + "position": [ 0, 1, 3 ], + "offsetFromPivot": [ 0, 0, 8 ], + "size": [ 15, 12, 17 ], + "rotation": [ -3.133037, 0, 0 ], + "texOffset": [ 183, 81 ], + "children": [ + { + "name": "Coup229", + "position": [ 0, 1, 4 ], + "offsetFromPivot": [ 0, 0, 11 ], + "size": [ 12, 10, 16 ], + "rotation": [ -0.3229544, 0, 0 ], + "texOffset": [ 200, 55 ], + "children": [ + { + "name": "Coup330", + "position": [ 0, 0.5093571, 5 ], + "offsetFromPivot": [ 0, 0, 7 ], + "size": [ 10, 8, 13 ], + "rotation": [ -0.6632345, 0, 0 ], + "texOffset": [ 154, 225 ], + "children": [ + { + "name": "Tete31", + "position": [ 0, -0.1389045, 4.999196 ], + "offsetFromPivot": [ 0, 0, 4 ], + "size": [ 11, 10, 9 ], + "rotation": [ 6.402159E-07, 0, 0 ], + "texOffset": [ 119, 216 ], + "children": [ + { + "name": "Museau32", + "position": [ 0, -0.09259965, 3.999468 ], + "offsetFromPivot": [ 0, 0, 4 ], + "size": [ 8, 6, 11 ], + "rotation": [ 2.977895E-07, 0, 0 ], + "texOffset": [ 218, 120 ], + "children": [ + { + "name": "Nez33", + "position": [ 0, -0.1041771, 4.999396 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 9, 6, 4 ], + "rotation": [ -3.424265E-07, 0, 0 ], + "texOffset": [ 207, 110 ], + "children": [ + { + "name": "Dent34", + "position": [ 3.5, -3.5, 1 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 3, 1 ], + "rotation": [ 2.742231, 0, 0 ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent2", + "position": [ -3.5, -3.5, 1 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 3, 1 ], + "rotation": [ 1.960055, -4.100175, -0.1404768 ], + "vertexCoords": [ + [ 0.5, 1.5, -0.5 ], + [ -0.5, 1.5, -0.5 ], + [ -0.5, -1.5, -0.5 ], + [ 0.5, -1.5, -0.5 ], + [ -0.5, 1.5, 0.5 ], + [ 0.5, 1.5, 0.5 ], + [ 0.5, -1.5, 0.5 ], + [ -0.5, -1.5, 0.5 ] + ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent3", + "position": [ -1.75, -3.3, 1 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 3, 1 ], + "rotation": [ 2.218437E-06, 7.798511E-16, -2.026353 ], + "vertexCoords": [ + [ 0.5, 1.5, -0.5 ], + [ -0.5, 1.5, -0.5 ], + [ -0.5, -1.5, -0.5 ], + [ 0.5, -1.5, -0.5 ], + [ -0.5, 1.5, 0.5 ], + [ 0.5, 1.5, 0.5 ], + [ 0.5, -1.5, 0.5 ], + [ -0.5, -1.5, 0.5 ] + ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent4", + "position": [ 1.75, -3.3, 1 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 3, 1 ], + "rotation": [ -2.960325, 0, 0 ], + "vertexCoords": [ + [ 0.5, 1.5, -0.5 ], + [ -0.5, 1.5, -0.5 ], + [ -0.5, -1.5, -0.5 ], + [ 0.5, -1.5, -0.5 ], + [ -0.5, 1.5, 0.5 ], + [ 0.5, 1.5, 0.5 ], + [ 0.5, -1.5, 0.5 ], + [ -0.5, -1.5, 0.5 ] + ], + "texOffset": [ 240, 111 ], + "children": [] + }, + { + "name": "Dent5", + "position": [ 0, -3, 1.000001 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 3, 1 ], + "rotation": [ 2.218437E-06, -8.897605E-16, 2.308754 ], + "vertexCoords": [ + [ 0.5, 1.5, -0.5 ], + [ -0.5, 1.5, -0.5 ], + [ -0.5, -1.5, -0.5 ], + [ 0.5, -1.5, -0.5 ], + [ -0.5, 1.5, 0.5 ], + [ 0.5, 1.5, 0.5 ], + [ 0.5, -1.5, 0.5 ], + [ -0.5, -1.5, 0.5 ] + ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent6", + "position": [ 3.5, -3.3, -1 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 3, 1 ], + "rotation": [ 2.218437E-06, 9.00719E-16, 1.37728 ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent7", + "position": [ -3.5, -3.3, -1 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 3, 1 ], + "rotation": [ 3.034465, -3.354562, -0.1777819 ], + "vertexCoords": [ + [ 0.5, 1.5, -0.5 ], + [ -0.5, 1.5, -0.5 ], + [ -0.5, -1.5, -0.5 ], + [ 0.5, -1.5, -0.5 ], + [ -0.5, 1.5, 0.5 ], + [ 0.5, 1.5, 0.5 ], + [ 0.5, -1.5, 0.5 ], + [ -0.5, -1.5, 0.5 ] + ], + "texOffset": [ 235, 112 ], + "children": [] + } + ] + }, + { + "name": "Dent8", + "position": [ -3, -3.104179, 2 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 3, 1 ], + "rotation": [ 2.858654E-06, 1.255225E-15, 2.301986 ], + "vertexCoords": [ + [ 0.5, 1.5, -0.5 ], + [ -0.5, 1.5, -0.5 ], + [ -0.5, -1.5, -0.5 ], + [ 0.5, -1.5, -0.5 ], + [ -0.5, 1.5, 0.5 ], + [ 0.5, 1.5, 0.5 ], + [ 0.5, -1.5, 0.5 ], + [ -0.5, -1.5, 0.5 ] + ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent9", + "position": [ 3, -3.104179, 2 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 3, 1 ], + "rotation": [ 1.596566, 0, 0 ], + "texOffset": [ 240, 111 ], + "children": [] + }, + { + "name": "Dent10", + "position": [ 3, -2.5, 0 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 3, 1 ], + "rotation": [ 2.858653E-06, 0, 0 ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent11", + "position": [ 3, -2.5, -2 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 3, 1 ], + "rotation": [ 2.858653E-06, 0, 0 ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent12", + "position": [ -3, -2.500001, -1.999999 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 3, 1 ], + "rotation": [ 2.858654E-06, -5.222579E-15, -3.430224 ], + "vertexCoords": [ + [ 0.5, 1.5, -0.5 ], + [ -0.5, 1.5, -0.5 ], + [ -0.5, -1.5, -0.5 ], + [ 0.5, -1.5, -0.5 ], + [ -0.5, 1.5, 0.5 ], + [ 0.5, 1.5, 0.5 ], + [ 0.5, -1.5, 0.5 ], + [ -0.5, -1.5, 0.5 ] + ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent13", + "position": [ -3, -2.5, -6.412849E-06 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 3, 1 ], + "rotation": [ 2.858653E-06, 3.088479E-16, -3.774049 ], + "vertexCoords": [ + [ 0.5, 1.5, -0.5 ], + [ -0.5, 1.5, -0.5 ], + [ -0.5, -1.5, -0.5 ], + [ 0.5, -1.5, -0.5 ], + [ -0.5, 1.5, 0.5 ], + [ 0.5, 1.5, 0.5 ], + [ 0.5, -1.5, 0.5 ], + [ -0.5, -1.5, 0.5 ] + ], + "texOffset": [ 235, 112 ], + "children": [] + } + ] + }, + { + "name": "Bouche", + "position": [ 0, -3, 0 ], + "offsetFromPivot": [ 0, 0, 7 ], + "size": [ 7, 2, 12 ], + "rotation": [ 23.55193, 0, 0 ], + "texOffset": [ 128, 235 ], + "children": [ + { + "name": "Dent14", + "position": [ -2.5, 0.5, -1 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 2, 1 ], + "rotation": [ 0, 0, -4.128194 ], + "vertexCoords": [ + [ 0.5, 1, -0.5 ], + [ -0.5, 1, -0.5 ], + [ -0.5, -1, -0.5 ], + [ 0.5, -1, -0.5 ], + [ -0.5, 1, 0.5 ], + [ 0.5, 1, 0.5 ], + [ 0.5, -1, 0.5 ], + [ -0.5, -1, 0.5 ] + ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent15", + "position": [ 2.5, 0.5000039, -0.9999986 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 2, 1 ], + "rotation": [ 1.627058, 0, 0 ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent16", + "position": [ 2.5, 0.7, 1 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 2, 1 ], + "rotation": [ 3.383539, 0, 0 ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent17", + "position": [ -2.5, 0.7, 1 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 2, 1 ], + "rotation": [ 4.623174E-06, -5.483579E-15, 5.149386 ], + "vertexCoords": [ + [ 0.5, 1, -0.5 ], + [ -0.5, 1, -0.5 ], + [ -0.5, -1, -0.5 ], + [ 0.5, -1, -0.5 ], + [ -0.5, 1, 0.5 ], + [ 0.5, 1, 0.5 ], + [ 0.5, -1, 0.5 ], + [ -0.5, -1, 0.5 ] + ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent18", + "position": [ -2.5, 1, 3 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 2, 1 ], + "rotation": [ 6.325756, 0, 0 ], + "vertexCoords": [ + [ 0.5, 1, -0.5 ], + [ -0.5, 1, -0.5 ], + [ -0.5, -1, -0.5 ], + [ 0.5, -1, -0.5 ], + [ -0.5, 1, 0.5 ], + [ 0.5, 1, 0.5 ], + [ 0.5, -1, 0.5 ], + [ -0.5, -1, 0.5 ] + ], + "texOffset": [ 240, 111 ], + "children": [] + }, + { + "name": "Dent19", + "position": [ 2.5, 1.000002, 3.000001 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 2, 1 ], + "rotation": [ -6.821664, 0, 0 ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent20", + "position": [ 2.5, 1.000006, 5 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 2, 1 ], + "rotation": [ 9.656855E-06, -1.583781E-15, 1.198872 ], + "texOffset": [ 240, 111 ], + "children": [] + }, + { + "name": "Dent21", + "position": [ -2.5, 1.000007, 4.999999 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 2, 1 ], + "rotation": [ -4.163713, 0, 0 ], + "vertexCoords": [ + [ 0.5, 1, -0.5 ], + [ -0.5, 1, -0.5 ], + [ -0.5, -1, -0.5 ], + [ 0.5, -1, -0.5 ], + [ -0.5, 1, 0.5 ], + [ 0.5, 1, 0.5 ], + [ 0.5, -1, 0.5 ], + [ -0.5, -1, 0.5 ] + ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent22", + "position": [ -1, 1.00001, 4.999997 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 2, 1 ], + "rotation": [ 1.301264E-05, 1.453839E-14, -2.817426 ], + "vertexCoords": [ + [ 0.5, 1, -0.5 ], + [ -0.5, 1, -0.5 ], + [ -0.5, -1, -0.5 ], + [ 0.5, -1, -0.5 ], + [ -0.5, 1, 0.5 ], + [ 0.5, 1, 0.5 ], + [ 0.5, -1, 0.5 ], + [ -0.5, -1, 0.5 ] + ], + "texOffset": [ 235, 112 ], + "children": [] + }, + { + "name": "Dent23", + "position": [ 1, 1.000014, 4.999996 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 2, 1 ], + "rotation": [ 1.297294E-05, -4.47666, -1.015675E-06 ], + "vertexCoords": [ + [ 0.5, 1, -0.5 ], + [ -0.5, 1, -0.5 ], + [ -0.5, -1, -0.5 ], + [ 0.5, -1, -0.5 ], + [ -0.5, 1, 0.5 ], + [ 0.5, 1, 0.5 ], + [ 0.5, -1, 0.5 ], + [ -0.5, -1, 0.5 ] + ], + "texOffset": [ 235, 112 ], + "children": [] + } + ] + }, + { + "name": "Crette ", + "position": [ 0, 4.478767, -2.948088 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 13, 8 ], + "rotation": [ -51.8001, 0, 0 ], + "texOffset": [ 238, 33 ], + "children": [] + }, + { + "name": "Corne G1", + "position": [ 4, 3.138902, -0.9991918 ], + "offsetFromPivot": [ 0, 0, -2 ], + "size": [ 4, 4, 10 ], + "rotation": [ 28.29965, -30.2206, -15.43754 ], + "texOffset": [ 174, 116 ], + "children": [ + { + "name": "Corne G2", + "position": [ 3.832608E-07, -6.300802E-07, -4 ], + "offsetFromPivot": [ 0, 0, -3 ], + "size": [ 3, 4, 7 ], + "rotation": [ -28.6929, 9.380481E-07, -2.480848E-07 ], + "texOffset": [ 168, 105 ], + "children": [ + { + "name": "Corne G3", + "position": [ 4.397035E-07, -1.773457E-06, -2 ], + "offsetFromPivot": [ 0, 0, -3 ], + "size": [ 2, 4, 7 ], + "rotation": [ -40.35846, 2.112802E-06, 1.951212E-06 ], + "texOffset": [ 196, 113 ], + "children": [ + { + "name": "Corne G4", + "position": [ 1.169115E-06, -2.845276E-06, -2 ], + "offsetFromPivot": [ 0, 0, -3 ], + "size": [ 2, 3, 7 ], + "rotation": [ -35.89212, 2.418688, -1.418534 ], + "texOffset": [ 195, 124 ], + "children": [ + { + "name": "Corne G5", + "position": [ -5.707215E-07, -5.288481E-07, -2 ], + "offsetFromPivot": [ 0, 0, -2 ], + "size": [ 2, 3, 5 ], + "rotation": [ -34.60033, -2.794594, 1.587758 ], + "texOffset": [ 168, 131 ], + "children": [ + { + "name": "Corne G6", + "position": [ -1.84081E-07, 2.999791E-07, -1 ], + "offsetFromPivot": [ 0, 0, -2 ], + "size": [ 2, 2, 5 ], + "rotation": [ -34.24986, 0.9201069, -0.5178673 ], + "texOffset": [ 168, 117 ], + "children": [] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "name": "Corne D1", + "position": [ -4, 3.138902, -0.9991918 ], + "offsetFromPivot": [ 0, 0, -2 ], + "size": [ 4, 4, 10 ], + "rotation": [ 28.29965, 30.2206, 15.43754 ], + "vertexCoords": [ + [ 2, 2, -5 ], + [ -2, 2, -5 ], + [ -2, -2, -5 ], + [ 2, -2, -5 ], + [ -2, 2, 5 ], + [ 2, 2, 5 ], + [ 2, -2, 5 ], + [ -2, -2, 5 ] + ], + "texOffset": [ 174, 116 ], + "children": [ + { + "name": "Corne D2", + "position": [ -3.832608E-07, -6.300802E-07, -4 ], + "offsetFromPivot": [ 0, 0, -3 ], + "size": [ 3, 4, 7 ], + "rotation": [ -28.6929, -9.380481E-07, 2.480848E-07 ], + "vertexCoords": [ + [ 1.5, 2, -3.5 ], + [ -1.5, 2, -3.5 ], + [ -1.5, -2, -3.5 ], + [ 1.5, -2, -3.5 ], + [ -1.5, 2, 3.5 ], + [ 1.5, 2, 3.5 ], + [ 1.5, -2, 3.5 ], + [ -1.5, -2, 3.5 ] + ], + "texOffset": [ 168, 105 ], + "children": [ + { + "name": "Corne D3", + "position": [ -4.397035E-07, -1.773457E-06, -2 ], + "offsetFromPivot": [ 0, 0, -3 ], + "size": [ 2, 4, 7 ], + "rotation": [ -40.35846, -2.112802E-06, -1.951212E-06 ], + "vertexCoords": [ + [ 1, 2, -3.5 ], + [ -1, 2, -3.5 ], + [ -1, -2, -3.5 ], + [ 1, -2, -3.5 ], + [ -1, 2, 3.5 ], + [ 1, 2, 3.5 ], + [ 1, -2, 3.5 ], + [ -1, -2, 3.5 ] + ], + "texOffset": [ 196, 113 ], + "children": [ + { + "name": "Corne D4", + "position": [ -1.169115E-06, -2.845276E-06, -2 ], + "offsetFromPivot": [ 0, 0, -3 ], + "size": [ 2, 3, 7 ], + "rotation": [ -35.8863, -2.693072, 1.579384 ], + "vertexCoords": [ + [ 1, 1.5, -3.5 ], + [ -1, 1.5, -3.5 ], + [ -1, -1.5, -3.5 ], + [ 1, -1.5, -3.5 ], + [ -1, 1.5, 3.5 ], + [ 1, 1.5, 3.5 ], + [ 1, -1.5, 3.5 ], + [ -1, -1.5, 3.5 ] + ], + "texOffset": [ 195, 124 ], + "children": [ + { + "name": "Corne D5", + "position": [ 5.707215E-07, -5.288481E-07, -2 ], + "offsetFromPivot": [ 0, 0, -2 ], + "size": [ 2, 3, 5 ], + "rotation": [ -34.62206, 1.57671, -0.8959765 ], + "vertexCoords": [ + [ 1, 1.5, -2.5 ], + [ -1, 1.5, -2.5 ], + [ -1, -1.5, -2.5 ], + [ 1, -1.5, -2.5 ], + [ -1, 1.5, 2.5 ], + [ 1, 1.5, 2.5 ], + [ 1, -1.5, 2.5 ], + [ -1, -1.5, 2.5 ] + ], + "texOffset": [ 168, 131 ], + "children": [ + { + "name": "Corne D6", + "position": [ 1.84081E-07, 2.999791E-07, -1 ], + "offsetFromPivot": [ 0, 0, -2 ], + "size": [ 2, 2, 5 ], + "rotation": [ -34.24011, 1.802034, -1.014167 ], + "vertexCoords": [ + [ 1, 1, -2.5 ], + [ -1, 1, -2.5 ], + [ -1, -1, -2.5 ], + [ 1, -1, -2.5 ], + [ -1, 1, 2.5 ], + [ 1, 1, 2.5 ], + [ 1, -1, 2.5 ], + [ -1, -1, 2.5 ] + ], + "texOffset": [ 168, 117 ], + "children": [] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "name": "Crette 1", + "position": [ 0, 4.568107, 0.08014464 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 13, 8 ], + "rotation": [ -63.77876, 0, 0 ], + "texOffset": [ 238, 33 ], + "children": [] + } + ] + }, + { + "name": "Crette 2", + "position": [ 0, 5.966101, -1 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 13, 8 ], + "rotation": [ -56.65558, 0, 0 ], + "texOffset": [ 238, 33 ], + "children": [] + } + ] + }, + { + "name": "Corp3", + "position": [ 0, -2, -31 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 18, 18, 19 ], + "rotation": [ -2.281355, 0, 0 ], + "texOffset": [ 172, 140 ], + "children": [ + { + "name": "Queue1", + "position": [ 0, 2, -8 ], + "offsetFromPivot": [ 0, 0, -5 ], + "size": [ 13, 14, 8 ], + "rotation": [ 0.6659851, 0, 0 ], + "texOffset": [ 164, 178 ], + "children": [ + { + "name": "Queue2", + "position": [ 0, 2, -4 ], + "offsetFromPivot": [ 0, -1, -5 ], + "size": [ 10, 12, 14 ], + "rotation": [ -1.160694, 0, 0 ], + "texOffset": [ 206, 177 ], + "children": [ + { + "name": "Queue3", + "position": [ 0, 2, -6 ], + "offsetFromPivot": [ 0, -1, -8 ], + "size": [ 8, 9, 14 ], + "rotation": [ -4.019387, -0.4245569, 0.02975945 ], + "texOffset": [ 150, 202 ], + "children": [ + { + "name": "Queue4", + "position": [ 0, 2.000002, -5 ], + "offsetFromPivot": [ 0, -1, -8 ], + "size": [ 6, 7, 14 ], + "rotation": [ -2.631835, 0, 0 ], + "texOffset": [ 194, 203 ], + "children": [ + { + "name": "Queue5", + "position": [ 0, 1.999995, -5 ], + "offsetFromPivot": [ 0, -1, -8 ], + "size": [ 4, 5, 14 ], + "rotation": [ -0.03058504, 0, 0 ], + "texOffset": [ 220, 210 ], + "children": [ + { + "name": "Queue6", + "position": [ 0, 1.500005, -6 ], + "offsetFromPivot": [ 0, -1, -8 ], + "size": [ 4, 4, 14 ], + "rotation": [ -1.766136, 0, 0 ], + "texOffset": [ 220, 229 ], + "children": [ + { + "name": "Queue7", + "position": [ 0, 1.000001, -5 ], + "offsetFromPivot": [ 0, -1, -9 ], + "size": [ 3, 3, 14 ], + "rotation": [ -3.908575, 0, 0 ], + "texOffset": [ 200, 224 ], + "children": [ + { + "name": "Crette 12", + "position": [ -0.08999997, 1.087998, -4.024301 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 13, 5 ], + "rotation": [ -67.97205, 0.2672611, 0.1637284 ], + "texOffset": [ 241, 36 ], + "children": [] + } + ] + }, + { + "name": "Crette 11", + "position": [ -0.08730779, 1.348922, -2.994474 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 13, 5 ], + "rotation": [ -59.55628, 0.3666071, 0.06453957 ], + "texOffset": [ 241, 36 ], + "children": [] + } + ] + }, + { + "name": "Crette 10", + "position": [ -0.08730782, 1.509915, -2.999726 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 13, 5 ], + "rotation": [ -61.32237, 0.3870896, 0.0409947 ], + "texOffset": [ 241, 36 ], + "children": [] + } + ] + }, + { + "name": "Crette 9", + "position": [ -0.08730784, 2.504039, -2.942479 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 13, 5 ], + "rotation": [ -61.35294, 0.3874678, 0.04056361 ], + "texOffset": [ 241, 36 ], + "children": [] + } + ] + }, + { + "name": "Crette 8", + "position": [ -0.08730784, 4.1004, -3.811406 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 13, 8 ], + "rotation": [ -63.98471, 0.4235127, -1.502742E-09 ], + "texOffset": [ 238, 33 ], + "children": [] + } + ] + }, + { + "name": "Crette 7", + "position": [ 0, 4.264826, -1 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 13, 8 ], + "rotation": [ -68.00421, 0, 0 ], + "texOffset": [ 238, 33 ], + "children": [] + } + ] + } + ] + }, + { + "name": "Jambe G 1", + "position": [ -8, 1.941249, 0.0612529 ], + "offsetFromPivot": [ 0, -6, 0 ], + "size": [ 6, 20, 13 ], + "rotation": [ 12.40515, -5.766162E-08, -4.187479 ], + "texOffset": [ 0, 216 ], + "children": [ + { + "name": "Jambe G 24", + "position": [ 0, -8, 1 ], + "offsetFromPivot": [ 0, -4, 1 ], + "size": [ 5, 22, 8 ], + "rotation": [ -81.37072, 0, 0 ], + "texOffset": [ 38, 217 ], + "children": [ + { + "name": "Patte GDansTonCulMonGars", + "position": [ -9.536743E-07, -9, 2 ], + "offsetFromPivot": [ 0, -5, 0 ], + "size": [ 8, 10, 5 ], + "rotation": [ 49.82677, 0, 0 ], + "texOffset": [ 64, 216 ], + "children": [ + { + "name": "Doigt 115", + "position": [ -3.3, -3, 0 ], + "offsetFromPivot": [ 0, -2, 0 ], + "size": [ 3, 7, 4 ], + "rotation": [ 69.43449, -7.633441E-08, -3.192671 ], + "texOffset": [ 65, 217 ], + "children": [ + { + "name": "Doigt 124", + "position": [ 0, -1.799195, -1.587085E-06 ], + "offsetFromPivot": [ 0, -2, 0 ], + "size": [ 3, 5, 3 ], + "rotation": [ 18.68956, 2.52309, 1.187656 ], + "texOffset": [ 78, 223 ], + "children": [ + { + "name": "Doigt 136", + "position": [ -9.386601E-07, -2, 2.893723E-06 ], + "offsetFromPivot": [ 0, -1, 0 ], + "size": [ 1, 4, 2 ], + "rotation": [ 45.39338, 3.221526E-07, 1.761976E-07 ], + "texOffset": [ 64, 239 ], + "children": [] + } + ] + } + ] + }, + { + "name": "Doigt 218", + "position": [ 0, -2.999999, 1.565276E-06 ], + "offsetFromPivot": [ 0, -2, 0 ], + "size": [ 3, 7, 4 ], + "rotation": [ 69.43449, 0, 0 ], + "texOffset": [ 65, 217 ], + "children": [ + { + "name": "Doigt 229", + "position": [ 0, -1.989176, -1.749227E-06 ], + "offsetFromPivot": [ 0, -2, 0 ], + "size": [ 3, 5, 3 ], + "rotation": [ 18.8, 1.44, -1.274122E-08 ], + "texOffset": [ 78, 223 ], + "children": [ + { + "name": "Doigt 238", + "position": [ 0.3343311, -1.992396, -0.1466559 ], + "offsetFromPivot": [ 0, -1, 0 ], + "size": [ 1, 4, 2 ], + "rotation": [ 45.35126, -2.210411, -3.105502 ], + "texOffset": [ 64, 239 ], + "children": [] + } + ] + } + ] + }, + { + "name": "Doigt 315", + "position": [ 3.3, -3, 0 ], + "offsetFromPivot": [ 0, -2, 0 ], + "size": [ 3, 7, 4 ], + "rotation": [ 69.43, -3.799124E-08, 1.981351 ], + "texOffset": [ 65, 217 ], + "children": [ + { + "name": "Doigt 326", + "position": [ -1.042691E-07, -2, -1.239786E-06 ], + "offsetFromPivot": [ 0, -2, 0 ], + "size": [ 3, 5, 3 ], + "rotation": [ 18.85166, -1.625271E-07, -1.054869E-06 ], + "texOffset": [ 78, 223 ], + "children": [ + { + "name": "Doigt 337", + "position": [ 0, -1.882363, -0.1897153 ], + "offsetFromPivot": [ 0, -1, 0 ], + "size": [ 1, 4, 2 ], + "rotation": [ 45.20541, -3.845515, -6.424582 ], + "texOffset": [ 64, 239 ], + "children": [] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "name": "Jambe D 1", + "position": [ 8, 1.941249, 0.0612529 ], + "offsetFromPivot": [ 0, -6, 0 ], + "size": [ 6, 20, 13 ], + "rotation": [ 12.40515, 5.766162E-08, 4.187479 ], + "vertexCoords": [ + [ 3, 10, -6.5 ], + [ -3, 10, -6.5 ], + [ -3, -10, -6.5 ], + [ 3, -10, -6.5 ], + [ -3, 10, 6.5 ], + [ 3, 10, 6.5 ], + [ 3, -10, 6.5 ], + [ -3, -10, 6.5 ] + ], + "texOffset": [ 0, 216 ], + "children": [ + { + "name": "Jambe G 2", + "position": [ 0, -8, 1 ], + "offsetFromPivot": [ 0, -4, 1 ], + "size": [ 5, 22, 8 ], + "rotation": [ -81.37072, 0, 0 ], + "vertexCoords": [ + [ 2.5, 11, -4 ], + [ -2.5, 11, -4 ], + [ -2.5, -11, -4 ], + [ 2.5, -11, -4 ], + [ -2.5, 11, 4 ], + [ 2.5, 11, 4 ], + [ 2.5, -11, 4 ], + [ -2.5, -11, 4 ] + ], + "texOffset": [ 38, 217 ], + "children": [ + { + "name": "Patte GToiAussiEncule", + "position": [ 9.536743E-07, -9, 2 ], + "offsetFromPivot": [ 0, -5, 0 ], + "size": [ 8, 10, 5 ], + "rotation": [ 49.82677, 0, 0 ], + "vertexCoords": [ + [ 4, 5, -2.5 ], + [ -4, 5, -2.5 ], + [ -4, -5, -2.5 ], + [ 4, -5, -2.5 ], + [ -4, 5, 2.5 ], + [ 4, 5, 2.5 ], + [ 4, -5, 2.5 ], + [ -4, -5, 2.5 ] + ], + "texOffset": [ 64, 216 ], + "children": [ + { + "name": "Doigt 11", + "position": [ 3.3, -3, 0 ], + "offsetFromPivot": [ 0, -2, 0 ], + "size": [ 3, 7, 4 ], + "rotation": [ 69.43449, 7.633441E-08, 3.192671 ], + "vertexCoords": [ + [ 1.5, 3.5, -2 ], + [ -1.5, 3.5, -2 ], + [ -1.5, -3.5, -2 ], + [ 1.5, -3.5, -2 ], + [ -1.5, 3.5, 2 ], + [ 1.5, 3.5, 2 ], + [ 1.5, -3.5, 2 ], + [ -1.5, -3.5, 2 ] + ], + "texOffset": [ 65, 217 ], + "children": [ + { + "name": "Doigt 12", + "position": [ 0, -1.799195, -1.587085E-06 ], + "offsetFromPivot": [ 0, -2, 0 ], + "size": [ 3, 5, 3 ], + "rotation": [ 18.68956, -2.52309, -1.187656 ], + "vertexCoords": [ + [ 1.5, 2.5, -1.5 ], + [ -1.5, 2.5, -1.5 ], + [ -1.5, -2.5, -1.5 ], + [ 1.5, -2.5, -1.5 ], + [ -1.5, 2.5, 1.5 ], + [ 1.5, 2.5, 1.5 ], + [ 1.5, -2.5, 1.5 ], + [ -1.5, -2.5, 1.5 ] + ], + "texOffset": [ 78, 223 ], + "children": [ + { + "name": "Doigt 13", + "position": [ 9.386601E-07, -2, 2.893723E-06 ], + "offsetFromPivot": [ 0, -1, 0 ], + "size": [ 1, 4, 2 ], + "rotation": [ 45.39338, -3.221526E-07, -1.761976E-07 ], + "vertexCoords": [ + [ 0.5, 2, -1 ], + [ -0.5, 2, -1 ], + [ -0.5, -2, -1 ], + [ 0.5, -2, -1 ], + [ -0.5, 2, 1 ], + [ 0.5, 2, 1 ], + [ 0.5, -2, 1 ], + [ -0.5, -2, 1 ] + ], + "texOffset": [ 64, 239 ], + "children": [] + } + ] + } + ] + }, + { + "name": "Doigt 21", + "position": [ 0, -2.999999, 1.565276E-06 ], + "offsetFromPivot": [ 0, -2, 0 ], + "size": [ 3, 7, 4 ], + "rotation": [ 69.43449, 0, 0 ], + "vertexCoords": [ + [ 1.5, 3.5, -2 ], + [ -1.5, 3.5, -2 ], + [ -1.5, -3.5, -2 ], + [ 1.5, -3.5, -2 ], + [ -1.5, 3.5, 2 ], + [ 1.5, 3.5, 2 ], + [ 1.5, -3.5, 2 ], + [ -1.5, -3.5, 2 ] + ], + "texOffset": [ 65, 217 ], + "children": [ + { + "name": "Doigt 22", + "position": [ 0, -1.989176, -1.749227E-06 ], + "offsetFromPivot": [ 0, -2, 0 ], + "size": [ 3, 5, 3 ], + "rotation": [ 18.8, -1.44, 1.274122E-08 ], + "vertexCoords": [ + [ 1.5, 2.5, -1.5 ], + [ -1.5, 2.5, -1.5 ], + [ -1.5, -2.5, -1.5 ], + [ 1.5, -2.5, -1.5 ], + [ -1.5, 2.5, 1.5 ], + [ 1.5, 2.5, 1.5 ], + [ 1.5, -2.5, 1.5 ], + [ -1.5, -2.5, 1.5 ] + ], + "texOffset": [ 78, 223 ], + "children": [ + { + "name": "Doigt 23", + "position": [ -0.3343311, -1.992396, -0.1466559 ], + "offsetFromPivot": [ 0, -1, 0 ], + "size": [ 1, 4, 2 ], + "rotation": [ 45.35126, 2.210411, 3.105502 ], + "vertexCoords": [ + [ 0.5, 2, -1 ], + [ -0.5, 2, -1 ], + [ -0.5, -2, -1 ], + [ 0.5, -2, -1 ], + [ -0.5, 2, 1 ], + [ 0.5, 2, 1 ], + [ 0.5, -2, 1 ], + [ -0.5, -2, 1 ] + ], + "texOffset": [ 64, 239 ], + "children": [] + } + ] + } + ] + }, + { + "name": "Doigt 31", + "position": [ -3.3, -3, 0 ], + "offsetFromPivot": [ 0, -2, 0 ], + "size": [ 3, 7, 4 ], + "rotation": [ 69.43, 3.799124E-08, -1.981351 ], + "vertexCoords": [ + [ 1.5, 3.5, -2 ], + [ -1.5, 3.5, -2 ], + [ -1.5, -3.5, -2 ], + [ 1.5, -3.5, -2 ], + [ -1.5, 3.5, 2 ], + [ 1.5, 3.5, 2 ], + [ 1.5, -3.5, 2 ], + [ -1.5, -3.5, 2 ] + ], + "texOffset": [ 65, 217 ], + "children": [ + { + "name": "Doigt 325624", + "position": [ 1.042691E-07, -2, -1.239786E-06 ], + "offsetFromPivot": [ 0, -2, 0 ], + "size": [ 3, 5, 3 ], + "rotation": [ 18.85166, 1.625271E-07, 1.054869E-06 ], + "vertexCoords": [ + [ 1.5, 2.5, -1.5 ], + [ -1.5, 2.5, -1.5 ], + [ -1.5, -2.5, -1.5 ], + [ 1.5, -2.5, -1.5 ], + [ -1.5, 2.5, 1.5 ], + [ 1.5, 2.5, 1.5 ], + [ 1.5, -2.5, 1.5 ], + [ -1.5, -2.5, 1.5 ] + ], + "texOffset": [ 78, 223 ], + "children": [ + { + "name": "Doigt 335623", + "position": [ 0, -1.882363, -0.1897153 ], + "offsetFromPivot": [ 0, -1, 0 ], + "size": [ 1, 4, 2 ], + "rotation": [ 45.20541, 3.845515, 6.424582 ], + "vertexCoords": [ + [ 0.5, 2, -1 ], + [ -0.5, 2, -1 ], + [ -0.5, -2, -1 ], + [ 0.5, -2, -1 ], + [ -0.5, 2, 1 ], + [ 0.5, 2, 1 ], + [ 0.5, -2, 1 ], + [ -0.5, -2, 1 ] + ], + "texOffset": [ 64, 239 ], + "children": [] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "name": "Crette 6", + "position": [ 0, 7.481722, -5 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 13, 8 ], + "rotation": [ -68.49892, 0, 0 ], + "texOffset": [ 238, 33 ], + "children": [] + } + ] + }, + { + "name": "Aile2", + "position": [ -15, 9.184255E-07, -2.546989E-06 ], + "offsetFromPivot": [ -24, 0, 0 ], + "size": [ 50, 5, 8 ], + "rotation": [ -6.89, -22, 2.168892E-09 ], + "vertexCoords": [ + [ 25, 2.5, -4 ], + [ -25, 2.5, -4 ], + [ -25, -2.5, -4 ], + [ 25, -2.5, -4 ], + [ -25, 2.5, 4 ], + [ 25, 2.5, 4 ], + [ 25, -2.5, 4 ], + [ -25, -2.5, 4 ] + ], + "texOffset": [ 58, 0 ], + "children": [ + { + "name": "Aile 2.2", + "position": [ -21.31004, 0.0002365663, -0.0255119 ], + "offsetFromPivot": [ -24, 0, 0 ], + "size": [ 50, 5, 7 ], + "rotation": [ 0.2339692, 63.46978, 0.4686372 ], + "vertexCoords": [ + [ 25, 2.5, -3.5 ], + [ -25, 2.5, -3.5 ], + [ -25, -2.5, -3.5 ], + [ 25, -2.5, -3.5 ], + [ -25, 2.5, 3.5 ], + [ 25, 2.5, 3.5 ], + [ 25, -2.5, 3.5 ], + [ -25, -2.5, 3.5 ] + ], + "texOffset": [ 74, 13 ], + "children": [ + { + "name": "AileBranche2.2", + "position": [ -23.84916, 0.09999574, 2.215488 ], + "offsetFromPivot": [ -44, 0, 0 ], + "size": [ 86, 5, 3 ], + "rotation": [ -1.543068E-05, -110.841, 8.969847E-06 ], + "vertexCoords": [ + [ 43, 2.5, -1.5 ], + [ -43, 2.5, -1.5 ], + [ -43, -2.5, -1.5 ], + [ 43, -2.5, -1.5 ], + [ -43, 2.5, 1.5 ], + [ 43, 2.5, 1.5 ], + [ 43, -2.5, 1.5 ], + [ -43, -2.5, 1.5 ] + ], + "texOffset": [ 74, 25 ], + "children": [ + { + "name": "AileToile2.2", + "position": [ 34.94409, -0.1125191, -8.335443 ], + "offsetFromPivot": [ -38, 0, -16 ], + "size": [ 86, 0, 46 ], + "rotation": [ -1.080418E-05, -1.636025E-05, 9.369185E-06 ], + "vertexCoords": [ + [ 43, 0, -23 ], + [ -43, 0, -23 ], + [ -43, 0, -23 ], + [ 43, 0, -23 ], + [ -43, 0, 23 ], + [ 43, 0, 23 ], + [ 43, 0, 23 ], + [ -43, 0, 23 ] + ], + "texOffset": [ -46, 140 ], + "children": [] + }, + { + "name": "griffes bout ailes2.2", + "position": [ -39.18649, 0.2161948, -0.09094638 ], + "offsetFromPivot": [ 0, 0, 5 ], + "size": [ 3, 3, 9 ], + "rotation": [ 0.5044933, -99.31251, -91.96687 ], + "vertexCoords": [ + [ 1.5, 1.5, -4.5 ], + [ -1.5, 1.5, -4.5 ], + [ -1.5, -1.5, -4.5 ], + [ 1.5, -1.5, -4.5 ], + [ -1.5, 1.5, 4.5 ], + [ 1.5, 1.5, 4.5 ], + [ 1.5, -1.5, 4.5 ], + [ -1.5, -1.5, 4.5 ] + ], + "texOffset": [ 174, 0 ], + "children": [ + { + "name": "griffes bout.2", + "position": [ -0.3783033, 0.1637897, 3 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 17.07758, -1.555225E-05, -9.53466E-06 ], + "vertexCoords": [ + [ 1, 1, -2 ], + [ -1, 1, -2 ], + [ -1, -1, -2 ], + [ 1, -1, -2 ], + [ -1, 1, 2 ], + [ 1, 1, 2 ], + [ 1, -1, 2 ], + [ -1, -1, 2 ] + ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou2.2", + "position": [ -0.02169422, 0.2021261, 0.5993456 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 9.424067, -5.280378E-06, 5.510787E-06 ], + "vertexCoords": [ + [ 1, 1, -2 ], + [ -1, 1, -2 ], + [ -1, -1, -2 ], + [ 1, -1, -2 ], + [ -1, 1, 2 ], + [ 1, 1, 2 ], + [ 1, -1, 2 ], + [ -1, -1, 2 ] + ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou3.2", + "position": [ 0, 0.2, 0.5 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 1, 2, 4 ], + "rotation": [ 8.012905, 5.684132E-06, -6.632725E-07 ], + "vertexCoords": [ + [ 0.5, 1, -2 ], + [ -0.5, 1, -2 ], + [ -0.5, -1, -2 ], + [ 0.5, -1, -2 ], + [ -0.5, 1, 2 ], + [ 0.5, 1, 2 ], + [ 0.5, -1, 2 ], + [ -0.5, -1, 2 ] + ], + "texOffset": [ 189, 0 ], + "children": [] + } + ] + } + ] + } + ] + } + ] + }, + { + "name": "AileBranche3.25622", + "position": [ -23.84916, 0.0999957, 2.215488 ], + "offsetFromPivot": [ -44, 0, 0 ], + "size": [ 86, 5, 3 ], + "rotation": [ -5.683263E-06, -141.5232, 2.130234E-05 ], + "vertexCoords": [ + [ 43, 2.5, -1.5 ], + [ -43, 2.5, -1.5 ], + [ -43, -2.5, -1.5 ], + [ 43, -2.5, -1.5 ], + [ -43, 2.5, 1.5 ], + [ 43, 2.5, 1.5 ], + [ 43, -2.5, 1.5 ], + [ -43, -2.5, 1.5 ] + ], + "texOffset": [ 74, 25 ], + "children": [ + { + "name": "griffes bout ailes2.25621", + "position": [ -39.18649, 0.2161948, -0.09094638 ], + "offsetFromPivot": [ 0, 0, 5 ], + "size": [ 3, 3, 9 ], + "rotation": [ 0.5044933, -99.31251, -91.96687 ], + "vertexCoords": [ + [ 1.5, 1.5, -4.5 ], + [ -1.5, 1.5, -4.5 ], + [ -1.5, -1.5, -4.5 ], + [ 1.5, -1.5, -4.5 ], + [ -1.5, 1.5, 4.5 ], + [ 1.5, 1.5, 4.5 ], + [ 1.5, -1.5, 4.5 ], + [ -1.5, -1.5, 4.5 ] + ], + "texOffset": [ 174, 0 ], + "children": [ + { + "name": "griffes bout.25620", + "position": [ -0.4, 0, 3 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 2.648026, -1.073253, 0.0176872 ], + "vertexCoords": [ + [ 1, 1, -2 ], + [ -1, 1, -2 ], + [ -1, -1, -2 ], + [ 1, -1, -2 ], + [ -1, 1, 2 ], + [ 1, 1, 2 ], + [ 1, -1, 2 ], + [ -1, -1, 2 ] + ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou2.25619", + "position": [ -0.02169422, 0.2021261, 0.5993456 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 9.424067, -5.280378E-06, 5.510787E-06 ], + "vertexCoords": [ + [ 1, 1, -2 ], + [ -1, 1, -2 ], + [ -1, -1, -2 ], + [ 1, -1, -2 ], + [ -1, 1, 2 ], + [ 1, 1, 2 ], + [ 1, -1, 2 ], + [ -1, -1, 2 ] + ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou3.25618", + "position": [ 0, 0.2, 0.5 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 1, 2, 4 ], + "rotation": [ 8.012905, 5.684132E-06, -6.632725E-07 ], + "vertexCoords": [ + [ 0.5, 1, -2 ], + [ -0.5, 1, -2 ], + [ -0.5, -1, -2 ], + [ 0.5, -1, -2 ], + [ -0.5, 1, 2 ], + [ 0.5, 1, 2 ], + [ 0.5, -1, 2 ], + [ -0.5, -1, 2 ] + ], + "texOffset": [ 189, 0 ], + "children": [] + } + ] + } + ] + } + ] + }, + { + "name": "AileToile 1.3.25617", + "position": [ 46.37394, 1.574688E-06, -11.22091 ], + "offsetFromPivot": [ -55, 0, -5 ], + "size": [ 82, 0, 30 ], + "rotation": [ -5.072849E-06, -3.746575E-07, 1.22216E-05 ], + "vertexCoords": [ + [ 41, 0, -15 ], + [ -41, 0, -15 ], + [ -41, 0, -15 ], + [ 41, 0, -15 ], + [ -41, 0, 15 ], + [ 41, 0, 15 ], + [ 41, 0, 15 ], + [ -41, 0, 15 ] + ], + "texOffset": [ -30, 186 ], + "children": [] + } + ] + }, + { + "name": "AileBranche1.25616", + "position": [ -23.84916, 0.1499978, 2.215489 ], + "offsetFromPivot": [ -29, 0, 0 ], + "size": [ 57, 5, 3 ], + "rotation": [ -1.716231E-05, -83.72255, 2.268148E-07 ], + "vertexCoords": [ + [ 28.5, 2.5, -1.5 ], + [ -28.5, 2.5, -1.5 ], + [ -28.5, -2.5, -1.5 ], + [ 28.5, -2.5, -1.5 ], + [ -28.5, 2.5, 1.5 ], + [ 28.5, 2.5, 1.5 ], + [ 28.5, -2.5, 1.5 ], + [ -28.5, -2.5, 1.5 ] + ], + "texOffset": [ 86, 25 ], + "children": [ + { + "name": "AileToilebranche 1.25615", + "position": [ 26.12369, -0.07595771, -7.794971 ], + "offsetFromPivot": [ -36, 0, -13 ], + "size": [ 84, 0, 42 ], + "rotation": [ -1.325583E-05, -1.158159E-05, 2.358795E-06 ], + "vertexCoords": [ + [ 42, 0, -21 ], + [ -42, 0, -21 ], + [ -42, 0, -21 ], + [ 42, 0, -21 ], + [ -42, 0, 21 ], + [ 42, 0, 21 ], + [ 42, 0, 21 ], + [ -42, 0, 21 ] + ], + "texOffset": [ -42, 98 ], + "children": [] + }, + { + "name": "griffes bout ailes.25614", + "position": [ -26.23009, 0.166191, -0.02326208 ], + "offsetFromPivot": [ 0, 0, 5 ], + "size": [ 3, 3, 9 ], + "rotation": [ 1.228018, -103.6092, -91.61719 ], + "vertexCoords": [ + [ 1.5, 1.5, -4.5 ], + [ -1.5, 1.5, -4.5 ], + [ -1.5, -1.5, -4.5 ], + [ 1.5, -1.5, -4.5 ], + [ -1.5, 1.5, 4.5 ], + [ 1.5, 1.5, 4.5 ], + [ 1.5, -1.5, 4.5 ], + [ -1.5, -1.5, 4.5 ] + ], + "texOffset": [ 174, 0 ], + "children": [ + { + "name": "griffes bout.25613", + "position": [ -0.3783033, 0.1637897, 3 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 17.07758, -1.555225E-05, -9.53466E-06 ], + "vertexCoords": [ + [ 1, 1, -2 ], + [ -1, 1, -2 ], + [ -1, -1, -2 ], + [ 1, -1, -2 ], + [ -1, 1, 2 ], + [ 1, 1, 2 ], + [ 1, -1, 2 ], + [ -1, -1, 2 ] + ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou2.25612", + "position": [ 0, 0.3, 0 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 12.42268, 6.004402E-06, 4.675526E-08 ], + "vertexCoords": [ + [ 1, 1, -2 ], + [ -1, 1, -2 ], + [ -1, -1, -2 ], + [ 1, -1, -2 ], + [ -1, 1, 2 ], + [ 1, 1, 2 ], + [ 1, -1, 2 ], + [ -1, -1, 2 ] + ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou3.25611", + "position": [ 4.170682E-06, -1.131516E-06, 1 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 1, 2, 4 ], + "rotation": [ 8.012905, 5.684132E-06, -6.632725E-07 ], + "vertexCoords": [ + [ 0.5, 1, -2 ], + [ -0.5, 1, -2 ], + [ -0.5, -1, -2 ], + [ 0.5, -1, -2 ], + [ -0.5, 1, 2 ], + [ 0.5, 1, 2 ], + [ 0.5, -1, 2 ], + [ -0.5, -1, 2 ] + ], + "texOffset": [ 189, 0 ], + "children": [] + } + ] + } + ] + } + ] + } + ] + }, + { + "name": "griffes bout ailes_centre2.25610", + "position": [ -18.87915, 0.3161964, 1.668767 ], + "offsetFromPivot": [ 0, 0, 5 ], + "size": [ 3, 3, 9 ], + "rotation": [ 1.389458, -87.70206, -88.51917 ], + "vertexCoords": [ + [ 1.5, 1.5, -4.5 ], + [ -1.5, 1.5, -4.5 ], + [ -1.5, -1.5, -4.5 ], + [ 1.5, -1.5, -4.5 ], + [ -1.5, 1.5, 4.5 ], + [ 1.5, 1.5, 4.5 ], + [ 1.5, -1.5, 4.5 ], + [ -1.5, -1.5, 4.5 ] + ], + "texOffset": [ 174, 0 ], + "children": [ + { + "name": "griffes bout.2569", + "position": [ -0.3783033, 0.1637897, 3 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 17.07758, -1.555225E-05, -9.53466E-06 ], + "vertexCoords": [ + [ 1, 1, -2 ], + [ -1, 1, -2 ], + [ -1, -1, -2 ], + [ 1, -1, -2 ], + [ -1, 1, 2 ], + [ 1, 1, 2 ], + [ 1, -1, 2 ], + [ -1, -1, 2 ] + ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou2.2568", + "position": [ 0, 0.3, 0 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 2, 2, 4 ], + "rotation": [ 12.42268, 6.004402E-06, 4.675526E-08 ], + "vertexCoords": [ + [ 1, 1, -2 ], + [ -1, 1, -2 ], + [ -1, -1, -2 ], + [ 1, -1, -2 ], + [ -1, 1, 2 ], + [ 1, 1, 2 ], + [ 1, -1, 2 ], + [ -1, -1, 2 ] + ], + "texOffset": [ 189, 0 ], + "children": [ + { + "name": "griffes bou3.2567", + "position": [ 4.170682E-06, -1.131516E-06, 1 ], + "offsetFromPivot": [ 0, 0, 3 ], + "size": [ 1, 2, 4 ], + "rotation": [ 8.012905, 5.684132E-06, -6.632725E-07 ], + "vertexCoords": [ + [ 0.5, 1, -2 ], + [ -0.5, 1, -2 ], + [ -0.5, -1, -2 ], + [ 0.5, -1, -2 ], + [ -0.5, 1, 2 ], + [ 0.5, 1, 2 ], + [ 0.5, -1, 2 ], + [ -0.5, -1, 2 ] + ], + "texOffset": [ 189, 0 ], + "children": [] + } + ] + } + ] + } + ] + } + ] + }, + { + "name": "AileToile1.1.2566", + "position": [ 24, -3.476012E-06, 1.473967E-06 ], + "offsetFromPivot": [ -23, 0, -23 ], + "size": [ 53, 0, 42 ], + "rotation": [ -1.219527E-05, -1.112748E-05, -3.504153E-06 ], + "vertexCoords": [ + [ 26.5, 0, -21 ], + [ -26.5, 0, -21 ], + [ -26.5, 0, -21 ], + [ 26.5, 0, -21 ], + [ -26.5, 0, 21 ], + [ 26.5, 0, 21 ], + [ 26.5, 0, 21 ], + [ -26.5, 0, 21 ] + ], + "texOffset": [ 52, 56 ], + "children": [] + } + ] + }, + { + "name": "Crette 3565", + "position": [ 6, 7.519951, -5.314118 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 13, 8 ], + "rotation": [ -60.43575, 0, 0 ], + "texOffset": [ 238, 33 ], + "children": [] + }, + { + "name": "Crette 4564", + "position": [ -6, 7.519951, -5.314118 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 13, 8 ], + "rotation": [ -60.43574, 0, 0 ], + "vertexCoords": [ + [ 0.5, 6.5, -4 ], + [ -0.5, 6.5, -4 ], + [ -0.5, -6.5, -4 ], + [ 0.5, -6.5, -4 ], + [ -0.5, 6.5, 4 ], + [ 0.5, 6.5, 4 ], + [ 0.5, -6.5, 4 ], + [ -0.5, -6.5, 4 ] + ], + "texOffset": [ 238, 33 ], + "children": [] + }, + { + "name": "Crette Centre563", + "position": [ 0, 8, -5.314118 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 17, 9 ], + "rotation": [ -59.58637, 0, 0 ], + "texOffset": [ 60, 32 ], + "children": [] + }, + { + "name": "Corp2562", + "position": [ 0, -0.9999974, -18 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 17, 16, 26 ], + "rotation": [ -2.281355, 0, 0 ], + "texOffset": [ 0, 32 ], + "children": [ + { + "name": "Crette 5561", + "position": [ 0, 7, -0.6600574 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 1, 13, 8 ], + "rotation": [ -68.49894, 0, 0 ], + "texOffset": [ 238, 33 ], + "children": [] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/craftstudioapi/craftstudio/models/entity/model_dead_corpse.csjsmodel b/src/main/resources/assets/craftstudioapi/craftstudio/models/entity/model_dead_corpse.csjsmodel new file mode 100644 index 0000000..362a4d8 --- /dev/null +++ b/src/main/resources/assets/craftstudioapi/craftstudio/models/entity/model_dead_corpse.csjsmodel @@ -0,0 +1,129 @@ +{ + "title": "ModelDeadCorpse", + "tree": [ + { + "name": "bipedBody", + "position": [ 0, 18, 0 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 8, 12, 4 ], + "rotation": [ 0, 0, 0 ], + "texOffset": [ 16, 16 ], + "children": [ + { + "name": "bipedHead", + "position": [ 0, 6, 0 ], + "offsetFromPivot": [ 0, 4, 0 ], + "size": [ 8, 8, 8 ], + "rotation": [ 0, 0, 0 ], + "vertexCoords": [ + [ -5.016337, 4, -4 ], + [ 5.016337, 4, -4 ], + [ 5.016337, -4, -4 ], + [ -5.016337, -4, -4 ], + [ 5.016337, 4, 4 ], + [ -5.016337, 4, 4 ], + [ -5.016337, -4, 4 ], + [ 5.016337, -4, 4 ] + ], + "texOffset": [ 0, 0 ], + "children": [ + { + "name": "bipedHeadWear", + "position": [ 0, -4, 0 ], + "offsetFromPivot": [ 0, 4, 0 ], + "size": [ 8, 8, 8 ], + "rotation": [ 0, 0, 0 ], + "texOffset": [ 32, 0 ], + "children": [] + } + ] + }, + { + "name": "bipedLeftArm", + "position": [ 4, 4, 0 ], + "offsetFromPivot": [ 2, -4, 0 ], + "size": [ 4, 12, 4 ], + "rotation": [ 0, 0, 0 ], + "texOffset": [ 32, 48 ], + "children": [ + { + "name": "bipedLeftArmWear", + "position": [ -2, 4, 0 ], + "offsetFromPivot": [ 2, -4, 0 ], + "size": [ 4, 12, 4 ], + "rotation": [ 0, 0, 0 ], + "texOffset": [ 48, 48 ], + "children": [] + } + ] + }, + { + "name": "bipedRightArm", + "position": [ -4, 4, 0 ], + "offsetFromPivot": [ -2, -4, 0 ], + "size": [ 4, 12, 4 ], + "rotation": [ 0, 0, 0 ], + "texOffset": [ 40, 16 ], + "children": [ + { + "name": "bipedRightArmWear", + "position": [ 2, 4, 0 ], + "offsetFromPivot": [ -2, -4, 0 ], + "size": [ 4, 12, 4 ], + "rotation": [ 0, 0, 0 ], + "texOffset": [ 40, 32 ], + "children": [] + } + ] + }, + { + "name": "bipedLeftLeg", + "position": [ 2, -6, 0 ], + "offsetFromPivot": [ 0, -6, 0 ], + "size": [ 4, 12, 4 ], + "rotation": [ 0, 0, 0 ], + "texOffset": [ 16, 48 ], + "children": [ + { + "name": "bipedLeftLegWear", + "position": [ 0, 6, 0 ], + "offsetFromPivot": [ 0, -6, 0 ], + "size": [ 4, 12, 4 ], + "rotation": [ 0, 0, 0 ], + "texOffset": [ 0, 48 ], + "children": [] + } + ] + }, + { + "name": "bipedRightLeg", + "position": [ -2, -6, 0 ], + "offsetFromPivot": [ 0, -6, 0 ], + "size": [ 4, 12, 4 ], + "rotation": [ 0, 0, 0 ], + "texOffset": [ 0, 16 ], + "children": [ + { + "name": "bipedRightLegWear", + "position": [ 0, 6, 0 ], + "offsetFromPivot": [ 0, -6, 0 ], + "size": [ 4, 12, 4 ], + "rotation": [ 0, 0, 0 ], + "texOffset": [ 0, 32 ], + "children": [] + } + ] + }, + { + "name": "bipedBodyWear", + "position": [ 0, 0, 0 ], + "offsetFromPivot": [ 0, 0, 0 ], + "size": [ 8, 12, 4 ], + "rotation": [ 0, 0, 0 ], + "texOffset": [ 16, 32 ], + "children": [] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/craftstudioapi/textures/block/block_test.png b/src/main/resources/assets/craftstudioapi/textures/block/block_test.png new file mode 100644 index 0000000..dc3dfb7 Binary files /dev/null and b/src/main/resources/assets/craftstudioapi/textures/block/block_test.png differ diff --git a/src/main/resources/assets/craftstudioapi/textures/entity/craftstudio_api_test.png b/src/main/resources/assets/craftstudioapi/textures/entity/craftstudio_api_test.png new file mode 100644 index 0000000..cd937e5 Binary files /dev/null and b/src/main/resources/assets/craftstudioapi/textures/entity/craftstudio_api_test.png differ diff --git a/src/main/resources/assets/craftstudioapi/textures/entity/deadmau5.png b/src/main/resources/assets/craftstudioapi/textures/entity/deadmau5.png new file mode 100644 index 0000000..ccadd99 Binary files /dev/null and b/src/main/resources/assets/craftstudioapi/textures/entity/deadmau5.png differ diff --git a/src/main/resources/assets/craftstudioapi/textures/entity/dragon_brun.png b/src/main/resources/assets/craftstudioapi/textures/entity/dragon_brun.png new file mode 100644 index 0000000..c771e93 Binary files /dev/null and b/src/main/resources/assets/craftstudioapi/textures/entity/dragon_brun.png differ diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info deleted file mode 100644 index 604590d..0000000 --- a/src/main/resources/mcmod.info +++ /dev/null @@ -1,16 +0,0 @@ -[ -{ - "modid": "craftstudioapi", - "name": "CraftStudio API", - "description": "A CraftStudio API for models/animations support in Minecraft", - "version": "${version}", - "mcversion": "${mcversion}", - "url": "", - "updateJSON": "https://leviathan-studio.com/craftstudioapi/update.json", - "authorList": ["ZeAmateis", "Timmypote", "Elisee", "IncubeSupreme", "Phenix246"], - "credits": "See https://github.com/Leviathan-Studio/CraftStudioAPI/blob/master/CREDITS.md", - "logoFile": "", - "screenshots": [], - "dependencies": [] -} -] diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta new file mode 100644 index 0000000..42ab490 --- /dev/null +++ b/src/main/resources/pack.mcmeta @@ -0,0 +1,7 @@ +{ + "pack": { + "description": "examplemod resources", + "pack_format": 4, + "_comment": "A pack_format of 4 requires json lang files. Note: we require v4 pack meta for all mods." + } +} diff --git a/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest.java b/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest.java index 0e7b7af..0b6c7aa 100644 --- a/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest.java +++ b/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest.java @@ -1,33 +1,33 @@ package com.leviathanstudio.test.client.entityRender; import com.leviathanstudio.craftstudio.client.model.ModelCraftStudio; -import com.leviathanstudio.test.common.Mod_Test; +import com.leviathanstudio.test.common.ModTest; import com.leviathanstudio.test.common.entity.EntityTest; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderLiving; -import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.client.renderer.entity.EntityRendererManager; +import net.minecraft.client.renderer.entity.LivingRenderer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.registry.IRenderFactory; -public class RenderTest extends RenderLiving +public class RenderTest extends LivingRenderer> { - public static final Factory FACTORY = new Factory(); + public static final Factory FACTORY = new Factory<>(); - public RenderTest(RenderManager manager) { - super(manager, new ModelCraftStudio(Mod_Test.MODID, "craftstudio_api_test", 64, 32), 0.5F); + public RenderTest(EntityRendererManager manager) { + super(manager, new ModelCraftStudio(ModTest.MODID, "craftstudio_api_test", 64, 32), 0.5F); } @Override protected ResourceLocation getEntityTexture(T entity) { - return new ResourceLocation(Mod_Test.MODID, "textures/entity/craftstudio_api_test.png"); + return new ResourceLocation(ModTest.MODID, "textures/entity/craftstudio_api_test.png"); } public static class Factory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) { - return new RenderTest(manager); + public EntityRenderer createRenderFor(EntityRendererManager manager) { + return new RenderTest(manager); } } } \ No newline at end of file diff --git a/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest2.java b/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest2.java index 2b67830..b9ede4e 100644 --- a/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest2.java +++ b/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest2.java @@ -1,33 +1,33 @@ package com.leviathanstudio.test.client.entityRender; import com.leviathanstudio.craftstudio.client.model.ModelCraftStudio; -import com.leviathanstudio.test.common.Mod_Test; +import com.leviathanstudio.test.common.ModTest; import com.leviathanstudio.test.common.entity.EntityTest2; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderLiving; -import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.client.renderer.entity.EntityRendererManager; +import net.minecraft.client.renderer.entity.LivingRenderer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.registry.IRenderFactory; -public class RenderTest2 extends RenderLiving +public class RenderTest2 extends LivingRenderer> { - public static final Factory FACTORY = new Factory(); + public static final Factory FACTORY = new Factory<>(); - public RenderTest2(RenderManager manager) { - super(manager, new ModelCraftStudio(Mod_Test.MODID, "peacock", 128, 64), 0.5F); + public RenderTest2(EntityRendererManager manager) { + super(manager, new ModelCraftStudio(ModTest.MODID, "peacock", 128, 64), 0.5F); } @Override protected ResourceLocation getEntityTexture(T entity) { - return new ResourceLocation(Mod_Test.MODID, "textures/entity/peacock.png"); + return new ResourceLocation(ModTest.MODID, "textures/entity/peacock.png"); } public static class Factory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) { - return new RenderTest2(manager); + public EntityRenderer createRenderFor(EntityRendererManager manager) { + return new RenderTest2(manager); } } } diff --git a/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest3.java b/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest3.java index a51a9a1..ef97389 100644 --- a/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest3.java +++ b/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest3.java @@ -1,33 +1,33 @@ package com.leviathanstudio.test.client.entityRender; import com.leviathanstudio.craftstudio.client.model.ModelCraftStudio; -import com.leviathanstudio.test.common.Mod_Test; +import com.leviathanstudio.test.common.ModTest; import com.leviathanstudio.test.common.entity.EntityTest3; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderLiving; -import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.client.renderer.entity.EntityRendererManager; +import net.minecraft.client.renderer.entity.LivingRenderer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.registry.IRenderFactory; -public class RenderTest3 extends RenderLiving +public class RenderTest3 extends LivingRenderer> { - public static final Factory FACTORY = new Factory(); + public static final Factory FACTORY = new Factory<>(); - public RenderTest3(RenderManager manager) { - super(manager, new ModelCraftStudio(Mod_Test.MODID, "dragon_brun", 256), 0.5F); + public RenderTest3(EntityRendererManager manager) { + super(manager, new ModelCraftStudio(ModTest.MODID, "dragon_brun", 256), 0.5F); } @Override protected ResourceLocation getEntityTexture(T entity) { - return new ResourceLocation(Mod_Test.MODID, "textures/entity/dragon_brun.png"); + return new ResourceLocation(ModTest.MODID, "textures/entity/dragon_brun.png"); } public static class Factory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) { - return new RenderTest3(manager); + public EntityRenderer createRenderFor(EntityRendererManager manager) { + return new RenderTest3(manager); } } } diff --git a/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest4.java b/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest4.java index 0e3a233..a83d906 100644 --- a/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest4.java +++ b/src/mod/java/com/leviathanstudio/test/client/entityRender/RenderTest4.java @@ -1,34 +1,34 @@ package com.leviathanstudio.test.client.entityRender; import com.leviathanstudio.craftstudio.client.model.ModelCraftStudio; -import com.leviathanstudio.test.common.Mod_Test; +import com.leviathanstudio.test.common.ModTest; import com.leviathanstudio.test.common.entity.EntityTest4; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderLiving; -import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.client.renderer.entity.EntityRendererManager; +import net.minecraft.client.renderer.entity.LivingRenderer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.registry.IRenderFactory; -public class RenderTest4 extends RenderLiving +public class RenderTest4 extends LivingRenderer> { - public static final Factory FACTORY = new Factory(); + public static final Factory FACTORY = new Factory<>(); - public RenderTest4(RenderManager manager) { - super(manager, new ModelCraftStudio(Mod_Test.MODID, "craftstudio_api_test2", 64, 32), 0.5F); + public RenderTest4(EntityRendererManager manager) { + super(manager, new ModelCraftStudio(ModTest.MODID, "craftstudio_api_test2", 64, 32), 0.5F); } @Override protected ResourceLocation getEntityTexture(T entity) { - return new ResourceLocation(Mod_Test.MODID, "textures/entity/craftstudio_api_test.png"); + return new ResourceLocation(ModTest.MODID, "textures/entity/craftstudio_api_test.png"); } public static class Factory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) { - return new RenderTest4(manager); + public EntityRenderer createRenderFor(EntityRendererManager manager) { + return new RenderTest4(manager); } } diff --git a/src/mod/java/com/leviathanstudio/test/common/ModTest.java b/src/mod/java/com/leviathanstudio/test/common/ModTest.java new file mode 100644 index 0000000..3721dd3 --- /dev/null +++ b/src/mod/java/com/leviathanstudio/test/common/ModTest.java @@ -0,0 +1,29 @@ +package com.leviathanstudio.test.common; + +import com.leviathanstudio.test.proxy.*; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; + +@Mod(ModTest.MODID) +public class ModTest +{ + public static final String MODID = "testmod"; + + public static final CommonProxy PROXY = DistExecutor.runForDist(() -> ClientProxy::new, () -> CommonProxy::new); + + public ModTest( ) { + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup); + + MinecraftForge.EVENT_BUS.register(PROXY); + } + + public void clientSetup(FMLClientSetupEvent event) { + ModTest.PROXY.registerCraftStudioAssets(); + ModTest.PROXY.bindTESR(); + } + +} \ No newline at end of file diff --git a/src/mod/java/com/leviathanstudio/test/common/Mod_Test.java b/src/mod/java/com/leviathanstudio/test/common/Mod_Test.java deleted file mode 100644 index 030be2d..0000000 --- a/src/mod/java/com/leviathanstudio/test/common/Mod_Test.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.leviathanstudio.test.common; - -import com.leviathanstudio.test.proxy.CommonProxy; - -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.Instance; -import net.minecraftforge.fml.common.SidedProxy; - -@Mod(name = "TestMod", modid = Mod_Test.MODID) -public class Mod_Test -{ - public static final String MODID = "testmod"; - - @SidedProxy(clientSide = "com.leviathanstudio.test.proxy.ClientProxy", serverSide = "com.leviathanstudio.test.proxy.CommonProxy") - private static CommonProxy proxy; - - @Instance(Mod_Test.MODID) - private static Mod_Test instance; - - public static Mod_Test getInstance() { - return instance; - } - - public static CommonProxy getProxy() { - return proxy; - } -} \ No newline at end of file diff --git a/src/mod/java/com/leviathanstudio/test/common/RegistryHandler.java b/src/mod/java/com/leviathanstudio/test/common/RegistryHandler.java index 36618b8..b10c8ff 100644 --- a/src/mod/java/com/leviathanstudio/test/common/RegistryHandler.java +++ b/src/mod/java/com/leviathanstudio/test/common/RegistryHandler.java @@ -1,7 +1,5 @@ package com.leviathanstudio.test.common; -import java.awt.Color; - import com.leviathanstudio.test.common.block.BlockTest; import com.leviathanstudio.test.common.entity.EntityTest; import com.leviathanstudio.test.common.entity.EntityTest2; @@ -9,48 +7,79 @@ import com.leviathanstudio.test.common.entity.EntityTest4; import com.leviathanstudio.test.common.item.ItemTest; import com.leviathanstudio.test.common.tileEntity.TileEntityTest; +import com.mojang.datafixers.DataFixUtils; +import com.mojang.datafixers.types.Type; import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityClassification; +import net.minecraft.entity.EntityType; +import net.minecraft.item.BlockItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.util.ResourceLocation; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityType; +import net.minecraft.util.SharedConstants; +import net.minecraft.util.datafix.DataFixesManager; +import net.minecraft.util.datafix.TypeReferences; import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.registry.EntityEntry; -import net.minecraftforge.fml.common.registry.EntityRegistry; -import net.minecraftforge.fml.common.registry.GameRegistry; -import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; - -@EventBusSubscriber(modid = Mod_Test.MODID) -@ObjectHolder(Mod_Test.MODID) +import net.minecraftforge.registries.ObjectHolder; + +@EventBusSubscriber(modid = ModTest.MODID, bus = EventBusSubscriber.Bus.MOD) public class RegistryHandler { - public static final Block block_test = null; - + public static final Block block_test = new BlockTest(Block.Properties.create(Material.ROCK)); + public static final TileEntityType tile_test = register("tileTest", TileEntityType.Builder.create(TileEntityTest::new, block_test)); + @SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { - event.getRegistry().register(new BlockTest()); - GameRegistry.registerTileEntity(TileEntityTest.class, "tile_entity_test"); + event.getRegistry().register(block_test.setRegistryName("block_test")); + } + + @SubscribeEvent + public static void registerTiles(RegistryEvent.Register> event) { + event.getRegistry().register(tile_test.setRegistryName("tile_test")); } @SubscribeEvent public static void registerItem(RegistryEvent.Register event) { - event.getRegistry().register(new ItemBlock(block_test).setRegistryName("item_block_test")); - event.getRegistry().register(new ItemTest().setRegistryName("item_test")); + event.getRegistry().register(new BlockItem(block_test, (new Item.Properties())).setRegistryName("block_test")); + event.getRegistry().register(new ItemTest(new Item.Properties()).setRegistryName("item_test")); } @SubscribeEvent - public static void registerEntities(RegistryEvent.Register event) { - EntityRegistry.registerModEntity(new ResourceLocation("testmod", "entityTest"), EntityTest.class, "entityTest", 420, Mod_Test.getInstance(), - 40, 1, true, new Color(0, 255, 0).getRGB(), new Color(255, 0, 0).getRGB()); - EntityRegistry.registerModEntity(new ResourceLocation("testmod", "entityTest2"), EntityTest2.class, "entityTest2", 421, - Mod_Test.getInstance(), 40, 1, true, new Color(255, 0, 0).getRGB(), new Color(0, 0, 0).getRGB()); - EntityRegistry.registerModEntity(new ResourceLocation("testmod", "entityTest3"), EntityTest3.class, "entityTest3", 422, - Mod_Test.getInstance(), 40, 1, true, new Color(0, 0, 255).getRGB(), new Color(0, 0, 0).getRGB()); - EntityRegistry.registerModEntity(new ResourceLocation("testmod", "entityTest4"), EntityTest4.class, "entityTest4", 423, - Mod_Test.getInstance(), 40, 1, true, new Color(255, 255, 0).getRGB(), new Color(0, 0, 0).getRGB()); - Mod_Test.getProxy().registerEntityRender(); - Mod_Test.getProxy().bindTESR(); + public static void registerEntities(RegistryEvent.Register> event) { + EntityType entityTest = EntityType.Builder.create(EntityTest::new, EntityClassification.MISC).build("entityTest"); + EntityType entityTest2 = EntityType.Builder.create(EntityTest2::new, EntityClassification.MISC).build("entityTest2"); + EntityType entityTest3 = EntityType.Builder.create(EntityTest3::new, EntityClassification.MISC).build("entityTest3"); + EntityType entityTest4 = EntityType.Builder.create(EntityTest4::new, EntityClassification.MISC).build("entityTest4"); + + + event.getRegistry().register(entityTest.setRegistryName("test_1")); + event.getRegistry().register(entityTest2.setRegistryName("test_2")); + event.getRegistry().register(entityTest3.setRegistryName("test_3")); + event.getRegistry().register(entityTest4.setRegistryName("test_4")); + + ModTest.PROXY.registerEntityRender(); + + } + + private static TileEntityType register(String id, TileEntityType.Builder builder) { + Type type = null; + + try { + type = DataFixesManager.getDataFixer().getSchema(DataFixUtils.makeKey(1631)).getChoiceType(TypeReferences.BLOCK_ENTITY, ModTest.MODID + ":" + id); + } + catch(IllegalArgumentException e) { + if(SharedConstants.developmentMode) { + throw e; + } + } + + TileEntityType tileEntityType = builder.build(type); + + return tileEntityType; } + } diff --git a/src/mod/java/com/leviathanstudio/test/common/block/BlockTest.java b/src/mod/java/com/leviathanstudio/test/common/block/BlockTest.java index aa860e9..7d3dcde 100644 --- a/src/mod/java/com/leviathanstudio/test/common/block/BlockTest.java +++ b/src/mod/java/com/leviathanstudio/test/common/block/BlockTest.java @@ -3,40 +3,43 @@ import com.leviathanstudio.test.common.tileEntity.TileEntityTest; import net.minecraft.block.Block; +import net.minecraft.block.BlockRenderType; +import net.minecraft.block.BlockState; +import net.minecraft.block.ChestBlock; import net.minecraft.block.ITileEntityProvider; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.util.EnumBlockRenderType; -import net.minecraft.world.World; +import net.minecraft.tileentity.ChestTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockReader; -public class BlockTest extends Block implements ITileEntityProvider +public class BlockTest extends Block { - public BlockTest() { - super(Material.ROCK); - this.setRegistryName("block_test").setUnlocalizedName("block_test"); - this.setCreativeTab(CreativeTabs.MISC); - } + public BlockTest(Block.Properties props) { + super(props); - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; } - @Override - public boolean isFullCube(IBlockState state) { - return false; - } + @Override - public EnumBlockRenderType getRenderType(IBlockState state) { - return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; - } + public BlockRenderType getRenderType(BlockState state) { + return BlockRenderType.INVISIBLE; + } - @Override - public TileEntityTest createNewTileEntity(World worldIn, int meta) { - return new TileEntityTest(worldIn); - } + + + @Override + public boolean hasTileEntity(BlockState state) { + return true; + } + + + @Override + public TileEntity createTileEntity(BlockState state, IBlockReader world) { + return new TileEntityTest(); + } + + + } \ No newline at end of file diff --git a/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest.java b/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest.java index 400dbf5..b48fba7 100644 --- a/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest.java +++ b/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest.java @@ -3,34 +3,37 @@ import com.leviathanstudio.craftstudio.CraftStudioApi; import com.leviathanstudio.craftstudio.common.animation.AnimationHandler; import com.leviathanstudio.craftstudio.common.animation.simpleImpl.AnimatedEntity; -import com.leviathanstudio.test.common.Mod_Test; +import com.leviathanstudio.test.common.ModTest; +import net.minecraft.entity.CreatureEntity; +import net.minecraft.entity.EntityType; import net.minecraft.world.World; public class EntityTest extends AnimatedEntity { - protected static AnimationHandler animHandler = CraftStudioApi.getNewAnimationHandler(EntityTest.class); + protected static AnimationHandler animHandler = CraftStudioApi.getNewAnimationHandler(EntityTest.class); static { - EntityTest.animHandler.addAnim(Mod_Test.MODID, "position", "craftstudio_api_test", true); - EntityTest.animHandler.addAnim(Mod_Test.MODID, "offset", "craftstudio_api_test", true); - EntityTest.animHandler.addAnim(Mod_Test.MODID, "streching", "craftstudio_api_test", true); + EntityTest.animHandler.addAnim(ModTest.MODID, "position", "craftstudio_api_test", true); + EntityTest.animHandler.addAnim(ModTest.MODID, "offset", "craftstudio_api_test", true); + EntityTest.animHandler.addAnim(ModTest.MODID, "streching", "craftstudio_api_test", true); } - - public EntityTest(World par1World) { - super(par1World); + + public EntityTest(EntityType type, World par1World) { + super(type, par1World); } - @Override - public AnimationHandler getAnimationHandler() { + @SuppressWarnings("unchecked") + @Override + public AnimationHandler getAnimationHandler() { return EntityTest.animHandler; } @Override - public void onLivingUpdate() { - super.onLivingUpdate(); + public void livingTick() { + super.livingTick(); - if (this.isWorldRemote() && !this.getAnimationHandler().isAnimationActive(Mod_Test.MODID, "streching", this)) - this.getAnimationHandler().startAnimation(Mod_Test.MODID, "streching", this); + if (this.isWorldRemote() && !this.getAnimationHandler().isAnimationActive(ModTest.MODID, "streching", this)) + this.getAnimationHandler().startAnimation(ModTest.MODID, "streching", this); } } \ No newline at end of file diff --git a/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest2.java b/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest2.java index f2eac0b..36d4c03 100644 --- a/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest2.java +++ b/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest2.java @@ -3,80 +3,84 @@ import com.leviathanstudio.craftstudio.CraftStudioApi; import com.leviathanstudio.craftstudio.common.animation.AnimationHandler; import com.leviathanstudio.craftstudio.common.animation.IAnimated; -import com.leviathanstudio.test.common.Mod_Test; +import com.leviathanstudio.test.common.ModTest; import com.leviathanstudio.test.pack.animation.AnimationLootAt; -import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.AgeableEntity; +import net.minecraft.entity.EntityType; import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.EntityAILookIdle; -import net.minecraft.entity.ai.EntityAIWatchClosest; -import net.minecraft.entity.passive.EntityAnimal; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.EnumHand; +import net.minecraft.entity.ai.goal.LookAtGoal; +import net.minecraft.entity.passive.AnimalEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.Hand; import net.minecraft.world.World; +import net.minecraft.world.dimension.DimensionType; -public class EntityTest2 extends EntityAnimal implements IAnimated +public class EntityTest2 extends AnimalEntity implements IAnimated { - protected static AnimationHandler animHandler = CraftStudioApi.getNewAnimationHandler(EntityTest2.class); + protected static AnimationHandler animHandler = CraftStudioApi.getNewAnimationHandler(EntityTest2.class); protected boolean fanOpen = true; static { - EntityTest2.animHandler.addAnim(Mod_Test.MODID, "close_fan", "peacock", false); - EntityTest2.animHandler.addAnim(Mod_Test.MODID, "open_fan", "close_fan"); - EntityTest2.animHandler.addAnim(Mod_Test.MODID, "lookat", new AnimationLootAt("Head")); + EntityTest2.animHandler.addAnim(ModTest.MODID, "close_fan", "peacock", false); + EntityTest2.animHandler.addAnim(ModTest.MODID, "open_fan", "close_fan"); + EntityTest2.animHandler.addAnim(ModTest.MODID, "lookat", new AnimationLootAt("Head")); } - public EntityTest2(World par1World) { - super(par1World); - this.setSize(1.0F, 1.5F); - this.tasks.addTask(1, new EntityAILookIdle(this)); - this.tasks.addTask(2, new EntityAIWatchClosest(this, EntityPlayer.class, 10)); - this.initEntityAI(); + public EntityTest2(EntityType type, World par1World) { + super(type, par1World); + this.stepHeight = 1.5F; } - + @Override - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(4.0D); - this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D); + protected void registerGoals() { + this.goalSelector.addGoal(2, new LookAtGoal(this, PlayerEntity.class, 10)); } @Override - public AnimationHandler getAnimationHandler() { + protected void registerAttributes() { + super.registerAttributes(); + this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(4.0D); + this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D); + } + + @SuppressWarnings("unchecked") + @Override + public AnimationHandler getAnimationHandler() { return EntityTest2.animHandler; } @Override - public boolean processInteract(EntityPlayer player, EnumHand hand) { - if (!this.getAnimationHandler().isAnimationActive(Mod_Test.MODID, "close_fan", this) - && !this.getAnimationHandler().isAnimationActive(Mod_Test.MODID, "open_fan", this)) + public boolean processInteract(PlayerEntity player, Hand hand) { + if (!this.getAnimationHandler().isAnimationActive(ModTest.MODID, "close_fan", this) + && !this.getAnimationHandler().isAnimationActive(ModTest.MODID, "open_fan", this)) if (this.fanOpen) { - this.getAnimationHandler().networkStopStartAnimation(Mod_Test.MODID, "open_fan", "close_fan", this); + this.getAnimationHandler().networkStopStartAnimation(ModTest.MODID, "open_fan", "close_fan", this); this.fanOpen = false; } else { - this.getAnimationHandler().networkStopStartAnimation(Mod_Test.MODID, "close_fan", "open_fan", this); + this.getAnimationHandler().networkStopStartAnimation(ModTest.MODID, "close_fan", "open_fan", this); this.fanOpen = true; } return true; } @Override - public void onLivingUpdate() { - super.onLivingUpdate(); + public void livingTick() { + super.livingTick(); this.getAnimationHandler().animationsUpdate(this); - if (this.isWorldRemote() && !this.getAnimationHandler().isAnimationActive(Mod_Test.MODID, "lookat", this)) - this.getAnimationHandler().startAnimation(Mod_Test.MODID, "lookat", this); + if (this.isWorldRemote() && !this.getAnimationHandler().isAnimationActive(ModTest.MODID, "lookat", this)) + this.getAnimationHandler().startAnimation(ModTest.MODID, "lookat", this); } @Override - public EntityAgeable createChild(EntityAgeable ageable) { + public AgeableEntity createChild(AgeableEntity ageable) { return null; } @Override - public int getDimension() { + public DimensionType getDimension() { return this.dimension; } diff --git a/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest3.java b/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest3.java index fddad0e..8850157 100644 --- a/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest3.java +++ b/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest3.java @@ -3,44 +3,46 @@ import com.leviathanstudio.craftstudio.CraftStudioApi; import com.leviathanstudio.craftstudio.common.animation.AnimationHandler; import com.leviathanstudio.craftstudio.common.animation.simpleImpl.AnimatedEntity; -import com.leviathanstudio.test.common.Mod_Test; +import com.leviathanstudio.test.common.ModTest; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.EnumHand; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.Hand; import net.minecraft.world.World; public class EntityTest3 extends AnimatedEntity { - protected static AnimationHandler animHandler = CraftStudioApi.getNewAnimationHandler(EntityTest3.class); + protected static AnimationHandler animHandler = CraftStudioApi.getNewAnimationHandler(EntityTest3.class); boolean fly = false; static { - EntityTest3.animHandler.addAnim(Mod_Test.MODID, "fly", "dragon_brun", true); - EntityTest3.animHandler.addAnim(Mod_Test.MODID, "idle", "dragon_brun", true); + EntityTest3.animHandler.addAnim(ModTest.MODID, "fly", "dragon_brun", true); + EntityTest3.animHandler.addAnim(ModTest.MODID, "idle", "dragon_brun", true); } - public EntityTest3(World par1World) { - super(par1World); + public EntityTest3(EntityType type, World par1World) { + super(type, par1World); } - @Override - public AnimationHandler getAnimationHandler() { + @SuppressWarnings("unchecked") + @Override + public AnimationHandler getAnimationHandler() { return EntityTest3.animHandler; } @Override - public boolean processInteract(EntityPlayer player, EnumHand hand) { + public boolean processInteract(PlayerEntity player, Hand hand) { if (!this.fly) this.fly = true; return true; } @Override - public void onLivingUpdate() { - super.onLivingUpdate(); + public void livingTick() { + super.livingTick(); - if (!this.getAnimationHandler().isAnimationActive(Mod_Test.MODID, "fly", this) && this.fly) - this.getAnimationHandler().networkStartAnimation(Mod_Test.MODID, "fly", this); + if (!this.getAnimationHandler().isAnimationActive(ModTest.MODID, "fly", this) && this.fly) + this.getAnimationHandler().networkStartAnimation(ModTest.MODID, "fly", this); } } diff --git a/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest4.java b/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest4.java index 1116510..4866388 100644 --- a/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest4.java +++ b/src/mod/java/com/leviathanstudio/test/common/entity/EntityTest4.java @@ -3,32 +3,34 @@ import com.leviathanstudio.craftstudio.CraftStudioApi; import com.leviathanstudio.craftstudio.common.animation.AnimationHandler; import com.leviathanstudio.craftstudio.common.animation.simpleImpl.AnimatedEntity; -import com.leviathanstudio.test.common.Mod_Test; +import com.leviathanstudio.test.common.ModTest; +import net.minecraft.entity.EntityType; import net.minecraft.world.World; public class EntityTest4 extends AnimatedEntity { - protected static AnimationHandler animHandler = CraftStudioApi.getNewAnimationHandler(EntityTest4.class); + protected static AnimationHandler animHandler = CraftStudioApi.getNewAnimationHandler(EntityTest4.class); static { - EntityTest4.animHandler.addAnim(Mod_Test.MODID, "rotation", "craftstudio_api_test2", true); + EntityTest4.animHandler.addAnim(ModTest.MODID, "rotation", "craftstudio_api_test2", true); } - public EntityTest4(World par1World) { - super(par1World); + public EntityTest4(EntityType type, World par1World) { + super(type, par1World); } - @Override - public AnimationHandler getAnimationHandler() { + @SuppressWarnings("unchecked") + @Override + public AnimationHandler getAnimationHandler() { return EntityTest4.animHandler; } @Override - public void onLivingUpdate() { - super.onLivingUpdate(); + public void livingTick() { + super.livingTick(); - if (this.isWorldRemote() && !this.getAnimationHandler().isAnimationActive(Mod_Test.MODID, "rotation", this)) - this.getAnimationHandler().startAnimation(Mod_Test.MODID, "rotation", this); + if (this.isWorldRemote() && !this.getAnimationHandler().isAnimationActive(ModTest.MODID, "rotation", this)) + this.getAnimationHandler().startAnimation(ModTest.MODID, "rotation", this); } } diff --git a/src/mod/java/com/leviathanstudio/test/common/item/ItemTest.java b/src/mod/java/com/leviathanstudio/test/common/item/ItemTest.java index 561a5ac..587e72a 100644 --- a/src/mod/java/com/leviathanstudio/test/common/item/ItemTest.java +++ b/src/mod/java/com/leviathanstudio/test/common/item/ItemTest.java @@ -1,14 +1,14 @@ package com.leviathanstudio.test.common.item; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; public class ItemTest extends Item { - public ItemTest() { - this.setUnlocalizedName("itemTest"); - this.setCreativeTab(CreativeTabs.MISC); - } + public ItemTest(Properties properties) { + super(properties); + } + + } \ No newline at end of file diff --git a/src/mod/java/com/leviathanstudio/test/common/tileEntity/TileEntityTest.java b/src/mod/java/com/leviathanstudio/test/common/tileEntity/TileEntityTest.java index 141499e..83f0924 100644 --- a/src/mod/java/com/leviathanstudio/test/common/tileEntity/TileEntityTest.java +++ b/src/mod/java/com/leviathanstudio/test/common/tileEntity/TileEntityTest.java @@ -3,38 +3,45 @@ import com.leviathanstudio.craftstudio.CraftStudioApi; import com.leviathanstudio.craftstudio.common.animation.AnimationHandler; import com.leviathanstudio.craftstudio.common.animation.simpleImpl.AnimatedTileEntity; -import com.leviathanstudio.test.common.Mod_Test; +import com.leviathanstudio.test.common.ModTest; +import com.leviathanstudio.test.common.RegistryHandler; +import net.minecraft.tileentity.TileEntityType; import net.minecraft.world.World; public class TileEntityTest extends AnimatedTileEntity { - protected static AnimationHandler animHandler = CraftStudioApi.getNewAnimationHandler(TileEntityTest.class); + protected static AnimationHandler animHandler = CraftStudioApi.getNewAnimationHandler(TileEntityTest.class); static { - TileEntityTest.animHandler.addAnim(Mod_Test.MODID, "position", "craftstudio_api_test", true); + TileEntityTest.animHandler.addAnim(ModTest.MODID, "position", "craftstudio_api_test", true); } + public TileEntityTest(TileEntityType tileEntityTypeIn) { + super(tileEntityTypeIn); + } + public TileEntityTest() { - super(); + super(RegistryHandler.tile_test); } public TileEntityTest(World worldIn) { - this(); + super(RegistryHandler.tile_test); this.world = worldIn; } - @Override - public AnimationHandler getAnimationHandler() { + @SuppressWarnings("unchecked") + @Override + public AnimationHandler getAnimationHandler() { return TileEntityTest.animHandler; } @Override - public void update() { - super.update(); + public void tick() { + super.tick(); - if (this.isWorldRemote() && !this.getAnimationHandler().isAnimationActive(Mod_Test.MODID, "position", this)) - this.getAnimationHandler().startAnimation(Mod_Test.MODID, "position", this); + if (this.isWorldRemote() && !this.getAnimationHandler().isAnimationActive(ModTest.MODID, "position", this)) + this.getAnimationHandler().startAnimation(ModTest.MODID, "position", this); } } \ No newline at end of file diff --git a/src/mod/java/com/leviathanstudio/test/pack/animation/AnimationLootAt.java b/src/mod/java/com/leviathanstudio/test/pack/animation/AnimationLootAt.java index f703152..e334c3e 100644 --- a/src/mod/java/com/leviathanstudio/test/pack/animation/AnimationLootAt.java +++ b/src/mod/java/com/leviathanstudio/test/pack/animation/AnimationLootAt.java @@ -7,32 +7,31 @@ import com.leviathanstudio.craftstudio.common.animation.CustomChannel; import com.leviathanstudio.craftstudio.common.animation.IAnimated; -import net.minecraft.entity.EntityLiving; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.entity.LivingEntity; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; -public class AnimationLootAt extends CustomChannel -{ - private String headPart; +public class AnimationLootAt extends CustomChannel { + private String headPart; - public AnimationLootAt(String headPartIn) { - super("lookat"); - this.headPart = headPartIn; - } + public AnimationLootAt(String headPartIn) { + super("lookat"); + this.headPart = headPartIn; + } - @Override - @SideOnly(Side.CLIENT) - public void update(CSModelRenderer parts, IAnimated animated) { - if (animated instanceof EntityLiving) - if (parts.boxName.equals(this.headPart)) { - EntityLiving entityL = (EntityLiving) animated; - float diff = entityL.getRotationYawHead() - entityL.renderYawOffset; - Quat4f quat = MathHelper.quatFromEuler(entityL.rotationPitch, 0.0F, diff); - Quat4f quat2 = new Quat4f(parts.getDefaultRotationAsQuaternion()); - quat.mul(quat2); - parts.getRotationMatrix().set(quat); - parts.getRotationMatrix().transpose(); - } - } + @Override + @OnlyIn(Dist.CLIENT) + public void update(CSModelRenderer parts, IAnimated animated) { + if (animated instanceof LivingEntity) + if (parts.boxName.equals(this.headPart)) { + LivingEntity entityL = (LivingEntity) animated; + float diff = entityL.getRotationYawHead() - entityL.renderYawOffset; + Quat4f quat = MathHelper.quatFromEuler(entityL.rotationPitch, 0.0F, diff); + Quat4f quat2 = new Quat4f(parts.getDefaultRotationAsQuaternion()); + quat.mul(quat2); + parts.getRotationMatrix().set(quat); + parts.getRotationMatrix().transpose(); + } + } } \ No newline at end of file diff --git a/src/mod/java/com/leviathanstudio/test/proxy/ClientProxy.java b/src/mod/java/com/leviathanstudio/test/proxy/ClientProxy.java index 1243499..e773a9a 100644 --- a/src/mod/java/com/leviathanstudio/test/proxy/ClientProxy.java +++ b/src/mod/java/com/leviathanstudio/test/proxy/ClientProxy.java @@ -1,7 +1,6 @@ package com.leviathanstudio.test.proxy; import com.leviathanstudio.craftstudio.client.registry.CSRegistryHelper; -import com.leviathanstudio.craftstudio.client.registry.CraftStudioLoader; import com.leviathanstudio.craftstudio.client.util.EnumRenderType; import com.leviathanstudio.craftstudio.client.util.EnumResourceType; import com.leviathanstudio.craftstudio.common.animation.simpleImpl.CSTileEntitySpecialRenderer; @@ -9,7 +8,7 @@ import com.leviathanstudio.test.client.entityRender.RenderTest2; import com.leviathanstudio.test.client.entityRender.RenderTest3; import com.leviathanstudio.test.client.entityRender.RenderTest4; -import com.leviathanstudio.test.common.Mod_Test; +import com.leviathanstudio.test.common.ModTest; import com.leviathanstudio.test.common.entity.EntityTest; import com.leviathanstudio.test.common.entity.EntityTest2; import com.leviathanstudio.test.common.entity.EntityTest3; @@ -22,15 +21,14 @@ public class ClientProxy extends CommonProxy { - @CraftStudioLoader - public static void registerCraftStudioAssets() { - CSRegistryHelper registry = new CSRegistryHelper(Mod_Test.MODID); - registry.register(EnumResourceType.MODEL, EnumRenderType.ENTITY, "model_dead_corpse"); + public void registerCraftStudioAssets() { + CSRegistryHelper registry = new CSRegistryHelper(ModTest.MODID); registry.register(EnumResourceType.MODEL, EnumRenderType.BLOCK, "craftstudio_api_test2"); registry.register(EnumResourceType.MODEL, EnumRenderType.BLOCK, "craftstudio_api_test"); + registry.register(EnumResourceType.MODEL, EnumRenderType.ENTITY, "model_dead_corpse"); registry.register(EnumResourceType.MODEL, EnumRenderType.ENTITY, "dragon_brun"); registry.register(EnumResourceType.MODEL, EnumRenderType.ENTITY, "peacock"); - + registry.register(EnumResourceType.ANIM, EnumRenderType.BLOCK, "position"); registry.register(EnumResourceType.ANIM, EnumRenderType.BLOCK, "rotation"); registry.register(EnumResourceType.ANIM, EnumRenderType.BLOCK, "offset"); @@ -50,7 +48,7 @@ public void registerEntityRender() { @Override public void bindTESR() { - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTest.class, new CSTileEntitySpecialRenderer(Mod_Test.MODID, "craftstudio_api_test", 64, - 32, new ResourceLocation(Mod_Test.MODID, "textures/entity/craftstudio_api_test.png"))); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTest.class, new CSTileEntitySpecialRenderer(ModTest.MODID, "craftstudio_api_test", 64, + 32, new ResourceLocation(ModTest.MODID, "textures/entity/craftstudio_api_test.png"))); } } \ No newline at end of file diff --git a/src/mod/java/com/leviathanstudio/test/proxy/CommonProxy.java b/src/mod/java/com/leviathanstudio/test/proxy/CommonProxy.java index 30493a0..d9a7f3d 100644 --- a/src/mod/java/com/leviathanstudio/test/proxy/CommonProxy.java +++ b/src/mod/java/com/leviathanstudio/test/proxy/CommonProxy.java @@ -2,6 +2,8 @@ public class CommonProxy { + public void registerCraftStudioAssets() {} + public void registerEntityRender() {} public void bindTESR() {} diff --git a/src/mod/resources/META-INF/mods.toml b/src/mod/resources/META-INF/mods.toml new file mode 100644 index 0000000..2f55dc8 --- /dev/null +++ b/src/mod/resources/META-INF/mods.toml @@ -0,0 +1,33 @@ + +modLoader="javafml" #mandatory +loaderVersion="[28,)" #mandatory (26 is current forge version) +issueTrackerURL="https://github.com/Leviathan-Studio/CraftStudioAPI" #optional +[[mods]] #mandatory +modId="testmod" #mandatory +version="${file.jarVersion}" #mandatory +displayName="CraftStudio API Test mod" #mandatory +updateJSONURL="https://leviathan-studio.com/craftstudioapi/update.json" #optional +#displayURL="http://example.com/" #optional +#logoFile="examplemod.png" #optional +credits="See https://github.com/Leviathan-Studio/CraftStudioAPI/blob/master/CREDITS.md" #optional +authors="ZeAmateis, Timmypote, Elisee, IncubeSupreme, Phenix246" #optional +description='''A CraftStudio API Test mod''' + +[[dependencies.testmod]] #optional + modId="forge" #mandatory + mandatory=true #mandatory + versionRange="[28,)" #mandatory + ordering="NONE" + side="BOTH" +[[dependencies.testmod]] + modId="minecraft" + mandatory=true + versionRange="[1.14.4]" + ordering="NONE" + side="BOTH" +[[dependencies.testmod]] + modId="craftstudioapi" + mandatory=true + versionRange="NONE" + ordering="NONE" + side="CLIENT" \ No newline at end of file diff --git a/src/mod/resources/pack.mcmeta b/src/mod/resources/pack.mcmeta new file mode 100644 index 0000000..b7fadad --- /dev/null +++ b/src/mod/resources/pack.mcmeta @@ -0,0 +1,7 @@ +{ + "pack": { + "description": "craftstudio api test mod resources", + "pack_format": 4, + "_comment": "A pack_format of 4 requires json lang files. Note: we require v4 pack meta for all mods." + } +}