package com.dairymoose.modernlife.renderer.tileentity;

import com.dairymoose.modernlife.blocks.MicrowaveBlock;
import com.dairymoose.modernlife.tileentities.MicrowaveBlockEntity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
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/MicrowaveBlockEntityRenderer.class */
public class MicrowaveBlockEntityRenderer implements BlockEntityRenderer<MicrowaveBlockEntity> {
    private static final Logger LOGGER = LogManager.getLogger();
    private int tickCount = 0;

    public MicrowaveBlockEntityRenderer(BlockEntityRendererProvider.Context ctx) {
    }

    public void render(MicrowaveBlockEntity tileEntity, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int lightmap, int i1) {
        if (!tileEntity.isEmpty()) {
            matrixStack.pushPose();
            matrixStack.translate(0.5d, 0.3d, 0.5d);
            Direction lvt_11_1_ = Direction.NORTH;
            float f = -lvt_11_1_.toYRot();
            matrixStack.mulPose(Vector3f.YP.rotationDegrees(4 * tileEntity.tickCounter));
            matrixStack.scale(0.375f, 0.375f, 0.375f);
            if (!((Boolean) tileEntity.getBlockState().getValue(MicrowaveBlock.OPEN_DOOR)).booleanValue() && tileEntity.tickCounter % 15 == 0) {
                Level world = tileEntity.getLevel();
                BlockPos pos = tileEntity.getBlockPos();
                world.addParticle(ParticleTypes.SPIT, pos.getX() + 0.5d, pos.getY() + 0.5d, pos.getZ() + 0.5d, 0.0d, 0.05d, 0.0d);
            }
            ItemStack toRender = tileEntity.getItem(0);
            Minecraft.getInstance().getItemRenderer().renderStatic(toRender, ItemTransforms.TransformType.FIXED, lightmap, i1, matrixStack, iRenderTypeBuffer, 0);
            matrixStack.popPose();
            if (!((Boolean) tileEntity.getBlockState().getValue(MicrowaveBlock.OPEN_DOOR)).booleanValue()) {
                this.tickCount++;
            }
        }
    }
}
