mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 04:27:59 +01:00
Fix riding position, and remove pony stacking (it was broken and I can't fix it)
This commit is contained in:
parent
807fb3213a
commit
cc463bb293
6 changed files with 16 additions and 100 deletions
|
@ -61,7 +61,7 @@ public class ModelAttributes {
|
|||
*/
|
||||
public boolean isLeftHanded;
|
||||
/**
|
||||
* True if the model is sitting as in boats.
|
||||
* True if the model is riding on the back of another pony.
|
||||
*/
|
||||
public boolean isRidingInteractive;
|
||||
/**
|
||||
|
|
|
@ -1,50 +1,28 @@
|
|||
package com.minelittlepony.client;
|
||||
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.api.pony.PonyPosture;
|
||||
import com.minelittlepony.client.transform.PonyTransformation;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class PonyBounds {
|
||||
public static Vec3d getAbsoluteRidingOffset(LivingEntity entity) {
|
||||
return PonyPosture.getMountPony(entity).map(ridingPony -> {
|
||||
LivingEntity vehicle = (LivingEntity)entity.getVehicle();
|
||||
|
||||
Vec3d offset = PonyTransformation.forSize(ridingPony.size()).getRiderOffset();
|
||||
float scale = ridingPony.metadata().size().scaleFactor();
|
||||
|
||||
return getAbsoluteRidingOffset(vehicle).add(
|
||||
0,
|
||||
offset.y - vehicle.getHeight() * 1 / scale,
|
||||
0
|
||||
);
|
||||
}).orElseGet(() -> getBaseRidingOffset(entity));
|
||||
}
|
||||
|
||||
private static Vec3d getBaseRidingOffset(LivingEntity entity) {
|
||||
float delta = MinecraftClient.getInstance().getTickDelta();
|
||||
|
||||
Entity vehicle = entity.getVehicle();
|
||||
double vehicleOffset = vehicle == null ? 0 : vehicle.getHeight();
|
||||
|
||||
return new Vec3d(
|
||||
MathHelper.lerp(delta, entity.prevX, entity.getX()),
|
||||
MathHelper.lerp(delta, entity.prevY, entity.getY()) + vehicleOffset,
|
||||
MathHelper.lerp(delta, entity.prevY, entity.getY()),
|
||||
MathHelper.lerp(delta, entity.prevZ, entity.getZ())
|
||||
);
|
||||
}
|
||||
|
||||
public static Box getBoundingBox(Pony pony, LivingEntity entity) {
|
||||
final float scale = pony.size().scaleFactor() + 0.1F;
|
||||
final float scale = pony.size().scaleFactor();
|
||||
final float width = entity.getWidth() * scale;
|
||||
final float height = entity.getHeight() * scale;
|
||||
|
||||
return new Box(-width, height, -width, width, 0, width).offset(getAbsoluteRidingOffset(entity));
|
||||
return new Box(-width, 0, -width, width, height, width).offset(getBaseRidingOffset(entity));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,14 +204,9 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
}
|
||||
|
||||
protected void ponySit() {
|
||||
adjustBodyComponents(BODY_RIDING_PITCH * (attributes.isRidingInteractive ? 2 : 1), BODY_RIDING);
|
||||
if (attributes.isRidingInteractive) {
|
||||
neck.setPivot(NECK_X, 0, -4);
|
||||
head.setPivot(0, -2, -5);
|
||||
} else {
|
||||
neck.setPivot(NECK_X, 0, 0);
|
||||
head.setPivot(0, 0, 0);
|
||||
}
|
||||
adjustBodyComponents(BODY_RIDING_PITCH, BODY_RIDING);
|
||||
neck.setPivot(NECK_X, 0, 0);
|
||||
head.setPivot(0, 0, 0);
|
||||
|
||||
leftLeg.pivotZ = 14;
|
||||
leftLeg.pivotY = 17;
|
||||
|
@ -231,26 +226,6 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
leftArm.pitch += body.pitch;
|
||||
rightArm.roll = MathHelper.PI * 0.06f;
|
||||
rightArm.pitch += body.pitch;
|
||||
|
||||
if (attributes.isRidingInteractive) {
|
||||
leftLeg.yaw = MathHelper.PI / 15;
|
||||
leftLeg.pitch = MathHelper.PI / 9;
|
||||
|
||||
leftLeg.pivotZ = 10;
|
||||
leftLeg.pivotY = 7;
|
||||
|
||||
rightLeg.yaw = -MathHelper.PI / 15;
|
||||
rightLeg.pitch = MathHelper.PI / 9;
|
||||
|
||||
rightLeg.pivotZ = 10;
|
||||
rightLeg.pivotY = 7;
|
||||
|
||||
leftArm.pitch = MathHelper.PI / 6;
|
||||
rightArm.pitch = MathHelper.PI / 6;
|
||||
|
||||
leftArm.roll *= 2;
|
||||
rightArm.roll *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -600,10 +575,6 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
}
|
||||
}
|
||||
|
||||
if (getAttributes().isRidingInteractive) {
|
||||
matrices.translate(left / 10, -0.2F, -0.5F);
|
||||
}
|
||||
|
||||
matrices.translate(-left * 0.1F, 0.45F, 0);
|
||||
|
||||
if (getAttributes().heldStack.getUseAction() == UseAction.BLOCK && getAttributes().itemUseTime == 0) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.minelittlepony.api.events.Channel;
|
|||
import com.minelittlepony.api.events.PonyDataCallback;
|
||||
import com.minelittlepony.api.model.*;
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.transform.PonyPosture;
|
||||
import com.minelittlepony.mson.api.ModelKey;
|
||||
import com.minelittlepony.util.MathUtil;
|
||||
|
@ -19,7 +18,6 @@ import net.minecraft.client.MinecraftClient;
|
|||
import net.minecraft.client.render.Frustum;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
|
@ -90,19 +88,6 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
|
|||
float s = getScaleFactor();
|
||||
stack.scale(s, s, s);
|
||||
|
||||
if (entity.hasVehicle() && entity.getVehicle() instanceof LivingEntity livingVehicles) {
|
||||
PonyRenderContext<LivingEntity, ?> renderer = MineLittlePony.getInstance().getRenderDispatcher().getPonyRenderer(livingVehicles);
|
||||
|
||||
if (renderer != null) {
|
||||
// negate vanilla translations so the rider begins at the ridees feet.
|
||||
stack.translate(0, -livingVehicles.getHeight(), 0);
|
||||
Pony pony = context.getEntityPony(entity);
|
||||
if (!pony.race().isHuman()) {
|
||||
renderer.getInternalRenderer().translateRider(livingVehicles, renderer.getEntityPony(livingVehicles), entity, pony, stack, tickDelta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entity instanceof PlayerEntity) {
|
||||
if (getModels().body().getAttributes().isSitting) {
|
||||
stack.translate(0, 0.125D, 0);
|
||||
|
@ -115,26 +100,11 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
|
|||
PonyPosture.of(getModels().body().getAttributes()).apply(entity, getModels().body(), stack, bodyYaw, tickDelta, 1);
|
||||
}
|
||||
|
||||
private void translateRider(T entity, Pony pony, LivingEntity passenger, Pony passengerPony, MatrixStack stack, float tickDelta) {
|
||||
if (!passengerPony.race().isHuman()) {
|
||||
float yaw = MathUtil.interpolateDegress((float)entity.prevY, (float)entity.getY(), tickDelta);
|
||||
|
||||
models.applyMetadata(pony.metadata());
|
||||
models.body().transform(BodyPart.BACK, stack);
|
||||
|
||||
PonyPosture.of(models.body().getAttributes()).apply(entity, getModels().body(), stack, yaw, tickDelta, -1);
|
||||
private float getMountedYaw(T entity, float bodyYaw, float tickDelta) {
|
||||
if (entity.hasVehicle() && entity.getVehicle() instanceof LivingEntity mount) {
|
||||
return bodyYaw + MathUtil.interpolateDegress(mount.prevBodyYaw, mount.bodyYaw, tickDelta);
|
||||
}
|
||||
}
|
||||
|
||||
private float getMountedYaw(T entity, float rotationYaw, float partialTicks) {
|
||||
if (entity.hasVehicle()) {
|
||||
Entity mount = entity.getVehicle();
|
||||
if (mount instanceof LivingEntity) {
|
||||
return MathUtil.interpolateDegress(((LivingEntity) mount).prevBodyYaw, ((LivingEntity) mount).bodyYaw, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
return rotationYaw;
|
||||
return bodyYaw;
|
||||
}
|
||||
|
||||
public float getScaleFactor() {
|
||||
|
|
|
@ -27,7 +27,6 @@ import net.minecraft.client.util.math.MatrixStack;
|
|||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public abstract class AbstractPonyRenderer<T extends MobEntity, M extends EntityModel<T> & PonyModel<T> & ModelWithArms> extends MobEntityRenderer<T, M> implements PonyRenderContext<T, M> {
|
||||
|
||||
|
@ -95,9 +94,9 @@ public abstract class AbstractPonyRenderer<T extends MobEntity, M extends Entity
|
|||
if (!entity.hasVehicle()) {
|
||||
stack.translate(0, 0, -entity.getWidth() / 2); // move us to the center of the shadow
|
||||
} else {
|
||||
// TODO: Check this
|
||||
Vec3d attachmentPos = entity.getVehicleAttachmentPos(entity.getVehicle());
|
||||
stack.translate(attachmentPos.getX(), attachmentPos.getY(), attachmentPos.getZ());
|
||||
if (manager.getModels().body().getAttributes().isSitting && entity.hasVehicle()) {
|
||||
stack.translate(0, 0.25F, 0);
|
||||
}
|
||||
}
|
||||
|
||||
stack.scale(scale, scale, scale);
|
||||
|
|
|
@ -27,7 +27,6 @@ import net.minecraft.client.render.entity.feature.*;
|
|||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRenderContext<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> {
|
||||
private final Function<Race, Models<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>>> modelsCache;
|
||||
|
@ -71,10 +70,9 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
|
|||
@Override
|
||||
protected void scale(AbstractClientPlayerEntity entity, MatrixStack stack, float tickDelta) {
|
||||
if (manager.getModels().body().getAttributes().isSitting && entity.hasVehicle()) {
|
||||
// TODO: Check this
|
||||
Vec3d attachmentPos = entity.getVehicleAttachmentPos(entity.getVehicle());
|
||||
stack.translate(attachmentPos.getX(), attachmentPos.getY(), attachmentPos.getZ());
|
||||
stack.translate(0, -0.25F * manager.getScaleFactor(), 0);
|
||||
}
|
||||
super.scale(entity, stack, tickDelta);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue