mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 08:14:23 +01:00
Fixed armour stand rendering
This commit is contained in:
parent
86fc15a59a
commit
4e57f6a267
8 changed files with 59 additions and 59 deletions
|
@ -2,8 +2,8 @@ package com.minelittlepony.client.model.entity;
|
|||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.entity.model.ArmorStandEntityModel;
|
||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||
import net.minecraft.client.render.entity.state.ArmorStandEntityRenderState;
|
||||
import net.minecraft.entity.decoration.ArmorStandEntity;
|
||||
|
||||
import com.minelittlepony.mson.util.PartUtil;
|
||||
|
||||
|
@ -12,20 +12,21 @@ public class PonyArmourStandModel extends ArmorStandEntityModel {
|
|||
super(modelPart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTransforms(BipedEntityModel<ArmorStandEntityRenderState> model) {
|
||||
if (model instanceof PonyArmourStandModel) {
|
||||
super.copyTransforms(model);
|
||||
} else {
|
||||
PartUtil.copyAngles(head, model.head);
|
||||
PartUtil.copyAngles(rightArm, model.rightArm);
|
||||
PartUtil.copyAngles(leftArm, model.leftArm);
|
||||
PartUtil.copyAngles(rightArm, model.rightLeg);
|
||||
PartUtil.copyAngles(leftLeg, model.leftLeg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAngles(ArmorStandEntityRenderState state) {
|
||||
super.setAngles(state);
|
||||
leftArm.visible = true;
|
||||
rightArm.visible = true;
|
||||
|
||||
if (state.leftLegRotation.equals(ArmorStandEntity.DEFAULT_LEFT_LEG_ROTATION)) {
|
||||
PartUtil.copyAngles(leftArm, leftLeg);
|
||||
leftLeg.pitch *= -1;
|
||||
}
|
||||
|
||||
if (state.rightLegRotation.equals(ArmorStandEntity.DEFAULT_RIGHT_LEG_ROTATION)) {
|
||||
PartUtil.copyAngles(rightArm, rightLeg);
|
||||
rightLeg.pitch *= -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.minecraft.client.MinecraftClient;
|
|||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import com.minelittlepony.api.model.RenderPass;
|
||||
import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
||||
|
@ -21,18 +20,8 @@ public final class DebugBoundingBoxRenderer {
|
|||
return;
|
||||
}
|
||||
|
||||
Vec3d offset = state.positionOffset;
|
||||
|
||||
stack.push();
|
||||
stack.translate(-offset.x, -offset.y, -offset.z);
|
||||
|
||||
double x = -state.x;
|
||||
double y = -state.y;
|
||||
double z = -state.z;
|
||||
|
||||
VertexConsumer vertices = matrices.getBuffer(RenderLayer.getLines());
|
||||
|
||||
VertexRendering.drawBox(stack, vertices, getBoundingBox(state).offset(x, y, z), 1, 1, 0, 1);
|
||||
VertexRendering.drawBox(stack, matrices.getBuffer(RenderLayer.getLines()), getBoundingBox(state).offset(-state.x, -state.y, -state.z), 1, 1, 0, 1);
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
|
|
|
@ -101,23 +101,9 @@ public class PlayerPonyRenderer
|
|||
|
||||
@Override
|
||||
public void render(PlayerEntityRenderState state, MatrixStack stack, VertexConsumerProvider vertices, int light) {
|
||||
// EntityModelFeatures: We have to force it to use our models otherwise EMF overrides it and breaks pony rendering
|
||||
shadowRadius = ((PlayerPonyRenderState)state).attributes.size.shadowSize();
|
||||
super.render(state, stack, vertices, light);
|
||||
DebugBoundingBoxRenderer.render((PlayerPonyRenderState)state, stack, vertices);
|
||||
|
||||
// Translate the shadow position after everything is done
|
||||
// (shadows are drawn after us)
|
||||
/*
|
||||
if (!entity.hasVehicle() && !entity.isSleeping()) {
|
||||
float yaw = MathHelper.lerpAngleDegrees(tickDelta, entity.prevBodyYaw, entity.bodyYaw);
|
||||
float l = entity.getWidth() / 2 * manager.getScaleFactor();
|
||||
|
||||
stack.multiply(RotationAxis.NEGATIVE_Y.rotationDegrees(yaw));
|
||||
stack.translate(0, 0, -l);
|
||||
stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(yaw));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,14 +10,14 @@ import net.minecraft.client.util.math.MatrixStack;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.decoration.ArmorStandEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import net.minecraft.util.math.*;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.api.model.ModelAttributes.Mode;
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.api.pony.PonyData;
|
||||
import com.minelittlepony.api.pony.meta.SizePreset;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.PonyArmourStandModel;
|
||||
import com.minelittlepony.client.model.entity.race.EarthPonyModel;
|
||||
|
@ -58,13 +58,40 @@ public class PonyStandRenderer extends LivingEntityRenderer<ArmorStandEntity, Po
|
|||
public void updateRenderState(ArmorStandEntity entity, State state, float tickDelta) {
|
||||
super.updateRenderState(entity, state, tickDelta);
|
||||
BipedEntityRenderer.updateBipedRenderState(entity, state.ponyState, tickDelta);
|
||||
state.yaw = MathHelper.lerpAngleDegrees(tickDelta, entity.prevYaw, entity.getYaw());
|
||||
state.marker = entity.isMarker();
|
||||
state.small = entity.isSmall();
|
||||
state.showArms = true;
|
||||
state.showBasePlate = entity.shouldShowBasePlate();
|
||||
state.bodyRotation = entity.getBodyRotation();
|
||||
state.headRotation = entity.getHeadRotation();
|
||||
state.leftArmRotation = entity.getLeftArmRotation();
|
||||
state.rightArmRotation = entity.getRightArmRotation();
|
||||
state.leftLegRotation = entity.getLeftLegRotation();
|
||||
state.rightLegRotation = entity.getRightLegRotation();
|
||||
state.timeSinceLastHit = (float)(entity.getWorld().getTime() - entity.lastHitTime) + tickDelta;
|
||||
|
||||
if (state.leftLegRotation.equals(ArmorStandEntity.DEFAULT_LEFT_LEG_ROTATION)) {
|
||||
state.leftLegRotation = new EulerAngle(-state.leftArmRotation.getPitch(), state.leftArmRotation.getYaw(), state.leftArmRotation.getRoll());
|
||||
}
|
||||
|
||||
if (state.rightLegRotation.equals(ArmorStandEntity.DEFAULT_RIGHT_LEG_ROTATION)) {
|
||||
state.rightLegRotation = new EulerAngle(-state.rightArmRotation.getPitch(), state.rightArmRotation.getYaw(), state.rightArmRotation.getRoll());
|
||||
}
|
||||
|
||||
context.manager.updateState(entity, state.ponyState, Mode.OTHER);
|
||||
state.ponyState.baby = state.small;
|
||||
state.ponyState.attributes.size = state.small ? SizePreset.FOAL : SizePreset.NORMAL;
|
||||
state.ponyState.equippedHeadStack = state.equippedHeadStack;
|
||||
state.pitch = MathHelper.RADIANS_PER_DEGREE * entity.getHeadRotation().getPitch();
|
||||
state.yawDegrees = MathHelper.RADIANS_PER_DEGREE * entity.getHeadRotation().getYaw();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupTransforms(State state, MatrixStack matrices, float animationProgress, float bodyYaw) {
|
||||
|
||||
context.manager.setupTransforms(state.ponyState, matrices, animationProgress, bodyYaw);
|
||||
|
||||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180 - animationProgress));
|
||||
if (state.timeSinceLastHit < 5) {
|
||||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(MathHelper.sin(state.timeSinceLastHit / 1.5F * (float) Math.PI) * 3.0F));
|
||||
|
@ -77,13 +104,9 @@ public class PonyStandRenderer extends LivingEntityRenderer<ArmorStandEntity, Po
|
|||
return entity.isCustomNameVisible();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@Override
|
||||
@Nullable
|
||||
protected RenderLayer getRenderLayer(State state, boolean showBody, boolean translucent, boolean showOutline) {
|
||||
if (context.getModel() instanceof BipedEntityModel bipedModel) {
|
||||
bipedModel.copyTransforms((BipedEntityModel)model);
|
||||
}
|
||||
if (!state.marker) {
|
||||
return super.getRenderLayer(state, showBody, translucent, showOutline);
|
||||
}
|
||||
|
@ -130,6 +153,9 @@ public class PonyStandRenderer extends LivingEntityRenderer<ArmorStandEntity, Po
|
|||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider vertices, int light, PonyStandRenderer.State state, float limbAngle, float limbDistance) {
|
||||
if (context.getModel() instanceof BipedEntityModel bipedModel) {
|
||||
model.copyTransforms(bipedModel);
|
||||
}
|
||||
((FeatureRenderer)feature).render(matrices, vertices, light, state.ponyState, limbAngle, limbDistance);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,9 +72,7 @@ public class SkeleponyRenderer<T extends AbstractSkeletonEntity> extends PonyRen
|
|||
public void updateState(LivingEntity entity, PonyModel<?> model, Pony pony, ModelAttributes.Mode mode) {
|
||||
super.updateState(entity, model, pony, mode);
|
||||
isAttacking = entity instanceof HostileEntity h && h.isAttacking();
|
||||
if (entity.getUuid().getLeastSignificantBits() % 3 == 0) {
|
||||
race = Race.EARTH;
|
||||
}
|
||||
race = entity.getUuid().getLeastSignificantBits() % 3 == 0 ? Race.EARTH : Race.UNICORN;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,12 @@ public class HeldItemFeature<
|
|||
this.context = context;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public final void render(MatrixStack matrices, VertexConsumerProvider vertices, int light, PlayerEntityRenderState state, float limbAngle, float limbDistance) {
|
||||
render(matrices, vertices, light, (S)state, limbAngle, limbDistance);
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider vertices, int light, S state, float limbAngle, float limbDistance) {
|
||||
if (!state.leftHandStack.isEmpty() || !state.rightHandStack.isEmpty()) {
|
||||
M model = context.getEquineManager().getModels().body();
|
||||
|
@ -44,9 +50,4 @@ public class HeldItemFeature<
|
|||
matrices.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void render(MatrixStack matrices, VertexConsumerProvider vertices, int light, PlayerEntityRenderState state, float limbAngle, float limbDistance) {
|
||||
render(matrices, vertices, light, (S)state, limbAngle, limbDistance);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.minelittlepony.client.render.entity.state;
|
||||
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.util.SkinTextures;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -19,6 +21,7 @@ public class PlayerPonyRenderState extends PonyRenderState {
|
|||
|
||||
@Override
|
||||
public void updateState(LivingEntity entity, PonyModel<?> model, Pony pony, ModelAttributes.Mode mode) {
|
||||
smallArms = ((ClientPlayerEntity)entity).getSkinTextures().model() == SkinTextures.Model.SLIM;
|
||||
super.updateState(entity, model, pony, mode);
|
||||
isPreviewModel = entity instanceof PreviewModel;
|
||||
wearabledTextures.clear();
|
||||
|
|
|
@ -82,11 +82,7 @@ public class PonyRenderState extends PlayerEntityRenderState implements PonyMode
|
|||
|
||||
protected float getLegOutset() {
|
||||
float outset = attributes.isLyingDown ? 3.6F : attributes.isCrouching ? 1 : 5;
|
||||
|
||||
if (smallArms) {
|
||||
return Math.max(1, outset - 1);
|
||||
}
|
||||
return outset;
|
||||
return smallArms ? Math.max(1, outset - 1) : outset;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue