package net.minecraft.client.renderer.blockentity;

import net.minecraft.world.level.block.entity.BlockEntity;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.client.renderer.RenderType;
import com.mojang.math.Vector3f;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.LecternBlock;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.model.BookModel;
import net.minecraft.world.level.block.entity.LecternBlockEntity;

public class LecternRenderer extends BlockEntityRenderer<LecternBlockEntity> {
    private final BookModel bookModel;
    
    public LecternRenderer(final BlockEntityRenderDispatcher edw) {
        super(edw);
        this.bookModel = new BookModel();
    }
    
    @Override
    public void render(final LecternBlockEntity ced, final float float2, final PoseStack dhl, final MultiBufferSource ebz, final int integer5, final int integer6) {
        final BlockState cfj8 = ced.getBlockState();
        if (!cfj8.<Boolean>getValue((Property<Boolean>)LecternBlock.HAS_BOOK)) {
            return;
        }
        dhl.pushPose();
        dhl.translate(0.5, 1.0625, 0.5);
        final float float3 = cfj8.<Direction>getValue((Property<Direction>)LecternBlock.FACING).getClockWise().toYRot();
        dhl.mulPose(Vector3f.YP.rotationDegrees(-float3));
        dhl.mulPose(Vector3f.ZP.rotationDegrees(67.5f));
        dhl.translate(0.0, -0.125, 0.0);
        this.bookModel.setupAnim(0.0f, 0.1f, 0.9f, 1.2f);
        final VertexConsumer dhp10 = EnchantTableRenderer.BOOK_LOCATION.buffer(ebz, RenderType::entitySolid);
        this.bookModel.render(dhl, dhp10, integer5, integer6, 1.0f, 1.0f, 1.0f, 1.0f);
        dhl.popPose();
    }
}
