package com.dairymoose.modernlife.renderer.tileentity;

import com.dairymoose.modernlife.blocks.WinchBlock;
import com.dairymoose.modernlife.core.CustomBlocks;
import com.dairymoose.modernlife.tileentities.WinchBlockEntity;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
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.world.level.block.Blocks;
import net.minecraft.world.level.block.ChainBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.AttachFace;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.model.data.EmptyModelData;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@OnlyIn(Dist.CLIENT)
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/renderer/tileentity/WinchBlockEntityRenderer.class */
public class WinchBlockEntityRenderer implements BlockEntityRenderer<WinchBlockEntity> {
    private static final Logger LOGGER = LogManager.getLogger();
    private int tickCount = 0;

    public WinchBlockEntityRenderer(BlockEntityRendererProvider.Context ctx) {
    }

    public boolean shouldRenderOffScreen(WinchBlockEntity winchBlockEntity) {
        return true;
    }

    public boolean shouldRender(WinchBlockEntity winchBlockEntity, Vec3 vec3) {
        return true;
    }

    public void render(WinchBlockEntity blockEntity, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int lightmap, int overlay) {
        BlockPos pos = blockEntity.getBlockPos();
        BlockState posState = blockEntity.getLevel().getBlockState(WinchBlockEntity.moveAwayFromWinch(blockEntity.getBlockState(), pos));
        if (blockEntity.isValidCeilingChain(posState) || (posState.is(CustomBlocks.BLOCK_WINCH_ANCHOR.get()) && (blockEntity.getBlockState().getValue(WinchBlock.FACE) == AttachFace.CEILING || blockEntity.getBlockState().getValue(WinchBlock.FACE) == AttachFace.FLOOR))) {
            Minecraft.getInstance().getBlockRenderer().renderSingleBlock((BlockState) Blocks.CHAIN.defaultBlockState().setValue(ChainBlock.AXIS, Direction.Axis.Y), matrixStack, iRenderTypeBuffer, lightmap, overlay, EmptyModelData.INSTANCE);
        } else if (blockEntity.isValidXChain(posState)) {
            Minecraft.getInstance().getBlockRenderer().renderSingleBlock((BlockState) Blocks.CHAIN.defaultBlockState().setValue(ChainBlock.AXIS, Direction.Axis.X), matrixStack, iRenderTypeBuffer, lightmap, overlay, EmptyModelData.INSTANCE);
        } else if (blockEntity.isValidZChain(posState)) {
            Minecraft.getInstance().getBlockRenderer().renderSingleBlock((BlockState) Blocks.CHAIN.defaultBlockState().setValue(ChainBlock.AXIS, Direction.Axis.Z), matrixStack, iRenderTypeBuffer, lightmap, overlay, EmptyModelData.INSTANCE);
        }
    }
}
