mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-25 13:57:59 +01:00
Fixed parrots on shoulders rendering at the wrong position
This commit is contained in:
parent
f73f053c06
commit
32b8c29073
1 changed files with 31 additions and 20 deletions
|
@ -10,11 +10,14 @@ import net.minecraft.client.util.math.Vector3f;
|
|||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.client.render.IPonyRenderContext;
|
||||
import com.minelittlepony.model.BodyPart;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class PassengerFeature<T extends PlayerEntity, M extends ClientPonyModel<T>> extends AbstractPonyFeature<T, M> {
|
||||
|
||||
private final ParrotEntityModel model = new ParrotEntityModel();
|
||||
|
@ -24,26 +27,34 @@ public class PassengerFeature<T extends PlayerEntity, M extends ClientPonyModel<
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
renderShoulderParrot(stack, renderContext, lightUv, entity, limbDistance, limbAngle, headYaw, headPitch, true);
|
||||
renderShoulderParrot(stack, renderContext, lightUv, entity, limbDistance, limbAngle, headYaw, headPitch, false);
|
||||
}
|
||||
|
||||
private void renderShoulderParrot(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float headYaw, float headPitch, boolean left) {
|
||||
|
||||
CompoundTag riderTag = left ? entity.getShoulderEntityLeft() : entity.getShoulderEntityRight();
|
||||
|
||||
EntityType.get(riderTag.getString("id")).filter(p -> p == EntityType.PARROT).ifPresent((entityType) -> {
|
||||
stack.push();
|
||||
|
||||
getContextModel().transform(BodyPart.BODY, stack);
|
||||
|
||||
stack.translate(left ? 0.25 : -0.25, entity.isInSneakingPose() ? -0.5 : -0.25, 0.35);
|
||||
stack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(left ? -5 : 5));
|
||||
|
||||
VertexConsumer vertexConsumer = renderContext.getBuffer(model.getLayer(ParrotEntityRenderer.TEXTURES[riderTag.getInt("Variant")]));
|
||||
model.poseOnShoulder(stack, vertexConsumer, lightUv, OverlayTexture.DEFAULT_UV, limbDistance, limbAngle, headYaw, headPitch, entity.age);
|
||||
stack.pop();
|
||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int light, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
getShoulderParrot(entity.getShoulderEntityLeft()).ifPresent(texture -> {
|
||||
renderShoulderParrot(stack, renderContext, light, entity, limbDistance, limbAngle, headYaw, headPitch, texture, 1);
|
||||
});
|
||||
getShoulderParrot(entity.getShoulderEntityRight()).ifPresent(texture -> {
|
||||
renderShoulderParrot(stack, renderContext, light, entity, limbDistance, limbAngle, headYaw, headPitch, texture, -1);
|
||||
});
|
||||
}
|
||||
|
||||
private Optional<Identifier> getShoulderParrot(CompoundTag tag) {
|
||||
return EntityType.get(tag.getString("id"))
|
||||
.filter(p -> p == EntityType.PARROT)
|
||||
.map(type -> ParrotEntityRenderer.TEXTURES[tag.getInt("Variant")]);
|
||||
}
|
||||
|
||||
private void renderShoulderParrot(MatrixStack stack, VertexConsumerProvider renderContext, int light, T entity, float limbDistance, float limbAngle, float headYaw, float headPitch, Identifier texture, int sigma) {
|
||||
stack.push();
|
||||
|
||||
getContextModel().transform(BodyPart.BODY, stack);
|
||||
|
||||
stack.translate(
|
||||
sigma * 0.25,
|
||||
entity.isInSneakingPose() ? -0.9 : -1.2,
|
||||
0.45);
|
||||
stack.multiply(Vector3f.NEGATIVE_Z.getDegreesQuaternion(sigma * -5));
|
||||
|
||||
VertexConsumer buffer = renderContext.getBuffer(model.getLayer(texture));
|
||||
model.poseOnShoulder(stack, buffer, light, OverlayTexture.DEFAULT_UV, limbDistance, limbAngle, headYaw, headPitch, entity.age);
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue