More formatting

This commit is contained in:
Sollace 2018-04-26 23:53:49 +02:00
parent 7a66dfda42
commit c6e81529f3
5 changed files with 68 additions and 67 deletions

View file

@ -1,53 +1,53 @@
package com.minelittlepony.model.components;
import com.minelittlepony.model.PonyModelConstants;
import com.minelittlepony.render.PonyRenderer;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.model.ModelBase;
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.math.Vec3d;
public class PonyElytra extends ModelBase {
private ModelRenderer rightWing;
private ModelRenderer leftWing = new ModelRenderer(this, 22, 0);
private PonyRenderer rightWing = new PonyRenderer(this, 22, 0);
private PonyRenderer leftWing = new PonyRenderer(this, 22, 0);
public PonyElytra() {
this.leftWing.addBox(-10.0F, 0.0F, 0.0F, 10, 20, 2, 1.0F);
this.rightWing = new ModelRenderer(this, 22, 0);
this.rightWing.mirror = true;
this.rightWing.addBox(0.0F, 0.0F, 0.0F, 10, 20, 2, 1.0F);
this.leftWing .box(-10, 0, 0, 10, 20, 2, 1);
this.rightWing.mirror().box( 0, 0, 0, 10, 20, 2, 1);
}
@Override
public void render(Entity entityIn, float p_78088_2_, float limbSwing, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
GlStateManager.disableRescaleNormal();
GlStateManager.disableCull();
this.leftWing.render(scale);
this.rightWing.render(scale);
leftWing.render(scale);
rightWing.render(scale);
}
@Override
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
final float PI = (float) Math.PI;
float rotateX = PI / 2F;
float rotateZ = PI / 12;
float rpY = PonyModelConstants.BODY_RP_Y_NOTSNEAK;
float rotateY = PI / 8F;
float rotateZ = PI / 12;
float rpY = PonyModelConstants.BODY_RP_Y_NOTSNEAK;
if (entityIn instanceof EntityLivingBase && ((EntityLivingBase) entityIn).isElytraFlying()) {
float f4 = 1.0F;
float f4 = 1;
if (entityIn.motionY < 0.0D) {
if (entityIn.motionY < 0) {
Vec3d vec3d = (new Vec3d(entityIn.motionX, entityIn.motionY, entityIn.motionZ)).normalize();
f4 = 1.0F - (float) Math.pow(-vec3d.y, 1.5D);
f4 = 1 - (float) Math.pow(-vec3d.y, 1.5);
}
rotateX = f4 * PI * (2 / 3F) + (1.0F - f4) * rotateX;
rotateY = f4 * ((float) Math.PI / 2F) + (1.0F - f4) * rotateY;
rotateX = f4 * PI * (2 / 3F) + (1 - f4) * rotateX;
rotateY = f4 * ((float) Math.PI / 2F) + (1 - f4) * rotateY;
} else if (entityIn.isSneaking()) {
rotateX = ((float) Math.PI * 1.175F);
rotateY = PI / 2;
@ -55,7 +55,7 @@ public class PonyElytra extends ModelBase {
rotateZ = PI / 4F;
}
this.leftWing.rotationPointX = 5.0F;
this.leftWing.rotationPointX = 5;
this.leftWing.rotationPointY = rpY;
if (entityIn instanceof AbstractClientPlayer) {

View file

@ -51,13 +51,13 @@ public class ModelIllagerPony extends ModelPlayerPony {
// this.bipedRightArm.rotationPointZ = 0.0F;
// this.bipedRightArm.rotationPointX = -5.0F;
this.bipedRightArm.rotateAngleX = (float) (-.75F * Math.PI);
this.bipedRightArm.rotateAngleZ = MathHelper.cos(ageInTicks * 0.6662F) * 0.25F;
this.bipedRightArm.rotateAngleZ = MathHelper.cos(ageInTicks * 0.6662F) / 4;
this.bipedRightArm.rotateAngleY = 1.1F;
} else {
// this.bipedLeftArm.rotationPointZ = 0.0F;
// this.bipedLeftArm.rotationPointX = 5.0F;
this.bipedLeftArm.rotateAngleX = (float) (-.75F * Math.PI);
this.bipedLeftArm.rotateAngleZ = -MathHelper.cos(ageInTicks * 0.6662F) * 0.25F;
this.bipedLeftArm.rotateAngleZ = -MathHelper.cos(ageInTicks * 0.6662F) / 4;
this.bipedLeftArm.rotateAngleY = -1.1F;
}

View file

@ -62,9 +62,9 @@ public class ModelPlayerPony extends AbstractPonyModel {
this.checkRainboom(entityIn, limbSwingAmount);
this.rotateHead(netHeadYaw, headPitch);
float bodySwingRotation = 0.0F;
if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) {
bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F;
float bodySwingRotation = 0;
if (swingProgress > -9990.0F && !metadata.hasMagic()) {
bodySwingRotation = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.2F;
}
rotateLook(limbSwing, limbSwingAmount, bodySwingRotation, ageInTicks);
@ -184,7 +184,10 @@ public class ModelPlayerPony extends AbstractPonyModel {
}
protected void rotateLegs(float move, float swing, float tick, Entity entity) {
float leftArm, rightArm, leftLeg, rightLeg;
float leftArm;
float rightArm;
float leftLeg;
float rightLeg;
if (isFlying(entity)) {
@ -196,11 +199,8 @@ public class ModelPlayerPony extends AbstractPonyModel {
rightLeg = leftLeg = MathHelper.sin(swing / 2);
}
bipedRightArm.rotateAngleY = 0.2F;
bipedLeftLeg.rotateAngleY = bipedRightArm.rotateAngleY = 0.2F;
bipedLeftArm.rotateAngleY = bipedRightLeg.rotateAngleY = -0.2F;
bipedLeftLeg.rotateAngleY = 0.2F;
} else {
float pi = PI * (float) Math.pow(swing, 16);
@ -325,55 +325,55 @@ public class ModelPlayerPony extends AbstractPonyModel {
if (mainPose == ArmPose.EMPTY) return;
float f16 = 1 - swingProgress;
f16 *= f16 * f16;
f16 = 1 - f16;
float f22 = MathHelper.sin(f16 * PI);
float f28 = MathHelper.sin(swingProgress * PI);
float f33 = f28 * (0.7F - bipedHead.rotateAngleX) * 0.75F;
if (metadata.hasMagic()) {
swingArm(mainRight ? unicornArmRight : unicornArmLeft, f22, f33, f28);
swingArm(mainRight ? unicornArmRight : unicornArmLeft);
} else {
swingArm(getArmForSide(mainSide), f22, f33, f28);
swingArm(getArmForSide(mainSide));
}
}
}
private void swingArm(ModelRenderer arm, float f22, float f33, float f28) {
arm.rotateAngleX = (float) (arm.rotateAngleX - (f22 * 1.2D + f33));
arm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F;
arm.rotateAngleZ = f28 * -0.4F;
private void swingArm(ModelRenderer arm) {
float swing = 1 - (float)Math.pow(1 - swingProgress, 3);
float deltaX = MathHelper.sin(swing * PI);
float deltaZ = MathHelper.sin(swingProgress * PI);
float deltaAim = deltaZ * (0.7F - bipedHead.rotateAngleX) * 0.75F;
arm.rotateAngleX -= deltaAim + deltaX * 1.2F;
arm.rotateAngleZ = deltaZ * -0.4F;
arm.rotateAngleY += bipedBody.rotateAngleY * 2;
}
protected void swingArms(float tick) {
float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(tick * 0.067F) * 0.05F;
if (this.rightArmPose != ArmPose.EMPTY && !this.isSleeping) {
if (rightArmPose != ArmPose.EMPTY && !isSleeping) {
if (this.metadata.hasMagic()) {
this.unicornArmRight.rotateAngleZ += cos;
this.unicornArmRight.rotateAngleX += sin;
if (metadata.hasMagic()) {
unicornArmRight.rotateAngleZ += cos;
unicornArmRight.rotateAngleX += sin;
} else {
this.bipedRightArm.rotateAngleZ += cos;
this.bipedRightArm.rotateAngleX += sin;
bipedRightArm.rotateAngleZ += cos;
bipedRightArm.rotateAngleX += sin;
}
}
if (this.leftArmPose != ArmPose.EMPTY && !this.isSleeping) {
if (this.metadata.hasMagic()) {
this.unicornArmLeft.rotateAngleZ += cos;
this.unicornArmLeft.rotateAngleX += sin;
if (leftArmPose != ArmPose.EMPTY && !isSleeping) {
if (metadata.hasMagic()) {
unicornArmLeft.rotateAngleZ += cos;
unicornArmLeft.rotateAngleX += sin;
} else {
this.bipedLeftArm.rotateAngleZ += cos;
this.bipedLeftArm.rotateAngleX += sin;
bipedLeftArm.rotateAngleZ += cos;
bipedLeftArm.rotateAngleX += sin;
}
}
}
protected void adjustBody(float rotateAngleX, float rotationPointY, float rotationPointZ) {
this.adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ);
this.adjustNeck(rotateAngleX, rotationPointY, rotationPointZ);
adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ);
adjustNeck(rotateAngleX, rotationPointY, rotationPointZ);
}
protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) {
@ -420,7 +420,7 @@ public class ModelPlayerPony extends AbstractPonyModel {
protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) {
if (leftArm == ArmPose.BOW_AND_ARROW || rightArm == ArmPose.BOW_AND_ARROW) {
if (this.metadata.hasMagic()) {
if (metadata.hasMagic()) {
if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, tick, true);
if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, tick, false);
} else {

View file

@ -48,9 +48,9 @@ public class LayerPonyCustomHead implements LayerRenderer<EntityLivingBase> {
model.transform(BodyPart.HEAD);
model.bipedHead.postRender(0.0625f);
if (model instanceof ModelPlayerPony) {
translate(0, .2, 0);
translate(0, 0.2F, 0);
} else {
translate(0, 0, .15);
translate(0, 0, 0.15F);
}
color(1, 1, 1, 1);
if (item == Items.SKULL) {
@ -65,26 +65,27 @@ public class LayerPonyCustomHead implements LayerRenderer<EntityLivingBase> {
private void renderBlock(EntityLivingBase entity, ItemStack itemstack) {
rotate(180, 0, 1, 0);
scale(0.625, -0.625, -0.625);
translate(0, 0.4, -0.21);
scale(0.625, -0.625F, -0.625F);
translate(0, 0.4F, -0.21F);
Minecraft.getMinecraft().getItemRenderer().renderItem(entity, itemstack, TransformType.HEAD);
}
private void renderSkull(ItemStack itemstack, boolean isVillager, float limbSwing) {
translate(0, 0, -.14);
translate(0, 0, -0.14F);
float f = 1.1875f;
scale(f, -f, -f);
if (isVillager) {
translate(0, 0.0625, 0);
translate(0, 0.0625F, 0);
}
translate(0, 0, -.05f);
translate(0, 0, -0.05F);
GameProfile profile = null;
if (itemstack.hasTagCompound()) {
NBTTagCompound nbt = itemstack.getTagCompound();
assert nbt != null;
if (nbt.hasKey("SkullOwner", 10)) {
profile = NBTUtil.readGameProfileFromNBT(nbt.getCompoundTag("SkullOwner"));
} else if (nbt.hasKey("SkullOwner", 8)) {
@ -93,7 +94,7 @@ public class LayerPonyCustomHead implements LayerRenderer<EntityLivingBase> {
}
}
TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.45F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), profile, -1, limbSwing);
TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0, -0.45F, EnumFacing.UP, 180, itemstack.getMetadata(), profile, -1, limbSwing);
}

View file

@ -36,7 +36,7 @@ public class LayerPonyElytra extends AbstractPonyLayer<EntityLivingBase> {
ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (itemstack.getItem() == Items.ELYTRA) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.color(1, 1, 1, 1);
if (entity instanceof AbstractClientPlayer) {
@ -53,7 +53,7 @@ public class LayerPonyElytra extends AbstractPonyLayer<EntityLivingBase> {
}
GlStateManager.pushMatrix();
GlStateManager.translate(0.0F, 0.25F, 0.125F);
GlStateManager.translate(0, 0.25F, 0.125F);
model.transform(BodyPart.BODY);
this.modelElytra.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity);
this.modelElytra.render(entity, swing, swingAmount, age, yaw, head, scale);