From 46c4244b7e99ce8879482968ccf7cd7f504da7d9 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 19 Sep 2018 23:22:59 +0200 Subject: [PATCH] Adjust ponies riding posture to be less propane --- .../com/minelittlepony/PonyRenderManager.java | 6 ++- .../com/minelittlepony/ducks/IRenderPony.java | 2 +- .../model/AbstractPonyModel.java | 37 +++++++++++++++++-- .../com/minelittlepony/pony/data/IPony.java | 12 ++++++ .../com/minelittlepony/pony/data/Pony.java | 16 ++++++++ 5 files changed, 68 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java index 4d6e58b4..318cc2dd 100644 --- a/src/main/java/com/minelittlepony/PonyRenderManager.java +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -97,7 +97,11 @@ public class PonyRenderManager { @SuppressWarnings("unchecked") @Nullable - public & IRenderPony> R getPonyRenderer(T entity) { + public & IRenderPony> R getPonyRenderer(@Nullable Entity entity) { + if (entity == null || !(entity instanceof EntityLivingBase)) { + return null; + } + Render renderer = Minecraft.getMinecraft().getRenderManager().getEntityRenderObject(entity); if (renderer instanceof RenderLivingBase && renderer instanceof IRenderPony) { diff --git a/src/main/java/com/minelittlepony/ducks/IRenderPony.java b/src/main/java/com/minelittlepony/ducks/IRenderPony.java index 6e84f6d5..6abb29a4 100644 --- a/src/main/java/com/minelittlepony/ducks/IRenderPony.java +++ b/src/main/java/com/minelittlepony/ducks/IRenderPony.java @@ -29,7 +29,7 @@ public interface IRenderPony { 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); } diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 51116541..8cf3fd0d 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -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,9 +186,17 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel, P } protected void adjustBodyRiding() { - 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); + 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); + } + + } /** diff --git a/src/main/java/com/minelittlepony/pony/data/IPony.java b/src/main/java/com/minelittlepony/pony/data/IPony.java index c80a0ace..b12b220c 100644 --- a/src/main/java/com/minelittlepony/pony/data/IPony.java +++ b/src/main/java/com/minelittlepony/pony/data/IPony.java @@ -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 diff --git a/src/main/java/com/minelittlepony/pony/data/Pony.java b/src/main/java/com/minelittlepony/pony/data/Pony.java index 258fa4b4..ca067d75 100644 --- a/src/main/java/com/minelittlepony/pony/data/Pony.java +++ b/src/main/java/com/minelittlepony/pony/data/Pony.java @@ -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 render = MineLittlePony.getInstance().getRenderManager().getPonyRenderer(mount); + + return render == null ? null : render.getEntityPony((EntityLivingBase)mount); + } + @Override public String toString() { return MoreObjects.toStringHelper(this)