Move some things for consistency

This commit is contained in:
Sollace 2018-04-29 11:56:26 +02:00
parent 7fbc14ca01
commit 4b27e432b9
15 changed files with 110 additions and 67 deletions

View file

@ -60,11 +60,6 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
initPositions(yOffset, stretch);
}
/**
* Returns a new pony armour to go with this model. Called on startup by a model wrapper.
*/
public abstract PonyArmor createArmour();
/**
* Loads texture values.
*/
@ -141,11 +136,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F;
}
/**
* Applies a transform particular to a certain body part.
*
* FIXME: Too long! Is there a better way to do this?
*/
@Override
public void transform(BodyPart part) {
if (isRiding) translate(0, -0.6F, -0.2F);

View file

@ -1,5 +1,7 @@
package com.minelittlepony.model.armour;
import com.minelittlepony.render.AbstractPonyRenderer;
public class ModelZombiePonyArmor extends ModelPonyArmor {
// Copied from ModelZombiePony
@ -24,9 +26,9 @@ public class ModelZombiePonyArmor extends ModelPonyArmor {
if (rightArmPose != ArmPose.EMPTY) return;
if (islookAngleRight(move)) {
shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3);
AbstractPonyRenderer.shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3);
} else {
shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3);
AbstractPonyRenderer.shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3);
}
}
}

View file

@ -1,9 +1,31 @@
package com.minelittlepony.model.capabilities;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.armour.PonyArmor;
import net.minecraft.entity.Entity;
public interface IModel {
/**
* Sets up this model's initial values, like a constructor...
* @param yOffset YPosition for this model. Always 0.
* @param stretch Scaling factor for this model. Ranges above or below 0 (no change).
*/
void init(float yOffset, float stretch);
/**
* Applies a transform particular to a certain body part.
*/
void transform(BodyPart part);
/**
* Returns a new pony armour to go with this model. Called on startup by a model wrapper.
*/
PonyArmor createArmour();
/**
* Returns true if this model is on the ground and crouching.
*/

View file

@ -17,4 +17,9 @@ public interface IModelUnicorn extends IModel {
* @return
*/
boolean isCasting();
/**
* Gets the preferred magic color for this mode.
*/
int getMagicColor();
}

View file

@ -12,8 +12,13 @@ public class PonySnout {
private PlaneRenderer mare;
private PlaneRenderer stallion;
public PonySnout(AbstractPonyModel pony, float yOffset, float stretch) {
public PonySnout(AbstractPonyModel pony) {
mare = new PlaneRenderer(pony);
stallion = new PlaneRenderer(pony);
pony.bipedHead.addChild(stallion);
}
public void init(float yOffset, float stretch) {
mare.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.tex(10, 14) .addBackPlane(-2, 2, -5, 4, 2, stretch)
@ -26,9 +31,6 @@ public class PonySnout {
.tex(14, 14) .addEastPlane( 2, 2, -5, 2, 1, stretch)
.tex(11, 12) .addWestPlane(-1, 1, -5, 1, 1, stretch)
.tex(12, 12) .addEastPlane( 1, 1, -5, 1, 1, stretch);
pony.bipedHead.addChild(mare);
stallion = new PlaneRenderer(pony);
stallion.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.tex(10, 13) .addBackPlane(-2, 1, -5, 4, 3, stretch)
@ -36,7 +38,6 @@ public class PonySnout {
.tex(18, 7).addBottomPlane(-2, 4, -5, 4, 1, stretch)
.tex(10, 13) .addWestPlane(-2, 1, -5, 3, 1, stretch)
.tex(13, 13) .addEastPlane( 2, 1, -5, 3, 1, stretch);
pony.bipedHead.addChild(stallion);
}
public void setGender(PonyGender gender) {

View file

@ -112,6 +112,11 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn {
return rightArmPose != ArmPose.EMPTY || leftArmPose != ArmPose.EMPTY;
}
@Override
public int getMagicColor() {
return metadata.getGlowColor();
}
@Override
protected void sneakLegs() {
super.sneakLegs();
@ -136,7 +141,7 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn {
if (canCast()) {
horn.render(scale);
if (isCasting()) {
horn.renderMagic(metadata.getGlowColor(), scale);
horn.renderMagic(getMagicColor(), scale);
}
}
}
@ -146,7 +151,6 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn {
super.initLegTextures();
unicornArmLeft = new PonyRenderer(this, 40, 32).size(64, 64);
unicornArmRight = new PonyRenderer(this, 40, 32).size(64, 64);
boxList.remove(unicornArmRight);
}
@Override
@ -155,7 +159,7 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn {
float armY = THIRDP_ARM_CENTRE_Y - 6;
float armZ = THIRDP_ARM_CENTRE_Z - 2;
unicornArmLeft .box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(5, yOffset + 2, 0);
unicornArmRight.box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(-5, yOffset + 2, 0);
unicornArmLeft .box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25F).around(5, yOffset + 2, 0);
unicornArmRight.box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25F).around(-5, yOffset + 2, 0);
}
}

View file

@ -6,6 +6,7 @@ import com.minelittlepony.model.armour.ModelPonyArmor;
import com.minelittlepony.model.armour.PonyArmor;
import com.minelittlepony.model.components.PonySnout;
import com.minelittlepony.model.components.PonyTail;
import com.minelittlepony.render.AbstractPonyRenderer;
import com.minelittlepony.render.PonyRenderer;
import com.minelittlepony.render.plane.PlaneRenderer;
@ -23,7 +24,7 @@ public class ModelEarthPony extends AbstractPonyModel {
private final boolean smallArms;
public ModelRenderer bipedCape;
public PonyRenderer bipedCape;
public PlaneRenderer upperTorso;
public PlaneRenderer neck;
@ -41,12 +42,6 @@ public class ModelEarthPony extends AbstractPonyModel {
return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor());
}
@Override
public void init(float yOffset, float stretch) {
super.init(yOffset, stretch);
snout = new PonySnout(this, yOffset, stretch);
}
@Override
public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) {
super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity);
@ -366,10 +361,10 @@ public class ModelEarthPony extends AbstractPonyModel {
setHead(1, 2, isSneak ? -1 : 1);
shiftRotationPoint(bipedRightArm, 0, 2, 6);
shiftRotationPoint(bipedLeftArm, 0, 2, 6);
shiftRotationPoint(bipedRightLeg, 0, 2, -8);
shiftRotationPoint(bipedLeftLeg, 0, 2, -8);
AbstractPonyRenderer.shiftRotationPoint(bipedRightArm, 0, 2, 6);
AbstractPonyRenderer.shiftRotationPoint(bipedLeftArm, 0, 2, 6);
AbstractPonyRenderer.shiftRotationPoint(bipedRightLeg, 0, 2, -8);
AbstractPonyRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8);
}
protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) {
@ -383,7 +378,7 @@ public class ModelEarthPony extends AbstractPonyModel {
arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX;
arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F;
if (shift) shiftRotationPoint(arm, 0, 0, 1);
if (shift) AbstractPonyRenderer.shiftRotationPoint(arm, 0, 0, 1);
}
protected void fixSpecialRotationPoints(float move) {
@ -467,6 +462,7 @@ public class ModelEarthPony extends AbstractPonyModel {
bipedCape = new PonyRenderer(this, 0, 0).size(64, 32);
bipedHead = new PonyRenderer(this, 0, 0);
bipedHeadwear = new PonyRenderer(this, 32, 0);
snout = new PonySnout(this);
}
protected void initBodyTextures() {
@ -507,6 +503,8 @@ public class ModelEarthPony extends AbstractPonyModel {
}
protected void initHeadPositions(float yOffset, float stretch) {
snout.init(yOffset, stretch);
bipedCape.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch);
((PonyRenderer)bipedHead).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z)

View file

@ -3,6 +3,7 @@ package com.minelittlepony.model.ponies;
import com.minelittlepony.model.ModelMobPony;
import com.minelittlepony.model.armour.ModelZombiePonyArmor;
import com.minelittlepony.model.armour.PonyArmor;
import com.minelittlepony.render.AbstractPonyRenderer;
public class ModelZombiePony extends ModelMobPony {
@ -32,9 +33,9 @@ public class ModelZombiePony extends ModelMobPony {
if (rightArmPose != ArmPose.EMPTY) return;
if (islookAngleRight(move)) {
shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3);
AbstractPonyRenderer.shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3);
} else {
shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3);
AbstractPonyRenderer.shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3);
}
}
}

View file

@ -80,6 +80,15 @@ public abstract class AbstractPonyRenderer<T extends AbstractPonyRenderer<T>> ex
return (T) this;
}
/**
* Adjusts the rotation center of the given renderer by the given amounts in each direction.
*/
public static void shiftRotationPoint(ModelRenderer renderer, float x, float y, float z) {
renderer.rotationPointX += x;
renderer.rotationPointY += y;
renderer.rotationPointZ += z;
}
/**
* Sets this renderer's rotation angles.
*/

View file

@ -2,13 +2,13 @@ package com.minelittlepony.render;
import static net.minecraft.client.renderer.GlStateManager.color;
import com.minelittlepony.util.coordinates.Color;
import net.minecraft.client.model.ModelBase;
public class HornGlowRenderer extends AbstractPonyRenderer<HornGlowRenderer> {
float red;
float green;
float blue;
int tint;
float alpha = 1;
public HornGlowRenderer(ModelBase model, int x, int y) {
@ -22,15 +22,13 @@ public class HornGlowRenderer extends AbstractPonyRenderer<HornGlowRenderer> {
}
public HornGlowRenderer setTint(int tint) {
red = (tint >> 16 & 255) / 255.0F;
green = (tint >> 8 & 255) / 255.0F;
blue = (tint & 255) / 255.0F;
this.tint = tint;
return this;
}
public void applyTint(float alpha) {
color(red, green, blue, alpha);
Color.glColor(tint, alpha);
}
@Override

View file

@ -2,6 +2,7 @@ package com.minelittlepony.render.layer;
import com.minelittlepony.ducks.IRenderPony;
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.capabilities.IModel;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderLivingBase;
@ -33,8 +34,9 @@ public abstract class AbstractPonyLayer<T extends EntityLivingBase> implements L
return ((IRenderPony) getRenderer()).getPlayerModel().getModel();
}
public AbstractPonyModel getPonyModel() {
return getMainModel();
@SuppressWarnings("unchecked")
public <M extends IModel> M getPonyModel() {
return (M)getMainModel();
}
@SuppressWarnings("unchecked")

View file

@ -7,13 +7,11 @@ import static net.minecraft.client.renderer.GlStateManager.pushMatrix;
import static net.minecraft.client.renderer.GlStateManager.scale;
import static net.minecraft.client.renderer.GlStateManager.translate;
import org.lwjgl.opengl.GL14;
import com.minelittlepony.ducks.IRenderItem;
import com.minelittlepony.model.capabilities.IModelUnicorn;
import com.minelittlepony.util.coordinates.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
@ -29,10 +27,10 @@ public class LayerHeldPonyItemMagical<T extends EntityLivingBase> extends LayerH
}
protected boolean isUnicorn() {
ModelBase model = getMainModel();
return model instanceof IModelUnicorn && ((IModelUnicorn) model).canCast();
return getMainModel() instanceof IModelUnicorn && this.<IModelUnicorn>getPonyModel().canCast();
}
@Override
protected void preItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) {
if (isUnicorn()) {
GlStateManager.translate(hand == EnumHandSide.LEFT ? -0.6F : 0.1F, 1, -0.5F);
@ -41,18 +39,17 @@ public class LayerHeldPonyItemMagical<T extends EntityLivingBase> extends LayerH
}
}
@Override
protected void postItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) {
if (isUnicorn()) {
renderItemGlow(entity, drop, transform, hand, getPonyModel().metadata.getGlowColor());
renderItemGlow(entity, drop, transform, hand, this.<IModelUnicorn>getPonyModel().getMagicColor());
}
}
/**
* Renders the main arm
*/
@Override
protected void renderArm(EnumHandSide side) {
if (isUnicorn()) {
((IModelUnicorn)getMainModel()).getUnicornArmForSide(side).postRender(0.0625F);
this.<IModelUnicorn>getPonyModel().getUnicornArmForSide(side).postRender(0.0625F);
} else {
super.renderArm(side);
}
@ -63,15 +60,10 @@ public class LayerHeldPonyItemMagical<T extends EntityLivingBase> extends LayerH
// enchantments mess up the rendering
drop = stackWithoutEnchantment(drop);
float red = (glowColor >> 16 & 255) / 255.0F;
float green = (glowColor >> 8 & 255) / 255.0F;
float blue = (glowColor & 255) / 255.0F;
float alpha = 0.2F;
pushMatrix();
disableLighting();
GL14.glBlendColor(red, green, blue, alpha);
Color.glColor(glowColor, 0.2F);
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
((IRenderItem) renderItem).useTransparency(true);

View file

@ -6,6 +6,7 @@ import com.minelittlepony.ducks.IRenderPony;
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.ModelWrapper;
import com.minelittlepony.model.armour.ModelPonyArmor;
import com.minelittlepony.util.coordinates.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
@ -69,11 +70,7 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
getRenderer().bindTexture(armors.getFirst());
if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) {
int color = itemarmor.getColor(itemstack);
float r = (color >> 16 & 255) / 255.0F;
float g = (color >> 8 & 255) / 255.0F;
float b = (color & 255) / 255.0F;
GlStateManager.color(r, g, b, 1);
Color.glColor(itemarmor.getColor(itemstack), 1);
modelbase.render(entity, move, swing, age, headYaw, headPitch, scale);
armors = getArmorTexture(entity, itemstack, armorSlot, "overlay");
getRenderer().bindTexture(armors.getFirst());

View file

@ -63,10 +63,10 @@ public class ModelPlane extends Box<PlaneRenderer> {
if (face == Face.DOWN) {
quad = quad(textureX, w, textureY, d, eus, wus, wun, eun);
}
if (face == Face.SOUTH) { // East/Left (was South)
if (face == Face.SOUTH) {
quad = quad(textureX, w, textureY, h, eds, wds, wus, eus);
}
if (face == Face.NORTH) { // West/Right (was North)
if (face == Face.NORTH) {
quad = quad(textureX, w, textureY, h, wdn, edn, eun, wun);
}

View file

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