mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24:23 +01:00
Fixed positioning of ponies riding other ponies, and fixed hitbox calculation (sort of)
This commit is contained in:
parent
2f56d64cb5
commit
3db1965da4
10 changed files with 51 additions and 26 deletions
|
@ -38,7 +38,7 @@ public interface IRenderPony<T extends EntityLivingBase> {
|
||||||
|
|
||||||
model.transform(BodyPart.BACK);
|
model.transform(BodyPart.BACK);
|
||||||
|
|
||||||
getInternalRenderer().applyPostureRiding(entity, entity.ticksExisted + ticks, yaw, ticks);
|
getInternalRenderer().applyPostureRiding(entity, yaw, ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,11 +166,16 @@ public class Pony implements IPony {
|
||||||
public Vec3d getAbsoluteRidingOffset(EntityLivingBase entity) {
|
public Vec3d getAbsoluteRidingOffset(EntityLivingBase entity) {
|
||||||
IPony ridingPony = getMountedPony(entity);
|
IPony ridingPony = getMountedPony(entity);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (ridingPony != null) {
|
if (ridingPony != null) {
|
||||||
EntityLivingBase ridee = (EntityLivingBase)entity.getRidingEntity();
|
EntityLivingBase ridee = (EntityLivingBase)entity.getRidingEntity();
|
||||||
|
|
||||||
Vec3d offset = ridingPony.getMetadata().getSize().getTranformation().getRiderOffset();
|
Vec3d offset = ridingPony.getMetadata().getSize().getTranformation().getRiderOffset();
|
||||||
return ridingPony.getAbsoluteRidingOffset(ridee).add(-offset.x / 4, offset.y / 5, -offset.z / 4);
|
float scale = ridingPony.getMetadata().getSize().getScaleFactor();
|
||||||
|
|
||||||
|
return ridingPony.getAbsoluteRidingOffset(ridee)
|
||||||
|
.add(0, offset.y - ridee.height * 1/scale, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return entity.getPositionVector();
|
return entity.getPositionVector();
|
||||||
|
@ -178,13 +183,15 @@ public class Pony implements IPony {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getComputedBoundingBox(EntityLivingBase entity) {
|
public AxisAlignedBB getComputedBoundingBox(EntityLivingBase entity) {
|
||||||
float scale = getMetadata().getSize().getScaleFactor();
|
float scale = getMetadata().getSize().getScaleFactor() + 0.1F;
|
||||||
|
|
||||||
Vec3d pos = getAbsoluteRidingOffset(entity);
|
Vec3d pos = getAbsoluteRidingOffset(entity);
|
||||||
|
|
||||||
|
float width = entity.width * scale;
|
||||||
|
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
- entity.width / 2, (entity.height * scale), -entity.width / 2,
|
- width, (entity.height * scale), -width,
|
||||||
entity.width / 2, 0, entity.width / 2).offset(pos);
|
width, 0, width).offset(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.minelittlepony.model.AbstractPonyModel;
|
||||||
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.transform.PonyPosture;
|
import com.minelittlepony.transform.PonyPosture;
|
||||||
|
import com.minelittlepony.util.math.MathUtil;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.culling.ICamera;
|
import net.minecraft.client.renderer.culling.ICamera;
|
||||||
|
@ -57,18 +58,27 @@ public class RenderPony<T extends EntityLivingBase> {
|
||||||
translateRider(entity, ticks);
|
translateRider(entity, ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getRenderYaw(T entity, float rotationYaw, float partialTicks) {
|
||||||
|
if (entity.isRiding()) {
|
||||||
|
Entity mount = entity.getRidingEntity();
|
||||||
|
if (mount instanceof EntityLivingBase) {
|
||||||
|
return MathUtil.interpolateDegress(((EntityLivingBase)mount).prevRenderYawOffset, ((EntityLivingBase)mount).renderYawOffset, partialTicks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rotationYaw;
|
||||||
|
}
|
||||||
|
|
||||||
protected void translateRider(EntityLivingBase entity, float 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, (ridingEntity.posY - entity.posY), 0);
|
GlStateManager.translate(0, -ridingEntity.height, 0);
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
IPony riderPony = renderer.getEntityPony((EntityLivingBase)ridingEntity);
|
IPony riderPony = renderer.getEntityPony((EntityLivingBase)ridingEntity);
|
||||||
|
@ -80,25 +90,25 @@ public class RenderPony<T extends EntityLivingBase> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void applyPostureTransform(T player, float pitch, float yaw, float ticks) {
|
public void applyPostureTransform(T player, float yaw, float ticks) {
|
||||||
PonyPosture<?> posture = getPosture(player);
|
PonyPosture<?> posture = getPosture(player);
|
||||||
if (posture != null && posture.applies(player)) {
|
if (posture != null && posture.applies(player)) {
|
||||||
double motionX = player.posX - player.prevPosX;
|
double motionX = player.posX - player.prevPosX;
|
||||||
double motionY = player.onGround ? 0 : player.posY - player.prevPosY;
|
double motionY = player.onGround ? 0 : player.posY - player.prevPosY;
|
||||||
double motionZ = player.posZ - player.prevPosZ;
|
double motionZ = player.posZ - player.prevPosZ;
|
||||||
((PonyPosture<EntityLivingBase>)posture).transform(ponyModel, player, motionX, motionY, motionZ, pitch, yaw, ticks);
|
((PonyPosture<EntityLivingBase>)posture).transform(ponyModel, player, motionX, motionY, motionZ, yaw, ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void applyPostureRiding(T player, float pitch, float yaw, float ticks) {
|
public void applyPostureRiding(T player, float yaw, float ticks) {
|
||||||
PonyPosture<?> posture = getPosture(player);
|
PonyPosture<?> posture = getPosture(player);
|
||||||
if (posture != null && posture.applies(player)) {
|
if (posture != null && posture.applies(player)) {
|
||||||
double motionX = player.posX - player.prevPosX;
|
double motionX = player.posX - player.prevPosX;
|
||||||
double motionY = player.onGround ? 0 : player.posY - player.prevPosY;
|
double motionY = player.onGround ? 0 : player.posY - player.prevPosY;
|
||||||
double motionZ = player.posZ - player.prevPosZ;
|
double motionZ = player.posZ - player.prevPosZ;
|
||||||
|
|
||||||
((PonyPosture<EntityLivingBase>)posture).transform(ponyModel, player, motionX, -motionY, motionZ, pitch, yaw, ticks);
|
((PonyPosture<EntityLivingBase>)posture).transform(ponyModel, player, motionX, -motionY, motionZ, yaw, ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,12 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
|
||||||
DebugBoundingBoxRenderer.instance.render(renderPony.getPony(entity), entity, ticks);
|
DebugBoundingBoxRenderer.instance.render(renderPony.getPony(entity), entity, ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void applyRotations(T entity, float ageInTicks, float rotationYaw, float partialTicks) {
|
||||||
|
rotationYaw = renderPony.getRenderYaw(entity, rotationYaw, partialTicks);
|
||||||
|
super.applyRotations(entity, ageInTicks, rotationYaw, partialTicks);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldRender(T entity, ICamera camera, double camX, double camY, double camZ) {
|
public boolean shouldRender(T entity, ICamera camera, double camX, double camY, double camZ) {
|
||||||
return super.shouldRender(entity, renderPony.getFrustrum(entity, camera), camX, camY, camZ);
|
return super.shouldRender(entity, renderPony.getFrustrum(entity, camera), camX, camY, camZ);
|
||||||
|
|
|
@ -144,10 +144,11 @@ public class RenderPonyPlayer extends RenderPlayer implements IRenderPony<Abstra
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void applyRotations(AbstractClientPlayer player, float yaw, float pitch, float ticks) {
|
protected void applyRotations(AbstractClientPlayer player, float age, float yaw, float ticks) {
|
||||||
super.applyRotations(player, yaw, pitch, ticks);
|
yaw = renderPony.getRenderYaw(player, yaw, ticks);
|
||||||
|
super.applyRotations(player, age, yaw, ticks);
|
||||||
|
|
||||||
renderPony.applyPostureTransform(player, yaw, pitch, ticks);
|
renderPony.applyPostureTransform(player, yaw, ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,5 +14,5 @@ public interface PonyPosture<T extends EntityLivingBase> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void transform(AbstractPonyModel model, T entity, double motionX, double motionY, double motionZ, float pitch, float yaw, float ticks);
|
void transform(AbstractPonyModel model, T entity, double motionX, double motionY, double motionZ, float yaw, float ticks);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import com.minelittlepony.model.capabilities.IModel;
|
||||||
|
|
||||||
public enum PonyTransformation {
|
public enum PonyTransformation {
|
||||||
|
|
||||||
NORMAL(0, 3, 0.5F) {
|
NORMAL(0, 3F, 0.75F) {
|
||||||
@Override
|
@Override
|
||||||
public void transform(IModel model, BodyPart part) {
|
public void transform(IModel model, BodyPart part) {
|
||||||
if (model.isCrouching()) translate(0, -0.2F, 0);
|
if (model.isCrouching()) translate(0, -0.2F, 0);
|
||||||
|
@ -31,7 +31,7 @@ public enum PonyTransformation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
LANKY(0, 2.3F, 0.3F) {
|
LANKY(0, 2.6F, 0.75F) {
|
||||||
@Override
|
@Override
|
||||||
public void transform(IModel model, BodyPart part) {
|
public void transform(IModel model, BodyPart part) {
|
||||||
if (model.isCrouching()) translate(0, -0.15F, 0);
|
if (model.isCrouching()) translate(0, -0.15F, 0);
|
||||||
|
@ -65,7 +65,7 @@ public enum PonyTransformation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
BULKY(0, 2.3F, 0.3F) {
|
BULKY(0, 2.3F, 0.75F) {
|
||||||
@Override
|
@Override
|
||||||
public void transform(IModel model, BodyPart part) {
|
public void transform(IModel model, BodyPart part) {
|
||||||
if (model.isCrouching()) translate(0, -0.15F, 0);
|
if (model.isCrouching()) translate(0, -0.15F, 0);
|
||||||
|
@ -99,7 +99,7 @@ public enum PonyTransformation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
FOAL(0, 4.5F, 0.6F) {
|
FOAL(0, 3.8F, 0.75F) {
|
||||||
@Override
|
@Override
|
||||||
public void transform(IModel model, BodyPart part) {
|
public void transform(IModel model, BodyPart part) {
|
||||||
if (model.isCrouching()) translate(0, -0.3F, 0);
|
if (model.isCrouching()) translate(0, -0.3F, 0);
|
||||||
|
@ -128,7 +128,7 @@ public enum PonyTransformation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TALL(0, 2F, 0.6F) {
|
TALL(0, 2.2F, 0.75F) {
|
||||||
@Override
|
@Override
|
||||||
public void transform(IModel model, BodyPart part) {
|
public void transform(IModel model, BodyPart part) {
|
||||||
if (model.isCrouching()) translate(0, -0.15F, 0);
|
if (model.isCrouching()) translate(0, -0.15F, 0);
|
||||||
|
@ -155,12 +155,13 @@ public enum PonyTransformation {
|
||||||
if (model.isGoingFast()) translate(0, 0.05F, 0);
|
if (model.isGoingFast()) translate(0, 0.05F, 0);
|
||||||
break;
|
break;
|
||||||
case BACK:
|
case BACK:
|
||||||
|
riderOffset = new Vec3d(0, 2.2F, 0.75F);
|
||||||
translateVec(riderOffset);
|
translateVec(riderOffset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
YEARLING(0, 4.3F, 0.6F) {
|
YEARLING(0, 3.8F, 0.75F) {
|
||||||
@Override
|
@Override
|
||||||
public void transform(IModel model, BodyPart part) {
|
public void transform(IModel model, BodyPart part) {
|
||||||
if (model.isCrouching()) translate(0, -0.15F, 0);
|
if (model.isCrouching()) translate(0, -0.15F, 0);
|
||||||
|
@ -194,7 +195,7 @@ public enum PonyTransformation {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected final Vec3d riderOffset;
|
protected Vec3d riderOffset;
|
||||||
|
|
||||||
PonyTransformation(float rX, float rY, float rZ) {
|
PonyTransformation(float rX, float rY, float rZ) {
|
||||||
riderOffset = new Vec3d(rX, rY, rZ);
|
riderOffset = new Vec3d(rX, rY, rZ);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import net.minecraft.entity.EntityLivingBase;
|
||||||
|
|
||||||
public class PostureElytra implements PonyPosture<EntityLivingBase> {
|
public class PostureElytra implements PonyPosture<EntityLivingBase> {
|
||||||
@Override
|
@Override
|
||||||
public void transform(AbstractPonyModel model, EntityLivingBase entity, double motionX, double motionY, double motionZ, float pitch, float yaw, float ticks) {
|
public void transform(AbstractPonyModel model, EntityLivingBase entity, double motionX, double motionY, double motionZ, float yaw, float ticks) {
|
||||||
GlStateManager.rotate(90, 1, 0, 0);
|
GlStateManager.rotate(90, 1, 0, 0);
|
||||||
GlStateManager.translate(0, entity.isSneaking() ? 0.2F : -1, 0);
|
GlStateManager.translate(0, entity.isSneaking() ? 0.2F : -1, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import net.minecraft.entity.EntityLivingBase;
|
||||||
|
|
||||||
public class PostureFalling implements PonyPosture<EntityLivingBase> {
|
public class PostureFalling implements PonyPosture<EntityLivingBase> {
|
||||||
@Override
|
@Override
|
||||||
public void transform(AbstractPonyModel model, EntityLivingBase entity, double motionX, double motionY, double motionZ, float pitch, float yaw, float ticks) {
|
public void transform(AbstractPonyModel model, EntityLivingBase entity, double motionX, double motionY, double motionZ, float yaw, float ticks) {
|
||||||
model.motionPitch = 0;
|
model.motionPitch = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class PostureFlight extends MotionCompositor implements PonyPosture<Abstr
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transform(AbstractPonyModel model, AbstractClientPlayer player, double motionX, double motionY, double motionZ, float pitch, float yaw, float ticks) {
|
public void transform(AbstractPonyModel model, AbstractClientPlayer player, double motionX, double motionY, double motionZ, float yaw, float ticks) {
|
||||||
model.motionPitch = (float) calculateIncline(player, motionX, motionY, motionZ);
|
model.motionPitch = (float) calculateIncline(player, motionX, motionY, motionZ);
|
||||||
|
|
||||||
GlStateManager.rotate(model.motionPitch, 1, 0, 0);
|
GlStateManager.rotate(model.motionPitch, 1, 0, 0);
|
||||||
|
|
Loading…
Reference in a new issue