package com.dairymoose.modernlife.renderer.tileentity;

import com.dairymoose.modernlife.blocks.WallShelfBlock;
import com.dairymoose.modernlife.tileentities.WallShelfBlockEntity;
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.Direction;
import net.minecraft.world.item.ItemStack;
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/WallShelfBlockEntityRenderer.class */
public class WallShelfBlockEntityRenderer implements BlockEntityRenderer<WallShelfBlockEntity> {
    private static final Logger LOGGER = LogManager.getLogger();
    private static final List<Double> itemPosX = new ArrayList();
    private static final List<Double> itemPosY = new ArrayList();
    private static final List<Double> itemPosYDouble = new ArrayList();
    private static final List<Double> itemPosZ = new ArrayList();

    static {
        itemPosX.add(Double.valueOf(0.2d));
        itemPosX.add(Double.valueOf(0.5d));
        itemPosX.add(Double.valueOf(0.8d));
        itemPosY.add(Double.valueOf(0.655d));
        itemPosYDouble.add(Double.valueOf(0.43625d));
        itemPosYDouble.add(Double.valueOf(0.43625d));
        itemPosYDouble.add(Double.valueOf(0.43625d));
        itemPosYDouble.add(Double.valueOf(0.93625d));
        itemPosYDouble.add(Double.valueOf(0.93625d));
        itemPosYDouble.add(Double.valueOf(0.93625d));
        itemPosZ.add(Double.valueOf(0.199d));
    }

    public WallShelfBlockEntityRenderer(BlockEntityRendererProvider.Context ctx) {
    }

    public void render(WallShelfBlockEntity tileEntity, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int lightmap, int i1) {
        List<Double> list;
        if (!tileEntity.isEmpty()) {
            for (int i = 0; i < tileEntity.getContainerSize(); i++) {
                ItemStack toRender = tileEntity.getItem(i);
                matrixStack.pushPose();
                if (tileEntity.getBlockState().getValue(WallShelfBlock.FACING) == Direction.EAST) {
                    matrixStack.mulPose(Vector3f.YP.rotationDegrees(90.0f));
                    matrixStack.translate(-1.0d, 0.0d, 0.0d);
                } else if (tileEntity.getBlockState().getValue(WallShelfBlock.FACING) == Direction.NORTH) {
                    matrixStack.mulPose(Vector3f.YP.rotationDegrees(180.0f));
                    matrixStack.translate(-1.0d, 0.0d, -1.0d);
                } else if (tileEntity.getBlockState().getValue(WallShelfBlock.FACING) == Direction.WEST) {
                    matrixStack.mulPose(Vector3f.YP.rotationDegrees(270.0f));
                    matrixStack.translate(0.0d, 0.0d, -1.0d);
                }
                if (tileEntity.getType() == WallShelfBlockEntity.DOUBLE_WALL_SHELF) {
                    list = itemPosYDouble;
                } else {
                    list = itemPosY;
                }
                List<Double> yList = list;
                matrixStack.translate(itemPosX.get(i % itemPosX.size()).doubleValue(), yList.get(i % yList.size()).doubleValue(), itemPosZ.get(i % itemPosZ.size()).doubleValue());
                matrixStack.mulPose(Vector3f.YP.rotationDegrees(180.0f));
                matrixStack.scale(0.35f, 0.35f, 0.35f);
                Minecraft.getInstance().getItemRenderer().renderStatic(toRender, ItemTransforms.TransformType.FIXED, lightmap, i1, matrixStack, iRenderTypeBuffer, 0);
                matrixStack.popPose();
            }
        }
    }
}
