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 dsq) {
        super(dsq);
        this.bookModel = new BookModel();
    }
    
    @Override
    public void render(final LecternBlockEntity bxd, final float float2, final PoseStack cyl, final MultiBufferSource dqt, final int integer5, final int integer6) {
        final BlockState byj8 = bxd.getBlockState();
        if (!byj8.<Boolean>getValue((Property<Boolean>)LecternBlock.HAS_BOOK)) {
            return;
        }
        cyl.pushPose();
        cyl.translate(0.5, 1.0625, 0.5);
        final float float3 = byj8.<Direction>getValue((Property<Direction>)LecternBlock.FACING).getClockWise().toYRot();
        cyl.mulPose(Vector3f.YP.rotationDegrees(-float3));
        cyl.mulPose(Vector3f.ZP.rotationDegrees(67.5f));
        cyl.translate(0.0, -0.125, 0.0);
        this.bookModel.setupAnim(0.0f, 0.1f, 0.9f, 1.2f);
        final VertexConsumer cyo10 = EnchantTableRenderer.BOOK_LOCATION.buffer(dqt, RenderType::entitySolid);
        this.bookModel.render(cyl, cyo10, integer5, integer6, 1.0f, 1.0f, 1.0f, 1.0f);
        cyl.popPose();
    }
}
