Apply rider position on a per-size basis and recursively translate riders higher up the stack

This commit is contained in:
Sollace 2018-09-20 11:33:27 +02:00
parent 46c4244b7e
commit 169ac3d3b9
4 changed files with 33 additions and 5 deletions

View file

@ -1,11 +1,12 @@
package com.minelittlepony.ducks; package com.minelittlepony.ducks;
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.ModelWrapper; import com.minelittlepony.model.ModelWrapper;
import com.minelittlepony.pony.data.IPony; import com.minelittlepony.pony.data.IPony;
import com.minelittlepony.render.RenderPony; import com.minelittlepony.render.RenderPony;
import com.minelittlepony.util.math.MathUtil; import com.minelittlepony.util.math.MathUtil;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
/** /**
@ -29,7 +30,10 @@ public interface IRenderPony<T extends EntityLivingBase> {
if (!passengerPony.getRace(false).isHuman()) { if (!passengerPony.getRace(false).isHuman()) {
float yaw = MathUtil.interpolateDegress(entity.prevRenderYawOffset, entity.renderYawOffset, ticks); 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); getInternalRenderer().applyPostureRiding(entity, entity.ticksExisted + ticks, yaw, ticks);
} }

View file

@ -5,6 +5,6 @@ public enum BodyPart {
BODY, BODY,
TAIL, TAIL,
NECK, NECK,
LEGS; LEGS,
BACK;
} }

View file

@ -44,16 +44,21 @@ public class RenderPony<T extends EntityLivingBase> {
GlStateManager.scale(s, s, s); GlStateManager.scale(s, s, s);
enableModelRenderProfile(); enableModelRenderProfile();
translateRider(entity, ticks);
}
protected void translateRider(EntityLivingBase entity, float ticks) {
if (entity.isRiding()) { if (entity.isRiding()) {
Entity ridingEntity = entity.getRidingEntity(); Entity ridingEntity = entity.getRidingEntity();
if (ridingEntity instanceof EntityLivingBase) { if (ridingEntity instanceof EntityLivingBase) {
translateRider((EntityLivingBase)ridingEntity, ticks);
IRenderPony<EntityLivingBase> renderer = MineLittlePony.getInstance().getRenderManager().getPonyRenderer((EntityLivingBase)ridingEntity); IRenderPony<EntityLivingBase> renderer = MineLittlePony.getInstance().getRenderManager().getPonyRenderer((EntityLivingBase)ridingEntity);
if (renderer != null) { if (renderer != null) {
// negate vanilla translations so the rider begins at the ridees feet. // 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") @SuppressWarnings("unchecked")
IPony riderPony = renderer.getEntityPony((EntityLivingBase)ridingEntity); IPony riderPony = renderer.getEntityPony((EntityLivingBase)ridingEntity);

View file

@ -22,6 +22,9 @@ public enum PonyTransformation {
case HEAD: case HEAD:
if (model.isCrouching()) translate(0, 0.1F, 0); if (model.isCrouching()) translate(0, 0.1F, 0);
break; break;
case BACK:
translate(0, 3, 0.5F);
break;
default: default:
} }
} }
@ -54,6 +57,9 @@ public enum PonyTransformation {
translate(0, -0.14F, 0); translate(0, -0.14F, 0);
scale(1.15F, 1.12F, 1.15F); scale(1.15F, 1.12F, 1.15F);
break; break;
case BACK:
translate(0, 2.3F, 0.3F);
break;
} }
} }
}, },
@ -79,6 +85,9 @@ public enum PonyTransformation {
translate(0, 0.1F, 0); translate(0, 0.1F, 0);
scale(1, 0.81F, 1); scale(1, 0.81F, 1);
break; break;
case BACK:
translate(0, 4.5F, 0.6F);
break;
default: default:
} }
} }
@ -109,6 +118,9 @@ public enum PonyTransformation {
scale(1, 1.18F, 1); scale(1, 1.18F, 1);
if (model.isGoingFast()) translate(0, 0.05F, 0); if (model.isGoingFast()) translate(0, 0.05F, 0);
break; break;
case BACK:
translate(0, 2F, 0.6F);
break;
} }
} }
}, },
@ -139,9 +151,16 @@ public enum PonyTransformation {
scale(1, 1.18F, 1); scale(1, 1.18F, 1);
if (model.isGoingFast()) translate(0, 0.05F, 0); if (model.isGoingFast()) translate(0, 0.05F, 0);
break; break;
case BACK:
translate(0, 4.3F, 0.6F);
break;
} }
} }
}; };
public abstract void transform(IModel model, BodyPart part); public abstract void transform(IModel model, BodyPart part);
} }