package com.dairymoose.modernlife.tileentities;

import com.dairymoose.modernlife.core.CustomBlocks;
import com.dairymoose.modernlife.core.ModernLifeCommon;
import com.mojang.datafixers.types.Type;
import java.util.LinkedHashSet;
import java.util.Set;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
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/CCTVCameraBlockEntity.class */
public class CCTVCameraBlockEntity extends BlockEntity {
    private int internalId;
    public static Set<CCTVCameraBlockEntity> cctvCameras = new LinkedHashSet();
    public static final BlockEntityType<CCTVCameraBlockEntity> CCTV_CAMERA = BlockEntityType.Builder.of(CCTVCameraBlockEntity::new, new Block[]{(Block) CustomBlocks.BLOCK_CCTV_CAMERA.get()}).build((Type) null);
    private static final Logger LOGGER = LogManager.getLogger();

    public int getInternalId() {
        return this.internalId;
    }

    public void setInternalId(int internalId) {
        this.internalId = internalId;
    }

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

    public void onDataPacket(Connection conn, ClientboundBlockEntityDataPacket pkt) {
        CompoundTag nbt = pkt.getTag();
        if (nbt != null) {
            this.internalId = nbt.getInt("InternalId");
        }
        super.onDataPacket(conn, pkt);
    }

    public CompoundTag getUpdateTag() {
        CompoundTag nbt = super.getUpdateTag();
        nbt.putInt("InternalId", this.internalId);
        return nbt;
    }

    public void handleUpdateTag(CompoundTag nbt) {
        this.internalId = nbt.getInt("InternalId");
        super.handleUpdateTag(nbt);
    }

    public void load(CompoundTag nbt) {
        super.load(nbt);
        ModernLifeCommon.LOGGER.debug("load: add to set: " + this);
        cctvCameras.add(this);
    }

    protected void saveAdditional(CompoundTag nbt) {
        nbt.putInt("InternalId", this.internalId);
    }

    public boolean equals(Object other) {
        if (other instanceof CCTVCameraBlockEntity) {
            CCTVCameraBlockEntity otherTransmitter = (CCTVCameraBlockEntity) other;
            return getBlockPos().equals(otherTransmitter.getBlockPos());
        }
        return false;
    }

    public int hashCode() {
        return getBlockPos().hashCode();
    }

    public CCTVCameraBlockEntity(BlockPos pos, BlockState state) {
        super(CCTV_CAMERA, pos, state);
        this.internalId = 0;
        ModernLifeCommon.LOGGER.debug("set position: add to set: " + this);
        cctvCameras.add(this);
    }
}
