public static IMySlimBlock GetSlimBlock(SyncBlockId id)
 {
     if (id == null)
     {
         return(null);
     }
     if (id.EntityId != 0)
     {
         IMyEntity entity;
         if (MyAPIGateway.Entities.TryGetEntityById(id.EntityId, out entity))
         {
             var block = entity as IMyCubeBlock;
             return(block != null ? block.SlimBlock : null);
         }
     }
     if (id.GridId != 0)
     {
         IMyEntity entity;
         if (MyAPIGateway.Entities.TryGetEntityById(id.GridId, out entity))
         {
             var grid = entity as IMyCubeGrid;
             return(grid != null?grid.GetCubeBlock(id.Position) : null);
         }
     }
     return(null);
 }
        internal void AssignReceived(SyncBlockState newState)
        {
            _Welding              = newState.Welding;
            _NeedWelding          = newState.NeedWelding;
            _CurrentWeldingBlock  = newState.CurrentWeldingBlock;
            _Grinding             = newState.Grinding;
            _CurrentGrindingBlock = newState.CurrentGrindingBlock;

            MissingComponents.Clear();
            foreach (var item in newState.MissingComponentsSync)
            {
                MissingComponents.Add(item.Component, item.Amount);
            }
            PossibleWeldTargets.Clear();
            foreach (var item in newState.PossibleWeldTargetsSync)
            {
                PossibleWeldTargets.Add(new TargetBlockData(SyncBlockId.GetSlimBlock(item.Block), item.Distance));
            }
            PossibleGrindTargets.Clear();
            foreach (var item in newState.PossibleGrindTargetsSync)
            {
                PossibleGrindTargets.Add(new TargetBlockData(SyncBlockId.GetSlimBlock(item.Block), item.Distance));
            }

            Changed = true;
        }