public static List<CompoundTag> writeInventory(ItemStack[] items,int start){
  List<CompoundTag> out=new ArrayList<>();
  for (int i=0; i < items.length; i++) {
    ItemStack stack=items[i];
    if (stack != null) {
      out.add(writeItem(stack,start + i));
    }
  }
  return out;
}

public static List < CompoundTag > writeInventory ( ItemStack [ ] items , int start ) { List < CompoundTag > out = new ArrayList < > ( ) ; for ( int i = 0 ; i < items . length ; i ++ ) { ItemStack stack = items [ i ] ; if ( stack != null ) { out . add ( writeItem ( stack , start + i ) ) ; } } return out ; }
write a full inventory ( players , chests , etc . ) to a compound list .
