package com.dairymoose.modernlife.tileentities;

import com.dairymoose.modernlife.core.CustomBlocks;
import com.mojang.datafixers.types.Type;
import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.world.Container;
import net.minecraft.world.ContainerHelper;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/* loaded from: outputsrg.jar:com/dairymoose/modernlife/tileentities/NightStandBlockEntity.class */
public class NightStandBlockEntity extends BlockEntity implements Container {
    public static final BlockEntityType<NightStandBlockEntity> NIGHT_STAND = BlockEntityType.Builder.of(NightStandBlockEntity::new, new Block[]{(Block) CustomBlocks.BLOCK_ACACIA_NIGHT_STAND.get(), (Block) CustomBlocks.BLOCK_BIRCH_NIGHT_STAND.get(), (Block) CustomBlocks.BLOCK_CRIMSON_NIGHT_STAND.get(), (Block) CustomBlocks.BLOCK_DARK_OAK_NIGHT_STAND.get(), (Block) CustomBlocks.BLOCK_JUNGLE_NIGHT_STAND.get(), (Block) CustomBlocks.BLOCK_OAK_NIGHT_STAND.get(), (Block) CustomBlocks.BLOCK_SPRUCE_NIGHT_STAND.get(), (Block) CustomBlocks.BLOCK_WARPED_NIGHT_STAND.get(), (Block) CustomBlocks.BLOCK_ACACIA_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_ACACIA_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_BIRCH_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_BIRCH_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_CRIMSON_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_CRIMSON_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_DARK_OAK_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_DARK_OAK_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_JUNGLE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_JUNGLE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_OAK_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_OAK_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_SPRUCE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_SPRUCE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_WARPED_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_WARPED_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_COBBLESTONE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_COBBLESTONE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_STONE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_STONE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_STONE_BRICKS_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_STONE_BRICKS_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_CRACKED_STONE_BRICKS_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_CRACKED_STONE_BRICKS_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_MOSSY_STONE_BRICKS_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_MOSSY_STONE_BRICKS_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_CHISELED_STONE_BRICKS_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_CHISELED_STONE_BRICKS_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_CLAY_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_CLAY_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_SAND_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_SAND_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_RED_SAND_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_RED_SAND_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_SMOOTH_STONE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_SMOOTH_STONE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_GRAVEL_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_GRAVEL_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_GRANITE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_GRANITE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_POLISHED_GRANITE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_POLISHED_GRANITE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_DIORITE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_DIORITE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_POLISHED_DIORITE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_POLISHED_DIORITE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_OBSIDIAN_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_OBSIDIAN_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_ANDESITE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_ANDESITE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_POLISHED_ANDESITE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_POLISHED_ANDESITE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_MOSSY_COBBLESTONE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_MOSSY_COBBLESTONE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_BRICKS_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_BRICKS_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_TERRACOTTA_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_TERRACOTTA_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_SANDSTONE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_SANDSTONE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_CHISELED_SANDSTONE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_CHISELED_SANDSTONE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_CUT_SANDSTONE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_CUT_SANDSTONE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_RED_SANDSTONE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_RED_SANDSTONE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_CHISELED_RED_SANDSTONE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_CHISELED_RED_SANDSTONE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_CUT_RED_SANDSTONE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_CUT_RED_SANDSTONE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_PRISMARINE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_PRISMARINE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_PRISMARINE_BRICKS_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_PRISMARINE_BRICKS_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_DARK_PRISMARINE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_DARK_PRISMARINE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_BLACKSTONE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_BLACKSTONE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_POLISHED_BLACKSTONE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_POLISHED_BLACKSTONE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_POLISHED_BLACKSTONE_BRICKS_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_POLISHED_BLACKSTONE_BRICKS_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_CHISELED_POLISHED_BLACKSTONE_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_CHISELED_POLISHED_BLACKSTONE_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_NETHERRACK_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_NETHERRACK_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_NETHER_BRICKS_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_NETHER_BRICKS_KITCHEN_DRAWER_CABINET.get(), (Block) CustomBlocks.BLOCK_CHISELED_NETHER_BRICKS_KITCHEN_CABINET.get(), (Block) CustomBlocks.BLOCK_CHISELED_NETHER_BRICKS_KITCHEN_DRAWER_CABINET.get()}).build((Type) null);
    private static final Logger LOGGER = LogManager.getLogger();
    public static final int NIGHT_STAND_CONTAINER_SIZE = 18;
    private NonNullList<ItemStack> items;

    public NonNullList<ItemStack> getItems() {
        return this.items;
    }

    public NightStandBlockEntity(BlockPos pos, BlockState state) {
        super(NIGHT_STAND, pos, state);
        this.items = NonNullList.withSize(18, ItemStack.EMPTY);
    }

    public NightStandBlockEntity(BlockEntityType<NightStandBlockEntity> blockEntityType, BlockPos pos, BlockState state) {
        super(blockEntityType, pos, state);
        this.items = NonNullList.withSize(18, ItemStack.EMPTY);
    }

    public CompoundTag getUpdateTag() {
        CompoundTag nbt = super.getUpdateTag();
        ContainerHelper.saveAllItems(nbt, this.items);
        return nbt;
    }

    public void handleUpdateTag(CompoundTag tag) {
        ContainerHelper.loadAllItems(tag, this.items);
        super.handleUpdateTag(tag);
    }

    /* renamed from: getUpdatePacket */
    public ClientboundBlockEntityDataPacket m235getUpdatePacket() {
        return ClientboundBlockEntityDataPacket.create(this);
    }

    public void onDataPacket(Connection conn, ClientboundBlockEntityDataPacket pkt) {
        CompoundTag tag = pkt.getTag();
        if (tag != null) {
            ContainerHelper.loadAllItems(tag, this.items);
        }
    }

    public void load(CompoundTag p_230337_2_) {
        super.load(p_230337_2_);
        ContainerHelper.loadAllItems(p_230337_2_, this.items);
    }

    protected void saveAdditional(CompoundTag p_189515_1_) {
        ContainerHelper.saveAllItems(p_189515_1_, this.items);
    }

    public void m_6211_() {
        for (int i = 0; i < this.items.size(); i++) {
            this.items.set(i, ItemStack.EMPTY);
        }
    }

    public int getContainerSize() {
        return 18;
    }

    public boolean isEmpty() {
        for (int i = 0; i < this.items.size(); i++) {
            if (!((ItemStack) this.items.get(i)).isEmpty()) {
                return false;
            }
        }
        return true;
    }

    public ItemStack getItem(int var1) {
        return (ItemStack) this.items.get(var1);
    }

    public ItemStack removeItem(int var1, int var2) {
        return ContainerHelper.removeItem(this.items, var1, var2);
    }

    public ItemStack removeItemNoUpdate(int var1) {
        return ContainerHelper.takeItem(this.items, var1);
    }

    public void setItem(int var1, ItemStack var2) {
        this.items.set(var1, var2);
    }

    public boolean stillValid(Player p_70300_1_) {
        return this.level.getBlockEntity(this.worldPosition) == this && p_70300_1_.distanceToSqr(((double) this.worldPosition.getX()) + 0.5d, ((double) this.worldPosition.getY()) + 0.5d, ((double) this.worldPosition.getZ()) + 0.5d) <= 64.0d;
    }
}
