mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 11:16:02 +00:00
Animation overhaul, along with animation changes to the API.
This commit is contained in:
1 parent
bda76bafe6
commit
be18e756fc
23 files changed
+648
-1229
No files matched your search
@@ -3,7 +3,7 @@ package noppes.npcs.client;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import noppes.npcs.AnimationDataShared;
|
||||
import noppes.npcs.AnimationData;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.gui.OverlayQuestTracking;
|
||||
@@ -19,7 +19,7 @@ public class Client {
|
||||
public static OverlayQuestTracking questTrackingOverlay = null;
|
||||
public static HashMap<Integer, OverlayCustom> customOverlays = new HashMap<>();
|
||||
public static HashMap<UUID, HashMap<Integer, SkinOverlay>> skinOverlays = new HashMap<>();
|
||||
public static HashMap<UUID, AnimationDataShared> playerModelData = new HashMap<>();
|
||||
public static HashMap<UUID, AnimationData> playerAnimations = new HashMap<>();
|
||||
|
||||
public static void sendData(EnumPacketServer enu, Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
|
||||
@@ -6,8 +6,11 @@ import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.client.event.*;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import noppes.npcs.AnimationData;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
import noppes.npcs.client.renderer.RenderCNPCPlayer;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -70,8 +73,36 @@ public class ClientEventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderEntity(RenderLivingEvent.Post event) {
|
||||
AnimationData data = null;
|
||||
if (event.entity instanceof EntityNPCInterface) {
|
||||
ClientEventHandler.renderingNpc = null;
|
||||
data = ClientEventHandler.renderingNpc.display.animationData;
|
||||
} else if (event.entity instanceof EntityPlayer && Client.playerAnimations.containsKey(event.entity.getUniqueID())) {
|
||||
data = Client.playerAnimations.get(event.entity.getUniqueID());
|
||||
}
|
||||
|
||||
if (data != null && data.isActive()) {
|
||||
Animation animation = data.animation;
|
||||
if (animation.renderTicks && data.isActive()) {
|
||||
animation.increaseTime();
|
||||
}
|
||||
}
|
||||
ClientEventHandler.renderingNpc = null;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onUpdateEntity(LivingEvent.LivingUpdateEvent event) {
|
||||
AnimationData data = null;
|
||||
if (event.entity instanceof EntityNPCInterface) {
|
||||
data = ((EntityNPCInterface)event.entity).display.animationData;
|
||||
} else if (event.entity instanceof EntityPlayer && Client.playerAnimations.containsKey(event.entity.getUniqueID())) {
|
||||
data = Client.playerAnimations.get(event.entity.getUniqueID());
|
||||
}
|
||||
|
||||
if (data != null && data.isActive()) {
|
||||
Animation animation = data.animation;
|
||||
if (!animation.renderTicks && data.isActive()) {
|
||||
animation.increaseTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.AnimationDataShared;
|
||||
import noppes.npcs.AnimationData;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.fx.CustomFX;
|
||||
@@ -88,19 +88,6 @@ public class NoppesUtil {
|
||||
Client.skinOverlays.put(player.getUniqueID(), skinOverlays);
|
||||
}
|
||||
|
||||
public static void updatePlayerModelData(EntityPlayer player, NBTTagCompound compound) {
|
||||
AnimationDataShared data;
|
||||
if (!Client.playerModelData.containsKey(player.getUniqueID())) {
|
||||
data = new AnimationDataShared(null);
|
||||
data.readFromNBT(compound);
|
||||
data.modelRotations = new float[]{data.rotationX, data.rotationY, data.rotationZ};
|
||||
} else {
|
||||
data = Client.playerModelData.get(player.getUniqueID());
|
||||
data.readFromNBT(compound);
|
||||
}
|
||||
Client.playerModelData.put(player.getUniqueID(), data);
|
||||
}
|
||||
|
||||
public static void spawnScriptedParticle(EntityPlayer player, ByteBuf buffer){
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import noppes.npcs.config.ConfigClient;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.controllers.RecipeController;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.RecipeCarpentry;
|
||||
import noppes.npcs.entity.EntityDialogNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
@@ -289,11 +290,31 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
NoppesUtil.updateSkinOverlayData(sendingPlayer, compound);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketClient.PLAYER_UPDATE_MODEL_DATA) {
|
||||
EntityPlayer sendingPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(Server.readString(buffer));
|
||||
else if(type == EnumPacketClient.UPDATE_ANIMATIONS) {
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
if (sendingPlayer != null) {
|
||||
NoppesUtil.updatePlayerModelData(sendingPlayer, compound);
|
||||
if (compound.hasKey("EntityId")) {
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(compound.getInteger("EntityId"));
|
||||
if (entity instanceof EntityNPCInterface) {
|
||||
AnimationData data = ((EntityNPCInterface) entity).display.animationData;
|
||||
data.readFromNBT(compound);
|
||||
if (data.animation == null) {
|
||||
data.animation = new Animation();
|
||||
}
|
||||
data.animation.readFromNBT(compound.getCompoundTag("Animation"));
|
||||
}
|
||||
} else {
|
||||
EntityPlayer sendingPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(Server.readString(buffer));
|
||||
if (sendingPlayer != null) {
|
||||
AnimationData data;
|
||||
if (!Client.playerAnimations.containsKey(player.getUniqueID())) {
|
||||
data = new AnimationData(player);
|
||||
data.readFromNBT(compound.getCompoundTag("Animation"));
|
||||
} else {
|
||||
data = Client.playerAnimations.get(player.getUniqueID());
|
||||
data.readFromNBT(compound.getCompoundTag("Animation"));
|
||||
}
|
||||
Client.playerAnimations.put(player.getUniqueID(), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketClient.DISABLE_MOUSE_INPUT) {
|
||||
|
||||
@@ -1,234 +0,0 @@
|
||||
package noppes.npcs.client.gui.roles;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.AnimationData;
|
||||
import noppes.npcs.AnimationPartConfig;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
|
||||
public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener, ITextfieldListener {
|
||||
|
||||
private GuiScreen parent;
|
||||
private int type = 6;
|
||||
private AnimationData job;
|
||||
private AnimationPartConfig part;
|
||||
|
||||
private GuiNpcSlider rotateX;
|
||||
private GuiNpcSlider rotateY;
|
||||
private GuiNpcSlider rotateZ;
|
||||
|
||||
public GuiNpcPuppet(GuiScreen parent, EntityCustomNpc npc){
|
||||
super(npc);
|
||||
this.parent = parent;
|
||||
this.xOffset = 100;
|
||||
ySize = 230;
|
||||
job = npc.display.animationData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
int y = guiTop;
|
||||
addLabel(new GuiNpcLabel(26, "gui.settings", guiLeft + 55, y + 5, 0xFFFFFF));
|
||||
if(type == 6){
|
||||
addButton(new GuiNpcButton(30, guiLeft + 120, y += 14, 60, 20, new String[]{"gui.yes", "gui.no"}, job.whileStanding?0:1));
|
||||
addLabel(new GuiNpcLabel(30, "puppet.standing", guiLeft + 30, y + 5, 0xFFFFFF));
|
||||
addButton(new GuiNpcButton(31, guiLeft + 120, y += 22, 60, 20, new String[]{"gui.yes", "gui.no"}, job.whileMoving?0:1));
|
||||
addLabel(new GuiNpcLabel(31, "puppet.walking", guiLeft + 30, y + 5, 0xFFFFFF));
|
||||
addButton(new GuiNpcButton(32, guiLeft + 120, y += 22, 60, 20, new String[]{"gui.yes", "gui.no"}, job.whileAttacking?0:1));
|
||||
addLabel(new GuiNpcLabel(32, "puppet.attacking", guiLeft + 30, y + 5, 0xFFFFFF));
|
||||
|
||||
y += 24;
|
||||
}
|
||||
else{
|
||||
addButton(new GuiNpcButton(6, guiLeft + 110, y , 60, 20, "selectServer.edit"));
|
||||
y += 24;
|
||||
}
|
||||
|
||||
addLabel(new GuiNpcLabel(20, "model.head", guiLeft + 55, y + 5, 0xFFFFFF));
|
||||
if(type == 0){
|
||||
y += drawSlider(y, job.head);
|
||||
}
|
||||
else{
|
||||
addButton(new GuiNpcButton(0, guiLeft + 110, y , 60, 20, "selectServer.edit"));
|
||||
y += 24;
|
||||
}
|
||||
|
||||
addLabel(new GuiNpcLabel(21, "model.body", guiLeft + 55, y + 5, 0xFFFFFF));
|
||||
if(type == 1){
|
||||
y += drawSlider(y, job.body);
|
||||
}
|
||||
else{
|
||||
addButton(new GuiNpcButton(1, guiLeft + 110, y , 60, 20, "selectServer.edit"));
|
||||
y += 24;
|
||||
}
|
||||
|
||||
addLabel(new GuiNpcLabel(22, "model.larm", guiLeft + 55, y + 5, 0xFFFFFF));
|
||||
if(type == 2){
|
||||
y += drawSlider(y, job.larm);
|
||||
}
|
||||
else{
|
||||
addButton(new GuiNpcButton(2, guiLeft + 110, y , 60, 20, "selectServer.edit"));
|
||||
y += 24;
|
||||
}
|
||||
|
||||
addLabel(new GuiNpcLabel(23, "model.rarm", guiLeft + 55, y + 5, 0xFFFFFF));
|
||||
if(type == 3){
|
||||
y += drawSlider(y, job.rarm);
|
||||
}
|
||||
else{
|
||||
addButton(new GuiNpcButton(3, guiLeft + 110, y , 60, 20, "selectServer.edit"));
|
||||
y += 24;
|
||||
}
|
||||
|
||||
addLabel(new GuiNpcLabel(24, "model.lleg", guiLeft + 55, y + 5, 0xFFFFFF));
|
||||
if(type == 4){
|
||||
y += drawSlider(y, job.lleg);;
|
||||
}
|
||||
else{
|
||||
addButton(new GuiNpcButton(4, guiLeft + 110, y , 60, 20, "selectServer.edit"));
|
||||
y += 24;
|
||||
}
|
||||
|
||||
addLabel(new GuiNpcLabel(25, "model.rleg", guiLeft + 55, y + 5, 0xFFFFFF));
|
||||
if(type == 5){
|
||||
y += drawSlider(y, job.rleg);;
|
||||
}
|
||||
else{
|
||||
addButton(new GuiNpcButton(5, guiLeft + 110, y , 60, 20, "selectServer.edit"));
|
||||
y += 24;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private float drawSlider(int y, AnimationPartConfig config){
|
||||
part = config;
|
||||
addButton(new GuiNpcButton(29, guiLeft + 100, y , 80, 20, new String[]{"gui.enabled","gui.disabled"}, !config.enablePart?1:0));
|
||||
y += 22;
|
||||
addLabel(new GuiNpcLabel(10, "X", guiLeft, y + 5, 0xFFFFFF));
|
||||
rotateX = new GuiNpcSlider(this, 10, guiLeft + 50, y, config.rotationX + 0.5f);
|
||||
addSlider(rotateX);
|
||||
addButton(new GuiNpcButton(170, guiLeft + 8, y, 40, 20, "Reset"));
|
||||
y += 22;
|
||||
addLabel(new GuiNpcLabel(11, "Y", guiLeft, y + 5, 0xFFFFFF));
|
||||
rotateY = new GuiNpcSlider(this, 11, guiLeft + 50, y, config.rotationY + 0.5f);
|
||||
addSlider(rotateY);
|
||||
addButton(new GuiNpcButton(171, guiLeft + 8, y, 40, 20, "Reset"));
|
||||
y += 22;
|
||||
addLabel(new GuiNpcLabel(12, "Z", guiLeft, y + 5, 0xFFFFFF));
|
||||
rotateZ = new GuiNpcSlider(this, 12, guiLeft + 50, y, config.rotationZ + 0.5f);
|
||||
addSlider(rotateZ);
|
||||
addButton(new GuiNpcButton(172, guiLeft + 8, y, 40, 20, "Reset"));
|
||||
|
||||
addTextField(new GuiNpcTextField(15, this, guiLeft + 60, y += 22, 40, 20, "" + config.pivotX));
|
||||
addLabel(new GuiNpcLabel(15, "puppet.pivotX", guiLeft, y + 5, 0xFFFFFF));
|
||||
getTextField(15).floatsOnly = true;
|
||||
getTextField(15).setMinMaxDefaultFloat(-Float.MAX_VALUE,Float.MAX_VALUE,0);
|
||||
|
||||
addTextField(new GuiNpcTextField(16, this, guiLeft + 60, y += 22, 40, 20, "" + config.pivotY));
|
||||
addLabel(new GuiNpcLabel(16, "puppet.pivotY", guiLeft, y + 5, 0xFFFFFF));
|
||||
getTextField(16).floatsOnly = true;
|
||||
getTextField(16).setMinMaxDefaultFloat(-Float.MAX_VALUE,Float.MAX_VALUE,0);
|
||||
|
||||
addTextField(new GuiNpcTextField(17, this, guiLeft + 60, y += 22, 40, 20, "" + config.pivotZ));
|
||||
addLabel(new GuiNpcLabel(17, "puppet.pivotZ", guiLeft, y + 5, 0xFFFFFF));
|
||||
getTextField(17).floatsOnly = true;
|
||||
getTextField(17).setMinMaxDefaultFloat(-Float.MAX_VALUE,Float.MAX_VALUE,0);
|
||||
|
||||
return 160;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
if(btn.id < 7){
|
||||
type = btn.id;
|
||||
initGui();
|
||||
}
|
||||
if(!(btn instanceof GuiNpcButton))
|
||||
return;
|
||||
|
||||
GuiNpcButton button = (GuiNpcButton) btn;
|
||||
if(btn.id == 29){
|
||||
part.enablePart = button.getValue() == 0;
|
||||
}
|
||||
if(btn.id == 30){
|
||||
job.whileStanding = button.getValue() == 0;
|
||||
}
|
||||
if(btn.id == 31){
|
||||
job.whileMoving = button.getValue() == 0;
|
||||
}
|
||||
if(btn.id == 32){
|
||||
job.whileAttacking = button.getValue() == 0;
|
||||
}
|
||||
if(btn.id == 170 || btn.id == 171 || btn.id == 172){
|
||||
if(btn.id == 170){
|
||||
part.rotationX = 0.0f;
|
||||
rotateX.sliderValue = 0.5f;
|
||||
int percent = (int) ((rotateX.sliderValue) * 360);
|
||||
rotateX.setString(percent + "%");
|
||||
}
|
||||
else if(btn.id == 171){
|
||||
part.rotationY = 0.0f;
|
||||
rotateY.sliderValue = 0.5f;
|
||||
int percent = (int) ((rotateY.sliderValue) * 360);
|
||||
rotateY.setString(percent + "%");
|
||||
}
|
||||
else{
|
||||
part.rotationZ = 0.0f;
|
||||
rotateZ.sliderValue = 0.5f;
|
||||
int percent = (int) ((rotateZ.sliderValue) * 360);
|
||||
rotateZ.setString(percent + "%");
|
||||
}
|
||||
npc.updateHitbox();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
if(textfield.id == 15) {
|
||||
part.pivotX = textfield.getFloat();
|
||||
}
|
||||
if(textfield.id == 16) {
|
||||
part.pivotY = textfield.getFloat();
|
||||
}
|
||||
if(textfield.id == 17) {
|
||||
part.pivotZ = textfield.getFloat();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(){
|
||||
this.mc.displayGuiScreen(parent);
|
||||
Client.sendData(EnumPacketServer.JobSave, job.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(GuiNpcSlider slider) {
|
||||
int percent = (int) ((slider.sliderValue) * 360);
|
||||
slider.setString(percent + "%");
|
||||
|
||||
if(slider.id == 10)
|
||||
part.rotationX = slider.sliderValue - 0.5f;
|
||||
if(slider.id == 11)
|
||||
part.rotationY = slider.sliderValue - 0.5f;
|
||||
if(slider.id == 12)
|
||||
part.rotationZ = slider.sliderValue - 0.5f;
|
||||
npc.updateHitbox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(GuiNpcSlider slider) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(GuiNpcSlider slider) {
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.*;
|
||||
import noppes.npcs.api.ISkinOverlay;
|
||||
import noppes.npcs.api.handler.data.IFramePart;
|
||||
import noppes.npcs.client.ClientEventHandler;
|
||||
import noppes.npcs.client.model.animation.AniCrawling;
|
||||
import noppes.npcs.client.model.animation.AniHug;
|
||||
import noppes.npcs.client.model.part.*;
|
||||
@@ -18,10 +20,15 @@ import noppes.npcs.client.model.util.ModelPartInterface;
|
||||
import noppes.npcs.client.model.util.ModelScaleRenderer;
|
||||
import noppes.npcs.client.renderer.RenderNPCInterface;
|
||||
import noppes.npcs.constants.EnumAnimation;
|
||||
import noppes.npcs.constants.EnumAnimationPart;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.Frame;
|
||||
import noppes.npcs.controllers.data.FramePart;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import static noppes.npcs.client.ClientProxy.bindTexture;
|
||||
@@ -562,14 +569,31 @@ public class ModelMPM extends ModelNPCMale{
|
||||
this.bipedBody.rotateAngleX = 0.5F / npc.modelData.body.scaleY;
|
||||
}
|
||||
|
||||
AnimationData job = npc.display.animationData;
|
||||
if (job.isActive()) {
|
||||
AnimationPartConfig[] partConfigs = new AnimationPartConfig[]{job.head,job.body,job.larm,job.rarm,job.lleg,job.rleg};
|
||||
ModelRenderer[] mainModelParts = new ModelRenderer[]{bipedHead,bipedBody,bipedLeftArm,bipedRightArm,bipedLeftLeg,bipedRightLeg};
|
||||
AnimationData animationData = npc.display.animationData;
|
||||
if (animationData.isActive()) {
|
||||
Animation animation = animationData.animation;
|
||||
Frame frame = animation.frames.get(animation.currentFrame);
|
||||
|
||||
for (int i = 0; i < partConfigs.length; i++) {
|
||||
if (partConfigs[i].enablePart) {
|
||||
this.setInterpolatedAngles(mainModelParts[i],partConfigs[i]);
|
||||
HashMap<EnumAnimationPart,ModelRenderer> animPartToModel = new HashMap<>();
|
||||
animPartToModel.put(EnumAnimationPart.HEAD,bipedHead);
|
||||
animPartToModel.put(EnumAnimationPart.BODY,bipedBody);
|
||||
animPartToModel.put(EnumAnimationPart.LEFT_ARM,bipedLeftArm);
|
||||
animPartToModel.put(EnumAnimationPart.RIGHT_ARM,bipedRightArm);
|
||||
animPartToModel.put(EnumAnimationPart.LEFT_LEG,bipedLeftLeg);
|
||||
animPartToModel.put(EnumAnimationPart.RIGHT_LEG,bipedRightLeg);
|
||||
|
||||
FramePart[] frameParts = frame.frameParts.values().toArray(new FramePart[0]);
|
||||
for (FramePart part : frameParts) {
|
||||
if (part != null) {
|
||||
if (part.part != EnumAnimationPart.FULL_MODEL) {
|
||||
ModelRenderer modelRenderer = animPartToModel.get(part.part);
|
||||
part.interpolateAngles();
|
||||
modelRenderer.rotateAngleX = part.prevRotations[0];
|
||||
modelRenderer.rotateAngleY = part.prevRotations[1];
|
||||
modelRenderer.rotateAngleZ = part.prevRotations[2];
|
||||
} else {
|
||||
part.interpolateAngles();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,78 +635,31 @@ public class ModelMPM extends ModelNPCMale{
|
||||
-MathHelper.sin(this.bipedBody.rotateAngleY) * 2.0F +
|
||||
MathHelper.sin(this.bipedBody.rotateAngleX) * MathHelper.cos(this.bipedBody.rotateAngleY) * 12.0F;
|
||||
|
||||
for (int i = 0; i < partConfigs.length; i++) {
|
||||
if (partConfigs[i].enablePart) {
|
||||
this.addInterpolatedOffset(mainModelParts[i],partConfigs[i]);
|
||||
frameParts = frame.frameParts.values().toArray(new FramePart[0]);
|
||||
for (FramePart part : frameParts) {
|
||||
if (part != null) {
|
||||
if (part.part != EnumAnimationPart.FULL_MODEL) {
|
||||
ModelRenderer modelRenderer = animPartToModel.get(part.part);
|
||||
part.interpolateOffset();
|
||||
modelRenderer.rotationPointX += part.prevPivots[0];
|
||||
modelRenderer.rotationPointY += part.prevPivots[1];
|
||||
modelRenderer.rotationPointZ += part.prevPivots[2];
|
||||
} else {
|
||||
part.interpolateOffset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setInterpolatedAngles(ModelRenderer renderer, AnimationPartConfig modelPart) {
|
||||
renderer.rotateAngleX = modelPart.prevRotations[0];
|
||||
renderer.rotateAngleY = modelPart.prevRotations[1];
|
||||
renderer.rotateAngleZ = modelPart.prevRotations[2];
|
||||
|
||||
float pi = (float) Math.PI * (modelPart.fullAngles ? 2 : 1);
|
||||
if (!modelPart.animate) {
|
||||
renderer.rotateAngleX = modelPart.rotationX * pi;
|
||||
renderer.rotateAngleY = modelPart.rotationY * pi;
|
||||
renderer.rotateAngleZ = modelPart.rotationZ * pi;
|
||||
} else {
|
||||
if (modelPart.interpolate) {
|
||||
renderer.rotateAngleX = (modelPart.rotationX * pi - renderer.rotateAngleX) * modelPart.animRate / 10f + renderer.rotateAngleX;
|
||||
renderer.rotateAngleY = (modelPart.rotationY * pi - renderer.rotateAngleY) * modelPart.animRate / 10f + renderer.rotateAngleY;
|
||||
renderer.rotateAngleZ = (modelPart.rotationZ * pi - renderer.rotateAngleZ) * modelPart.animRate / 10f + renderer.rotateAngleZ;
|
||||
} else {
|
||||
int directionX = Float.compare(modelPart.rotationX * pi, renderer.rotateAngleX);
|
||||
renderer.rotateAngleX += directionX * modelPart.animRate / 10f;
|
||||
renderer.rotateAngleX = directionX == 1 ?
|
||||
Math.min(modelPart.rotationX * pi,renderer.rotateAngleX) : Math.max(modelPart.rotationX * pi,renderer.rotateAngleX);
|
||||
int directionY = Float.compare(modelPart.rotationY * pi, renderer.rotateAngleY);
|
||||
renderer.rotateAngleY += directionY * modelPart.animRate / 10f;
|
||||
renderer.rotateAngleY = directionY == 1 ?
|
||||
Math.min(modelPart.rotationY * pi,renderer.rotateAngleY) : Math.max(modelPart.rotationY * pi,renderer.rotateAngleY);
|
||||
int directionZ = Float.compare(modelPart.rotationZ * pi, renderer.rotateAngleZ);
|
||||
renderer.rotateAngleZ += directionZ * modelPart.animRate / 10f;
|
||||
renderer.rotateAngleZ = directionZ == 1 ?
|
||||
Math.min(modelPart.rotationZ * pi,renderer.rotateAngleZ) : Math.max(modelPart.rotationZ * pi,renderer.rotateAngleZ);
|
||||
}
|
||||
}
|
||||
modelPart.prevRotations = new float[]{renderer.rotateAngleX,renderer.rotateAngleY,renderer.rotateAngleZ};
|
||||
}
|
||||
|
||||
public void addInterpolatedOffset(ModelRenderer renderer, AnimationPartConfig modelPart) {
|
||||
if (!modelPart.animate) {
|
||||
renderer.rotationPointX += modelPart.pivotX;
|
||||
renderer.rotationPointY += modelPart.pivotY;
|
||||
renderer.rotationPointZ += modelPart.pivotZ;
|
||||
} else {
|
||||
renderer.rotationPointX += modelPart.prevPivots[0];
|
||||
renderer.rotationPointY += modelPart.prevPivots[1];
|
||||
renderer.rotationPointZ += modelPart.prevPivots[2];
|
||||
if (modelPart.interpolate) {
|
||||
modelPart.prevPivots[0] = (modelPart.pivotX - modelPart.prevPivots[0]) * modelPart.animRate / 10f + modelPart.prevPivots[0];
|
||||
modelPart.prevPivots[1] = (modelPart.pivotY - modelPart.prevPivots[1]) * modelPart.animRate / 10f + modelPart.prevPivots[1];
|
||||
modelPart.prevPivots[2] = (modelPart.pivotZ - modelPart.prevPivots[2]) * modelPart.animRate / 10f + modelPart.prevPivots[2];
|
||||
} else {
|
||||
int directionX = Float.compare(modelPart.pivotX, modelPart.prevPivots[0]);
|
||||
modelPart.prevPivots[0] += directionX * modelPart.animRate / 10f;
|
||||
modelPart.prevPivots[0] = directionX == 1 ?
|
||||
Math.min(modelPart.pivotX,modelPart.prevPivots[0]) : Math.max(modelPart.pivotX,modelPart.prevPivots[0]);
|
||||
int directionY = Float.compare(modelPart.pivotY, modelPart.prevPivots[1]);
|
||||
modelPart.prevPivots[1] += directionY * modelPart.animRate / 10f;
|
||||
modelPart.prevPivots[1] = directionY == 1 ?
|
||||
Math.min(modelPart.pivotY,modelPart.prevPivots[1]) : Math.max(modelPart.pivotY,modelPart.prevPivots[1]);
|
||||
int directionZ = Float.compare(modelPart.pivotZ, modelPart.prevPivots[2]);
|
||||
modelPart.prevPivots[2] += directionZ * modelPart.animRate / 10f;
|
||||
modelPart.prevPivots[2] = directionZ == 1 ?
|
||||
Math.min(modelPart.pivotZ,modelPart.prevPivots[2]) : Math.max(modelPart.pivotZ,modelPart.prevPivots[2]);
|
||||
if (frame.frameParts.containsKey(EnumAnimationPart.FULL_MODEL)) {
|
||||
FramePart part = frame.frameParts.get(EnumAnimationPart.FULL_MODEL);
|
||||
GL11.glTranslatef(part.prevPivots[0],part.prevPivots[1],part.prevPivots[2]);
|
||||
GL11.glRotatef(part.prevRotations[0],1,0,0);
|
||||
GL11.glRotatef(part.prevRotations[1],0,1,0);
|
||||
GL11.glRotatef(part.prevRotations[2],0,0,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4)
|
||||
{
|
||||
if(entityModel != null){
|
||||
|
||||
Reference in new issue
Block a user