mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-26 06:18:00 +01:00
Apply rider position on a per-size basis and recursively translate riders higher up the stack
This commit is contained in:
parent
46c4244b7e
commit
169ac3d3b9
4 changed files with 33 additions and 5 deletions
|
@ -1,11 +1,12 @@
|
|||
package com.minelittlepony.ducks;
|
||||
|
||||
import com.minelittlepony.model.AbstractPonyModel;
|
||||
import com.minelittlepony.model.BodyPart;
|
||||
import com.minelittlepony.model.ModelWrapper;
|
||||
import com.minelittlepony.pony.data.IPony;
|
||||
import com.minelittlepony.render.RenderPony;
|
||||
import com.minelittlepony.util.math.MathUtil;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +30,10 @@ public interface IRenderPony<T extends EntityLivingBase> {
|
|||
if (!passengerPony.getRace(false).isHuman()) {
|
||||
float yaw = MathUtil.interpolateDegress(entity.prevRenderYawOffset, entity.renderYawOffset, ticks);
|
||||
|
||||
GlStateManager.translate(0, 0, 0.3F);
|
||||
getModelWrapper().apply(entityPony.getMetadata());
|
||||
AbstractPonyModel model = getModelWrapper().getBody();
|
||||
|
||||
model.transform(BodyPart.BACK);
|
||||
|
||||
getInternalRenderer().applyPostureRiding(entity, entity.ticksExisted + ticks, yaw, ticks);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,6 @@ public enum BodyPart {
|
|||
BODY,
|
||||
TAIL,
|
||||
NECK,
|
||||
LEGS;
|
||||
|
||||
LEGS,
|
||||
BACK;
|
||||
}
|
||||
|
|
|
@ -44,16 +44,21 @@ public class RenderPony<T extends EntityLivingBase> {
|
|||
GlStateManager.scale(s, s, s);
|
||||
enableModelRenderProfile();
|
||||
|
||||
translateRider(entity, ticks);
|
||||
}
|
||||
|
||||
protected void translateRider(EntityLivingBase entity, float ticks) {
|
||||
if (entity.isRiding()) {
|
||||
Entity ridingEntity = entity.getRidingEntity();
|
||||
|
||||
if (ridingEntity instanceof EntityLivingBase) {
|
||||
translateRider((EntityLivingBase)ridingEntity, ticks);
|
||||
|
||||
IRenderPony<EntityLivingBase> renderer = MineLittlePony.getInstance().getRenderManager().getPonyRenderer((EntityLivingBase)ridingEntity);
|
||||
|
||||
if (renderer != null) {
|
||||
// negate vanilla translations so the rider begins at the ridees feet.
|
||||
GlStateManager.translate(0, entity.getYOffset() + ridingEntity.getMountedYOffset(), 0);
|
||||
GlStateManager.translate(0, (ridingEntity.posY - entity.posY), 0);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
IPony riderPony = renderer.getEntityPony((EntityLivingBase)ridingEntity);
|
||||
|
|
|
@ -22,6 +22,9 @@ public enum PonyTransformation {
|
|||
case HEAD:
|
||||
if (model.isCrouching()) translate(0, 0.1F, 0);
|
||||
break;
|
||||
case BACK:
|
||||
translate(0, 3, 0.5F);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +57,9 @@ public enum PonyTransformation {
|
|||
translate(0, -0.14F, 0);
|
||||
scale(1.15F, 1.12F, 1.15F);
|
||||
break;
|
||||
case BACK:
|
||||
translate(0, 2.3F, 0.3F);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -79,6 +85,9 @@ public enum PonyTransformation {
|
|||
translate(0, 0.1F, 0);
|
||||
scale(1, 0.81F, 1);
|
||||
break;
|
||||
case BACK:
|
||||
translate(0, 4.5F, 0.6F);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +118,9 @@ public enum PonyTransformation {
|
|||
scale(1, 1.18F, 1);
|
||||
if (model.isGoingFast()) translate(0, 0.05F, 0);
|
||||
break;
|
||||
case BACK:
|
||||
translate(0, 2F, 0.6F);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -139,9 +151,16 @@ public enum PonyTransformation {
|
|||
scale(1, 1.18F, 1);
|
||||
if (model.isGoingFast()) translate(0, 0.05F, 0);
|
||||
break;
|
||||
case BACK:
|
||||
translate(0, 4.3F, 0.6F);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public abstract void transform(IModel model, BodyPart part);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue