Some spring cleaning

This commit is contained in:
Sollace 2018-08-17 22:46:28 +02:00
parent da26aef533
commit cea9419fb6
8 changed files with 20 additions and 37 deletions

View file

@ -104,8 +104,8 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
float headRotateAngleY = isSleeping ? 1.4f : headYaw / 57.29578F; float headRotateAngleY = isSleeping() ? 1.4f : headYaw / 57.29578F;
float headRotateAngleX = isSleeping ? 0.1f : headPitch / 57.29578F; float headRotateAngleX = isSleeping() ? 0.1f : headPitch / 57.29578F;
headRotateAngleX = Math.min(headRotateAngleX, (float) (0.5f - Math.toRadians(motionPitch))); headRotateAngleX = Math.min(headRotateAngleX, (float) (0.5f - Math.toRadians(motionPitch)));
headRotateAngleX = Math.max(headRotateAngleX, (float) (-1.25f - Math.toRadians(motionPitch))); headRotateAngleX = Math.max(headRotateAngleX, (float) (-1.25f - Math.toRadians(motionPitch)));
@ -115,7 +115,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
shakeBody(move, swing, getWobbleAmount(), ticks); shakeBody(move, swing, getWobbleAmount(), ticks);
rotateLegs(move, swing, ticks, entity); rotateLegs(move, swing, ticks, entity);
if (!isSwimming && !rainboom) { if (!isSwimming() && !rainboom) {
holdItem(swing); holdItem(swing);
} }
swingItem(entity); swingItem(entity);
@ -178,7 +178,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}. * @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
*/ */
protected void shakeBody(float move, float swing, float bodySwing, float ticks) { protected void shakeBody(float move, float swing, float bodySwing, float ticks) {
tail.setRotationAndAngles(isSwimming || rainboom, move, swing, bodySwing * 5, ticks); tail.setRotationAndAngles(isSwimming() || rainboom, move, swing, bodySwing * 5, ticks);
upperTorso.rotateAngleY = bodySwing; upperTorso.rotateAngleY = bodySwing;
bipedBody.rotateAngleY = bodySwing; bipedBody.rotateAngleY = bodySwing;
@ -349,7 +349,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
} }
protected float getLegOutset() { protected float getLegOutset() {
if (isSleeping) return 3.6f; if (isSleeping()) return 3.6f;
if (isCrouching()) return 1; if (isCrouching()) return 1;
return 5; return 5;
} }
@ -382,13 +382,13 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
switch (pose) { switch (pose) {
case ITEM: case ITEM:
float swag = 1; float swag = 1;
if (!isFlying && both) { if (!isFlying() && both) {
swag -= (float)Math.pow(swing, 2); swag -= (float)Math.pow(swing, 2);
} }
float mult = 1 - swag/2; float mult = 1 - swag/2;
arm.rotateAngleX = arm.rotateAngleX * mult - (PI / 10) * swag; arm.rotateAngleX = arm.rotateAngleX * mult - (PI / 10) * swag;
arm.rotateAngleZ = -reflect * (PI / 15); arm.rotateAngleZ = -reflect * (PI / 15);
if (isSneak) { if (isCrouching()) {
arm.rotationPointX -= reflect * 2; arm.rotationPointX -= reflect * 2;
} }
case EMPTY: case EMPTY:
@ -399,7 +399,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
arm.rotateAngleY = reflect * PI / 9; arm.rotateAngleY = reflect * PI / 9;
arm.rotationPointX += reflect; arm.rotationPointX += reflect;
arm.rotationPointZ += 3; arm.rotationPointZ += 3;
if (isSneak) { if (isCrouching()) {
arm.rotationPointY += 4; arm.rotationPointY += 4;
} }
break; break;
@ -426,7 +426,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
* @param entity The entity we are being called for. * @param entity The entity we are being called for.
*/ */
protected void swingItem(Entity entity) { protected void swingItem(Entity entity) {
if (swingProgress > 0 && !isSleeping) { if (swingProgress > 0 && !isSleeping()) {
EnumHandSide mainSide = getMainHand(entity); EnumHandSide mainSide = getMainHand(entity);
swingArm(getArmForSide(mainSide)); swingArm(getArmForSide(mainSide));
@ -457,7 +457,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}. * @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
*/ */
protected void swingArms(float ticks) { protected void swingArms(float ticks) {
if (isSleeping) return; if (isSleeping()) return;
float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(ticks * 0.067F) * 0.05F; float sin = MathHelper.sin(ticks * 0.067F) * 0.05F;
@ -841,7 +841,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
public void transform(BodyPart part) { public void transform(BodyPart part) {
if (isRiding()) translate(0, -0.4F, -0.2F); if (isRiding()) translate(0, -0.4F, -0.2F);
if (isSleeping) { if (isSleeping()) {
rotate(90, 1, 0, 0); rotate(90, 1, 0, 0);
rotate(180, 0, 1, 0); rotate(180, 0, 1, 0);
} }

View file

@ -19,7 +19,7 @@ public class ModelWrapper implements IModelWrapper {
public ModelWrapper(AbstractPonyModel model) { public ModelWrapper(AbstractPonyModel model) {
body = model; body = model;
armor = model.createArmour(); armor = model.createArmour();
armor.apply(model.metadata); armor.apply(model.getMetadata());
} }
public AbstractPonyModel getBody() { public AbstractPonyModel getBody() {
@ -28,7 +28,6 @@ public class ModelWrapper implements IModelWrapper {
/** /**
* Returns the contained armour model. * Returns the contained armour model.
* @return
*/ */
public IEquestrianArmor getArmor() { public IEquestrianArmor getArmor() {
return armor; return armor;

View file

@ -58,7 +58,7 @@ public class PonyTail extends PlaneRenderer implements IModelPart {
rotationPointZ++; rotationPointZ++;
} }
tailStop = theModel.metadata.getTail().ordinal(); tailStop = theModel.getMetadata().getTail().ordinal();
} }
private void swingX(float ticks) { private void swingX(float ticks) {

View file

@ -1,7 +0,0 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
package com.minelittlepony.posture;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -23,8 +23,6 @@ import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
// TODO: A lot of this duplicates RenderPonyPlayer
// and is the whole reason we had this scaling bug in the first place.
public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving<T> implements IRenderPony<T> { public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving<T> implements IRenderPony<T> {
protected RenderPony<T> renderPony = new RenderPony<T>(this); protected RenderPony<T> renderPony = new RenderPony<T>(this);

View file

@ -3,19 +3,19 @@ package com.minelittlepony.util.coordinates;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
public interface Color { public interface Color {
public static float r(int color) { static float r(int color) {
return (color >> 16 & 255) / 255F; return (color >> 16 & 255) / 255F;
} }
public static float g(int color) { static float g(int color) {
return (color >> 8 & 255) / 255F; return (color >> 8 & 255) / 255F;
} }
public static float b(int color) { static float b(int color) {
return (color & 255) / 255F; return (color & 255) / 255F;
} }
public static void glColor(int color, float alpha) { static void glColor(int color, float alpha) {
GlStateManager.color(Color.r(color), Color.g(color), Color.b(color), alpha); GlStateManager.color(Color.r(color), Color.g(color), Color.b(color), alpha);
} }
} }

View file

@ -4,7 +4,7 @@ import net.minecraft.client.model.TexturedQuad;
public class Quad extends TexturedQuad { public class Quad extends TexturedQuad {
public Quad(Vertex[] vertices, int texcoordU1, int texcoordV1, int texcoordU2, int texcoordV2, float textureWidth, float textureHeight) { Quad(Vertex[] vertices, int texcoordU1, int texcoordV1, int texcoordU2, int texcoordV2, float textureWidth, float textureHeight) {
super(vertices, texcoordU1, texcoordV1, texcoordU2, texcoordV2, textureWidth, textureHeight); super(vertices, texcoordU1, texcoordV1, texcoordU2, texcoordV2, textureWidth, textureHeight);
} }
} }

View file

@ -4,11 +4,11 @@ import net.minecraft.client.model.PositionTextureVertex;
public class Vertex extends PositionTextureVertex { public class Vertex extends PositionTextureVertex {
public Vertex(float x, float y, float z, int texX, int texY) { Vertex(float x, float y, float z, int texX, int texY) {
super(x, y, z, texX, texY); super(x, y, z, texX, texY);
} }
public Vertex(Vertex old, float texX, float texY) { private Vertex(Vertex old, float texX, float texY) {
super(old, texX, texY); super(old, texX, texY);
} }
@ -17,11 +17,4 @@ public class Vertex extends PositionTextureVertex {
public Vertex setTexturePosition(float texX, float texY) { public Vertex setTexturePosition(float texX, float texY) {
return new Vertex(this, texX, texY); return new Vertex(this, texX, texY);
} }
/**
* Creates a new vertex mapping the given (x, y, z) coordinates to a texture offset.
*/
public static Vertex vert(float x, float y, float z, int texX, int texY) {
return new Vertex(x, y, z, texX, texY);
}
} }