package cn.mcmod.tofucraft.client.model; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHandSide; import net.minecraft.util.math.MathHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; /** * TofuMindCore - bagu * Created using Tabula 7.0.0 */ public class ModelTofuMindCore extends ModelBiped { public ModelRenderer body; public ModelRenderer head; public ModelRenderer handR; public ModelRenderer handL; public ModelRenderer balanceCore; public ModelRenderer core; public ModelTofuMindCore() { this.textureWidth = 128; this.textureHeight = 64; this.core = new ModelRenderer(this, 28, 26); this.core.setRotationPoint(0.0F, 5.3F, -2.6F); this.core.addBox(-2.0F, -2.0F, -1.0F, 4, 4, 1, 0.0F); this.balanceCore = new ModelRenderer(this, 28, 16); this.balanceCore.setRotationPoint(0.0F, 10.0F, 0.0F); this.balanceCore.addBox(-2.5F, 0.0F, -2.5F, 5, 5, 5, 0.0F); this.handL = new ModelRenderer(this, 14, 18); this.handL.setRotationPoint(5.0F, 2.0F, 0.0F); this.handL.addBox(-0.5F, 0.0F, -2.0F, 3, 9, 4, 0.0F); this.body = new ModelRenderer(this, 0, 0); this.body.setRotationPoint(0.0F, 8.0F, 0.0F); this.body.addBox(-5.0F, 0.0F, -3.0F, 10, 12, 6, 0.0F); this.handR = new ModelRenderer(this, 0, 18); this.handR.setRotationPoint(-5.0F, 2.0F, 0.0F); this.handR.addBox(-2.5F, 0.0F, -2.0F, 3, 9, 4, 0.0F); this.head = new ModelRenderer(this, 32, 0); this.head.setRotationPoint(0.0F, 0.0F, 0.0F); this.head.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.0F); this.body.addChild(this.core); this.body.addChild(this.balanceCore); this.body.addChild(this.handL); this.body.addChild(this.handR); this.body.addChild(this.head); } @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { this.body.render(f5); } @Override public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { this.head.rotateAngleY = netHeadYaw * 0.017453292F; this.head.rotateAngleX = headPitch * 0.017453292F; this.body.rotateAngleY = 0.0F; float f = 1.0F; this.handR.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 2.0F * limbSwingAmount * 0.5F / f; this.handL.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 2.0F * limbSwingAmount * 0.5F / f; this.handR.rotateAngleZ = 0.0F; this.handL.rotateAngleY = 0.0F; this.handL.rotateAngleZ = 0.0F; this.handR.rotateAngleY = 0.0F; this.handR.rotateAngleZ = 0.0F; if (this.swingProgress > 0.0F) { EnumHandSide enumhandside = this.getMainHand(entityIn); ModelRenderer modelrenderer = this.getArmForSide(enumhandside); float f1 = this.swingProgress; this.body.rotateAngleY = MathHelper.sin(MathHelper.sqrt(f1) * ((float) Math.PI * 2F)) * 0.2F; if (enumhandside == EnumHandSide.LEFT) { this.body.rotateAngleY *= -1.0F; } this.handR.rotationPointZ = MathHelper.sin(this.body.rotateAngleY) * 5.0F; this.handR.rotationPointX = -MathHelper.cos(this.body.rotateAngleY) * 5.0F; this.handL.rotationPointZ = -MathHelper.sin(this.body.rotateAngleY) * 5.0F; this.handL.rotationPointX = MathHelper.cos(this.body.rotateAngleY) * 5.0F; this.handR.rotateAngleY += this.body.rotateAngleY; this.handL.rotateAngleY += this.body.rotateAngleY; this.handL.rotateAngleX += this.body.rotateAngleY; f1 = 1.0F - this.swingProgress; f1 = f1 * f1; f1 = f1 * f1; f1 = 1.0F - f1; float f2 = MathHelper.sin(f1 * (float) Math.PI); float f3 = MathHelper.sin(this.swingProgress * (float) Math.PI) * -(this.head.rotateAngleX - 0.7F) * 0.75F; modelrenderer.rotateAngleX = (float) ((double) modelrenderer.rotateAngleX - ((double) f2 * 1.2D + (double) f3)); modelrenderer.rotateAngleY += this.body.rotateAngleY * 2.0F; modelrenderer.rotateAngleZ += MathHelper.sin(this.swingProgress * (float) Math.PI) * -0.4F; } this.body.rotateAngleX = 0.0F; this.handR.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F; this.handL.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F; this.handR.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F; this.handL.rotateAngleX -= MathHelper.sin(ageInTicks * 0.067F) * 0.05F; } @Override public void setLivingAnimations(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks) { float tick = entity.ticksExisted + partialTicks; GlStateManager.translate(0F, -0.1F - MathHelper.sin(tick * 0.12F) * 0.1F, 0F); } public void postRenderArm(float scale, EnumHandSide side) { this.getArmForSide(side).postRender(scale); } protected ModelRenderer getArmForSide(EnumHandSide side) { return side == EnumHandSide.LEFT ? this.handL : handR; } protected EnumHandSide getMainHand(Entity entityIn) { if (entityIn instanceof EntityLivingBase) { EntityLivingBase entitylivingbase = (EntityLivingBase) entityIn; EnumHandSide enumhandside = entitylivingbase.getPrimaryHand(); return entitylivingbase.swingingHand == EnumHand.MAIN_HAND ? enumhandside : enumhandside.opposite(); } else { return EnumHandSide.RIGHT; } } @SideOnly(Side.CLIENT) public static enum ArmPose { EMPTY, ITEM, BLOCK, BOW_AND_ARROW; } /** * This is a helper function from Tabula to set the rotation of model parts */ public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; modelRenderer.rotateAngleY = y; modelRenderer.rotateAngleZ = z; } }