Clean up and get rid of this weird split between textures and positions

This commit is contained in:
Sollace 2018-06-21 23:49:11 +02:00
parent b14a6cb233
commit aed1dbd8d3
10 changed files with 148 additions and 205 deletions

View file

@ -7,6 +7,7 @@ import com.minelittlepony.model.capabilities.IModelPart;
import com.minelittlepony.model.components.PonySnout;
import com.minelittlepony.model.components.PonyTail;
import com.minelittlepony.pony.data.IPonyData;
import com.minelittlepony.pony.data.Pony;
import com.minelittlepony.pony.data.PonyData;
import com.minelittlepony.pony.data.PonySize;
import com.minelittlepony.render.AbstractPonyRenderer;
@ -18,6 +19,7 @@ import net.minecraft.client.model.ModelPlayer;
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.EnumHandSide;
import net.minecraft.util.math.MathHelper;
@ -31,10 +33,11 @@ import static com.minelittlepony.model.PonyModelConstants.*;
*/
public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
public boolean isFlying;
public boolean isSleeping;
public boolean isSwimming;
public boolean headGear;
protected boolean isSleeping;
private boolean isFlying;
private boolean isSwimming;
private boolean headGear;
/**
* Associcated pony data.
@ -73,6 +76,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
rainboom = canFly() && Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ) > 0.4F;
}
public void updateLivingState(EntityLivingBase entity, Pony pony) {
isSneak = entity.isSneaking();
isSleeping = entity.isPlayerSleeping();
isFlying = pony.isPegasusFlying(entity);
isSwimming = pony.isSwimming(entity);
headGear = pony.isWearingHeadgear(entity);
}
/**
* Sets the model's various rotation angles.
*
@ -469,94 +480,53 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
}
public void init(float yOffset, float stretch) {
// TODO: Splitting things like this isn't strictly neccessary and just complicates things.
initTextures();
initPositions(yOffset, stretch);
}
/**
* Loads texture values.
*/
protected void initTextures() {
boxList.clear();
initHeadTextures();
initBodyTextures();
initLegTextures();
initTailTextures();
initHead(yOffset, stretch);
initBody(yOffset, stretch);
initLegs(yOffset, stretch);
initTail(yOffset, stretch);
}
/**
* Loads texture positions and boxes. Pretty much just finishes the job of initTextures.
*/
protected void initPositions(float yOffset, float stretch) {
initHeadPositions(yOffset, stretch);
initBodyPositions(yOffset, stretch);
initLegPositions(yOffset, stretch);
initTailPositions(yOffset, stretch);
}
protected void initTailTextures() {
tail = new PonyTail(this);
}
protected void initHeadTextures() {
bipedHead = new PonyRenderer(this, 0, 0);
bipedHeadwear = new PonyRenderer(this, 32, 0);
protected void initHead(float yOffset, float stretch) {
snout = new PonySnout(this);
}
protected void initBodyTextures() {
bipedBody = new ModelRenderer(this, 16, 16);
if (textureHeight == 64) {
bipedBodyWear = new ModelRenderer(this, 16, 32);
}
upperTorso = new PlaneRenderer(this, 24, 0);
neck = new PlaneRenderer(this, 0, 16);
}
protected void initLegTextures() {
bipedLeftArm = new ModelRenderer(this, 32, 48);
bipedRightArm = new ModelRenderer(this, 40, 16);
bipedLeftArmwear = new ModelRenderer(this, 48, 48);
bipedRightArmwear = new ModelRenderer(this, 40, 32);
bipedLeftLeg = new ModelRenderer(this, 16, 48);
bipedRightLeg = new ModelRenderer(this, 0, 16);
bipedLeftLegwear = new ModelRenderer(this, 0, 48);
bipedRightLegwear = new ModelRenderer(this, 0, 32);
}
protected void initTailPositions(float yOffset, float stretch) {
tail.init(yOffset, stretch);
}
protected void initHeadPositions(float yOffset, float stretch) {
snout.init(yOffset, stretch);
((PonyRenderer)bipedHead).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z)
bipedHead = new PonyRenderer(this, 0, 0)
.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2)
.box(-4, -4, -4, 8, 8, 8, stretch)
.tex(12, 16).box(-4, -6, 1, 2, 2, 2, stretch)
.flip().box( 2, -6, 1, 2, 2, 2, stretch);
((PonyRenderer)bipedHeadwear).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z)
bipedHeadwear = new PonyRenderer(this, 32, 0)
.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2)
.box(-4, -4, -4, 8, 8, 8, stretch + 0.5F);
}
protected void initTail(float yOffset, float stretch) {
tail = new PonyTail(this);
tail.init(yOffset, stretch);
}
/**
* Creates the main torso and neck.
*/
protected void initBodyPositions(float yOffset, float stretch) {
bipedBody.addBox(-4, 4, -2, 8, 8, 4, stretch);
bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
protected void initBody(float yOffset, float stretch) {
if (textureHeight == 64) {
bipedBodyWear = new ModelRenderer(this, 16, 32);
}
bipedBody = new PonyRenderer(this, 16, 16)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.box(-4, 4, -2, 8, 8, 4, stretch);
bipedBodyWear.addBox(-4, 4, -2, 8, 8, 4, stretch + 0.25F);
bipedBodyWear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
upperTorso = new PlaneRenderer(this, 24, 0);
upperTorso.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.tex(24, 0) .addEastPlane( 4, -4, -4, 8, 8, stretch)
@ -575,34 +545,37 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
.addEastPlane( 1, 2, 2, 2, 6, stretch)
.addBackPlane(-1, 2, 8, 2, 2, stretch)
.flipZ().addWestPlane(-1, 2, 2, 2, 6, stretch)
.rotateAngleX = 0.5F;
.rotate(0.5F, 0, 0);
neck.at(NECK_CENTRE_X, NECK_CENTRE_Y, NECK_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
neck = new PlaneRenderer(this, 0, 16)
.at(NECK_CENTRE_X, NECK_CENTRE_Y, NECK_CENTRE_Z)
.rotate(NECK_ROT_X, 0, 0).around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.addFrontPlane(0, 0, 0, 4, 4, stretch)
.addBackPlane(0, 0, 4, 4, 4, stretch)
.addEastPlane(4, 0, 0, 4, 4, stretch)
.addWestPlane(0, 0, 0, 4, 4, stretch)
.rotateAngleX = NECK_ROT_X;
.addWestPlane(0, 0, 0, 4, 4, stretch);
}
protected int getArmWidth() {
return 4;
protected void preInitLegs() {
bipedLeftArm = new ModelRenderer(this, 32, 48);
bipedRightArm = new ModelRenderer(this, 40, 16);
bipedLeftLeg = new ModelRenderer(this, 16, 48);
bipedRightLeg = new ModelRenderer(this, 0, 16);
}
protected int getArmDepth() {
return 4;
protected void preInitLegwear() {
bipedLeftArmwear = new ModelRenderer(this, 48, 48);
bipedRightArmwear = new ModelRenderer(this, 40, 32);
bipedLeftLegwear = new ModelRenderer(this, 0, 48);
bipedRightLegwear = new ModelRenderer(this, 0, 32);
}
protected float getLegRotationX() {
return 3;
}
protected void initLegs(float yOffset, float stretch) {
preInitLegs();
preInitLegwear();
protected float getArmRotationY() {
return 8;
}
protected void initLegPositions(float yOffset, float stretch) {
int armWidth = getArmWidth();
int armDepth = getArmDepth();
@ -638,6 +611,22 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
bipedRightLegwear.setRotationPoint(-rarmX, yOffset, 0);
}
protected int getArmWidth() {
return 4;
}
protected int getArmDepth() {
return 4;
}
protected float getLegRotationX() {
return 3;
}
protected float getArmRotationY() {
return 8;
}
public ArmPose getArmPoseForSide(EnumHandSide side) {
return side == EnumHandSide.RIGHT ? rightArmPose : leftArmPose;
}

View file

@ -49,24 +49,6 @@ public class ModelPonyArmor extends AbstractPonyModel {
super.renderLegs(scale);
}
@Override
protected void initBodyTextures() {
super.initBodyTextures();
flankGuard = new PonyRenderer(this, 0, 0);
saddle = new PonyRenderer(this, 16, 8);
}
@Override
protected void initLegTextures() {
super.initLegTextures();
bipedLeftArm = new PonyRenderer(this, 0, 16).flip();
bipedRightArm = new PonyRenderer(this, 0, 16);
bipedLeftLeg = new PonyRenderer(this, 0, 16).flip();
bipedRightLeg = new PonyRenderer(this, 0, 16);
}
public void synchroniseLegs(AbstractPonyModel mainModel) {
copyModelAngles(mainModel.bipedRightArm, bipedRightArm);
copyModelAngles(mainModel.bipedLeftArm, bipedLeftArm);
@ -75,22 +57,34 @@ public class ModelPonyArmor extends AbstractPonyModel {
}
@Override
protected void initHeadPositions(float yOffset, float stretch) {
super.initHeadPositions(yOffset, stretch * 1.1F);
protected void initHead(float yOffset, float stretch) {
super.initHead(yOffset, stretch * 1.1F);
((PonyRenderer)bipedHead).child()
.tex(0, 4).box(2, -6, 1, 2, 2, 2, stretch * 0.5F)
.box(-4, -6, 1, 2, 2, 2, stretch * 0.5F);
}
@Override
protected void initBodyPositions(float yOffset, float stretch) {
super.initBodyPositions(yOffset, stretch);
flankGuard.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
protected void initBody(float yOffset, float stretch) {
super.initBody(yOffset, stretch);
flankGuard = new PonyRenderer(this, 0, 0)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.box(-4, 4, 6, 8, 8, 8, stretch);
saddle.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
saddle = new PonyRenderer(this, 16, 8)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.box(-4, 4, -2, 8, 8, 16, stretch);
}
@Override
protected void preInitLegs() {
bipedLeftArm = new PonyRenderer(this, 0, 16).flip();
bipedRightArm = new PonyRenderer(this, 0, 16);
bipedLeftLeg = new PonyRenderer(this, 0, 16).flip();
bipedRightLeg = new PonyRenderer(this, 0, 16);
}
@Override
public void setVisible(boolean invisible) {
super.setVisible(invisible);

View file

@ -44,18 +44,6 @@ public class ModelEarthPony extends AbstractPonyModel {
}
@Override
protected void initTextures() {
super.initTextures();
saddlebags = new SaddleBags(this);
}
@Override
protected void initPositions(float yOffset, float stretch) {
super.initPositions(yOffset, stretch);
saddlebags.init(yOffset, stretch);
}
protected float getLegOutset() {
if (smallArms) {
if (isSleeping) return 2.6f;
@ -65,26 +53,33 @@ public class ModelEarthPony extends AbstractPonyModel {
return super.getLegOutset();
}
@Override
protected int getArmWidth() {
return smallArms ? 3 : super.getArmWidth();
}
@Override
protected float getLegRotationX() {
return smallArms ? 2 : super.getLegRotationX();
}
@Override
protected float getArmRotationY() {
return smallArms ? 8.5f : super.getArmRotationY();
}
protected void initHeadTextures() {
super.initHeadTextures();
bipedCape = new PonyRenderer(this, 0, 0).size(64, 32);
@Override
protected void initHead(float yOffset, float stretch) {
super.initHead(yOffset, stretch);
bipedCape = new PonyRenderer(this, 0, 0)
.size(64, 32).box(-5, 0, -1, 10, 16, 1, stretch);
}
protected void initHeadPositions(float yOffset, float stretch) {
super.initHeadPositions(yOffset, stretch);
bipedCape.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch);
@Override
protected void initBody(float yOffset, float stretch) {
super.initBody(yOffset, stretch);
saddlebags = new SaddleBags(this);
saddlebags.init(yOffset, stretch);
}
@Override

View file

@ -147,15 +147,11 @@ public class ModelUnicorn extends ModelEarthPony implements IModelUnicorn {
}
@Override
protected void initLegTextures() {
super.initLegTextures();
protected void initLegs(float yOffset, float stretch) {
super.initLegs(yOffset, stretch);
unicornArmLeft = new PonyRenderer(this, 40, 32).size(64, 64);
unicornArmRight = new PonyRenderer(this, 40, 32).size(64, 64);
}
@Override
protected void initLegPositions(float yOffset, float stretch) {
super.initLegPositions(yOffset, stretch);
float armY = THIRDP_ARM_CENTRE_Y - 6;
float armZ = THIRDP_ARM_CENTRE_Z - 2;

View file

@ -26,16 +26,11 @@ public class ModelZebra extends ModelEarthPony {
}
@Override
protected void initHeadTextures() {
super.initHeadTextures();
protected void initHead(float yOffset, float stretch) {
super.initHead(yOffset, stretch);
bristles = new PonyRenderer(this, 56, 32);
bipedHead.addChild(bristles);
}
@Override
protected void initHeadPositions(float yOffset, float stretch) {
super.initHeadPositions(yOffset, stretch);
bristles.offset(-1, -1, -3)
.box(0, -10, 2, 2, 6, 2, stretch)

View file

@ -27,48 +27,38 @@ public class ModelSeapony extends ModelUnicorn {
}
@Override
protected void initLegTextures() {
super.initLegTextures();
protected void initLegs(float yOffset, float stretch) {
super.initLegs(yOffset, stretch);
// hide the back legs
bipedLeftLeg.showModel = false;
bipedRightLeg.showModel = false;
bipedLeftLegwear.showModel = false;
bipedRightLegwear.showModel = false;
centerFin = new PlaneRenderer(this, 58, 28);
leftFin = new PlaneRenderer(this, 56, 16);
rightFin = new PlaneRenderer(this, 56, 16);
}
@Override
protected void initLegPositions(float yOffset, float stretch) {
super.initLegPositions(yOffset, stretch);
centerFin.rotate(PI / 2 - 0.1F, 0, 0).around(0, 6, 9)
centerFin = new PlaneRenderer(this, 58, 28)
.rotate(PI / 2 - 0.1F, 0, 0).around(0, 6, 9)
.addEastPlane(0, -6, 0, 12, 6, stretch);
leftFin.rotate(0, FIN_ROTY, 0).around(3, -6, 3)
leftFin = new PlaneRenderer(this, 56, 16)
.rotate(0, FIN_ROTY, 0).around(3, -6, 3)
.flipZ().addEastPlane(0, 0, 0, 12, 8, stretch);
rightFin.rotate(0, -FIN_ROTY, 0).around(-3, -6, 3)
rightFin = new PlaneRenderer(this, 56, 16)
.rotate(0, -FIN_ROTY, 0).around(-3, -6, 3)
.addWestPlane(0, 0, 0, 12, 8, stretch);
}
@Override
protected void initTailTextures() {
protected void initTail(float yOffset, float stretch) {
tail = new SeaponyTail(this);
tail.init(yOffset, stretch);
}
@Override
protected void initBodyTextures() {
super.initBodyTextures();
bodyCenter = new PonyRenderer(this, 0, 48);
}
@Override
protected void initBodyPositions(float yOffset, float stretch) {
super.initBodyPositions(yOffset, stretch);
bodyCenter.around(0, 6, 1)
protected void initBody(float yOffset, float stretch) {
super.initBody(yOffset, stretch);
bodyCenter = new PonyRenderer(this, 0, 48)
.around(0, 6, 1)
.box(-3, -1, 0, 6, 7, 9, stretch).flip();
}

View file

@ -64,23 +64,17 @@ public class ModelVillagerPony extends ModelAlicorn {
}
@Override
protected void initTextures() {
super.initTextures();
public void init(float yOffset, float stretch) {
super.init(yOffset, stretch);
saddlebags = new SaddleBags(this);
apron = new PlaneRenderer(this, 56, 16);
trinket = new PlaneRenderer(this, 0, 3);
}
@Override
protected void initPositions(float yOffset, float stretch) {
super.initPositions(yOffset, stretch);
saddlebags.init(yOffset, stretch);
apron.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z)
apron = new PlaneRenderer(this, 56, 16)
.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.addBackPlane(-4, -4, -9, 8, 10, stretch);
trinket.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z)
trinket = new PlaneRenderer(this, 0, 3)
.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.addBackPlane(-2, -4, -9, 4, 5, stretch);
}

View file

@ -84,14 +84,9 @@ public class ModelWitchPony extends ModelZebra {
}
@Override
protected void initTextures() {
super.initTextures();
public void init(float yOffset, float stretch) {
super.init(yOffset, stretch);
witchHat = new PonyRenderer(this).size(64, 128);
}
@Override
protected void initPositions(float yOffset, float stretch) {
super.initPositions(yOffset, stretch);
witchHat.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2)
.tex(0, 64).box(-5, -6, -7, 10, 2, 10, stretch)
.child(0).around(1.75F, -4, 2)

View file

@ -31,18 +31,17 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
public RenderPonyMob(RenderManager manager, ModelWrapper model) {
super(manager, model.getBody(), 0.5F);
playerModel = model;
ponyModel = playerModel.getBody();
setPonyModel(model);
addLayers();
}
protected void addLayers() {
addLayer(new LayerPonyArmor<>(this));
addLayer(createItemHoldingLayer());
addLayer(new LayerArrow(this));
addLayer(new LayerPonyCustomHead<>(this));
addLayer(new LayerPonyElytra<>(this));
addLayer(createItemHoldingLayer());
}
protected LayerHeldPonyItem<T> createItemHoldingLayer() {
@ -61,11 +60,7 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
protected void preRenderCallback(T entity, float ticks) {
updateModel(entity);
ponyModel.isSneak = entity.isSneaking();
ponyModel.isSleeping = entity.isPlayerSleeping();
ponyModel.isFlying = pony.isPegasusFlying(entity);
ponyModel.isSwimming = pony.isSwimming(entity);
ponyModel.headGear = pony.isWearingHeadgear(entity);
ponyModel.updateLivingState(entity, pony);
super.preRenderCallback(entity, ticks);
shadowSize = getShadowScale();
@ -101,6 +96,11 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
return playerModel;
}
protected void setPonyModel(ModelWrapper model) {
playerModel = model;
ponyModel = playerModel.getBody();
}
protected void updateModel(T entity) {
pony = MineLittlePony.getInstance().getManager().getPony(getEntityTexture(entity), false);
playerModel.apply(pony.getMetadata());

View file

@ -30,20 +30,19 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony
public RenderPonyBase(RenderManager manager, boolean useSmallArms, ModelWrapper model) {
super(manager, useSmallArms);
setPlayerModel(model);
setPonyModel(model);
layerRenderers.clear();
addExtraLayers();
addLayers();
}
protected void addExtraLayers() {
protected void addLayers() {
addLayer(new LayerPonyArmor<>(this));
addLayer(new LayerHeldPonyItemMagical<>(this));
addLayer(new LayerArrow(this));
addLayer(new LayerPonyCape(this));
addLayer(new LayerPonyCustomHead<>(this));
addLayer(new LayerPonyElytra<>(this));
addLayer(new LayerPonyCape(this));
addLayer(new LayerEntityOnPonyShoulder(renderManager, this));
}
@ -70,11 +69,7 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony
protected void preRenderCallback(AbstractClientPlayer player, float ticks) {
updateModel(player);
ponyModel.isSneak = player.isSneaking();
ponyModel.isSleeping = player.isPlayerSleeping();
ponyModel.isFlying = pony.isPegasusFlying(player);
ponyModel.isSwimming = pony.isSwimming(player);
ponyModel.headGear = pony.isWearingHeadgear(player);
ponyModel.updateLivingState(player, pony);
super.preRenderCallback(player, ticks);
shadowSize = getShadowScale();
@ -149,7 +144,7 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony
return playerModel;
}
protected void setPlayerModel(ModelWrapper model) {
protected void setPonyModel(ModelWrapper model) {
playerModel = model;
mainModel = ponyModel = playerModel.getBody();
}