Adjust ponies riding posture to be less propane

This commit is contained in:
Sollace 2018-09-19 23:22:59 +02:00
parent ff57ec8e40
commit 46c4244b7e
5 changed files with 68 additions and 5 deletions

View file

@ -97,7 +97,11 @@ public class PonyRenderManager {
@SuppressWarnings("unchecked")
@Nullable
public <T extends EntityLivingBase, R extends RenderLivingBase<T> & IRenderPony<T>> R getPonyRenderer(T entity) {
public <T extends EntityLivingBase, R extends RenderLivingBase<T> & IRenderPony<T>> R getPonyRenderer(@Nullable Entity entity) {
if (entity == null || !(entity instanceof EntityLivingBase)) {
return null;
}
Render<Entity> renderer = Minecraft.getMinecraft().getRenderManager().getEntityRenderObject(entity);
if (renderer instanceof RenderLivingBase && renderer instanceof IRenderPony) {

View file

@ -29,7 +29,7 @@ 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.8F);
GlStateManager.translate(0, 0, 0.3F);
getInternalRenderer().applyPostureRiding(entity, entity.ticksExisted + ticks, yaw, ticks);
}

View file

@ -36,6 +36,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
public boolean isFlying;
public boolean isElytraFlying;
public boolean isSwimming;
public boolean isRidingInteractive;
public boolean headGear;
/**
@ -84,6 +85,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
isElytraFlying = entity.isElytraFlying();
isSwimming = pony.isSwimming(entity);
headGear = pony.isWearingHeadgear(entity);
isRidingInteractive = pony.isRidingInteractive(entity);
}
/**
@ -137,6 +139,27 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
bipedLeftArm.rotateAngleZ = -PI * 0.06f;
bipedRightArm.rotateAngleZ = PI * 0.06f;
if (isRidingInteractive) {
bipedLeftLeg.rotateAngleY = PI / 15;
bipedLeftLeg.rotateAngleX = PI / 9;
bipedLeftLeg.rotationPointZ = 10;
bipedLeftLeg.rotationPointY = 7;
bipedRightLeg.rotateAngleY = -PI / 15;
bipedRightLeg.rotateAngleX = PI / 9;
bipedRightLeg.rotationPointZ = 10;
bipedRightLeg.rotationPointY = 7;
bipedLeftArm.rotateAngleX = PI / 6;
bipedRightArm.rotateAngleX = PI / 6;
bipedLeftArm.rotateAngleZ *= 2;
bipedRightArm.rotateAngleZ *= 2;
}
} else {
adjustBody(BODY_ROT_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK);
@ -163,11 +186,19 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P
}
protected void adjustBodyRiding() {
if (isRidingInteractive) {
adjustBodyComponents(BODY_ROT_X_RIDING * 2, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING);
adjustNeck(BODY_ROT_X_NOTSNEAK * 2, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK - 4);
setHead(0, -2, -5);
} else {
adjustBodyComponents(BODY_ROT_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING);
adjustNeck(BODY_ROT_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK);
setHead(0, 0, 0);
}
}
/**
* Sets the model's various rotation angles.
*

View file

@ -51,6 +51,18 @@ public interface IPony {
*/
PonyRace getRace(boolean ignorePony);
/**
* Returns true if an entity is riding a pony or other sentient life-form.
*
* Boats do not count.
*/
boolean isRidingInteractive(EntityLivingBase entity);
/**
* Returns the pony this entity is currently riding if any.
*/
IPony getMountedPony(EntityLivingBase entity);
/**
* Gets the texture used for rendering this pony.
* @return

View file

@ -3,6 +3,7 @@ package com.minelittlepony.pony.data;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.ducks.IRenderPony;
import com.voxelmodpack.hdskins.resources.texture.IBufferedTexture;
import net.minecraft.block.material.Material;
@ -10,6 +11,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.resources.IResource;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
@ -146,6 +148,20 @@ public class Pony implements IPony {
return metadata;
}
@Override
public boolean isRidingInteractive(EntityLivingBase entity) {
return MineLittlePony.getInstance().getRenderManager().getPonyRenderer(entity.getRidingEntity()) != null;
}
@Override
public IPony getMountedPony(EntityLivingBase entity) {
Entity mount = entity.getRidingEntity();
IRenderPony<EntityLivingBase> render = MineLittlePony.getInstance().getRenderManager().getPonyRenderer(mount);
return render == null ? null : render.getEntityPony((EntityLivingBase)mount);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)