package net.minecraft.client.renderer.entity.layers;

import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.entity.Saddleable;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.client.model.EntityModel;

public class SaddleLayer<T extends Entity, M extends EntityModel<T>> extends RenderLayer<T, M> {
    private final ResourceLocation textureLocation;
    private final M model;
    
    public SaddleLayer(final RenderLayerParent<T, M> eid, final M dvv, final ResourceLocation uh) {
        super(eid);
        this.model = dvv;
        this.textureLocation = uh;
    }
    
    @Override
    public void render(final PoseStack dhl, final MultiBufferSource ebz, final int integer, final T aom, final float float5, final float float6, final float float7, final float float8, final float float9, final float float10) {
        if (!((Saddleable)aom).isSaddled()) {
            return;
        }
        this.getParentModel().copyPropertiesTo(this.model);
        this.model.prepareMobModel(aom, float5, float6, float7);
        this.model.setupAnim(aom, float5, float6, float8, float9, float10);
        final VertexConsumer dhp12 = ebz.getBuffer(RenderType.entityCutoutNoCull(this.textureLocation));
        this.model.renderToBuffer(dhl, dhp12, integer, OverlayTexture.NO_OVERLAY, 1.0f, 1.0f, 1.0f, 1.0f);
    }
}
