package net.minecraft.client.renderer.blockentity;

import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.core.NonNullList;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.Minecraft;
import com.mojang.math.Vector3f;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.CampfireBlock;
import net.minecraft.core.Direction;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.world.level.block.entity.CampfireBlockEntity;

public class CampfireRenderer extends BlockEntityRenderer<CampfireBlockEntity> {
    public CampfireRenderer(final BlockEntityRenderDispatcher dsq) {
        super(dsq);
    }
    
    @Override
    public void render(final CampfireBlockEntity bwo, final float float2, final PoseStack cyl, final MultiBufferSource dqt, final int integer5, final int integer6) {
        final Direction fp8 = bwo.getBlockState().<Direction>getValue((Property<Direction>)CampfireBlock.FACING);
        final NonNullList<ItemStack> fy9 = bwo.getItems();
        for (int integer7 = 0; integer7 < fy9.size(); ++integer7) {
            final ItemStack ben11 = fy9.get(integer7);
            if (ben11 != ItemStack.EMPTY) {
                cyl.pushPose();
                cyl.translate(0.5, 0.44921875, 0.5);
                final Direction fp9 = Direction.from2DDataValue((integer7 + fp8.get2DDataValue()) % 4);
                final float float3 = -fp9.toYRot();
                cyl.mulPose(Vector3f.YP.rotationDegrees(float3));
                cyl.mulPose(Vector3f.XP.rotationDegrees(90.0f));
                cyl.translate(-0.3125, -0.3125, 0.0);
                cyl.scale(0.375f, 0.375f, 0.375f);
                Minecraft.getInstance().getItemRenderer().renderStatic(ben11, ItemTransforms.TransformType.FIXED, integer5, integer6, cyl, dqt);
                cyl.popPose();
            }
        }
    }
}
