package com.dairymoose.modernlife.renderer.tileentity;

import com.dairymoose.modernlife.blocks.StoveBlock;
import com.dairymoose.modernlife.tileentities.StoveBlockEntity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@OnlyIn(Dist.CLIENT)
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/renderer/tileentity/StoveBlockEntityRenderer.class */
public class StoveBlockEntityRenderer implements BlockEntityRenderer<StoveBlockEntity> {
    private static final Logger LOGGER = LogManager.getLogger();
    private static List<Double> itemPosX = new ArrayList();
    private static List<Double> itemPosY = new ArrayList();
    private static List<Double> itemPosZ = new ArrayList();

    static {
        itemPosX.add(Double.valueOf(0.4d));
        itemPosX.add(Double.valueOf(0.6d));
        itemPosY.add(Double.valueOf(0.25d));
        itemPosY.add(Double.valueOf(0.25d));
        itemPosY.add(Double.valueOf(0.25d));
        itemPosY.add(Double.valueOf(0.25d));
        itemPosY.add(Double.valueOf(0.45d));
        itemPosY.add(Double.valueOf(0.45d));
        itemPosY.add(Double.valueOf(0.45d));
        itemPosY.add(Double.valueOf(0.45d));
        itemPosZ.add(Double.valueOf(0.25d));
        itemPosZ.add(Double.valueOf(0.25d));
        itemPosZ.add(Double.valueOf(0.45d));
        itemPosZ.add(Double.valueOf(0.45d));
    }

    public StoveBlockEntityRenderer(BlockEntityRendererProvider.Context ctx) {
    }

    public void render(StoveBlockEntity tileEntity, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int lightmap, int i1) {
        if (!tileEntity.isEmpty()) {
            for (int i = 0; i < tileEntity.getContainerSize(); i++) {
                ItemStack toRender = tileEntity.getItem(i);
                matrixStack.pushPose();
                if (tileEntity.getBlockState().getValue(StoveBlock.FACING) == Direction.EAST) {
                    matrixStack.mulPose(Vector3f.YP.rotationDegrees(90.0f));
                    matrixStack.translate(-1.0d, 0.0d, 0.0d);
                } else if (tileEntity.getBlockState().getValue(StoveBlock.FACING) == Direction.NORTH) {
                    matrixStack.mulPose(Vector3f.YP.rotationDegrees(180.0f));
                    matrixStack.translate(-1.0d, 0.0d, -1.0d);
                } else if (tileEntity.getBlockState().getValue(StoveBlock.FACING) == Direction.WEST) {
                    matrixStack.mulPose(Vector3f.YP.rotationDegrees(270.0f));
                    matrixStack.translate(0.0d, 0.0d, -1.0d);
                }
                matrixStack.translate(itemPosX.get(i % itemPosX.size()).doubleValue(), itemPosY.get(i % itemPosY.size()).doubleValue(), itemPosZ.get(i % itemPosZ.size()).doubleValue());
                Direction lvt_11_1_ = Direction.NORTH;
                float f = -lvt_11_1_.toYRot();
                matrixStack.scale(0.15f, 0.15f, 0.15f);
                if (!((Boolean) tileEntity.getBlockState().getValue(StoveBlock.OPEN_DOOR)).booleanValue() && tileEntity.tickCounter % 45 == 0) {
                    Level world = tileEntity.getLevel();
                    BlockPos pos = tileEntity.getBlockPos();
                    world.addParticle(ParticleTypes.CLOUD, pos.getX() + 0.5d, pos.getY() + 0.7d, pos.getZ() + 0.5d, 0.0d, 0.1d, 0.0d);
                }
                Minecraft.getInstance().getItemRenderer().renderStatic(toRender, ItemTransforms.TransformType.FIXED, lightmap, i1, matrixStack, iRenderTypeBuffer, 0);
                matrixStack.popPose();
            }
        }
    }
}
