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 edw) {
        super(edw);
    }
    
    @Override
    public void render(final CampfireBlockEntity cdo, final float float2, final PoseStack dhl, final MultiBufferSource ebz, final int integer5, final int integer6) {
        final Direction fz8 = cdo.getBlockState().<Direction>getValue((Property<Direction>)CampfireBlock.FACING);
        final NonNullList<ItemStack> gi9 = cdo.getItems();
        for (int integer7 = 0; integer7 < gi9.size(); ++integer7) {
            final ItemStack bki11 = gi9.get(integer7);
            if (bki11 != ItemStack.EMPTY) {
                dhl.pushPose();
                dhl.translate(0.5, 0.44921875, 0.5);
                final Direction fz9 = Direction.from2DDataValue((integer7 + fz8.get2DDataValue()) % 4);
                final float float3 = -fz9.toYRot();
                dhl.mulPose(Vector3f.YP.rotationDegrees(float3));
                dhl.mulPose(Vector3f.XP.rotationDegrees(90.0f));
                dhl.translate(-0.3125, -0.3125, 0.0);
                dhl.scale(0.375f, 0.375f, 0.375f);
                Minecraft.getInstance().getItemRenderer().renderStatic(bki11, ItemTransforms.TransformType.FIXED, integer5, integer6, dhl, ebz);
                dhl.popPose();
            }
        }
    }
}
